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

Author Topic: resetGLStates() problem  (Read 2285 times)

0 Members and 1 Guest are viewing this topic.

lol123

  • Newbie
  • *
  • Posts: 11
    • View Profile
resetGLStates() problem
« on: November 30, 2013, 04:24:25 pm »
Could somebody give me an example how to use resetGLStates() function to mix direct OpenGL drawing with RenderTarget.draw() function without using pushGLStates() and popGLStates? Docs (http://www.sfml-dev.org/documentation/2.1/classsf_1_1RenderTarget.php#aac7504990d27dada4bfe3c7866920765) don't help  :( Just a code snippet like that:

window.draw();
//magic
glRectf();
//magic
window.draw()
//magic
glRectf();

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10884
    • View Profile
    • development blog
    • Email
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

lol123

  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: resetGLStates() problem
« Reply #2 on: November 30, 2013, 06:48:11 pm »
I know, but the example doesn't work

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Re: resetGLStates() problem
« Reply #3 on: November 30, 2013, 06:51:47 pm »
Why don't you tell us what doesn't work? ???
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

lol123

  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: resetGLStates() problem
« Reply #4 on: November 30, 2013, 07:06:31 pm »
Well, I want to mix OpenGL draw functions and window.draw() function. Now I surround every OpenGL functions block with popGLStates() and pushGLStates():
window.draw();

popGLStates();
glRectf();
pushGLStates();

window.draw();

popGLStates();
glRectf();
pushGLStates();

window.draw();

but that doesn't work. What am I doing wrong?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10884
    • View Profile
    • development blog
    • Email
Re: resetGLStates() problem
« Reply #5 on: November 30, 2013, 07:58:58 pm »
I don't have experience with OpenGL, but I don't think you can switch between states multiple times for one frame. So you can just either draw OpenGL stuff first and then SFML or the other way around - not sure though.

Anyways you still haven't said what happens that let's you say "it doesn't work". Does it crash? Do you get an error? Is the drawing odd?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

lol123

  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: resetGLStates() problem
« Reply #6 on: November 30, 2013, 08:01:06 pm »
It just doesn't draw what I draw with OpenGL calls

Thanks, I will try that

lol123

  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: resetGLStates() problem
« Reply #7 on: November 30, 2013, 08:08:21 pm »
No that didn't help

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: resetGLStates() problem
« Reply #8 on: November 30, 2013, 08:51:41 pm »
Quote
now I surround every OpenGL functions block with popGLStates() and pushGLStates():
This is not the correct usage. Please read the tutorial one more time.
Laurent Gomila - SFML developer