summaryrefslogtreecommitdiff
path: root/code/gl_graphics.cpp
diff options
context:
space:
mode:
authortalha <talha@talhaamir.xyz>2023-08-30 22:58:18 +0500
committertalha <talha@talhaamir.xyz>2023-08-30 22:58:18 +0500
commit66e84eabf70a11d91abbbe8777b1746573a51bae (patch)
tree3cca9403bde6a97889353b439ec84af5c661d988 /code/gl_graphics.cpp
parentd980dcd2b66e4879989ce18291d044d5a4ffc902 (diff)
Refactored files:
- moved memory arenas to memory files - replaced r32 and r64 with f32 and f64 - prefixing internal libs with amr_
Diffstat (limited to 'code/gl_graphics.cpp')
-rw-r--r--code/gl_graphics.cpp46
1 files changed, 23 insertions, 23 deletions
diff --git a/code/gl_graphics.cpp b/code/gl_graphics.cpp
index 91730ec..0c2aa62 100644
--- a/code/gl_graphics.cpp
+++ b/code/gl_graphics.cpp
@@ -9,7 +9,7 @@ void LoadUniformInt(u32 SP, const char *Uniform, i32 Val)
glUniform1i(glGetUniformLocation(SP, Uniform), Val);
}
-void LoadUniformFloat(u32 SP, const char *Uniform, r32 Val)
+void LoadUniformFloat(u32 SP, const char *Uniform, f32 Val)
{
glUniform1f(glGetUniformLocation(SP, Uniform), Val);
}
@@ -19,7 +19,7 @@ void LoadUniformVec3(u32 SP, const char *Uniform, Vec3 Val)
glUniform3f(glGetUniformLocation(SP, Uniform), Val.x, Val.y, Val.z);
}
-void LoadUniformMat4(u32 SP, const char *Uniform, const r32 *Val)
+void LoadUniformMat4(u32 SP, const char *Uniform, const f32 *Val)
{
glUniformMatrix4fv(glGetUniformLocation(SP, Uniform), 1, GL_TRUE, Val);
}
@@ -94,7 +94,7 @@ u32 CreateShaderProgram(unsigned int VertexShader, unsigned int FragmentShader)
// ---------------------------------------------------------------------------
-u32 CreateTriangle(r32 vertices[], i32 sz)
+u32 CreateTriangle(f32 vertices[], i32 sz)
{
u32 VAO;
glGenVertexArrays(1, &VAO);
@@ -107,11 +107,11 @@ u32 CreateTriangle(r32 vertices[], i32 sz)
glBufferData(GL_ARRAY_BUFFER, sz, vertices, GL_STATIC_DRAW);
// position attribute
- glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 6*sizeof(r32), (void*)0);
+ glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 6*sizeof(f32), (void*)0);
glEnableVertexAttribArray(0);
// color attribute
- glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 6*sizeof(r32), (void*)(3*sizeof(r32)));
+ glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 6*sizeof(f32), (void*)(3*sizeof(f32)));
glEnableVertexAttribArray(1);
// unbind post setup
@@ -127,7 +127,7 @@ void DrawTriangle(u32 VAO)
glBindVertexArray(0);
}
-u32 CreateRectangle(r32 vertices[], i32 v_sz, u32 indices[], i32 i_sz)
+u32 CreateRectangle(f32 vertices[], i32 v_sz, u32 indices[], i32 i_sz)
{
u32 VAO;
glGenVertexArrays(1, &VAO);
@@ -145,11 +145,11 @@ u32 CreateRectangle(r32 vertices[], i32 v_sz, u32 indices[], i32 i_sz)
glBufferData(GL_ELEMENT_ARRAY_BUFFER, i_sz, indices, GL_STATIC_DRAW);
// position attribute
- glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 6*sizeof(r32), (void*)0);
+ glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 6*sizeof(f32), (void*)0);
glEnableVertexAttribArray(0);
// color attribute
- glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 6*sizeof(r32), (void*)(3*sizeof(float)));
+ glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 6*sizeof(f32), (void*)(3*sizeof(float)));
glEnableVertexAttribArray(1);
// unbind post setup
@@ -159,7 +159,7 @@ u32 CreateRectangle(r32 vertices[], i32 v_sz, u32 indices[], i32 i_sz)
}
-BufferO CreateRectangleTextured(r32 vertices[], i32 v_sz, u32 indices[], i32 i_sz, u32 attr)
+BufferO CreateRectangleTextured(f32 vertices[], i32 v_sz, u32 indices[], i32 i_sz, u32 attr)
{
/*
* This will setup options and buffer objects to create a rectangle based on a texture
@@ -197,13 +197,13 @@ BufferO CreateRectangleTextured(r32 vertices[], i32 v_sz, u32 indices[], i32 i_s
u8 attr_pos = 1;
// position attribute
- glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, stride*sizeof(r32), (void*)0);
+ glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, stride*sizeof(f32), (void*)0);
glEnableVertexAttribArray(0);
if (attr & ATTR_COLOR)
{
// color attribute
- glVertexAttribPointer(attr_pos, 3, GL_FLOAT, GL_FALSE, stride*sizeof(r32), (void*)(color_offset*sizeof(r32)));
+ glVertexAttribPointer(attr_pos, 3, GL_FLOAT, GL_FALSE, stride*sizeof(f32), (void*)(color_offset*sizeof(f32)));
glEnableVertexAttribArray(attr_pos);
attr_pos += 1;
}
@@ -211,7 +211,7 @@ BufferO CreateRectangleTextured(r32 vertices[], i32 v_sz, u32 indices[], i32 i_s
if (attr & ATTR_TEX)
{
// texture attribute
- glVertexAttribPointer(attr_pos, 2, GL_FLOAT, GL_FALSE, stride*sizeof(r32), (void*)(tex_offset*sizeof(r32)));
+ glVertexAttribPointer(attr_pos, 2, GL_FLOAT, GL_FALSE, stride*sizeof(f32), (void*)(tex_offset*sizeof(f32)));
glEnableVertexAttribArray(attr_pos);
}
@@ -226,7 +226,7 @@ BufferO CreateRectangleTextured(r32 vertices[], i32 v_sz, u32 indices[], i32 i_s
return BO;
}
-void MakeRectangleTextured(BufferO *bo, r32 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)
{
/*
* This will setup options and buffer objects to create a rectangle based on a texture
@@ -260,13 +260,13 @@ void MakeRectangleTextured(BufferO *bo, r32 vertices[], i32 v_sz, u32 indices[],
u8 attr_pos = 1;
// position attribute
- glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, stride*sizeof(r32), (void*)0);
+ glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, stride*sizeof(f32), (void*)0);
glEnableVertexAttribArray(0);
if (attr & ATTR_COLOR)
{
// color attribute
- glVertexAttribPointer(attr_pos, 3, GL_FLOAT, GL_FALSE, stride*sizeof(r32), (void*)(color_offset*sizeof(r32)));
+ glVertexAttribPointer(attr_pos, 3, GL_FLOAT, GL_FALSE, stride*sizeof(f32), (void*)(color_offset*sizeof(f32)));
glEnableVertexAttribArray(attr_pos);
attr_pos += 1;
}
@@ -274,7 +274,7 @@ void MakeRectangleTextured(BufferO *bo, r32 vertices[], i32 v_sz, u32 indices[],
if (attr & ATTR_TEX)
{
// texture attribute
- glVertexAttribPointer(attr_pos, 2, GL_FLOAT, GL_FALSE, stride*sizeof(r32), (void*)(tex_offset*sizeof(r32)));
+ glVertexAttribPointer(attr_pos, 2, GL_FLOAT, GL_FALSE, stride*sizeof(f32), (void*)(tex_offset*sizeof(f32)));
glEnableVertexAttribArray(attr_pos);
}
@@ -298,7 +298,7 @@ void DrawRectangleTextured(u32 VAO, u32 TexO)
glBindTexture(GL_TEXTURE_2D, 0);
}
-BufferO CreateCube(r32 vertices[], i32 v_sz)
+BufferO CreateCube(f32 vertices[], i32 v_sz)
{
u32 VAO;
glGenVertexArrays(1, &VAO);
@@ -311,11 +311,11 @@ BufferO CreateCube(r32 vertices[], i32 v_sz)
glBufferData(GL_ARRAY_BUFFER, v_sz, vertices, GL_STATIC_DRAW);
// position attribute
- glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 6*sizeof(r32), (void*)0);
+ glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 6*sizeof(f32), (void*)0);
glEnableVertexAttribArray(0);
// normal attribute
- glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 6*sizeof(r32), (void*)(3*sizeof(r32)));
+ glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 6*sizeof(f32), (void*)(3*sizeof(f32)));
glEnableVertexAttribArray(1);
// unbind post setup
@@ -328,7 +328,7 @@ BufferO CreateCube(r32 vertices[], i32 v_sz)
return BO;
}
-BufferO CreateCubeTextured(r32 vertices[], i32 v_sz)
+BufferO CreateCubeTextured(f32 vertices[], i32 v_sz)
{
/*
* This will setup options and buffer objects to create a rectangle based on a texture
@@ -345,15 +345,15 @@ BufferO CreateCubeTextured(r32 vertices[], i32 v_sz)
glBufferData(GL_ARRAY_BUFFER, v_sz, vertices, GL_STATIC_DRAW);
// position attribute
- glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 8*sizeof(r32), (void*)0);
+ glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 8*sizeof(f32), (void*)0);
glEnableVertexAttribArray(0);
// normal attribute
- glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 8*sizeof(r32), (void*)(3*sizeof(r32)));
+ glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 8*sizeof(f32), (void*)(3*sizeof(f32)));
glEnableVertexAttribArray(1);
// texture attribute
- glVertexAttribPointer(2, 2, GL_FLOAT, GL_FALSE, 8*sizeof(r32), (void*)(6*sizeof(r32)));
+ glVertexAttribPointer(2, 2, GL_FLOAT, GL_FALSE, 8*sizeof(f32), (void*)(6*sizeof(f32)));
glEnableVertexAttribArray(2);
// unbind post setup