diff --git a/.vs/OpenGL/v17/.suo b/.vs/OpenGL/v17/.suo index 89f6c8d..583c2b4 100644 Binary files a/.vs/OpenGL/v17/.suo and b/.vs/OpenGL/v17/.suo differ diff --git a/.vs/OpenGL/v17/Browse.VC.db b/.vs/OpenGL/v17/Browse.VC.db index 8bde3e6..9625b35 100644 Binary files a/.vs/OpenGL/v17/Browse.VC.db and b/.vs/OpenGL/v17/Browse.VC.db differ diff --git a/.vs/OpenGL/v17/ipch/AutoPCH/19c5fdc91625b6ef/APPLICATION.ipch b/.vs/OpenGL/v17/ipch/AutoPCH/19c5fdc91625b6ef/APPLICATION.ipch index 5fcee05..5d6174c 100644 Binary files a/.vs/OpenGL/v17/ipch/AutoPCH/19c5fdc91625b6ef/APPLICATION.ipch and b/.vs/OpenGL/v17/ipch/AutoPCH/19c5fdc91625b6ef/APPLICATION.ipch differ diff --git a/.vs/OpenGL/v17/ipch/AutoPCH/29f0bb36daeece8/REMDERER.ipch b/.vs/OpenGL/v17/ipch/AutoPCH/29f0bb36daeece8/REMDERER.ipch new file mode 100644 index 0000000..b961a3a Binary files /dev/null and b/.vs/OpenGL/v17/ipch/AutoPCH/29f0bb36daeece8/REMDERER.ipch differ diff --git a/.vs/OpenGL/v17/ipch/AutoPCH/2eb7037a0f95a519/VERTEXBUFFER.ipch b/.vs/OpenGL/v17/ipch/AutoPCH/2eb7037a0f95a519/VERTEXBUFFER.ipch new file mode 100644 index 0000000..bbcc6ad Binary files /dev/null and b/.vs/OpenGL/v17/ipch/AutoPCH/2eb7037a0f95a519/VERTEXBUFFER.ipch differ diff --git a/.vs/OpenGL/v17/ipch/AutoPCH/64e5a29d06d8a206/RENDERER.ipch b/.vs/OpenGL/v17/ipch/AutoPCH/64e5a29d06d8a206/RENDERER.ipch new file mode 100644 index 0000000..1937c19 Binary files /dev/null and b/.vs/OpenGL/v17/ipch/AutoPCH/64e5a29d06d8a206/RENDERER.ipch differ diff --git a/.vs/OpenGL/v17/ipch/AutoPCH/7785b098ab0d136/APPLICATION.ipch b/.vs/OpenGL/v17/ipch/AutoPCH/7785b098ab0d136/APPLICATION.ipch deleted file mode 100644 index f4ceadb..0000000 Binary files a/.vs/OpenGL/v17/ipch/AutoPCH/7785b098ab0d136/APPLICATION.ipch and /dev/null differ diff --git a/.vs/OpenGL/v17/ipch/AutoPCH/9c05f35919684dbb/RENDERER.ipch b/.vs/OpenGL/v17/ipch/AutoPCH/9c05f35919684dbb/RENDERER.ipch new file mode 100644 index 0000000..61a3a8f Binary files /dev/null and b/.vs/OpenGL/v17/ipch/AutoPCH/9c05f35919684dbb/RENDERER.ipch differ diff --git a/.vs/OpenGL/v17/ipch/AutoPCH/be8e051a9678111d/APPLICATION.ipch b/.vs/OpenGL/v17/ipch/AutoPCH/be8e051a9678111d/APPLICATION.ipch new file mode 100644 index 0000000..e5411f6 Binary files /dev/null and b/.vs/OpenGL/v17/ipch/AutoPCH/be8e051a9678111d/APPLICATION.ipch differ diff --git a/.vs/OpenGL/v17/ipch/AutoPCH/ed3850acba3c2a77/INDEXBUFFER.ipch b/.vs/OpenGL/v17/ipch/AutoPCH/ed3850acba3c2a77/INDEXBUFFER.ipch new file mode 100644 index 0000000..3b9755c Binary files /dev/null and b/.vs/OpenGL/v17/ipch/AutoPCH/ed3850acba3c2a77/INDEXBUFFER.ipch differ diff --git a/.vs/VSWorkspaceState.json b/.vs/VSWorkspaceState.json new file mode 100644 index 0000000..05f8ab5 --- /dev/null +++ b/.vs/VSWorkspaceState.json @@ -0,0 +1,7 @@ +{ + "ExpandedNodes": [ + "" + ], + "SelectedNode": "\\OpenGL.sln", + "PreviewInSolutionExplorer": false +} \ No newline at end of file diff --git a/.vs/slnx.sqlite b/.vs/slnx.sqlite new file mode 100644 index 0000000..dc852fe Binary files /dev/null and b/.vs/slnx.sqlite differ diff --git a/Debug/OpenGL.exe b/Debug/OpenGL.exe index 0b1dae8..4eb0aad 100644 Binary files a/Debug/OpenGL.exe and b/Debug/OpenGL.exe differ diff --git a/Debug/OpenGL.pdb b/Debug/OpenGL.pdb index 24b6b94..73431ca 100644 Binary files a/Debug/OpenGL.pdb and b/Debug/OpenGL.pdb differ diff --git a/OpenGL/Debug/Application.obj b/OpenGL/Debug/Application.obj index 5a160ee..77f3621 100644 Binary files a/OpenGL/Debug/Application.obj and b/OpenGL/Debug/Application.obj differ diff --git a/OpenGL/Debug/IndexBuffer.obj b/OpenGL/Debug/IndexBuffer.obj new file mode 100644 index 0000000..f66effc Binary files /dev/null and b/OpenGL/Debug/IndexBuffer.obj differ diff --git a/OpenGL/Debug/OpenGL.ilk b/OpenGL/Debug/OpenGL.ilk index 70daa5d..a6cd517 100644 Binary files a/OpenGL/Debug/OpenGL.ilk and b/OpenGL/Debug/OpenGL.ilk differ diff --git a/OpenGL/Debug/OpenGL.log b/OpenGL/Debug/OpenGL.log index 65f511a..c137235 100644 --- a/OpenGL/Debug/OpenGL.log +++ b/OpenGL/Debug/OpenGL.log @@ -1,5 +1,2 @@  Application.cpp -LINK : warning LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs; use /NODEFAULTLIB:library -LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library -glew32s.lib(glew.obj) : warning LNK4099: PDB 'vc120.pdb' was not found with 'glew32s.lib(glew.obj)' or at 'D:\cpp\OpenGL\Debug\vc120.pdb'; linking object as if no debug info OpenGL.vcxproj -> D:\cpp\OpenGL\Debug\OpenGL.exe diff --git a/OpenGL/Debug/OpenGL.tlog/CL.command.1.tlog b/OpenGL/Debug/OpenGL.tlog/CL.command.1.tlog index 96dc2fa..6958b21 100644 Binary files a/OpenGL/Debug/OpenGL.tlog/CL.command.1.tlog and b/OpenGL/Debug/OpenGL.tlog/CL.command.1.tlog differ diff --git a/OpenGL/Debug/OpenGL.tlog/CL.read.1.tlog b/OpenGL/Debug/OpenGL.tlog/CL.read.1.tlog index 88cd8fb..71f9ab2 100644 Binary files a/OpenGL/Debug/OpenGL.tlog/CL.read.1.tlog and b/OpenGL/Debug/OpenGL.tlog/CL.read.1.tlog differ diff --git a/OpenGL/Debug/OpenGL.tlog/CL.write.1.tlog b/OpenGL/Debug/OpenGL.tlog/CL.write.1.tlog index b7dfd2e..6db3f97 100644 Binary files a/OpenGL/Debug/OpenGL.tlog/CL.write.1.tlog and b/OpenGL/Debug/OpenGL.tlog/CL.write.1.tlog differ diff --git a/OpenGL/Debug/OpenGL.tlog/link.command.1.tlog b/OpenGL/Debug/OpenGL.tlog/link.command.1.tlog index 765f912..52278d7 100644 Binary files a/OpenGL/Debug/OpenGL.tlog/link.command.1.tlog and b/OpenGL/Debug/OpenGL.tlog/link.command.1.tlog differ diff --git a/OpenGL/Debug/OpenGL.tlog/link.read.1.tlog b/OpenGL/Debug/OpenGL.tlog/link.read.1.tlog index c161083..d02cc04 100644 Binary files a/OpenGL/Debug/OpenGL.tlog/link.read.1.tlog and b/OpenGL/Debug/OpenGL.tlog/link.read.1.tlog differ diff --git a/OpenGL/Debug/OpenGL.tlog/link.write.1.tlog b/OpenGL/Debug/OpenGL.tlog/link.write.1.tlog index c954736..08deab1 100644 Binary files a/OpenGL/Debug/OpenGL.tlog/link.write.1.tlog and b/OpenGL/Debug/OpenGL.tlog/link.write.1.tlog differ diff --git a/OpenGL/Debug/Renderer.obj b/OpenGL/Debug/Renderer.obj new file mode 100644 index 0000000..49f6f9c Binary files /dev/null and b/OpenGL/Debug/Renderer.obj differ diff --git a/OpenGL/Debug/VertexBuffer.obj b/OpenGL/Debug/VertexBuffer.obj new file mode 100644 index 0000000..47115b1 Binary files /dev/null and b/OpenGL/Debug/VertexBuffer.obj differ diff --git a/OpenGL/Debug/application.obj.enc b/OpenGL/Debug/application.obj.enc new file mode 100644 index 0000000..a68e7e0 Binary files /dev/null and b/OpenGL/Debug/application.obj.enc differ diff --git a/OpenGL/Debug/vc143.idb b/OpenGL/Debug/vc143.idb index 0b24eb3..918b66e 100644 Binary files a/OpenGL/Debug/vc143.idb and b/OpenGL/Debug/vc143.idb differ diff --git a/OpenGL/Debug/vc143.pdb b/OpenGL/Debug/vc143.pdb index 75de98b..2f5b7fb 100644 Binary files a/OpenGL/Debug/vc143.pdb and b/OpenGL/Debug/vc143.pdb differ diff --git a/OpenGL/OpenGL.vcxproj b/OpenGL/OpenGL.vcxproj index bcaa3ea..f640133 100644 --- a/OpenGL/OpenGL.vcxproj +++ b/OpenGL/OpenGL.vcxproj @@ -152,10 +152,18 @@ + + + + + + + + diff --git a/OpenGL/OpenGL.vcxproj.filters b/OpenGL/OpenGL.vcxproj.filters index 706e1ae..9cf59c6 100644 --- a/OpenGL/OpenGL.vcxproj.filters +++ b/OpenGL/OpenGL.vcxproj.filters @@ -18,8 +18,28 @@ Source Files + + Source Files + + + Source Files + + + Source Files + + + + Header Files + + + Header Files + + + Header Files + + \ No newline at end of file diff --git a/OpenGL/Release/Application.obj b/OpenGL/Release/Application.obj new file mode 100644 index 0000000..a0e2276 Binary files /dev/null and b/OpenGL/Release/Application.obj differ diff --git a/OpenGL/Release/OpenGL.exe.recipe b/OpenGL/Release/OpenGL.exe.recipe new file mode 100644 index 0000000..273b2bb --- /dev/null +++ b/OpenGL/Release/OpenGL.exe.recipe @@ -0,0 +1,11 @@ + + + + + D:\cpp\OpenGL\Release\OpenGL.exe + + + + + + \ No newline at end of file diff --git a/OpenGL/Release/OpenGL.iobj b/OpenGL/Release/OpenGL.iobj new file mode 100644 index 0000000..f61499c Binary files /dev/null and b/OpenGL/Release/OpenGL.iobj differ diff --git a/OpenGL/Release/OpenGL.ipdb b/OpenGL/Release/OpenGL.ipdb new file mode 100644 index 0000000..e7cf563 Binary files /dev/null and b/OpenGL/Release/OpenGL.ipdb differ diff --git a/OpenGL/Release/OpenGL.log b/OpenGL/Release/OpenGL.log new file mode 100644 index 0000000..1cd75d2 --- /dev/null +++ b/OpenGL/Release/OpenGL.log @@ -0,0 +1,8 @@ + Application.cpp +LINK : warning LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs; use /NODEFAULTLIB:library + Generating code + Previous IPDB not found, fall back to full compilation. + All 214 functions were compiled because no usable IPDB/IOBJ from previous compilation was found. + Finished generating code +glew32s.lib(glew.obj) : warning LNK4099: PDB 'vc120.pdb' was not found with 'glew32s.lib(glew.obj)' or at 'D:\cpp\OpenGL\Release\vc120.pdb'; linking object as if no debug info + OpenGL.vcxproj -> D:\cpp\OpenGL\Release\OpenGL.exe diff --git a/OpenGL/Release/OpenGL.tlog/CL.command.1.tlog b/OpenGL/Release/OpenGL.tlog/CL.command.1.tlog new file mode 100644 index 0000000..4705705 Binary files /dev/null and b/OpenGL/Release/OpenGL.tlog/CL.command.1.tlog differ diff --git a/OpenGL/Release/OpenGL.tlog/CL.read.1.tlog b/OpenGL/Release/OpenGL.tlog/CL.read.1.tlog new file mode 100644 index 0000000..88cd8fb Binary files /dev/null and b/OpenGL/Release/OpenGL.tlog/CL.read.1.tlog differ diff --git a/OpenGL/Release/OpenGL.tlog/CL.write.1.tlog b/OpenGL/Release/OpenGL.tlog/CL.write.1.tlog new file mode 100644 index 0000000..500012c Binary files /dev/null and b/OpenGL/Release/OpenGL.tlog/CL.write.1.tlog differ diff --git a/OpenGL/Release/OpenGL.tlog/OpenGL.lastbuildstate b/OpenGL/Release/OpenGL.tlog/OpenGL.lastbuildstate new file mode 100644 index 0000000..3cac30c --- /dev/null +++ b/OpenGL/Release/OpenGL.tlog/OpenGL.lastbuildstate @@ -0,0 +1,2 @@ +PlatformToolSet=v143:VCToolArchitecture=Native32Bit:VCToolsVersion=14.31.31103:TargetPlatformVersion=10.0.19041.0: +Release|Win32|D:\cpp\OpenGL\| diff --git a/OpenGL/Release/OpenGL.tlog/link.command.1.tlog b/OpenGL/Release/OpenGL.tlog/link.command.1.tlog new file mode 100644 index 0000000..6819572 Binary files /dev/null and b/OpenGL/Release/OpenGL.tlog/link.command.1.tlog differ diff --git a/OpenGL/Release/OpenGL.tlog/link.read.1.tlog b/OpenGL/Release/OpenGL.tlog/link.read.1.tlog new file mode 100644 index 0000000..4948b1c Binary files /dev/null and b/OpenGL/Release/OpenGL.tlog/link.read.1.tlog differ diff --git a/OpenGL/Release/OpenGL.tlog/link.write.1.tlog b/OpenGL/Release/OpenGL.tlog/link.write.1.tlog new file mode 100644 index 0000000..b436507 Binary files /dev/null and b/OpenGL/Release/OpenGL.tlog/link.write.1.tlog differ diff --git a/OpenGL/Release/vc143.pdb b/OpenGL/Release/vc143.pdb new file mode 100644 index 0000000..4850e45 Binary files /dev/null and b/OpenGL/Release/vc143.pdb differ diff --git a/OpenGL/res/shaders/Basic.shader b/OpenGL/res/shaders/Basic.shader index 3265b45..2fa5a36 100644 --- a/OpenGL/res/shaders/Basic.shader +++ b/OpenGL/res/shaders/Basic.shader @@ -13,7 +13,9 @@ void main() layout(location = 0) out vec4 color; +uniform vec4 u_Color; + void main() { - color = vec4(1, 1, 0, 1.0); + color = u_Color; }; \ No newline at end of file diff --git a/OpenGL/src/Application.cpp b/OpenGL/src/Application.cpp index 477348e..fee1537 100644 --- a/OpenGL/src/Application.cpp +++ b/OpenGL/src/Application.cpp @@ -4,8 +4,13 @@ #include #include #include +#include #include +#include "Renderer.h" +#include "VertexBuffer.h" +#include "IndexBuffer.h" + struct ShaderProgramSource { std::string VertexSource; @@ -86,10 +91,16 @@ static unsigned int CreateShader(const std::string& vertexShader, const std::str int main(void) { + srand(static_cast (time(0))); /* Initialize the library */ + if (!glfwInit()) return -1; + glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); + glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); + glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); + /* Create a windowed mode window and its OpenGL context */ GLFWwindow* window = glfwCreateWindow(640, 480, "Hello World", nullptr, nullptr); @@ -103,78 +114,104 @@ int main(void) /* Make the window's context current */ glfwMakeContextCurrent(window); + glfwSwapInterval(1); if (glewInit() != GLEW_OK) std::cout << "ERROR" << std::endl; std::cout << glGetString(GL_VERSION) << std::endl; - - constexpr float triforcePos[] = { - -1.0f, -1.0f, //0 - -0.5f, 0.0f, //1 -- - 0.0f, -1.0f, //2 - 0.0f, 1.0f, //3 - 0.5f, 0.0f, //4 -- - 1.0f, -1.0f //5 - - }; - - unsigned int triforceInd[] = { - 0, 1, 2, - 2, 4, 5, - 1, 3, 4 - - }; - - constexpr float positions[] = { - -0.5f, -0.5f, - 0.5f, -0.5f, - 0.5f, 0.5f, - -0.5f, 0.5f, - - }; - - unsigned int indices[] = { - 0, 1, 2, - 2, 3, 0 - }; - - unsigned int buffer; - glGenBuffers(1, &buffer); - glBindBuffer(GL_ARRAY_BUFFER, buffer); - glBufferData(GL_ARRAY_BUFFER, 6 * 2 * sizeof(float), triforcePos, GL_STATIC_DRAW); - - glEnableVertexAttribArray(0); - glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, sizeof(float) * 2, 0); - - unsigned int ibo; - glGenBuffers(1, &ibo); - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ibo); - glBufferData(GL_ELEMENT_ARRAY_BUFFER, 3 * 3 * sizeof(unsigned int), triforceInd, GL_STATIC_DRAW); - - ShaderProgramSource source = ParseShader("res/shaders/Basic.shader"); - - unsigned int shader = CreateShader(source.VertexSource, source.FragmentSource); - glUseProgram(shader); - - /* Loop until the user closes the window */ - while (!glfwWindowShouldClose(window)) { - /* Render here */ - glClear(GL_COLOR_BUFFER_BIT); + constexpr float triforcePos[] = { + -1.0f, -1.0f, //0 + -0.5f, 0.0f, //1 -- + 0.0f, -1.0f, //2 + 0.0f, 1.0f, //3 + 0.5f, 0.0f, //4 -- + 1.0f, -1.0f //5 - glDrawElements(GL_TRIANGLES, 9, GL_UNSIGNED_INT, nullptr); + }; + + unsigned int triforceInd[] = { + 0, 1, 2, + 2, 4, 5, + 1, 3, 4 + + }; + + constexpr float positions[] = { + -0.5f, -0.5f, + 0.5f, -0.5f, + 0.5f, 0.5f, + -0.5f, 0.5f, + + }; + + unsigned int indices[] = { + 0, 1, 2, + 2, 3, 0 + }; + + unsigned int vao; + GLCall(glGenVertexArrays(1, &vao)); + GLCall(glBindVertexArray(vao)); + + VertexBuffer vb(positions, 4 * 2 * sizeof(float)); + + glEnableVertexAttribArray(0); + glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, sizeof(float) * 2, 0); + + IndexBuffer ib(indices, 3 * 2); + + ShaderProgramSource source = ParseShader("res/shaders/Basic.shader"); + + unsigned int shader = CreateShader(source.VertexSource, source.FragmentSource); + glUseProgram(shader); - /* Swap front and back buffers */ - glfwSwapBuffers(window); + int location = glGetUniformLocation(shader, "u_Color"); + ASSERT(location != -1); + glUniform4f(location, 0.8f, 0.3f, 0.8f, 1.0f); - /* Poll for and process events */ - glfwPollEvents(); + GLCall(glBindVertexArray(0)); + glBindBuffer(GL_ARRAY_BUFFER, 0); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); + glUseProgram(0); + + float r = 0.0f; + float increment = 0.05f; + + int x = 0; + /* Loop until the user closes the window */ + while (!glfwWindowShouldClose(window)) + { + x++; + /* Render here */ + glClear(GL_COLOR_BUFFER_BIT); + + glUseProgram(shader); + glUniform4f(location, r, 0.3f, 0.8f, 1.0f); + + GLCall(glBindVertexArray(vao)); + ib.Bind(); + + GLCall(glDrawElements(GL_TRIANGLES, 9, GL_UNSIGNED_INT, nullptr)); + + if (r > 1.0f) + increment = -0.05f; + else if (r < 0.0f) + increment = 0.05f; + + r += increment; + + /* Swap front and back buffers */ + glfwSwapBuffers(window); + + /* Poll for and process events */ + glfwPollEvents(); + } + + glDeleteProgram(shader); } - - glDeleteProgram(shader); - glfwTerminate(); return 0; } \ No newline at end of file diff --git a/OpenGL/src/IndexBuffer.cpp b/OpenGL/src/IndexBuffer.cpp new file mode 100644 index 0000000..915b563 --- /dev/null +++ b/OpenGL/src/IndexBuffer.cpp @@ -0,0 +1,25 @@ +#include "IndexBuffer.h" +#include "Renderer.h" + +IndexBuffer::IndexBuffer(const unsigned int* data, unsigned int count) + : m_Count(count) +{ + GLCall(glGenBuffers(1, &m_RendererID)); + GLCall(glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_RendererID)); + GLCall(glBufferData(GL_ELEMENT_ARRAY_BUFFER, count * sizeof(unsigned int), data, GL_STATIC_DRAW)); +} + +IndexBuffer::~IndexBuffer() +{ + GLCall(glDeleteBuffers(1, &m_RendererID)); +} + +void IndexBuffer::Bind() const +{ + GLCall(glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_RendererID)); +} + +void IndexBuffer::Unbind() const +{ + GLCall(glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0)); +} diff --git a/OpenGL/src/IndexBuffer.h b/OpenGL/src/IndexBuffer.h new file mode 100644 index 0000000..793867d --- /dev/null +++ b/OpenGL/src/IndexBuffer.h @@ -0,0 +1,16 @@ +#pragma once + +class IndexBuffer +{ +private: + unsigned int m_RendererID; + unsigned int m_Count; +public: + IndexBuffer(const unsigned int* data, unsigned int count); + ~IndexBuffer(); + + void Bind() const; + void Unbind() const; + + inline unsigned int GetCount() const { return m_Count; } +}; \ No newline at end of file diff --git a/OpenGL/src/Renderer.cpp b/OpenGL/src/Renderer.cpp new file mode 100644 index 0000000..8200951 --- /dev/null +++ b/OpenGL/src/Renderer.cpp @@ -0,0 +1,18 @@ +#include "Renderer.h" + +#include + +void GLClearError() +{ + while (glGetError() != GL_NO_ERROR); +} + +bool GLLogCall(const char* function, const char* file, int line) +{ + while (const GLenum error = glGetError()) + { + std::cout << "[OpenGL Error] (" << error << "): " << function << " " << file << ":" << line << std::endl; + return false; + } + return true; +} \ No newline at end of file diff --git a/OpenGL/src/Renderer.h b/OpenGL/src/Renderer.h new file mode 100644 index 0000000..bc13469 --- /dev/null +++ b/OpenGL/src/Renderer.h @@ -0,0 +1,11 @@ +#pragma once + +#include + +#define ASSERT(x) if (!(x)) __debugbreak(); +#define GLCall(x) GLClearError();\ + x;\ + ASSERT(GLLogCall(#x, __FILE__, __LINE__)) + +void GLClearError(); +bool GLLogCall (const char* function, const char* file, int line); \ No newline at end of file diff --git a/OpenGL/src/VertexBuffer.cpp b/OpenGL/src/VertexBuffer.cpp new file mode 100644 index 0000000..fd73225 --- /dev/null +++ b/OpenGL/src/VertexBuffer.cpp @@ -0,0 +1,25 @@ +#include "VertexBuffer.h" +#include "Renderer.h" + +VertexBuffer::VertexBuffer(const void* data, unsigned int size) +{ + GLCall(glGenBuffers(1, &m_RendererID)); + GLCall(glBindBuffer(GL_ARRAY_BUFFER, m_RendererID)); + GLCall(glBufferData(GL_ARRAY_BUFFER, size, data, GL_STATIC_DRAW)); +} + +VertexBuffer::~VertexBuffer() +{ + GLCall(glDeleteBuffers(1, &m_RendererID)); +} + +void VertexBuffer::Bind() const +{ + GLCall(glBindBuffer(GL_ARRAY_BUFFER, m_RendererID)); +} + +void VertexBuffer::Unbind() const +{ + GLCall(glBindBuffer(GL_ARRAY_BUFFER, 0)); +} + diff --git a/OpenGL/src/VertexBuffer.h b/OpenGL/src/VertexBuffer.h new file mode 100644 index 0000000..b4ca84c --- /dev/null +++ b/OpenGL/src/VertexBuffer.h @@ -0,0 +1,13 @@ +#pragma once + +class VertexBuffer +{ +private: + unsigned int m_RendererID{}; +public: + VertexBuffer(const void* data, unsigned int size); + ~VertexBuffer(); + + void Bind() const; + void Unbind() const; +}; \ No newline at end of file diff --git a/Release/OpenGL.exe b/Release/OpenGL.exe new file mode 100644 index 0000000..f4a3871 Binary files /dev/null and b/Release/OpenGL.exe differ diff --git a/Release/OpenGL.pdb b/Release/OpenGL.pdb new file mode 100644 index 0000000..8ed2e33 Binary files /dev/null and b/Release/OpenGL.pdb differ