Draw a triangle using the shader pair created in Init()
| 102 | // Draw a triangle using the shader pair created in Init() |
| 103 | // |
| 104 | void Draw () |
| 105 | { |
| 106 | GLfloat vVertices[] = { 0.0f, 0.5f, 0.0f, |
| 107 | -0.5f, -0.5f, 0.0f, |
| 108 | 0.5f, -0.5f, 0.0f }; |
| 109 | |
| 110 | // No clientside arrays, so do this in a webgl-friendly manner |
| 111 | GLuint vertexPosObject; |
| 112 | glGenBuffers(1, &vertexPosObject); |
| 113 | glBindBuffer(GL_ARRAY_BUFFER, vertexPosObject); |
| 114 | glBufferData(GL_ARRAY_BUFFER, 9*4, vVertices, GL_STATIC_DRAW); |
| 115 | |
| 116 | glViewport ( 0, 0, width, height ); |
| 117 | glClear ( GL_COLOR_BUFFER_BIT ); |
| 118 | glUseProgram ( programObject ); |
| 119 | |
| 120 | glBindBuffer(GL_ARRAY_BUFFER, vertexPosObject); |
| 121 | glVertexAttribPointer(0 /* ? */, 3, GL_FLOAT, 0, 0, 0); |
| 122 | glEnableVertexAttribArray(0); |
| 123 | |
| 124 | glDrawArrays ( GL_TRIANGLES, 0, 3 ); |
| 125 | } |
| 126 | |
| 127 | void Verify() { |
| 128 | unsigned char *data = malloc(width*height*4 + 16); |