src/video/x11/SDL_x11opengl.h
author Michael Sartain <mikesart@valvesoftware.com>
Thu, 11 Oct 2012 09:41:43 -0700
changeset 6570 45855398762c
parent 6382 64d54101773a
child 6846 97eb26e2dee0
permissions -rw-r--r--
Add GLX_X_VISUAL_TYPE_EXT so created window will use DirectColor if available (instead of TrueColor). Our new X11 window was being created with the TrueColor attribute, and trying to set the gamma on that would fail. This change checks for the visual_info extension, and uses that to ask for DirectColor if available.
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;
6570
45855398762c Add GLX_X_VISUAL_TYPE_EXT so created window will use DirectColor if available (instead of TrueColor).
Michael Sartain <mikesart@valvesoftware.com>
parents: 6382
diff changeset
    33
    SDL_bool HAS_GLX_EXT_visual_info;
6382
64d54101773a Add support for (GLX|WGL)_EXT_swap_control_tear.
Ryan C. Gordon <icculus@icculus.org>
parents: 6138
diff changeset
    34
    SDL_bool HAS_GLX_EXT_swap_control_tear;
1952
420716272158 Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    35
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
    36
    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
    37
    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
    38
    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
    39
    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
    40
    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
    41
    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
    42
    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
    43
    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
    44
    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
    45
    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
    46
    int (*glXGetSwapIntervalMESA) (void);
1952
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
420716272158 Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    49
/* OpenGL functions */
420716272158 Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    50
extern int X11_GL_LoadLibrary(_THIS, const char *path);
420716272158 Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    51
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
    52
extern void X11_GL_UnloadLibrary(_THIS);
1952
420716272158 Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    53
extern XVisualInfo *X11_GL_GetVisual(_THIS, Display * display, int screen);
420716272158 Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    54
extern SDL_GLContext X11_GL_CreateContext(_THIS, SDL_Window * window);
420716272158 Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    55
extern int X11_GL_MakeCurrent(_THIS, SDL_Window * window,
420716272158 Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    56
                              SDL_GLContext context);
420716272158 Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    57
extern int X11_GL_SetSwapInterval(_THIS, int interval);
420716272158 Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    58
extern int X11_GL_GetSwapInterval(_THIS);
420716272158 Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    59
extern void X11_GL_SwapWindow(_THIS, SDL_Window * window);
420716272158 Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    60
extern void X11_GL_DeleteContext(_THIS, SDL_GLContext context);
420716272158 Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    61
420716272158 Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    62
#endif /* SDL_VIDEO_OPENGL_GLX */
420716272158 Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    63
420716272158 Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    64
#endif /* _SDL_x11opengl_h */
420716272158 Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    65
420716272158 Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    66
/* vi: set ts=4 sw=4 expandtab: */