grk_5sem_labs/cw 2/src/Render_Utils.cpp
2023-11-18 02:25:43 +01:00

36 lines
821 B
C++

#include "Render_Utils.h"
#include <algorithm>
#include "glew.h"
#include "freeglut.h"
void Core::DrawContext(Core::RenderContext& context)
{
glBindVertexArray(context.vertexArray);
glDrawElements(
GL_TRIANGLES, // mode
context.size, // count
GL_UNSIGNED_SHORT, // type
(void*)0 // element array buffer offset
);
glBindVertexArray(0);
}
void Core::deleteVAO(GLuint VAO) {
GLint nAttr = 0;
glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &nAttr);
glBindVertexArray(VAO);
for (int iAttr = 0; iAttr < nAttr; ++iAttr) {
GLint vboId = 0;
glGetVertexAttribiv(iAttr, GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING, &vboId);
if (vboId > 0) {
GLuint _v = GLuint(vboId);
glDeleteBuffers(1, &_v);
}
}
glDeleteVertexArrays(1, &VAO);
}