Commit graph

56 commits

Author SHA1 Message Date
Ryan C. Gordon
2cd5fc4e97 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.
2012-08-01 20:29:36 -04:00
Ryan C. Gordon
82ebf2d4ff Fixed some minor compiler warnings.
--HG--
extra : rebase_source : 9466732b4e5ab87e92e8eb9e2377aa5405bdc23b
2012-07-20 13:33:15 -04:00
Sam Lantinga
1277706b2b More OpenGL ES fixes from Scott Percival 2012-07-19 09:36:58 -07:00
Sam Lantinga
b3219a6db1 Improved simultaneous support for OpenGL and OpenGL ES
From Scott Percival

Okay, I think I have something for this. Tested it on GL and GLES
machines, it seems to work okay.

- Add a new SDL GL attribute SDL_GL_CONTEXT_EGL:
        - Only useful for the X11 video driver at the moment
        - Set to 1 for an EGL context, 0 to use the default for the video driver
        - Default is 0, unless library is built for EGL only
        - Should be set after SDL init, but before window/context
creation (i.e. same place you'd specify attributes for major/minor GL
version)
- After a lot of agony pondering the least-terrible way to go about
it, made it so that X11_GL_LoadLibrary and X11_GLES_LoadLibrary check
SDL_GL_CONTEXT_EGL. If no GL context exists yet, and the attribute
choice doesn't match with the checking function, then it changes all
the function pointers in the video driver and passes control on to the
new LoadLibrary method.
- Likewise, make X11_CreateWindow check this attribute before firing
off a call to X11_GL_GetVisual/X11_GLES_GetVisual
- Added a sanity check to the start of X11_GL_LoadLibrary
- Tidied up SDL_x11opengles.h
- Moved ownership of the gles_data structure over to
X11_GLES_LoadLibrary/UnloadLibrary
- Should incorporate the 3 fixes posted by Andre Heider

This is obviously quite a bit to take in, but is (at least) a proof of
concept for the approach I think EGL/GLX mingling should take. Any
comments/criticism is much appreciated.
2012-07-18 15:17:27 -07:00
Ryan C. Gordon
0e49fa682a Patched to compile on FreeBSD 8.2. 2012-07-11 22:20:02 -04:00
Ryan C. Gordon
e3e3adf168 Removed unused variable to silence compiler warning. 2012-07-11 22:04:19 -04:00
Sam Lantinga
38463b3a0c Add OpenGL 3.X context creation support
Matthias Bentrup 2011-10-30 03:58:24 PDT

I've updated the context creation patch to include the bugfixes by Martin
Schreiber and also included a profile bit to request a ES2 compatible profile.

