X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=hacks%2Fglx%2Fengine.c;h=8c44bff3983a777886742774909a8bc07954c901;hb=b81f521c5ad7022ac12db18ca8fcdd9fb063831e;hp=f8be3c493e5455f3bfb99e9096f3781ccfeb7112;hpb=c1b9b55ad8d59dc05ef55e316aebf5863e7dfa56;p=xscreensaver diff --git a/hacks/glx/engine.c b/hacks/glx/engine.c index f8be3c49..8c44bff3 100644 --- a/hacks/glx/engine.c +++ b/hacks/glx/engine.c @@ -109,8 +109,12 @@ typedef struct { rotator *rot; trackball_state *trackball; Bool button_down_p; +# ifdef HAVE_GLBITMAP XFontStruct *xfont; GLuint font_dlist; +# else + texture_font_data *font_data; +# endif char *engine_name; int engineType; int movepaused; @@ -303,10 +307,8 @@ static int cylinder (Engine *e, GLfloat x, GLfloat y, GLfloat z, int b = 0; /* previous */ int angle, norm, step, sangle; float z1, y1, z2, y2, ex=0; - float y3, z3; - float Z1, Y1, Z2, Y2, xl, Y3, Z3; + float Z1, Y1, Z2, Y2, xl; GLfloat y2c[TWOREV], z2c[TWOREV]; - GLfloat ony, onz; /* previous normals */ int nsegs, tube = 0; glPushMatrix(); @@ -317,7 +319,6 @@ static int cylinder (Engine *e, GLfloat x, GLfloat y, GLfloat z, nsegs += 1; sangle = sang; angle = eang; - ony = onz = 0; z1 = e->cos_table[sangle]*outer+z; y1 = e->sin_table[sangle] * outer+y; Z1 = e->cos_table[sangle] * inner+z; Y1 = e->sin_table[sangle]*inner+y ; Z2 = z; @@ -330,15 +331,11 @@ 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; - y3=outer*(float)e->sin_table[a+step]+y; - z3=outer*(float)e->cos_table[a+step]+z; 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; - Y3=inner*(float)e->sin_table[a+step]+y; - Z3=inner*(float)e->cos_table[a+step]+z; } glNormal3f(0, y1, z1); glVertex3f(x,y1,z1); @@ -590,7 +587,7 @@ static int boom(Engine *e, GLfloat x, GLfloat y, int s) glLightfv(GL_LIGHT1, GL_POSITION, e->boom_lpos); glLightfv(GL_LIGHT1, GL_DIFFUSE, e->boom_red); glLightfv(GL_LIGHT1, GL_SPECULAR, e->boom_red); - glLighti(GL_LIGHT1, GL_LINEAR_ATTENUATION, 1.3); + glLightf(GL_LIGHT1, GL_LINEAR_ATTENUATION, 1.3); glLighti(GL_LIGHT1, GL_CONSTANT_ATTENUATION, 0); glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, e->boom_red); @@ -621,6 +618,7 @@ static int display(Engine *e) e->lookat[0], e->lookat[1], e->lookat[2], 0.0, 1.0, 0.0); glPushMatrix(); + glLightfv(GL_LIGHT0, GL_POSITION, lightpos); glLightfv(GL_LIGHT0, GL_SPECULAR, light_sp); glLightfv(GL_LIGHT0, GL_DIFFUSE, light_sp); @@ -630,9 +628,15 @@ static int display(Engine *e) get_position (e->rot, &x, &y, &z, !e->button_down_p); glTranslatef(x*16-9, y*14-7, z*16-10); } + if (spin) { double x, y, z; + + /* Do it twice because we don't track the device's orientation. */ + glRotatef( current_device_rotation(), 0, 0, 1); gltrackball_rotate (e->trackball); + glRotatef(-current_device_rotation(), 0, 0, 1); + get_rotation(e->rot, &x, &y, &z, !e->button_down_p); glRotatef(x*ONEREV, 1.0, 0.0, 0.0); glRotatef(y*ONEREV, 0.0, 1.0, 0.0); @@ -902,7 +906,6 @@ ENTRYPOINT void init_engine(ModeInfo *mi) } else { MI_CLEARWINDOW(mi); } - glClearColor(0.0,0.0,0.0,0.0); glShadeModel(GL_SMOOTH); glPolygonMode(GL_FRONT_AND_BACK,GL_FILL); glEnable(GL_DEPTH_TEST); @@ -924,7 +927,12 @@ ENTRYPOINT void init_engine(ModeInfo *mi) e->shaft_polys = makeshaft(e); e->piston_polys = makepiston(e); + +#ifdef HAVE_GLBITMAP load_font (mi->dpy, "titleFont", &e->xfont, &e->font_dlist); +#else + e->font_data = load_texture_font (mi->dpy, "Font"); +#endif } ENTRYPOINT Bool @@ -982,8 +990,14 @@ ENTRYPOINT void draw_engine(ModeInfo *mi) mi->polygon_count = display(e); + glColor3f (1, 1, 0); if (do_titles) - print_gl_string (mi->dpy, e->xfont, e->font_dlist, + print_gl_string (mi->dpy, +# ifdef HAVE_GLBITMAP + e->xfont, e->font_dlist, +# else + e->font_data, +# endif mi->xgwa.width, mi->xgwa.height, 10, mi->xgwa.height - 10, e->engine_name, False);