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

Author Topic: How to enable GLSL 330  (Read 4735 times)

0 Members and 1 Guest are viewing this topic.

Mörkö

  • Jr. Member
  • **
  • Posts: 96
    • View Profile
How to enable GLSL 330
« on: June 28, 2014, 11:09:52 am »
Is it true that opengl 3.3 is not supported in SFML 2? I seem unable to set sf::ContextSettings.minorVersion to 3, as that is what I believe would enable me to use glsl version 330.

I was following along in a tutorial, and when I tried to create a shader the program gave some error about NEW_IDENTIFIER, which after googling it seems I was using an outdated version of glsl, so I tried using context settings to get the required version.

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


So I thought maybe I simply have an installed version that is outdated.

[morran@5586577d ~]$ glxinfo
OpenGL vendor string: X.Org
OpenGL renderer string: Gallium 0.4 on AMD CAYMAN
OpenGL core profile version string: 3.3 (Core Profile) Mesa 10.1.5
OpenGL core profile shading language version string: 3.30


My system clearly supports glsl version 330, so why does it seem like SFML doesn't do so too?

What steps can I take to enable opengl 3.3 in SFML?

edit--

Yeah it turns out I didn't understand the meaning of opengl core profile. So I guess my new question is, can I enable that somehow?

edit2--

For example, in SDL I can do this:

SDL_Init(SDL_INIT_VIDEO);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3);

SDL_Window* window = SDL_CreateWindow("OpenGL", 100, 100, 800, 600, SDL_WINDOW_OPENGL);
SDL_GLContext context = SDL_GL_CreateContext(window);

char* version = (char*)glGetString(GL_VERSION);
printf("%s\n", version);

And as far as I can tell from my brief testing, it works with no problems.

outputs
3.3 (Core Profile) Mesa 10.1.5
« Last Edit: June 28, 2014, 01:55:51 pm by Mårran »

binary1248

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1405
  • I am awesome.
    • View Profile
    • The server that really shouldn't be running
Re: How to enable GLSL 330
« Reply #1 on: June 28, 2014, 03:10:55 pm »
You can check the context version that you get from the operating system with window.getSettings() after creating the window. For me, not explicitly specifying a context version will get me a 4.4 context which supports GLSL 440 (I tested it and it works), so it is not a question of whether SFML "supports a specific context version". SFML doesn't have to support a version, you will just get one that works for you (often the newest version in compatibility mode).

You can check the GL strings using glGetString(GL_VERSION​) and glGetString(GL_SHADING_LANGUAGE_VERSION​​) after creating the window as well. If it reports what you would expect and GLSL 330 still doesn't work, it is probably a driver bug, nothing SFML can do about those. Also, it seems you are using Gallium3D? It is already quite dated. Did you try updating/installing the radeon driver?
SFGUI # SFNUL # GLS # Wyrm <- Why do I waste my time on such a useless project? Because I am awesome (first meaning).

Mörkö

  • Jr. Member
  • **
  • Posts: 96
    • View Profile
Re: How to enable GLSL 330
« Reply #2 on: June 28, 2014, 05:43:01 pm »
You can check the GL strings using glGetString(GL_VERSION​) and glGetString(GL_SHADING_LANGUAGE_VERSION​​) after creating the window as well. If it reports what you would expect and GLSL 330 still doesn't work, it is probably a driver bug, nothing SFML can do about those. Also, it seems you are using Gallium3D? It is already quite dated. Did you try updating/installing the radeon driver?
Well I'm using the free drivers at the moment, I did find an article saying that the proprietry fglrx drivers would give access to openGL 3.3, but fglrx have given me a lot of trouble in the past so I'm hesitant to install it. Also an entry on stackexchange suggested that intel users have a more updated version of MESA, but I guess that's unfortunately not relevant to this case.

However, I was wondering if there is any way to enable core profile in SFML, like I did in SDL? From what I can tell that would let me use the features I need without changing drivers.

binary1248

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1405
  • I am awesome.
    • View Profile
    • The server that really shouldn't be running
Re: How to enable GLSL 330
« Reply #3 on: June 28, 2014, 06:02:53 pm »
SFML will never give you a core-only profile. It needs a compatibility profile to function properly. Normally this should not be a problem, because as its name implies, the compatibility profile is meant to be compatible with both core and legacy GL usage. If what you say is true and GLSL 330 only works with a core profile and not a compatibility profile then that is a serious bug (or unimplemented feature) in the driver and if it hasn't already been reported/fixed, you should file a bug report.

Also, from what I understand, Gallium is not the same as radeon and radeon is not the same as fglrx. Gallium is an experimental driver for all cards (very ambitious) whereas radeon is a driver specifically for AMD cards. radeon supports as of now a lot more features than Gallium and is probably also maintained by more people. You should try removing Gallium and installing the radeon driver and see if it works.
SFGUI # SFNUL # GLS # Wyrm <- Why do I waste my time on such a useless project? Because I am awesome (first meaning).

 

anything