src/video/x11/SDL_x11gl_c.h
author Sam Lantinga <slouken@lokigames.com>
Sat, 14 Jul 2001 19:11:26 +0000
changeset 110 7edee9f0f2cc
parent 0 74212992fb08
child 252 e8157fcb3114
permissions -rw-r--r--
SDL GL dynamic loading fix for OpenBSD
slouken@0
     1
/*
slouken@0
     2
    SDL - Simple DirectMedia Layer
slouken@0
     3
    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
slouken@0
     4
slouken@0
     5
    This library is free software; you can redistribute it and/or
slouken@0
     6
    modify it under the terms of the GNU Library General Public
slouken@0
     7
    License as published by the Free Software Foundation; either
slouken@0
     8
    version 2 of the License, or (at your option) any later version.
slouken@0
     9
slouken@0
    10
    This library is distributed in the hope that it will be useful,
slouken@0
    11
    but WITHOUT ANY WARRANTY; without even the implied warranty of
slouken@0
    12
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
slouken@0
    13
    Library General Public License for more details.
slouken@0
    14
slouken@0
    15
    You should have received a copy of the GNU Library General Public
slouken@0
    16
    License along with this library; if not, write to the Free
slouken@0
    17
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
slouken@0
    18
slouken@0
    19
    Sam Lantinga
slouken@0
    20
    slouken@devolution.com
slouken@0
    21
*/
slouken@0
    22
slouken@0
    23
#ifdef SAVE_RCSID
slouken@0
    24
static char rcsid =
slouken@0
    25
 "@(#) $Id$";
slouken@0
    26
#endif
slouken@0
    27
slouken@0
    28
#ifdef HAVE_OPENGL
slouken@0
    29
#include <GL/glx.h>
slouken@0
    30
#include <dlfcn.h>
slouken@110
    31
#if defined(__OpenBSD__) && !defined(__ELF__)
slouken@110
    32
#define dlsym(x,y) dlsym(x, "_" y)
slouken@110
    33
#endif
slouken@0
    34
#endif
slouken@0
    35
#include "SDL_sysvideo.h"
slouken@0
    36
slouken@0
    37
struct SDL_PrivateGLData {
slouken@0
    38
    int gl_active; /* to stop switching drivers while we have a valid context */
slouken@0
    39
slouken@0
    40
#ifdef HAVE_OPENGL
slouken@0
    41
    GLXContext glx_context;	/* Current GL context */
slouken@0
    42
    XVisualInfo* glx_visualinfo; /* XVisualInfo* returned by glXChooseVisual */
slouken@0
    43
slouken@0
    44
    void * (*glXGetProcAddress)(const GLubyte *procName);
slouken@0
    45
slouken@0
    46
    XVisualInfo* (*glXChooseVisual)
slouken@0
    47
		( Display*		dpy,
slouken@0
    48
		  int			screen,
slouken@0
    49
		  int*		attribList );
slouken@0
    50
slouken@0
    51
    GLXContext (*glXCreateContext)
slouken@0
    52
		( Display*		dpy,
slouken@0
    53
		  XVisualInfo*	vis,
slouken@0
    54
		  GLXContext		shareList,
slouken@0
    55
		  Bool		direct );
slouken@0
    56
slouken@0
    57
    void (*glXDestroyContext)
slouken@0
    58
		( Display* 		dpy,
slouken@0
    59
		  GLXContext		ctx );
slouken@0
    60
slouken@0
    61
    Bool (*glXMakeCurrent)
slouken@0
    62
		( Display*		dpy,
slouken@0
    63
		  GLXDrawable		drawable,
slouken@0
    64
		  GLXContext		ctx );
slouken@0
    65
slouken@0
    66
    void (*glXSwapBuffers)
slouken@0
    67
		( Display*		dpy,
slouken@0
    68
		  GLXDrawable		drawable );
slouken@0
    69
slouken@0
    70
    int (*glXGetConfig)
slouken@0
    71
	 ( Display* dpy,
slouken@0
    72
	   XVisualInfo* visual_info,
slouken@0
    73
	   int attrib,
slouken@0
    74
	   int* value );
slouken@0
    75
slouken@0
    76
    void (*glXReleaseBuffersMESA)
slouken@0
    77
	 ( Display* dpy,
slouken@0
    78
	   GLXDrawable drawable );
slouken@0
    79
slouken@0
    80
#endif /* HAVE_OPENGL */
slouken@0
    81
};
slouken@0
    82
slouken@0
    83
/* Old variable names */
slouken@0
    84
#define gl_active		(this->gl_data->gl_active)
slouken@0
    85
#define glx_context		(this->gl_data->glx_context)
slouken@0
    86
#define glx_visualinfo		(this->gl_data->glx_visualinfo)
slouken@0
    87
slouken@0
    88
/* OpenGL functions */
slouken@0
    89
extern XVisualInfo *X11_GL_GetVisual(_THIS);
slouken@0
    90
extern int X11_GL_CreateWindow(_THIS, int w, int h);
slouken@0
    91
extern int X11_GL_CreateContext(_THIS);
slouken@0
    92
extern void X11_GL_Shutdown(_THIS);
slouken@0
    93
#ifdef HAVE_OPENGL
slouken@0
    94
extern int X11_GL_MakeCurrent(_THIS);
slouken@0
    95
extern int X11_GL_GetAttribute(_THIS, SDL_GLattr attrib, int* value);
slouken@0
    96
extern void X11_GL_SwapBuffers(_THIS);
slouken@0
    97
extern int X11_GL_LoadLibrary(_THIS, const char* path);
slouken@0
    98
extern void *X11_GL_GetProcAddress(_THIS, const char* proc);
slouken@0
    99
#endif
slouken@0
   100
extern void X11_GL_UnloadLibrary(_THIS);
slouken@0
   101