I would expect this to render on the left half of my window but it stretches the image across the full width of the window instead. Am I doing something wrong?
The entire screen wil get cleared to the clear color that you set with the code that you have. However, if you draw a square or something in that viewport, you will notice that it is only being drawn to the left.
I started rendering in the full 640x480 window… the geometry shows up right where it should.
glViewport(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
glOrtho(-4,4,-3,3,4,4000);
Then I updated those lines like they appear in my previous post:
glViewport(0, 0, SCREEN_WIDTH/2, SCREEN_HEIGHT); glOrtho(-2,2,-3,3,4,4000);
So you guys agree that this change should render just on the left half of the screen? Its just stretching the image across the whole window.
You’ll need to define a callback in glutReshapeFunc() that sets your viewport correctly. As you haven’t done this in the code above, the default handler will reset your viewport to the whole screen when the window gets a resize event.