Small program to quickly test OpenGL GLSL shaders.
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.
 
 
 

96 lines
1.5 KiB

#pragma once
#include <GL/glew.h>
#include <glm/glm.hpp>
typedef uint32_t u32;
struct gl_uniform
{
GLenum id;
GLenum data_type;
};
struct gl_buffer
{
GLuint id;
GLenum data_type;
};
struct shader
{
GLuint prog_id;
GLuint xforms_ubo_id;
};
struct transforms
{
glm::mat4 view_xform;
glm::mat4 proj_xform;
glm::mat4 normal_xform;
};
enum glsl_layout
{
POSITION,
NORMAL,
UV,
COLOR
};
struct mesh
{
u32 num_vertices;
u32 num_indices;
glm::vec3* vertices;
glm::vec3* normals;
glm::vec3* uvs;
glm::vec3* colors;
u32* indices;
};
struct gl_mesh
{
u32 num_indices;
GLuint vao_id;
GLuint tex_id;
GLenum draw_mode;
glm::mat4* model_xform;
GLuint model_xform_id;
GLuint vert_buf_id;
GLuint norm_buf_id;
GLuint uv_buf_id;
GLuint clr_buf_id;
GLuint idx_buf_id;
};
struct node;
struct entity;
struct light;
struct animation;
const float DEFAULT_FOV = 60.f;
const float NEAR_CLIP_PLANE = 5.f;
const float DEFAULT_ASPECT_RATIO = 16.f / 9.f;
const glm::vec3 DEFAULT_CAM_POS = { 0, 0, -30.f };
const glm::vec3 DEFAULT_LOOK_POS = { 0, 0, 0 };
bool loadShaderProgram(const char* vs, const char* fs, shader* s);
transforms initXformUBO(shader* s,
float fov = DEFAULT_FOV,
float near_clip_plane = NEAR_CLIP_PLANE,
float aspect_ratio = DEFAULT_ASPECT_RATIO,
glm::vec3 cam_pos = DEFAULT_CAM_POS,
glm::vec3 look_pos = DEFAULT_LOOK_POS);
mesh initCubeMesh();
gl_mesh loadGLMesh(shader* s, const mesh& m, const glm::vec3& pos);
void loop(shader* s, gl_mesh* mesh_arr, u32 num_meshes);
void quit(shader* s);