-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathRenderer.cpp
More file actions
34 lines (27 loc) · 757 Bytes
/
Copy pathRenderer.cpp
File metadata and controls
34 lines (27 loc) · 757 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include "Renderer.h"
#include <iostream>
void GLClearError()
{
while (glGetError() != GL_NO_ERROR);
}
bool GLLogCall(const char* function, const char* file, int line)
{
while (GLenum error = glGetError())
{
std::cout << "[OpenGL error] (0x" << std::hex << error << std::dec << "): " << function << " call in "
<< file << " file at line " << line << std::endl;
return false;
}
return true;
}
void Renderer::Clear() const
{
GLCall(glClear(GL_COLOR_BUFFER_BIT));
}
void Renderer::Draw(const VertexArray& va, const IndexBuffer& ib, const Shader& shader) const
{
shader.Bind();
va.Bind();
ib.Bind();
GLCall(glDrawElements(GL_TRIANGLES, ib.GetCount(), GL_UNSIGNED_INT, nullptr));
}