The wgl context creation may use 2 call to wglChoosePixelFormat if no
acceleration attribute is selected, this should work around a bug with buggy
AMD drivers (see #1254).
2012-02-20 23:37:57 -05:00
Ryan C. Gordon
3e4b380d2c Removed GLX_BUFFER_SIZE attribute; it doesn't do anything with GLX_RGBA. 2012-02-07 02:11:42 -05:00
Ryan C. Gordon
df8784cd61 Replaced some assert macros with SDL_assert. 2012-02-07 02:11:15 -05:00
Sam Lantinga
0975880949 The #define was asking to use dlopen(), but the code wasn't doing it.
Also added error message in case the library open failed in that case.
2012-01-07 21:02:39 -08:00
Sam Lantinga
5b2a5e3412 Fixed bug 1313 - Segfault on SDL_CreateWindow when gl lib cannot be loaded
Don't crash if the gl_data isn't valid, just return NULL.
2012-01-07 23:33:15 -05:00
Sam Lantinga
028e5dcdbd Happy New Year! 2011-12-31 09:28:07 -05:00
Sam Lantinga
ad2a21d404 Lots of fixes importing SDL source wholesale into a new iOS project
--HG--
rename : src/libm/math.h => src/libm/math_libm.h
2011-10-31 05:56:58 -04:00
Ryan C. Gordon
bc13816375 Fixed a whole slew of compiler warnings that -Wall exposed. 2011-10-13 01:08:30 -04:00
Ryan C. Gordon
08f49bd2d3 Apparently glXSwapIntervalEXT() _does_ return a value.
Revision 6 of the GLX_EXT_swap_control spec has a typo; the function
signature they list is void, but the docs talk about a return value, and the
glxext.h headers list "int".
2011-08-22 02:26:11 -04:00
Ryan C. Gordon
1a862ae6d3 Patched to compile on older GLX headers. 2011-07-18 14:55:24 -07:00
Ryan C. Gordon
93d2b83299 Added support for GLX_EXT_swap_control, and cleaned up some other extensions.
This allows the Nvidia Linux drivers to use SDL_GL_SetSwapInterval(0).
2011-07-18 14:34:19 -07:00
Sam Lantinga
b0660ba5ff SDL 1.3 is now under the zlib license. 2011-04-08 13:03:26 -07:00
Sam Lantinga
1a2a914b33 Fixed bug 1145 (GL Context creation fails for OpenGL 3.2 + Alpha buffer with X11 BadMatch)
Matthias      2011-02-23 09:37:51 PST

Please view the attached source file. Using this minimal program (as attached),
it creates an OpenGL 2.0 context with a cleared color buffer. If I set the
OpenGL version to 3.2, the function SDL_GL_CreateContext fails (or more
specifically, glXMakeCurrent fails) with an X11 BadMatch error:


X Error of failed request:  BadMatch (invalid parameter attributes)
  Major opcode of failed request:  128 (GLX)
  Minor opcode of failed request:  5 (X_GLXMakeCurrent)
  Serial number of failed request:  153
  Current serial number in output stream:  153


Also note that if I do not specify the alpha buffer size, the program works for
OpenGL 2.0 and OpenGL 3.2.

After some further analysis, I believe I have found the problem. The specific
issue is in:

SDL_x11opengl.c::X11_GL_CreateContext.

Note that for OpenGL 3.2 contexts, the GLXFBConfig to use is chosen as the best
match from glXChooseFBConfig. However, opengl attributes originally set with
SDL_GL_SetAttribute are not mapped to GLX attributes and then passed to the
glXChooseFBConfig function. According to the GLX 1.4 specification, if the
attributes are not specified, the function falls back to defaults (which, in
this particular case, prefer alpha channel size == 0).

For testing purposes, I modified the call to glXChooseFBConfig to look
something like this:


int glxAttribs[] =
{
 GLX_RED_SIZE,8,
 GLX_GREEN_SIZE,8,
 GLX_BLUE_SIZE,8,
 GLX_ALPHA_SIZE,8,
 None
};

if (!glXChooseFBConfig ||
 !(framebuffer_config = glXChooseFBConfig(display, DefaultScreen(display),
glxAttribs, &fbcount)))
{
 ...
}


The best match GLXFBConfig then supports 8 bit alpha channel. The program then
works as intended.


Hope this helps!
2011-02-24 17:52:47 -08:00
Sam Lantinga
e5803d148c Happy 2011! :) 2011-02-11 22:37:15 -08:00
Sam Lantinga
018af55e16 Window coordinates are in the global space and windows are not tied to a particular display.
Also added Ctrl-Enter keybinding to the test code to toggle fullscreen mode for testing.
2011-02-10 14:44:25 -08:00
Sam Lantinga
e9689c29d5 Be explicit about what display you're querying. The default display is 0. 2011-02-10 12:14:37 -08:00
Sam Lantinga
e0f869b698 Removed gamma support since it wasn't widely used and not well supported. 2011-02-10 11:39:08 -08:00
Sam Lantinga
c53fea3bcc Fixed build against 10.4 SDK 2011-01-18 14:57:39 -08:00
Sam Lantinga
d16468c1cb Fixed compiler error with the latest Xcode package 2011-01-18 14:26:30 -08:00
Sam Lantinga
5ae90a3bef Fixed bug 1006
Get the GLX functions with glXGetProcAddress() when available.
2010-07-18 11:18:36 -07:00
Sam Lantinga
4d3df8b3e3 Fixed bug #926
Updated copyright to LGPL version 2.1 and year 2010

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%404453
2010-01-24 21:10:53 +00:00
Sam Lantinga
a0e019f786 Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%404438
2010-01-21 06:21:52 +00:00
Sam Lantinga
240b5fcaab Default to allow either accelerated or not
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%404320
2009-12-15 20:53:09 +00:00
Sam Lantinga
fe2b42f86c OpenGL hardware acceleration defaults on
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%404319
2009-12-15 20:36:31 +00:00
Sam Lantinga
2e3beaf83d typo
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%404004
2009-10-10 06:51:42 +00:00
Sam Lantinga
063b24f5a2 Fixed a few issues compiling with Mac OS X 10.6
Unfortunately the audio and cdrom systems do not build at all, and if you
disable those, SDL still fails to link with these errors:

