X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?p=xscreensaver;a=blobdiff_plain;f=hacks%2Fglx%2Fsurfaces.c;h=165264895d15b0838f3771f75a48ff3261d12569;hp=9dac523bfb649778a38ad5aae086feccefa4fc75;hb=4361b69d3178d7fc98d0388f9a223af6c2651aba;hpb=6f5482d73adb0165c0130bb47d852644ab0c4869 diff --git a/hacks/glx/surfaces.c b/hacks/glx/surfaces.c index 9dac523b..16526489 100644 --- a/hacks/glx/surfaces.c +++ b/hacks/glx/surfaces.c @@ -43,9 +43,11 @@ #ifdef STANDALONE # define DEFAULTS "*delay: 20000 \n" \ - "*showFPS: False \n" + "*showFPS: False \n" \ + "*suppressRotationAnimation: True\n" \ # define refresh_surface 0 +# define release_surface 0 # include "xlockmore.h" /* from the xscreensaver distribution */ #else /* !STANDALONE */ # include "xlock.h" /* from the xlockmore distribution */ @@ -163,10 +165,7 @@ static void draw(ModeInfo *mi) get_position(sp->rot, &x, &y, &z, !sp->button_down_p); glTranslatef((x-0.5)*10, (y-0.5)*10, (z-0.5)*20); - /* Do it twice because we don't track the device's orientation. */ - glRotatef( current_device_rotation(), 0, 0, 1); gltrackball_rotate(sp->trackball); - glRotatef(-current_device_rotation(), 0, 0, 1); get_rotation(sp->rot, &x, &y, &z, !sp->button_down_p); glRotatef(x*360, 1.0, 0.0, 0.0); @@ -420,8 +419,11 @@ static void draw(ModeInfo *mi) /* new window size or exposure */ ENTRYPOINT void reshape_surface(ModeInfo *mi, int width, int height) { + surfacestruct *sp = &surface[MI_SCREEN(mi)]; GLfloat h = (GLfloat) height / (GLfloat) width; + glXMakeCurrent(MI_DISPLAY(mi), MI_WINDOW(mi), *(sp->glx_context)); + glViewport(0, 0, (GLint) width, (GLint) height); glMatrixMode(GL_PROJECTION); glLoadIdentity(); @@ -431,6 +433,14 @@ ENTRYPOINT void reshape_surface(ModeInfo *mi, int width, int height) glLoadIdentity(); gluLookAt(0.0, 0.0, 30.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0); +# ifdef HAVE_MOBILE /* Keep it the same relative size when rotated. */ + { + int o = (int) current_device_rotation(); + if (o != 0 && o != 180 && o != -180) + glScalef (1/h, 1/h, 1/h); + } +# endif + glClear(GL_COLOR_BUFFER_BIT); } @@ -439,34 +449,10 @@ ENTRYPOINT Bool surface_handle_event(ModeInfo *mi, XEvent *event) { surfacestruct *sp = &surface[MI_SCREEN(mi)]; - if (event->xany.type == ButtonPress && event->xbutton.button == Button1) - { - sp->button_down_p = True; - gltrackball_start(sp->trackball, event->xbutton.x, event->xbutton.y, - MI_WIDTH (mi), MI_HEIGHT (mi)); + if (gltrackball_event_handler (event, sp->trackball, + MI_WIDTH (mi), MI_HEIGHT (mi), + &sp->button_down_p)) return True; - } - else if (event->xany.type == ButtonRelease && - event->xbutton.button == Button1) - { - sp->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(sp->trackball, event->xbutton.button, 10, - !!event->xbutton.state); - return True; - } - else if (event->xany.type == MotionNotify && sp->button_down_p) - { - gltrackball_track (sp->trackball, event->xmotion.x, event->xmotion.y, - MI_WIDTH (mi), MI_HEIGHT (mi)); - return True; - } return False; } @@ -477,12 +463,7 @@ ENTRYPOINT void init_surface(ModeInfo *mi) int screen = MI_SCREEN(mi); surfacestruct *sp; - if (surface == NULL) - { - if ((surface = (surfacestruct *) calloc(MI_NUM_SCREENS(mi), - sizeof(surfacestruct))) == NULL) - return; - } + MI_INIT (mi, surface, NULL); sp = &surface[screen]; sp->window = MI_WINDOW(mi); @@ -496,7 +477,7 @@ ENTRYPOINT void init_surface(ModeInfo *mi) 1.0, do_wander ? wander_speed : 0, True); - sp->trackball = gltrackball_init (); + sp->trackball = gltrackball_init (True); } if (!strcasecmp(surface_type,"random")) @@ -655,29 +636,6 @@ ENTRYPOINT void draw_surface(ModeInfo * mi) } -ENTRYPOINT void release_surface(ModeInfo * mi) -{ - if (surface != NULL) - { - int screen; - - for (screen = 0; screen < MI_NUM_SCREENS(mi); screen++) - { - surfacestruct *sp = &surface[screen]; - - if (sp->glx_context) - { - /* Display lists MUST be freed while their glXContext is current. */ - glXMakeCurrent(MI_DISPLAY(mi), sp->window, *(sp->glx_context)); - } - } - (void) free((void *)surface); - surface = NULL; - } - FreeAllGL(mi); -} - - XSCREENSAVER_MODULE_2("Surfaces", surfaces, surface) #endif