Commit 931e1c10 authored by Sam Lantinga's avatar Sam Lantinga

Implemented X11 OpenGL support.

Added support for the SDL_VIDEO_OPENGL environment variable.

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%401998
parent cc0b6550
...@@ -1359,7 +1359,7 @@ AC_HELP_STRING([--enable-video-dummy], [use dummy video driver [[default=yes]]]) ...@@ -1359,7 +1359,7 @@ AC_HELP_STRING([--enable-video-dummy], [use dummy video driver [[default=yes]]])
dnl Check to see if OpenGL support is desired dnl Check to see if OpenGL support is desired
AC_ARG_ENABLE(video-opengl, AC_ARG_ENABLE(video-opengl,
AC_HELP_STRING([--enable-video-opengl], [include OpenGL context creation [[default=yes]]]), AC_HELP_STRING([--enable-video-opengl], [include OpenGL support [[default=yes]]]),
, enable_video_opengl=yes) , enable_video_opengl=yes)
dnl Find OpenGL dnl Find OpenGL
...@@ -1379,6 +1379,7 @@ CheckOpenGLX11() ...@@ -1379,6 +1379,7 @@ CheckOpenGLX11()
if test x$video_opengl = xyes; then if test x$video_opengl = xyes; then
AC_DEFINE(SDL_VIDEO_OPENGL) AC_DEFINE(SDL_VIDEO_OPENGL)
AC_DEFINE(SDL_VIDEO_OPENGL_GLX) AC_DEFINE(SDL_VIDEO_OPENGL_GLX)
AC_DEFINE(SDL_VIDEO_RENDER_OGL)
fi fi
fi fi
} }
...@@ -1398,6 +1399,7 @@ CheckOpenGLQNX() ...@@ -1398,6 +1399,7 @@ CheckOpenGLQNX()
AC_MSG_RESULT($video_opengl) AC_MSG_RESULT($video_opengl)
if test x$video_opengl = xyes; then if test x$video_opengl = xyes; then
AC_DEFINE(SDL_VIDEO_OPENGL) AC_DEFINE(SDL_VIDEO_OPENGL)
AC_DEFINE(SDL_VIDEO_RENDER_OGL)
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lGL" EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lGL"
fi fi
fi fi
...@@ -1409,6 +1411,7 @@ CheckWIN32GL() ...@@ -1409,6 +1411,7 @@ CheckWIN32GL()
if test x$enable_video = xyes -a x$enable_video_opengl = xyes; then if test x$enable_video = xyes -a x$enable_video_opengl = xyes; then
AC_DEFINE(SDL_VIDEO_OPENGL) AC_DEFINE(SDL_VIDEO_OPENGL)
AC_DEFINE(SDL_VIDEO_OPENGL_WGL) AC_DEFINE(SDL_VIDEO_OPENGL_WGL)
AC_DEFINE(SDL_VIDEO_RENDER_OGL)
fi fi
} }
...@@ -1417,6 +1420,8 @@ CheckBeGL() ...@@ -1417,6 +1420,8 @@ CheckBeGL()
{ {
if test x$enable_video = xyes -a x$enable_video_opengl = xyes; then if test x$enable_video = xyes -a x$enable_video_opengl = xyes; then
AC_DEFINE(SDL_VIDEO_OPENGL) AC_DEFINE(SDL_VIDEO_OPENGL)
AC_DEFINE(SDL_VIDEO_OPENGL_BGL)
AC_DEFINE(SDL_VIDEO_RENDER_OGL)
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lGL" EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lGL"
fi fi
} }
...@@ -1426,6 +1431,8 @@ CheckMacGL() ...@@ -1426,6 +1431,8 @@ CheckMacGL()
{ {
if test x$enable_video = xyes -a x$enable_video_opengl = xyes; then if test x$enable_video = xyes -a x$enable_video_opengl = xyes; then
AC_DEFINE(SDL_VIDEO_OPENGL) AC_DEFINE(SDL_VIDEO_OPENGL)
AC_DEFINE(SDL_VIDEO_OPENGL_CGL)
AC_DEFINE(SDL_VIDEO_RENDER_OGL)
case "$host" in case "$host" in
*-*-darwin*) *-*-darwin*)
if test x$enable_video_cocoa = xyes; then if test x$enable_video_cocoa = xyes; then
...@@ -1456,6 +1463,7 @@ CheckAtariOSMesa() ...@@ -1456,6 +1463,7 @@ CheckAtariOSMesa()
fi fi
AC_DEFINE(SDL_VIDEO_OPENGL) AC_DEFINE(SDL_VIDEO_OPENGL)
AC_DEFINE(SDL_VIDEO_OPENGL_OSMESA) AC_DEFINE(SDL_VIDEO_OPENGL_OSMESA)
AC_DEFINE(SDL_VIDEO_RENDER_OGL)
SDL_CFLAGS="$SDL_CFLAGS $OSMESA_CFLAGS" SDL_CFLAGS="$SDL_CFLAGS $OSMESA_CFLAGS"
SDL_LIBS="$SDL_LIBS $OSMESA_LIBS" SDL_LIBS="$SDL_LIBS $OSMESA_LIBS"
......
...@@ -292,6 +292,8 @@ ...@@ -292,6 +292,8 @@
/* Enable OpenGL support */ /* Enable OpenGL support */
#undef SDL_VIDEO_OPENGL #undef SDL_VIDEO_OPENGL
#undef SDL_VIDEO_OPENGL_BGL
#undef SDL_VIDEO_OPENGL_CGL
#undef SDL_VIDEO_OPENGL_GLX #undef SDL_VIDEO_OPENGL_GLX
#undef SDL_VIDEO_OPENGL_WGL #undef SDL_VIDEO_OPENGL_WGL
#undef SDL_VIDEO_OPENGL_OSMESA #undef SDL_VIDEO_OPENGL_OSMESA
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
*/ */
#include "SDL_config.h" #include "SDL_config.h"
#if SDL_VIDEO_OPENGL #if SDL_VIDEO_RENDER_OGL
#include "SDL_video.h" #include "SDL_video.h"
#include "SDL_opengl.h" #include "SDL_opengl.h"
...@@ -197,6 +197,7 @@ GL_CreateRenderer(SDL_Window * window, Uint32 flags) ...@@ -197,6 +197,7 @@ GL_CreateRenderer(SDL_Window * window, Uint32 flags)
{ {
SDL_Renderer *renderer; SDL_Renderer *renderer;
GL_RenderData *data; GL_RenderData *data;
GLint value;
if (!(window->flags & SDL_WINDOW_OPENGL)) { if (!(window->flags & SDL_WINDOW_OPENGL)) {
if (SDL_RecreateWindow(window, window->flags | SDL_WINDOW_OPENGL) < 0) { if (SDL_RecreateWindow(window, window->flags | SDL_WINDOW_OPENGL) < 0) {
...@@ -261,10 +262,10 @@ GL_CreateRenderer(SDL_Window * window, Uint32 flags) ...@@ -261,10 +262,10 @@ GL_CreateRenderer(SDL_Window * window, Uint32 flags)
renderer->info.flags |= SDL_Renderer_PresentVSync; renderer->info.flags |= SDL_Renderer_PresentVSync;
} }
data->glGetIntegerv(GL_MAX_TEXTURE_SIZE, data->glGetIntegerv(GL_MAX_TEXTURE_SIZE, &value);
&renderer->info.max_texture_width); renderer->info.max_texture_width = value;
data->glGetIntegerv(GL_MAX_TEXTURE_SIZE, data->glGetIntegerv(GL_MAX_TEXTURE_SIZE, &value);
&renderer->info.max_texture_height); renderer->info.max_texture_height = value;
if (SDL_GL_ExtensionSupported("GL_ARB_texture_rectangle") if (SDL_GL_ExtensionSupported("GL_ARB_texture_rectangle")
|| SDL_GL_ExtensionSupported("GL_EXT_texture_rectangle")) { || SDL_GL_ExtensionSupported("GL_EXT_texture_rectangle")) {
...@@ -706,6 +707,6 @@ GL_DestroyRenderer(SDL_Renderer * renderer) ...@@ -706,6 +707,6 @@ GL_DestroyRenderer(SDL_Renderer * renderer)
SDL_free(renderer); SDL_free(renderer);
} }
#endif /* SDL_VIDEO_OPENGL */ #endif /* SDL_VIDEO_RENDER_OGL */
/* vi: set ts=4 sw=4 expandtab: */ /* vi: set ts=4 sw=4 expandtab: */
...@@ -276,7 +276,7 @@ SDL_VideoInit(const char *driver_name, Uint32 flags) ...@@ -276,7 +276,7 @@ SDL_VideoInit(const char *driver_name, Uint32 flags)
/* The software renderer is always available */ /* The software renderer is always available */
for (i = 0; i < _this->num_displays; ++i) { for (i = 0; i < _this->num_displays; ++i) {
#if SDL_VIDEO_OPENGL #if SDL_VIDEO_RENDER_OGL
SDL_AddRenderDriver(i, &GL_RenderDriver); SDL_AddRenderDriver(i, &GL_RenderDriver);
#endif #endif
if (_this->displays[i].num_render_drivers > 0) { if (_this->displays[i].num_render_drivers > 0) {
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
#ifndef _SDL_cocoaopengl_h #ifndef _SDL_cocoaopengl_h
#define _SDL_cocoaopengl_h #define _SDL_cocoaopengl_h
#if SDL_VIDEO_OPENGL #if SDL_VIDEO_OPENGL_CGL
struct SDL_GLDriverData struct SDL_GLDriverData
{ {
...@@ -44,7 +44,7 @@ extern int Cocoa_GL_GetSwapInterval(_THIS); ...@@ -44,7 +44,7 @@ extern int Cocoa_GL_GetSwapInterval(_THIS);
extern void Cocoa_GL_SwapWindow(_THIS, SDL_Window * window); extern void Cocoa_GL_SwapWindow(_THIS, SDL_Window * window);
extern void Cocoa_GL_DeleteContext(_THIS, SDL_GLContext context); extern void Cocoa_GL_DeleteContext(_THIS, SDL_GLContext context);
#endif /* SDL_VIDEO_OPENGL */ #endif /* SDL_VIDEO_OPENGL_CGL */
#endif /* _SDL_cocoaopengl_h */ #endif /* _SDL_cocoaopengl_h */
......
...@@ -25,14 +25,14 @@ ...@@ -25,14 +25,14 @@
/* NSOpenGL implementation of SDL OpenGL support */ /* NSOpenGL implementation of SDL OpenGL support */
#if SDL_VIDEO_OPENGL #if SDL_VIDEO_OPENGL_CGL
#include <OpenGL/CGLTypes.h> #include <OpenGL/CGLTypes.h>
#include "SDL_loadso.h" #include "SDL_loadso.h"
#include "SDL_opengl.h" #include "SDL_opengl.h"
#define DEFAULT_OPENGL_PATH "/System/Library/Frameworks/OpenGL.framework/Libraries/libGL.dylib" #define DEFAULT_OPENGL "/System/Library/Frameworks/OpenGL.framework/Libraries/libGL.dylib"
/* This is implemented in Mac OS X 10.3 and above */ /* This is implemented in Mac OS X 10.3 and above */
#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_3 #if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_3
...@@ -57,7 +57,10 @@ Cocoa_GL_LoadLibrary(_THIS, const char *path) ...@@ -57,7 +57,10 @@ Cocoa_GL_LoadLibrary(_THIS, const char *path)
} }
} }
if (path == NULL) { if (path == NULL) {
path = DEFAULT_OPENGL_PATH; path = SDL_getenv("SDL_OPENGL_LIBRARY");
}
if (path == NULL) {
path = DEFAULT_OPENGL;
} }
_this->gl_config.dll_handle = SDL_LoadObject(path); _this->gl_config.dll_handle = SDL_LoadObject(path);
if (!_this->gl_config.dll_handle) { if (!_this->gl_config.dll_handle) {
...@@ -87,19 +90,6 @@ Cocoa_GL_UnloadLibrary(_THIS) ...@@ -87,19 +90,6 @@ Cocoa_GL_UnloadLibrary(_THIS)
} }
} }
static void
Cocoa_GL_Shutdown(_THIS)
{
if (!_this->gl_data || (--_this->gl_data->initialized > 0)) {
return;
}
Cocoa_GL_UnloadLibrary(_this);
SDL_free(_this->gl_data);
_this->gl_data = NULL;
}
static int static int
Cocoa_GL_Initialize(_THIS) Cocoa_GL_Initialize(_THIS)
{ {
...@@ -124,6 +114,19 @@ Cocoa_GL_Initialize(_THIS) ...@@ -124,6 +114,19 @@ Cocoa_GL_Initialize(_THIS)
return 0; return 0;
} }
static void
Cocoa_GL_Shutdown(_THIS)
{
if (!_this->gl_data || (--_this->gl_data->initialized > 0)) {
return;
}
Cocoa_GL_UnloadLibrary(_this);
SDL_free(_this->gl_data);
_this->gl_data = NULL;
}
int int
Cocoa_GL_SetupWindow(_THIS, SDL_Window * window) Cocoa_GL_SetupWindow(_THIS, SDL_Window * window)
{ {
...@@ -352,6 +355,6 @@ Cocoa_GL_DeleteContext(_THIS, SDL_GLContext context) ...@@ -352,6 +355,6 @@ Cocoa_GL_DeleteContext(_THIS, SDL_GLContext context)
[pool release]; [pool release];
} }
#endif /* SDL_VIDEO_OPENGL */ #endif /* SDL_VIDEO_OPENGL_CGL */
/* vi: set ts=4 sw=4 expandtab: */ /* vi: set ts=4 sw=4 expandtab: */
...@@ -87,7 +87,7 @@ Cocoa_CreateDevice(int devindex) ...@@ -87,7 +87,7 @@ Cocoa_CreateDevice(int devindex)
device->SetWindowGrab = Cocoa_SetWindowGrab; device->SetWindowGrab = Cocoa_SetWindowGrab;
device->DestroyWindow = Cocoa_DestroyWindow; device->DestroyWindow = Cocoa_DestroyWindow;
device->GetWindowWMInfo = Cocoa_GetWindowWMInfo; device->GetWindowWMInfo = Cocoa_GetWindowWMInfo;
#ifdef SDL_VIDEO_OPENGL #ifdef SDL_VIDEO_OPENGL_CGL
device->GL_LoadLibrary = Cocoa_GL_LoadLibrary; device->GL_LoadLibrary = Cocoa_GL_LoadLibrary;
device->GL_GetProcAddress = Cocoa_GL_GetProcAddress; device->GL_GetProcAddress = Cocoa_GL_GetProcAddress;
device->GL_CreateContext = Cocoa_GL_CreateContext; device->GL_CreateContext = Cocoa_GL_CreateContext;
......
...@@ -385,7 +385,7 @@ Cocoa_CreateWindow(_THIS, SDL_Window * window) ...@@ -385,7 +385,7 @@ Cocoa_CreateWindow(_THIS, SDL_Window * window)
[nswindow release]; [nswindow release];
return -1; return -1;
} }
#ifdef SDL_VIDEO_OPENGL #ifdef SDL_VIDEO_OPENGL_CGL
if (window->flags & SDL_WINDOW_OPENGL) { if (window->flags & SDL_WINDOW_OPENGL) {
if (Cocoa_GL_SetupWindow(_this, window) < 0) { if (Cocoa_GL_SetupWindow(_this, window) < 0) {
Cocoa_DestroyWindow(_this, window); Cocoa_DestroyWindow(_this, window);
...@@ -535,7 +535,7 @@ Cocoa_DestroyWindow(_THIS, SDL_Window * window) ...@@ -535,7 +535,7 @@ Cocoa_DestroyWindow(_THIS, SDL_Window * window)
SDL_WindowData *data = (SDL_WindowData *) window->driverdata; SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
if (data) { if (data) {
#ifdef SDL_VIDEO_OPENGL #ifdef SDL_VIDEO_OPENGL_CGL
if (window->flags & SDL_WINDOW_OPENGL) { if (window->flags & SDL_WINDOW_OPENGL) {
Cocoa_GL_CleanupWindow(_this, window); Cocoa_GL_CleanupWindow(_this, window);
} }
......
...@@ -25,10 +25,10 @@ ...@@ -25,10 +25,10 @@
/* WGL implementation of SDL OpenGL support */ /* WGL implementation of SDL OpenGL support */
#if SDL_VIDEO_OPENGL #if SDL_VIDEO_OPENGL_WGL
#include "SDL_opengl.h" #include "SDL_opengl.h"
#define DEFAULT_OPENGL_PATH "OPENGL32.DLL" #define DEFAULT_OPENGL "OPENGL32.DLL"
int int
...@@ -47,7 +47,10 @@ WIN_GL_LoadLibrary(_THIS, const char *path) ...@@ -47,7 +47,10 @@ WIN_GL_LoadLibrary(_THIS, const char *path)
} }
} }
if (path == NULL) { if (path == NULL) {
path = DEFAULT_OPENGL_PATH; path = SDL_getenv("SDL_OPENGL_LIBRARY");
}
if (path == NULL) {
path = DEFAULT_OPENGL;
} }
wpath = WIN_UTF8ToString(path); wpath = WIN_UTF8ToString(path);
handle = LoadLibrary(wpath); handle = LoadLibrary(wpath);
...@@ -257,19 +260,6 @@ WIN_GL_InitExtensions(_THIS) ...@@ -257,19 +260,6 @@ WIN_GL_InitExtensions(_THIS)
WIN_PumpEvents(_this); WIN_PumpEvents(_this);
} }
static void
WIN_GL_Shutdown(_THIS)
{
if (!_this->gl_data || (--_this->gl_data->initialized > 0)) {
return;
}
WIN_GL_UnloadLibrary(_this);
SDL_free(_this->gl_data);
_this->gl_data = NULL;
}
static int static int
WIN_GL_Initialize(_THIS) WIN_GL_Initialize(_THIS)
{ {
...@@ -298,6 +288,19 @@ WIN_GL_Initialize(_THIS) ...@@ -298,6 +288,19 @@ WIN_GL_Initialize(_THIS)
return 0; return 0;
} }
static void
WIN_GL_Shutdown(_THIS)
{
if (!_this->gl_data || (--_this->gl_data->initialized > 0)) {
return;
}
WIN_GL_UnloadLibrary(_this);
SDL_free(_this->gl_data);
_this->gl_data = NULL;
}
int int
WIN_GL_SetupWindow(_THIS, SDL_Window * window) WIN_GL_SetupWindow(_THIS, SDL_Window * window)
{ {
...@@ -479,7 +482,6 @@ WIN_GL_DeleteContext(_THIS, SDL_GLContext context) ...@@ -479,7 +482,6 @@ WIN_GL_DeleteContext(_THIS, SDL_GLContext context)
_this->gl_data->wglDeleteContext((HGLRC) context); _this->gl_data->wglDeleteContext((HGLRC) context);
} }
#endif /* SDL_VIDEO_OPENGL */ #endif /* SDL_VIDEO_OPENGL_WGL */
/* vi: set ts=4 sw=4 expandtab: */ /* vi: set ts=4 sw=4 expandtab: */
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
#ifndef _SDL_win32opengl_h #ifndef _SDL_win32opengl_h
#define _SDL_win32opengl_h #define _SDL_win32opengl_h
#if SDL_VIDEO_OPENGL #if SDL_VIDEO_OPENGL_WGL
struct SDL_GLDriverData struct SDL_GLDriverData
{ {
...@@ -120,7 +120,7 @@ extern void WIN_GL_DeleteContext(_THIS, SDL_GLContext context); ...@@ -120,7 +120,7 @@ extern void WIN_GL_DeleteContext(_THIS, SDL_GLContext context);
#define WGL_SAMPLES_ARB 0x2042 #define WGL_SAMPLES_ARB 0x2042
#endif #endif
#endif /* SDL_VIDEO_OPENGL */ #endif /* SDL_VIDEO_OPENGL_WGL */
#endif /* _SDL_win32opengl_h */ #endif /* _SDL_win32opengl_h */
......
...@@ -123,7 +123,7 @@ WIN_CreateDevice(int devindex) ...@@ -123,7 +123,7 @@ WIN_CreateDevice(int devindex)
device->SetWindowGrab = WIN_SetWindowGrab; device->SetWindowGrab = WIN_SetWindowGrab;
device->DestroyWindow = WIN_DestroyWindow; device->DestroyWindow = WIN_DestroyWindow;
device->GetWindowWMInfo = WIN_GetWindowWMInfo; device->GetWindowWMInfo = WIN_GetWindowWMInfo;
#ifdef SDL_VIDEO_OPENGL #ifdef SDL_VIDEO_OPENGL_WGL
device->GL_LoadLibrary = WIN_GL_LoadLibrary; device->GL_LoadLibrary = WIN_GL_LoadLibrary;
device->GL_GetProcAddress = WIN_GL_GetProcAddress; device->GL_GetProcAddress = WIN_GL_GetProcAddress;
device->GL_CreateContext = WIN_GL_CreateContext; device->GL_CreateContext = WIN_GL_CreateContext;
......
...@@ -213,7 +213,7 @@ WIN_CreateWindow(_THIS, SDL_Window * window) ...@@ -213,7 +213,7 @@ WIN_CreateWindow(_THIS, SDL_Window * window)
DestroyWindow(hwnd); DestroyWindow(hwnd);
return -1; return -1;
} }
#ifdef SDL_VIDEO_OPENGL #ifdef SDL_VIDEO_OPENGL_WGL
if (window->flags & SDL_WINDOW_OPENGL) { if (window->flags & SDL_WINDOW_OPENGL) {
if (WIN_GL_SetupWindow(_this, window) < 0) { if (WIN_GL_SetupWindow(_this, window) < 0) {
WIN_DestroyWindow(_this, window); WIN_DestroyWindow(_this, window);
...@@ -419,7 +419,7 @@ WIN_DestroyWindow(_THIS, SDL_Window * window) ...@@ -419,7 +419,7 @@ WIN_DestroyWindow(_THIS, SDL_Window * window)
SDL_WindowData *data = (SDL_WindowData *) window->driverdata; SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
if (data) { if (data) {
#ifdef SDL_VIDEO_OPENGL #ifdef SDL_VIDEO_OPENGL_WGL
if (window->flags & SDL_WINDOW_OPENGL) { if (window->flags & SDL_WINDOW_OPENGL) {
WIN_GL_CleanupWindow(_this, window); WIN_GL_CleanupWindow(_this, window);
} }
......
This diff is collapsed.
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2006 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
#ifndef _SDL_x11opengl_h
#define _SDL_x11opengl_h
#if SDL_VIDEO_OPENGL_GLX
#include "SDL_opengl.h"
#include <GL/glx.h>
struct SDL_GLDriverData
{
int initialized;
SDL_bool HAS_GLX_EXT_visual_rating;
void *(*glXGetProcAddress) (const GLubyte * procName);
XVisualInfo *(*glXChooseVisual)
(Display * dpy, int screen, int *attribList);
GLXContext(*glXCreateContext)
(Display * dpy, XVisualInfo * vis, GLXContext shareList, Bool direct);
void (*glXDestroyContext)
(Display * dpy, GLXContext ctx);
Bool(*glXMakeCurrent)
(Display * dpy, GLXDrawable drawable, GLXContext ctx);
void (*glXSwapBuffers)
(Display * dpy, GLXDrawable drawable);
int (*glXGetConfig)
(Display * dpy, XVisualInfo * visual_info, int attrib, int *value);
int (*glXSwapIntervalSGI) (int interval);
GLint(*glXSwapIntervalMESA) (unsigned interval);
GLint(*glXGetSwapIntervalMESA) (void);
};
/* OpenGL functions */
extern int X11_GL_LoadLibrary(_THIS, const char *path);
extern void *X11_GL_GetProcAddress(_THIS, const char *proc);
extern int X11_GL_Initialize(_THIS);
extern void X11_GL_Shutdown(_THIS);
extern XVisualInfo *X11_GL_GetVisual(_THIS, Display * display, int screen);
extern SDL_GLContext X11_GL_CreateContext(_THIS, SDL_Window * window);
extern int X11_GL_MakeCurrent(_THIS, SDL_Window * window,
SDL_GLContext context);
extern int X11_GL_SetSwapInterval(_THIS, int interval);
extern int X11_GL_GetSwapInterval(_THIS);
extern void X11_GL_SwapWindow(_THIS, SDL_Window * window);
extern void X11_GL_DeleteContext(_THIS, SDL_GLContext context);
#endif /* SDL_VIDEO_OPENGL_GLX */
#endif /* _SDL_x11opengl_h */
/* vi: set ts=4 sw=4 expandtab: */
This diff is collapsed.
...@@ -186,8 +186,7 @@ X11_CreateDevice(int devindex) ...@@ -186,8 +186,7 @@ X11_CreateDevice(int devindex)
device->SetWindowGrab = X11_SetWindowGrab; device->SetWindowGrab = X11_SetWindowGrab;
device->DestroyWindow = X11_DestroyWindow; device->DestroyWindow = X11_DestroyWindow;
device->GetWindowWMInfo = X11_GetWindowWMInfo; device->GetWindowWMInfo = X11_GetWindowWMInfo;
/* #ifdef SDL_VIDEO_OPENGL_GLX
#ifdef SDL_VIDEO_OPENGL
device->GL_LoadLibrary = X11_GL_LoadLibrary; device->GL_LoadLibrary = X11_GL_LoadLibrary;
device->GL_GetProcAddress = X11_GL_GetProcAddress; device->GL_GetProcAddress = X11_GL_GetProcAddress;
device->GL_CreateContext = X11_GL_CreateContext; device->GL_CreateContext = X11_GL_CreateContext;
...@@ -197,7 +196,6 @@ X11_CreateDevice(int devindex) ...@@ -197,7 +196,6 @@ X11_CreateDevice(int devindex)
device->GL_SwapWindow = X11_GL_SwapWindow; device->GL_SwapWindow = X11_GL_SwapWindow;
device->GL_DeleteContext = X11_GL_DeleteContext; device->GL_DeleteContext = X11_GL_DeleteContext;
#endif #endif
*/
device->free = X11_DeleteDevice; device->free = X11_DeleteDevice;
......
...@@ -53,7 +53,7 @@ ...@@ -53,7 +53,7 @@
#include "SDL_x11keyboard.h" #include "SDL_x11keyboard.h"
#include "SDL_x11modes.h" #include "SDL_x11modes.h"
#include "SDL_x11mouse.h" #include "SDL_x11mouse.h"
//#include "SDL_x11opengl.h" #include "SDL_x11opengl.h"
#include "SDL_x11window.h" #include "SDL_x11window.h"
/* Private display data */ /* Private display data */
......
...@@ -135,7 +135,7 @@ X11_CreateWindow(_THIS, SDL_Window * window) ...@@ -135,7 +135,7 @@ X11_CreateWindow(_THIS, SDL_Window * window)
{ {
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
SDL_DisplayData *displaydata = SDL_DisplayData *displaydata =
(SDL_DisplayData *) SDL_CurrentDisplay.driverdata; (SDL_DisplayData *) SDL_GetDisplayFromWindow(window)->driverdata;
Visual *visual; Visual *visual;
int depth; int depth;
XSetWindowAttributes xattr; XSetWindowAttributes xattr;
...@@ -153,9 +153,23 @@ X11_CreateWindow(_THIS, SDL_Window * window) ...@@ -153,9 +153,23 @@ X11_CreateWindow(_THIS, SDL_Window * window)
} }
*/ */
#endif #endif
#ifdef SDL_VIDEO_OPENGL_GLX
if (window->flags & SDL_WINDOW_OPENGL) { if (window->flags & SDL_WINDOW_OPENGL) {
/* FIXME: get the glx visual */ XVisualInfo *vinfo;
} else {
if (X11_GL_Initialize(_this) < 0) {
return -1;
}
vinfo = X11_GL_GetVisual(_this, data->display, displaydata->screen);
if (!vinfo) {
return -1;
}
visual = vinfo->visual;
depth = vinfo->depth;
XFree(vinfo);
} else
#endif
{
visual = displaydata->visual; visual = displaydata->visual;
depth = displaydata->depth; depth = displaydata->depth;
} }
...@@ -203,6 +217,15 @@ X11_CreateWindow(_THIS, SDL_Window * window) ...@@ -203,6 +217,15 @@ X11_CreateWindow(_THIS, SDL_Window * window)
window->w, window->h, 0, depth, InputOutput, visual, window->w, window->h, 0, depth, InputOutput, visual,
(CWOverrideRedirect | CWBackPixel | CWBorderPixel | (CWOverrideRedirect | CWBackPixel | CWBorderPixel |
CWColormap), &xattr); CWColormap), &xattr);
if (!w) {
#ifdef SDL_VIDEO_OPENGL_GLX
if (window->flags & SDL_WINDOW_OPENGL) {
X11_GL_Shutdown(_this);
}
#endif
SDL_SetError("Couldn't create window");
return -1;
}
sizehints = XAllocSizeHints(); sizehints = XAllocSizeHints();
if (sizehints) { if (sizehints) {
...@@ -370,27 +393,26 @@ X11_CreateWindow(_THIS, SDL_Window * window) ...@@ -370,27 +393,26 @@ X11_CreateWindow(_THIS, SDL_Window * window)
/* Finally, show the window */ /* Finally, show the window */
if (window->flags & SDL_WINDOW_SHOWN) { if (window->flags & SDL_WINDOW_SHOWN) {
XEvent event;
XMapRaised(data->display, w); XMapRaised(data->display, w);
do {
XCheckWindowEvent(data->display, w, StructureNotifyMask, &event);
} while (event.type != MapNotify);
} }
XSync(data->display, False);
if (SetupWindowData(_this, window, w, SDL_TRUE) < 0) { if (SetupWindowData(_this, window, w, SDL_TRUE) < 0) {
#ifdef SDL_VIDEO_OPENGL_GLX
if (window->flags & SDL_WINDOW_OPENGL) {
X11_GL_Shutdown(_this);
}
#endif
XDestroyWindow(data->display, w); XDestroyWindow(data->display, w);
return -1; return -1;
} }
X11_SetWindowTitle(_this, window); X11_SetWindowTitle(_this, window);
#ifdef SDL_VIDEO_OPENGL
/*
if (window->flags & SDL_WINDOW_OPENGL) {
if (X11_GL_SetupWindow(_this, window) < 0) {
X11_DestroyWindow(_this, window);
return -1;
}
}
*/
#endif
return 0; return 0;
} }
...@@ -486,7 +508,7 @@ X11_SetWindowPosition(_THIS, SDL_Window * window) ...@@ -486,7 +508,7 @@ X11_SetWindowPosition(_THIS, SDL_Window * window)
{ {
SDL_WindowData *data = (SDL_WindowData *) window->driverdata; SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
SDL_DisplayData *displaydata = SDL_DisplayData *displaydata =
(SDL_DisplayData *) SDL_CurrentDisplay.driverdata; (SDL_DisplayData *) SDL_GetDisplayFromWindow(window)->driverdata;
Display *display = data->videodata->display; Display *display = data->videodata->display;
int x, y; int x, y;
...@@ -576,12 +598,10 @@ X11_DestroyWindow(_THIS, SDL_Window * window) ...@@ -576,12 +598,10 @@ X11_DestroyWindow(_THIS, SDL_Window * window)
if (data) { if (data) {
Display *display = data->videodata->display; Display *display = data->videodata->display;
#ifdef SDL_VIDEO_OPENGL #ifdef SDL_VIDEO_OPENGL_GLX
/* if (window->flags & SDL_WINDOW_OPENGL) {
if (window->flags & SDL_WINDOW_OPENGL) { X11_GL_Shutdown(_this);
X11_GL_CleanupWindow(_this, window); }
}
*/
#endif #endif
#ifdef X_HAVE_UTF8_STRING #ifdef X_HAVE_UTF8_STRING
if (data->ic) { if (data->ic) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment