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

Author Topic: Add OpenGL context flag and profile version setting  (Read 7762 times)

0 Members and 1 Guest are viewing this topic.

ZHAOPeng

  • Newbie
  • *
  • Posts: 4
    • View Profile
Add OpenGL context flag and profile version setting
« on: July 14, 2010, 08:59:01 am »
Hello,

I find that no option for context flag and profile version can be used in SFML 2.0 snapshot.
It is very easy to add them to ContextSettings and the attributes list for creating context.
I hope these two options could be added in the next release so that we can change the profile version for OpenGL 3.2 or later.

Thanks!

ZHAO Peng :wink:

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Add OpenGL context flag and profile version setting
« Reply #1 on: July 14, 2010, 11:08:18 am »
What exactly are the "context flag" and the "profile version"?
Laurent Gomila - SFML developer

ZHAOPeng

  • Newbie
  • *
  • Posts: 4
    • View Profile
Add OpenGL context flag and profile version setting
« Reply #2 on: July 14, 2010, 12:53:39 pm »
http://www.opengl.org/registry/specs/ARB/glx_create_context.txt

The OpenGL 3.2 introduces the profile mechanism. Each profile is one subset of full OpenGL API. Now there are two profiles: core profile and compatibility  profile. The core profile removes lost of old functions. And the compatibility profile could be compatible with any old OpenGL versions.As a result, when create an OpenGL context, the profile should be specified.

Besides, there are two context flag:
GLX_CONTEXT_DEBUG_BIT_ARB and  GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB

"If the GLX_CONTEXT_DEBUG_BIT_ARB flag bit is set in
    GLX_CONTEXT_FLAGS_ARB, then a <debug context> will be created. Debug
    contexts are intended for use during application development, and
    provide additional runtime checking, validation, and logging
    functionality while possibly incurring performance penalties. The
    additional functionality provided by debug contexts may vary
    according to the implementation(fn). In some cases a debug context
    may be identical to a non-debug context.

    If the GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB is set in
    GLX_CONTEXT_FLAGS_ARB, then a <forward-compatible> context will be
    created. Forward-compatible contexts are defined only for OpenGL
    versions 3.0 and later. They must not support functionality marked
    as <deprecated> by that version of the API, while a
    non-forward-compatible context must support all functionality in
    that version, deprecated or not."


The profile and flag should be set in the attribute list, which is the last parameter of glXCreateContextAttribsARB.

So just add two options to ContextSetting and set them into the attribute list before calling glXCreateContextAttribsARB.

I have modified the SFML 2.0 snapshot and it works fine for me.

Thanks!

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Add OpenGL context flag and profile version setting
« Reply #3 on: July 14, 2010, 03:20:43 pm »
It would probably not be a good idea to provide these options, as SFML still uses old/deprecated OpenGL functions.

Rendering would be totally broken with the core profile / without the compatibility flag (I'm not sure I understand the difference between these two).
Laurent Gomila - SFML developer

l0calh05t

  • Full Member
  • ***
  • Posts: 200
    • View Profile
Add OpenGL context flag and profile version setting
« Reply #4 on: July 14, 2010, 04:21:17 pm »
I'd prefer if you still offered these as an option, but include a warning in the documentation that it may cause problems if SFML-Graphics is used with incorrect flags.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Add OpenGL context flag and profile version setting
« Reply #5 on: July 14, 2010, 06:28:47 pm »
Yes, I'll definitely think about that for SFML 2.0.
Laurent Gomila - SFML developer

ZHAOPeng

  • Newbie
  • *
  • Posts: 4
    • View Profile
Add OpenGL context flag and profile version setting
« Reply #6 on: July 15, 2010, 04:13:02 am »
Quote
I'd prefer if you still offered these as an option, but include a warning in the documentation that it may cause problems if SFML-Graphics is used with incorrect flags.


I agree. It is time to remove the deprecated OpenGL functions and move forward to the core profile. Although it can not be finished at one blow, we should start.

Quote
Yes, I'll definitely think about that for SFML 2.0.

Thanks for your attention!

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Add OpenGL context flag and profile version setting
« Reply #7 on: July 15, 2010, 08:53:48 am »
Quote
It is time to remove the deprecated OpenGL functions and move forward to the core profile

You mean in SFML? This is impossible. I would have to implement two (or more) totally different rendering paths, which is a huge amount of work. Maybe for SFML 3.0 ;)
Laurent Gomila - SFML developer

l0calh05t

  • Full Member
  • ***
  • Posts: 200
    • View Profile
Add OpenGL context flag and profile version setting
« Reply #8 on: July 15, 2010, 08:56:41 am »
if you were to make a flexible rendering abstraction (as Ogre or Irrlicht use), I am sure someone would take over writing a GL3 or a GLES backend.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Add OpenGL context flag and profile version setting
« Reply #9 on: July 15, 2010, 09:18:41 am »
This is a goal that I definitely want to reach. Using GL3 internally won't make a big difference, but GLES is mandatory for porting SFML to mobile devices.

The abstraction is already much better in SFML 2 than in SFML 1, but there's still a lot to do. It requires major modifications in the graphics module, so I keep that for later (maybe SFML 3 :D).
Laurent Gomila - SFML developer

yuriks

  • Newbie
  • *
  • Posts: 2
    • View Profile
Add OpenGL context flag and profile version setting
« Reply #10 on: October 22, 2010, 04:08:28 am »
Is there still a plan to add support to this feature to context creation in SFML2 when not using the Graphics module? I'd also like to take the opportunity and suggest that it be made possible to create debug context's too.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Add OpenGL context flag and profile version setting
« Reply #11 on: October 22, 2010, 08:07:34 am »
Yes, it's still planned.
Laurent Gomila - SFML developer

 

anything