More stuff
This commit is contained in:
parent
d4827b1366
commit
c4407c5275
7 changed files with 31 additions and 12 deletions
|
@ -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)
|
||||
|
@ -11,13 +11,13 @@ add_compile_definitions(IS_DEBUG=1)
|
|||
# Add gl1 executable build from gl1.cpp, glew.c and Renderer.cpp
|
||||
add_executable(
|
||||
gl1
|
||||
glew.c
|
||||
gl1.cpp
|
||||
Shader.cpp
|
||||
Renderer.cpp
|
||||
VertexBuffer.cpp
|
||||
IndexBuffer.cpp
|
||||
VertexArray.cpp
|
||||
glew.c
|
||||
utils.cpp
|
||||
)
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
//Force the compilation process to statically link glew
|
||||
#define GLEW_STATIC
|
||||
|
||||
#include "glew.h"
|
||||
#include <GL/glew.h>
|
||||
#include <GLFW/glfw3.h>
|
||||
#include <csignal>
|
||||
|
||||
|
|
|
@ -3,7 +3,10 @@
|
|||
|
||||
VertexArray::VertexArray()
|
||||
{
|
||||
LOG("VERTEX_ARRAY_START");
|
||||
LOG(glGenVertexArrays);
|
||||
GLCall(glGenVertexArrays(1,&m_RendererID));
|
||||
LOG("VERTEX_ARRAY_END");
|
||||
}
|
||||
|
||||
VertexArray::~VertexArray()
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include "glew.h"
|
||||
#include <GL/glew.h>
|
||||
#include "utils.h"
|
||||
|
||||
struct VertexBufferElement
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include <string>
|
||||
#include <sstream>
|
||||
#include <signal.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#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));
|
||||
|
|
|
@ -18,6 +18,14 @@ bool GLLogCall(const char *function, const char *file, int line)
|
|||
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)
|
||||
{
|
||||
std::cout << "Source: " << source << "Type: " << type << "Id: " << id << "Severity: " << severity << "Length: " << length << message << std::endl;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#pragma once
|
||||
#include <iostream>
|
||||
#include "glew.h"
|
||||
#include <GL/glew.h>
|
||||
#include <csignal>
|
||||
|
||||
#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);
|
Loading…
Reference in a new issue