ObjectivelyGPU
Object oriented graphics framework for SDL3 and C
Loading...
Searching...
No Matches
Graphics pipeline presets

Ready-made render state to copy into an SDL_GPUGraphicsPipelineCreateInfo. More...

Variables

OBJECTIVELYGPU_EXPORT const SDL_GPUColorTargetBlendState GPU_BlendStateOpaque
 Opaque blending: source color overwrites the destination (no blending).
 
OBJECTIVELYGPU_EXPORT const SDL_GPUColorTargetBlendState GPU_BlendStateAlpha
 Straight (non-premultiplied) alpha blending: src·srcA + dst·(1 - srcA).
 
OBJECTIVELYGPU_EXPORT const SDL_GPUColorTargetBlendState GPU_BlendStatePremultipliedAlpha
 Premultiplied alpha blending: src + dst·(1 - srcA).
 
OBJECTIVELYGPU_EXPORT const SDL_GPUColorTargetBlendState GPU_BlendStateAdditive
 Additive blending: src·srcA + dst, for glow, particles, and light accumulation.
 
OBJECTIVELYGPU_EXPORT const SDL_GPUGraphicsPipelineCreateInfo GPU_GraphicsPipeline3D
 3D world geometry: triangle list, solid fill, back-face culling (CCW front), depth test and write enabled with LESS_OR_EQUAL.
 
OBJECTIVELYGPU_EXPORT const SDL_GPUGraphicsPipelineCreateInfo GPU_GraphicsPipeline2D
 2D UI and sprites: triangle list, solid fill, no culling, no depth test.
 

Detailed Description

Ready-made render state to copy into an SDL_GPUGraphicsPipelineCreateInfo.

Copy a pipeline preset by value, then fill in the caller-specific fields — vertex_shader, fragment_shader, vertex_input_state, and target_info:

SDL_GPUGraphicsPipelineCreateInfo info = GPU_GraphicsPipeline3D;
info.vertex_shader = vertexShader->shader;
info.fragment_shader = fragmentShader->shader;
info.vertex_input_state = (SDL_GPUVertexInputState) { ... };
info.target_info = (SDL_GPUGraphicsPipelineTargetInfo) {
.color_target_descriptions = &(SDL_GPUColorTargetDescription) {
.format = framebuffer->colorTexture->format,
.blend_state = GPU_BlendStateOpaque,
},
.num_color_targets = 1,
.depth_stencil_format = framebuffer->depthTexture->format,
.has_depth_stencil_target = true,
};
GraphicsPipeline *pipeline = $(renderDevice, createGraphicsPipeline, &info);
OBJECTIVELYGPU_EXPORT_DATA const SDL_GPUGraphicsPipelineCreateInfo GPU_GraphicsPipeline3D
Definition GraphicsPipeline.c:67
OBJECTIVELYGPU_EXPORT_DATA const SDL_GPUColorTargetBlendState GPU_BlendStateOpaque
Definition GraphicsPipeline.c:33
static GraphicsPipeline * createGraphicsPipeline(RenderDevice *self, const SDL_GPUGraphicsPipelineCreateInfo *info)
Definition RenderDevice.c:264
An SDL_GPUGraphicsPipeline: the compiled vertex/fragment program plus all fixed-function render state...
Definition GraphicsPipeline.h:51

Variable Documentation

◆ GPU_BlendStateAdditive

OBJECTIVELYGPU_EXPORT const SDL_GPUColorTargetBlendState GPU_BlendStateAdditive

Additive blending: src·srcA + dst, for glow, particles, and light accumulation.

◆ GPU_BlendStateAlpha

OBJECTIVELYGPU_EXPORT const SDL_GPUColorTargetBlendState GPU_BlendStateAlpha

Straight (non-premultiplied) alpha blending: src·srcA + dst·(1 - srcA).

◆ GPU_BlendStateOpaque

OBJECTIVELYGPU_EXPORT const SDL_GPUColorTargetBlendState GPU_BlendStateOpaque

Opaque blending: source color overwrites the destination (no blending).

◆ GPU_BlendStatePremultipliedAlpha

OBJECTIVELYGPU_EXPORT const SDL_GPUColorTargetBlendState GPU_BlendStatePremultipliedAlpha

Premultiplied alpha blending: src + dst·(1 - srcA).

◆ GPU_GraphicsPipeline2D

OBJECTIVELYGPU_EXPORT const SDL_GPUGraphicsPipelineCreateInfo GPU_GraphicsPipeline2D

2D UI and sprites: triangle list, solid fill, no culling, no depth test.

Fill in vertex_shader, fragment_shader, vertex_input_state, and target_info. Apply a blend preset via each color target's blend_state.

◆ GPU_GraphicsPipeline3D

OBJECTIVELYGPU_EXPORT const SDL_GPUGraphicsPipelineCreateInfo GPU_GraphicsPipeline3D

3D world geometry: triangle list, solid fill, back-face culling (CCW front), depth test and write enabled with LESS_OR_EQUAL.

Fill in vertex_shader, fragment_shader, vertex_input_state, and target_info (including depth_stencil_format and has_depth_stencil_target).