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

Author Topic: How to get glCreateShader and other 3.x > functions  (Read 6769 times)

0 Members and 1 Guest are viewing this topic.

Groogy

  • Hero Member
  • *****
  • Posts: 1469
    • MSN Messenger - groogy@groogy.se
    • View Profile
    • http://www.groogy.se
    • Email
How to get glCreateShader and other 3.x > functions
« on: June 11, 2011, 11:13:56 pm »
Yeah well as I continue with my engine the only thing left that is not wrapped in the rendering part is shaders. Got an interesting idea that I'll have for my engine but this is my first time ever using shaders in OpenGL so it's fairly new concept for me.

I looked in the Shader.cpp source for SFML and found you used the ARB version? What is the difference from using the GLuint glCreateShader(GLenum shaderType); function?

Also I tried using the glCreateShader function but according to my VS2010 it's an undefined symbol... I tried both with including <gl/GL.h> and <SFML/OpenGL.hpp> but no prevail. I was missing several functions I think was added in OpenGL 3, how do I get the correct development files for that?

Also what is recommended to use? Fairly new to this so any suggestions, ideas and opinions are appreciated.

UPDATE: Got a hold of glCreateShader from GLEW but still would like to know what the pro's and con's are, what the difference is and what I should use.
Also curious, I could get a OpenGL 3.3 context but if taking OpenGL 4.1 it reverted back to 3.3, is OpenGL 4.1 supported at all by SFML or is it just that my laptop is too crappy?
Developer and Maker of rbSFML and Programmer at Paradox Development Studio

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
How to get glCreateShader and other 3.x > functions
« Reply #1 on: June 12, 2011, 09:53:58 am »
Quote
I looked in the Shader.cpp source for SFML and found you used the ARB version? What is the difference from using the GLuint glCreateShader(GLenum shaderType); function?

glCreateShader is part of OpenGL 2, therefore if you don't have OpenGL 2 headers you have to retrieve the function dynamically, as an extension (that's why there's the ARB suffix).
On Windows, GL headers are never updated: they are stuck in version 1.4. So it's always safer to use extensions for features that are not part of the 1.4 core.

Quote
Also I tried using the glCreateShader function but according to my VS2010 it's an undefined symbol... I tried both with including <gl/GL.h> and <SFML/OpenGL.hpp> but no prevail. I was missing several functions I think was added in OpenGL 3, how do I get the correct development files for that?

On Windows you can't, so you must use extensions -- use a dedicated library such as GLEW or GLEE for that (SFML uses GLEW).

Quote
Also curious, I could get a OpenGL 3.3 context but if taking OpenGL 4.1 it reverted back to 3.3, is OpenGL 4.1 supported at all by SFML or is it just that my laptop is too crappy?

Recent revisions of SFML support any version of contexts. You should check what your GPU supports, for example with OpenGL Viewer.
Laurent Gomila - SFML developer

Groogy

  • Hero Member
  • *****
  • Posts: 1469
    • MSN Messenger - groogy@groogy.se
    • View Profile
    • http://www.groogy.se
    • Email
How to get glCreateShader and other 3.x > functions
« Reply #2 on: June 12, 2011, 12:11:11 pm »
Quote from: "Laurent"
glCreateShader is part of OpenGL 2, therefore if you don't have OpenGL 2 headers you have to retrieve the function dynamically, as an extension (that's why there's the ARB suffix).
On Windows, GL headers are never updated: they are stuck in version 1.4. So it's always safer to use extensions for features that are not part of the 1.4 core.

On Windows you can't, so you must use extensions -- use a dedicated library such as GLEW or GLEE for that (SFML uses GLEW).

So I should still use the ARB version even though GLEW gives me access to the non-ARB functions?

Quote from: "Laurent"
Recent revisions of SFML support any version of contexts. You should check what your GPU supports, for example with OpenGL Viewer.

Thanks, found out I need to update my drivers and of course that my card only has support up to 3.3 :D

Anyway so bottom line, I should use the ARB version right? Because it's safer on Windows? But I will still gain the full functionality?
Developer and Maker of rbSFML and Programmer at Paradox Development Studio

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
How to get glCreateShader and other 3.x > functions
« Reply #3 on: June 12, 2011, 12:59:20 pm »
In fact I don't know what GLEW does. Maybe it automatically hides glCreateShaderARB behind glCreateShader if the latter is not available from the core headers.

This is something that I should examine deeper, could be interesting for SFML too.
Laurent Gomila - SFML developer

Groogy

  • Hero Member
  • *****
  • Posts: 1469
    • MSN Messenger - groogy@groogy.se
    • View Profile
    • http://www.groogy.se
    • Email
How to get glCreateShader and other 3.x > functions
« Reply #4 on: June 12, 2011, 01:30:49 pm »
You might like my Shader implementation, it wraps the OpenGL functionality pretty well. It's divided into 3 classes(actually 2 are only typedefs of a single template class)

Just thinking since you talked about maybe adding Vertex shaders too you'll need a flexible way to create entire shader programs.

For now I'll add a ShaderConfig.hpp file with defines for the different functions so you/me can easily change between 2.0+ and ARB version.
Developer and Maker of rbSFML and Programmer at Paradox Development Studio