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

Author Topic: Replace SFML and SFGUI dependency of Glew and GLee with OpenGL Loader Generator?  (Read 2925 times)

0 Members and 1 Guest are viewing this topic.

SLC

  • Newbie
  • *
  • Posts: 20
    • View Profile
Hi, I was wondering if It's possible to make SFML and SFGUI use OpenGL Loader Generator instead of SFML with Glew and SFGUI with GLee. My final executable size has a limit of 3 max 4 MB (UPX compressed) and those two add up about >1 MB which doesn't leave room for my other libraries. Also it's pointless to have two commonly combined projects that each use a library that does the same thing as the other. While OpenGL Loader Generator (from what I've read) is better and (from what I've seen) is smaller (about ~100 Kb).

I'm asking this because right now I'm not that much of an expert in OpenGL or know too much of SFML and SFGUI internal code design. So before I start changing code I wan't to know if it's possible, that way I won't hit my head to the wall only to find out it's not possible (or recommended).

I used Notedpad++ to run a global search in the source files of SFML and SFGUI and from what I've seen they  both use Glew and GLee only to check if some OpenGL extensions are available. I'm guessing that all I have to do is adapt the code to use OpenGL Loader Generator instead.

SFML uses Glew in:
D:\DevLibs\SFML-master\src\SFML\Graphics\GLCheck.cpp (5 hits)
  Line 111: void ensureGlewInit()
  Line 116:         GLenum status = glewInit();
  Line 117:         if (status == GLEW_OK)
  Line 123:             err() << "Failed to initialize GLEW, " << glewGetErrorString(status) << std::endl;
  Line 123:             err() << "Failed to initialize GLEW, " << glewGetErrorString(status) << std::endl;
D:\DevLibs\SFML-master\src\SFML\Graphics\GLCheck.hpp (3 hits)
  Line 32: #include <GL/glew.h>
  Line 65: /// \brief Make sure that GLEW is initialized
  Line 68: void ensureGlewInit();
D:\DevLibs\SFML-master\src\SFML\Graphics\RenderTarget.cpp (4 hits)
  Line 293:         // Make sure that GLEW is initialized
  Line 294:         priv::ensureGlewInit();
  Line 366:             if (GLEW_EXT_blend_func_separate)
  Line 374:             if (GLEW_EXT_blend_func_separate)
D:\DevLibs\SFML-master\src\SFML\Graphics\RenderTextureImplFBO.cpp (3 hits)
  Line 76:     // Make sure that GLEW is initialized
  Line 77:     priv::ensureGlewInit();
  Line 79:     return GLEW_EXT_framebuffer_object != 0;
D:\DevLibs\SFML-master\src\SFML\Graphics\Shader.cpp (6 hits)
  Line 430:     // Make sure that GLEW is initialized
  Line 431:     priv::ensureGlewInit();
  Line 433:     return GLEW_ARB_shading_language_100 &&
  Line 434:            GLEW_ARB_shader_objects       &&
  Line 435:            GLEW_ARB_vertex_shader        &&
  Line 436:            GLEW_ARB_fragment_shader;
D:\DevLibs\SFML-master\src\SFML\Graphics\Texture.cpp (3 hits)
  Line 533:     // Make sure that GLEW is initialized
  Line 534:     priv::ensureGlewInit();
  Line 536:     if (GLEW_ARB_texture_non_power_of_two)
 

SFGUI uses GLee in:
D:\DevLibs\SFGUI\src\SFGUI\Renderers\VertexBufferRenderer.cpp (8 hits)
  Line 1: // Needs to be included before GLee for NOMINMAX
  Line 5: #include <GLee.h>
  Line 30:    // with GLee or else it will report missing extensions sometimes.
  Line 33:    if( GLEE_ARB_vertex_buffer_object ) {
  Line 47:    if( GLEE_EXT_framebuffer_object || GLEE_ARB_framebuffer_object ) {
  Line 47:    if( GLEE_EXT_framebuffer_object || GLEE_ARB_framebuffer_object ) {
  Line 70:    // with GLee or else it will report missing extensions sometimes.
  Line 73:    if( GLEE_ARB_vertex_buffer_object ) {
 

So yeah, is it possible or not? I'm waiting for your replies :)

More about OpenGL Loader Generator: Performance advantages using OpenGL Loader Generator over GLEW?
« Last Edit: February 06, 2014, 05:28:20 am by SLC »

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
To be honest, I'm not convinced by the advantages. We don't know how well OpenGL Loader Generator works in practice, and the StackOverflow thread is too biased (the answer is from the developer himself).

On the other side, GLEW works fine and there are tons of really important tasks to do in SFML...

By the way, SFGUI using GLee instead of GLEW is the result of a linking restriction in SFML that has been mitigated meanwhile.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10819
    • View Profile
    • development blog
    • Email
By the way, SFGUI using GLee instead of GLEW is the result of a linking restriction in SFML that has been mitigated meanwhile.
And by the way to the by the way, binary1248 already switched back to GLEW, but the commits are waiting to be merged. ;)

Also if you have such a tight size requirement I don't see why you'd bother with libraries, instead you'd be better off with using OpenGL directly. Is this for some kind of demo or why does it have a size requirement?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Tank

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1486
    • View Profile
    • Blog
    • Email
Quote from: Nexus
We don't know how well OpenGL Loader Generator works in practice
At least it's mentioned at opengl.org. I personally haven't heard of it either, but it sounds very promising.

Quote from: eXpl0it3r
And by the way to the by the way, binary1248 already switched back to GLEW, but the commits are waiting to be merged. ;)
I'm merging right now. :)

SLC

  • Newbie
  • *
  • Posts: 20
    • View Profile
Thank you Tank  :) Now it's much better with just Glew. (<500 Kb) I gave up on OpenGL Loader Generator and decide it's best to use Glew now.