MrFrenik / gunslinger

C99, header-only framework for games and multimedia applications

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Uniform Arrays handling

PixelRifts opened this issue · comments

There seems to be no wrapper around glUniformXv which handles uploading arrays of uniforms.
Currently, you have to have a bunch of uniforms which can get very tedious.

Considering this as a potential API change:

// Construct sampler buffer (added the .count field for variable arrays)
u_tex = gs_graphics_uniform_create (
    &(gs_graphics_uniform_desc_t) {
        .stage = GS_GRAPHICS_SHADER_STAGE_FRAGMENT,
        .name = "u_tex",
        .layout = &(gs_graphics_uniform_layout_desc_t){.type = GS_GRAPHICS_UNIFORM_SAMPLER2D, .count = 16}			// So you can upload multiples of data
    }
);

// Later on 
// Texture data array
gs_handle(gs_graphics_texture_t) textures[] = {
    ... 
};
// Binding 
gs_graphics_bind_desc_t binds = {
    .uniforms = {.desc = &(gs_graphics_bind_uniform_desc_t){.uniform = u_tex, .data = textures, .binding = 0}}
};

Nothing too drastic i hope :-)

It shouldn't be, hopefully

Added this in commit: 6c183e7