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

Author Topic: Force OpenGL Context  (Read 3807 times)

0 Members and 1 Guest are viewing this topic.

golgoth

  • Jr. Member
  • **
  • Posts: 99
    • View Profile
Force OpenGL Context
« on: November 23, 2012, 07:36:59 pm »
Greetings,

When creating a window I do:

   sf::ContextSettings l_settings;
   l_settings.majorVersion = 2;
   l_settings.minorVersion = 1;

but when I retrieve the info:

mywindow.getSettings().majorVersion
mywindow.getSettings().minorVersion

I get (4 and 2)

How do I force a 2.1 context?

Thx

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Force OpenGL Context
« Reply #1 on: November 23, 2012, 08:21:09 pm »
The driver is allowed to use a greater version as long as it's 100% compatible with what you requested.
Laurent Gomila - SFML developer

golgoth

  • Jr. Member
  • **
  • Posts: 99
    • View Profile
Re: Force OpenGL Context
« Reply #2 on: November 23, 2012, 08:44:38 pm »
hum, the thing is I'd like to test different Opengl configuration depending on the user's machine. Is there a way to set the context version as being requested?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Force OpenGL Context
« Reply #3 on: November 23, 2012, 09:52:01 pm »
The driver is allowed to do so because it makes absolutely no difference. So there's no point trying to force a specific version -- you can consider that you got it.
Laurent Gomila - SFML developer

golgoth

  • Jr. Member
  • **
  • Posts: 99
    • View Profile
Re: Force OpenGL Context
« Reply #4 on: November 23, 2012, 10:38:08 pm »
Don't get me wrong, it’s a very good feature but allowing to create a specific context version (as long as it is supported) would be very handy.

The point is, debugging a 4.2 context to make sure it will run on a system that only support 2.1 is rather painful and It makes a big difference.

I suggest to process the requested context version before:

wglContext.cpp
while (!m_context && (m_settings.majorVersion >= 3))

if the version number is past explicitly and it is supported simply stop there and voila.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Force OpenGL Context
« Reply #5 on: November 24, 2012, 08:41:53 am »
Quote
The point is, debugging a 4.2 context to make sure it will run on a system that only support 2.1 is rather painful and It makes a big difference.
Why? I mean, if drivers are allowed to do that, I guess (and I hope) that it doesn't make any difference for both the programmer and user.

Quote
I suggest to process the requested context version before:

wglContext.cpp
while (!m_context && (m_settings.majorVersion >= 3))

if the version number is past explicitly and it is supported simply stop there and voila.
Sorry, I don't understand what you suggest.
If the requested number is less than 3.0 then I use the "old" wglCreateContext function, which creates a pre-3.0 context. It's then the driver who decides to create a greater version. There's nothing I can do, and it's not supposed to be a problem (otherwise they wouldn't be allowed to do that).
Laurent Gomila - SFML developer

golgoth

  • Jr. Member
  • **
  • Posts: 99
    • View Profile
Re: Force OpenGL Context
« Reply #6 on: November 25, 2012, 07:32:30 am »
Quote
It's then the driver who decides to create a greater version.

Oh, my apologies! As I read your code, it seemed like you where cycling to the highest supported context explicitly. My question is, is there a point in passing the version number when creating a context?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Force OpenGL Context
« Reply #7 on: November 25, 2012, 09:59:53 am »
Quote
My question is, is there a point in passing the version number when creating a context?
Yes, if you need specific features that were introduced in a specific version greater than 3.0.
Laurent Gomila - SFML developer

golgoth

  • Jr. Member
  • **
  • Posts: 99
    • View Profile
Re: Force OpenGL Context
« Reply #8 on: November 26, 2012, 06:35:07 pm »
Oh I see, thank you for your inputs Laurent,

It’s beyond the scope of this thread but I’m guessing you’ve been there before. I’m using VMware 9 on Windows 8 to do testing on Ubuntu and OSX. AFAIK, VMware only supports OpenGL 2.1 and I need to downgrade my OpenGL features for testing purposes. I’m open for suggestions in how to achieve this, if that make any sense to you.

golgoth

  • Jr. Member
  • **
  • Posts: 99
    • View Profile
Re: Force OpenGL Context
« Reply #9 on: November 26, 2012, 08:09:46 pm »
wait...

Quote
Yes, if you need specific features that were introduced in a specific version greater than 3.0.

Even if I choose any specific version number I always get the higher supported version... I can assure you that this feature worked in the past. I remember creating a 2.1 or 3.3 context without any trouble. Am I taking crazy pills or am I taking a lot of crazy pills?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Force OpenGL Context
« Reply #10 on: November 26, 2012, 08:50:51 pm »
You probably updated your graphics driver.
Laurent Gomila - SFML developer

golgoth

  • Jr. Member
  • **
  • Posts: 99
    • View Profile
Re: Force OpenGL Context
« Reply #11 on: November 30, 2012, 08:03:00 pm »
Any way to prevent this automation from the driver? I tried to Google it but I couldn't find anything useful.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Force OpenGL Context
« Reply #12 on: November 30, 2012, 09:13:54 pm »
I don't think so. But you don't need to. Seriously, what's wrong? If the driver is allowed to do that, it's because it doesn't make any difference. It's not to bother developers.

If you want to be sure to stick to OpenGL 2.1, don't use any 3.0+ function. If you use GLEW, you can set a macro to the version that you want to use, and you'll get compiler errors for any function that is 3.0+.
Laurent Gomila - SFML developer

 

anything