Ver código fonte

* OpenGL driver mouse support

tags/v0.99.beta14
Jean-Yves Lamoureux jylam 19 anos atrás
pai
commit
7faa9019fd
2 arquivos alterados com 39 adições e 5 exclusões
  1. +15
    -4
      src/event.c
  2. +24
    -1
      src/graphics.c

+ 15
- 4
src/event.c Ver arquivo

@@ -64,7 +64,9 @@ extern float gl_font_width;
extern float gl_font_height;
extern int gl_new_width;
extern int gl_new_height;

extern unsigned char gl_mouse_changed, gl_mouse_clicked;
extern unsigned int gl_mouse_x, gl_mouse_y;
extern unsigned int gl_mouse_button, gl_mouse_state;
#endif
#include "caca.h"
#include "caca_internals.h"
@@ -746,14 +748,23 @@ static unsigned int _lowlevel_event(void)
{
if(!_caca_resize)
{


_caca_resize = 1;
gl_resized=0;
return CACA_EVENT_RESIZE;
}
}

if(gl_mouse_changed)
{
if(gl_mouse_clicked)
{
event|= CACA_EVENT_MOUSE_PRESS | gl_mouse_button;
gl_mouse_clicked=0;
}
mouse_x = gl_mouse_x;
mouse_y = gl_mouse_y;
event |= CACA_EVENT_MOUSE_MOTION | (mouse_x << 12) | mouse_y;
gl_mouse_changed = 0;
}
if(gl_key!=0)
{
event |= CACA_EVENT_KEY_PRESS;


+ 24
- 1
src/graphics.c Ver arquivo

@@ -265,6 +265,9 @@ float gl_font_width, gl_font_height;
float gl_incx, gl_incy;
int id[94];
unsigned char gl_resized=0, gl_bit=0;
unsigned char gl_mouse_changed=0, gl_mouse_clicked=0;
unsigned int gl_mouse_x, gl_mouse_y;
unsigned int gl_mouse_button=0, gl_mouse_state=0;
#endif


@@ -324,8 +327,23 @@ static void gl_handle_reshape (int w, int h)
}
else
gl_bit=1;

}
static void gl_handle_mouse(int button, int state, int x, int y)
{
gl_mouse_clicked = 1;
gl_mouse_button = button;
gl_mouse_state = state;
gl_mouse_x = x/gl_font_width;
gl_mouse_y = y/gl_font_height;
gl_mouse_changed = 1;
}
static void gl_handle_mouse_motion(int x, int y)
{
gl_mouse_x = x/gl_font_width;
gl_mouse_y = y/gl_font_height;
gl_mouse_changed = 1;
}

#endif


@@ -1008,6 +1026,11 @@ int _caca_init_graphics(void)
glutSpecialFunc(gl_handle_special_key);
glutReshapeFunc(gl_handle_reshape);

glutMouseFunc(gl_handle_mouse);
glutMotionFunc(gl_handle_mouse_motion);
glutPassiveMotionFunc(gl_handle_mouse_motion);


glLoadIdentity();

glMatrixMode(GL_PROJECTION);


Carregando…
Cancelar
Salvar