MrOk
MrOk

Reputation: 11

Visual studio 2012 don't work with OpenGL

I wrote a simple program by visual studio 2012 using OpenGL. Building has no error. But when I press F5 to Debug, a console window appear but nothing else. And Debug is still running. Just like is take a long time to finish. Specially, when I press ALT+F2 to Debug+Analysis, two windows appear: one is console window, another is a red square which I write.

So, I don't know if the problem is from Visual Studio software or from the OpenGL lib. Visual Studio worked well in the past.

This is the code:

#include <GL/glut.h>

void mydisplay() { 
   glClear(GL_COLOR_BUFFER_BIT); 
   glColor3f(1.0f, 0.0f, 0.0f); 
   glBegin(GL_POLYGON); 
   glVertex2f(-0.5, -0.5); 
   glVertex2f(-0.5, 0.5); 
   glVertex2f(0.5, 0.5); 
   glVertex2f(0.5, -0.5); 
   glEnd(); 
   glFlush(); 
} 

int main(int argc, char** argv) { 
   glutCreateWindow("simple"); 
   glutDisplayFunc(mydisplay); 
   glutMainLoop(); 
}

Upvotes: 1

Views: 87

Answers (1)

genpfault
genpfault

Reputation: 52166

Call glutInit() before glutCreateWindow().

Upvotes: 2

Related Questions