Small bug-fix that's been on my mind:
Modified the two Fractals* demos so that they only clear (for the random one) or redraw (for the non-random one) if there is need to do so. (E.g., pressing the space bar should not clear and redraw the random fractal since no parameters are altered.) git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@231 7f0cb862-5218-0410-a997-914c9d46530a
This commit is contained in:
parent
6e00dab2da
commit
fd81891b21
@ -120,6 +120,8 @@ Reshape(int width, int height)
|
||||
static void
|
||||
Key(unsigned char key, int x, int y)
|
||||
{
|
||||
int need_redisplay = 1;
|
||||
|
||||
switch (key) {
|
||||
case 27: /* Escape key */
|
||||
glutLeaveMainLoop () ;
|
||||
@ -140,16 +142,21 @@ Key(unsigned char key, int x, int y)
|
||||
xwin = -1.0 ;
|
||||
ywin = 0.0 ;
|
||||
glTranslated ( xwin, ywin, -5.0 ) ;
|
||||
|
||||
break ;
|
||||
}
|
||||
|
||||
glutPostRedisplay();
|
||||
default:
|
||||
need_redisplay = 0;
|
||||
break;
|
||||
}
|
||||
if (need_redisplay)
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
static void
|
||||
Special(int key, int x, int y)
|
||||
{
|
||||
int need_redisplay = 1;
|
||||
|
||||
switch (key) {
|
||||
case GLUT_KEY_UP :
|
||||
glMatrixMode ( GL_MODELVIEW ) ;
|
||||
@ -190,9 +197,13 @@ Special(int key, int x, int y)
|
||||
glTranslated ( xwin, ywin, 0.0 ) ;
|
||||
scale_factor *= 1.25 ;
|
||||
break ;
|
||||
}
|
||||
|
||||
glutPostRedisplay();
|
||||
default:
|
||||
need_redisplay = 0;
|
||||
break;
|
||||
}
|
||||
if (need_redisplay)
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
|
||||
|
@ -116,6 +116,8 @@ Reshape(int width, int height)
|
||||
static void
|
||||
Key(unsigned char key, int x, int y)
|
||||
{
|
||||
int changed_settings = 1;
|
||||
|
||||
switch (key) {
|
||||
case 27: /* Escape key */
|
||||
glutLeaveMainLoop ();
|
||||
@ -127,18 +129,22 @@ Key(unsigned char key, int x, int y)
|
||||
xwin = -1.0 ;
|
||||
ywin = 0.0 ;
|
||||
glTranslatef(xwin, ywin, -5.0);
|
||||
|
||||
break ;
|
||||
|
||||
default:
|
||||
changed_settings = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
needClear = GL_TRUE;
|
||||
|
||||
if (changed_settings)
|
||||
needClear = GL_TRUE;
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
static void
|
||||
Special(int key, int x, int y)
|
||||
{
|
||||
int changed_settings = 1;
|
||||
|
||||
switch (key) {
|
||||
case GLUT_KEY_UP :
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
@ -179,9 +185,13 @@ Special(int key, int x, int y)
|
||||
glTranslatef ( xwin, ywin, 0.0 ) ;
|
||||
scale_factor *= 1.25 ;
|
||||
break ;
|
||||
}
|
||||
|
||||
needClear = GL_TRUE;
|
||||
default:
|
||||
changed_settings = 0;
|
||||
break;
|
||||
}
|
||||
if (changed_settings)
|
||||
needClear = GL_TRUE;
|
||||
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
Reference in New Issue
Block a user