static int randsheet_draw( randsheet *rs );
static void setup_lights(void);
static int drawBoard(Flipflopcreen *);
-static int display(Flipflopcreen *c);
+static int display(ModeInfo *mi);
static int draw_sheet(float *tex);
glEnable(GL_LIGHT0);
}
+static void get_texture(ModeInfo *);
+
+
ENTRYPOINT Bool
flipflop_handle_event (ModeInfo *mi, XEvent *event)
{
Flipflopcreen *c = &qs[MI_SCREEN(mi)];
- if (event->xany.type == ButtonPress &&
- event->xbutton.button == Button1)
- {
- c->button_down_p = True;
- gltrackball_start (c->trackball,
- event->xbutton.x, event->xbutton.y,
- MI_WIDTH (mi), MI_HEIGHT (mi));
- return True;
- }
- else if (event->xany.type == ButtonRelease &&
- event->xbutton.button == Button1)
- {
- c->button_down_p = False;
- return True;
- }
- else if (event->xany.type == ButtonPress &&
- (event->xbutton.button == Button4 ||
- event->xbutton.button == Button5 ||
- event->xbutton.button == Button6 ||
- event->xbutton.button == Button7))
- {
- gltrackball_mousewheel (c->trackball, event->xbutton.button, 5,
- !event->xbutton.state);
- return True;
- }
- else if (event->xany.type == MotionNotify &&
- c->button_down_p)
+ if (gltrackball_event_handler (event, c->trackball,
+ MI_WIDTH (mi), MI_HEIGHT (mi),
+ &c->button_down_p))
+ return True;
+ else if (screenhack_event_helper (MI_DISPLAY(mi), MI_WINDOW(mi), event))
+ {
+ if (!textured || c->got_texture)
{
- gltrackball_track (c->trackball,
- event->xmotion.x, event->xmotion.y,
- MI_WIDTH (mi), MI_HEIGHT (mi));
- return True;
+ textured = 1;
+ c->got_texture = False;
+ get_texture (mi);
+ return True;
}
+ }
return False;
}
static int
-display(Flipflopcreen *c)
+display(ModeInfo *mi)
{
+ Flipflopcreen *c = &qs[MI_SCREEN(mi)];
GLfloat amb[] = { 0.8, 0.8, 0.8, 1.0 };
int polys = 0;
glClear(clearbits);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
-
glLightf(GL_LIGHT0, GL_CONSTANT_ATTENUATION, 1.2);
glLightf(GL_LIGHT0, GL_LINEAR_ATTENUATION, 0.15/board_avg_size );
glLightf(GL_LIGHT0, GL_QUADRATIC_ATTENUATION, 0.15/board_avg_size );
/** setup perspectif */
glTranslatef(0.0, 0.0, -c->reldist*board_avg_size);
glRotatef(22.5, 1.0, 0.0, 0.0);
- glRotatef(-current_device_rotation(), 0, 0, 1);
gltrackball_rotate (c->trackball);
- glRotatef(current_device_rotation(), 0, 0, 1);
glRotatef(c->theta*100, 0.0, 1.0, 0.0);
glTranslatef(-0.5*board_x_size, 0.0, -0.5*board_y_size); /* Center the board */
if(textured)
glBindTexture(GL_TEXTURE_2D, c->texid);
+# ifdef HAVE_MOBILE /* Keep it the same relative size when rotated. */
+ {
+ GLfloat h = MI_HEIGHT(mi) / (GLfloat) MI_WIDTH(mi);
+ int o = (int) current_device_rotation();
+ if (o != 0 && o != 180 && o != -180)
+ glScalef (1/h, 1/h, 1/h);
+ }
+# endif
+
polys = drawBoard(c);
if (!c->button_down_p) {
c = &qs[screen];
c->window = MI_WINDOW(mi);
- c->trackball = gltrackball_init ();
+ c->trackball = gltrackball_init (False);
c->flipspeed = 0.03;
c->reldist = 1;
glXMakeCurrent(disp, w, *(c->glx_context));
- mi->polygon_count = display(c);
+ mi->polygon_count = display(mi);
if(mi->fps_p){
do_fps(mi);