What is the actual difference between gluortho2d and glViewport

I made the window size 800x600. I called

gluOrtho2D(-400,400,-300,300);
glViewport(400,300,400,300);

and I drew a line from (-100,-100)to (100,100). I think I should see the line from (0,0)to (100,100), but I get the whole line. Why is this?

+3
source share
2 answers

In theory, it glViewport does not cause any clipping (see section 10) . Usually all drawings are attached to the window. Since you asked OpenGL to draw in the area of ​​your window, you also need to specify OpenGL for the clip coordinates outside this viewport. For this you will need glScissor. However, some implementations bind their drawing to the viewport (see My comment for details).

, . 800 600 , (0, 0). 400 300 .

(-100, -100) (100, 100), . , .

, . , .

, . http://img696.imageshack.us/img696/6541/opengl.png

, !

+10

glViewport , OpenGL. glOrtho gluOrtho2D ( OpenGL), ( glViewport) . , Viewport -100, -100 100,100

0

Source: https://habr.com/ru/post/1725982/


All Articles