opengl_learn

Step-by-step introduction to OpenGL
git clone https://0xdd.org/code/opengl_learn.git
Log | Files | Refs | README | LICENSE

commit debe4ab718c941c356140b18a5c09c0d819220cf
parent a549948ba1abaf0e31c98287d814e0ae6a6af125
Author: David DiPaola <DavidDiPaola@users.noreply.github.com>
Date:   Wed, 27 Jun 2018 08:22:54 -0400

00: made shader variable naming match 01, 02, 03

Diffstat:
M00-triangle.c | 13+++++++------
1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/00-triangle.c b/00-triangle.c @@ -19,12 +19,13 @@ int main() { GLFWwindow * window = ogl_init(400, 240, "00 - triangle"); + /* vu: vertex shader uniform, va: vertex shader attribute, fu: fragment shader uniform, fv: fragment shader varying */ const char * program_vertex_source = "#version 100" "\n" "precision highp float;" "\n" - "attribute vec3 attribute_position;" "\n" /* attributes are inputs to vertex shaders */ + "attribute vec3 va_vertex_position;" "\n" /* attributes are inputs to vertex shaders */ "void main(){" "\n" - " gl_Position = vec4(attribute_position,1);" "\n" + " gl_Position = vec4(va_vertex_position,1);" "\n" "}" "\n" ; const char * program_fragment_source = @@ -35,7 +36,7 @@ main() { "}" "\n" ; GLuint program_ID = ogl_program_build(program_vertex_source, program_fragment_source); - GLint program_attribute_position_ID = glGetAttribLocation(program_ID, "attribute_position"); + GLint program_va_vertex_position_ID = glGetAttribLocation(program_ID, "va_vertex_position"); const GLfloat triangle_vertexbuffer_data[] = { -1.0f, -1.0f, 0.0f, 1.0f, -1.0f, 0.0f, 0.0f, 1.0f, 0.0f, @@ -49,12 +50,12 @@ main() { glUseProgram(program_ID); - glEnableVertexAttribArray(program_attribute_position_ID); + glEnableVertexAttribArray(program_va_vertex_position_ID); glBindBuffer(GL_ARRAY_BUFFER, triangle_vertexbuffer_ID); - glVertexAttribPointer(program_attribute_position_ID, 3, GL_FLOAT, GL_FALSE, 0, (GLvoid *)0); + glVertexAttribPointer(program_va_vertex_position_ID, 3, GL_FLOAT, GL_FALSE, 0, (GLvoid *)0); glDrawArrays(GL_TRIANGLES, 0, triangle_vertexbuffer_data_vertexes); glBindBuffer(GL_ARRAY_BUFFER, 0); - glDisableVertexAttribArray(program_attribute_position_ID); + glDisableVertexAttribArray(program_va_vertex_position_ID); glfwSwapBuffers(window); glfwPollEvents();