MCPcopy Create free account
hub / github.com/OpenNFS/OpenNFS / genBuffers

Method genBuffers

src/Scene/Light.cpp:74–119  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

72}
73
74bool Light::genBuffers() {
75 glGenVertexArrays(1, &VertexArrayID);
76 glBindVertexArray(VertexArrayID);
77 // Verts
78 glGenBuffers(1, &vertexbuffer);
79 glBindBuffer(GL_ARRAY_BUFFER, vertexbuffer);
80 glBufferData(GL_ARRAY_BUFFER, m_vertices.size() * sizeof(glm::vec3), &m_vertices[0], GL_STATIC_DRAW);
81 glVertexAttribPointer(
82 0, // attribute
83 3, // size
84 GL_FLOAT, // type
85 GL_FALSE, // normalized?
86 0, // stride
87 (void *) 0 // array buffer offset
88 );
89 // 1st attribute buffer : Vertices
90 glEnableVertexAttribArray(0);
91 // UVs
92 glGenBuffers(1, &uvbuffer);
93 glBindBuffer(GL_ARRAY_BUFFER, uvbuffer);
94 glBufferData(GL_ARRAY_BUFFER, m_uvs.size() * sizeof(glm::vec2), &m_uvs[0], GL_STATIC_DRAW);
95 glVertexAttribPointer(
96 1, // attribute
97 2, // size
98 GL_FLOAT, // type
99 GL_FALSE, // normalized?
100 0, // stride
101 (void *) 0 // array buffer offset
102 );
103 // 2nd attribute buffer : normals
104 glEnableVertexAttribArray(1);
105 // Normals
106 glGenBuffers(1, &normalBuffer);
107 glBindBuffer(GL_ARRAY_BUFFER, normalBuffer);
108 glBufferData(GL_ARRAY_BUFFER, m_normals.size() * sizeof(glm::vec3), &m_normals[0], GL_STATIC_DRAW);
109 glVertexAttribPointer(
110 4, // attribute
111 3, // size
112 GL_FLOAT, // type
113 GL_FALSE, // normalized?
114 0, // stride
115 (void *) 0 // array buffer offset
116 );
117 glBindVertexArray(0);
118 return true;
119}
120
121Light::Light() : super("Light", std::vector<glm::vec3>(), std::vector<glm::vec2>(), std::vector<glm::vec3>(), std::vector<unsigned int>(), false, glm::vec3(0,0,0)){}
122

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected