Created
October 31, 2015 18:18
-
-
Save witchica/1c30ab87ec822d8d5dd4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "GLEngine.h" | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <GL/glew.h> | |
#include <GLFW/glfw3.h> | |
#include <glm/glm.hpp> | |
GLEngine::GLEngine() | |
{ | |
} | |
GLEngine::~GLEngine() | |
{ | |
} | |
int GLEngine::init() | |
{ | |
if (!glfwInit()) | |
{ | |
fprintf(stderr, "Error initializing the GLFW context!"); | |
return -1; | |
} | |
glfwWindowHint(GLFW_SAMPLES, 4); | |
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); | |
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); | |
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); | |
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); | |
GLFWwindow* window; | |
window = glfwCreateWindow(1024, 768, "MessAbout", NULL, NULL); | |
if (window == NULL) | |
{ | |
fprintf(stderr, "Failed to initialize OpenGL window!"); | |
glfwTerminate(); | |
return -1; | |
} | |
glfwMakeContextCurrent(window); | |
glewExperimental = true; | |
if (glewInit() != GLEW_OK) | |
{ | |
fprintf(stderr, "Failed to initialize GLEW"); | |
return -1; | |
} | |
glfwSetInputMode(window, GLFW_STICKY_KEYS, GL_TRUE); | |
do { | |
// Draw nothing, see you in tutorial 2 ! | |
/*glBegin(GL_QUADS); | |
glVertex2f(0, 0); | |
glVertex2f(0, 1); | |
glVertex2f(1, 1); | |
glVertex2f(1, 0); | |
glEnd();*/ | |
// Swap buffers | |
glfwSwapBuffers(window); | |
glfwPollEvents(); | |
} // Check if the ESC key was pressed or the window was closed | |
while (glfwGetKey(window, GLFW_KEY_ESCAPE) != GLFW_PRESS && | |
glfwWindowShouldClose(window) == 0); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment