diff --git a/src/IndexBuffer.cpp b/src/IndexBuffer.cpp index 1cf66db..4349232 100644 --- a/src/IndexBuffer.cpp +++ b/src/IndexBuffer.cpp @@ -6,13 +6,15 @@ IndexBuffer::IndexBuffer(const unsigned int* data, unsigned int count) { ASSERT(sizeof(unsigned int) == sizeof(GLuint)); // + std::cout << "m_RendererID: " << &m_RendererID << " " << m_RendererID << std::endl; GLCall(glGenBuffers(1, &m_RendererID)); GLCall(glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_RendererID)); //select buffer called 'buffer' - GLCall(glBufferData(GL_ELEMENT_ARRAY_BUFFER, count * sizeof(GLuint), data, GL_STATIC_DRAW)); // assigne buffer size, static as we use many times, but does not change + GLCall(glBufferData(GL_ELEMENT_ARRAY_BUFFER, count * sizeof(unsigned int), data, GL_STATIC_DRAW)); // assigne buffer size, static as we use many times, but does not change } IndexBuffer::~IndexBuffer() { + std::cout << "m_RendererID: " << &m_RendererID << " " << m_RendererID << std::endl; GLCall(glDeleteBuffers(1, &m_RendererID)); } diff --git a/src/Renderer.cpp b/src/Renderer.cpp index 552d629..537c7b6 100644 --- a/src/Renderer.cpp +++ b/src/Renderer.cpp @@ -1,9 +1,10 @@ #include "Renderer.h" +#include void GLClearError() { - while (glGetError() != GL_NO_ERROR); + //while (glGetError() != GL_NO_ERROR); } diff --git a/src/Renderer.h b/src/Renderer.h index 8de98da..75a4451 100644 --- a/src/Renderer.h +++ b/src/Renderer.h @@ -34,4 +34,4 @@ #define INT2VOIDP(i) (void*)(uintptr_t)(i) void GLClearError(); -bool GLLogCall(); +bool GLLogCall(); \ No newline at end of file diff --git a/src/sdl.cpp b/src/sdl.cpp index 0602e2f..71c1110 100644 --- a/src/sdl.cpp +++ b/src/sdl.cpp @@ -63,7 +63,7 @@ SdlWindow::SdlWindow(const char* title, int width, int height) r(0.5f), location(), increment(0.05f), - ib(nullptr,6) + m_ib(nullptr, 0) { // 1. Set attributes SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3); @@ -120,13 +120,10 @@ SdlWindow::SdlWindow(const char* title, int width, int height) 2, 3, 0 }; - //unsigned int vao; //vertext array object - //GLCall(glGenVertexArrays(1, &vao)); - //GLCall(glBindVertexArray(vao)); - VertexArray va; VertexBuffer vb(positions, 4 * 2 * sizeof(float)); - ib = IndexBuffer(indices, 6); + IndexBuffer ib(indices, 6); + m_ib = ib; VertexBufferLayout layout; layout.Push(2); @@ -255,7 +252,7 @@ void SdlWindow::render() { GLCall(glUniform4f(location, r, 0.3f, 0.8f, 1.0f)); va.Bind(); - ib.Bind(); + m_ib.Bind(); // TODO: Draw with OpenGL here (shaders, triangles, etc.) //glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, nullptr); GLCall(glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, nullptr)); //macro assert for debugging @@ -363,7 +360,7 @@ SdlWindow::ShaderProgramSource SdlWindow::parseShader(const std::string& filepat } void SdlWindow::GLClearError() { - while (glGetError() != GL_NO_ERROR); + //while (glGetError() != GL_NO_ERROR); } diff --git a/src/sdl.hpp b/src/sdl.hpp index 469a563..6a03628 100644 --- a/src/sdl.hpp +++ b/src/sdl.hpp @@ -62,11 +62,11 @@ private: unsigned int buffer; unsigned int ibo; unsigned int vao; - IndexBuffer ib; // pointer, no default constructor needed unsigned int shader; unsigned int location; VertexBufferLayout layout; VertexArray va; + IndexBuffer m_ib; // Private methods void processEvents();