diff --git a/src/opengl/CMakeLists.txt b/src/opengl/CMakeLists.txt index f6d4229..57f8fcb 100644 --- a/src/opengl/CMakeLists.txt +++ b/src/opengl/CMakeLists.txt @@ -1,7 +1,7 @@ # Search for glfw find_package(glfw3 3.3 REQUIRED) # Search for glew -#find_package(GLEW REQUIRED) +find_package(GLEW REQUIRED) # Search for OpenGL find_package(OpenGL REQUIRED) add_compile_definitions(IS_DEBUG=1) @@ -10,14 +10,14 @@ add_compile_definitions(IS_DEBUG=1) # Add gl1 executable build from gl1.cpp, glew.c and Renderer.cpp add_executable( - gl1 + gl1 + glew.c gl1.cpp Shader.cpp Renderer.cpp VertexBuffer.cpp IndexBuffer.cpp VertexArray.cpp - glew.c utils.cpp ) diff --git a/src/opengl/Renderer.h b/src/opengl/Renderer.h index e29ff37..9c4376e 100644 --- a/src/opengl/Renderer.h +++ b/src/opengl/Renderer.h @@ -3,7 +3,7 @@ //Force the compilation process to statically link glew #define GLEW_STATIC -#include "glew.h" +#include #include #include diff --git a/src/opengl/VertexArray.cpp b/src/opengl/VertexArray.cpp index 57768c8..2c0e121 100644 --- a/src/opengl/VertexArray.cpp +++ b/src/opengl/VertexArray.cpp @@ -3,7 +3,10 @@ VertexArray::VertexArray() { + LOG("VERTEX_ARRAY_START"); + LOG(glGenVertexArrays); GLCall(glGenVertexArrays(1,&m_RendererID)); + LOG("VERTEX_ARRAY_END"); } VertexArray::~VertexArray() diff --git a/src/opengl/VertexBufferLayout.h b/src/opengl/VertexBufferLayout.h index ca4c44b..26334da 100644 --- a/src/opengl/VertexBufferLayout.h +++ b/src/opengl/VertexBufferLayout.h @@ -1,7 +1,7 @@ #pragma once #include -#include "glew.h" +#include #include "utils.h" struct VertexBufferElement diff --git a/src/opengl/gl1.cpp b/src/opengl/gl1.cpp index 8982074..69fadf1 100644 --- a/src/opengl/gl1.cpp +++ b/src/opengl/gl1.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include "Shader.h" #include "Renderer.h" @@ -25,9 +26,19 @@ int main(void) if (!glfwInit()) return -1; + glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); + glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2); + glfwWindowHint(GLFW_OPENGL_PROFILE,GLFW_OPENGL_CORE_PROFILE); + glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); + glfwWindowHint(GLFW_RESIZABLE, GL_FALSE); + /* Create a windowed mode window and its OpenGL context */ LOG("Create Window"); + //glfwCreateWindow(640, 480, "OpenGL Window", NULL, NULL); + //GLCall(window = glfwCreateWindow(640, 480, "OpenGL Window", NULL, NULL)); + window = glfwCreateWindow(640, 480, "OpenGL Window", NULL, NULL); + if (!window) { LOG("Terminate because not window"); @@ -40,8 +51,7 @@ int main(void) glfwMakeContextCurrent(window); glfwSwapInterval(1); - //Print opengl version - LOG("GL_VERSION: " << glGetString(GL_VERSION)); + GLPrintVersion(); float positions[] = { @@ -55,10 +65,7 @@ int main(void) //Create buffer //Buffer id - - LOG("VertexArray defining"); VertexArray va; - LOG("VertexArray defined"); LOG("VertexBuffer to be created"); VertexBuffer vb(positions, 4 * 2 * sizeof(float)); diff --git a/src/opengl/utils.cpp b/src/opengl/utils.cpp index d57b039..03b8a24 100644 --- a/src/opengl/utils.cpp +++ b/src/opengl/utils.cpp @@ -16,7 +16,15 @@ bool GLLogCall(const char *function, const char *file, int line) return true; } return false; -} +} + +void GLPrintVersion() +{ + LOG("Vendor: " << glGetString(GL_VENDOR)); + LOG("Renderer: " << glGetString(GL_RENDERER)); + LOG("Version: " << glGetString(GL_VERSION)); + LOG("Shading Version: " << glGetString(GL_SHADING_LANGUAGE_VERSION)); +} void ErrorGLCallback(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *message, const void *userParam) { diff --git a/src/opengl/utils.h b/src/opengl/utils.h index 403433a..de9e7e0 100644 --- a/src/opengl/utils.h +++ b/src/opengl/utils.h @@ -1,6 +1,6 @@ #pragma once #include -#include "glew.h" +#include #include #if IS_DEBUG==1 @@ -21,6 +21,7 @@ //Discard error flags from openGL state machine void GLClearError(); +void GLPrintVersion(); bool GLLogCall(const char *function, const char *file, int line); //This is just for OpenGL4.3 onwards void ErrorGLCallback(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *message, const void *userParam); \ No newline at end of file