More stuff

This commit is contained in:
Vitor Fernandes 2020-07-02 03:01:54 +01:00
parent d4827b1366
commit c4407c5275
No known key found for this signature in database
GPG key ID: EBFB4EE09F348A26
7 changed files with 31 additions and 12 deletions

View file

@ -1,7 +1,7 @@
# Search for glfw # Search for glfw
find_package(glfw3 3.3 REQUIRED) find_package(glfw3 3.3 REQUIRED)
# Search for glew # Search for glew
#find_package(GLEW REQUIRED) find_package(GLEW REQUIRED)
# Search for OpenGL # Search for OpenGL
find_package(OpenGL REQUIRED) find_package(OpenGL REQUIRED)
add_compile_definitions(IS_DEBUG=1) 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 gl1 executable build from gl1.cpp, glew.c and Renderer.cpp
add_executable( add_executable(
gl1 gl1
glew.c
gl1.cpp gl1.cpp
Shader.cpp Shader.cpp
Renderer.cpp Renderer.cpp
VertexBuffer.cpp VertexBuffer.cpp
IndexBuffer.cpp IndexBuffer.cpp
VertexArray.cpp VertexArray.cpp
glew.c
utils.cpp utils.cpp
) )

View file

@ -3,7 +3,7 @@
//Force the compilation process to statically link glew //Force the compilation process to statically link glew
#define GLEW_STATIC #define GLEW_STATIC
#include "glew.h" #include <GL/glew.h>
#include <GLFW/glfw3.h> #include <GLFW/glfw3.h>
#include <csignal> #include <csignal>

View file

@ -3,7 +3,10 @@
VertexArray::VertexArray() VertexArray::VertexArray()
{ {
LOG("VERTEX_ARRAY_START");
LOG(glGenVertexArrays);
GLCall(glGenVertexArrays(1,&m_RendererID)); GLCall(glGenVertexArrays(1,&m_RendererID));
LOG("VERTEX_ARRAY_END");
} }
VertexArray::~VertexArray() VertexArray::~VertexArray()

View file

@ -1,7 +1,7 @@
#pragma once #pragma once
#include <vector> #include <vector>
#include "glew.h" #include <GL/glew.h>
#include "utils.h" #include "utils.h"
struct VertexBufferElement struct VertexBufferElement

View file

@ -4,6 +4,7 @@
#include <string> #include <string>
#include <sstream> #include <sstream>
#include <signal.h> #include <signal.h>
#include <stdlib.h>
#include "Shader.h" #include "Shader.h"
#include "Renderer.h" #include "Renderer.h"
@ -25,9 +26,19 @@ int main(void)
if (!glfwInit()) if (!glfwInit())
return -1; 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 */ /* Create a windowed mode window and its OpenGL context */
LOG("Create Window"); 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); window = glfwCreateWindow(640, 480, "OpenGL Window", NULL, NULL);
if (!window) if (!window)
{ {
LOG("Terminate because not window"); LOG("Terminate because not window");
@ -40,8 +51,7 @@ int main(void)
glfwMakeContextCurrent(window); glfwMakeContextCurrent(window);
glfwSwapInterval(1); glfwSwapInterval(1);
//Print opengl version GLPrintVersion();
LOG("GL_VERSION: " << glGetString(GL_VERSION));
float positions[] = float positions[] =
{ {
@ -55,10 +65,7 @@ int main(void)
//Create buffer //Create buffer
//Buffer id //Buffer id
LOG("VertexArray defining");
VertexArray va; VertexArray va;
LOG("VertexArray defined");
LOG("VertexBuffer to be created"); LOG("VertexBuffer to be created");
VertexBuffer vb(positions, 4 * 2 * sizeof(float)); VertexBuffer vb(positions, 4 * 2 * sizeof(float));

View file

@ -16,7 +16,15 @@ bool GLLogCall(const char *function, const char *file, int line)
return true; return true;
} }
return false; 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) void ErrorGLCallback(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *message, const void *userParam)
{ {

View file

@ -1,6 +1,6 @@
#pragma once #pragma once
#include <iostream> #include <iostream>
#include "glew.h" #include <GL/glew.h>
#include <csignal> #include <csignal>
#if IS_DEBUG==1 #if IS_DEBUG==1
@ -21,6 +21,7 @@
//Discard error flags from openGL state machine //Discard error flags from openGL state machine
void GLClearError(); void GLClearError();
void GLPrintVersion();
bool GLLogCall(const char *function, const char *file, int line); bool GLLogCall(const char *function, const char *file, int line);
//This is just for OpenGL4.3 onwards //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); void ErrorGLCallback(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *message, const void *userParam);