cinera_handmade.network/cmuratori/hero/code/code371.hmml

85 lines
6.2 KiB
Plaintext

[video output=day371 member=cmuratori stream_platform=twitch stream_username=handmade_hero project=code title="OpenGL Vertex Arrays" vod_platform=youtube id=Bn97Txqu9No annotator=Miblo]
[0:04][Recap and set the stage for the day]
[1:34][Run the game and note that the sprites are all being submitted separately]
[4:21][handmade_render_group.cpp: Enable PushBitmap() to append new textured quads to the CurrentQuads array]
[13:07][Run the game to see where we were before]
[13:21][handmade_render_group.cpp: Enable PushBitmap() to push the quads on in a coherent way]
[16:29][Run the game and step in to OpenGLRenderCommands() to inspect the QuadCount]
[19:05][handmade_render_group.cpp: Introduce GetCurrentQuads()]
[24:50][handmade_render_group.cpp: Make PushCube() construct the cube data inline]
[27:37][handmade_render_group.cpp: Introduce PushQuad()]
[31:55][handmade_render_group.cpp: Clean up compile errors]
[34:16][Run the game to see textured cubes and note that we must bind some texture to the sampler]
[37:11][Consider creating a permanently resident plain white asset]
[39:35][handmade_opengl.cpp: Create a WhiteBitmap]
[46:30][handmade_render_group.cpp: Introduce a version of PushCube() that takes the WhiteBitmap directly]
[48:55][handmade_opengl.cpp: Initialise WhiteBitmap to 0xFFFFFFFF and run the game to admire the fanciness]
[49:56][Investigate what's going on with that colouring]
[52:39][Step in to OpenGLAllocateTexture() and inspect the Data]
[53:40][handmade_opengl.cpp: Prevent OpenGLInit() from returning anything, and tweak the WhiteBitmap]
[56:00][Run the game and investigate the hypothesis that it's the vertices of the cube, rather than our texture, that are broken]
[1:02:56][handmade_opengl.cpp: Prevent OpenGLAllocateTexture() from doing linear filtering, and run the game to see that this looks correct]
[1:04:45][Consult the documentation on glTexParameter[ref
site="Khronos"
page="glTexParameter"
url="https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/glTexParameter.xml"]]
[1:05:08][handmade_opengl.cpp: Make OpenGLAllocateTexture() use GL_CLAMP_TO_EDGE]
[1:05:55][Run the game to see that this also looks correct]
[1:07:05][Consult the OpenGL 4.5[ref
site=OpenGL
page="OpenGL 4.5 (Core Profile)"
url=https://www.khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf] and 2.0[ref
site=OpenGL
page="The OpenGL Graphics System: A Specification (Version 2.0)"
url=https://www.khronos.org/registry/OpenGL/specs/gl/glspec20.pdf] documentation on CLAMP]
[1:09:38][Run the game and determine that we're drawing what we expect to draw]
[1:10:07][handmade_opengl.cpp: Ensure that sRGB is being correctly passed through the pipeline]
[1:15:23][handmade_render_group.h: Remove bitmap and rectangle from render_entry_group_type]
[1:15:55][handmade_render_group.cpp: Enable PushRect() to push on to the CurrentQuads array]
[1:22:14][Run the game, note that everything is going through the new path and inspect the QuadCount]
[1:23:16][A few words on why this is an improvement]
[1:25:20][handmade_opengl.cpp: Force a call to OpenGLRectangle(), step into it and inspect the assembly]
[1:28:56][A few words on going fully bindless in order to do this in bulk completely]
[1:34:55][Consult the documentation on glDrawArrays[ref
site=docs.GL
page="glDrawArrays"
url=http://docs.gl/gl3/glDrawArrays] and glVertexAttribPointer[ref
site=docs.GL
page="glVertexAttribPointer"
url=http://docs.gl/gl3/glVertexAttribPointer]]
[1:40:47][handmade_opengl.cpp: Enable OpenGLRenderCommands() to setup arrays for the texcoord, color and position]
[1:45:32][Blackboard: Striding through our vertex array]
[1:47:03][handmade_opengl.cpp: Continue working on OpenGLRenderCommands()]
[1:51:09][Consult the documentation on glGetAttribLocation[ref
site=docs.GL
page="glGetAttribLocation"
url=http://docs.gl/gl3/glGetAttribLocation]]
[1:52:14][handmade_opengl.cpp: Make OpenGLInit() allow us to specify the vertices to pass to the shader]
[1:56:42][handmade_opengl.cpp: Make OpenGLRenderCommands() call glDrawArrays()]
[1:59:18][handmade_opengl.cpp: Make OpenGLRenderCommands() pass the vertices directly to the shader program]
[2:02:25][win32_handmade.cpp: Pull in the necessary functions from glcorearb.h[ref
site="Khronos"
page="glcorearb.h"
url="https://www.khronos.org/registry/OpenGL/api/GL/glcorearb.h"]]
[2:07:27][Run the game to admire the loveliness and investigate it]
[2:08:08][handmade_opengl.cpp: Make OpenGLRenderCommands() correctly loop through the vertices and run the game to see that we're getting close]
[2:08:37][handmade_opengl.cpp: Make OpenGLInit() set the correct VertUVID]
[2:09:42][Run the game and note that we're in a good place, using fewer OpenGL calls]
[2:12:18][Q&A][:speech]
[2:12:50][@kim_jorgensen][Would it be better to expose an OpenGLGetProcAddress method in the platform layer and do the lookups in the handmade_opengl layer?]
[2:14:22][@vaualbus][We will use VBO and IBO? In that case you prefer using glBufferData to send TGE data into the buffer or using glMapBuffer / glUnmapBuffer to send the data?]
[2:17:30][@robrobby][Will you use 4coder in full window mode (4ed.exe -F) in the future?]
[2:18:16][@macielda][By moving the construction of the vertex array to the RenderGroup, we kind of miss the opportunity of writing the quads directly into driver-owned memory, e.g. glMapBuffer. Is that statement correct? If so, is that a problem?]
[2:20:08][@kim_jorgensen][Couldn't OpenGLGetProcAddress just return the method directly on some platforms, using string lookup?]
[2:21:36][@jessem3y3r][Why not build one massive vertex buffer and just draw that once?]
[2:23:51][@jessem3y3r][I see, thanks! Any chance we can see a render callstack from nsight or renderdoc just to see what the driver has to work through?]
[2:24:24][Install RenderDoc[ref
site=RenderDoc
url=https://renderdoc.org/builds]]
[2:26:04][Run the game in RenderDoc]
[2:27:57][@jessem3y3r][Press F12 to capture]
[2:29:47][@macielda][Does the Debug UI still work? If so, how does one activate it?]
[2:30:08][@Jim0_o][Have you set a version target for the pipeline? Will you go full Embedded Systems bananas (OpenGL ES)?]
[2:30:30][Close it down with a glimpse into the future][:speech]
[/video]