- Timestamp:
- Aug 8, 2017, 1:11:28 AM (7 years ago)
- Branches:
- feature/imgui-sdl, master, points-test
- Children:
- 363d5ff
- Parents:
- 9e81839
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pong.cpp
r9e81839 reeece4e 96 96 97 97 GLfloat points_paddle[] = { 98 0.0f, -0.5f, 0.0f, 99 0.5f, 0.5f, 0.0f, 100 -0.5f, 0.5f, 0.0f, 98 -1.0f, 1.0f, 0.0f, 99 -1.0f, 0.7f, 0.0f, 100 -0.9f, 0.7f, 0.0f, 101 -1.0f, 1.0f, 0.0f, 102 -0.9f, 0.7f, 0.0f, 103 -0.9f, 1.0f, 0.0f, 101 104 }; 102 105 103 106 GLfloat colors_paddle[] = { 104 107 1.0, 0.0, 0.0, 105 0.0, 0.0, 1.0, 106 0.0, 1.0, 0.0, 108 1.0, 0.0, 0.0, 109 1.0, 0.0, 0.0, 110 1.0, 0.0, 0.0, 111 1.0, 0.0, 0.0, 112 1.0, 0.0, 0.0, 107 113 }; 108 114 … … 111 117 0.0f, 1.0f, 0.0f, 0.0f, // column 2 112 118 0.0f, 0.0f, 1.0f, 0.0f, // column 3 113 0. 5f, 0.0f, 0.0f, 1.0f, // column 4119 0.0f, 0.0f, 0.0f, 1.0f, // column 4 114 120 }; 115 121 … … 130 136 131 137 glLinkProgram(shader_program); 138 glUseProgram(shader_program); 132 139 133 140 GLint location = glGetUniformLocation(shader_program, "model"); … … 146 153 } 147 154 155 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 156 157 model[12] = 0.0f; 158 glUniformMatrix4fv(location, 1, GL_FALSE, model); 159 160 glBindVertexArray(paddle_vao); 161 glEnableVertexAttribArray(0); 162 glEnableVertexAttribArray(1); 163 164 glDrawArrays(GL_TRIANGLES, 0, sizeof(points_paddle)/sizeof(GLfloat)/3); 165 148 166 model[12] = last_position + speed*elapsed_seconds; 149 167 last_position = model[12]; 150 glUseProgram(shader_program);151 168 glUniformMatrix4fv(location, 1, GL_FALSE, model); 152 153 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);154 169 155 170 glBindVertexArray(ball_vao); … … 157 172 glEnableVertexAttribArray(1); 158 173 159 glDrawArrays(GL_TRIANGLES, 0, 3); 160 161 glBindVertexArray(paddle_vao); 162 glEnableVertexAttribArray(0); 163 glEnableVertexAttribArray(1); 164 165 glDrawArrays(GL_TRIANGLES, 0, 3); 174 glDrawArrays(GL_TRIANGLES, 0, sizeof(points)/sizeof(GLfloat)/3); 166 175 167 176 glfwPollEvents();
Note:
See TracChangeset
for help on using the changeset viewer.