src/video/x11/SDL_x11opengl.h
author Ryan C. Gordon <icculus@icculus.org>
Wed, 01 Aug 2012 20:29:36 -0400
changeset 6382 64d54101773a
parent 6138 4c64952a58fb
child 6570 45855398762c
permissions -rwxr-xr-x
Add support for (GLX|WGL)_EXT_swap_control_tear. This required a small public API change: SDL_GL_SetSwapInterval() now accepts negative values, and SDL_GL_GetSwapInterval() doesn't report errors anymore (if it can't work, it'll return zero as a reasonable default). If you need to test for errors, such as a lack of swap_control_tear support, check the results of SDL_GL_SetSwapInterval() when you set your desired value.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1952
420716272158 Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     1
/*
5535
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
     2
  Simple DirectMedia Layer
6138
4c64952a58fb Happy New Year!
Sam Lantinga <slouken@libsdl.org>
parents: 5630
diff changeset
     3
  Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
1952
420716272158 Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     4
5535
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
     5
  This software is provided 'as-is', without any express or implied
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
     6
  warranty.  In no event will the authors be held liable for any damages
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
     7
  arising from the use of this software.
1952
420716272158 Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     8
5535
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
     9
  Permission is granted to anyone to use this software for any purpose,
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    10
  including commercial applications, and to alter it and redistribute it
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    11
  freely, subject to the following restrictions:
1952
420716272158 Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    12
5535
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    13
  1. The origin of this software must not be misrepresented; you must not
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    14
     claim that you wrote the original software. If you use this software
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    15
     in a product, an acknowledgment in the product documentation would be
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    16
     appreciated but is not required.
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    17
  2. Altered source versions must be plainly marked as such, and must not be
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    18
     misrepresented as being the original software.
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    19
  3. This notice may not be removed or altered from any source distribution.
1952
420716272158 Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    20
*/
420716272158 Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    21
#include "SDL_config.h"
420716272158 Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    22
420716272158 Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    23
#ifndef _SDL_x11opengl_h
420716272158 Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    24
#define _SDL_x11opengl_h
420716272158 Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    25
420716272158 Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    26
#if SDL_VIDEO_OPENGL_GLX
420716272158 Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    27
#include "SDL_opengl.h"
420716272158 Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    28
#include <GL/glx.h>
420716272158 Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    29
420716272158 Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    30
struct SDL_GLDriverData
420716272158 Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    31
{
420716272158 Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    32
    SDL_bool HAS_GLX_EXT_visual_rating;
6382
64d54101773a Add support for (GLX|WGL)_EXT_swap_control_tear.
Ryan C. Gordon <icculus@icculus.org>
parents: 6138
diff changeset
    33
    SDL_bool HAS_GLX_EXT_swap_control_tear;
1952
420716272158 Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    34
5572
32a785da3f49 Added support for GLX_EXT_swap_control, and cleaned up some other extensions.
Ryan C. Gordon <icculus@icculus.org>
parents: 5535
diff changeset
    35
    void *(*glXGetProcAddress) (const GLubyte*);
32a785da3f49 Added support for GLX_EXT_swap_control, and cleaned up some other extensions.
Ryan C. Gordon <icculus@icculus.org>
parents: 5535
diff changeset
    36
    XVisualInfo *(*glXChooseVisual) (Display*,int,int*);
32a785da3f49 Added support for GLX_EXT_swap_control, and cleaned up some other extensions.
Ryan C. Gordon <icculus@icculus.org>
parents: 5535
diff changeset
    37
    GLXContext (*glXCreateContext) (Display*,XVisualInfo*,GLXContext,Bool);
32a785da3f49 Added support for GLX_EXT_swap_control, and cleaned up some other extensions.
Ryan C. Gordon <icculus@icculus.org>
parents: 5535
diff changeset
    38
    void (*glXDestroyContext) (Display*, GLXContext);
32a785da3f49 Added support for GLX_EXT_swap_control, and cleaned up some other extensions.
Ryan C. Gordon <icculus@icculus.org>
parents: 5535
diff changeset
    39
    Bool(*glXMakeCurrent) (Display*,GLXDrawable,GLXContext);
32a785da3f49 Added support for GLX_EXT_swap_control, and cleaned up some other extensions.
Ryan C. Gordon <icculus@icculus.org>
parents: 5535
diff changeset
    40
    void (*glXSwapBuffers) (Display*, GLXDrawable);
32a785da3f49 Added support for GLX_EXT_swap_control, and cleaned up some other extensions.
Ryan C. Gordon <icculus@icculus.org>
parents: 5535
diff changeset
    41
    void (*glXQueryDrawable) (Display*,GLXDrawable,int,unsigned int*);
5630
39e74dab5ebb Apparently glXSwapIntervalEXT() _does_ return a value.
Ryan C. Gordon <icculus@icculus.org>
parents: 5572
diff changeset
    42
    int (*glXSwapIntervalEXT) (Display*,GLXDrawable,int);
5572
32a785da3f49 Added support for GLX_EXT_swap_control, and cleaned up some other extensions.
Ryan C. Gordon <icculus@icculus.org>
parents: 5535
diff changeset
    43
    int (*glXSwapIntervalSGI) (int);
32a785da3f49 Added support for GLX_EXT_swap_control, and cleaned up some other extensions.
Ryan C. Gordon <icculus@icculus.org>
parents: 5535
diff changeset
    44
    int (*glXSwapIntervalMESA) (int);
32a785da3f49 Added support for GLX_EXT_swap_control, and cleaned up some other extensions.
Ryan C. Gordon <icculus@icculus.org>
parents: 5535
diff changeset
    45
    int (*glXGetSwapIntervalMESA) (void);
1952
420716272158 Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    46
};
420716272158 Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    47
420716272158 Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    48
/* OpenGL functions */
420716272158 Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    49
extern int X11_GL_LoadLibrary(_THIS, const char *path);
420716272158 Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    50
extern void *X11_GL_GetProcAddress(_THIS, const char *proc);
3057
089a77aebb7d Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
    51
extern void X11_GL_UnloadLibrary(_THIS);
1952
420716272158 Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    52
extern XVisualInfo *X11_GL_GetVisual(_THIS, Display * display, int screen);
420716272158 Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    53
extern SDL_GLContext X11_GL_CreateContext(_THIS, SDL_Window * window);
420716272158 Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    54
extern int X11_GL_MakeCurrent(_THIS, SDL_Window * window,
420716272158 Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    55
                              SDL_GLContext context);
420716272158 Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    56
extern int X11_GL_SetSwapInterval(_THIS, int interval);
420716272158 Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    57
extern int X11_GL_GetSwapInterval(_THIS);
420716272158 Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    58
extern void X11_GL_SwapWindow(_THIS, SDL_Window * window);
420716272158 Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    59
extern void X11_GL_DeleteContext(_THIS, SDL_GLContext context);
420716272158 Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    60
420716272158 Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    61
#endif /* SDL_VIDEO_OPENGL_GLX */
420716272158 Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    62
420716272158 Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    63
#endif /* _SDL_x11opengl_h */
420716272158 Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    64
420716272158 Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    65
/* vi: set ts=4 sw=4 expandtab: */