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

Author Topic: [Solved] SFML 2.0 RC, OpenGL 3.3 and Window.display()  (Read 2102 times)

0 Members and 1 Guest are viewing this topic.

impega

  • Newbie
  • *
  • Posts: 2
    • View Profile
[Solved] SFML 2.0 RC, OpenGL 3.3 and Window.display()
« on: September 26, 2012, 08:37:12 am »
I started following this tutorial on http://en.wikibooks.org/wiki/OpenGL_Programming/Modern_OpenGL_Introduction but instead of using GLUT I decided on using SFML 2.0 RC. The goal is to draw a simple triangle in 2D.

The full source of the tutorial is here:
https://gitorious.org/wikibooks-opengl/modern-tutorials/blobs/master/tut01_intro/triangle.cpp
My code using SFML 2.0 RC is here:
http://pastebin.com/ucunPzL3

If you look at the tutorial code on line 105 you'll see a call to glutSwapBuffers() at the end of the onDisplay() function.
Since I'm not using GLUT, I figured this should be App.display() (where App is of type sf::Window).
So I placed App.display() after the call to onDisplay() in the main loop, but that doesn't show any triangle.
I also tried passing sf::Window App to the onDisplay() function with a pointer, and calling App->display() at the end, and inside onDisplay() but that didn't show a triangle either.

The tutorial code works fine on my system when compiling with
g++ -o main main.cpp -lglut -lGLEW -lGL
And my code is compiled (without glut) using:
g++ -o main main.cpp -lsfml-window -lsfml-system -lGLEW -lGL

What's the best way to replace glutSwapBuffers()  ? 
« Last Edit: September 26, 2012, 09:43:14 am by impega »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: SFML 2.0 RC, OpenGL 3.3 and Window.display()
« Reply #1 on: September 26, 2012, 08:53:07 am »
Your code looks ok. Unfortunately I can't test it because my graphics card doesn't support OpenGL 3.3.

You should have a look at the "Window" example that comes with SFML, and which works. Then try to modify it by small steps so that it looks like your program, and see at which moment it stops working.
Laurent Gomila - SFML developer

impega

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: SFML 2.0 RC, OpenGL 3.3 and Window.display()
« Reply #2 on: September 26, 2012, 09:42:52 am »
Instead of applying your idea to Window.cpp, I slowly changed the tutorial code until things... just worked! :D
That means I must have made a mistake while transcribing the tutorial code. 

For people interested in seeing http://en.wikibooks.org/wiki/OpenGL_Programming/Modern_OpenGL_Introduction work with SFML, check out the working version here: http://pastebin.com/xnTzaW96

Pretty amazing how it only takes one line of code to get a working opengl render context in SFML :) Thanks!