A few minor changes:

* glutInit*() calls should preceed glutInit(), per se, generally.
   This is so that glutInit()'s configuration (which picks up on user
   parameters) can override application defaults.
 * glutInit() should be called before ANY attempt to process {argv, argc}.
   This is because there may be GLUT/freeglut parameters (such as
   "-display" on X11).
 * If the window is tall and skinny, rather than short and squat, we need
   to handle aspect ratios differently.

The first is a user-interface bug.  The second is a serious bug (especially
since the demo assumes that argv[1] contains a filename).  The third is a
display bug.


git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@218 7f0cb862-5218-0410-a997-914c9d46530a
This commit is contained in:
rkrolib 2003-10-09 03:00:04 +00:00
parent 30d1e165a0
commit 8bde679512

View File

@ -83,7 +83,7 @@ static void draw_level ( int num, double m00, double m01, double m10, double m11
static void static void
Display(void) Display(void)
{ {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glClear( GL_COLOR_BUFFER_BIT );
/* the curve */ /* the curve */
glPushMatrix(); glPushMatrix();
@ -106,7 +106,10 @@ Reshape(int width, int height)
glMatrixMode ( GL_PROJECTION ) ; glMatrixMode ( GL_PROJECTION ) ;
glLoadIdentity(); glLoadIdentity();
ar = (float) width / (float) height ; ar = (float) width / (float) height ;
if( ar > 1 )
glFrustum ( -ar, ar, -1.0, 1.0, 2.0, 100.0 ) ; 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 ) ; glMatrixMode ( GL_MODELVIEW ) ;
glLoadIdentity () ; glLoadIdentity () ;
xwin = -1.0 ; xwin = -1.0 ;
@ -259,17 +262,16 @@ main(int argc, char *argv[])
{ {
int fractal_window ; int fractal_window ;
glutInitWindowSize(500, 250);
glutInitWindowPosition ( 140, 140 );
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE );
glutInit(&argc, argv);
if ( argc > 1 ) if ( argc > 1 )
readConfigFile ( argv[1] ) ; readConfigFile ( argv[1] ) ;
else else
readConfigFile ( "fractals.dat" ) ; readConfigFile ( "fractals.dat" ) ;
glutInit(&argc, argv);
glutInitWindowSize(500, 250);
glutInitWindowPosition ( 140, 140 ) ;
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
fractal_window = glutCreateWindow( window_title ); fractal_window = glutCreateWindow( window_title );
glClearColor(1.0, 1.0, 1.0, 1.0); glClearColor(1.0, 1.0, 1.0, 1.0);