commit 12c31f39b6c68b28ec4ce4ee094c9084178a0234
parent f5d97777de27fb08bcec02fd3b29410947826312
Author: amin <dev@aminmesbah.com>
Date: Sat, 15 Jun 2019 22:17:30 +0000
Remove unused pyramid rendering code
FossilOrigin-Name: 54f09bed2880c9f77344f85ece99776a89c0f2a36d26ca766812701f6684800b
Diffstat:
4 files changed, 3 insertions(+), 107 deletions(-)
diff --git a/shader/pyramid_f.glsl b/shader/pyramid_f.glsl
@@ -1,12 +0,0 @@
-#version 300 es
-
-precision highp float;
-
-uniform vec3 pyramid_color;
-
-out vec4 frag_color;
-
-void main()
-{
- frag_color = vec4(pyramid_color, 1.0f);
-}
diff --git a/shader/pyramid_v.glsl b/shader/pyramid_v.glsl
@@ -1,12 +0,0 @@
-#version 300 es
-
-layout (location = 0) in vec3 a_position;
-
-uniform mat4 model;
-uniform mat4 view;
-uniform mat4 projection;
-
-void main()
-{
- gl_Position = projection * view * model * vec4(a_position, 1.0f);
-}
diff --git a/src/game.c b/src/game.c
@@ -48,56 +48,6 @@ float randf(float min, float max)
void game_init(struct GameState *game_state, uint32_t screen_width, uint32_t screen_height)
{
- // load pyramid vertex data
- {
- float edge_length = 1.0f;
- float height = 1.0f / sqrtf(2.0f) * edge_length;
- float half_length = edge_length / 2.0f;
- float half_height = height / 2.0f;
-
- GLfloat pyramid_vertices[] = {
- // positions
- -half_length, -half_height, -half_length,
- -half_length, -half_height, half_length,
- half_length, -half_height, half_length,
- half_length, -half_height, -half_length,
- 0.0f, half_height, 0.0f,
- };
-
- GLuint elements[] = {
- 0, 3, 2,
- 2, 1, 0,
- 0, 4, 3,
- 3, 4, 2,
- 2, 4, 1,
- 1, 4, 0,
- };
-
- GLuint pyramid_vao_id;
- glGenVertexArrays(1, &pyramid_vao_id);
- glBindVertexArray(pyramid_vao_id);
-
- GLuint pyramid_vbo_id;
- glGenBuffers(1, &pyramid_vbo_id);
- glBindBuffer(GL_ARRAY_BUFFER, pyramid_vbo_id);
- glBufferData(GL_ARRAY_BUFFER, sizeof(pyramid_vertices), pyramid_vertices, GL_STATIC_DRAW);
-
- // positions
- glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(*pyramid_vertices), (GLvoid*)0);
- glEnableVertexAttribArray(0);
-
- GLuint pyramid_ebo_id;
- glGenBuffers(1, &pyramid_ebo_id);
- glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, pyramid_ebo_id);
- glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(elements), elements, GL_STATIC_DRAW);
-
- glBindVertexArray(0);
-
- game_state->pyramid_vao_id = pyramid_vao_id;
- game_state->pyramid_vbo_id = pyramid_vbo_id;
- game_state->pyramid_ebo_id = pyramid_ebo_id;
- }
-
// load cube vertex data
{
GLfloat cube_vertices[] = {
@@ -149,7 +99,6 @@ void game_init(struct GameState *game_state, uint32_t screen_width, uint32_t scr
game_state->cube_ebo = cube_ebo;
}
- game_state->pyramid_shader = shader_compile("shader/pyramid_v.glsl", "shader/pyramid_f.glsl");
game_state->cube_shader = shader_compile("shader/cube_v.glsl", "shader/cube_f.glsl");
glEnable(GL_DEPTH_TEST);
@@ -174,31 +123,6 @@ void game_update_and_render(struct GameState *game_state, float dt, uint32_t scr
view = glmth_translate(view, glmth_v3_init(0.0f, 0.0f, -3.0f));
projection = glmth_projection_perspective_fov(glmth_rad(45.0f), (float)screen_width / (float)screen_height, 0.1f, 100.0f);
-#if 0
- // render pyramid
- {
- shader_use(&game_state->pyramid_shader);
- shader_setm4(&game_state->pyramid_shader, "view", &view);
- shader_setm4(&game_state->pyramid_shader, "projection", &projection);
-
- m4 model = glmth_m4_init_id();
- f32 angle = 20.0f;
- model = glmth_rotate(model, dt * glmth_rad(angle), glmth_v3_init(0.5f, 1.0f, 0.0f));
-
- f32 color_freq = dt * 0.1f;
- v3 pyramid_color = glmth_v3_init(
- sinf(color_freq),
- sinf(color_freq + (2 * M_PI / 3)),
- sinf(color_freq + (4 * M_PI / 3)));
- shader_setm4(&game_state->pyramid_shader, "model", &model);
- shader_setv3(&game_state->pyramid_shader, "pyramid_color", &pyramid_color);
-
- glBindVertexArray(game_state->pyramid_vao_id);
- glDrawElements(GL_TRIANGLES, 18, GL_UNSIGNED_INT, 0);
- glBindVertexArray(0);
- }
-#endif
-
// render cube
{
// Depth testing causes the blending to be applied inconsistently
@@ -236,7 +160,7 @@ void game_update_and_render(struct GameState *game_state, float dt, uint32_t scr
void game_cleanup(struct GameState *game_state)
{
- glDeleteVertexArrays(1, &game_state->pyramid_vao_id);
- glDeleteBuffers(1, &game_state->pyramid_vbo_id);
- glDeleteBuffers(1, &game_state->pyramid_ebo_id);
+ glDeleteVertexArrays(1, &game_state->cube_vao);
+ glDeleteBuffers(1, &game_state->cube_vbo);
+ glDeleteBuffers(1, &game_state->cube_ebo);
}
diff --git a/src/game.h b/src/game.h
@@ -14,13 +14,9 @@
struct GameState
{
- GLuint pyramid_vao_id;
- GLuint pyramid_vbo_id;
- GLuint pyramid_ebo_id;
GLuint cube_vao;
GLuint cube_vbo;
GLuint cube_ebo;
- struct Shader pyramid_shader;
struct Shader cube_shader;
};