laituan245
laituan245

Reputation: 83

onReshape function of openGL

So the picture below is from one of the slides of my computer graphics class. Can anyone please explain to me what the last 4 lines of code do ?

enter image description here

Upvotes: 0

Views: 99

Answers (1)

user1118321
user1118321

Reputation: 26345

Those 4 lines of code are specific to the application you're writing in your class (or that your teacher is showing you or whatever). They appear to be setting up some scene coordinates so that the center of the scene is always aligned with the center of the window. cx is the x coordinate of the center of the scene (in world coordinates, I imagine). dy is the height of the scene (also in world coordinates). In the last 2 lines, the left and right edges of the scene are adjusted based on the aspect ratio of the window. The new left edge is the center minus half the height times the aspect ratio of the window.

Also, you should understand that OpenGL does not have a Reshape function. That is part of glut, which is not part of OpenGL. glut is a separate library to aid in using OpenGL, but is not part of OpenGL itself. I mention that mainly because glut is deprecated on some platforms.

Upvotes: 2

Related Questions