#ifndef GL_GRAPHICS_H #define GL_GRAPHICS_H typedef struct BufferO { u32 VAO; // Vertex Array Object u32 VBO; // Vertex Buffer Object u32 EBO; // Element Buffer Object u32 TexO; // Texture Buffer Object u32 *TexArray; // Tex Object Array } BufferO; typedef struct Texture2D { i32 width; i32 height; i32 nrChannels; unsigned char* data; } Texture2D; void LoadUniformInt(u32 SP, const char *Unifrom, i32 Val); void LoadUniformFloat(u32 SP, const char *Uniform, f32 Val); void LoadUniformVec3(u32 SP, const char *Unifrom, Vec3 Val); void LoadUniformMat4(u32 SP, const char *Uniform, Mat4 Val); u32 CreateVertexShader(const char *VertexShaderSource); u32 CreateFragmentShader(const char *FragmentShaderSource); u32 CreateShaderProgram(unsigned int VertexShader, unsigned int FragmentShader); u32 CreateTriangle(f32 vertices[], i32 sz); void DrawTriangle(u32 VAO); u32 CreateRectangle(f32 vertices[], i32 v_sz, u32 indices[], i32 i_sz); /** * @note: the texture functions for rectangle are more obtuse and less clear * they don't make as much sense. And they dont just create something. * They play on to the state machine-ness of opengl, and just enable a set of * operations I find repetitive. * * @todo: I need to probably add the examples to my utils file as notes * */ BufferO CreateRectangleTextured(f32 vertices[], i32 v_sz, u32 indices[], i32 i_sz, u32 attr); void MakeRectangleTextured(BufferO *bo, f32 vertices[], i32 v_sz, u32 indices[], i32 i_sz, u32 attr); void DrawRectangle(u32 VAO); void DrawRectangleTextured(u32 VAO, u32 TexO); BufferO CreateCube(f32 vertices[], i32 v_sz); BufferO CreateCubeTextured(f32 vertices[], i32 v_sz); void DrawCube(u32 VAO); GLint GetColorAttrib(u32 nrChannels); void GenAndBindGlTexture(Texture2D Tex, u32 VAO, u32 *TexO); void BindGlTexture(Texture2D Tex, u32 VAO, u32 TexO); #endif