A small OpenGL 3+ renderer and game engine
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

67 lines
1.2 KiB

#pragma once
#if defined (_WIN32)
#include <SDL.h>
#else
#include <SDL2/SDL.h>
#endif
#include <GL/glew.h>
#include <glm/glm.hpp>
#include "camera.h"
#include "entity.h"
#include "lights.h"
#include "util.h"
#include "shader_program.h"
struct SDL_Handles
{
SDL_Window *window;
SDL_GLContext glContext;
SDL_DisplayMode currentDisplayMode;
};
// NOTE: array of entities rendered with the same shader program
struct render_group
{
entity* entities;
uint entity_count;
shader_program shader;
};
struct render_state
{
glm::vec2 viewport_dims;
SDL_Handles handles;
camera cam;
util_RGBA clear_col;
// TODO: this really needs to be a resizable array, or linked list, or
// ...gasp, std::vector
render_group* render_groups;
uint render_group_count;
shader_program* default_shader;
light_group* lights;
};
render_state*
renInit(const char* title = "Tangerine",
glm::vec2 viewport_dims = glm::vec2(1280, 720));
void renShutdown(render_state* rs);
render_group*
renAllocateGroup(uint entity_count, shader_program shader);
void renRenderFrame(render_state* rs);
bool
renAddLight(render_state* rs,
glm::vec3 pos = glm::vec3(0, 0, 0),
glm::vec3 color = glm::vec3(1, 1, 1),
float intensity = 1.0);