Undefined symbols:
  "_OBJC_IVAR_$_NSScreen._frame", referenced from:
      -[NSScreen(NSScreenAccess) setFrame:] in SDL_cocoamodes.o
  "_KLGetKeyboardLayoutProperty", referenced from:
      _UpdateKeymap in SDL_cocoakeyboard.o
      _UpdateKeymap in SDL_cocoakeyboard.o
  "_KLGetCurrentKeyboardLayout", referenced from:
      _UpdateKeymap in SDL_cocoakeyboard.o
ld: symbol(s) not found

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%403771
2009-09-05 07:33:54 +00:00
Sam Lantinga
483f2ba3fb indent
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%403608
2009-05-23 22:41:08 +00:00
Sam Lantinga
d7b72e290b Fixed bug #721
From  michalziulek@gmail.com   2009-03-28 07:43:34   (-) [reply]

There is a bug in OpenGL 3.x context creation code.
Function glXGetProcAddress is used directly where it should be:
_this->gl_data->glXGetProcAddress. I have attached patch which fixes this on
x11 and win32. Thanks.

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%403575
2009-04-03 17:19:05 +00:00
Sam Lantinga
ba096ad053 Date: Sun, 22 Mar 2009 12:52:29 +0000
From: Luke Benstead
Subject: OpenGL 3.0 Context Creation

I've attached a patch which implements OpenGL 3.x context creation on
the latest SVN. I've added two options to SDL_GL_SetAttribute, these
are SDL_GL_CONTEXT_MAJOR_VERSION and SDL_GL_CONTEXT_MINOR_VERSION.
These default to 2 and 1 respectively. If the major version is less
than 3 then the current context creation method is used, otherwise the
appropriate new context creation function is called (depending on the
platform).

Sample code:

    if (SDL_Init(SDL_INIT_VIDEO) != 0) {
        printf("Unable to initialize SDL: %s\n", SDL_GetError());
        return 1;
    }

    SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3); //Without these 2 lines, SDL will create a GL 2.x context
    SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0);
    SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);

    SDL_Surface* screen = SDL_SetVideoMode( 640, 480, 16, SDL_OPENGL | SDL_FULLSCREEN );


