Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: OpenGL Forward Compatible Context  (Read 5694 times)

0 Members and 1 Guest are viewing this topic.

kire

  • Newbie
  • *
  • Posts: 4
    • View Profile
OpenGL Forward Compatible Context
« 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

kire

  • Newbie
  • *
  • Posts: 4
    • View Profile
OpenGL Forward Compatible Context
« Reply #1 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

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.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
OpenGL Forward Compatible Context
« Reply #2 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.
Laurent Gomila - SFML developer

kire

  • Newbie
  • *
  • Posts: 4
    • View Profile
OpenGL Forward Compatible Context
« Reply #3 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 :).

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
OpenGL Forward Compatible Context
« Reply #4 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.
Laurent Gomila - SFML developer

kire

  • Newbie
  • *
  • Posts: 4
    • View Profile
OpenGL Forward Compatible Context
« Reply #5 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 :).

Fierce_Dutch

  • Full Member
  • ***
  • Posts: 138
    • View Profile
OpenGL Forward Compatible Context
« Reply #6 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

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
OpenGL Forward Compatible Context
« Reply #7 on: May 30, 2011, 08:21:02 am »
Choosing the GL version of the context is already implemented. Are you talking about something else?
Laurent Gomila - SFML developer

Fierce_Dutch

  • Full Member
  • ***
  • Posts: 138
    • View Profile
OpenGL Forward Compatible Context
« Reply #8 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?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
OpenGL Forward Compatible Context
« Reply #9 on: May 31, 2011, 07:39:52 am »
Laurent Gomila - SFML developer

Waterlimon

  • Newbie
  • *
  • Posts: 7
    • View Profile
...
« Reply #10 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*
This sententace makes me more unique. Too lazy to upload avatar. Nobody reads usernames.

Groogy

  • Hero Member
  • *****
  • Posts: 1469
    • MSN Messenger - groogy@groogy.se
    • View Profile
    • http://www.groogy.se
    • Email
Re: ...
« Reply #11 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.
Developer and Maker of rbSFML and Programmer at Paradox Development Studio