projects
/
freeglut
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fixed:
[freeglut]
/
progs
/
demos
/
Fractals_random
/
fractals_random.c
diff --git
a/progs/demos/Fractals_random/fractals_random.c
b/progs/demos/Fractals_random/fractals_random.c
index
ca52dd5
..
324f00b
100644
(file)
--- a/
progs/demos/Fractals_random/fractals_random.c
+++ b/
progs/demos/Fractals_random/fractals_random.c
@@
-50,6
+50,9
@@
float scale_factor = 1.0 ;
/* The current point */
float current_x = 0.0, current_y = 0.0 ;
/* The current point */
float current_x = 0.0, current_y = 0.0 ;
+/* Signals when a glClear is needed */
+static GLboolean needClear = GL_TRUE;
+
static void draw_level ( int num, double m00, double m01, double m10, double m11, double n0, double n1 )
{
/* Draw a fractal transformed by "M", "N" as passed in */
static void draw_level ( int num, double m00, double m01, double m10, double m11, double n0, double n1 )
{
/* Draw a fractal transformed by "M", "N" as passed in */
@@
-70,6
+73,11
@@
static void draw_level ( int num, double m00, double m01, double m10, double m11
static void
Display(void)
{
static void
Display(void)
{
+ if (needClear) {
+ glClear(GL_COLOR_BUFFER_BIT);
+ needClear = GL_FALSE;
+ }
+
/* the curve */
glPushMatrix();
glScalef(2.5, 2.5, 2.5);
/* the curve */
glPushMatrix();
glScalef(2.5, 2.5, 2.5);
@@
-81,7
+89,7
@@
Display(void)
glPopMatrix();
glPopMatrix();
- // glutSwapBuffers(); /* Should NOT be here... This is a Single-Buffered Program! */
+ glFlush();
glutPostRedisplay(); /* Needed so that this function will be called again */
}
glutPostRedisplay(); /* Needed so that this function will be called again */
}
@@
-93,12
+101,16
@@
Reshape(int width, int height)
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
ar = (float) width / (float) height;
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
ar = (float) width / (float) height;
- glFrustum(-ar, ar, -1.0, 1.0, 2.0, 100.0);
+ if( ar > 1 )
+ glFrustum(-ar, ar, -1.0, 1.0, 2.0, 100.0);
+ else
+ glFrustum(-1.0, 1.0, -1/ar, 1/ar, 2.0, 100.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
xwin = -1.0 ;
ywin = 0.0 ;
glTranslatef(xwin, ywin, -5.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
xwin = -1.0 ;
ywin = 0.0 ;
glTranslatef(xwin, ywin, -5.0);
+ needClear = GL_TRUE;
}
static void
}
static void
@@
-119,7
+131,7
@@
Key(unsigned char key, int x, int y)
break ;
}
break ;
}
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+ needClear = GL_TRUE;
glutPostRedisplay();
}
glutPostRedisplay();
}
@@
-169,7
+181,7
@@
Special(int key, int x, int y)
break ;
}
break ;
}
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+ needClear = GL_TRUE;
glutPostRedisplay();
}
glutPostRedisplay();
}
@@
-236,37
+248,30
@@
void readConfigFile ( char *fnme )
}
}
}
}
-void Idle(void) {
- return;
-}
-
int
main(int argc, char *argv[])
{
int fractal_window ;
int
main(int argc, char *argv[])
{
int fractal_window ;
- if ( argc > 1 )
- readConfigFile ( argv[1] ) ;
- else
- readConfigFile ( "fractals.dat" ) ;
+ glutInitDisplayMode( GLUT_RGB | GLUT_SINGLE );
- glutInit(&argc, argv);
glutInitWindowSize(500, 250);
glutInitWindowPosition ( 140, 140 ) ;
glutInitWindowSize(500, 250);
glutInitWindowPosition ( 140, 140 ) ;
+ glutInit(&argc, argv);
- glutInitDisplayMode(GLUT_RGB | GLUT_SINGLE | GLUT_DEPTH);
+ if ( argc > 1 )
+ readConfigFile ( argv[1] ) ;
+ else
+ readConfigFile ( "fractals.dat" ) ;
fractal_window = glutCreateWindow( window_title );
glClearColor(1.0, 1.0, 1.0, 1.0);
fractal_window = glutCreateWindow( window_title );
glClearColor(1.0, 1.0, 1.0, 1.0);
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
-
glutReshapeFunc(Reshape);
glutKeyboardFunc(Key);
glutSpecialFunc(Special);
glutDisplayFunc(Display);
glutReshapeFunc(Reshape);
glutKeyboardFunc(Key);
glutSpecialFunc(Special);
glutDisplayFunc(Display);
- glutIdleFunc(Idle);
glutMainLoop();
glutMainLoop();