how do you open a window in 1-2 lines using glut?. Do the drawing commands have to be in
int DrawGLScene(GLvoid)
or can you just put them in any function?
This is a discussion on opening window using glut within the Game Programming forums, part of the General Programming Boards category; how do you open a window in 1-2 lines using glut?. Do the drawing commands have to be in int ...
how do you open a window in 1-2 lines using glut?. Do the drawing commands have to be in
int DrawGLScene(GLvoid)
or can you just put them in any function?
i figure this is about as simple as it gets...
Code:#include <windows.h> #include <gl/glut.h> GLvoid Render(GLvoid) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // do your drawing here } GLvoid Initialize(GLvoid) { glClearColor(0.0f,0.0f,0.0f,1.0f); glClearDepth(1.0f); // do your initializing here } GLvoid Resize(GLint Width,GLint Height) { if (Height == 0) { Height = 1; } glViewport(0,0,Width,Height); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(45,(float)Width/(float)Height,1.0f,100.0f); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); } main() { glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA); glutCreateWindow("OpenGL"); glutDisplayFunc(Render); glutReshapeFunc(Resize); Initialize(); glutMainLoop(); return 0; }
ADVISORY: This users posts are rated CP-MA, for Mature Audiences only.