I am behind with the series and have reached day 394. On my machine, the day 394 code does not run. I skipped some episodes ahead and checked resolved github issues to find and fix part of the problem. I stopped using gl_FragData
and use layout(location = 0) out v4 FragColour[4];
. That works fine.
I still have the problem that the lighting textures are not drawn the same as on Casey's machine. To debug, I set FakeSeedLighting
to fill with red, and commented out the call to ComputeLightTransport
. When drawing it, it does not fill the screen. It is just in the lower left corner.
If I call ComputeLightTransport
, it draws smaller in the lower left, getting smaller for each loop to OpenGL.LightBufferCount
.
I assume there is some OpenGl state that is causing this, but I am new to OpenGl and have been unable to figure it out.
And idea of the problem? Thanks
If I read the code correctly (it has been a while since I watched those episodes), the display of lighting texture will only display it according to the size of buffer, which might not be the same as the "rendering region".
If you put the application fullscreen and use Win32ResizeDIBSection(&GlobalBackbuffer, 1920, 1080);
instead of the 960, 540
version it displays the rectangle on the entire screen.
I tried it in a window with the 1280*720 version, and there are some issues for it to work correctly:
glViewport
call at the end of handmade_opengl.cpp
is wrong,glScissor
call in there as well.glViewport(DrawRegion.MinX, DrawRegion.MinY, RenderWidth, RenderHeight); glScissor(DrawRegion.MinX, DrawRegion.MinY, RenderWidth, RenderHeight); glBlitFramebuffer(0, 0, Buf->Width, Buf->Height, DrawRegion.MinX, DrawRegion.MinY, DrawRegion.MaxX, DrawRegion.MaxY, GL_COLOR_BUFFER_BIT, GL_NEAREST);
The rectangle becoming smaller could be related to the glScissor
calls in OpenGLBeginScreenFill
but I didn't observe that behavior so I don't really know what's happening.
Yes, the glViewport and glScissor was the problem!
I have now set it to:
glViewport(0, 0, WindowWidth, WindowHeight); glScissor(0, 0, WindowWidth, WindowHeight);
With that, all the lighting textures fill the screen in fullscreen and any windowed size.
I guess glBlitFramebuffer needs it since it has x and y DrawRegion offsets.
Thanks so much, I can continue following along now