diff --git a/examples/main.cpp b/examples/main.cpp index 03776fc..bfaa384 100644 --- a/examples/main.cpp +++ b/examples/main.cpp @@ -329,7 +329,7 @@ render_cb_pre(RenderState* rs) int main() { - RenderState* rs = initRenderState(); + RenderState* rs = initRenderState("tangerine example", uvec2(1600, 900)); if (rs) { if (!loadScene(rs)) { diff --git a/include/tangerine.h b/include/tangerine.h index ca82636..ad2b933 100644 --- a/include/tangerine.h +++ b/include/tangerine.h @@ -84,6 +84,8 @@ #include "types.h" #include "util.h" +using glm::uvec2; + struct SDLHandles { @@ -189,6 +191,8 @@ struct RenderState }; +#define DEFAULT_WIDTH 1280 +#define DEFAULT_HEIGHT 720 #define DEFAULT_MODEL_COUNT 256 #define DEFAULT_TEXTURE_COUNT 64 #define DEFAULT_SHADER_COUNT 64 @@ -197,7 +201,9 @@ struct RenderState #define DEFAULT_CLEAR_COLOR { 0.2, 0.2, 0.2, 1 } #define DEFAULT_AMBIENT_COLOR { 0.1, 0.1, 0.1, 1 } #define DEFAULT_MAX_LIGHTS 32 // NOTE: needs to match NUM_LIGHTS in shaders -RenderState* initRenderState(GLClearColor clear_col = DEFAULT_CLEAR_COLOR, +RenderState* initRenderState(const char* window_title = "tangerine", + uvec2 window_dims = uvec2(DEFAULT_WIDTH, DEFAULT_HEIGHT), + GLClearColor clear_col = DEFAULT_CLEAR_COLOR, glm::vec4 ambient_color = DEFAULT_AMBIENT_COLOR, u32 max_models = DEFAULT_MODEL_COUNT, u32 max_textures = DEFAULT_TEXTURE_COUNT, diff --git a/src/tangerine.cpp b/src/tangerine.cpp index 830a2d0..f870f3c 100644 --- a/src/tangerine.cpp +++ b/src/tangerine.cpp @@ -12,7 +12,7 @@ using glm::vec4; // forward declarations -bool initGraphics(SDLHandles* handles); +bool initGraphics(SDLHandles* handles, const char* title, uvec2 dims); LightsBuffer* initLights(RenderState* rs, u32 max_lights, vec4 ambient_color); @@ -20,7 +20,9 @@ LightsBuffer* initLights(RenderState* rs, u32 max_lights, vec4 ambient_color); // interface RenderState* -initRenderState(GLClearColor clear_col, +initRenderState(const char* window_title, + uvec2 window_dims, + GLClearColor clear_col, vec4 ambient_color, u32 max_models, u32 max_textures, @@ -46,7 +48,7 @@ initRenderState(GLClearColor clear_col, rs->render_groups = ARENA_ALLOC(rs->rg_arena, RenderGroup, DEFAULT_RENDER_GROUP_COUNT); - if (!initGraphics(&rs->handles)) { + if (!initGraphics(&rs->handles, window_title, window_dims)) { LOGF(Error, "error initializing renderer\n"); return nullptr; } @@ -267,14 +269,14 @@ getVertexAttribByType(ShaderProgram* shader, MeshBufferType buf_type) // internal bool -initGraphics(SDLHandles* handles) +initGraphics(SDLHandles* handles, const char* title, uvec2 dims) { handles->window = SDL_CreateWindow( - "shader_testing", + title, SDL_WINDOWPOS_CENTERED_DISPLAY(0), SDL_WINDOWPOS_CENTERED_DISPLAY(0), - 1280, - 720, + dims.x, + dims.y, SDL_WINDOW_OPENGL|SDL_WINDOW_RESIZABLE); if (SDL_Init(SDL_INIT_VIDEO) != 0) {