diff --git a/Debug/Window_practice.exe b/Debug/Window_practice.exe
index 3bdfcc2..259910a 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 08a9717..9d215c7 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 3f6e3a8..08f1725 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 1606bb4..6a96939 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 8fa17b8..7f84570 100644
--- a/Window_practice/Debug/Window_practice.log
+++ b/Window_practice/Debug/Window_practice.log
@@ -1,5 +1,2 @@
Main.cpp
-LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library
-LINK : warning LNK4098: defaultlib 'LIBCMT' 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 'C:\dev\Glfw_Practice\c++\Window_practice\Debug\vc120.pdb'; linking object as if no debug info
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 2d05569..d3f6f4b 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 982d0cf..ff2c7d9 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 4dd3728..908397d 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.command.1.tlog b/Window_practice/Debug/Window_practice.tlog/link.command.1.tlog
index fa7e6bb..8536775 100644
Binary files a/Window_practice/Debug/Window_practice.tlog/link.command.1.tlog and b/Window_practice/Debug/Window_practice.tlog/link.command.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 d727625..a753cd3 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/Window_practice.tlog/link.write.1.tlog b/Window_practice/Debug/Window_practice.tlog/link.write.1.tlog
index ff2831e..ef1a633 100644
Binary files a/Window_practice/Debug/Window_practice.tlog/link.write.1.tlog and b/Window_practice/Debug/Window_practice.tlog/link.write.1.tlog differ
diff --git a/Window_practice/Debug/vc142.idb b/Window_practice/Debug/vc142.idb
index 132ac97..f0560b3 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 262b107..341b1b2 100644
Binary files a/Window_practice/Debug/vc142.pdb and b/Window_practice/Debug/vc142.pdb differ
diff --git a/Window_practice/Window_practice.vcxproj b/Window_practice/Window_practice.vcxproj
index 39d4a4c..4a974b3 100644
--- a/Window_practice/Window_practice.vcxproj
+++ b/Window_practice/Window_practice.vcxproj
@@ -145,10 +145,16 @@
+
+
+
+
+
+
diff --git a/Window_practice/Window_practice.vcxproj.filters b/Window_practice/Window_practice.vcxproj.filters
index 6ea4cd9..e280cae 100644
--- a/Window_practice/Window_practice.vcxproj.filters
+++ b/Window_practice/Window_practice.vcxproj.filters
@@ -18,11 +18,29 @@
Source Files
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
Header Files
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
diff --git a/Window_practice/src/Main.cpp b/Window_practice/src/Main.cpp
index 2fc2ce7..e7e32d3 100644
--- a/Window_practice/src/Main.cpp
+++ b/Window_practice/src/Main.cpp
@@ -6,27 +6,9 @@
#include
#include
-//Macros
-#define ASSERT(x) if(!(x)) __debugbreak();
-#define GLCall(x) GLClearError();\
- x;\
- ASSERT(GLLogCall(#x, __FILE__, __LINE__))
-
-//Clearing OpenGl error list
-static void GLClearError() {
- while (glGetError() != GL_NO_ERROR);
-}
-
-//OpenGl logging
-static bool GLLogCall(const char* function, const char* file, int line) {
- while (GLenum error = glGetError()) {
- std::cout << "[OpenGL Error] (" << error << "): "
- << function << " " << file << ":" << line << std::endl;
- return false;
- }
-
- return true;
-}
+#include "Renderer.h"
+#include "VertexBuffer.h"
+#include "IndexBuffer.h"
struct ShaderProgramSource {
std::string VertexSource;
@@ -138,97 +120,91 @@ int main(void){
}
std::cout << "OpenGL version: " << glGetString(GL_VERSION) << std::endl;
+ {
+ //vertex positions
+ float positions[] = {
+ -0.5f, -0.5f,
+ 0.5f, -0.5f,
+ 0.5f, 0.5f,
+ -0.5f, 0.5f
+ };
- //vertex positions
- float positions[] = {
- -0.5f, -0.5f,
- 0.5f, -0.5f,
- 0.5f, 0.5f,
- -0.5f, 0.5f
- };
-
- //index buffer
- unsigned int indecies[]{
- 0, 1, 2,
- 2, 3, 0
- };
-
- //creating vertex array object and bindig it
- unsigned int vao;
- GLCall(glGenVertexArrays(1, &vao));
- GLCall(glBindVertexArray(vao));
-
- //Vertex buffer(s)
- unsigned int buffer;
- GLCall(glGenBuffers(1, &buffer)); //number of buffer to generate
- GLCall(glBindBuffer(GL_ARRAY_BUFFER, buffer)); //binding the buffer
- GLCall(glBufferData(GL_ARRAY_BUFFER, 4 * 2 * sizeof(float), positions, GL_STATIC_DRAW));
-
- GLCall(glEnableVertexAttribArray(0));
- GLCall(glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, sizeof(float) * 2, 0));
-
- //index buffer setup
- unsigned int ibo; //index buffer object
- GLCall(glGenBuffers(1, &ibo));
- GLCall(glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ibo)); //binding the buffer
- GLCall(glBufferData(GL_ELEMENT_ARRAY_BUFFER, 6 * sizeof(unsigned int), indecies, GL_STATIC_DRAW));
-
- //Shader to console
- ShaderProgramSource source = ParseShader("res/shaders/Basic.shader");
- std::cout << "VERTEX" << std::endl;
- std::cout << source.VertexSource << std::endl;
- std::cout << "FRAGMENT" << std::endl;
- std::cout << source.FragmentSource << std::endl;
-
- //Creating the shader
- unsigned int shader = CreateShader(source.VertexSource, source.FragmentSource);
- glUseProgram(shader);
-
- //Shader Uniform
- //need to bound a shader before this
- GLCall(int location = glGetUniformLocation(shader, "u_Color")); //finding u_Color location
- ASSERT(location != -1);
- GLCall(glUniform4f(location, 0.8f, 0.3f, 0.8f, 1.0f));
-
- //unbinding the buffers
- GLCall(glBindVertexArray(0));
- GLCall(glUseProgram(0));
- GLCall(glBindBuffer(GL_ARRAY_BUFFER, 0));
- GLCall(glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0));
-
- //for animation
- float r = 0.0f;
- float increment = 0.05f;
-
- //Main loop
- while (!glfwWindowShouldClose(window)){
- /* Render here */
- GLCall(glClear(GL_COLOR_BUFFER_BIT));
-
- GLCall(glUseProgram(shader));
- GLCall(glUniform4f(location, r, 0.3f, 0.8f, 1.0f));
+ //index buffer
+ unsigned int indecies[]{
+ 0, 1, 2,
+ 2, 3, 0
+ };
+ //creating vertex array object and bindig it
+ unsigned int vao;
+ GLCall(glGenVertexArrays(1, &vao));
GLCall(glBindVertexArray(vao));
- GLCall(glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ibo));
- GLCall(glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, nullptr));
+ //Vertex buffer(s)
+ VertexBuffer vb(positions, 4 * 2 * sizeof(float));
- if (r > 1.0f)
- increment = -0.05f;
- else if (r < 0.0f)
- increment = 0.05f;
+ GLCall(glEnableVertexAttribArray(0));
+ GLCall(glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, sizeof(float) * 2, 0));
- r += increment;
+ //index buffer
+ IndexBuffer ib(indecies, 6);
- /* Swap front and back buffers */
- GLCall(glfwSwapBuffers(window));
+ //Shader to console
+ ShaderProgramSource source = ParseShader("res/shaders/Basic.shader");
+ /*std::cout << "VERTEX" << std::endl;
+ std::cout << source.VertexSource << std::endl; //to write shader to console
+ std::cout << "FRAGMENT" << std::endl;
+ std::cout << source.FragmentSource << std::endl;*/
- /* Poll for and process events */
- GLCall(glfwPollEvents());
+ //Creating the shader
+ unsigned int shader = CreateShader(source.VertexSource, source.FragmentSource);
+ glUseProgram(shader);
+
+ //Shader Uniform
+ //need to bound a shader before this
+ GLCall(int location = glGetUniformLocation(shader, "u_Color")); //finding u_Color location
+ ASSERT(location != -1);
+ GLCall(glUniform4f(location, 0.8f, 0.3f, 0.8f, 1.0f));
+
+ //unbinding the buffers
+ GLCall(glBindVertexArray(0));
+ GLCall(glUseProgram(0));
+ GLCall(glBindBuffer(GL_ARRAY_BUFFER, 0));
+ GLCall(glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0));
+
+ //for animation
+ float r = 0.0f;
+ float increment = 0.05f;
+
+ //Main loop
+ while (!glfwWindowShouldClose(window)) {
+ /* Render here */
+ GLCall(glClear(GL_COLOR_BUFFER_BIT));
+
+ GLCall(glUseProgram(shader));
+ GLCall(glUniform4f(location, r, 0.3f, 0.8f, 1.0f));
+
+ GLCall(glBindVertexArray(vao));
+ ib.Bind();
+
+ GLCall(glDrawElements(GL_TRIANGLES, 6, 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 */
+ GLCall(glfwSwapBuffers(window));
+
+ /* Poll for and process events */
+ GLCall(glfwPollEvents());
+ }
+
+ GLCall(glDeleteProgram(shader));
}
-
- GLCall(glDeleteProgram(shader));
-
glfwTerminate();
return 0;
}
\ No newline at end of file