diff --git a/Debug/Window_practice.exe b/Debug/Window_practice.exe index f7ac2fd..d6bb2a3 100644 Binary files a/Debug/Window_practice.exe and b/Debug/Window_practice.exe differ diff --git a/Debug/Window_practice.pdb b/Debug/Window_practice.pdb index f8d9ef9..b41d01e 100644 Binary files a/Debug/Window_practice.pdb and b/Debug/Window_practice.pdb differ diff --git a/Window_practice/Debug/Main.obj b/Window_practice/Debug/Main.obj index 9d306a2..3fd493a 100644 Binary files a/Window_practice/Debug/Main.obj and b/Window_practice/Debug/Main.obj differ diff --git a/Window_practice/Debug/Window_practice.ilk b/Window_practice/Debug/Window_practice.ilk index 368a8a4..30c4718 100644 Binary files a/Window_practice/Debug/Window_practice.ilk and b/Window_practice/Debug/Window_practice.ilk differ diff --git a/Window_practice/Debug/Window_practice.log b/Window_practice/Debug/Window_practice.log index d9a298a..a9f28f4 100644 --- a/Window_practice/Debug/Window_practice.log +++ b/Window_practice/Debug/Window_practice.log @@ -1,3 +1,10 @@ - Main.cpp + IndexBuffer.cpp + Main.cpp C:\dev\Glfw_Practice\c++\Window_practice\Window_practice\src\VertexBufferLayout.h(5,10): warning C4067: unexpected tokens following preprocessor directive - expected a newline + Renderer.cpp + Shader.cpp + VertexArray.cpp +C:\dev\Glfw_Practice\c++\Window_practice\Window_practice\src\VertexBufferLayout.h(5,10): warning C4067: unexpected tokens following preprocessor directive - expected a newline + VertexBuffer.cpp + Generating Code... Window_practice.vcxproj -> C:\dev\Glfw_Practice\c++\Window_practice\Debug\Window_practice.exe diff --git a/Window_practice/Debug/Window_practice.tlog/CL.command.1.tlog b/Window_practice/Debug/Window_practice.tlog/CL.command.1.tlog index b2dfb02..3d4ca17 100644 Binary files a/Window_practice/Debug/Window_practice.tlog/CL.command.1.tlog and b/Window_practice/Debug/Window_practice.tlog/CL.command.1.tlog differ diff --git a/Window_practice/Debug/Window_practice.tlog/CL.read.1.tlog b/Window_practice/Debug/Window_practice.tlog/CL.read.1.tlog index 366e7c3..4c72fa9 100644 Binary files a/Window_practice/Debug/Window_practice.tlog/CL.read.1.tlog and b/Window_practice/Debug/Window_practice.tlog/CL.read.1.tlog differ diff --git a/Window_practice/Debug/Window_practice.tlog/CL.write.1.tlog b/Window_practice/Debug/Window_practice.tlog/CL.write.1.tlog index ffdc983..ec7c817 100644 Binary files a/Window_practice/Debug/Window_practice.tlog/CL.write.1.tlog and b/Window_practice/Debug/Window_practice.tlog/CL.write.1.tlog differ diff --git a/Window_practice/Debug/Window_practice.tlog/link.read.1.tlog b/Window_practice/Debug/Window_practice.tlog/link.read.1.tlog index 145bce9..495c433 100644 Binary files a/Window_practice/Debug/Window_practice.tlog/link.read.1.tlog and b/Window_practice/Debug/Window_practice.tlog/link.read.1.tlog differ diff --git a/Window_practice/Debug/vc142.idb b/Window_practice/Debug/vc142.idb index 668b00c..2476f2d 100644 Binary files a/Window_practice/Debug/vc142.idb and b/Window_practice/Debug/vc142.idb differ diff --git a/Window_practice/Debug/vc142.pdb b/Window_practice/Debug/vc142.pdb index 302c9a2..d823b80 100644 Binary files a/Window_practice/Debug/vc142.pdb and b/Window_practice/Debug/vc142.pdb differ diff --git a/Window_practice/src/Main.cpp b/Window_practice/src/Main.cpp index 0c5566e..3d6264c 100644 --- a/Window_practice/src/Main.cpp +++ b/Window_practice/src/Main.cpp @@ -5,6 +5,7 @@ #include "Renderer.h" #include "VertexBuffer.h" +#include "VertexBufferLayout.h" #include "IndexBuffer.h" #include "VertexArray.h" #include "Shader.h" @@ -70,6 +71,8 @@ int main(void){ shader.Bind(); shader.SetUniform4f("u_Color", 0.8f, 0.3f, 0.8f, 1.0f); + Renderer renderer; + //unbinding the buffers va.Unbind(); vb.Unbind(); @@ -83,15 +86,12 @@ int main(void){ //Main loop while (!glfwWindowShouldClose(window)) { /* Render here */ - GLCall(glClear(GL_COLOR_BUFFER_BIT)); + renderer.Clear(); shader.Bind(); shader.SetUniform4f("u_Color", r, 0.3f, 0.8f, 1.0f); - va.Bind(); - ib.Bind(); - - GLCall(glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, nullptr)); + renderer.Draw(va, ib, shader); if (r > 1.0f) increment = -0.05f; diff --git a/Window_practice/src/Renderer.cpp b/Window_practice/src/Renderer.cpp index 739f29a..e83c56b 100644 --- a/Window_practice/src/Renderer.cpp +++ b/Window_practice/src/Renderer.cpp @@ -14,4 +14,16 @@ bool GLLogCall(const char* function, const char* file, int line) { return false; } return true; +} + +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)); +} + +void Renderer::Clear() const{ + GLCall(glClear(GL_COLOR_BUFFER_BIT)); } \ No newline at end of file diff --git a/Window_practice/src/Renderer.h b/Window_practice/src/Renderer.h index d0139c9..a115202 100644 --- a/Window_practice/src/Renderer.h +++ b/Window_practice/src/Renderer.h @@ -2,6 +2,10 @@ #include +#include "VertexArray.h" +#include "IndexBuffer.h" +#include "Shader.h" + //Macros #define ASSERT(x) if(!(x)) __debugbreak(); #define GLCall(x) GLClearError();\ @@ -11,4 +15,10 @@ //Clearing OpenGl error list void GLClearError(); //OpenGl logging -bool GLLogCall(const char* function, const char* file, int line); \ No newline at end of file +bool GLLogCall(const char* function, const char* file, int line); + +class Renderer { +public: + void Clear() const; + void Draw(const VertexArray& va, const IndexBuffer& ib, const Shader& shader) const; +}; \ No newline at end of file diff --git a/Window_practice/src/VertexArray.cpp b/Window_practice/src/VertexArray.cpp index 2396f81..3a9baa7 100644 --- a/Window_practice/src/VertexArray.cpp +++ b/Window_practice/src/VertexArray.cpp @@ -1,4 +1,5 @@ #include "VertexArray.h" +#include "VertexBufferLayout.h" #include "Renderer.h" VertexArray::VertexArray() diff --git a/Window_practice/src/VertexArray.h b/Window_practice/src/VertexArray.h index 7b57e4b..43947be 100644 --- a/Window_practice/src/VertexArray.h +++ b/Window_practice/src/VertexArray.h @@ -1,7 +1,8 @@ #pragma once #include "VertexBuffer.h" -#include "VertexBufferLayout.h" + +class VertexBufferLayout; class VertexArray { private: