Handmade Hero » Forums » Code » Help understanding render commands
boagz57
Jason
22 posts
#14855 Help understanding render commands
3 months, 1 week ago Edited by Jason on April 7, 2018, 3:14 p.m. Reason: Initial post

So I've jumped a head a bit through handmade hero to see how Casey starts implementing opengl and in the series of videos he starts describing his 'three tiered architecture' which involves the game passing 'render commands' to a buffer which can then be rendered. I understand that this helps separate game code from any specific rendering code thus avoiding round trips through the platform layer. However, I'm a little stuck on what exactly constitutes a render command. I tried looking through the code but since I haven't watched all the videos leading up to it I'm having trouble grasping it. What exactly is an individual render command? What sort of data is stored in it?
mmozeiko
Mārtiņš Možeiko
1716 posts / 1 project
#14859 Help understanding render commands
3 months, 1 week ago

Example of render commands:
1) clear current framebuffer with color C
2) clear current depth buffer
2) set current framebuffer to specific FB
3) draw quad with following vertices V1,V2,V3,V4 - that includes position, texcoord, and color and other info related to lighting

Render command can be whatever you want - its just an information you want to pass render API like OpenGL, D3D or other.
boagz57
Jason
22 posts
#14860 Help understanding render commands
3 months, 1 week ago

Okay so basically it's just like opengl or directx instead its your own, platform independent commands that you can then pass to your renderer for it to figure out what to do with it? So if say your renderer is built using opengl commands then your own 'clear_buffer()' function/command would get sent to the renderer and the renderer would call the opengl specific glclearbuffer() within? Am I understanding this correctly?
mmozeiko
Mārtiņš Možeiko
1716 posts / 1 project
#14871 Help understanding render commands
3 months, 1 week ago

Yes, that's exactly what clear command should do - call glClear or similar function.