medfall

A super great game engine
Log | Files | Refs

commit 6b0a6f4986e06a164167da17240ce6731d6969ea
parent 742a0c1283d982821bb14ed2cdd998d5c1c86056
Author: Michael Savage <mikejsavage@gmail.com>
Date:   Tue May 16 21:39:14 +0300

Use StaticArray in RenderState/HotloadShader

Diffstat:
renderer.h | 11++++++-----
shaders.cc | 8++++----
2 files changed, 10 insertions(+), 9 deletions(-)
diff --git a/renderer.h b/renderer.h @@ -1,6 +1,7 @@ #pragma once #include "intrinsics.h" +#include "array.h" #include "linear_algebra.h" /* @@ -59,9 +60,9 @@ struct FB { }; struct RenderState { - UB ubs[ RENDERER_MAX_UBS ] = { }; - Texture textures[ RENDERER_MAX_TEXTURES ] = { }; - TB tbs[ RENDERER_MAX_TEXTURE_BUFFERS ] = { }; + StaticArray< UB, RENDERER_MAX_UBS > ubs = { }; + StaticArray< Texture, RENDERER_MAX_TEXTURES > textures = { }; + StaticArray< TB, RENDERER_MAX_TEXTURE_BUFFERS > tbs = { }; FB fb = { }; Shader shader = INVALID_SHADER; DepthFunc depth_func = DEPTHFUNC_LESS; @@ -125,8 +126,8 @@ struct MeshConfig { struct ShaderConfig { const char * src = NULL; - const char * texture_uniform_names[ RENDERER_MAX_TEXTURES ] = { }; - const char * texture_buffer_uniform_names[ RENDERER_MAX_TEXTURE_BUFFERS ] = { }; + StaticArray< const char *, RENDERER_MAX_TEXTURES > texture_uniform_names = { }; + StaticArray< const char *, RENDERER_MAX_TEXTURE_BUFFERS > texture_buffer_uniform_names = { }; }; enum TextureFormat { diff --git a/shaders.cc b/shaders.cc @@ -10,8 +10,8 @@ struct HotloadShader { const char * path = NULL; Shader shader = 0; time_t last_modified = 0; - const char * texture_uniform_names[ RENDERER_MAX_TEXTURES ] = { }; - const char * texture_buffer_uniform_names[ RENDERER_MAX_TEXTURE_BUFFERS ] = { }; + StaticArray< const char *, RENDERER_MAX_TEXTURES > texture_uniform_names = { }; + StaticArray< const char *, RENDERER_MAX_TEXTURE_BUFFERS > texture_buffer_uniform_names = { }; }; StaticArray< HotloadShader, SHADER_COUNT > shaders; @@ -82,8 +82,8 @@ int hotload_shaders() { ShaderConfig shader_config; shader_config.src = contents; - memcpy( shader_config.texture_uniform_names, shader.texture_uniform_names, sizeof( shader.texture_uniform_names ) ); - memcpy( shader_config.texture_buffer_uniform_names, shader.texture_buffer_uniform_names, sizeof( shader.texture_buffer_uniform_names ) ); + shader_config.texture_uniform_names = shader.texture_uniform_names; + shader_config.texture_buffer_uniform_names = shader.texture_buffer_uniform_names; Shader new_shader = renderer_new_shader( shader_config ); if( new_shader != INVALID_SHADER ) {