Changeset 493


Ignore:
Timestamp:
Jun 25, 2005, 1:27:31 PM (16 years ago)
Author:
Jean-Yves Lamoureux
Message:
  • OpenGL driver mouse support
Location:
libcaca/trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • libcaca/trunk/src/event.c

    r487 r493  
    6565extern int gl_new_width;
    6666extern int gl_new_height;
    67 
     67extern unsigned char gl_mouse_changed, gl_mouse_clicked;
     68extern unsigned int gl_mouse_x, gl_mouse_y;
     69extern unsigned int gl_mouse_button, gl_mouse_state;
    6870#endif
    6971#include "caca.h"
     
    747749              if(!_caca_resize)
    748750                {
    749 
    750 
    751751                  _caca_resize = 1;
    752752                  gl_resized=0;
     
    754754                }
    755755            }
    756 
     756          if(gl_mouse_changed)
     757            {
     758              if(gl_mouse_clicked)
     759                {
     760                  event|= CACA_EVENT_MOUSE_PRESS | gl_mouse_button;
     761                  gl_mouse_clicked=0;
     762                }
     763              mouse_x = gl_mouse_x;
     764              mouse_y = gl_mouse_y;
     765              event |= CACA_EVENT_MOUSE_MOTION | (mouse_x << 12) | mouse_y;
     766              gl_mouse_changed = 0;
     767            }
    757768          if(gl_key!=0)
    758769            {
  • libcaca/trunk/src/graphics.c

    r491 r493  
    266266int id[94];
    267267unsigned char gl_resized=0, gl_bit=0;
     268unsigned char gl_mouse_changed=0, gl_mouse_clicked=0;
     269unsigned int gl_mouse_x, gl_mouse_y;
     270unsigned int gl_mouse_button=0, gl_mouse_state=0;
    268271#endif
    269272
     
    325328  else
    326329    gl_bit=1;
    327 
    328 }
     330}
     331static void gl_handle_mouse(int button, int state, int x, int y)
     332{
     333  gl_mouse_clicked = 1;
     334  gl_mouse_button = button;
     335  gl_mouse_state = state;
     336  gl_mouse_x = x/gl_font_width;
     337  gl_mouse_y = y/gl_font_height;
     338  gl_mouse_changed = 1;
     339}
     340static void gl_handle_mouse_motion(int x, int y)
     341{
     342  gl_mouse_x = x/gl_font_width;
     343  gl_mouse_y = y/gl_font_height;
     344  gl_mouse_changed = 1;
     345}
     346
    329347#endif
    330348
     
    10091027          glutReshapeFunc(gl_handle_reshape);
    10101028
     1029          glutMouseFunc(gl_handle_mouse);
     1030          glutMotionFunc(gl_handle_mouse_motion);
     1031          glutPassiveMotionFunc(gl_handle_mouse_motion);
     1032
     1033
    10111034          glLoadIdentity();
    10121035
Note: See TracChangeset for help on using the changeset viewer.