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

Author Topic: glClear  (Read 2904 times)

0 Members and 2 Guests are viewing this topic.

sludge

  • Newbie
  • *
  • Posts: 24
    • View Profile
glClear
« on: July 23, 2010, 07:18:58 pm »
Will glClear() act on all objects that have been drawn to the buffer using drawing functions native to SFML as well as those drawn using openGL functions? Or is it only the latter?

My guess is both because, at its core, SFML is an tool through which one can interact with OpenGL, among other interfaces.   I suppose if the latter is the case, then SFML and OpenGL functions draw to separate buffers before display.  How exactly do things work under the hood?

Also, if I call window::clear(), does this clear everything I have drawn with OpenGL as well?  I imagine the answer to this question is based on the answer to the first.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
glClear
« Reply #1 on: July 24, 2010, 10:40:16 am »
RenderWindow::Clear() calls glClear, which simply fills the rendering buffer with the current clear-color. So it doesn't matter what was drawn before and by who, everything is cleared after that.
Laurent Gomila - SFML developer

sludge

  • Newbie
  • *
  • Posts: 24
    • View Profile
glClear
« Reply #2 on: July 28, 2010, 06:36:53 pm »
Does this mean that any OpenGL setting I make could also affect drawing of graphics using SFML commands?  For example, could I accidentally adjust where I draw a box if I were to have set the viewport before calling said draw command?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
glClear
« Reply #3 on: July 28, 2010, 06:44:31 pm »
You can. SFML ensures that the states it needs are correct when drawing a drawable, but doesn't care about others (which may as well have an impact on what it draws).

If you want to be sure that your OpenGL settings will never mess up with SFML (and vice versa), use this
Code: [Select]
window.PreserveOpenGLStates(true);
Laurent Gomila - SFML developer

 

anything