| Код | #include "stdafx.h" #include "Sample.h"
// Making necessary preparations void InitScene() { glClearColor(0.0, 0.0, 0.0, 0.0); glShadeModel(GL_FLAT); }
//Displaying the scene void OnDisplay() { glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0, 1.0, 0.0); 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(); }
//Reshapng the scene void OnReshape(int w, int h) { glViewport(0, 0, (GLsizei) w, (GLsizei) h); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluOrtho2D(-1.0, 1.0, -1.0, 1.0);
glMatrixMode(GL_MODELVIEW); glLoadIdentity(); gluLookAt(0.0, 0.0, 3.0, 0.0, 0.0, -1.0, 0.0, 1.0, 0.0); }
//Reacting to the keyboard void OnKeyPress(unsigned char key, int x, int y) { switch (key) { case 27: PostQuitMessage(0); break; } }
//Application entry point int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) { glutInit(&nCmdShow, (char **) &lpCmdLine); glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); glutCreateWindow("Example OpenGL program"); glutFullScreen(); InitScene(); glutDisplayFunc(OnDisplay); glutReshapeFunc(OnReshape); glutKeyboardFunc(OnKeyPress); glutMainLoop();
return 0; }
|
Где же проблема в коде???
Добавлено через 7 минут и 51 секунду У меня квадрат не в поле видимости. Вопрос снимается, прошу прощения. |