Need Help!only backround,not expected graph

Glaux is a very old library,I cannot deal with it.My result only includes black background,not a colorful rectangle I wanted.

#include <windows.h>
#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glaux.h>
void myinit(void);
void  object(void);
void CALLBACK display(void);
void CALLBACK myReshape(GLsizei w, GLsizei h);
/*  GL_SMOOTH is actually the default shading model.  */
void myinit (void)
    glShadeModel (GL_SMOOTH);
void object(void)
    glBegin (GL_POLYGON);
	glColor3f (1.0, 0.0, 0.0);
	glVertex2f (4.0, 4.0);
	glVertex2f (12.0, 4.0);
	glVertex2f (12.0, 12.0);
	glVertex2f (4.0, 12.0);
    glEnd ();
void CALLBACK display(void)
    object ();
    glFlush ();
void CALLBACK myReshape(GLsizei w, GLsizei h)
    glViewport(0, 0, w, h);
    if (w <= h) 
    gluOrtho2D (0.0, 16.0, 0.0, 16.0 * (GLfloat) h/(GLfloat) w);
    gluOrtho2D (0.0, 16.0 * (GLfloat) w/(GLfloat) h, 0.0, 16.0);
void main(void)
    auxInitDisplayMode (AUX_SINGLE | AUX_RGBA);
    auxInitPosition (0, 0, 500, 500);
    auxInitWindow ("Smoothy Shading");
    auxReshapeFunc (myReshape);

From the OpenGL WIki:

Image Libraries # GLAUX:

This library was obsolete 20 years ago and only available on Microsoft Windows. If you decide to continue with this ancient code, you’ll need to replace the GLAUX include and API calls with something newer.

For the above code snippet, you could easily switch to using GLUT instead. See FreeGLUT. But I’d instead recommend just finding a newer OpenGL tutorial to follow, such as:

1 Like

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.