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

Author Topic: [SOLVED] Learning OpenGL with SFML  (Read 6954 times)

0 Members and 1 Guest are viewing this topic.

Wafthrudnir

  • Newbie
  • *
  • Posts: 26
    • View Profile
[SOLVED] Learning OpenGL with SFML
« on: September 27, 2016, 07:34:12 pm »
Hi,

I want to learn some basic OpenGL and use SFML for everything else, no GLUT/GLEW. I found this online tutorials: http://www.opengl-tutorial.org/.

My system supports OpenGL 4.5. And afaik glBegin()-tutorials are outdated. Is it possible to use "modern" openGL with SFML. I get compilation errors with these lines:
                GLuint VertexArrayID;
                glGenVertexArrays(1, &VertexArrayID);
                glBindVertexArray(VertexArrayID);
 

Error is: identifier "glGenVertexArrays" is undefined

So I have 3 questions:
1.) Does OpenGL 4.5 work with SFML? (I would like to use SFML 2D functionality with OpenGL 3D)
2.) glGenVertexXXX is GLEW/GLUT?! Maybe that's why I get the error?!
3.) Any good tutorial or book suggestions for a beginner?! :)
EDIT:
4.) Yeah, maybe I should keep in mind, that not all systems support the latest. Is there some info somewhere which OS supports which version of OpenGL?! .. Edit2.) http://store.steampowered.com/hwsurvey guess most users seem to have at least a OpenGL 3.0 compatible card (compared to DX10) ...

Regards,
Wafthrudnir

Edit: I just read, that under windows the default headers are OpenGL 1.1. Someone suggested to use Glew. urgh...really?! (http://stackoverflow.com/questions/37736829/glgenvertexarrays-not-available-in-c)

I am using Visual Studio 2015, the included GL.h doesn't contain the stated functions and the header says:
BUILD Version: 0004    // Increment this if a change has global effects

Copyright (c) 1985-96, Microsoft Corporation
 
Path is: c:\Program Files (x86)\Windows Kits\8.1\Include\um\gl\GL.h
« Last Edit: September 28, 2016, 06:39:33 pm by Wafthrudnir »
Black Metal + Coding = Win!

AlexxanderX

  • Full Member
  • ***
  • Posts: 128
    • View Profile
    • AlexanderX
Re: Learning OpenGL with SFML
« Reply #1 on: September 28, 2016, 02:57:37 pm »
1. Yes, you can use SFML's window & system modules with raw OpenGL, but I'm not sure about graphics module.
3. I'm also learning OpenGL and here are some good lessons: http://learnopengl.com/ and https://open.gl/. (if you wants learn by creating a game you can watch ThinMatrix's series, but they are in Java( pretty easy to translate to C++), but is a good series for beginners).
4. I'm not sure, but from what I know this does not depend on the OS, but the gpu drivers.

I also use GLEW and not the SFML's GL header.
« Last Edit: September 28, 2016, 03:10:04 pm by AlexxanderX »
Here you can find my blog and tutorials about SFML - http://alexanderx.net/ (died...) - http://web.archive.org/web/20160110002847/http://alexanderx.net/

Wafthrudnir

  • Newbie
  • *
  • Posts: 26
    • View Profile
Re: Learning OpenGL with SFML
« Reply #2 on: September 28, 2016, 03:40:26 pm »
Thanks for the answer and the tutorial links :)

I guess my problem really is the SFML header. AFAIK Windows still only supports OpenGL 1.1. GLEW seems to communicate with the driver directly and thus supports the newer OpenGL functions (using this: GetAnyGLFuncAddress etc....

So I guess I also have to include GLEW to get it working with OpenGL 3+?! I thought SFML is an alternative to GLEW x_X

The SFML tutorials state, that it's possible to use SFML graphics module besides plain OpenGL (you have to save the GL states etc.. as stated in the tutorials).

« Last Edit: September 28, 2016, 03:42:55 pm by Wafthrudnir »
Black Metal + Coding = Win!

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Learning OpenGL with SFML
« Reply #3 on: September 28, 2016, 03:48:11 pm »
Quote
I guess my problem really is the SFML header.
SFML/OpenGL.hpp is only a generic bridge to the system specific OpenGL header (which is different on every OS). It doesn't do anything else. Look at what's inside and you'll understand ;)

Quote
AFAIK Windows still only supports OpenGL 1.1
That's why you have to use the OpenGL extension system.

Quote
GLEW seems to communicate with the driver directly and thus supports the newer OpenGL functions
GLEW doesn't communicate with the driver directly, it's just a wrapper on top of the OpenGL extension system, that makes the whole process of checking and loading extensions slightly easier (and cross-platform). There are many similar libraries.

Quote
So I guess I also have to include GLEW to get it working with OpenGL 3+?
If you want to use OpenGL features not included in 1.1, then yes, you must use extensions, and yes, GLEW is one solution for using extensions.

Quote
I thought SFML is an alternative to GLEW x_X
Not at all. If you've read this somewhere, then it was clearly a mistake or a lie.

Quote
The SFML tutorials state, that it's possible to use SFML Graphics module besides plain OpenGL (you have to save the GL states etc.. as stated in the tutorials).
Indeed.
Laurent Gomila - SFML developer

Wafthrudnir

  • Newbie
  • *
  • Posts: 26
    • View Profile
Re: Learning OpenGL with SFML
« Reply #4 on: September 28, 2016, 06:39:24 pm »
Thank you very much Laurent,

these were the informations I was missing. My understanding of OpenGL was a little bit off, but now I get it.
And yeah, that's maybe because I thought SFML is an alternative to GLEW.

I will check out GLEW then and later on glbinding :)

Regards,
Wafthrudnir
« Last Edit: September 28, 2016, 08:20:03 pm by Wafthrudnir »
Black Metal + Coding = Win!

 

anything