---
name: sokol_setup
kind: function
lang: cpp
domain: gfx
version: "0.1.0"
purity: pure
signature: "make_environment() -> sg_environment; make_swapchain(int w, int h) -> sg_swapchain"
description: "Builders puros para inicializar sokol_gfx encima de un GL context creado por SDL3 (no por sokol_app). Construye sg_environment con defaults RGBA8 + depth/stencil y sg_swapchain con el default framebuffer del contexto activo. Issue 0072b — base del runtime gamedev en PC + WASM."
tags: [gamedev-engine, sokol, gfx, sdl3, wasm]
uses_functions: []
uses_types: []
returns: []
returns_optional: false
error_type: ""
imports: []
example: |
  // tras SDL_GL_CreateContext():
  sg_desc d{};
  d.environment = fn::gfx::make_environment();
  d.logger.func = slog_func;
  sg_setup(&d);
  // por frame:
  sg_pass p{};
  p.swapchain = fn::gfx::make_swapchain(w, h);
  sg_begin_pass(&p);
tested: false
tests: []
test_file_path: ""
file_path: "cpp/functions/gfx/sokol_setup.cpp"
params:
  - name: width
    desc: "Ancho del framebuffer en pixeles. Usar SDL_GetWindowSizeInPixels."
  - name: height
    desc: "Alto del framebuffer en pixeles."
output: "Estructuras sg_environment / sg_swapchain listas para sokol_gfx."
---

# sokol_setup

Helpers minimos para usar `sokol_gfx` con SDL3 sin depender de `sokol_glue.h` (que importa simbolos de `sokol_app` y rompe en stacks SDL3-driven).

Definidos como funciones puras: solo construyen structs, no tocan estado global. Llamadas tipicas en `engine_smoke` (issue 0072a) y `runtime_test` (0072b).
