From 0783875b84c724574b5e68ba26893c07f7cddaf7 Mon Sep 17 00:00:00 2001 From: ~skmp Date: Tue, 30 Dec 2014 13:20:51 +0200 Subject: [PATCH] Linux GLX/3.1 support My setup is only 2.1 right now, so this is totally untested --- core/khronos/GL3/gl3w.c | 3 +- core/linux-dist/main.cpp | 75 +++++-- core/rend/gles/gles.cpp | 451 +++++++++++++++++++++------------------ core/rend/gles/gles.h | 2 +- shell/lin86/Makefile | 10 +- 5 files changed, 309 insertions(+), 232 deletions(-) diff --git a/core/khronos/GL3/gl3w.c b/core/khronos/GL3/gl3w.c index 5ea7a19a6..98642b23f 100644 --- a/core/khronos/GL3/gl3w.c +++ b/core/khronos/GL3/gl3w.c @@ -77,7 +77,7 @@ static void *get_proc(const char *proc) { void *res; - res = glXGetProcAddress((const GLubyte *) proc); + res = (void*)glXGetProcAddress((const GLubyte *) proc); if (!res) res = dlsym(libgl, proc); return res; @@ -96,6 +96,7 @@ static int parse_version(void) glGetIntegerv(GL_MAJOR_VERSION, &version.major); glGetIntegerv(GL_MINOR_VERSION, &version.minor); + printf("GL context version: %d.%d\n", version.major, version.minor); if (version.major < 3) return -1; return 0; diff --git a/core/linux-dist/main.cpp b/core/linux-dist/main.cpp index 44d20c2f7..2bd594b6a 100755 --- a/core/linux-dist/main.cpp +++ b/core/linux-dist/main.cpp @@ -22,6 +22,12 @@ #include #include #include + + #if !defined(GLES) + #include + #include + #endif + #endif #if !defined(ANDROID) @@ -476,6 +482,8 @@ void os_SetWindowText(const char * text) } +void* x11_glc; + int ndcid=0; void os_CreateWindow() { @@ -508,15 +516,36 @@ void os_CreateWindow() // Gets the window parameters sRootWindow = RootWindow(x11Display, x11Screen); - i32Depth = DefaultDepth(x11Display, x11Screen); - x11Visual = new XVisualInfo; - XMatchVisualInfo( x11Display, x11Screen, i32Depth, TrueColor, x11Visual); - if (!x11Visual) - { - printf("Error: Unable to acquire visual\n"); - return; - } - x11Colormap = XCreateColormap( x11Display, sRootWindow, x11Visual->visual, AllocNone ); + + int depth = CopyFromParent; + + #if !defined(GLES) + int attr32[] = { GLX_RGBA, GLX_DEPTH_SIZE, 32, GLX_DOUBLEBUFFER, GLX_STENCIL_SIZE, 8, None }; + int attr24[] = { GLX_RGBA, GLX_DEPTH_SIZE, 24, GLX_DOUBLEBUFFER, GLX_STENCIL_SIZE, 8, None }; + + XVisualInfo* vi = glXChooseVisual(x11Display, 0, attr32); + if (!vi) + vi = glXChooseVisual(x11Display, 0, attr24); + + if (!vi) + die("Failed to glXChooseVisual"); + + depth = vi->depth; + x11Visual = vi; + + x11Colormap = XCreateColormap(x11Display, RootWindow(x11Display, x11Screen), vi->visual, AllocNone); + #else + i32Depth = DefaultDepth(x11Display, x11Screen); + x11Visual = new XVisualInfo; + XMatchVisualInfo( x11Display, x11Screen, i32Depth, TrueColor, x11Visual); + if (!x11Visual) + { + printf("Error: Unable to acquire visual\n"); + return; + } + x11Colormap = XCreateColormap( x11Display, sRootWindow, x11Visual->visual, AllocNone ); + #endif + sWA.colormap = x11Colormap; // Add to these for handling other events @@ -536,18 +565,24 @@ void os_CreateWindow() width=XDisplayWidth(x11Display,x11Screen); height=XDisplayHeight(x11Display,x11Screen); } + // Creates the X11 window x11Window = XCreateWindow( x11Display, RootWindow(x11Display, x11Screen), (ndcid%3)*640, (ndcid/3)*480, width, height, - 0, CopyFromParent, InputOutput, CopyFromParent, ui32Mask, &sWA); + 0, depth, InputOutput, x11Visual->visual, ui32Mask, &sWA); #ifdef TARGET_PANDORA - // fullscreen - Atom wmState = XInternAtom(x11Display, "_NET_WM_STATE", False); - Atom wmFullscreen = XInternAtom(x11Display, "_NET_WM_STATE_FULLSCREEN", False); - XChangeProperty(x11Display, x11Window, wmState, XA_ATOM, 32, PropModeReplace, (unsigned char *)&wmFullscreen, 1); - - XMapRaised(x11Display, x11Window); + // fullscreen + Atom wmState = XInternAtom(x11Display, "_NET_WM_STATE", False); + Atom wmFullscreen = XInternAtom(x11Display, "_NET_WM_STATE_FULLSCREEN", False); + XChangeProperty(x11Display, x11Window, wmState, XA_ATOM, 32, PropModeReplace, (unsigned char *)&wmFullscreen, 1); + + XMapRaised(x11Display, x11Window); #else - XMapWindow(x11Display, x11Window); + XMapWindow(x11Display, x11Window); + + #if !defined(GLES) + x11_glc = glXCreateContext(x11Display, x11Visual, NULL, GL_TRUE); + //glXMakeCurrent(x11Display, x11Window, glc); + #endif #endif XFlush(x11Display); @@ -722,3 +757,9 @@ return 1; int get_mic_data(u8* buffer) { return 0; } int push_vmu_screen(u8* buffer) { return 0; } + + +void os_DebugBreak() +{ + raise(SIGTRAP); +} diff --git a/core/rend/gles/gles.cpp b/core/rend/gles/gles.cpp index 678dc1744..a0b079d68 100755 --- a/core/rend/gles/gles.cpp +++ b/core/rend/gles/gles.cpp @@ -355,248 +355,277 @@ int screen_width; int screen_height; #ifdef GLES -// Create a basic GLES context -bool gl_init(void* wind, void* disp) -{ -#if !defined(_ANDROID) - gl.setup.native_wind=(EGLNativeWindowType)wind; - gl.setup.native_disp=(EGLNativeDisplayType)disp; - - //try to get a display - gl.setup.display = eglGetDisplay(gl.setup.native_disp); - - //if failed, get the default display (this will not happen in win32) - if(gl.setup.display == EGL_NO_DISPLAY) - gl.setup.display = eglGetDisplay((EGLNativeDisplayType) EGL_DEFAULT_DISPLAY); - - - // Initialise EGL - EGLint maj, min; - if (!eglInitialize(gl.setup.display, &maj, &min)) + // Create a basic GLES context + bool gl_init(void* wind, void* disp) { - printf("EGL Error: eglInitialize failed\n"); - return false; - } + #if !defined(_ANDROID) + gl.setup.native_wind=(EGLNativeWindowType)wind; + gl.setup.native_disp=(EGLNativeDisplayType)disp; - printf("Info: EGL version %d.%d\n",maj,min); + //try to get a display + gl.setup.display = eglGetDisplay(gl.setup.native_disp); + + //if failed, get the default display (this will not happen in win32) + if(gl.setup.display == EGL_NO_DISPLAY) + gl.setup.display = eglGetDisplay((EGLNativeDisplayType) EGL_DEFAULT_DISPLAY); + + + // Initialise EGL + EGLint maj, min; + if (!eglInitialize(gl.setup.display, &maj, &min)) + { + printf("EGL Error: eglInitialize failed\n"); + return false; + } + + printf("Info: EGL version %d.%d\n",maj,min); - EGLint pi32ConfigAttribs[] = { EGL_SURFACE_TYPE, EGL_WINDOW_BIT, EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT , EGL_DEPTH_SIZE, 24, EGL_STENCIL_SIZE, 8, EGL_NONE }; - EGLint pi32ContextAttribs[] = { EGL_CONTEXT_CLIENT_VERSION, 2 , EGL_NONE }; - - int num_config; + EGLint pi32ConfigAttribs[] = { EGL_SURFACE_TYPE, EGL_WINDOW_BIT, EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT , EGL_DEPTH_SIZE, 24, EGL_STENCIL_SIZE, 8, EGL_NONE }; + EGLint pi32ContextAttribs[] = { EGL_CONTEXT_CLIENT_VERSION, 2 , EGL_NONE }; + + int num_config; - EGLConfig config; - if (!eglChooseConfig(gl.setup.display, pi32ConfigAttribs, &config, 1, &num_config) || (num_config != 1)) - { - printf("EGL Error: eglChooseConfig failed\n"); - return false; - } + EGLConfig config; + if (!eglChooseConfig(gl.setup.display, pi32ConfigAttribs, &config, 1, &num_config) || (num_config != 1)) + { + printf("EGL Error: eglChooseConfig failed\n"); + return false; + } - gl.setup.surface = eglCreateWindowSurface(gl.setup.display, config, (EGLNativeWindowType)wind, NULL); + gl.setup.surface = eglCreateWindowSurface(gl.setup.display, config, (EGLNativeWindowType)wind, NULL); - if (eglCheck()) - return false; + if (eglCheck()) + return false; - eglBindAPI(EGL_OPENGL_ES_API); - if (eglCheck()) - return false; + eglBindAPI(EGL_OPENGL_ES_API); + if (eglCheck()) + return false; - gl.setup.context = eglCreateContext(gl.setup.display, config, NULL, pi32ContextAttribs); + gl.setup.context = eglCreateContext(gl.setup.display, config, NULL, pi32ContextAttribs); - if (eglCheck()) - return false; + if (eglCheck()) + return false; -#endif - - eglMakeCurrent(gl.setup.display, gl.setup.surface, gl.setup.surface, gl.setup.context); - - if (eglCheck()) - return false; - - EGLint w,h; - eglQuerySurface(gl.setup.display, gl.setup.surface, EGL_WIDTH, &w); - eglQuerySurface(gl.setup.display, gl.setup.surface, EGL_HEIGHT, &h); - - screen_width=w; - screen_height=h; - - printf("EGL config: %08X, %08X, %08X %dx%d\n",gl.setup.context,gl.setup.display,gl.setup.surface,w,h); - return true; -} - -void egl_stealcntx() -{ - gl.setup.context=eglGetCurrentContext(); - gl.setup.display=eglGetCurrentDisplay(); - gl.setup.surface=eglGetCurrentSurface(EGL_DRAW); -} - -//swap buffers -void gl_swap() -{ - #ifdef TARGET_PANDORA0 - if (fbdev >= 0) - { - int arg = 0; - ioctl(fbdev,FBIO_WAITFORVSYNC,&arg); - } #endif - eglSwapBuffers(gl.setup.display, gl.setup.surface); -} -//destroy the gles context and free resources -void gl_term() -{ -#if HOST_OS==OS_WINDOWS - ReleaseDC((HWND)gl.setup.native_wind,(HDC)gl.setup.native_disp); -#endif -#ifdef TARGET_PANDORA - eglMakeCurrent( gl.setup.display, NULL, NULL, EGL_NO_CONTEXT ); - if (gl.setup.context) - eglDestroyContext(gl.setup.display, gl.setup.context); - if (gl.setup.surface) - eglDestroySurface(gl.setup.display, gl.setup.surface); - if (gl.setup.display) - eglTerminate(gl.setup.display); - if (fbdev>=0) - close( fbdev ); - - fbdev=-1; - gl.setup.context=0; - gl.setup.surface=0; - gl.setup.display=0; -#endif -} + eglMakeCurrent(gl.setup.display, gl.setup.surface, gl.setup.surface, gl.setup.context); + + if (eglCheck()) + return false; + + EGLint w,h; + eglQuerySurface(gl.setup.display, gl.setup.surface, EGL_WIDTH, &w); + eglQuerySurface(gl.setup.display, gl.setup.surface, EGL_HEIGHT, &h); + + screen_width=w; + screen_height=h; + + printf("EGL config: %08X, %08X, %08X %dx%d\n",gl.setup.context,gl.setup.display,gl.setup.surface,w,h); + return true; + } + + void egl_stealcntx() + { + gl.setup.context=eglGetCurrentContext(); + gl.setup.display=eglGetCurrentDisplay(); + gl.setup.surface=eglGetCurrentSurface(EGL_DRAW); + } + + //swap buffers + void gl_swap() + { + #ifdef TARGET_PANDORA0 + if (fbdev >= 0) + { + int arg = 0; + ioctl(fbdev,FBIO_WAITFORVSYNC,&arg); + } + #endif + eglSwapBuffers(gl.setup.display, gl.setup.surface); + } + + //destroy the gles context and free resources + void gl_term() + { + #if HOST_OS==OS_WINDOWS + ReleaseDC((HWND)gl.setup.native_wind,(HDC)gl.setup.native_disp); + #endif + #ifdef TARGET_PANDORA + eglMakeCurrent( gl.setup.display, NULL, NULL, EGL_NO_CONTEXT ); + if (gl.setup.context) + eglDestroyContext(gl.setup.display, gl.setup.context); + if (gl.setup.surface) + eglDestroySurface(gl.setup.display, gl.setup.surface); + if (gl.setup.display) + eglTerminate(gl.setup.display); + if (fbdev>=0) + close( fbdev ); + + fbdev=-1; + gl.setup.context=0; + gl.setup.surface=0; + gl.setup.display=0; + #endif + } #else -#define WGL_DRAW_TO_WINDOW_ARB 0x2001 -#define WGL_ACCELERATION_ARB 0x2003 -#define WGL_SWAP_METHOD_ARB 0x2007 -#define WGL_SUPPORT_OPENGL_ARB 0x2010 -#define WGL_DOUBLE_BUFFER_ARB 0x2011 -#define WGL_PIXEL_TYPE_ARB 0x2013 -#define WGL_COLOR_BITS_ARB 0x2014 -#define WGL_DEPTH_BITS_ARB 0x2022 -#define WGL_STENCIL_BITS_ARB 0x2023 -#define WGL_FULL_ACCELERATION_ARB 0x2027 -#define WGL_SWAP_EXCHANGE_ARB 0x2028 -#define WGL_TYPE_RGBA_ARB 0x202B -#define WGL_CONTEXT_MAJOR_VERSION_ARB 0x2091 -#define WGL_CONTEXT_MINOR_VERSION_ARB 0x2092 -#define WGL_CONTEXT_FLAGS_ARB 0x2094 + #if HOST_OS == OS_WINDOWS + #define WGL_DRAW_TO_WINDOW_ARB 0x2001 + #define WGL_ACCELERATION_ARB 0x2003 + #define WGL_SWAP_METHOD_ARB 0x2007 + #define WGL_SUPPORT_OPENGL_ARB 0x2010 + #define WGL_DOUBLE_BUFFER_ARB 0x2011 + #define WGL_PIXEL_TYPE_ARB 0x2013 + #define WGL_COLOR_BITS_ARB 0x2014 + #define WGL_DEPTH_BITS_ARB 0x2022 + #define WGL_STENCIL_BITS_ARB 0x2023 + #define WGL_FULL_ACCELERATION_ARB 0x2027 + #define WGL_SWAP_EXCHANGE_ARB 0x2028 + #define WGL_TYPE_RGBA_ARB 0x202B + #define WGL_CONTEXT_MAJOR_VERSION_ARB 0x2091 + #define WGL_CONTEXT_MINOR_VERSION_ARB 0x2092 + #define WGL_CONTEXT_FLAGS_ARB 0x2094 -#define WGL_CONTEXT_PROFILE_MASK_ARB 0x9126 -#define WGL_CONTEXT_MAJOR_VERSION_ARB 0x2091 -#define WGL_CONTEXT_MINOR_VERSION_ARB 0x2092 -#define WGL_CONTEXT_LAYER_PLANE_ARB 0x2093 -#define WGL_CONTEXT_FLAGS_ARB 0x2094 -#define WGL_CONTEXT_DEBUG_BIT_ARB 0x0001 -#define WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x0002 -#define ERROR_INVALID_VERSION_ARB 0x2095 -#define WGL_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001 + #define WGL_CONTEXT_PROFILE_MASK_ARB 0x9126 + #define WGL_CONTEXT_MAJOR_VERSION_ARB 0x2091 + #define WGL_CONTEXT_MINOR_VERSION_ARB 0x2092 + #define WGL_CONTEXT_LAYER_PLANE_ARB 0x2093 + #define WGL_CONTEXT_FLAGS_ARB 0x2094 + #define WGL_CONTEXT_DEBUG_BIT_ARB 0x0001 + #define WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x0002 + #define ERROR_INVALID_VERSION_ARB 0x2095 + #define WGL_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001 -typedef BOOL (WINAPI * PFNWGLCHOOSEPIXELFORMATARBPROC) (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, - int *piFormats, UINT *nNumFormats); -typedef HGLRC (WINAPI * PFNWGLCREATECONTEXTATTRIBSARBPROC) (HDC hDC, HGLRC hShareContext, const int *attribList); -typedef BOOL (WINAPI * PFNWGLSWAPINTERVALEXTPROC) (int interval); + typedef BOOL (WINAPI * PFNWGLCHOOSEPIXELFORMATARBPROC) (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, + int *piFormats, UINT *nNumFormats); + typedef HGLRC (WINAPI * PFNWGLCREATECONTEXTATTRIBSARBPROC) (HDC hDC, HGLRC hShareContext, const int *attribList); + typedef BOOL (WINAPI * PFNWGLSWAPINTERVALEXTPROC) (int interval); -PFNWGLCHOOSEPIXELFORMATARBPROC wglChoosePixelFormatARB; -PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribsARB; -PFNWGLSWAPINTERVALEXTPROC wglSwapIntervalEXT; + PFNWGLCHOOSEPIXELFORMATARBPROC wglChoosePixelFormatARB; + PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribsARB; + PFNWGLSWAPINTERVALEXTPROC wglSwapIntervalEXT; -HDC ourWindowHandleToDeviceContext; -bool gl_init(void* hwnd, void* hdc) -{ - PIXELFORMATDESCRIPTOR pfd = - { - sizeof(PIXELFORMATDESCRIPTOR), - 1, - PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER, //Flags - PFD_TYPE_RGBA, //The kind of framebuffer. RGBA or palette. - 32, //Colordepth of the framebuffer. - 0, 0, 0, 0, 0, 0, - 0, - 0, - 0, - 0, 0, 0, 0, - 24, //Number of bits for the depthbuffer - 8, //Number of bits for the stencilbuffer - 0, //Number of Aux buffers in the framebuffer. - PFD_MAIN_PLANE, - 0, - 0, 0, 0 - }; - - /*HDC*/ ourWindowHandleToDeviceContext = (HDC)hdc;//GetDC((HWND)hwnd); - - int letWindowsChooseThisPixelFormat; - letWindowsChooseThisPixelFormat = ChoosePixelFormat(ourWindowHandleToDeviceContext, &pfd); - SetPixelFormat(ourWindowHandleToDeviceContext,letWindowsChooseThisPixelFormat, &pfd); - - HGLRC ourOpenGLRenderingContext = wglCreateContext(ourWindowHandleToDeviceContext); - wglMakeCurrent (ourWindowHandleToDeviceContext, ourOpenGLRenderingContext); - - bool rv = true; - - if (rv) { - - wglChoosePixelFormatARB = (PFNWGLCHOOSEPIXELFORMATARBPROC)wglGetProcAddress("wglChoosePixelFormatARB"); - if(!wglChoosePixelFormatARB) + HDC ourWindowHandleToDeviceContext; + bool gl_init(void* hwnd, void* hdc) { - return false; - } + PIXELFORMATDESCRIPTOR pfd = + { + sizeof(PIXELFORMATDESCRIPTOR), + 1, + PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER, //Flags + PFD_TYPE_RGBA, //The kind of framebuffer. RGBA or palette. + 32, //Colordepth of the framebuffer. + 0, 0, 0, 0, 0, 0, + 0, + 0, + 0, + 0, 0, 0, 0, + 24, //Number of bits for the depthbuffer + 8, //Number of bits for the stencilbuffer + 0, //Number of Aux buffers in the framebuffer. + PFD_MAIN_PLANE, + 0, + 0, 0, 0 + }; - wglCreateContextAttribsARB = (PFNWGLCREATECONTEXTATTRIBSARBPROC)wglGetProcAddress("wglCreateContextAttribsARB"); - if(!wglCreateContextAttribsARB) + /*HDC*/ ourWindowHandleToDeviceContext = (HDC)hdc;//GetDC((HWND)hwnd); + + int letWindowsChooseThisPixelFormat; + letWindowsChooseThisPixelFormat = ChoosePixelFormat(ourWindowHandleToDeviceContext, &pfd); + SetPixelFormat(ourWindowHandleToDeviceContext,letWindowsChooseThisPixelFormat, &pfd); + + HGLRC ourOpenGLRenderingContext = wglCreateContext(ourWindowHandleToDeviceContext); + wglMakeCurrent (ourWindowHandleToDeviceContext, ourOpenGLRenderingContext); + + bool rv = true; + + if (rv) { + + wglChoosePixelFormatARB = (PFNWGLCHOOSEPIXELFORMATARBPROC)wglGetProcAddress("wglChoosePixelFormatARB"); + if(!wglChoosePixelFormatARB) + { + return false; + } + + wglCreateContextAttribsARB = (PFNWGLCREATECONTEXTATTRIBSARBPROC)wglGetProcAddress("wglCreateContextAttribsARB"); + if(!wglCreateContextAttribsARB) + { + return false; + } + + wglSwapIntervalEXT = (PFNWGLSWAPINTERVALEXTPROC)wglGetProcAddress("wglSwapIntervalEXT"); + if(!wglSwapIntervalEXT) + { + return false; + } + + int attribs[] = + { + WGL_CONTEXT_MAJOR_VERSION_ARB, 3, + WGL_CONTEXT_MINOR_VERSION_ARB, 1, + WGL_CONTEXT_FLAGS_ARB, WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB, + WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_CORE_PROFILE_BIT_ARB, + 0 + }; + + HGLRC m_hrc = wglCreateContextAttribsARB(ourWindowHandleToDeviceContext,0, attribs); + + if (m_hrc) + wglMakeCurrent(ourWindowHandleToDeviceContext,m_hrc); + else + rv = false; + + wglDeleteContext(ourOpenGLRenderingContext); + } + + if (rv) { + rv = gl3wInit() != -1 && gl3wIsSupported(3, 1); + } + + RECT r; + GetClientRect((HWND)hwnd, &r); + screen_width = r.right - r.left; + screen_height = r.bottom - r.top; + + return rv; + } + #include + void gl_swap() { - return false; + wglSwapLayerBuffers(ourWindowHandleToDeviceContext,WGL_SWAP_MAIN_PLANE); + //SwapBuffers(ourWindowHandleToDeviceContext); } + #else + #if defined(SUPPORT_X11) + //! windows && X11 + //let's assume glx for now - wglSwapIntervalEXT = (PFNWGLSWAPINTERVALEXTPROC)wglGetProcAddress("wglSwapIntervalEXT"); - if(!wglSwapIntervalEXT) - { - return false; - } + #include + #include + #include + #include - int attribs[] = - { - WGL_CONTEXT_MAJOR_VERSION_ARB, 3, - WGL_CONTEXT_MINOR_VERSION_ARB, 1, - WGL_CONTEXT_FLAGS_ARB, WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB, - WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_CORE_PROFILE_BIT_ARB, - 0 - }; - HGLRC m_hrc = wglCreateContextAttribsARB(ourWindowHandleToDeviceContext,0, attribs); + bool gl_init(void* wind, void* disp) + { + extern void* x11_glc; - if (m_hrc) - wglMakeCurrent(ourWindowHandleToDeviceContext,m_hrc); - else - rv = false; + glXMakeCurrent((Display*)libPvr_GetRenderSurface(), + (GLXDrawable)libPvr_GetRenderTarget(), + (GLXContext)x11_glc); - wglDeleteContext(ourOpenGLRenderingContext); - } + return gl3wInit() != -1 && gl3wIsSupported(3, 1); + } - if (rv) { - rv = gl3wInit() != -1 && gl3wIsSupported(3, 1); - } - - RECT r; - GetClientRect((HWND)hwnd, &r); - screen_width = r.right - r.left; - screen_height = r.bottom - r.top; - - return rv; -} -#include -void gl_swap() -{ - wglSwapLayerBuffers(ourWindowHandleToDeviceContext,WGL_SWAP_MAIN_PLANE); - //SwapBuffers(ourWindowHandleToDeviceContext); -} + void gl_swap() + { + glXSwapBuffers((Display*)libPvr_GetRenderSurface(), (GLXDrawable)libPvr_GetRenderTarget()); + } + #endif + #endif #endif diff --git a/core/rend/gles/gles.h b/core/rend/gles/gles.h index 064c37766..cee0bfe4f 100755 --- a/core/rend/gles/gles.h +++ b/core/rend/gles/gles.h @@ -22,7 +22,7 @@ #endif #else -#include + #include #endif diff --git a/shell/lin86/Makefile b/shell/lin86/Makefile index bc5675fb0..8913396f9 100644 --- a/shell/lin86/Makefile +++ b/shell/lin86/Makefile @@ -37,7 +37,10 @@ CXXFLAGS += -ffast-math -ftree-vectorize #-std=c++0x CXXFLAGS += $(CFLAGS) $(MFLAGS) -fno-exceptions -fno-rtti -CXXFLAGS += -D SUPPORT_X11 -DGLES +CXXFLAGS += -D SUPPORT_X11 + +# use this to do GLES on x11 (also, update the libs) +# CXXFLAGS += -DGLES ifdef PGO_MAKE @@ -61,7 +64,10 @@ INCS := -I$(RZDCY_SRC_DIR) -I$(RZDCY_SRC_DIR)/deps -I$(RZDCY_SRC_DIR)/khronos -I LIBS := -L../linux-deps/lib/x86 -L./enta_viv #LIBS += -lglapi -LIBS += -lm -lrt -lEGL -lGLESv2 #-lglslcompiler -lIMGegl -lpvr2d -lsrv_um +LIBS += -lm -lrt +LIBS += -ldl -lGL #for desktop gl +#use this for GLES +#LIBS += -lEGL -lGLESv2 #-lglslcompiler -lIMGegl -lpvr2d -lsrv_um LIBS += -lpthread -lasound -lX11 -lXdmcp -lXau