1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
|
#include "OGLAbstr.hpp"
OGLAbstr::OGLAbstr(LogMgr* log)
{
mLog = log;
if(!glfwInit())
{
mLog->logMessage(mLog->CRITICAL, "COULD NOT INITIALIZE GLFW");
}
mLog->logMessage(mLog->NORMAL, "Starting up OpenGL-GLFW");
}
OGLAbstr::~OGLAbstr()
{
glfwTerminate();
mLog->logMessage(mLog->NORMAL, "Shutting down OpenGL-GLFW");
}
bool OGLAbstr::renderOneFrame()
{
glfwSwapBuffers();
return true;
}
bool OGLAbstr::createWindow(int w, int h, bool fullscreen, int colourBits, int depthBits, int stencilBits)
{
glfwOpenWindowHint(GLFW_FSAA_SAMPLES, 4);
glfwOpenWindowHint(GLFW_OPENGL_VERSION_MAJOR, 3); // We want OpenGL 3.1
glfwOpenWindowHint(GLFW_OPENGL_VERSION_MINOR, 1);
glfwOpenWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); //We don't want the old OpenGL
if(!glfwOpenWindow( 800, 600, 0, 0, 0, 0, 32, 0, GLFW_WINDOW))
{
mLog->logMessage(mLog->CRITICAL, "COULD NOT CREATE RENDER WINDOW");
glfwTerminate();
return false;
}
else
{
mLog->logMessage(mLog->NORMAL, "Successfully created renderwindow");
glfwSetWindowTitle("Engine");
glClearColor(0.0f, 0.0f, 0.3f, 0.0f);
return true;
}
}
bool OGLAbstr::isOpen()
{
if(glfwGetWindowParam(GLFW_OPENED))
return true;
else
return false;
}
|