clean-up the hokey transformation code so that window resizes actually work
This commit is contained in:
parent
b18715fea3
commit
6fedd4e3bf
|
@ -36,7 +36,6 @@
|
||||||
static GLfloat angle = -150; /* in degrees */
|
static GLfloat angle = -150; /* in degrees */
|
||||||
static int spin = 0;
|
static int spin = 0;
|
||||||
static int moving, begin;
|
static int moving, begin;
|
||||||
static int newModel = 1;
|
|
||||||
static float theTime;
|
static float theTime;
|
||||||
static int repeat = 1;
|
static int repeat = 1;
|
||||||
static int blend = 1;
|
static int blend = 1;
|
||||||
|
@ -183,7 +182,6 @@ idle(void)
|
||||||
updatePointList();
|
updatePointList();
|
||||||
if (spin) {
|
if (spin) {
|
||||||
angle += 0.3;
|
angle += 0.3;
|
||||||
newModel = 1;
|
|
||||||
}
|
}
|
||||||
glutPostRedisplay();
|
glutPostRedisplay();
|
||||||
}
|
}
|
||||||
|
@ -200,23 +198,16 @@ visible(int vis)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
recalcModelView(void)
|
|
||||||
{
|
|
||||||
glPopMatrix();
|
|
||||||
glPushMatrix();
|
|
||||||
glRotatef(angle, 0.0, 1.0, 0.0);
|
|
||||||
newModel = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
redraw(void)
|
redraw(void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
if (newModel)
|
|
||||||
recalcModelView();
|
glPushMatrix();
|
||||||
|
glRotatef(15.0, 1.0, 0.0, 0.0);
|
||||||
|
glRotatef(angle, 0.0, 1.0, 0.0);
|
||||||
|
|
||||||
glDepthMask(GL_FALSE);
|
glDepthMask(GL_FALSE);
|
||||||
|
|
||||||
|
@ -264,6 +255,8 @@ redraw(void)
|
||||||
#endif
|
#endif
|
||||||
glDisable(GL_BLEND);
|
glDisable(GL_BLEND);
|
||||||
|
|
||||||
|
glPopMatrix();
|
||||||
|
|
||||||
glutSwapBuffers();
|
glutSwapBuffers();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -289,7 +282,6 @@ mouseMotion(int x, int y)
|
||||||
if (moving) {
|
if (moving) {
|
||||||
angle = angle + (x - begin);
|
angle = angle + (x - begin);
|
||||||
begin = x;
|
begin = x;
|
||||||
newModel = 1;
|
|
||||||
glutPostRedisplay();
|
glutPostRedisplay();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -301,7 +293,7 @@ menu(int option)
|
||||||
case 0:
|
case 0:
|
||||||
makePointList();
|
makePointList();
|
||||||
break;
|
break;
|
||||||
#if GL_ARB_point_parameters
|
#ifdef GL_ARB_point_parameters
|
||||||
case 1:
|
case 1:
|
||||||
glPointParameterfvARB(GL_POINT_DISTANCE_ATTENUATION_ARB, constant);
|
glPointParameterfvARB(GL_POINT_DISTANCE_ATTENUATION_ARB, constant);
|
||||||
break;
|
break;
|
||||||
|
@ -318,7 +310,7 @@ menu(int option)
|
||||||
case 5:
|
case 5:
|
||||||
blend = 0;
|
blend = 0;
|
||||||
break;
|
break;
|
||||||
#if GL_ARB_point_parameters
|
#ifdef GL_ARB_point_parameters
|
||||||
case 6:
|
case 6:
|
||||||
glPointParameterfARB(GL_POINT_FADE_THRESHOLD_SIZE_ARB, 1.0);
|
glPointParameterfARB(GL_POINT_FADE_THRESHOLD_SIZE_ARB, 1.0);
|
||||||
break;
|
break;
|
||||||
|
@ -390,8 +382,8 @@ key(unsigned char c, int x, int y)
|
||||||
case 'o':
|
case 'o':
|
||||||
case 'O':
|
case 'O':
|
||||||
org ^= 1;
|
org ^= 1;
|
||||||
#if GL_VERSION_2_0
|
#ifdef GL_VERSION_2_0
|
||||||
#if GL_ARB_point_parameters
|
#ifdef GL_ARB_point_parameters
|
||||||
glPointParameteri(GL_POINT_SPRITE_COORD_ORIGIN,
|
glPointParameteri(GL_POINT_SPRITE_COORD_ORIGIN,
|
||||||
org ? GL_LOWER_LEFT : GL_UPPER_LEFT);
|
org ? GL_LOWER_LEFT : GL_UPPER_LEFT);
|
||||||
#endif
|
#endif
|
||||||
|
@ -485,10 +477,10 @@ reshape(int width, int height)
|
||||||
glViewport(0, 0, (GLint) width, (GLint) height);
|
glViewport(0, 0, (GLint) width, (GLint) height);
|
||||||
glMatrixMode(GL_PROJECTION);
|
glMatrixMode(GL_PROJECTION);
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
glFrustum(-1.0, 1.0, -h, h, 2.0, 20.0);
|
glFrustum(-1.0, 1.0, -h, h, 2.0, 30.0);
|
||||||
glMatrixMode(GL_MODELVIEW);
|
glMatrixMode(GL_MODELVIEW);
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
glTranslatef(0.0, 0.0, -60.0);
|
glTranslatef(0.0, 0.0, -10.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -544,19 +536,9 @@ main(int argc, char **argv)
|
||||||
glEnable(GL_POINT_SMOOTH);
|
glEnable(GL_POINT_SMOOTH);
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
glPointSize(16.0);
|
glPointSize(16.0);
|
||||||
#if GL_ARB_point_parameters
|
#ifdef GL_ARB_point_parameters
|
||||||
glPointParameterfvARB(GL_POINT_DISTANCE_ATTENUATION_ARB, theQuad);
|
glPointParameterfvARB(GL_POINT_DISTANCE_ATTENUATION_ARB, theQuad);
|
||||||
#endif
|
#endif
|
||||||
glMatrixMode(GL_PROJECTION);
|
|
||||||
gluPerspective( /* field of view in degree */ 40.0,
|
|
||||||
/* aspect ratio */ 1.0,
|
|
||||||
/* Z near */ 0.5, /* Z far */ 40.0);
|
|
||||||
glMatrixMode(GL_MODELVIEW);
|
|
||||||
gluLookAt(0.0, 1.0, 8.0, /* eye location */
|
|
||||||
0.0, 1.0, 0.0, /* center is at (0,0,0) */
|
|
||||||
0.0, 1.0, 0.); /* up is in postivie Y direction */
|
|
||||||
glPushMatrix(); /* dummy push so we can pop on model
|
|
||||||
recalc */
|
|
||||||
|
|
||||||
makePointList();
|
makePointList();
|
||||||
makeSprite();
|
makeSprite();
|
||||||
|
|
Loading…
Reference in New Issue