这是我的剧本 我不知道解决这个错误 请帮我 非常感谢你
float angle = 15;
float x, y, z; // for polygon rotate
void display()
{
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); // clear screen and depth buffer
glLoadIdentity();
glPushMatrix();
glColor3f(1.0, 0.0, 0.0);
glBegin(GL_POLYGON);
glVertex2f(160.0, 360.0);
glVertex2f(300.0, 360.0);
glVertex2f(160.0, 480.0);
glVertex2f(300.0, 480.0);
glPushMatrix();
glColor3f(0.0, 0.0, 0.0);
glVertex2f(580.0, 200.0);
glVertex2f(640.0, 200.0);
glVertex2f(580.0, 480.0);
glVertex2f(640.0, 480.0);
glRotatef(angle, -1.0f, 0.0, 0.0);
angle += 15.0f;
glEnd();
glutSwapBuffers(); // dounle buffering
}
LRESULT CALLBACK MainWindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg)
{
case WM_LBUTTONDOWN:
{
}break;
case WM_DESTROY: {
PostQuitMessage(0);
}break;
default:break;
}
return 0;
}
int main(int argc, char** argv)
{
glutInit(&argc, argv); // Initialize GLUT
glutInitDisplayMode(GLUT_DOUBLE);// Set up some memory buffers for our display
glutInitWindowSize(640, 400);
glutInitWindowPosition(100, 20);
glutCreateWindow("My GLUT GAME");
glutDisplayFunc(display);
//glutKeyboardFunc();
glutMainLoop();
return 0;
}
答案 0 :(得分:7)
您已将项目设置为构建为Windows应用程序,而不是命令行应用程序。将int main()
更改为:
int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR pCmdLine, int nCmdShow)
https://msdn.microsoft.com/en-us/library/windows/desktop/ms633559%28v=vs.85%29.aspx
或者,将项目属性更改为命令行应用程序。
答案 1 :(得分:2)
答案 2 :(得分:1)
作为解决方法,您可以添加WinMain
函数,从中调用main
:
#ifdef _WIN32
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow)
{
return main(__argc, __argv);
}
#endif
答案 3 :(得分:1)
对我来说,这有所帮助。
转到properties->Linker -> System -> Sub-system
并选择“未设置”或“ Windows”