commit 94949da7c2e8e5d273ecdf5554e3f67a3f8da8b4
parent ddfb5806153cd123889e2900006d17eab3e4f870
Author: David DiPaola <DavidDiPaola@users.noreply.github.com>
Date: Sun, 10 Jun 2018 10:12:24 -0400
00,01,02,ogl: removed program:attribute:get:ID() abstraction because the underlying OpenGL call is not complicated
Diffstat:
5 files changed, 5 insertions(+), 56 deletions(-)
diff --git a/00-triangle.c b/00-triangle.c
@@ -47,13 +47,7 @@ main() {
fprintf(stderr, "\t" "at %s : %d" "\n", __FILE__, __LINE__);
return status;
}
-
- GLint program_attribute_position_ID = 0;
- status = ogl_program_attribute_get_ID(program_ID, "attribute_position", &program_attribute_position_ID);
- if (status < 0) {
- fprintf(stderr, "\t" "at %s : %d" "\n", __FILE__, __LINE__);
- return status;
- }
+ GLint program_attribute_position_ID = glGetAttribLocation(program_ID, "attribute_position");
const GLfloat triangle_vertexbuffer_data[] = {
-1.0f, -1.0f, 0.0f, 1.0f, -1.0f, 0.0f, 0.0f, 1.0f, 0.0f,
diff --git a/01-perspective.c b/01-perspective.c
@@ -48,13 +48,7 @@ main() {
fprintf(stderr, "\t" "at %s : %d" "\n", __FILE__, __LINE__);
return status;
}
-
- GLint program_attribute_position_ID = 0;
- status = ogl_program_attribute_get_ID(program_ID, "attribute_position", &program_attribute_position_ID);
- if (status < 0) {
- fprintf(stderr, "\t" "at %s : %d" "\n", __FILE__, __LINE__);
- return status;
- }
+ GLint program_attribute_position_ID = glGetAttribLocation(program_ID, "attribute_position");
struct ogl_mat4f MVP_projection;
status = ogl_perspective(45.0f, 0.1f, 100.0f, &MVP_projection);
diff --git a/02-cube.c b/02-cube.c
@@ -52,20 +52,8 @@ main() {
fprintf(stderr, "\t" "at %s : %d" "\n", __FILE__, __LINE__);
return status;
}
-
- GLint program_attribute_position_ID = 0;
- status = ogl_program_attribute_get_ID(program_ID, "attribute_position", &program_attribute_position_ID);
- if (status < 0) {
- fprintf(stderr, "\t" "at %s : %d" "\n", __FILE__, __LINE__);
- return status;
- }
-
- GLint program_attribute_color_ID = 0;
- status = ogl_program_attribute_get_ID(program_ID, "attribute_color", &program_attribute_color_ID);
- if (status < 0) {
- fprintf(stderr, "\t" "at %s : %d" "\n", __FILE__, __LINE__);
- return status;
- }
+ GLint program_attribute_position_ID = glGetAttribLocation(program_ID, "attribute_position");
+ GLint program_attribute_color_ID = glGetAttribLocation(program_ID, "attribute_color");
struct ogl_mat4f MVP_projection;
status = ogl_perspective(45.0f, 0.1f, 100.0f, &MVP_projection);
diff --git a/ogl/Makefile b/ogl/Makefile
@@ -4,7 +4,7 @@ SRC = \
ogl_mat4f_identity.c ogl_mat4f_isapproxequal.c ogl_mat4f_multiply.c ogl_mat4f_print.c \
ogl_lookat.c \
ogl_perspective.c \
- ogl_program_build.c ogl_program_attribute_get_ID.c ogl_program_uniform_get_ID.c ogl_program_uniform_set_mat4f.c \
+ ogl_program_build.c ogl_program_uniform_get_ID.c ogl_program_uniform_set_mat4f.c \
ogl_vec3f_cross.c ogl_vec3f_dot.c ogl_vec3f_isapproxequal.c ogl_vec3f_magnitude.c ogl_vec3f_normal.c ogl_vec3f_print.c \
ogl_vertex_buffer_load.c
OBJ = $(SRC:.c=.o)
diff --git a/ogl/ogl_program_attribute_get_ID.c b/ogl/ogl_program_attribute_get_ID.c
@@ -1,27 +0,0 @@
-/*
-2018 David DiPaola
-licensed under CC0 (public domain, see https://creativecommons.org/publicdomain/zero/1.0/)
-*/
-
-#include <stdio.h>
-
-#include <GL/glew.h>
-
-int
-ogl_program_attribute_get_ID(
- GLuint program_ID, const char * attribute_name,
- GLint * out_attribute_ID
-) {
- GLint attribute_ID;
-
- attribute_ID = glGetAttribLocation(program_ID, attribute_name);
- if (attribute_ID < 0) {
- fprintf(stderr, "GL glGetAttribLocation(%i, \"%s\"): ERROR" "\n", program_ID, attribute_name);
- fprintf(stderr, "\t" "at %s : %d" "\n", __FILE__, __LINE__);
- return -1;
- }
-
- (*out_attribute_ID) = attribute_ID;
- return 0;
-}
-