Handmade Hero»Forums»Code
Roderic Bos
70 posts
Day242: setting DIBSection to 960x540 wrong output
Edited by Roderic Bos on
I tried day 242 on my crappy laptop to see if opengl was a bit more speedy than before now. But still on 24/msec . So I set the screensize to half 960x540 but then the output only filled the bottom left quadrant of the screen with the rest going to black.

Probably something to do with the ProjectionMatrix or something but can't really find it. Anybody else have this?
Mārtiņš Možeiko
2561 posts / 2 projects
Day242: setting DIBSection to 960x540 wrong output
Yeah, code there is a bit incorrect.
Projection matrix is fine - it uses width and height for size that game expects image to be rendered in.
The wrong thing is call to glViewport function - it sets up area in which OpenGL will be rendering. Currently it uses same width and height as render commands, which is incorrect (only half size for width/height). Instead it should use WindowWidth and WindowHeight that is passed in OpenGLRenderCommands arguments. That will set up viewport to cover full window. Then image will be stretched to full window size, if that's what you want. Ideally of course it should keep aspect ratio the same, but for now you can simply ignore that.

Another thing to try would be to set HANDMADE_STREAMING define to 0. By default it is set to 1 and that disables double buffering. Maybe double buffering will increase performance for you.
Roderic Bos
70 posts
Day242: setting DIBSection to 960x540 wrong output
Thanks, I was looking in the wrong direction then.

That seem to work fine, whole screen is filled.

Didn't really help with the speed though but at least the game is beter than 30 frames a seconds :-).