Queues render target switch (deferred command, subsequent draws render to this texture).
Takes imageHandle (render target handle from b2dCreateRenderTarget, positive integer, must have isRenderTarget=true).
Returns nothing.
2D Overlay
Parameters & Returns
Parameters
imageHandleInt
Returns
Void
Quick Summary
Queues render target switch (deferred command, subsequent draws render to this texture).
Takes imageHandle (render target handle from b2dCreateRenderTarget, positive integer, must have isRenderTarget=true).
Returns nothing.
Technical Exegesis...
Queues render target switch (deferred command, subsequent draws render to this texture). Takes imageHandle (render target handle from b2dCreateRenderTarget, positive integer, must have isRenderTarget=true). Returns nothing.
Queues render target switch (deferred command, subsequent draws render to this texture). Takes imageHandle (render target handle from b2dCreateRenderTarget, positive integer, must have isRenderTarget=true). Returns nothing. Creates CMD_SET_RENDER_TARGET command (queued to g_overlayCommands, executed during b2dFlush or b3dRenderWorld), updates g_currentState dimensions (sets renderTargetWidth/Height for subsequent draw commands), affects all subsequent draws (b2dDrawImage, b2dDrawAnimImage, b2dDrawText, etc render to this RT until b2dSetDefaultRenderTarget called). Use to render to texture (offscreen rendering for compositing), create dynamic textures (draw shapes/text to RT then use as texture), build UI layers (composite complex UI in RT), or create effects (minimap, mirror, portal rendering). Deferred execution: command queued (not executed immediately, added to command buffer), executed during flush (b2dFlush or b3dRenderWorld processes command), order matters (commands executed in queue order, SET_RENDER_TARGET affects subsequent draws in buffer). Use cases: (1) Minimap (b2dSetRenderTarget(minimapRT): draw map elements: b2dSetDefaultRenderTarget(): draw minimapRT to corner), (2) Dynamic texture (b2dSetRenderTarget(texRT): draw procedural content: b2dSetDefaultRenderTarget(): apply texRT to 3D model), (3) UI layers (b2dSetRenderTarget(uiRT): draw UI elements: b2dSetDefaultRenderTarget(): draw uiRT with fade effect), (4) Post-processing (b2dSetRenderTarget(bufferRT): draw scene: b2dSetDefaultRenderTarget(): draw bufferRT with shader), (5) Text to texture (b2dSetRenderTarget(textRT): b2dDrawText: b2dSetDefaultRenderTarget(): use textRT as dynamic label). Common patterns: activate = b2dSetRenderTarget(rt): draw commands: b2dSetDefaultRenderTarget() switch to RT, draw, reset; immediate execution = b2dSetRenderTarget(rt): b2dFlush() force immediate switch. Render target state: active until reset (remains active for all subsequent queued draws until b2dSetDefaultRenderTarget), dimension tracking (g_currentState.renderTargetWidth/Height updated for coordinate systems), GPU transitions (engine transitions RT texture PIXEL_SHADER_RESOURCE -> RENDER_TARGET during execution). Command execution: during b2dFlush (user calls b2dFlush to execute commands immediately), during b3dRenderWorld (automatic execution when rendering 3D world), GPU barriers (automatic resource state transitions RT <-> texture), clear on execute (render target cleared to its clearColor before first draw). State capture: captures current state (command stores g_currentState snapshot including color/alpha/scale/rotation), RT dimensions (width/height stored for subsequent draw coordinate calculations), canvas filter (command respects g_activeCanvasFilter binding). Performance: queue cost minimal (command structure creation and push, ~0.001ms), execution cost moderate (RT binding + clear + barriers, ~0.1-1ms depending on RT size), batching broken (render target switch prevents batching, each RT costs PSO bind and clear). Validation: ignores if invalid handle (handle not in g_images map, prints error, silently skips), requires isRenderTarget flag (handle must be from b2dCreateRenderTarget, regular images rejected), no dimension check (RT can be any size, coordinates not validated). Related: b2dCreateRenderTarget creates RT (allocates render target used by this function), b2dSetDefaultRenderTarget resets to screen (switches back to screen rendering, ends RT rendering), b2dFlush executes commands (forces immediate RT switch and draw execution), b2dGrabImage captures from RT (reads pixels from active render target), b2dDrawImage draws RT as texture (displays RT contents after rendering to it).