pcsx2: increase a bit the minimum size of the plugin dialogs (GSdx name is too long)

gsdx:
* move gl function loading into GSwnd. Clean the header and avoid to rely on macro.
* Always require libegl for GSdx. You still need to select the API at compilation.


git-svn-id: http://pcsx2.googlecode.com/svn/trunk@5670 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
gregory.hainaut 2013-06-16 08:43:50 +00:00
parent b10d554764
commit 9b037a3813
17 changed files with 194 additions and 180 deletions

View File

@ -48,9 +48,6 @@ else()
endif()
find_package(wxWidgets COMPONENTS base core adv)
find_package(ZLIB)
if (EGL_API)
include(FindEGL)
endif()
## Use pcsx2 package to find module
include(FindAio)
@ -58,6 +55,7 @@ include(FindAio)
#if(NOT GLSL_API)
include(FindCg)
#endif(NOT GLSL_API)
include(FindEGL)
include(FindGlew)
include(FindLibc)
include(FindPortAudio)

View File

@ -5,7 +5,7 @@ set(msg_dep_common_libs "check these libraries -> wxWidgets (>=2.8.10), sparseha
set(msg_dep_pcsx2 "check these libraries -> wxWidgets (>=2.8.10), gtk2 (>=2.16), zlib (>=1.2.4), pcsx2 common libs")
set(msg_dep_cdvdiso "check these libraries -> bzip2 (>=1.0.5), gtk2 (>=2.16)")
set(msg_dep_zerogs "check these libraries -> glew (>=1.6), opengl, X11, nvidia-cg-toolkit (>=2.1)")
set(msg_dep_gsdx "check these libraries -> opengl, X11")
set(msg_dep_gsdx "check these libraries -> opengl, egl, X11")
set(msg_dep_onepad "check these libraries -> sdl (>=1.2)")
set(msg_dep_spu2x "check these libraries -> soundtouch (>=1.5), alsa, portaudio (>=1.9), pcsx2 common libs")
set(msg_dep_zerospu2 "check these libraries -> soundtouch (>=1.5), alsa")
@ -130,15 +130,15 @@ endif(GTK2_FOUND)
# requires: -OpenGL
# -X11
#---------------------------------------
if(OPENGL_FOUND AND X11_FOUND)
if(OPENGL_FOUND AND X11_FOUND AND EGL_FOUND)
set(GSdx TRUE)
elseif(NOT EXISTS "${PROJECT_SOURCE_DIR}/plugins/GSdx")
set(GSdx FALSE)
else(OPENGL_FOUND AND X11_FOUND)
else(OPENGL_FOUND AND X11_FOUND AND EGL_FOUND)
set(GSdx FALSE)
message(STATUS "Skip build of GSdx: miss some dependencies")
message(STATUS "${msg_dep_gsdx}")
endif(OPENGL_FOUND AND X11_FOUND)
endif(OPENGL_FOUND AND X11_FOUND AND EGL_FOUND)
#---------------------------------------
#---------------------------------------

View File

@ -234,7 +234,7 @@ Dialogs::SysConfigDialog::SysConfigDialog(wxWindow* parent)
}
Dialogs::ComponentsConfigDialog::ComponentsConfigDialog(wxWindow* parent)
: BaseConfigurationDialog( parent, AddAppName(_("Components Selectors - %s")), 600 )
: BaseConfigurationDialog( parent, AddAppName(_("Components Selectors - %s")), 650 )
{
ScopedBusyCursor busy( Cursor_ReallyBusy );

View File

@ -45,7 +45,7 @@ if(XDG_STD)
endif(XDG_STD)
# Select the EGL API
if(EGL_API AND EGL_FOUND)
if(EGL_API)
add_definitions(-DEGL_API)
endif()
@ -188,9 +188,7 @@ add_library(${Output} SHARED ${GSdxSources} ${GSdxHeaders})
target_link_libraries(${Output} ${X11_LIBRARIES})
target_link_libraries(${Output} ${OPENGL_LIBRARIES})
if(EGL_API AND EGL_FOUND)
target_link_libraries(${Output} ${EGL_LIBRARIES})
endif()
target_link_libraries(${Output} ${EGL_LIBRARIES})
if(Linux)
target_link_libraries(${Output} ${GTK2_LIBRARIES})

View File

@ -147,80 +147,6 @@ namespace GLLoader {
return true;
}
void init_gl_function() {
GL_LOADFN(gl_ActiveTexture, glActiveTexture);
GL_LOADFN(gl_BlendColor, glBlendColor);
GL_LOADFN(gl_AttachShader, glAttachShader);
GL_LOADFN(gl_BindBuffer, glBindBuffer);
GL_LOADFN(gl_BindBufferBase, glBindBufferBase);
GL_LOADFN(gl_BindFragDataLocationIndexed, glBindFragDataLocationIndexed);
GL_LOADFN(gl_BindFramebuffer, glBindFramebuffer);
GL_LOADFN(gl_BindProgramPipeline, glBindProgramPipeline);
GL_LOADFN(gl_BindSampler, glBindSampler);
GL_LOADFN(gl_BindVertexArray, glBindVertexArray);
GL_LOADFN(gl_BlendEquationSeparate, glBlendEquationSeparate);
GL_LOADFN(gl_BlendFuncSeparate, glBlendFuncSeparate);
GL_LOADFN(gl_BlitFramebuffer, glBlitFramebuffer);
GL_LOADFN(gl_BufferData, glBufferData);
GL_LOADFN(gl_CheckFramebufferStatus, glCheckFramebufferStatus);
GL_LOADFN(gl_ClearBufferfv, glClearBufferfv);
GL_LOADFN(gl_ClearBufferiv, glClearBufferiv);
GL_LOADFN(gl_CompileShader, glCompileShader);
GL_LOADFN(gl_CopyImageSubDataNV, glCopyImageSubDataNV);
GL_LOADFN(gl_CreateProgram, glCreateProgram);
GL_LOADFN(gl_CreateShader, glCreateShader);
GL_LOADFN(gl_CreateShaderProgramv, glCreateShaderProgramv);
GL_LOADFN(gl_DeleteBuffers, glDeleteBuffers);
GL_LOADFN(gl_DeleteFramebuffers, glDeleteFramebuffers);
GL_LOADFN(gl_DeleteProgram, glDeleteProgram);
GL_LOADFN(gl_DeleteProgramPipelines, glDeleteProgramPipelines);
GL_LOADFN(gl_DeleteSamplers, glDeleteSamplers);
GL_LOADFN(gl_DeleteShader, glDeleteShader);
GL_LOADFN(gl_DeleteVertexArrays, glDeleteVertexArrays);
GL_LOADFN(gl_DetachShader, glDetachShader);
GL_LOADFN(gl_DrawBuffers, glDrawBuffers);
GL_LOADFN(gl_DrawElementsBaseVertex, glDrawElementsBaseVertex);
GL_LOADFN(gl_EnableVertexAttribArray, glEnableVertexAttribArray);
GL_LOADFN(gl_FramebufferRenderbuffer, glFramebufferRenderbuffer);
GL_LOADFN(gl_FramebufferTexture2D, glFramebufferTexture2D);
GL_LOADFN(gl_GenBuffers, glGenBuffers);
GL_LOADFN(gl_GenFramebuffers, glGenFramebuffers);
GL_LOADFN(gl_GenProgramPipelines, glGenProgramPipelines);
GL_LOADFN(gl_GenSamplers, glGenSamplers);
GL_LOADFN(gl_GenVertexArrays, glGenVertexArrays);
GL_LOADFN(gl_GetBufferParameteriv, glGetBufferParameteriv);
GL_LOADFN(gl_GetDebugMessageLogARB, glGetDebugMessageLogARB);
GL_LOADFN(gl_GetFragDataIndex, glGetFragDataIndex);
GL_LOADFN(gl_GetFragDataLocation, glGetFragDataLocation);
GL_LOADFN(gl_GetProgramInfoLog, glGetProgramInfoLog);
GL_LOADFN(gl_GetProgramiv, glGetProgramiv);
GL_LOADFN(gl_GetShaderiv, glGetShaderiv);
GL_LOADFN(gl_GetStringi, glGetStringi);
GL_LOADFN(gl_IsFramebuffer, glIsFramebuffer);
GL_LOADFN(gl_LinkProgram, glLinkProgram);
GL_LOADFN(gl_MapBuffer, glMapBuffer);
GL_LOADFN(gl_MapBufferRange, glMapBufferRange);
GL_LOADFN(gl_ProgramParameteri, glProgramParameteri);
GL_LOADFN(gl_SamplerParameterf, glSamplerParameterf);
GL_LOADFN(gl_SamplerParameteri, glSamplerParameteri);
GL_LOADFN(gl_ShaderSource, glShaderSource);
GL_LOADFN(gl_Uniform1i, glUniform1i);
GL_LOADFN(gl_UnmapBuffer, glUnmapBuffer);
GL_LOADFN(gl_UseProgramStages, glUseProgramStages);
GL_LOADFN(gl_VertexAttribIPointer, glVertexAttribIPointer);
GL_LOADFN(gl_VertexAttribPointer, glVertexAttribPointer);
GL_LOADFN(gl_TexStorage2D, glTexStorage2D);
GL_LOADFN(gl_BufferSubData, glBufferSubData);
// NO GL4.1
GL_LOADFN(gl_UseProgram, glUseProgram);
GL_LOADFN(gl_GetShaderInfoLog, glGetShaderInfoLog);
GL_LOADFN(gl_ProgramUniform1i, glProgramUniform1i);
// NO GL4.2
GL_LOADFN(gl_GetUniformBlockIndex, glGetUniformBlockIndex);
GL_LOADFN(gl_UniformBlockBinding, glUniformBlockBinding);
GL_LOADFN(gl_GetUniformLocation, glGetUniformLocation);
}
bool check_gl_supported_extension() {
int max_ext = 0;
glGetIntegerv(GL_NUM_EXTENSIONS, &max_ext);

View File

@ -21,34 +21,6 @@
#pragma once
#ifdef _LINUX
#include <GL/glx.h>
#include <EGL/egl.h>
#include <EGL/eglext.h>
#endif
#ifdef _WINDOWS
#define GL_LOADFN(name, glName) { \
if( (*(void**)&name = (void*)wglGetProcAddress(#glName)) == NULL ) { \
fprintf(stderr,"Failed to find %s\n", #glName); \
} \
}
#else
#ifdef EGL_API
#define GL_LOADFN(name, glName) { \
if( (*(void**)&name = (void*)eglGetProcAddress(#glName)) == NULL ) { \
fprintf(stderr,"Failed to find %s\n", #glName); \
} \
}
#else
#define GL_LOADFN(name, glName) { \
if( (*(void**)&name = (void*)glXGetProcAddress((const GLubyte*)#glName)) == NULL ) { \
fprintf(stderr,"Failed to find %s\n", #glName); \
} \
}
#endif
#endif
extern PFNGLACTIVETEXTUREPROC gl_ActiveTexture;
extern PFNGLBLENDCOLORPROC gl_BlendColor;
extern PFNGLATTACHSHADERPROC gl_AttachShader;

View File

@ -191,8 +191,6 @@ GSTexture* GSDeviceOGL::FetchSurface(int type, int w, int h, bool msaa, int form
bool GSDeviceOGL::Create(GSWnd* wnd)
{
if (m_window == NULL) {
GLLoader::init_gl_function();
if (!GLLoader::check_gl_version(3, 0)) return false;
if (!GLLoader::check_gl_supported_extension()) return false;

View File

@ -21,6 +21,9 @@
#include "stdafx.h"
#include "GSRenderer.h"
#ifdef _LINUX
#include <X11/keysym.h>
#endif
GSRenderer::GSRenderer()
: m_wnd(NULL)
@ -560,7 +563,7 @@ void GSRenderer::KeyEvent(GSKeyEventData* e)
}
}
#else
#elif defined(_LINUX)
if(e->type == KEYPRESS)
{
int step = m_shift_key ? -1 : 1;

View File

@ -20,3 +20,79 @@
*/
#include "stdafx.h"
#include "GSWnd.h"
void GSWndGL::PopulateGlFunction()
{
*(void**)&(gl_ActiveTexture) = GetProcAddress("glActiveTexture");
*(void**)&(gl_BlendColor) = GetProcAddress("glBlendColor");
*(void**)&(gl_AttachShader) = GetProcAddress("glAttachShader");
*(void**)&(gl_BindBuffer) = GetProcAddress("glBindBuffer");
*(void**)&(gl_BindBufferBase) = GetProcAddress("glBindBufferBase");
*(void**)&(gl_BindFragDataLocationIndexed) = GetProcAddress("glBindFragDataLocationIndexed");
*(void**)&(gl_BindFramebuffer) = GetProcAddress("glBindFramebuffer");
*(void**)&(gl_BindProgramPipeline) = GetProcAddress("glBindProgramPipeline");
*(void**)&(gl_BindSampler) = GetProcAddress("glBindSampler");
*(void**)&(gl_BindVertexArray) = GetProcAddress("glBindVertexArray");
*(void**)&(gl_BlendEquationSeparate) = GetProcAddress("glBlendEquationSeparate");
*(void**)&(gl_BlendFuncSeparate) = GetProcAddress("glBlendFuncSeparate");
*(void**)&(gl_BlitFramebuffer) = GetProcAddress("glBlitFramebuffer");
*(void**)&(gl_BufferData) = GetProcAddress("glBufferData");
*(void**)&(gl_CheckFramebufferStatus) = GetProcAddress("glCheckFramebufferStatus");
*(void**)&(gl_ClearBufferfv) = GetProcAddress("glClearBufferfv");
*(void**)&(gl_ClearBufferiv) = GetProcAddress("glClearBufferiv");
*(void**)&(gl_CompileShader) = GetProcAddress("glCompileShader");
*(void**)&(gl_CopyImageSubDataNV) = GetProcAddress("glCopyImageSubDataNV");
*(void**)&(gl_CreateProgram) = GetProcAddress("glCreateProgram");
*(void**)&(gl_CreateShader) = GetProcAddress("glCreateShader");
*(void**)&(gl_CreateShaderProgramv) = GetProcAddress("glCreateShaderProgramv");
*(void**)&(gl_DeleteBuffers) = GetProcAddress("glDeleteBuffers");
*(void**)&(gl_DeleteFramebuffers) = GetProcAddress("glDeleteFramebuffers");
*(void**)&(gl_DeleteProgram) = GetProcAddress("glDeleteProgram");
*(void**)&(gl_DeleteProgramPipelines) = GetProcAddress("glDeleteProgramPipelines");
*(void**)&(gl_DeleteSamplers) = GetProcAddress("glDeleteSamplers");
*(void**)&(gl_DeleteShader) = GetProcAddress("glDeleteShader");
*(void**)&(gl_DeleteVertexArrays) = GetProcAddress("glDeleteVertexArrays");
*(void**)&(gl_DetachShader) = GetProcAddress("glDetachShader");
*(void**)&(gl_DrawBuffers) = GetProcAddress("glDrawBuffers");
*(void**)&(gl_DrawElementsBaseVertex) = GetProcAddress("glDrawElementsBaseVertex");
*(void**)&(gl_EnableVertexAttribArray) = GetProcAddress("glEnableVertexAttribArray");
*(void**)&(gl_FramebufferRenderbuffer) = GetProcAddress("glFramebufferRenderbuffer");
*(void**)&(gl_FramebufferTexture2D) = GetProcAddress("glFramebufferTexture2D");
*(void**)&(gl_GenBuffers) = GetProcAddress("glGenBuffers");
*(void**)&(gl_GenFramebuffers) = GetProcAddress("glGenFramebuffers");
*(void**)&(gl_GenProgramPipelines) = GetProcAddress("glGenProgramPipelines");
*(void**)&(gl_GenSamplers) = GetProcAddress("glGenSamplers");
*(void**)&(gl_GenVertexArrays) = GetProcAddress("glGenVertexArrays");
*(void**)&(gl_GetBufferParameteriv) = GetProcAddress("glGetBufferParameteriv");
*(void**)&(gl_GetDebugMessageLogARB) = GetProcAddress("glGetDebugMessageLogARB");
*(void**)&(gl_GetFragDataIndex) = GetProcAddress("glGetFragDataIndex");
*(void**)&(gl_GetFragDataLocation) = GetProcAddress("glGetFragDataLocation");
*(void**)&(gl_GetProgramInfoLog) = GetProcAddress("glGetProgramInfoLog");
*(void**)&(gl_GetProgramiv) = GetProcAddress("glGetProgramiv");
*(void**)&(gl_GetShaderiv) = GetProcAddress("glGetShaderiv");
*(void**)&(gl_GetStringi) = GetProcAddress("glGetStringi");
*(void**)&(gl_IsFramebuffer) = GetProcAddress("glIsFramebuffer");
*(void**)&(gl_LinkProgram) = GetProcAddress("glLinkProgram");
*(void**)&(gl_MapBuffer) = GetProcAddress("glMapBuffer");
*(void**)&(gl_MapBufferRange) = GetProcAddress("glMapBufferRange");
*(void**)&(gl_ProgramParameteri) = GetProcAddress("glProgramParameteri");
*(void**)&(gl_SamplerParameterf) = GetProcAddress("glSamplerParameterf");
*(void**)&(gl_SamplerParameteri) = GetProcAddress("glSamplerParameteri");
*(void**)&(gl_ShaderSource) = GetProcAddress("glShaderSource");
*(void**)&(gl_Uniform1i) = GetProcAddress("glUniform1i");
*(void**)&(gl_UnmapBuffer) = GetProcAddress("glUnmapBuffer");
*(void**)&(gl_UseProgramStages) = GetProcAddress("glUseProgramStages");
*(void**)&(gl_VertexAttribIPointer) = GetProcAddress("glVertexAttribIPointer");
*(void**)&(gl_VertexAttribPointer) = GetProcAddress("glVertexAttribPointer");
*(void**)&(gl_TexStorage2D) = GetProcAddress("glTexStorage2D");
*(void**)&(gl_BufferSubData) = GetProcAddress("glBufferSubData");
// NO GL4.1
*(void**)&(gl_UseProgram) = GetProcAddress("glUseProgram");
*(void**)&(gl_GetShaderInfoLog) = GetProcAddress("glGetShaderInfoLog");
*(void**)&(gl_ProgramUniform1i) = GetProcAddress("glProgramUniform1i");
// NO GL4.2
*(void**)&(gl_GetUniformBlockIndex) = GetProcAddress("glGetUniformBlockIndex");
*(void**)&(gl_UniformBlockBinding) = GetProcAddress("glUniformBlockBinding");
*(void**)&(gl_GetUniformLocation) = GetProcAddress("glGetUniformLocation");
}

View File

@ -55,3 +55,36 @@ public:
virtual void SetVSync(bool enable) {};
};
class GSWndGL : public GSWnd
{
protected:
bool m_ctx_attached;
bool IsContextAttached() const { return m_ctx_attached; }
public:
GSWndGL() : m_ctx_attached(false) {};
virtual ~GSWndGL() {};
virtual bool Create(const string& title, int w, int h) = 0;
virtual bool Attach(void* handle, bool managed = true) = 0;
virtual void Detach() = 0;
virtual void* GetDisplay() = 0;
virtual void* GetHandle() = 0;
virtual GSVector4i GetClientRect() = 0;
virtual bool SetWindowText(const char* title) = 0;
virtual void AttachContext() = 0;
virtual void DetachContext() = 0;
virtual void* GetProcAddress(const char* name) = 0;
virtual void Show() = 0;
virtual void Hide() = 0;
virtual void HideFrame() = 0;
virtual void Flip() = 0;
virtual void SetVSync(bool enable) = 0;
void PopulateGlFunction();
};

View File

@ -22,27 +22,10 @@
#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
#if defined(_LINUX)
#if defined(_LINUX) && defined (EGL_API)
GSWndEGL::GSWndEGL()
: m_NativeWindow(0), m_NativeDisplay(NULL), m_ctx_attached(false)
: m_NativeWindow(0), m_NativeDisplay(NULL)
{
}
@ -146,6 +129,8 @@ bool GSWndEGL::Attach(void* handle, bool managed)
CheckContext();
PopulateGlFunction();
return true;
}
@ -185,9 +170,22 @@ bool GSWndEGL::Create(const string& title, int w, int h)
AttachContext();
CheckContext();
PopulateGlFunction();
return (m_NativeWindow != 0);
}
void* GSWndEGL::GetProcAddress(const char* name)
{
void* ptr = (void*)eglGetProcAddress(name);
if (ptr == NULL) {
fprintf(stderr, "Failed to find %s\n", name);
}
return ptr;
}
void* GSWndEGL::GetDisplay()
{
// note this part must be only executed when replaying .gs debug file
@ -278,5 +276,4 @@ EGLBoolean GSWndEGL::OpenEGLDisplay()
return EGL_TRUE;
}
#endif

View File

@ -21,12 +21,31 @@
#include "GSWnd.h"
#if defined(_LINUX) && defined (EGL_API)
#if defined(_LINUX)
#include <X11/Xlib.h>
#include <EGL/egl.h>
#include <EGL/eglext.h>
class GSWndEGL : public GSWnd
// 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
class GSWndEGL : public GSWndGL
{
EGLNativeWindowType m_NativeWindow;
EGLNativeDisplayType m_NativeDisplay;
@ -35,9 +54,6 @@ class GSWndEGL : public GSWnd
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();
@ -59,6 +75,7 @@ public:
void AttachContext();
void DetachContext();
void* GetProcAddress(const char* name);
void Show();
void Hide();

View File

@ -24,7 +24,7 @@
#ifdef _LINUX
GSWndOGL::GSWndOGL()
: m_NativeWindow(0), m_NativeDisplay(NULL), m_swapinterval(NULL), m_ctx_attached(false)
: m_NativeWindow(0), m_NativeDisplay(NULL), m_swapinterval(NULL)
{
}
@ -147,6 +147,7 @@ bool GSWndOGL::Attach(void* handle, bool managed)
m_swapinterval = (PFNGLXSWAPINTERVALMESAPROC)glXGetProcAddress((const GLubyte*) "glXSwapIntervalMESA");
//PFNGLXSWAPINTERVALMESAPROC m_swapinterval = (PFNGLXSWAPINTERVALMESAPROC)glXGetProcAddress((const GLubyte*) "glXSwapInterval");
PopulateGlFunction();
return true;
}
@ -178,34 +179,7 @@ bool GSWndOGL::Create(const string& title, int w, int h)
// note this part must be only executed when replaying .gs debug file
m_NativeDisplay = XOpenDisplay(NULL);
#if 0
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);
XFree(vi);
#else
m_NativeWindow = XCreateSimpleWindow(m_NativeDisplay, DefaultRootWindow(m_NativeDisplay), 0, 0, w, h, 0, 0, 0);
#endif
XMapWindow (m_NativeDisplay, m_NativeWindow);
@ -216,9 +190,20 @@ bool GSWndOGL::Create(const string& title, int w, int h)
CheckContext();
PopulateGlFunction();
return (m_NativeWindow != 0);
}
void* GSWndOGL::GetProcAddress(const char* name)
{
void* ptr = (void*)glXGetProcAddress((const GLubyte*)name);
if (ptr == NULL) {
fprintf(stderr, "Failed to find %s\n", name);
}
return ptr;
}
void* GSWndOGL::GetDisplay()
{
// note this part must be only executed when replaying .gs debug file

View File

@ -25,17 +25,14 @@
#include <X11/Xlib.h>
#include <GL/glx.h>
class GSWndOGL : public GSWnd
class GSWndOGL : public GSWndGL
{
Window m_NativeWindow;
Display* m_NativeDisplay;
GLXContext m_context;
bool m_ctx_attached;
PFNGLXSWAPINTERVALMESAPROC m_swapinterval;
bool IsContextAttached() const { return m_ctx_attached; }
bool CreateContext(int major, int minor);
void CheckContext();
@ -54,6 +51,7 @@ public:
void AttachContext();
void DetachContext();
void* GetProcAddress(const char* name);
void Show();
void Hide();

View File

@ -24,7 +24,7 @@
#ifdef _WINDOWS
GSWndWGL::GSWndWGL()
: m_NativeWindow(NULL), m_NativeDisplay(NULL), m_context(NULL), m_ctx_attached(false)
: m_NativeWindow(NULL), m_NativeDisplay(NULL), m_context(NULL)
{
}
@ -128,6 +128,8 @@ bool GSWndWGL::Attach(void* handle, bool managed)
//m_swapinterval = (PFNGLXSWAPINTERVALMESAPROC)glXGetProcAddress((const GLubyte*) "glXSwapIntervalMESA");
//PFNGLXSWAPINTERVALMESAPROC m_swapinterval = (PFNGLXSWAPINTERVALMESAPROC)glXGetProcAddress((const GLubyte*) "glXSwapInterval");
PopulateGlFunction();
UpdateWindow(m_NativeWindow);
return true;
@ -263,6 +265,15 @@ GSVector4i GSWndWGL::GetClientRect()
return r;
}
void* GSWndWGL::GetProcAddress(const char* name)
{
void* ptr = (void*)wglGetProcAddress(name);
if (ptr == NULL) {
fprintf(stderr, "Failed to find %s\n", name);
}
return ptr;
}
//TODO: check extensions supported or not
//FIXME : extension allocation
void GSWndWGL::SetVSync(bool enable)

View File

@ -23,17 +23,14 @@
#ifdef _WINDOWS
class GSWndWGL : public GSWnd
class GSWndWGL : public GSWndGL
{
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();
@ -55,6 +52,7 @@ public:
void AttachContext();
void DetachContext();
void* GetProcAddress(const char* name);
void Show();
void Hide();

View File

@ -262,10 +262,14 @@ struct aligned_free_second {template<class T> void operator()(T& p) {_aligned_fr
#define RESTRICT restrict
#elif _MSC_VER >= 1400 // TODO: gcc
#elif _MSC_VER >= 1400
#define RESTRICT __restrict
#elif defined(__GNUC__)
#define RESTRICT __restrict__
#else
#define RESTRICT