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.97 by root, Fri May 26 18:28:23 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;
1117 tex->r = r; 1076 tex->r = r;
1118 tex->g = g; 1077 tex->g = g;
1119 tex->b = b; 1078 tex->b = b;
1120 tex->a = a; 1079 tex->a = a;
1121 } 1080 }
1081
1082 // somewhat hackish, but for textures that require it, it really
1083 // improves the look, and most others don't suffer.
1084 glBindTexture (GL_TEXTURE_2D, name);
1085 glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
1086 glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
1122} 1087}
1123 1088
1124int 1089int
1125ox (CFClient::Map self) 1090ox (CFClient::Map self)
1126 ALIAS: 1091 ALIAS:
1638 1603
1639 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) 1604 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; )
1640 newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); 1605 newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv));
1641} 1606}
1642 1607
1608char *
1609gl_vendor ()
1610 CODE:
1611 RETVAL = (char *)glGetString (GL_VENDOR);
1612 OUTPUT:
1613 RETVAL
1614
1615char *
1616gl_version ()
1617 CODE:
1618 RETVAL = (char *)glGetString (GL_VERSION);
1619 OUTPUT:
1620 RETVAL
1621
1622char *
1623gl_extensions ()
1624 CODE:
1625 RETVAL = (char *)glGetString (GL_EXTENSIONS);
1626 OUTPUT:
1627 RETVAL
1628
1643int glGetError () 1629int glGetError ()
1644 1630
1645void glClear (int mask) 1631void glClear (int mask)
1646 1632
1647void glClearColor (float r, float g, float b, float a = 1.0) 1633void glClearColor (float r, float g, float b, float a = 1.0)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines