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

Author Topic: push/resetGLStates and buffers  (Read 1536 times)

0 Members and 1 Guest are viewing this topic.

Radek

  • Newbie
  • *
  • Posts: 2
    • View Profile
push/resetGLStates and buffers
« on: October 27, 2017, 02:14:27 am »
I had a problem up until recently involving the mixing of OpenGL draw calls and SFML draw calls.

I'm focusing on using OpenGL itself and simply having SFML handle input, OpenGL contexts, Mutex, and a few simple sprites.

While implementing my more advanced model loading/displaying, some sprites within the program stopped drawing (pause menu sprites for the game), it was nothing major and I ignored it until my next bug sweep.

Anyway, I found no answer on the internet or these forums from my searching, but I eventually worked it out.

I am unsure if its a bug, not a feature yet, or something that push/resetGLStates will not handle, but it did not reset the GL_VERTEX_BUFFER I was using for my models. It was in the end my fault, as I should have been resetting the buffer after using it, but I'm an idiot sometimes.

I thought I'd share the results here in case someone else has the same issue, or if the development team would consider implementing resetting the vertex buffer when calling push/resetGLStates because it interferes with SFML draw calls if a buffer is currently set.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: push/resetGLStates and buffers
« Reply #1 on: October 27, 2017, 06:38:13 am »
Quote
I'm focusing on using OpenGL itself and simply having SFML handle input, OpenGL contexts, Mutex, and a few simple sprites.
If you use sfml-graphics only for drawing a few sprites, maybe you should do it with OpenGL too and totally get rid of the graphics module and its issues.

Quote
I found no answer on the internet or these forums
This is surprising, because it is a recurring problem.
Laurent Gomila - SFML developer

binary1248

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1405
  • I am awesome.
    • View Profile
    • The server that really shouldn't be running
SFGUI # SFNUL # GLS # Wyrm <- Why do I waste my time on such a useless project? Because I am awesome (first meaning).

Radek

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: push/resetGLStates and buffers
« Reply #3 on: October 31, 2017, 04:59:01 am »
Quote
I found no answer on the internet or these forums
This is surprising, because it is a recurring problem.

its largely because I didn't know what the problem was until I actually solved it.

The only keywords I could use involved things such as sprites not drawing. Once I found the problem I should have searched, but I didn't, that was another my bad moment.

As for the other suggestion, I plan to drop the graphics module, but the current project has a time crunch to it so I don't have the time to manage basic but useful functions that the Sprite object has, so I may as well use that for now, and simplify the draw code to what you have built in to SFML.

Anyway, thanks for the help, sorry for repeating a question/problem that has been looked at before.
However while I am here, are you unable to make resetGLStates reset the buffer states because SFML itself still uses old OpenGL? After all, the fix was to simply call
glBindBuffer(GL_ARRAY_BUFFER, 0);