opengl_learn

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

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

01: updated shader variable names to match 02 and 03

Diffstat:
M01-perspective.c | 17+++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/01-perspective.c b/01-perspective.c @@ -19,13 +19,14 @@ int main() { GLFWwindow * window = ogl_init(400, 240, "01 - triangle with perspective"); + /* 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" - "uniform mat4 uniform_MVP;" "\n" /* uniforms are inputs to vertex shaders that don't change per-vertex */ - "attribute vec3 attribute_position;" "\n" /* attributes are inputs to vertex shaders */ + "uniform mat4 vu_vertex_MVP;" "\n" /* uniforms are inputs to vertex and fragment shaders that don't change per-vertex */ + "attribute vec3 va_vertex_position;" "\n" /* attributes are inputs to vertex shaders */ "void main(){" "\n" - " gl_Position = uniform_MVP * vec4(attribute_position,1);" "\n" + " gl_Position = vu_vertex_MVP * vec4(va_vertex_position,1);" "\n" "}" "\n" ; const char * program_fragment_source = @@ -36,7 +37,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"); struct ogl_mat4f MVP_projection; ogl_perspective(45.0f, 0.1f, 100.0f, &MVP_projection); @@ -67,14 +68,14 @@ main() { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glUseProgram(program_ID); - ogl_program_uniform_set_mat4f(program_ID, "uniform_MVP", MVP); + ogl_program_uniform_set_mat4f(program_ID, "vu_vertex_MVP", MVP); - 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();