X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=hacks%2Fglx%2Fblocktube.c;h=682b64390e05eb8da7e3e99198e9a511b962c6af;hb=4361b69d3178d7fc98d0388f9a223af6c2651aba;hp=f62f3413c8b1c7e17d0cb14f05cf57e5986eed03;hpb=c1b9b55ad8d59dc05ef55e316aebf5863e7dfa56;p=xscreensaver diff --git a/hacks/glx/blocktube.c b/hacks/glx/blocktube.c index f62f3413..682b6439 100644 --- a/hacks/glx/blocktube.c +++ b/hacks/glx/blocktube.c @@ -16,8 +16,10 @@ #define DEFAULTS "*delay: 40000 \n" \ "*wireframe: False \n" \ "*showFPS: False \n" \ + "*suppressRotationAnimation: True\n" \ # define refresh_blocktube 0 +# define release_blocktube 0 # define blocktube_handle_event 0 #undef countof #define countof(x) (sizeof((x))/sizeof((*x))) @@ -108,7 +110,7 @@ ENTRYPOINT ModeSpecOpt blocktube_opts = {countof(opts), opts, countof(vars), var #ifdef USE_MODULES ModStruct blocktube_description = - {"blocktube", "init_blocktube", "draw_blocktube", "release_blocktube", + {"blocktube", "init_blocktube", "draw_blocktube", (char *)NULL, "draw_blocktube", "init_blocktube", (char *)NULL, &blocktube_opts, 40000, 30, 1, 1, 64, 1.0, "", "A shifting tunnel of reflective blocks", 0, NULL}; @@ -133,8 +135,10 @@ static Bool LoadGLTextures(ModeInfo *mi) GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, lp->texti->data); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); +# ifndef HAVE_JWZGLES /* #### Sphere maps unimplemented */ glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP); glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP); +# endif } return status; } @@ -201,6 +205,7 @@ static void tick(blocktube_configuration *lp) static int cube_vertices(float x, float y, float z, int wire); ENTRYPOINT void reshape_blocktube (ModeInfo *mi, int width, int height); +static void free_blocktube (ModeInfo *mi); ENTRYPOINT void init_blocktube (ModeInfo *mi) { @@ -209,15 +214,7 @@ ENTRYPOINT void init_blocktube (ModeInfo *mi) blocktube_configuration *lp; int wire = MI_IS_WIREFRAME(mi); - if (!lps) { - lps = (blocktube_configuration *) - calloc (MI_NUM_SCREENS(mi), sizeof (blocktube_configuration)); - if (!lps) { - fprintf(stderr, "%s: out of memory\n", progname); - exit(1); - } - lp = &lps[MI_SCREEN(mi)]; - } + MI_INIT(mi, lps, free_blocktube); lp = &lps[MI_SCREEN(mi)]; lp->glx_context = init_GL(mi); @@ -261,7 +258,6 @@ ENTRYPOINT void init_blocktube (ModeInfo *mi) glShadeModel(GL_SMOOTH); glEnable(GL_DEPTH_TEST); glEnable(GL_CULL_FACE); - glClearColor(0.0f, 0.0f, 0.0f, 0.0f); glClearDepth(1.0f); if (!do_texture && !wire) { @@ -293,34 +289,41 @@ ENTRYPOINT void init_blocktube (ModeInfo *mi) glFlush(); } -ENTRYPOINT void release_blocktube (ModeInfo *mi) +static void free_blocktube (ModeInfo *mi) { - if (lps) { - int screen; - for (screen = 0; screen < MI_NUM_SCREENS(mi); screen++) { - blocktube_configuration *lp = &lps[screen]; + blocktube_configuration *lp = &lps[MI_SCREEN(mi)]; # if defined ( I_HAVE_XPM ) - if (lp->envTexture) - glDeleteTextures(1, &lp->envTexture); - if (lp->texti) - XDestroyImage(lp->texti); -# endif - } - free (lps); - lps = 0; + if (lp->glx_context) { + glXMakeCurrent(MI_DISPLAY(mi), MI_WINDOW(mi), *(lp->glx_context)); + + if (lp->envTexture) + glDeleteTextures(1, &lp->envTexture); + if (lp->texti) + XDestroyImage(lp->texti); } - FreeAllGL(mi); +# endif } ENTRYPOINT void reshape_blocktube (ModeInfo *mi, int width, int height) { + blocktube_configuration *lp = &lps[MI_SCREEN(mi)]; GLfloat h = (GLfloat) height / (GLfloat) width; + glXMakeCurrent(MI_DISPLAY(mi), MI_WINDOW(mi), *(lp->glx_context)); + glViewport(0, 0, (GLint) width, (GLint) height); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(45.0, 1/h, 1.0, 100.0); glMatrixMode(GL_MODELVIEW); + +# 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 } static int cube_vertices(float x, float y, float z, int wire)