mirror of https://github.com/PCSX2/pcsx2.git
gsdx-ogl-wnd:
* implement GSWndEGL copy/pasted from zzogl. * remove linux debugging shader that failed to compile on window * add additional debug message during context creation git-svn-id: http://pcsx2.googlecode.com/svn/branches/gsdx-ogl-wnd@5520 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
parent
c4dfd0c7c5
commit
36f8dda3fe
|
@ -106,6 +106,7 @@ set(GSdxSources
|
|||
GSVertexTrace.cpp
|
||||
GSWnd.cpp
|
||||
GSWndOGL.cpp
|
||||
GSWndEGL.cpp
|
||||
GSdx.cpp
|
||||
stdafx.cpp
|
||||
)
|
||||
|
@ -168,6 +169,7 @@ set(GSdxHeaders
|
|||
GSVertexTrace.h
|
||||
GSWnd.h
|
||||
GSWndOGL.h
|
||||
GSWndEGL.h
|
||||
GSdx.h
|
||||
stdafx.h
|
||||
xbyak/xbyak.h
|
||||
|
|
|
@ -21,6 +21,12 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#ifdef _LINUX
|
||||
#include <GL/glx.h>
|
||||
#include <EGL/egl.h>
|
||||
#include <EGL/eglext.h>
|
||||
#endif
|
||||
|
||||
#ifdef _WINDOWS
|
||||
#define GL_LOADFN(name) { \
|
||||
if( (*(void**)&name = (void*)wglGetProcAddress(#name)) == NULL ) { \
|
||||
|
@ -28,11 +34,19 @@
|
|||
} \
|
||||
}
|
||||
#else
|
||||
#ifdef EGL_API
|
||||
#define GL_LOADFN(name) { \
|
||||
if( (*(void**)&name = (void*)glXGetProcAddress((const GLubyte*)#name)) == NULL ) { \
|
||||
fprintf(stderr,"Failed to find %s\n", #name); \
|
||||
} \
|
||||
if( (*(void**)&name = (void*)eglGetProcAddress(#name)) == NULL ) { \
|
||||
fprintf(stderr,"Failed to find %s\n", #name); \
|
||||
} \
|
||||
}
|
||||
#else
|
||||
#define GL_LOADFN(name) { \
|
||||
if( (*(void**)&name = (void*)glXGetProcAddress((const GLubyte*)#name)) == NULL ) { \
|
||||
fprintf(stderr,"Failed to find %s\n", #name); \
|
||||
} \
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// Those are provided on gl.h on linux...
|
||||
|
|
|
@ -44,6 +44,7 @@ static HRESULT s_hr = E_FAIL;
|
|||
#else
|
||||
|
||||
#include "GSWndOGL.h"
|
||||
#include "GSWndEGL.h"
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include <gdk/gdkx.h>
|
||||
|
@ -279,7 +280,11 @@ static int _GSopen(void** dsp, char* title, int renderer, int threads = -1)
|
|||
else
|
||||
s_gs->m_wnd = new GSWndDX();
|
||||
#else
|
||||
#ifdef EGL_API
|
||||
s_gs->m_wnd = new GSWndEGL();
|
||||
#else
|
||||
s_gs->m_wnd = new GSWndOGL();
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
|
|
@ -61,11 +61,13 @@ void GSDeviceOGL::CreateTextureFX()
|
|||
m_vb = new GSVertexBufferStateOGL(sizeof(GSVertex), vert_format, countof(vert_format));
|
||||
|
||||
// Compile some dummy shaders to allow modification inside Apitrace for debug
|
||||
#ifdef _LINUX
|
||||
GLuint dummy;
|
||||
std::string macro = "";
|
||||
std::string macro = "\n";
|
||||
CompileShaderFromSource("tfx.glsl", "vs_main", GL_VERTEX_SHADER, &dummy, macro);
|
||||
CompileShaderFromSource("tfx.glsl", "gs_main", GL_GEOMETRY_SHADER, &dummy, macro);
|
||||
CompileShaderFromSource("tfx.glsl", "ps_main", GL_FRAGMENT_SHADER, &dummy, macro);
|
||||
#endif
|
||||
}
|
||||
|
||||
void GSDeviceOGL::SetupVS(VSSelector sel, const VSConstantBuffer* cb)
|
||||
|
|
|
@ -0,0 +1,299 @@
|
|||
/*
|
||||
* Copyright (C) 2007-2012 Gabest
|
||||
* http://www.gabest.org
|
||||
*
|
||||
* This Program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This Program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GNU Make; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA USA.
|
||||
* http://www.gnu.org/copyleft/gpl.html
|
||||
*
|
||||
*/
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "GSWndEGL.h"
|
||||
|
||||
// Need at least MESA 9.0 (plan for october/november 2012)
|
||||
// So force the destiny to at least check the compilation
|
||||
#ifndef EGL_KHR_create_context
|
||||
#define EGL_KHR_create_context 1
|
||||
#define EGL_CONTEXT_MAJOR_VERSION_KHR EGL_CONTEXT_CLIENT_VERSION
|
||||
#define EGL_CONTEXT_MINOR_VERSION_KHR 0x30FB
|
||||
#define EGL_CONTEXT_FLAGS_KHR 0x30FC
|
||||
#define EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR 0x30FD
|
||||
#define EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR 0x31BD
|
||||
#define EGL_NO_RESET_NOTIFICATION_KHR 0x31BE
|
||||
#define EGL_LOSE_CONTEXT_ON_RESET_KHR 0x31BF
|
||||
#define EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR 0x00000001
|
||||
#define EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR 0x00000002
|
||||
#define EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR 0x00000004
|
||||
#define EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR 0x00000001
|
||||
#define EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR 0x00000002
|
||||
#endif
|
||||
|
||||
#ifdef _LINUX
|
||||
GSWndEGL::GSWndEGL()
|
||||
: m_NativeWindow(0), m_NativeDisplay(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
bool GSWndEGL::CreateContext(int major, int minor)
|
||||
{
|
||||
EGLConfig eglConfig;
|
||||
EGLint numConfigs;
|
||||
EGLint contextAttribs[] =
|
||||
{
|
||||
EGL_CONTEXT_MAJOR_VERSION_KHR, major,
|
||||
EGL_CONTEXT_MINOR_VERSION_KHR, minor,
|
||||
// Keep compatibility for old cruft
|
||||
EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR, EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR,
|
||||
//EGL_CONTEXT_FLAGS_KHR, EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR | EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR,
|
||||
// FIXME : Request a debug context to ease opengl development
|
||||
#if defined(ZEROGS_DEVBUILD) || defined(_DEBUG)
|
||||
EGL_CONTEXT_FLAGS_KHR, EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR,
|
||||
#endif
|
||||
EGL_NONE
|
||||
};
|
||||
EGLint attrList[] = {
|
||||
EGL_RED_SIZE, 8,
|
||||
EGL_GREEN_SIZE, 8,
|
||||
EGL_BLUE_SIZE, 8,
|
||||
EGL_DEPTH_SIZE, 24,
|
||||
EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT,
|
||||
EGL_NONE
|
||||
};
|
||||
|
||||
eglBindAPI(EGL_OPENGL_API);
|
||||
|
||||
if ( !eglChooseConfig(m_eglDisplay, attrList, &eglConfig, 1, &numConfigs) )
|
||||
{
|
||||
fprintf(stderr,"EGL: Failed to get a frame buffer config!");
|
||||
return EGL_FALSE;
|
||||
}
|
||||
|
||||
m_eglSurface = eglCreateWindowSurface(m_eglDisplay, eglConfig, m_NativeWindow, NULL);
|
||||
if ( m_eglSurface == EGL_NO_SURFACE )
|
||||
{
|
||||
fprintf(stderr,"EGL: Failed to get a window surface");
|
||||
return EGL_FALSE;
|
||||
}
|
||||
|
||||
m_eglContext = eglCreateContext(m_eglDisplay, eglConfig, EGL_NO_CONTEXT, contextAttribs );
|
||||
if ( m_eglContext == EGL_NO_CONTEXT )
|
||||
{
|
||||
fprintf(stderr,"EGL: Failed to create the context");
|
||||
fprintf(stderr,"EGL STATUS: %x", eglGetError());
|
||||
return EGL_FALSE;
|
||||
}
|
||||
|
||||
if ( !eglMakeCurrent(m_eglDisplay, m_eglSurface, m_eglSurface, m_eglContext) )
|
||||
{
|
||||
return EGL_FALSE;
|
||||
}
|
||||
|
||||
return EGL_TRUE;
|
||||
}
|
||||
|
||||
void GSWndEGL::AttachContext()
|
||||
{
|
||||
if (!IsContextAttached()) {
|
||||
//fprintf(stderr, "Attach the context\n");
|
||||
eglMakeCurrent(m_eglDisplay, m_eglSurface, m_eglSurface, m_eglContext);
|
||||
m_ctx_attached = true;
|
||||
}
|
||||
}
|
||||
|
||||
void GSWndEGL::DetachContext()
|
||||
{
|
||||
if (IsContextAttached()) {
|
||||
//fprintf(stderr, "Detach the context\n");
|
||||
eglMakeCurrent(m_eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
|
||||
m_ctx_attached = false;
|
||||
}
|
||||
}
|
||||
|
||||
void GSWndEGL::CheckContext()
|
||||
{
|
||||
fprintf(stderr,"EGL: %s : %s", eglQueryString(m_eglDisplay, EGL_VENDOR) , eglQueryString(m_eglDisplay, EGL_VERSION) );
|
||||
fprintf(stderr,"EGL: extensions supported: %s", eglQueryString(m_eglDisplay, EGL_EXTENSIONS));
|
||||
}
|
||||
|
||||
bool GSWndEGL::Attach(void* handle, bool managed)
|
||||
{
|
||||
m_NativeWindow = *(Window*)handle;
|
||||
m_managed = managed;
|
||||
|
||||
m_NativeDisplay = XOpenDisplay(NULL);
|
||||
if (!OpenEGLDisplay()) return false;
|
||||
|
||||
// Note: 4.2 crash on latest nvidia drivers!
|
||||
if (!CreateContext(3, 3)) return false;
|
||||
|
||||
AttachContext();
|
||||
|
||||
CheckContext();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void GSWndEGL::Detach()
|
||||
{
|
||||
// Actually the destructor is not called when there is only a GSclose/GSshutdown
|
||||
// The window still need to be closed
|
||||
DetachContext();
|
||||
CloseEGLDisplay();
|
||||
|
||||
if (m_NativeDisplay) {
|
||||
XCloseDisplay(m_NativeDisplay);
|
||||
m_NativeDisplay = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
bool GSWndEGL::Create(const string& title, int w, int h)
|
||||
{
|
||||
if(m_NativeWindow) return false;
|
||||
|
||||
if(w <= 0 || h <= 0) {
|
||||
w = theApp.GetConfig("ModeWidth", 640);
|
||||
h = theApp.GetConfig("ModeHeight", 480);
|
||||
}
|
||||
|
||||
m_managed = true;
|
||||
|
||||
// note this part must be only executed when replaying .gs debug file
|
||||
m_NativeDisplay = XOpenDisplay(NULL);
|
||||
|
||||
int attrListDbl[] = { GLX_RGBA, GLX_DOUBLEBUFFER,
|
||||
GLX_RED_SIZE, 8,
|
||||
GLX_GREEN_SIZE, 8,
|
||||
GLX_BLUE_SIZE, 8,
|
||||
GLX_DEPTH_SIZE, 24,
|
||||
None
|
||||
};
|
||||
XVisualInfo* vi = glXChooseVisual(m_NativeDisplay, DefaultScreen(m_NativeDisplay), attrListDbl);
|
||||
|
||||
/* create a color map */
|
||||
XSetWindowAttributes attr;
|
||||
attr.colormap = XCreateColormap(m_NativeDisplay, RootWindow(m_NativeDisplay, vi->screen),
|
||||
vi->visual, AllocNone);
|
||||
attr.border_pixel = 0;
|
||||
attr.event_mask = ExposureMask | KeyPressMask | KeyReleaseMask | ButtonPressMask |
|
||||
StructureNotifyMask | SubstructureRedirectMask | SubstructureNotifyMask |
|
||||
EnterWindowMask | LeaveWindowMask | FocusChangeMask ;
|
||||
|
||||
// Create a window at the last position/size
|
||||
m_NativeWindow = XCreateWindow(m_NativeDisplay, RootWindow(m_NativeDisplay, vi->screen),
|
||||
0 , 0 , w, h, 0, vi->depth, InputOutput, vi->visual,
|
||||
CWBorderPixel | CWColormap | CWEventMask, &attr);
|
||||
|
||||
XMapWindow (m_NativeDisplay, m_NativeWindow);
|
||||
XFree(vi);
|
||||
|
||||
if (!CreateContext(3, 3)) return false;
|
||||
|
||||
AttachContext();
|
||||
|
||||
return (m_NativeWindow != 0);
|
||||
}
|
||||
|
||||
void* GSWndEGL::GetDisplay()
|
||||
{
|
||||
// note this part must be only executed when replaying .gs debug file
|
||||
return (void*)m_NativeDisplay;
|
||||
}
|
||||
|
||||
GSVector4i GSWndEGL::GetClientRect()
|
||||
{
|
||||
unsigned int h = 480;
|
||||
unsigned int w = 640;
|
||||
|
||||
unsigned int borderDummy;
|
||||
unsigned int depthDummy;
|
||||
Window winDummy;
|
||||
int xDummy;
|
||||
int yDummy;
|
||||
|
||||
if (!m_NativeDisplay) m_NativeDisplay = XOpenDisplay(NULL);
|
||||
XGetGeometry(m_NativeDisplay, m_NativeWindow, &winDummy, &xDummy, &yDummy, &w, &h, &borderDummy, &depthDummy);
|
||||
|
||||
return GSVector4i(0, 0, (int)w, (int)h);
|
||||
}
|
||||
|
||||
// Returns FALSE if the window has no title, or if th window title is under the strict
|
||||
// management of the emulator.
|
||||
|
||||
bool GSWndEGL::SetWindowText(const char* title)
|
||||
{
|
||||
if (!m_managed) return true;
|
||||
|
||||
XTextProperty prop;
|
||||
|
||||
memset(&prop, 0, sizeof(prop));
|
||||
|
||||
char* ptitle = (char*)title;
|
||||
if (XStringListToTextProperty(&ptitle, 1, &prop)) {
|
||||
XSetWMName(m_NativeDisplay, m_NativeWindow, &prop);
|
||||
}
|
||||
|
||||
XFree(prop.value);
|
||||
XFlush(m_NativeDisplay);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void GSWndEGL::SetVSync(bool enable)
|
||||
{
|
||||
// 0 -> disable vsync
|
||||
// n -> wait n frame
|
||||
eglSwapInterval(m_eglDisplay, enable);
|
||||
}
|
||||
|
||||
void GSWndEGL::Flip()
|
||||
{
|
||||
eglSwapBuffers(m_eglDisplay, m_eglSurface);
|
||||
}
|
||||
|
||||
void GSWndEGL::Show()
|
||||
{
|
||||
XMapRaised(m_NativeDisplay, m_NativeWindow);
|
||||
XFlush(m_NativeDisplay);
|
||||
}
|
||||
|
||||
void GSWndEGL::Hide()
|
||||
{
|
||||
XUnmapWindow(m_NativeDisplay, m_NativeWindow);
|
||||
XFlush(m_NativeDisplay);
|
||||
}
|
||||
|
||||
void GSWndEGL::HideFrame()
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
void GSWndEGL::CloseEGLDisplay()
|
||||
{
|
||||
eglTerminate(m_eglDisplay);
|
||||
}
|
||||
|
||||
EGLBoolean GSWndEGL::OpenEGLDisplay()
|
||||
{
|
||||
// Create an EGL display from the native display
|
||||
m_eglDisplay = eglGetDisplay((EGLNativeDisplayType)m_NativeDisplay);
|
||||
if ( m_eglDisplay == EGL_NO_DISPLAY ) return EGL_FALSE;
|
||||
|
||||
if ( !eglInitialize(m_eglDisplay, NULL, NULL) ) return EGL_FALSE;
|
||||
|
||||
return EGL_TRUE;
|
||||
}
|
||||
|
||||
|
||||
#endif
|
|
@ -0,0 +1,70 @@
|
|||
/*
|
||||
* Copyright (C) 2007-2012 Gabest
|
||||
* http://www.gabest.org
|
||||
*
|
||||
* This Program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This Program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GNU Make; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA USA.
|
||||
* http://www.gnu.org/copyleft/gpl.html
|
||||
*
|
||||
*/
|
||||
|
||||
#include "GSWnd.h"
|
||||
|
||||
#ifdef _LINUX
|
||||
#include <X11/Xlib.h>
|
||||
#include <EGL/egl.h>
|
||||
#include <EGL/eglext.h>
|
||||
|
||||
class GSWndEGL : public GSWnd
|
||||
{
|
||||
EGLNativeWindowType m_NativeWindow;
|
||||
EGLNativeDisplayType m_NativeDisplay;
|
||||
|
||||
EGLDisplay m_eglDisplay;
|
||||
EGLSurface m_eglSurface;
|
||||
EGLContext m_eglContext;
|
||||
|
||||
bool m_ctx_attached;
|
||||
|
||||
bool IsContextAttached() const { return m_ctx_attached; }
|
||||
bool CreateContext(int major, int minor);
|
||||
void CheckContext();
|
||||
|
||||
EGLBoolean OpenEGLDisplay();
|
||||
void CloseEGLDisplay();
|
||||
|
||||
public:
|
||||
GSWndEGL();
|
||||
virtual ~GSWndEGL() {};
|
||||
|
||||
bool Create(const string& title, int w, int h);
|
||||
bool Attach(void* handle, bool managed = true);
|
||||
void Detach();
|
||||
|
||||
void* GetDisplay();
|
||||
void* GetHandle() {return (void*)m_NativeWindow;}
|
||||
GSVector4i GetClientRect();
|
||||
bool SetWindowText(const char* title);
|
||||
|
||||
void AttachContext();
|
||||
void DetachContext();
|
||||
|
||||
void Show();
|
||||
void Hide();
|
||||
void HideFrame();
|
||||
void Flip();
|
||||
void SetVSync(bool enable);
|
||||
};
|
||||
|
||||
#endif
|
|
@ -23,6 +23,7 @@
|
|||
|
||||
#ifdef _LINUX
|
||||
#include <X11/Xlib.h>
|
||||
#include <GL/glx.h>
|
||||
|
||||
class GSWndOGL : public GSWnd
|
||||
{
|
||||
|
|
|
@ -29,7 +29,6 @@ GSWndWGL::GSWndWGL()
|
|||
{
|
||||
}
|
||||
|
||||
//TODO: GL3 context
|
||||
bool GSWndWGL::CreateContext(int major, int minor)
|
||||
{
|
||||
if ( !m_NativeDisplay || !m_NativeWindow )
|
||||
|
@ -39,7 +38,10 @@ bool GSWndWGL::CreateContext(int major, int minor)
|
|||
}
|
||||
|
||||
// GL2 context are quite easy but we need GL3 which is another painful story...
|
||||
if (!(m_context = wglCreateContext(m_NativeDisplay))) return false;
|
||||
if (!(m_context = wglCreateContext(m_NativeDisplay))) {
|
||||
fprinf(stderr, "Failed to create a 2.0 context\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
// FIXME test it
|
||||
// Note: albeit every tutorial said that we need an opengl context to use the GL function wglCreateContextAttribsARB
|
||||
|
@ -60,10 +62,16 @@ bool GSWndWGL::CreateContext(int major, int minor)
|
|||
};
|
||||
|
||||
PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribsARB = (PFNWGLCREATECONTEXTATTRIBSARBPROC)wglGetProcAddress("wglCreateContextAttribsARB");
|
||||
if (!wglCreateContextAttribsARB) return false;
|
||||
if (!wglCreateContextAttribsARB) {
|
||||
fprinf(stderr, "Failed to init wglCreateContextAttribsARB function pointer\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
HGLRC context30 = wglCreateContextAttribsARB(m_NativeDisplay, NULL, context_attribs);
|
||||
if (!context30) return false;
|
||||
if (!context30) {
|
||||
fprinf(stderr, "Failed to create a 3.x context\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
DetachContext();
|
||||
wglDeleteContext(m_context);
|
||||
|
@ -72,48 +80,6 @@ bool GSWndWGL::CreateContext(int major, int minor)
|
|||
fprintf(stderr, "3.x GL context successfully created\n");
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
||||
|
||||
// Get visual information
|
||||
static int attrListDbl[] =
|
||||
{
|
||||
// GLX_X_RENDERABLE: If True is specified, then only frame buffer configurations that have associated X
|
||||
// visuals (and can be used to render to Windows and/or GLX pixmaps) will be considered. The default value is GLX_DONT_CARE.
|
||||
GLX_X_RENDERABLE , True,
|
||||
GLX_RED_SIZE , 8,
|
||||
GLX_GREEN_SIZE , 8,
|
||||
GLX_BLUE_SIZE , 8,
|
||||
GLX_DEPTH_SIZE , 24,
|
||||
GLX_DOUBLEBUFFER , True,
|
||||
None
|
||||
};
|
||||
|
||||
PFNGLXCHOOSEFBCONFIGPROC glXChooseFBConfig = (PFNGLXCHOOSEFBCONFIGPROC) glXGetProcAddress((GLubyte *) "glXChooseFBConfig");
|
||||
int fbcount = 0;
|
||||
GLXFBConfig *fbc = glXChooseFBConfig(m_NativeDisplay, DefaultScreen(m_NativeDisplay), attrListDbl, &fbcount);
|
||||
if (!fbc || fbcount < 1) return false;
|
||||
|
||||
PFNGLXCREATECONTEXTATTRIBSARBPROC glXCreateContextAttribsARB = (PFNGLXCREATECONTEXTATTRIBSARBPROC)glXGetProcAddress((const GLubyte*) "glXCreateContextAttribsARB");
|
||||
if (!glXCreateContextAttribsARB) return false;
|
||||
|
||||
// Create a context
|
||||
int context_attribs[] =
|
||||
{
|
||||
GLX_CONTEXT_MAJOR_VERSION_ARB, major,
|
||||
GLX_CONTEXT_MINOR_VERSION_ARB, minor,
|
||||
// FIXME : Request a debug context to ease opengl development
|
||||
// Note: don't support deprecated feature (pre openg 3.1)
|
||||
//GLX_CONTEXT_FLAGS_ARB, GLX_CONTEXT_DEBUG_BIT_ARB | GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB,
|
||||
GLX_CONTEXT_FLAGS_ARB, GLX_CONTEXT_DEBUG_BIT_ARB,
|
||||
None
|
||||
};
|
||||
|
||||
m_context = glXCreateContextAttribsARB(m_NativeDisplay, fbc[0], 0, true, context_attribs);
|
||||
if (!m_context) return false;
|
||||
|
||||
XSync( m_NativeDisplay, false);
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -153,8 +119,6 @@ bool GSWndWGL::Attach(void* handle, bool managed)
|
|||
|
||||
if (!OpenWGLDisplay()) return false;
|
||||
|
||||
// FIXME: debug purpose
|
||||
//if (!CreateContext(2, 0)) return false;
|
||||
if (!CreateContext(3, 3)) return false;
|
||||
|
||||
AttachContext();
|
||||
|
@ -178,6 +142,7 @@ void GSWndWGL::Detach()
|
|||
DetachContext();
|
||||
|
||||
if (m_context) wglDeleteContext(m_context);
|
||||
m_context = NULL;
|
||||
|
||||
CloseWGLDisplay();
|
||||
}
|
||||
|
@ -234,8 +199,8 @@ void GSWndWGL::CloseWGLDisplay()
|
|||
if (m_NativeDisplay && !ReleaseDC(m_NativeWindow, m_NativeDisplay)) // Are We Able To Release The DC
|
||||
{
|
||||
MessageBox(NULL, "Release Device Context Failed.", "SHUTDOWN ERROR", MB_OK | MB_ICONINFORMATION);
|
||||
m_NativeDisplay = NULL; // Set DC To NULL
|
||||
}
|
||||
m_NativeDisplay = NULL; // Set DC To NULL
|
||||
}
|
||||
|
||||
//TODO: GSopen 1 => Drop?
|
||||
|
|
|
@ -208,7 +208,6 @@ using namespace std;
|
|||
//#include <ext/hash_set>
|
||||
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glx.h>
|
||||
#include <GL/glext.h>
|
||||
#include "GLLoader.h"
|
||||
|
||||
|
|
Loading…
Reference in New Issue