… | |
… | |
491 | void |
491 | void |
492 | SDL_PollEvent () |
492 | SDL_PollEvent () |
493 | PPCODE: |
493 | PPCODE: |
494 | { |
494 | { |
495 | SDL_Event ev; |
495 | SDL_Event ev; |
|
|
496 | int i; |
|
|
497 | static int modifier; |
|
|
498 | static int modkey[] = { |
|
|
499 | SDLK_RSHIFT, KMOD_RSHIFT, |
|
|
500 | SDLK_LSHIFT, KMOD_LSHIFT, |
|
|
501 | SDLK_RCTRL, KMOD_RCTRL, |
|
|
502 | SDLK_LCTRL, KMOD_LCTRL, |
|
|
503 | SDLK_RALT, KMOD_RALT, |
|
|
504 | SDLK_LALT, KMOD_LALT, |
|
|
505 | SDLK_RMETA, KMOD_RMETA, |
|
|
506 | SDLK_LMETA, KMOD_LMETA, |
|
|
507 | }; |
496 | |
508 | |
497 | while (SDL_PollEvent (&ev)) |
509 | while (SDL_PollEvent (&ev)) |
498 | { |
510 | { |
499 | HV *hv = newHV (); |
511 | HV *hv = newHV (); |
500 | hv_store (hv, "type", 4, newSViv (ev.type), 0); |
512 | hv_store (hv, "type", 4, newSViv (ev.type), 0); |
501 | |
513 | |
502 | switch (ev.type) |
514 | switch (ev.type) |
503 | { |
515 | { |
504 | case SDL_KEYDOWN: |
516 | case SDL_KEYDOWN: |
505 | case SDL_KEYUP: |
517 | case SDL_KEYUP: |
|
|
518 | |
|
|
519 | for (i = 0; i < sizeof (modkey) / (sizeof (int) * 2); i++) |
|
|
520 | if (modkey [i * 2] == ev.key.keysym.sym) |
|
|
521 | { |
|
|
522 | if (ev.type == SDL_KEYDOWN) |
|
|
523 | modifier |= modkey [i * 2 + 1]; |
|
|
524 | else |
|
|
525 | modifier &= ~modkey [i * 2 + 1]; |
|
|
526 | break; |
|
|
527 | } |
|
|
528 | |
506 | hv_store (hv, "state", 5, newSViv (ev.key.state), 0); |
529 | hv_store (hv, "state", 5, newSViv (ev.key.state), 0); |
507 | hv_store (hv, "sym", 3, newSViv (ev.key.keysym.sym), 0); |
530 | hv_store (hv, "sym", 3, newSViv (ev.key.keysym.sym), 0); |
508 | hv_store (hv, "mod", 3, newSViv (ev.key.keysym.mod), 0); |
531 | hv_store (hv, "mod", 3, newSViv (ev.key.keysym.mod), 0); |
509 | hv_store (hv, "unicode", 7, newSViv (ev.key.keysym.unicode), 0); |
532 | hv_store (hv, "unicode", 7, newSViv (ev.key.keysym.unicode), 0); |
510 | break; |
533 | break; |
… | |
… | |
513 | hv_store (hv, "gain", 4, newSViv (ev.active.gain), 0); |
536 | hv_store (hv, "gain", 4, newSViv (ev.active.gain), 0); |
514 | hv_store (hv, "state", 5, newSViv (ev.active.state), 0); |
537 | hv_store (hv, "state", 5, newSViv (ev.active.state), 0); |
515 | break; |
538 | break; |
516 | |
539 | |
517 | case SDL_MOUSEMOTION: |
540 | case SDL_MOUSEMOTION: |
|
|
541 | hv_store (hv, "mod", 3, newSViv (modifier), 0); |
|
|
542 | |
518 | hv_store (hv, "state", 5, newSViv (ev.motion.state), 0); |
543 | hv_store (hv, "state", 5, newSViv (ev.motion.state), 0); |
519 | hv_store (hv, "x", 1, newSViv (ev.motion.x), 0); |
544 | hv_store (hv, "x", 1, newSViv (ev.motion.x), 0); |
520 | hv_store (hv, "y", 1, newSViv (ev.motion.y), 0); |
545 | hv_store (hv, "y", 1, newSViv (ev.motion.y), 0); |
521 | hv_store (hv, "xrel", 4, newSViv (ev.motion.xrel), 0); |
546 | hv_store (hv, "xrel", 4, newSViv (ev.motion.xrel), 0); |
522 | hv_store (hv, "yrel", 4, newSViv (ev.motion.yrel), 0); |
547 | hv_store (hv, "yrel", 4, newSViv (ev.motion.yrel), 0); |
523 | break; |
548 | break; |
524 | |
549 | |
525 | case SDL_MOUSEBUTTONDOWN: |
550 | case SDL_MOUSEBUTTONDOWN: |
526 | case SDL_MOUSEBUTTONUP: |
551 | case SDL_MOUSEBUTTONUP: |
|
|
552 | hv_store (hv, "mod", 3, newSViv (modifier), 0); |
|
|
553 | |
527 | hv_store (hv, "button", 6, newSViv (ev.button.button), 0); |
554 | hv_store (hv, "button", 6, newSViv (ev.button.button), 0); |
528 | hv_store (hv, "state", 5, newSViv (ev.button.state), 0); |
555 | hv_store (hv, "state", 5, newSViv (ev.button.state), 0); |
529 | hv_store (hv, "x", 1, newSViv (ev.button.x), 0); |
556 | hv_store (hv, "x", 1, newSViv (ev.button.x), 0); |
530 | hv_store (hv, "y", 1, newSViv (ev.button.y), 0); |
557 | hv_store (hv, "y", 1, newSViv (ev.button.y), 0); |
531 | break; |
558 | break; |
… | |
… | |
557 | lowdelay (int fd, int val = 1) |
584 | lowdelay (int fd, int val = 1) |
558 | CODE: |
585 | CODE: |
559 | #ifndef _WIN32 |
586 | #ifndef _WIN32 |
560 | setsockopt (fd, IPPROTO_TCP, TCP_NODELAY, &val, sizeof (val)); |
587 | setsockopt (fd, IPPROTO_TCP, TCP_NODELAY, &val, sizeof (val)); |
561 | #endif |
588 | #endif |
|
|
589 | |
|
|
590 | char * |
|
|
591 | gl_vendor () |
|
|
592 | CODE: |
|
|
593 | RETVAL = (char *)glGetString (GL_VENDOR); |
|
|
594 | OUTPUT: |
|
|
595 | RETVAL |
562 | |
596 | |
563 | char * |
597 | char * |
564 | gl_version () |
598 | gl_version () |
565 | CODE: |
599 | CODE: |
566 | RETVAL = (char *)glGetString (GL_VERSION); |
600 | RETVAL = (char *)glGetString (GL_VERSION); |
… | |
… | |
1635 | |
1669 | |
1636 | void glPopMatrix () |
1670 | void glPopMatrix () |
1637 | |
1671 | |
1638 | void glLoadIdentity () |
1672 | void glLoadIdentity () |
1639 | |
1673 | |
1640 | # near and far are due to microsofts buggy c compiler |
1674 | # near_ and far_ are due to microsofts buggy "c" compiler |
|
|
1675 | void glFrustum (double left, double right, double bottom, double top, double near_, double far_) |
|
|
1676 | |
|
|
1677 | # near_ and far_ are due to microsofts buggy "c" compiler |
1641 | void glOrtho (double left, double right, double bottom, double top, double near_, double far_) |
1678 | void glOrtho (double left, double right, double bottom, double top, double near_, double far_) |
1642 | |
1679 | |
1643 | void glViewport (int x, int y, int width, int height) |
1680 | void glViewport (int x, int y, int width, int height) |
1644 | |
1681 | |
1645 | void glScissor (int x, int y, int width, int height) |
1682 | void glScissor (int x, int y, int width, int height) |
… | |
… | |
1661 | void glEnd () |
1698 | void glEnd () |
1662 | |
1699 | |
1663 | void glColor (float r, float g, float b, float a = 1.0) |
1700 | void glColor (float r, float g, float b, float a = 1.0) |
1664 | PROTOTYPE: @ |
1701 | PROTOTYPE: @ |
1665 | CODE: |
1702 | CODE: |
|
|
1703 | // microsoft visual "c" rounds instead of truncating... |
1666 | glColor4ub (MIN ((int)(r * 255.f), 255), |
1704 | glColor4ub (MIN ((int)(r * 255.f), 255), |
1667 | MIN ((int)(g * 255.f), 255), |
1705 | MIN ((int)(g * 255.f), 255), |
1668 | MIN ((int)(b * 255.f), 255), |
1706 | MIN ((int)(b * 255.f), 255), |
1669 | MIN ((int)(a * 255.f), 255)); |
1707 | MIN ((int)(a * 255.f), 255)); |
1670 | |
1708 | |
… | |
… | |
1672 | |
1710 | |
1673 | void glDrawElements (int mode, int count, int type, char *indices) |
1711 | void glDrawElements (int mode, int count, int type, char *indices) |
1674 | |
1712 | |
1675 | # 1.2 void glDrawRangeElements (int mode, int start, int end |
1713 | # 1.2 void glDrawRangeElements (int mode, int start, int end |
1676 | |
1714 | |
|
|
1715 | void glRasterPos (float x, float y, float z = 0.) |
|
|
1716 | CODE: |
|
|
1717 | glRasterPos3f (0, 0, z); |
|
|
1718 | glBitmap (0, 0, 0, 0, x, y, 0); |
|
|
1719 | |
1677 | void glVertex (float x, float y, float z = 0.) |
1720 | void glVertex (float x, float y, float z = 0.) |
1678 | CODE: |
1721 | CODE: |
1679 | glVertex3f (x, y, z); |
1722 | glVertex3f (x, y, z); |
1680 | |
1723 | |
1681 | void glTexCoord (float s, float t) |
1724 | void glTexCoord (float s, float t) |
… | |
… | |
1708 | |
1751 | |
1709 | void glTexImage2D (int target, int level, int internalformat, int width, int height, int border, int format, int type, char *data) |
1752 | void glTexImage2D (int target, int level, int internalformat, int width, int height, int border, int format, int type, char *data) |
1710 | |
1753 | |
1711 | void glCopyTexImage2D (int target, int level, int internalformat, int x, int y, int width, int height, int border) |
1754 | void glCopyTexImage2D (int target, int level, int internalformat, int x, int y, int width, int height, int border) |
1712 | |
1755 | |
1713 | void glRasterPos (int x, int y) |
1756 | void glDrawPixels (int width, int height, int format, int type, char *pixels) |
1714 | CODE: |
|
|
1715 | glRasterPos2i (x, y); |
|
|
1716 | |
1757 | |
1717 | void glCopyPixels (int x, int y, int width, int height, int type = GL_COLOR) |
1758 | void glCopyPixels (int x, int y, int width, int height, int type = GL_COLOR) |
1718 | |
1759 | |
1719 | int glGenTexture () |
1760 | int glGenTexture () |
1720 | CODE: |
1761 | CODE: |