Added two render layers and the basic rendering pipeline; Fixed fullscreen graphics; No shader re-binding
This commit is contained in:
1 parent
e35688373e
commit
1c638bdcb9
12 files changed
+76
-35
No files matched your search
@@ -1,8 +1,28 @@
|
||||
#include "Drawable.h"
|
||||
|
||||
namespace nf {
|
||||
Drawable::Drawable() {
|
||||
Drawable::Drawable(const char* vertexShader, const char* fragmentShader, const void* vertexBufferData, const size_t vertexBufferSize, const void* indexBufferData, size_t indexBufferCount) :
|
||||
m_shader(vertexShader, fragmentShader),
|
||||
m_vao(),
|
||||
m_ib(indexBufferData, indexBufferCount)
|
||||
{
|
||||
m_vao.addBuffer(vertexBufferData, vertexBufferSize);
|
||||
m_vao.push<float>(2);
|
||||
m_vao.finishBufferLayout();
|
||||
}
|
||||
|
||||
unsigned int Drawable::getIndexCount() {
|
||||
return m_ib.getCount();
|
||||
}
|
||||
|
||||
void Drawable::bind() {
|
||||
m_shader.bind();
|
||||
m_vao.bind();
|
||||
m_ib.bind();
|
||||
}
|
||||
|
||||
Drawable::DrawableType Drawable::identity() {
|
||||
return DrawableType::NF_NONE;
|
||||
}
|
||||
|
||||
Drawable::~Drawable() {
|
||||
|
||||
@@ -53,8 +53,13 @@ namespace nf {
|
||||
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
|
||||
}
|
||||
|
||||
void Renderer::render(const Drawable& in) {
|
||||
//TODO: Check identity
|
||||
void Renderer::render(Drawable* in) {
|
||||
if (in == nullptr)
|
||||
Error("Drawable object tried to render before being constructed!");
|
||||
if (in->identity() == Drawable::DrawableType::NF_UI)
|
||||
m_lUI.push_back(in);
|
||||
else
|
||||
m_lGame.push_back(in);
|
||||
}
|
||||
|
||||
void Renderer::doFrame() {
|
||||
@@ -63,7 +68,8 @@ namespace nf {
|
||||
|
||||
for (Drawable* draw : m_lGame) {
|
||||
Drawable& curr = *draw;
|
||||
|
||||
curr.bind();
|
||||
glDrawElements(GL_TRIANGLES, curr.getIndexCount(), GL_UNSIGNED_INT, nullptr);
|
||||
}
|
||||
|
||||
for (Drawable* draw : m_lUI) {
|
||||
|
||||
@@ -44,7 +44,10 @@ namespace nf {
|
||||
}
|
||||
|
||||
void Shader::bind() {
|
||||
glUseProgram(m_id);
|
||||
if (m_id != Shader::current) {
|
||||
glUseProgram(m_id);
|
||||
Shader::current = m_id;
|
||||
}
|
||||
}
|
||||
//TODO: Create overloaded setUniform function
|
||||
void Shader::getUniformLocation(const char* uniformName) {
|
||||
@@ -57,4 +60,6 @@ namespace nf {
|
||||
Shader::~Shader() {
|
||||
glDeleteProgram(m_id);
|
||||
}
|
||||
|
||||
unsigned int Shader::current;
|
||||
}
|
||||
Reference in new issue
Block a user