Added Drawable, rewrote changing states, and organized class definitions and macros
This commit is contained in:
1 parent
1f6bb4630c
commit
2f4e0ebfac
12 files changed
+141
-109
No files matched your search
@@ -0,0 +1,11 @@
|
||||
#include "Drawable.h"
|
||||
|
||||
namespace nf {
|
||||
Drawable::Drawable() {
|
||||
|
||||
}
|
||||
|
||||
Drawable::~Drawable() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -33,9 +33,8 @@ namespace nf {
|
||||
m_hglrc = wglCreateContext(m_hdc);
|
||||
wglMakeCurrent(m_hdc, m_hglrc);
|
||||
glewExperimental = GL_TRUE;
|
||||
if (glewInit() != GLEW_OK) {
|
||||
if (glewInit() != GLEW_OK)
|
||||
Error("Could not initialize GLEW!");
|
||||
}
|
||||
const int attrib[] = {
|
||||
WGL_CONTEXT_MAJOR_VERSION_ARB, 3,
|
||||
WGL_CONTEXT_MINOR_VERSION_ARB, 3,
|
||||
@@ -57,9 +56,8 @@ namespace nf {
|
||||
SwapBuffers(m_hdc);
|
||||
|
||||
GLenum err = glGetError();
|
||||
if (err != GL_NO_ERROR) {
|
||||
if (err != GL_NO_ERROR)
|
||||
Error("OpenGL error " + std::to_string(err));
|
||||
}
|
||||
}
|
||||
|
||||
Renderer::~Renderer() {
|
||||
|
||||
@@ -49,9 +49,8 @@ namespace nf {
|
||||
//TODO: Create overloaded setUniform function
|
||||
void Shader::getUniformLocation(const char* uniformName) {
|
||||
unsigned int loc = glGetUniformLocation(m_id, uniformName);
|
||||
if (loc == -1) {
|
||||
if (loc == -1)
|
||||
Error("Uniform \"" + (std::string)uniformName + "\" does not exist!");
|
||||
}
|
||||
m_uniformLocations[uniformName] = loc;
|
||||
}
|
||||
|
||||
|
||||
@@ -14,9 +14,8 @@ namespace nf {
|
||||
}
|
||||
|
||||
void VertexArray::addBuffer(const void* data, const size_t size) {
|
||||
if (!m_lastBufferHasLayout) {
|
||||
if (!m_lastBufferHasLayout)
|
||||
Error("Buffer added to vertex array has no layout!");
|
||||
}
|
||||
m_buffers.push_back(new VertexBuffer(data, size));
|
||||
m_buffers.back()->bind();
|
||||
m_lastBufferHasLayout = false;
|
||||
@@ -25,9 +24,8 @@ namespace nf {
|
||||
|
||||
template<>
|
||||
void VertexArray::push<float>(unsigned int count) {
|
||||
if (m_lastBufferHasLayout) {
|
||||
if (m_lastBufferHasLayout)
|
||||
Error("Tried to modify a vertex array's buffer after the layout was final!");
|
||||
}
|
||||
m_lastBufferLayout.push_back({ GL_FLOAT, count, GL_FALSE });
|
||||
m_lastStride += count * sizeof(GL_FLOAT);
|
||||
}
|
||||
@@ -45,12 +43,10 @@ namespace nf {
|
||||
}
|
||||
|
||||
void VertexArray::bind(unsigned int buffer) {
|
||||
if (m_buffers.empty()) {
|
||||
if (m_buffers.empty())
|
||||
Error("No buffers and layouts added to vertex array before being bound!");
|
||||
}
|
||||
if (!m_lastBufferHasLayout) {
|
||||
if (!m_lastBufferHasLayout)
|
||||
Error("Buffer added to vertex array has no layout!");
|
||||
}
|
||||
glBindVertexArray(m_id);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user