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

Author Topic: Remove GLEW dependency in favour of glLoadGen  (Read 7326 times)

0 Members and 1 Guest are viewing this topic.

therocode

  • Full Member
  • ***
  • Posts: 125
    • View Profile
    • Development blog
Remove GLEW dependency in favour of glLoadGen
« on: March 22, 2014, 08:51:03 am »
Hello!

This is not purely a feature request, but more like a suggestion. I have no idea if it has been suggested before or not as the search function still doesn't work for me.

Anyhow, I stumbled upon this project called glLoadGen which can be used as a replacement for GLEW and similar libraries. It is not a library in itself, but merely a lua script which accepts parameters telling it which gl version is desired, and which extensions are to be used. Then it spits out a header/source pair which contains the desired functions/enums and they can directly be used in your project. No external linking nor runtime library loading required! :)

I thought this sounded pretty awesome so I tried it out in my own project and it was super easy to switch. It took me about 15 minutes. I just ran this:
lua LoadGen.lua -style=pointer_c -spec=gl -version=3.2 -profile=core core_3_2


Then I included those, and replaced the glewInit call with ogl_LoadFunctions and then included the generated header instead of glew. No sweat, blood nor tears.

The licensing of the script is MIT licence and I don't think there is any particular licence on the generated files. At least I couldn't find any info on it.

I thought this would fit SFML well since it aims to be simple for newbies, and we all know that newbies hate to deal with external libraries, linking errors and stuff like that, and glew can be pretty nasty on that front. SFML even had special hacky solutions to make this easy in the past, but with this, the dependency could perhaps be dropped entirely.

So is there anything that I have missed in my excitement about this approach? Has this been discussed before? Or is it indeed a good idea?

Let me know. :)

EDIT: here is a link
The licensing of the script is MIT licence and I don't think
« Last Edit: March 22, 2014, 09:17:25 am by therocode »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11036
    • View Profile
    • development blog
    • Email
Re: Remove GLEW dependency in favour of glLoadGen
« Reply #1 on: March 22, 2014, 09:36:04 am »
I remember that we had this suggested once already, but I can't find the thread.

Anyways this could indeed be easier to use. I wonder however, if I want to use my own OpenGL code, what header do I have to include? Will that all still work via the SFML/OpenGL.hpp header?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Remove GLEW dependency in favour of glLoadGen
« Reply #2 on: March 22, 2014, 07:48:59 pm »
Sounds good to me.

I was about to ask what would happen if someone uses it in its own code, and links SFML statically, but I just found the -prefix option that allows you to give a unique name to all the non-static globals that it generates.

Quote
I wonder however, if I want to use my own OpenGL code, what header do I have to include? Will that all still work via the SFML/OpenGL.hpp header?
This is purely an implementation detail, it doesn't change anything to regular OpenGL usage.
Laurent Gomila - SFML developer

therocode

  • Full Member
  • ***
  • Posts: 125
    • View Profile
    • Development blog
Re: Remove GLEW dependency in favour of glLoadGen
« Reply #3 on: March 23, 2014, 04:39:21 am »
Awesome!

I hadn't noticed the -prefix flag myself so that was a point I missed but cool that it has such a flag.

Will this be a SFML 3.x change or could it happen before it?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Remove GLEW dependency in favour of glLoadGen
« Reply #4 on: March 23, 2014, 09:44:41 am »
It can happen before, since it doesn't break the public API.
Laurent Gomila - SFML developer

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: Remove GLEW dependency in favour of glLoadGen
« Reply #5 on: April 03, 2014, 08:37:57 pm »
Pretty damn sweet!

SLC

  • Newbie
  • *
  • Posts: 20
    • View Profile
Re: Remove GLEW dependency in favour of glLoadGen
« Reply #6 on: April 07, 2014, 03:47:37 am »
I remember that we had this suggested once already, but I can't find the thread.

Anyways this could indeed be easier to use. I wonder however, if I want to use my own OpenGL code, what header do I have to include? Will that all still work via the SFML/OpenGL.hpp header?

It was one of my question when I tried to reduce the executable size from SFML and SFGUI based application because they both used two different libraries back then  (SFML GLEW and SFGUI GLee). Topic Replace SFML and SFGUI dependency of Glew and GLee with OpenGL Loader Generator?

While OpenGL Loader Generator is very lightweight in size that doesn't mean it comes without costs. It doesn't offer as much functionality like GLEW. But sometime I wonder who needs it. And also you'll be surprised to know that glLoadGen is much more pretentious then GLEW if you don't know the linking order of libraries.

I'm all up for glLoadGen because it's small and simple but would be preferred to either let the user implement it's own or to have an implementation for both libraries and let the users pick the one they want or need.

If they want minimal then glLoadGen is for them or if they want functionality then it's GLEW :)

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Remove GLEW dependency in favour of glLoadGen
« Reply #7 on: April 07, 2014, 07:53:08 am »
Since it's used internally, it doesn't make any difference for end users. They will always have to choose their own extension loader if they need one in their code.
Laurent Gomila - SFML developer

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: Remove GLEW dependency in favour of glLoadGen
« Reply #8 on: April 07, 2014, 09:18:33 am »
If I understand correctly, the only difference would be that users who link SFML statically don't have to link GLEW anymore; glLoadGen would be included in SFML source rather than as a binary.

But as much as everyone hypes glLoadGen, we should see how well everything works in practice. If even older OpenGL profiles work flawlessly, that would of course be nice ;)
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development: