mirror of https://github.com/PCSX2/pcsx2.git
gsdx-ogl-wnd: * add a preliminary context and wgl management
Note: don't expect to compile/work yet git-svn-id: http://pcsx2.googlecode.com/svn/branches/gsdx-ogl-wnd@5502 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
parent
d91b28ac32
commit
5e4bae5f5d
|
@ -33,6 +33,7 @@
|
|||
#include "GSDevice9.h"
|
||||
#include "GSDevice11.h"
|
||||
#include "GSWndDX.h"
|
||||
#include "GSWndWGL.h"
|
||||
#include "GSRendererCS.h"
|
||||
#include "GSSettingsDlg.h"
|
||||
|
||||
|
@ -270,15 +271,14 @@ static int _GSopen(void** dsp, char* title, int renderer, int threads = -1)
|
|||
|
||||
if (s_gs->m_wnd == NULL)
|
||||
{
|
||||
switch(renderer / 3)
|
||||
{
|
||||
default:
|
||||
#ifdef _WINDOWS
|
||||
s_gs->m_wnd = new GSWndDX(); break;
|
||||
#else
|
||||
case 4: s_gs->m_wnd = new GSWndOGL(); break;
|
||||
#endif
|
||||
}
|
||||
#ifdef _WINDOWS
|
||||
if (renderer / 3 == 4)
|
||||
s_gs->m_wnd = new GSWndWGL();
|
||||
else
|
||||
s_gs->m_wnd = new GSWndDX();
|
||||
#else
|
||||
s_gs->m_wnd = new GSWndOGL();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
catch(std::exception& ex)
|
||||
|
|
|
@ -23,13 +23,13 @@
|
|||
|
||||
#ifdef _LINUX
|
||||
GSWndOGL::GSWndOGL()
|
||||
: m_window(NULL), m_Xwindow(0), m_XDisplay(NULL), m_swapinterval(NULL)
|
||||
: m_NativeWindow(0), m_NativeDisplay(NULL), m_swapinterval(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
bool GSWndOGL::CreateContext(int major, int minor)
|
||||
{
|
||||
if ( !m_XDisplay || !m_Xwindow )
|
||||
if ( !m_NativeDisplay || !m_NativeWindow )
|
||||
{
|
||||
fprintf( stderr, "Wrong X11 display/window\n" );
|
||||
exit(1);
|
||||
|
@ -51,7 +51,7 @@ bool GSWndOGL::CreateContext(int major, int minor)
|
|||
|
||||
PFNGLXCHOOSEFBCONFIGPROC glXChooseFBConfig = (PFNGLXCHOOSEFBCONFIGPROC) glXGetProcAddress((GLubyte *) "glXChooseFBConfig");
|
||||
int fbcount = 0;
|
||||
GLXFBConfig *fbc = glXChooseFBConfig(m_XDisplay, DefaultScreen(m_XDisplay), attrListDbl, &fbcount);
|
||||
GLXFBConfig *fbc = glXChooseFBConfig(m_NativeDisplay, DefaultScreen(m_NativeDisplay), attrListDbl, &fbcount);
|
||||
if (!fbc || fbcount < 1) return false;
|
||||
|
||||
PFNGLXCREATECONTEXTATTRIBSARBPROC glXCreateContextAttribsARB = (PFNGLXCREATECONTEXTATTRIBSARBPROC)glXGetProcAddress((const GLubyte*) "glXCreateContextAttribsARB");
|
||||
|
@ -69,10 +69,10 @@ bool GSWndOGL::CreateContext(int major, int minor)
|
|||
None
|
||||
};
|
||||
|
||||
m_context = glXCreateContextAttribsARB(m_XDisplay, fbc[0], 0, true, context_attribs);
|
||||
m_context = glXCreateContextAttribsARB(m_NativeDisplay, fbc[0], 0, true, context_attribs);
|
||||
if (!m_context) return false;
|
||||
|
||||
XSync( m_XDisplay, false);
|
||||
XSync( m_NativeDisplay, false);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -80,7 +80,7 @@ void GSWndOGL::AttachContext()
|
|||
{
|
||||
if (!IsContextAttached()) {
|
||||
//fprintf(stderr, "Attach the context\n");
|
||||
glXMakeCurrent(m_XDisplay, m_Xwindow, m_context);
|
||||
glXMakeCurrent(m_NativeDisplay, m_NativeWindow, m_context);
|
||||
m_ctx_attached = true;
|
||||
}
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ void GSWndOGL::DetachContext()
|
|||
{
|
||||
if (IsContextAttached()) {
|
||||
//fprintf(stderr, "Detach the context\n");
|
||||
glXMakeCurrent(m_XDisplay, None, NULL);
|
||||
glXMakeCurrent(m_NativeDisplay, None, NULL);
|
||||
m_ctx_attached = false;
|
||||
}
|
||||
}
|
||||
|
@ -97,8 +97,8 @@ void GSWndOGL::DetachContext()
|
|||
void GSWndOGL::CheckContext()
|
||||
{
|
||||
int glxMajorVersion, glxMinorVersion;
|
||||
glXQueryVersion(m_XDisplay, &glxMajorVersion, &glxMinorVersion);
|
||||
if (glXIsDirect(m_XDisplay, m_context))
|
||||
glXQueryVersion(m_NativeDisplay, &glxMajorVersion, &glxMinorVersion);
|
||||
if (glXIsDirect(m_NativeDisplay, m_context))
|
||||
fprintf(stderr, "glX-Version %d.%d with Direct Rendering\n", glxMajorVersion, glxMinorVersion);
|
||||
else
|
||||
fprintf(stderr, "glX-Version %d.%d with Indirect Rendering !!! It won't support properly opengl\n", glxMajorVersion, glxMinorVersion);
|
||||
|
@ -106,10 +106,10 @@ void GSWndOGL::CheckContext()
|
|||
|
||||
bool GSWndOGL::Attach(void* handle, bool managed)
|
||||
{
|
||||
m_Xwindow = *(Window*)handle;
|
||||
m_NativeWindow = *(Window*)handle;
|
||||
m_managed = managed;
|
||||
|
||||
m_XDisplay = XOpenDisplay(NULL);
|
||||
m_NativeDisplay = XOpenDisplay(NULL);
|
||||
|
||||
// Note: 4.2 crash on latest nvidia drivers!
|
||||
if (!CreateContext(3, 3)) return false;
|
||||
|
@ -130,17 +130,17 @@ void GSWndOGL::Detach()
|
|||
// Actually the destructor is not called when there is only a GSclose/GSshutdown
|
||||
// The window still need to be closed
|
||||
DetachContext();
|
||||
if (m_context) glXDestroyContext(m_XDisplay, m_context);
|
||||
if (m_context) glXDestroyContext(m_NativeDisplay, m_context);
|
||||
|
||||
if (m_XDisplay) {
|
||||
XCloseDisplay(m_XDisplay);
|
||||
m_XDisplay = NULL;
|
||||
if (m_NativeDisplay) {
|
||||
XCloseDisplay(m_NativeDisplay);
|
||||
m_NativeDisplay = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
bool GSWndOGL::Create(const string& title, int w, int h)
|
||||
{
|
||||
if(m_window != NULL) return false;
|
||||
if(m_NativeWindow) return false;
|
||||
|
||||
if(w <= 0 || h <= 0) {
|
||||
w = theApp.GetConfig("ModeWidth", 640);
|
||||
|
@ -150,7 +150,7 @@ bool GSWndOGL::Create(const string& title, int w, int h)
|
|||
m_managed = true;
|
||||
|
||||
// note this part must be only executed when replaying .gs debug file
|
||||
m_XDisplay = XOpenDisplay(NULL);
|
||||
m_NativeDisplay = XOpenDisplay(NULL);
|
||||
|
||||
int attrListDbl[] = { GLX_RGBA, GLX_DOUBLEBUFFER,
|
||||
GLX_RED_SIZE, 8,
|
||||
|
@ -159,11 +159,11 @@ bool GSWndOGL::Create(const string& title, int w, int h)
|
|||
GLX_DEPTH_SIZE, 24,
|
||||
None
|
||||
};
|
||||
XVisualInfo* vi = glXChooseVisual(m_XDisplay, DefaultScreen(m_XDisplay), attrListDbl);
|
||||
XVisualInfo* vi = glXChooseVisual(m_NativeDisplay, DefaultScreen(m_NativeDisplay), attrListDbl);
|
||||
|
||||
/* create a color map */
|
||||
XSetWindowAttributes attr;
|
||||
attr.colormap = XCreateColormap(m_XDisplay, RootWindow(m_XDisplay, vi->screen),
|
||||
attr.colormap = XCreateColormap(m_NativeDisplay, RootWindow(m_NativeDisplay, vi->screen),
|
||||
vi->visual, AllocNone);
|
||||
attr.border_pixel = 0;
|
||||
attr.event_mask = ExposureMask | KeyPressMask | KeyReleaseMask | ButtonPressMask |
|
||||
|
@ -171,24 +171,24 @@ bool GSWndOGL::Create(const string& title, int w, int h)
|
|||
EnterWindowMask | LeaveWindowMask | FocusChangeMask ;
|
||||
|
||||
// Create a window at the last position/size
|
||||
m_Xwindow = XCreateWindow(m_XDisplay, RootWindow(m_XDisplay, vi->screen),
|
||||
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_XDisplay, m_Xwindow);
|
||||
XMapWindow (m_NativeDisplay, m_NativeWindow);
|
||||
XFree(vi);
|
||||
|
||||
if (!CreateContext(3, 3)) return false;
|
||||
|
||||
AttachContext();
|
||||
|
||||
return (m_Xwindow != 0);
|
||||
return (m_NativeWindow != 0);
|
||||
}
|
||||
|
||||
void* GSWndOGL::GetDisplay()
|
||||
{
|
||||
// note this part must be only executed when replaying .gs debug file
|
||||
return (void*)m_XDisplay;
|
||||
return (void*)m_NativeDisplay;
|
||||
}
|
||||
|
||||
GSVector4i GSWndOGL::GetClientRect()
|
||||
|
@ -202,8 +202,8 @@ GSVector4i GSWndOGL::GetClientRect()
|
|||
int xDummy;
|
||||
int yDummy;
|
||||
|
||||
if (!m_XDisplay) m_XDisplay = XOpenDisplay(NULL);
|
||||
XGetGeometry(m_XDisplay, m_Xwindow, &winDummy, &xDummy, &yDummy, &w, &h, &borderDummy, &depthDummy);
|
||||
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);
|
||||
}
|
||||
|
@ -221,11 +221,11 @@ bool GSWndOGL::SetWindowText(const char* title)
|
|||
|
||||
char* ptitle = (char*)title;
|
||||
if (XStringListToTextProperty(&ptitle, 1, &prop)) {
|
||||
XSetWMName(m_XDisplay, m_Xwindow, &prop);
|
||||
XSetWMName(m_NativeDisplay, m_NativeWindow, &prop);
|
||||
}
|
||||
|
||||
XFree(prop.value);
|
||||
XFlush(m_XDisplay);
|
||||
XFlush(m_NativeDisplay);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -240,23 +240,24 @@ void GSWndOGL::SetVSync(bool enable)
|
|||
|
||||
void GSWndOGL::Flip()
|
||||
{
|
||||
glXSwapBuffers(m_XDisplay, m_Xwindow);
|
||||
glXSwapBuffers(m_NativeDisplay, m_NativeWindow);
|
||||
}
|
||||
|
||||
void GSWndOGL::Show()
|
||||
{
|
||||
XMapRaised(m_XDisplay, m_Xwindow);
|
||||
XFlush(m_XDisplay);
|
||||
XMapRaised(m_NativeDisplay, m_NativeWindow);
|
||||
XFlush(m_NativeDisplay);
|
||||
}
|
||||
|
||||
void GSWndOGL::Hide()
|
||||
{
|
||||
XUnmapWindow(m_XDisplay, m_Xwindow);
|
||||
XFlush(m_XDisplay);
|
||||
XUnmapWindow(m_NativeDisplay, m_NativeWindow);
|
||||
XFlush(m_NativeDisplay);
|
||||
}
|
||||
|
||||
void GSWndOGL::HideFrame()
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -26,9 +26,8 @@
|
|||
|
||||
class GSWndOGL : public GSWnd
|
||||
{
|
||||
void* m_window;
|
||||
Window m_Xwindow;
|
||||
Display* m_XDisplay;
|
||||
Window m_NativeWindow;
|
||||
Display* m_NativeDisplay;
|
||||
GLXContext m_context;
|
||||
|
||||
bool m_ctx_attached;
|
||||
|
@ -48,7 +47,7 @@ public:
|
|||
void Detach();
|
||||
|
||||
void* GetDisplay();
|
||||
void* GetHandle() {return (void*)m_Xwindow;}
|
||||
void* GetHandle() {return (void*)m_NativeWindow;}
|
||||
GSVector4i GetClientRect();
|
||||
bool SetWindowText(const char* title);
|
||||
|
||||
|
@ -61,4 +60,5 @@ public:
|
|||
void Flip();
|
||||
void SetVSync(bool enable);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -0,0 +1,339 @@
|
|||
/*
|
||||
* 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 "GSWndWGL.h"
|
||||
|
||||
#ifdef _WINDOWS
|
||||
//TODO
|
||||
GSWndWGL::GSWndWGL()
|
||||
: m_NativeWindow(NULL), m_NativeDisplay(NULL), m_context(NULL)//, m_swapinterval(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
//TODO: GL3 context
|
||||
bool GSWndWGL::CreateContext(int major, int minor)
|
||||
{
|
||||
if ( !m_NativeDisplay || !m_NativeWindow )
|
||||
{
|
||||
fprintf( stderr, "Wrong display/window\n" );
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// GL2 context are quite easy but we need GL3 which is another painful story...
|
||||
if (!(m_context = wglCreateContext(m_NativeDisplay))) return false;
|
||||
|
||||
// FIXME test it
|
||||
// Note: albeit every tutorial said that we need an opengl context to use the GL function wglCreateContextAttribsARB
|
||||
// On linux it works without the extra temporary context, not sure the limitation still applied
|
||||
if (major >= 3) {
|
||||
AttachContext();
|
||||
|
||||
// Create a context
|
||||
int context_attribs[] =
|
||||
{
|
||||
WGL_CONTEXT_MAJOR_VERSION_ARB, major,
|
||||
WGL_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,
|
||||
WGL_CONTEXT_FLAGS_ARB, WGL_CONTEXT_DEBUG_BIT_ARB,
|
||||
None
|
||||
};
|
||||
|
||||
PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribsARB = (PFNWGLCREATECONTEXTATTRIBSARBPROC)wglGetProcAddress((const GLubyte*) "wglCreateContextAttribsARB");
|
||||
if (!wglCreateContextAttribsARB) return false;
|
||||
|
||||
HGLRC context30 = wglCreateContextAttribsARB(m_NativeDisplay, NULL, context_attribs);
|
||||
if (!context30) return false;
|
||||
|
||||
DetachContext();
|
||||
wglDeleteContext(m_context);
|
||||
|
||||
m_context = context30;
|
||||
}
|
||||
|
||||
#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;
|
||||
}
|
||||
|
||||
void GSWndWGL::AttachContext()
|
||||
{
|
||||
if (!IsContextAttached()) {
|
||||
wglMakeCurrent(m_NativeDisplay, m_context);
|
||||
m_ctx_attached = true;
|
||||
}
|
||||
}
|
||||
|
||||
void GSWndWGL::DetachContext()
|
||||
{
|
||||
if (IsContextAttached()) {
|
||||
wglMakeCurrent(NULL, NULL);
|
||||
m_ctx_attached = false;
|
||||
}
|
||||
}
|
||||
|
||||
//TODO: DROP ???
|
||||
void GSWndWGL::CheckContext()
|
||||
{
|
||||
#if 0
|
||||
int glxMajorVersion, glxMinorVersion;
|
||||
glXQueryVersion(m_NativeDisplay, &glxMajorVersion, &glxMinorVersion);
|
||||
if (glXIsDirect(m_NativeDisplay, m_context))
|
||||
fprintf(stderr, "glX-Version %d.%d with Direct Rendering\n", glxMajorVersion, glxMinorVersion);
|
||||
else
|
||||
fprintf(stderr, "glX-Version %d.%d with Indirect Rendering !!! It won't support properly opengl\n", glxMajorVersion, glxMinorVersion);
|
||||
#endif
|
||||
}
|
||||
|
||||
bool GSWndWGL::Attach(void* handle, bool managed)
|
||||
{
|
||||
m_NativeWindow = (HWND)handle;
|
||||
m_managed = managed;
|
||||
|
||||
if (!OpenWGLDisplay()) return false;
|
||||
|
||||
// FIXME: debug purpose
|
||||
if (!CreateContext(2, 0)) return false;
|
||||
//if (!CreateContext(3, 3)) return false;
|
||||
|
||||
AttachContext();
|
||||
|
||||
CheckContext();
|
||||
|
||||
// TODO
|
||||
//m_swapinterval = (PFNGLXSWAPINTERVALMESAPROC)glXGetProcAddress((const GLubyte*) "glXSwapIntervalMESA");
|
||||
//PFNGLXSWAPINTERVALMESAPROC m_swapinterval = (PFNGLXSWAPINTERVALMESAPROC)glXGetProcAddress((const GLubyte*) "glXSwapInterval");
|
||||
|
||||
UpdateWindow(m_NativeWindow);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//TODO
|
||||
void GSWndWGL::Detach()
|
||||
{
|
||||
// Actually the destructor is not called when there is only a GSclose/GSshutdown
|
||||
// The window still need to be closed
|
||||
DetachContext();
|
||||
|
||||
if (m_context) wglContext(m_context);
|
||||
|
||||
CloseWGLDisplay();
|
||||
}
|
||||
|
||||
bool GSWndWGL::OpenWGLDisplay()
|
||||
{
|
||||
GLuint PixelFormat; // Holds The Results After Searching For A Match
|
||||
PIXELFORMATDESCRIPTOR pfd = // pfd Tells Windows How We Want Things To Be
|
||||
|
||||
{
|
||||
sizeof(PIXELFORMATDESCRIPTOR), // Size Of This Pixel Format Descriptor
|
||||
1, // Version Number
|
||||
PFD_DRAW_TO_WINDOW | // Format Must Support Window
|
||||
PFD_SUPPORT_OPENGL | // Format Must Support OpenGL
|
||||
PFD_DOUBLEBUFFER, // Must Support Double Buffering
|
||||
PFD_TYPE_RGBA, // Request An RGBA Format
|
||||
32, // Select Our Color Depth
|
||||
0, 0, 0, 0, 0, 0, // Color Bits Ignored
|
||||
0, // 8bit Alpha Buffer
|
||||
0, // Shift Bit Ignored
|
||||
0, // No Accumulation Buffer
|
||||
0, 0, 0, 0, // Accumulation Bits Ignored
|
||||
24, // 24Bit Z-Buffer (Depth Buffer)
|
||||
8, // 8bit Stencil Buffer
|
||||
0, // No Auxiliary Buffer
|
||||
PFD_MAIN_PLANE, // Main Drawing Layer
|
||||
0, // Reserved
|
||||
0, 0, 0 // Layer Masks Ignored
|
||||
};
|
||||
|
||||
if (!(m_NativeDisplay = GetDC(m_NativeWindow)))
|
||||
{
|
||||
MessageBox(NULL, L"(1) Can't Create A GL Device Context.", L"ERROR", MB_OK | MB_ICONEXCLAMATION);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!(PixelFormat = ChoosePixelFormat(m_NativeDisplay, &pfd)))
|
||||
{
|
||||
MessageBox(NULL, L"(2) Can't Find A Suitable PixelFormat.", L"ERROR", MB_OK | MB_ICONEXCLAMATION);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!SetPixelFormat(m_NativeDisplay, PixelFormat, &pfd))
|
||||
{
|
||||
MessageBox(NULL, L"(3) Can't Set The PixelFormat.", L"ERROR", MB_OK | MB_ICONEXCLAMATION);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void GSWndWGL::CloseWGLDisplay()
|
||||
{
|
||||
if (m_NativeDisplay && !ReleaseDC(m_NativeWindow, m_NativeDisplay)) // Are We Able To Release The DC
|
||||
{
|
||||
MessageBox(NULL, L"Release Device Context Failed.", L"SHUTDOWN ERROR", MB_OK | MB_ICONINFORMATION);
|
||||
m_NativeDisplay = NULL; // Set DC To NULL
|
||||
}
|
||||
}
|
||||
|
||||
//TODO: GSopen 1 => Drop?
|
||||
bool GSWndWGL::Create(const string& title, int w, int h)
|
||||
{
|
||||
#if 0
|
||||
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);
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
//Same as DX
|
||||
GSVector4i GSWndWGL::GetClientRect()
|
||||
{
|
||||
GSVector4i r;
|
||||
|
||||
::GetClientRect(m_NativeWindow, r);
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
//TODO: check extensions supported or not
|
||||
void GSWndWGL::SetVSync(bool enable)
|
||||
{
|
||||
// m_swapinterval uses an integer as parameter
|
||||
// 0 -> disable vsync
|
||||
// n -> wait n frame
|
||||
//if (m_swapinterval) m_swapinterval((int)enable);
|
||||
wglSwapIntervalEXT(!enable);
|
||||
|
||||
}
|
||||
|
||||
void GSWndWGL::Flip()
|
||||
{
|
||||
SwapBuffers(m_NativeDisplay);
|
||||
}
|
||||
|
||||
void GSWndWGL::Show()
|
||||
{
|
||||
}
|
||||
|
||||
void GSWndWGL::Hide()
|
||||
{
|
||||
}
|
||||
|
||||
void GSWndWGL::HideFrame()
|
||||
{
|
||||
}
|
||||
|
||||
// Returns FALSE if the window has no title, or if th window title is under the strict
|
||||
// management of the emulator.
|
||||
|
||||
bool GSWndWGL::SetWindowText(const char* title)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
#endif
|
|
@ -0,0 +1,69 @@
|
|||
/*
|
||||
* 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 _WINDOWS
|
||||
|
||||
class GSWndWGL : public GSWnd
|
||||
{
|
||||
//Window m_NativeWindow;
|
||||
//Display* m_NativeDisplay;
|
||||
//GLXContext m_context;
|
||||
HWND m_NativeWindow;
|
||||
HDC m_NativeDisplay;
|
||||
HGLRC m_context;
|
||||
|
||||
bool m_ctx_attached;
|
||||
|
||||
//PFNGLXSWAPINTERVALMESAPROC m_swapinterval;
|
||||
|
||||
bool IsContextAttached() const { return m_ctx_attached; }
|
||||
bool CreateContext(int major, int minor);
|
||||
void CheckContext();
|
||||
|
||||
void CloseWGLDisplay();
|
||||
bool OpenWGLDisplay();
|
||||
|
||||
public:
|
||||
GSWndWGL();
|
||||
virtual ~GSWndWGL() {};
|
||||
|
||||
bool Create(const string& title, int w, int h);
|
||||
bool Attach(void* handle, bool managed = true);
|
||||
void Detach();
|
||||
|
||||
void* GetDisplay() {return m_NativeWindow;}
|
||||
void* GetHandle() {return 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
|
|
@ -120,10 +120,8 @@ GSdxApp::GSdxApp()
|
|||
#endif
|
||||
m_gs_renderers.push_back(GSSetting(10, "Null", "Software"));
|
||||
m_gs_renderers.push_back(GSSetting(11, "Null", "Null"));
|
||||
#ifdef _LINUX
|
||||
m_gs_renderers.push_back(GSSetting(12, "OpenGL", "Hardware"));
|
||||
m_gs_renderers.push_back(GSSetting(13, "OpenGL", "Software"));
|
||||
#endif
|
||||
|
||||
m_gs_interlace.push_back(GSSetting(0, "None", ""));
|
||||
m_gs_interlace.push_back(GSSetting(1, "Weave tff", "saw-tooth"));
|
||||
|
|
|
@ -619,6 +619,7 @@
|
|||
<ClCompile Include="GSVertexTrace.cpp" />
|
||||
<ClCompile Include="GSWnd.cpp" />
|
||||
<ClCompile Include="GSWndDX.cpp" />
|
||||
<ClCompile Include="GSWndWGL.cpp" />
|
||||
<ClCompile Include="stdafx.cpp">
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug SSE2|Win32'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug SSE2|x64'">Create</PrecompiledHeader>
|
||||
|
@ -1634,6 +1635,7 @@
|
|||
<ClInclude Include="GSVertexTrace.h" />
|
||||
<ClInclude Include="GSWnd.h" />
|
||||
<ClInclude Include="GSWndDX.h" />
|
||||
<ClInclude Include="GSWndWGL.h" />
|
||||
<ClInclude Include="stdafx.h" />
|
||||
<ClInclude Include="svnrev.h" />
|
||||
<ClInclude Include="resource.h" />
|
||||
|
|
|
@ -180,6 +180,9 @@
|
|||
<ClCompile Include="GSWndDX.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="GSWndWGL.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="stdafx.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
|
@ -485,6 +488,9 @@
|
|||
<ClInclude Include="GSWndDX.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="GSWndWGL.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="stdafx.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
|
|
|
@ -635,6 +635,7 @@
|
|||
<ClCompile Include="GSVertexTrace.cpp" />
|
||||
<ClCompile Include="GSWnd.cpp" />
|
||||
<ClCompile Include="GSWndDX.cpp" />
|
||||
<ClCompile Include="GSWndWGL.cpp" />
|
||||
<ClCompile Include="stdafx.cpp">
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug SSE2|Win32'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug SSE2|x64'">Create</PrecompiledHeader>
|
||||
|
@ -1650,6 +1651,7 @@
|
|||
<ClInclude Include="GSVertexTrace.h" />
|
||||
<ClInclude Include="GSWnd.h" />
|
||||
<ClInclude Include="GSWndDX.h" />
|
||||
<ClInclude Include="GSWndWGL.h" />
|
||||
<ClInclude Include="stdafx.h" />
|
||||
<ClInclude Include="svnrev.h" />
|
||||
<ClInclude Include="resource.h" />
|
||||
|
|
|
@ -180,6 +180,9 @@
|
|||
<ClCompile Include="GSWndDX.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="GSWndWGL.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="stdafx.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
|
@ -485,6 +488,9 @@
|
|||
<ClInclude Include="GSWndDX.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="GSWndWGL.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="stdafx.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
|
|
|
@ -1241,6 +1241,10 @@
|
|||
RelativePath=".\GSWndDX.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\GSWndWGL.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\stdafx.cpp"
|
||||
>
|
||||
|
@ -1651,6 +1655,10 @@
|
|||
RelativePath=".\GSWndDX.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\GSWndWGL.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\stdafx.h"
|
||||
>
|
||||
|
|
Loading…
Reference in New Issue