ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra-Client/Client.xs
(Generate patch)

Comparing deliantra/Deliantra-Client/Client.xs (file contents):
Revision 1.93 by root, Tue May 23 18:54:37 2006 UTC vs.
Revision 1.100 by root, Wed May 31 17:16:47 2006 UTC

486 RETVAL 486 RETVAL
487 487
488void 488void
489SDL_GL_SwapBuffers () 489SDL_GL_SwapBuffers ()
490 490
491char *
492SDL_GetKeyName (int sym)
493
491void 494void
492SDL_PollEvent () 495SDL_PollEvent ()
493 PPCODE: 496 PPCODE:
494{ 497{
495 SDL_Event ev; 498 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 };
508 499
509 while (SDL_PollEvent (&ev)) 500 while (SDL_PollEvent (&ev))
510 { 501 {
511 HV *hv = newHV (); 502 HV *hv = newHV ();
512 hv_store (hv, "type", 4, newSViv (ev.type), 0); 503 hv_store (hv, "type", 4, newSViv (ev.type), 0);
513 504
514 switch (ev.type) 505 switch (ev.type)
515 { 506 {
516 case SDL_KEYDOWN: 507 case SDL_KEYDOWN:
517 case SDL_KEYUP: 508 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
529 hv_store (hv, "state", 5, newSViv (ev.key.state), 0); 509 hv_store (hv, "state", 5, newSViv (ev.key.state), 0);
530 hv_store (hv, "sym", 3, newSViv (ev.key.keysym.sym), 0); 510 hv_store (hv, "sym", 3, newSViv (ev.key.keysym.sym), 0);
531 hv_store (hv, "mod", 3, newSViv (ev.key.keysym.mod), 0); 511 hv_store (hv, "mod", 3, newSViv (ev.key.keysym.mod), 0);
532 hv_store (hv, "unicode", 7, newSViv (ev.key.keysym.unicode), 0); 512 hv_store (hv, "unicode", 7, newSViv (ev.key.keysym.unicode), 0);
533 break; 513 break;
536 hv_store (hv, "gain", 4, newSViv (ev.active.gain), 0); 516 hv_store (hv, "gain", 4, newSViv (ev.active.gain), 0);
537 hv_store (hv, "state", 5, newSViv (ev.active.state), 0); 517 hv_store (hv, "state", 5, newSViv (ev.active.state), 0);
538 break; 518 break;
539 519
540 case SDL_MOUSEMOTION: 520 case SDL_MOUSEMOTION:
541 hv_store (hv, "mod", 3, newSViv (modifier), 0); 521 hv_store (hv, "mod", 3, newSViv (SDL_GetModState ()), 0);
542 522
543 hv_store (hv, "state", 5, newSViv (ev.motion.state), 0); 523 hv_store (hv, "state", 5, newSViv (ev.motion.state), 0);
544 hv_store (hv, "x", 1, newSViv (ev.motion.x), 0); 524 hv_store (hv, "x", 1, newSViv (ev.motion.x), 0);
545 hv_store (hv, "y", 1, newSViv (ev.motion.y), 0); 525 hv_store (hv, "y", 1, newSViv (ev.motion.y), 0);
546 hv_store (hv, "xrel", 4, newSViv (ev.motion.xrel), 0); 526 hv_store (hv, "xrel", 4, newSViv (ev.motion.xrel), 0);
547 hv_store (hv, "yrel", 4, newSViv (ev.motion.yrel), 0); 527 hv_store (hv, "yrel", 4, newSViv (ev.motion.yrel), 0);
548 break; 528 break;
549 529
550 case SDL_MOUSEBUTTONDOWN: 530 case SDL_MOUSEBUTTONDOWN:
551 case SDL_MOUSEBUTTONUP: 531 case SDL_MOUSEBUTTONUP:
552 hv_store (hv, "mod", 3, newSViv (modifier), 0); 532 hv_store (hv, "mod", 3, newSViv (SDL_GetModState ()), 0);
553 533
554 hv_store (hv, "button", 6, newSViv (ev.button.button), 0); 534 hv_store (hv, "button", 6, newSViv (ev.button.button), 0);
555 hv_store (hv, "state", 5, newSViv (ev.button.state), 0); 535 hv_store (hv, "state", 5, newSViv (ev.button.state), 0);
556 hv_store (hv, "x", 1, newSViv (ev.button.x), 0); 536 hv_store (hv, "x", 1, newSViv (ev.button.x), 0);
557 hv_store (hv, "y", 1, newSViv (ev.button.y), 0); 537 hv_store (hv, "y", 1, newSViv (ev.button.y), 0);
584lowdelay (int fd, int val = 1) 564lowdelay (int fd, int val = 1)
585 CODE: 565 CODE:
586#ifndef _WIN32 566#ifndef _WIN32
587 setsockopt (fd, IPPROTO_TCP, TCP_NODELAY, &val, sizeof (val)); 567 setsockopt (fd, IPPROTO_TCP, TCP_NODELAY, &val, sizeof (val));
588#endif 568#endif
589
590char *
591gl_vendor ()
592 CODE:
593 RETVAL = (char *)glGetString (GL_VENDOR);
594 OUTPUT:
595 RETVAL
596
597char *
598gl_version ()
599 CODE:
600 RETVAL = (char *)glGetString (GL_VERSION);
601 OUTPUT:
602 RETVAL
603
604char *
605gl_extensions ()
606 CODE:
607 RETVAL = (char *)glGetString (GL_EXTENSIONS);
608 OUTPUT:
609 RETVAL
610 569
611void 570void
612add_font (char *file) 571add_font (char *file)
613 CODE: 572 CODE:
614 FcConfigAppFontAddFile (0, (const FcChar8 *)file); /* no idea wether this is required */ 573 FcConfigAppFontAddFile (0, (const FcChar8 *)file); /* no idea wether this is required */
751 710
752CFClient::Layout 711CFClient::Layout
753new (SV *class, int rgba = 0) 712new (SV *class, int rgba = 0)
754 CODE: 713 CODE:
755#if _WIN32 714#if _WIN32
756 rgba = 0;//D 715 //rgba = 0;//D make stext nicer, breaks TextView
757#endif 716#endif
758 New (0, RETVAL, 1, struct cf_layout); 717 New (0, RETVAL, 1, struct cf_layout);
759 718
760 RETVAL->pl = pango_layout_new (rgba ? cairo_context : ft2_context); 719 RETVAL->pl = pango_layout_new (rgba ? cairo_context : ft2_context);
761 RETVAL->rgba = rgba; 720 RETVAL->rgba = rgba;
1008{ 967{
1009 HV *hv = (HV *)SvRV (self); 968 HV *hv = (HV *)SvRV (self);
1010 float s = SvNV (*hv_fetch (hv, "s", 1, 1)); 969 float s = SvNV (*hv_fetch (hv, "s", 1, 1));
1011 float t = SvNV (*hv_fetch (hv, "t", 1, 1)); 970 float t = SvNV (*hv_fetch (hv, "t", 1, 1));
1012 int name = SvIV (*hv_fetch (hv, "name", 4, 1)); 971 int name = SvIV (*hv_fetch (hv, "name", 4, 1));
1013 int wrap_mode = SvIV (*hv_fetch (hv, "wrap_mode", 9, 1));
1014 972
1015 if (items < 5) 973 if (items < 5)
1016 { 974 {
1017 w = SvNV (*hv_fetch (hv, "w", 1, 1)); 975 w = SvNV (*hv_fetch (hv, "w", 1, 1));
1018 h = SvNV (*hv_fetch (hv, "h", 1, 1)); 976 h = SvNV (*hv_fetch (hv, "h", 1, 1));
1025 glEnable (GL_ALPHA_TEST); 983 glEnable (GL_ALPHA_TEST);
1026 glAlphaFunc (GL_GREATER, 0.01f); 984 glAlphaFunc (GL_GREATER, 0.01f);
1027 } 985 }
1028 986
1029 glBindTexture (GL_TEXTURE_2D, name); 987 glBindTexture (GL_TEXTURE_2D, name);
1030
1031 if (wrap_mode)
1032 {
1033 glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
1034 glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
1035 }
1036 988
1037 glBegin (GL_QUADS); 989 glBegin (GL_QUADS);
1038 glTexCoord2f (0, 0); glVertex2f (x , y ); 990 glTexCoord2f (0, 0); glVertex2f (x , y );
1039 glTexCoord2f (0, t); glVertex2f (x , y + h); 991 glTexCoord2f (0, t); glVertex2f (x , y + h);
1040 glTexCoord2f (s, t); glVertex2f (x + w, y + h); 992 glTexCoord2f (s, t); glVertex2f (x + w, y + h);
1117 tex->r = r; 1069 tex->r = r;
1118 tex->g = g; 1070 tex->g = g;
1119 tex->b = b; 1071 tex->b = b;
1120 tex->a = a; 1072 tex->a = a;
1121 } 1073 }
1074
1075 // somewhat hackish, but for textures that require it, it really
1076 // improves the look, and most others don't suffer.
1077 glBindTexture (GL_TEXTURE_2D, name);
1078 //glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
1079 //glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
1080 // use uglier nearest interpolation because linear suffers
1081 // from transparent color bleeding and ugly wrapping effects.
1082 glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
1122} 1083}
1123 1084
1124int 1085int
1125ox (CFClient::Map self) 1086ox (CFClient::Map self)
1126 ALIAS: 1087 ALIAS:
1597 const_iv (GL_TEXTURE_MAG_FILTER), 1558 const_iv (GL_TEXTURE_MAG_FILTER),
1598 const_iv (GL_TEXTURE_MIN_FILTER), 1559 const_iv (GL_TEXTURE_MIN_FILTER),
1599 const_iv (GL_TEXTURE_ENV_MODE), 1560 const_iv (GL_TEXTURE_ENV_MODE),
1600 const_iv (GL_TEXTURE_WRAP_S), 1561 const_iv (GL_TEXTURE_WRAP_S),
1601 const_iv (GL_TEXTURE_WRAP_T), 1562 const_iv (GL_TEXTURE_WRAP_T),
1563 const_iv (GL_REPEAT),
1602 const_iv (GL_CLAMP), 1564 const_iv (GL_CLAMP),
1603 const_iv (GL_REPEAT), 1565 const_iv (GL_CLAMP_TO_EDGE),
1604 const_iv (GL_NEAREST), 1566 const_iv (GL_NEAREST),
1605 const_iv (GL_LINEAR), 1567 const_iv (GL_LINEAR),
1606 const_iv (GL_NEAREST_MIPMAP_NEAREST), 1568 const_iv (GL_NEAREST_MIPMAP_NEAREST),
1607 const_iv (GL_LINEAR_MIPMAP_NEAREST), 1569 const_iv (GL_LINEAR_MIPMAP_NEAREST),
1608 const_iv (GL_NEAREST_MIPMAP_LINEAR), 1570 const_iv (GL_NEAREST_MIPMAP_LINEAR),
1638 1600
1639 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) 1601 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; )
1640 newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); 1602 newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv));
1641} 1603}
1642 1604
1605char *
1606gl_vendor ()
1607 CODE:
1608 RETVAL = (char *)glGetString (GL_VENDOR);
1609 OUTPUT:
1610 RETVAL
1611
1612char *
1613gl_version ()
1614 CODE:
1615 RETVAL = (char *)glGetString (GL_VERSION);
1616 OUTPUT:
1617 RETVAL
1618
1619char *
1620gl_extensions ()
1621 CODE:
1622 RETVAL = (char *)glGetString (GL_EXTENSIONS);
1623 OUTPUT:
1624 RETVAL
1625
1643int glGetError () 1626int glGetError ()
1644 1627
1645void glClear (int mask) 1628void glClear (int mask)
1646 1629
1647void glClearColor (float r, float g, float b, float a = 1.0) 1630void glClearColor (float r, float g, float b, float a = 1.0)
1699 1682
1700void glColor (float r, float g, float b, float a = 1.0) 1683void glColor (float r, float g, float b, float a = 1.0)
1701 PROTOTYPE: @ 1684 PROTOTYPE: @
1702 CODE: 1685 CODE:
1703 // microsoft visual "c" rounds instead of truncating... 1686 // microsoft visual "c" rounds instead of truncating...
1704 glColor4ub (MIN ((int)(r * 255.f), 255), 1687 glColor4ub (MIN ((int)(r * 256.f), 255),
1705 MIN ((int)(g * 255.f), 255), 1688 MIN ((int)(g * 256.f), 255),
1706 MIN ((int)(b * 255.f), 255), 1689 MIN ((int)(b * 256.f), 255),
1707 MIN ((int)(a * 255.f), 255)); 1690 MIN ((int)(a * 256.f), 255));
1708 1691
1709void glInterleavedArrays (int format, int stride, char *data) 1692void glInterleavedArrays (int format, int stride, char *data)
1710 1693
1711void glDrawElements (int mode, int count, int type, char *indices) 1694void glDrawElements (int mode, int count, int type, char *indices)
1712 1695

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines