X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=hacks%2Fglx%2Fengine.c;h=753eff6679dd53b196c53fd15bf31d937288ed46;hb=aa75c7476aeaa84cf3abc192b376a8b03c325213;hp=d29ec0d6f486f248f1dd145b1684a1ca5fd882d5;hpb=6afd6db0ae9396cd7ff897ade597cd5483f49b0e;p=xscreensaver diff --git a/hacks/glx/engine.c b/hacks/glx/engine.c index d29ec0d6..753eff66 100644 --- a/hacks/glx/engine.c +++ b/hacks/glx/engine.c @@ -24,7 +24,8 @@ #ifdef STANDALONE #define DEFAULTS "*delay: 30000 \n" \ "*showFPS: False \n" \ - "*titleFont: -*-helvetica-medium-r-normal-*-180-*\n" \ + "*suppressRotationAnimation: True\n" \ + "*titleFont: -*-helvetica-medium-r-normal-*-*-180-*-*-*-*-*-*\n" \ # define refresh_engine 0 # include "xlockmore.h" /* from the xscreensaver distribution */ @@ -32,7 +33,7 @@ # include "xlock.h" /* from the xlockmore distribution */ #endif /* !STANDALONE */ -#include "glxfonts.h" +#include "texfont.h" #include "rotator.h" #include "gltrackball.h" @@ -326,8 +327,10 @@ static int cylinder (Engine *e, GLfloat x, GLfloat y, GLfloat z, for (a = sangle ; a <= angle || b <= angle ; a+= step) { y2=outer*(float)e->sin_table[a]+y; z2=outer*(float)e->cos_table[a]+z; - if (endcaps) - y2c[a] = y2; z2c[a] = z2; /* cache for later */ + if (endcaps) { + y2c[a] = y2; + z2c[a] = z2; /* cache for later */ + } if (tube) { Y2=inner*(float)e->sin_table[a]+y; Z2=inner*(float)e->cos_table[a]+z; @@ -530,8 +533,8 @@ static int makepiston(Engine *e) int polys = 0; GLfloat colour[] = {0.6, 0.6, 0.6, 1.0}; - if (e->piston_list) glDeleteLists(1, e->piston_list); - e->piston_list = glGenLists(1); + /* if (e->piston_list) glDeleteLists(1, e->piston_list); */ + if (! e->piston_list) e->piston_list = glGenLists(1); glNewList(e->piston_list, GL_COMPILE); glRotatef(90, 0, 0, 1); glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, colour); @@ -598,8 +601,9 @@ static int boom(Engine *e, GLfloat x, GLfloat y, int s) return polys; } -static int display(Engine *e) +static int display(ModeInfo *mi) { + Engine *e = &engine[MI_SCREEN(mi)]; int polys = 0; GLfloat zb, yb; float rightSide; @@ -615,6 +619,15 @@ static int display(Engine *e) 0.0, 1.0, 0.0); glPushMatrix(); +# 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 + glLightfv(GL_LIGHT0, GL_POSITION, lightpos); glLightfv(GL_LIGHT0, GL_SPECULAR, light_sp); glLightfv(GL_LIGHT0, GL_DIFFUSE, light_sp); @@ -774,8 +787,8 @@ static int makeshaft (Engine *e) float crankThick = 0.2; float crankDiam = 0.3; - if (e->shaft_list) glDeleteLists(1, e->shaft_list); - e->shaft_list = glGenLists(1); + /* if (e->shaft_list) glDeleteLists(1, e->shaft_list); */ + if (! e->shaft_list) e->shaft_list = glGenLists(1); glNewList(e->shaft_list, GL_COMPILE); glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, blue); @@ -836,7 +849,8 @@ ENTRYPOINT void reshape_engine(ModeInfo *mi, int width, int height) glViewport(0,0,(GLint)width, (GLint) height); glMatrixMode(GL_PROJECTION); glLoadIdentity(); - glFrustum(-1.0,1.0,-1.0,1.0,1.5,70.0); +/* glFrustum(-1.0,1.0,-1.0,1.0,1.5,70.0);*/ + gluPerspective(40.0,((GLdouble)width)/height,1.5,70.0); glMatrixMode(GL_MODELVIEW); e->win_h = height; e->win_w = width; @@ -895,7 +909,8 @@ ENTRYPOINT void init_engine(ModeInfo *mi) e->trackball = gltrackball_init (True); } - if ((e->glx_context = init_GL(mi)) != NULL) { + if (!e->glx_context && /* re-initting breaks print_texture_label */ + (e->glx_context = init_GL(mi)) != NULL) { reshape_engine(mi, MI_WIDTH(mi), MI_HEIGHT(mi)); } else { MI_CLEARWINDOW(mi); @@ -968,14 +983,13 @@ ENTRYPOINT void draw_engine(ModeInfo *mi) glXMakeCurrent(disp, w, *(e->glx_context)); - mi->polygon_count = display(e); + mi->polygon_count = display(mi); glColor3f (1, 1, 0); if (do_titles) - print_gl_string (mi->dpy, e->font_data, - mi->xgwa.width, mi->xgwa.height, - 10, mi->xgwa.height - 10, - e->engine_name, False); + print_texture_label (mi->dpy, e->font_data, + mi->xgwa.width, mi->xgwa.height, + 1, e->engine_name); if(mi->fps_p) do_fps(mi); glFinish();