-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRenderer.cpp
30 lines (27 loc) · 930 Bytes
/
Renderer.cpp
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
#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 (" << error << " )" << function << " " << file << " : " << line << std::endl;
return false;
}
return true;
}
void Renderer::Clear() const
{
glClearColor(0.2f, 0.3f, 0.3f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
}
void Renderer::Draw(const VertexArray &va, const IndexBuffer& ib, const Shader &shader) const
{
shader.Bind();
ib.Bind();
va.Bind();
//glDrawArrays(GL_TRIANGLES, 0, 3);
glDrawElements(GL_TRIANGLES, ib.GetCount(), GL_UNSIGNED_INT, nullptr);
//glDrawElementsInstanced(GL_TRIANGLES, ib.GetCount(), GL_UNSIGNED_INT, nullptr, 10 * 10);
//glDrawElementsInstanced(GL_TRIANGLES, ib.GetCount(), GL_UNSIGNED_INT, nullptr, 1);
}