#include #include // tu potrebne len kvoli gluOrtho2D #include const float Lmax = 40.0; void obsluhaResize(int sirka, int vyska) { glViewport(0, 0, sirka, vyska); glMatrixMode(GL_PROJECTION); glLoadIdentity(); if (sirka == 0) sirka++; const float pomstr = ((float)vyska)/sirka; glOrtho(-0.5*Lmax, 0.5*Lmax, -0.5*Lmax*pomstr, 0.5*Lmax*pomstr, -1, +1); } void kresliRovnobezky3D() { glClear(GL_COLOR_BUFFER_BIT); glMatrixMode(GL_MODELVIEW); glColor3f(0.0, 0.0, 0.0); glBegin(GL_LINES); glVertex3f(-0.1*Lmax, 0.2*Lmax, 0.0); glVertex3f(-0.1*Lmax, 0.3*Lmax, -1.0); glVertex3f(+0.1*Lmax, 0.2*Lmax, 0.0); glVertex3f(+0.1*Lmax, 0.3*Lmax, -4.0); glEnd(); glutSwapBuffers(); } int main(int argc, char **argv) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_DOUBLE); glutInitWindowSize(640, 640); glutInitWindowPosition(200, 150); glutCreateWindow("OpenGL: rovnobezky"); glutDisplayFunc(kresliRovnobezky3D); glutReshapeFunc(obsluhaResize); glClearColor(1.0, 1.0, 1.0, 0); // farba pozadia biela glutMainLoop(); return 0; }