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

Author Topic: openGL + SFML window question  (Read 2272 times)

0 Members and 1 Guest are viewing this topic.

RixCoder

  • Newbie
  • *
  • Posts: 40
    • View Profile
openGL + SFML window question
« on: September 16, 2009, 02:52:23 am »
I'm more or less curious as to how the normal 2d calls for drawing to a renderwindow work in tandem with just plain openGL calls.

For example im working on doing a dynamic 2D shadow system for my next project and I noticed that if the plain openGL calls are not the last thing to be called they don't appear to render or maybe getting discarded somewhere?

Is there a way to draw openGL primitives ( like in my case a triangle strip ) than draw normal 2D sfml draw calls over it?

Code Ex: This works
Code: [Select]
for(unsigned int i = 0; i < m_FrontList.size(); ++i)
m_pGameWindow.Draw(*m_FrontList[i].DrawObj.first);

glBegin(GL_TRIANGLE_STRIP);
for(unsigned int i = 0; i < m_TriangleFan.size(); ++i)
{
for(unsigned int k = 0; k < m_TriangleFan[i].m_Points.size(); ++k)
{
glVertex2f(m_TriangleFan[i].m_Points[k].x, m_TriangleFan[i].m_Points[k].y);
}
}
glEnd();


This Does not!
Code: [Select]


glBegin(GL_TRIANGLE_STRIP);
for(unsigned int i = 0; i < m_TriangleFan.size(); ++i)
{
for(unsigned int k = 0; k < m_TriangleFan[i].m_Points.size(); ++k)
{
glVertex2f(m_TriangleFan[i].m_Points[k].x, m_TriangleFan[i].m_Points[k].y);
}
}
glEnd();
for(unsigned int i = 0; i < m_FrontList.size(); ++i)
m_pGameWindow.Draw(*m_FrontList[i].DrawObj.first);

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
openGL + SFML window question
« Reply #1 on: September 16, 2009, 08:57:34 am »
I guess your real code contains more OpenGL calls, as this example doesn't change any render state (and thus doesn't impact SFML).

The solution is simple: call m_pGameWindow.PreserveOpenGLStates(true) so that SFML won't assume anything about the current states, and will make a full reset of them before drawing anything.
Laurent Gomila - SFML developer

 

anything