Skip to content

Commit

Permalink
Remove GLEW dependancy. OpenGL Context works Closes #5
Browse files Browse the repository at this point in the history
  • Loading branch information
beltegeuse committed Jun 28, 2011
1 parent 973276c commit 9afb783
Show file tree
Hide file tree
Showing 3 changed files with 916 additions and 16 deletions.
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ SET(CMAKE_COLOR_MAKEFILE ON)
SET(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/Config/CMake ${CMAKE_MODULE_PATH})

# -- Dependancies
FIND_PACKAGE(GLEW REQUIRED)
FIND_PACKAGE(OpenGL REQUIRED)

# * -- To install project ---
Expand Down
30 changes: 15 additions & 15 deletions Source/PCM/Win32/WindowImplWin32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
#include <PCM/Trace.h>

// OpenGL includes
#include <GL/glew.h>
#include <GL/wglew.h>
#include <GL/gl.h>
#include <PCM/glext/wglext.h>

// Other includes
#include <iostream>
Expand All @@ -21,6 +21,9 @@ const char* ClsName = "OpenGLPWM";
#define MAPVK_VK_TO_VSC (0)
#endif

#define WGL_CONTEXT_MAJOR_VERSION_ARB 0x2091
#define WGL_CONTEXT_MINOR_VERSION_ARB 0x2092

WindowImplWin32::WindowImplWin32(const WindowMode& mode,
const std::string& name, const OpenGLContextSettings& settings) :
m_Handle(NULL), m_hInstance(NULL), m_DeviceContext(NULL),
Expand Down Expand Up @@ -188,23 +191,20 @@ WindowImplWin32::WindowImplWin32(const WindowMode& mode,
"Can't Activate The temporary GL Rendering Context.");
}

//FIXME: Retrait de la dependance GLEW
GLenum err = glewInit();
if (GLEW_OK != err)
{
throw new CException("Impossible to initialize GLEW.");
}

TRACE("WindowImplWin32::WindowImplWin32 : OpenGL context Creation : " << settings.MajorVersion << "." << settings.MinorVersion);

// Spec : http://www.opengl.org/registry/specs/ARB/wgl_create_context.txt
int attribs[] =
{ WGL_CONTEXT_MAJOR_VERSION_ARB, settings.MajorVersion,
WGL_CONTEXT_MINOR_VERSION_ARB, settings.MinorVersion,
WGL_CONTEXT_FLAGS_ARB, WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB, 0 };
WGL_CONTEXT_MINOR_VERSION_ARB, settings.MinorVersion,
//WGL_CONTEXT_FLAGS_ARB, WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB,
0
};

if (wglewIsSupported("WGL_ARB_create_context") == 1)
PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribsARB = reinterpret_cast<PFNWGLCREATECONTEXTATTRIBSARBPROC>(wglGetProcAddress("wglCreateContextAttribsARB"));
if (wglCreateContextAttribsARB != 0)
{
m_OpenGLContext = wglCreateContextAttribsARB(m_DeviceContext, 0,
attribs);
m_OpenGLContext = wglCreateContextAttribsARB(m_DeviceContext, 0, attribs);
wglMakeCurrent(NULL, NULL);
wglDeleteContext(tempContext);
wglMakeCurrent(m_DeviceContext, m_OpenGLContext);
Expand Down Expand Up @@ -507,7 +507,7 @@ void WindowImplWin32::ProcessEvent(UINT message, WPARAM wParam, LPARAM lParam)
PushEvent(event);
break;
}

// TODO: Voir si on ajoute cette fonction ...
// // Mouse X button down event
// case WM_XBUTTONDOWN :
// {
Expand Down
Loading

0 comments on commit 9afb783

Please sign in to comment.