I've implemented context creation on both Win32 and X and run basic
tests on both. This patch doesn't provide access to all the options
allowed by the new context creation (e.g. shared contexts, forward
compatible contexts) but they can be added pretty easily.

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%403567
2009-03-24 10:43:53 +00:00
Sam Lantinga
2aab251e38 Added test program for SDL_CreateWindowFrom()
Make sure OpenGL library is loaded before working with OpenGL windows,
even those created with SDL_CreateWindowFrom()

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%403521
2009-02-09 05:32:12 +00:00
Sam Lantinga
d123950aa3 Reverted Bob's indent checkin
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%403475
2009-01-10 21:50:26 +00:00
Bob Pendleton
44fa7675c8 I ran a global "make indent" it modified the following files.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%403473
2009-01-09 20:43:30 +00:00
Sam Lantinga
b84ae14eeb Don't use DirectColor visuals until we implement DirectColor colormap support
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%403425
2009-01-02 15:47:49 +00:00
Sam Lantinga
0c30a927ed Updated copyright date
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%403321
2008-12-08 00:27:32 +00:00
Sam Lantinga
ede44c4b85 Final merge of Google Summer of Code 2008 work...
Port SDL 1.3 to the Nintendo DS
by Darren Alton, mentored by Sam Lantinga

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%403188
2008-08-27 15:10:03 +00:00
Sam Lantinga
4dd047e9c7 Couriersud fixed bug #603
Using the following sequence

SDL_Init(..:)
SDL_CreateWindow(..., SDL_WINDOW_OPENGL)
SDL_DestroyWindow
SDL_CreateWindow(..., SDL_WINDOW_OPENGL)

SDL will crash in X11_GL_GetVisual. This is due to the fact that
during SDL_DestroyWindow X11_GL_Shutdown was called because the last window
has been closed.

On the next call to SDL_CreateWindow the library is still loaded and only the
memory is reinitialized. Function pointers such as gl_data->glXChooseVisual
will not be reinitialized.

Consequently, SDL will crash due to a NULL pointer access.

The attached patch corrects the behaviour.

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%403174
2008-08-26 02:47:26 +00:00
Bob Pendleton
d8da8f7c27 In testdyngl.c the event type was being anded (&) with SDL_KEYDOWN and if the result was none zero the program was quiting. This is very weird because it was
working earlier this week.

I added some more trace code to SDL_x11events.c

In SDL_X11opengl.c I modified SDL_GL_GetSwapInterval() so that it returns a pretty good value even if you have the SGI swap extension instead of the MESA swap
extension. I just saved the value you set and return it too you.

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%402744
2008-03-07 23:57:15 +00:00
Bob Pendleton
c19af725fa more valgrind errors fixed. Plus I ran make indent which changed a few files.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%402741
2008-03-07 17:20:37 +00:00
Bob Pendleton
b315d5379d Fixed many valgrind errors. But, I broke testdyngl.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%402740
2008-03-06 23:07:02 +00:00
Bob Pendleton
011c8c6dc3 Fixing valgrind errors.
One of the error was the result of an unitended recursive call to X11_GL_LoadLibrary which was also fixed.

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%402739
2008-03-06 17:08:10 +00:00
Bob Pendleton
b8101a644e Deleted a call to X__PumpEvents at the end of X11_GL_InitExtensions(). This function is being called from SDL_RecreateWindow at a point when the numwindows value in
is incorrect. The result is that an illegal access is being made in X_PumpEvents when it tries to look up the windows ID of the source of an event. Taking out that
call does not seem to have any effect on the testgl. But, I would be happy if someone else took a look at this problem and found a fix higher up the stack.

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%402737
2008-03-01 20:34:36 +00:00
Sam Lantinga
b480be4c28 indent
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%402606
2007-08-15 03:50:49 +00:00
Sam Lantinga
6113055717 Date: Wed, 15 Aug 2007 01:08:38 +0200
From: Couriersud
Subject: Some SDL1.3 patches

LoadLibrary will call X11_GL_Initialize. If LoadLibrary is called before
a window is created, it will crash since structures are not properly set
up.

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%402605
2007-08-15 03:34:14 +00:00
Sam Lantinga
a3245a4e7c Creating a context makes it current, per the documentation.
Applied a variant of the multi-card OpenGL fix from SDL 1.2

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%402497
2007-07-12 06:31:36 +00:00