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.
 
 
 

57 lines
1.5 KiB

#pragma once
#include <GL/glew.h>
#include "types.h"
// TODO: implement a 'cavity' effect for the default shader
// https://blender.community/c/rightclickselect/J9bbbc/
// https://developer.blender.org/rBf1fd5ed74fb0afd602f53860d0b2db46189c218a
// https://developer.blender.org/diffusion/B/browse/master/source/blender/draw/engines/workbench/shaders/workbench_cavity_lib.glsl
// https://www.casual-effects.com/research/McGuire2011AlchemyAO/VV11AlchemyAO.pdf
// https://github.com/evanw/madebyevan.com/blob/master/src/templates/shaders-curvature.jade
struct default_shader_program
{
GLuint program_id;
GLuint model_matrix_id;
GLuint world_transform_id;
GLuint view_matrix_id;
GLuint projection_matrix_id;
GLuint normal_matrix_id;
GLuint vertex_array_id;
GLuint sampler_id;
GLuint num_lights_id;
};
struct simple_shader_program
{
GLuint program_id;
GLuint world_transform_id;
GLuint MVP_id;
GLuint vertex_array_id;
};
struct shader_wrapper
{
shader_t shader_type;
default_shader_program* default_shader;
simple_shader_program* simple_shader;
};
// TODO: find a way to initialize different shaders with different
// uniform layouts with a single function
// look at using uniform blocks and retrieving locations with
// glGetUniformBlockIndex() and their size with glGetActiveUniformBlockiv()
// see chapter 2 in the red book
simple_shader_program*
shaderInitSimple(const char* vertex_code, const char* frag_code);
default_shader_program*
shaderInitDefault(const char* vertex_code, const char* frag_code);
void shaderFree(uint program_id);