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

Author Topic: Drawing with resetGLstates  (Read 1291 times)

0 Members and 1 Guest are viewing this topic.

Nawy

  • Newbie
  • *
  • Posts: 6
    • View Profile
Drawing with resetGLstates
« on: September 30, 2014, 05:48:51 am »
I'm using in my project SFGUI. And for drawing I'm using following code:
void render()
{
        glDisableClientState(GL_COLOR_ARRAY);
        m_rWindow->pushGLStates();

        glTranslatef(m_pos.x, m_pos.y, 0.0f);
        glPointSize(1.0f);
        glColor3f(0.7f, 0.7f, 1.0f);
        glDisableClientState(GL_COLOR_ARRAY);
        glDisableClientState(GL_TEXTURE_COORD_ARRAY);
        float vertData[] = {20.0f, 20.0f, 50.0f, 50.0f };
        glEnableClientState(GL_VERTEX_ARRAY);
                glVertexPointer(2, GL_FLOAT, 0, vertData);
                glDrawArrays(GL_POINTS, 0, 2);
        glDisableClientState(GL_VERTEX_ARRAY);
        m_rWindow->popGLStates();

        m_rWindow->resetGLStates();
        m_sfgui.Display(*m_rWindow);

}

glDrawArrays(GL_POINTS, 0, 2); - is drawed nothing

Why? What can I do for correct it?

binary1248

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1405
  • I am awesome.
    • View Profile
    • The server that really shouldn't be running
Re: Drawing with resetGLstates
« Reply #1 on: October 01, 2014, 05:51:49 pm »
All I can say is that this probably doesn't have anything to do with SFGUI, so please don't mention it. It confuses people who might otherwise be able to help.

The problem is that it seems that you are not managing your OpenGL states properly. SFGUI assumes that you are using SFML's graphics module for rendering, so you can make the same assumptions. If you don't intend on using SFML graphics to draw stuff, don't use a sf::RenderWindow, just use a sf::Window instead. SFGUI will detect it and adjust accordingly.

The problem you are having would probably also happen even without using SFGUI, simply just mixing your OpenGL code with SFML graphics code. You need to make sure that all OpenGL states are set back to the values that the respective library expects them to be before continuing to do stuff with them. If you don't know what all these states are, you can search around on the forum. There have been enough posts about mixing SFML and OpenGL.

If you really want help targeted towards your specific code, you will have to show us more of it. These 21 lines, where you don't even show the declaration of the objects and other setup that has to be performed, aren't enough for anyone to provide meaningful help. The result is that people, such as myself with this post, have to resort to guessing, and we all know how unproductive that is.
SFGUI # SFNUL # GLS # Wyrm <- Why do I waste my time on such a useless project? Because I am awesome (first meaning).

 

anything