SFML community forums

General => Feature requests => Topic started by: kire on November 28, 2010, 01:12:51 pm

Title: OpenGL Forward Compatible Context
Post by: kire on November 28, 2010, 01:12:51 pm
In SFML 2.0, is there any plan to add a context setting to enable a forward compatible context? As I am developping on cutting edge and future-minded I really could use those.

I know how to create such contexts myself using wgl or glx (the two platforms I'm developping for most) but I'd rather see it wrapped in a decent cross-platform media API like SFML.

also, related: are OpenGL 4 and 4.1 contexts supported without problem? (I'm not getting my new gpu for another 2 weeks so can't test myself).

Kind regards
Title: OpenGL Forward Compatible Context
Post by: kire on November 28, 2010, 03:53:11 pm
Appearantly you even set the compatibility by default, which I think is great :).

However, concerning 4.x support I think this doesn't really work as expected, your 'release try' currently happens as follows:
Code: [Select]

while (!myContext && (mySettings.MajorVersion >= 3))
    {
        //Try create context

        // If we couldn't create an OpenGL 3 context, adjust the settings
        if (!myContext)
        {
            if (mySettings.MinorVersion > 0)
            {
                // If the minor version is not 0, we decrease it and try again
                mySettings.MinorVersion--;
            }
            else
            {
                // If the minor version is 0, we decrease the major version and stop with 3.x contexts
                mySettings.MajorVersion = 2;
            }
        }
    }


So if it cannot create a 4.1/4.0 context it will immediately fall back to 2.x, which shouldn't really happen. I added some methods to the more general GLContext and adapted the glx and wgl context classes accordingly. I think this fix is more future proof. Anyway, you can find the patch here (https://sourceforge.net/tracker/?func=detail&aid=3121284&group_id=188964&atid=927429)

I know there are some weird looking +/- lines in the fix also, I guess that has something to do with line endings getting changed upon saving.
Title: OpenGL Forward Compatible Context
Post by: Laurent on November 28, 2010, 05:49:03 pm
Thanks for the patch, but I think it's too complicated. I can simply decrement the major version like I do with the minor version, instead of setting it to 2.
Title: OpenGL Forward Compatible Context
Post by: kire on November 28, 2010, 06:08:30 pm
Well,  I actually tried that way first because it's obviously easier, however there is no clear way of going from 4.0->3.3 with that method. That's why I came up with the versions array (the method is simply because I think it's tidier to reuse in multiple impl versions). And with this implementation adding support to a new version is simply done by adding it to an array, given of course that opengl's createcontext method doesn't change again :p.

Anway, thanks for looking at it :).
Title: OpenGL Forward Compatible Context
Post by: Laurent on November 28, 2010, 06:27:21 pm
Quote
there is no clear way of going from 4.0->3.3

Is it necessary? Creating a 3.x (for x > 3) context will fail, until we get to 3.3. This way we don't have to manually hard-code all the valid version numbers.
Title: OpenGL Forward Compatible Context
Post by: kire on November 28, 2010, 06:29:38 pm
Ah so you would go from 4.0 to something like 3.9? I guess that will also work, yes :).
Title: OpenGL Forward Compatible Context
Post by: Fierce_Dutch on May 30, 2011, 08:14:39 am
Sorry to bump this but will this be implemented any time soon? I would like to be able to call setting.SetLowestGLVersion(3.3); Or at least something similar.

Regards,
Brent
Title: OpenGL Forward Compatible Context
Post by: Laurent on May 30, 2011, 08:21:02 am
Choosing the GL version of the context is already implemented. Are you talking about something else?
Title: OpenGL Forward Compatible Context
Post by: Fierce_Dutch on May 31, 2011, 05:48:46 am
Quote from: "Laurent"
Choosing the GL version of the context is already implemented. Are you talking about something else?


Oh it is? Sorry maybe I read this thread wrong. How do I use it?
Title: OpenGL Forward Compatible Context
Post by: Laurent on May 31, 2011, 07:39:52 am
Quote
How do I use it?

You read the doc ;)
http://www.sfml-dev.org/documentation/2.0/structsf_1_1ContextSettings.php
Title: ...
Post by: Waterlimon on June 21, 2011, 03:22:48 am
Hmm, couldnt you make that fancy loop go up until it finds a not supported version?

like

*increment major version until not supported*
*take last supported major version*
*increment minor version until not supported*
*use last working minor version with the major version*
Title: Re: ...
Post by: Groogy on June 21, 2011, 04:06:31 am
Quote from: "Waterlimon"
Hmm, couldnt you make that fancy loop go up until it finds a not supported version?

like

*increment major version until not supported*
*take last supported major version*
*increment minor version until not supported*
*use last working minor version with the major version*


Because if we pick context version "3.3" but the computer only support 2.0, we are screwed to say the least. Unless you remove the possibility to choose a version for the user. I'm not experienced enough with OpenGL to make a call on that, I don't know any reason why you would rather want an older context than the newest  as the "highest" version for an application.

Think it would be better if SFML provided a way to check if a context setting is valid before sending it to the window to do custom things like you want.