create fixed vertex buffer to store mesh vertices
| 798 | |
| 799 | // create fixed vertex buffer to store mesh vertices |
| 800 | void createMeshPositionVBO(GLuint *id, int w, int h) |
| 801 | { |
| 802 | createVBO(id, w * h * 4 * sizeof(float)); |
| 803 | |
| 804 | glBindBuffer(GL_ARRAY_BUFFER, *id); |
| 805 | float *pos = (float *)glMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY); |
| 806 | |
| 807 | if (!pos) { |
| 808 | return; |
| 809 | } |
| 810 | |
| 811 | for (int y = 0; y < h; y++) { |
| 812 | for (int x = 0; x < w; x++) { |
| 813 | float u = x / (float)(w - 1); |
| 814 | float v = y / (float)(h - 1); |
| 815 | *pos++ = u * 2.0f - 1.0f; |
| 816 | *pos++ = 0.0f; |
| 817 | *pos++ = v * 2.0f - 1.0f; |
| 818 | *pos++ = 1.0f; |
| 819 | } |
| 820 | } |
| 821 | |
| 822 | glUnmapBuffer(GL_ARRAY_BUFFER); |
| 823 | glBindBuffer(GL_ARRAY_BUFFER, 0); |
| 824 | } |
| 825 | |
| 826 | // Attach shader to a program |
| 827 | int attachShader(GLuint prg, GLenum type, const char *name) |
no test coverage detected