So yeah. I’m trying to render to a child window in my win32 application. I get the glClearColor properly, but whenever I try to render any polygons, I get nothing. Here’s my render code:
Before rendering to a child window, make sure it works fine in a single window first. You have not setup the projection and modelview matrix properly. Usually, we would call glMatrixMode before we call the projection or modelview matrix functions. So your resize code should be this,
Okay, well, progress. At first it looked like nothing was being rendered, but now I move the splitter bar, making my child window rreeeeeeeeeeeeaaaaaaally wide, I can see the triangle on the right side of the window.
Why isn’t it rendering in the middle like it’s supposed to…?
I think your viewport is not setup properly. To test it, just give it a size equal to the client area of the parent window. This should show you the whole triangle. Then adjust the viewport based on the size of the child window.
Why isn’t it rendering in the middle like it’s supposed to…?
Because the coordinates that u r passing in are not centered. For centered triangle try this.
Solved! For glViewport, I put 0 for x, and ToolHeight for y, and it works perfectly now. Also, yes, I found that (0, 0) is the center of the screen. Thanks a ton!!