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

Author Topic: Using OpenGL with SFML 2.0  (Read 2511 times)

0 Members and 1 Guest are viewing this topic.

Zaid

  • Newbie
  • *
  • Posts: 11
    • View Profile
Using OpenGL with SFML 2.0
« on: September 18, 2012, 03:13:25 am »
So I want to get into 3D graphics, and after a few weeks of studying and writing a little 3D engine using a shit ton of matrix mathematics and SFML 2; I feel that I am finally ready to make the switch over to OpenGL. So my "mentor" if you will who has pretty much taught me how to program wrote some tutorial code for me in SFML 1.6.

(Here are the first two tutorials):
http://pastebin.com/u8zzhggQ
http://pastebin.com/Qwv7mz7i

After switching the SFML 1.6 code over to SFML 2, I compiled to check the results. Everything apparently compiled correctly but the windows don't draw anything like they're supposed to. They only fade from black to white, then white to black and so on and so forth. After asking my "mentor" he said he had no idea, and that it probably had something to do with SFML 2. So here I am, asking the true SFML experts what might possibly be wrong.
Thanks for at least taking the time to read this!
++ZAID++

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: Using OpenGL with SFML 2.0
« Reply #1 on: September 18, 2012, 07:18:35 am »
I don't really have much knowledge on OpenGL, but things underneath in SFML have change in SFML 2, have you taken a look at the offical OpenGL example to see what's nessecary to get things working?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

nullByte

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Using OpenGL with SFML 2.0
« Reply #2 on: September 18, 2012, 07:45:49 am »
Im pretty sure you have to set OpenGL's model view matrix before listing the verticies.

something like...

...

glClear(...);

glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

glBegin(GL_TRIANGLES);

...
 

Its been a while since I used the direct rendering pipeline.

You might want to consider switching over to VBOs and VAOs
theyre a little more in depth to set up but they give you a lot better control and performance.

http://www.opengl.org/wiki/Vertex_Specification

------------
**update

In case it helps I dug up some of my old code where I loaded a cube (its in SFML 1.6)
Its pretty similar to what youre trying to do.
http://pastebin.com/jXe88BtJ

« Last Edit: September 18, 2012, 07:56:29 am by nullByte »

 

anything