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

Author Topic: Using OpenGL with SFML  (Read 2188 times)

0 Members and 2 Guests are viewing this topic.

Karclintinton

  • Newbie
  • *
  • Posts: 5
    • View Profile
Using OpenGL with SFML
« on: October 21, 2014, 01:05:59 am »
I've started a project for which I wish to use SFML with OpenGL for both 2D and 3D stuff at the same time. However, when I've come to use openGL vertex Buffer Objects and stuff like that I've been unable to as I need to use GLEW or something similar? There are posts saying that SFML has that already inplace and some saying it doesn't and its really confusing with all the information saying conflicting things.

My question is how do I go about using stuff like openGL vertex buffer objects, vertex array objects, the shader functionality of openGL within SFML? I've looked into using GLEW but I'm not really sure how to go about including it as including libraries isn't one of my strong points.

Any help would be super useful

If I've posted this in the wrong area btw please let me know asap

binary1248

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1405
  • I am awesome.
    • View Profile
    • The server that really shouldn't be running
Re: Using OpenGL with SFML
« Reply #1 on: October 21, 2014, 01:26:00 am »
Forget about piggybacking on SFML's GLEW, it is going to get removed in 2.3 anyway.

Don't use GLEW either. Although many tutorials/guides/videos use GLEW, it has been proven to be slow, archaic in ways, and just loaded with too much stuff nobody should care about any more. What I would recommend is using one of the more "modern" ways of loading extensions: loader generators. You can find a few on the OpenGL Loading Library wiki page, and I have turned to using glLoadGen more and more recently. It is much easier to understand, and if you ask me, also simpler to use compared to separately building and linking GLEW. This is the reason why SFML is going to get rid of it in favour of a custom loader generator in 2.3 as well and since none of it gets exposed to the user, nobody will have to care about it like they do with GLEW at the moment.
SFGUI # SFNUL # GLS # Wyrm <- Why do I waste my time on such a useless project? Because I am awesome (first meaning).

Karclintinton

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Using OpenGL with SFML
« Reply #2 on: October 21, 2014, 01:46:44 am »
So using glLoadGen instead of Glew its given me a few questions. Firstly I'm really not all too sure how to go about using the LUA command line stuff it talks about to generate the header files for OpenGL and forgive me for seeming a little dense and newbish with all of this but say I get the glLoadGen stuff created and I link it into my project correctly. Will this then allow me to have the functionality I desire? (as I described in my first post?)

Thanks for the help so far

binary1248

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1405
  • I am awesome.
    • View Profile
    • The server that really shouldn't be running
Re: Using OpenGL with SFML
« Reply #3 on: October 21, 2014, 01:54:02 am »
The explanation is here. If you are on Windows, you can install Lua For Windows. After doing that, you enter the command that you can find on that page and it will generate a loader that loads all the functions you requested. It is up to you what OpenGL version you want to support. If you just want to experiment with widely supported parts of the "modern" API, create a loader for OpenGL 3.2, whether core or legacy it is up to you. You can research about this for yourself.
SFGUI # SFNUL # GLS # Wyrm <- Why do I waste my time on such a useless project? Because I am awesome (first meaning).

Karclintinton

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Using OpenGL with SFML
« Reply #4 on: October 22, 2014, 11:46:07 pm »
So I've got the GLLoadGen stuff created and all that but I'm having troubles with including it into my project. If I include the GLloadGen before including the SFML/OpenGL.hpp it gives an error about including GLloadGen after GL.h, I understand roughly what this means so I put the include for the GLloadGen files before the SFML OpenGL include but by doing that it causes a whole bunch of functions and things which I have been using to be unavailable to include. Some stuff can be got by the double bracket :: and I understand that but stuff like glBegin becomes unavailable (reason I'm using it was just for purposes of gradually converting from immediate mode to using VBOs and VAOs and drawElements

Not sure if what I've said is understandable but if it is any ideas on what it is I need to do?

Thanks in advance

binary1248

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1405
  • I am awesome.
    • View Profile
    • The server that really shouldn't be running
Re: Using OpenGL with SFML
« Reply #5 on: October 23, 2014, 12:32:14 am »
Very simple answer: Do not include SFML/OpenGL.hpp if you are using glLoadGen. glLoadGen contains everything you will ever need.
SFGUI # SFNUL # GLS # Wyrm <- Why do I waste my time on such a useless project? Because I am awesome (first meaning).