-1

I want to write cross-platform 3D app (maybe game, who knows) with SFML and OpenGL 3.3 with the main purpose to learn C++.

SFML provides cool event model, handles textures, texts, inputs etc. I've done simple demo with cube (still in old glBegin/glEnd way, but I'll fix it when I'll find a way to attach OpenGL extensions).

The first problem which I got is a double bufferization. As you must know, usual (and logic) way to perform rendering uses two buffers, display buffer and render buffer. Rendering cycle performed on render buffer and when it ends, the result coping to display buffer (or maybe there's two same buffers just switching roles per cycle, don't know). That's prevents flickering and artifacts.

The trouble is that at any OpenGL example which I see authors using GLUT and functions like glutSwapBuffers. If I understand correct, double buffering is platform-specific (and that's strange for me, because I think it must be done on OpenGL part) and things like GLUT just hides platform-specific points. But I'm already using SFML for context and OpenGL initialization.

Is there any cross-platform way to deal with OpenGL double-buffering in pair with SFML? I'm not using SFML graphics in this project, but target is a RenderWindow.

Arman Hayots
  • 2,459
  • 6
  • 29
  • 53
  • Not directly related to the question, but you don't need to *"attach OpenGL extensions"* to use new OpenGL (3 and above). On Windows you need GLEW or similar library. – HolyBlackCat Jun 13 '16 at 19:30
  • 3
    Don't [delete and re-ask a question](http://stackoverflow.com/questions/37777345) just because you didn't get an answer. Also, why are you asking about a solution with SFML if "*I'm not using SFML graphics in this project.*"? – Nicol Bolas Jun 13 '16 at 19:41
  • 1
    @NicolBolas it's somewhat counter-intuitive, but the SFML Graphics headers aren't necessary to leverage SFML's graphics capabilities unless you want to use SFML's high-level, (mostly) OpenGL-free functions. The Window library is probably all that OP is using. – Conduit Jun 13 '16 at 20:04
  • 2 @Nicol Bolas : Question got no answer and completely changes — thanks to your comments, so I've created an another one. I mean I don't need SFML for render, SFML just provides context, events etc – Arman Hayots Jun 13 '16 at 20:19

1 Answers1

2

SFML can handle double buffering, but if you are not using the SFML Graphics library you must use an sf::Window instance.

Double buffering is handled by calling sf::Window::setActive to set the window as the OpenGL rendering target, drawing content using OpenGL functions, and then calling sf::Window::display to swap the back buffer. More information can be found in the SFML API (linked version is v2.3.2).

Conduit
  • 2,675
  • 1
  • 26
  • 39
  • Thank thee for answer, I'll check. Must I use RenderWindow instead of Window? – Arman Hayots Jun 13 '16 at 20:01
  • 1
    @ArmanHayots I don't believe so. If you are sticking only to OpenGL functions, then you should only need `sf::Window`, not `sf::RenderWindow`. If you want to leverage SFML's transforms, colors, etc., *then* you need an `sf::RenderWindow`. – Conduit Jun 13 '16 at 20:08
  • Look's like i need to read SFML API completely before ask any another questions. Thank again. – Arman Hayots Jun 13 '16 at 20:24
  • 1
    @ArmanHayots Always a good plan - SFML's API documentation is actually really well done. Good luck! – Conduit Jun 13 '16 at 21:21