Rendering code for main game menu


I have looked almost everywhere for the actual rendering code (which makes OpenGL function calls) for the main menu. All I could see was the syscall function being used but even with using VS2017’s find references to variables and functions I was not able to find it…I want to convert the code to DirectX11 and I thought that starting with the menu would be a good idea.



All rendering in Quake 3 stores data in an array (vertex position, colors, etc) [see shaderCommands_t structure] and draws it using a shader. 2D and 3D graphics share the same main rendering functions. Modern games called Q3’s “shaders” materials to avoid confusing with GPU shaders.

Introduction to Q3 shaders:

2D graphic drawing.

  1. Register shader using trap_R_RegisterShader() which finds explicit shader definition or uses implicit shader and loads necessary image files.
  2. Add render command using trap_R_DrawStretchPic() which calls RE_StretchPic() in the engine.
  3. Later render commands are executed by RB_ExecuteRenderCommands().
  4. RB_StretchPic() sets up the shader / vertex information.
  5. Later when attempting to draw a different shader or finished drawing for the scene, RB_EndSurface() is called which preforms the shader drawing. Typically using RB_StageIteratorGeneric().

code/renderergl1/tr_shader.c has the default implicit shader information for LIGHTMAP_2D (“2D graphics”) and loading shader files. RB_StageIteratorGeneric() and basically the entirety of code/renderergl1/tr_shade.c and code/renderergl1/tr_shade_calc.c does the actually drawing.


Awesome, RB_StretchPic() is the function I was looking for. It clearly sets up quads for 2d rendering.

Thanks a lot!