Renderer - SWTube/Darkest-Cave GitHub Wiki
Render Process
Init
- Set error callback (UNIX GLFW)
- Initialize Dependencies (UNIX GLFW)
- Initialize Window
- Initialize Device
InitWindow
- Register Class (WIN32
WNDCLASSEX
)
- Create Window
- Show Window (WIN32
ShowWindow
)
- Set Callbacks (UNIX GLFW)
InitDevice
- Create D3D11 Device and Make Context Current (WIN32
D3D11CreateDevice
)
- Make Context Current
- Initialize Dependencies (UNIX GL3W)
- Obtain DXGI factory from device (WIN32
IDXGIFactory*
)
- Create swap chain (WIN32
DXGI_SWAP_CHAIN_DESC*
)
- Create Render Target View (WIN32
CreateRenderTargetView
)
- Create Depth Stencil Texture (WIN32
CreateTexture2D
)
- Create Depth Stencil View (WIN32
CreateDepthStencilView
)
- Set Render Targets (WIN32
OMSetRenderTargets
)
- Setup Viewport (WIN32
RSSetViewport
)
- Compile Shaders
- Define, create, set the input layout (in UNIX, this is done after binding the buffers)
- WIN32
D3D11_INPUT_ELEMENT_DESC
CreateInputLayout
IASetInputLayout
- UNIX
glVertexAttribPointer
glEnableVertexAttribArray
- Set up Vertices and Indices
- Create Buffer
- WIN32
- UNIX
glCreateBuffers
/ glGenBuffer
- Bind / Set Buffers
- WIN32
IASetVertexBuffers
IASetIndexBuffer
- UNIX
- Bind
glBindBuffer
- Store Buffers (
glNamedBufferStorage
)
- Set primitive topology (WIN32
IASetPrimitiveTopology
)
- Create constant buffer (WIN32
CreateBuffer
)
- Load Textures
- WIN32
- UNIX
- Create Textures (
glCreateTextures
)
- Bind Texture (
glBindTextureUnit
)
- Get uniform location for Texture (
glGetUniformLocation
)
- Set Texture Parameters (
glTextureParameter*
)
- Store Texture (
glTextureStorage2D
)
- Create Image (1glTextureSubImage2D`)
- Generate Mipmap (
glGenerateTextureMipmap
)
- Get uniform location for Texture and set (
glUniform*
)
- Create sample state (WIN32
CreateSamplerState
)
- Initialize matrices + inject them to constant buffers
- Create Vertex Arrays (
glCreateVertexArrays
)
Render
- Calculate transformations (WIN32)
- Clear buffer
- WIN32
- clear back buffer
ClearRenderTargetView
- clear depth buffer
ClearDepthStencilView
- UNIX
- Update variables (WIN32 feed the transformed values to the constant buffer)
- Set Render Data
- WIN32
*SSetShader
*SSetConstantBuffers
*SSetShaderResources
*SSetSamplers
- UNIX
- Bind Texture Unit (UNIX
glBindTextureUnit
)
- Bind Vertex Array (UNIX
glBindVertexArray
)
- Bind Buffers (UNIX
glBindBuffer
. bind element array buffer)
- Render
- WIN32
- UNIX
glDrawArrays
, glDrawElements
- Swap buffers
Destroy