MCPcopy Create free account
hub / github.com/NVIDIA/cuda-samples / createMeshPositionVBO

Function createMeshPositionVBO

cpp/4_CUDA_Libraries/oceanFFT/oceanFFT.cpp:800–824  ·  view source on GitHub ↗

create fixed vertex buffer to store mesh vertices

Source from the content-addressed store, hash-verified

798
799// create fixed vertex buffer to store mesh vertices
800void 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
827int attachShader(GLuint prg, GLenum type, const char *name)

Callers 1

runGraphicsTestFunction · 0.85

Calls 1

createVBOFunction · 0.70

Tested by

no test coverage detected