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

Author Topic: [SOLVED] SFML Shape and OGL Name Stack  (Read 1487 times)

0 Members and 1 Guest are viewing this topic.

cidolfas7

  • Newbie
  • *
  • Posts: 1
    • View Profile
[SOLVED] SFML Shape and OGL Name Stack
« on: February 16, 2011, 05:21:00 pm »
I'm using the OGL name stack to allow selection of geometry.  I have code that's drawing a set of squares to the screen using OGL calls.  My selection code works, and I'm able to click on my drawn squares.

Now I'm trying to draw a SFML shape to the screen, and it does.  The issue is that when I try to select any of my squares the SFML shape gets selected no matter what.

Visually the drawn SFML shape only takes up a small portion of the top right corner, but according to the OGL name stack it's taking up the whole screen.  Thus anytime I try to click on other geometry the OGL name stack tells me I'm clicking on the SFML shape.

Squares drawn with OGL:
Code: [Select]

double tx = -1.0 * (double)(width-1);
double ty = -1.0 * (double)(height-1);

for (int j = height-1; j >= 0; j--) {
    for (int i = width-1; i >= 0; i--) {
       
        glTranslated(tx, ty, 0.0);
        glPushName(j);
        glPushName(i);

        glColor3f(0.
        glBegin(GL_QUADS);
          glNormal3f(0.0f, 0.0f, 1.0f);
          glVertex3f(-1.0f, 1.0f, 0.0f);
   
          glNormal3f(0.0f, 0.0f, 1.0f);
          glVertex3f(-1.0f, -1.0f, 0.0f);
   
          glNormal3f(0.0f, 0.0f, 1.0f);
          glVertex3f(1.0f, -1.0f, 0.0f);
   
          glNormal3f(0.0f, 0.0f, 1.0f);
          glVertex3f(1.0f, 1.0f, 0.0f);
        glEnd();
           
        glPopName();
        glPopName();
        tx+=2.0;
    }

    ty+=2.0;
    tx = -1.0 * (double)(width-1);
}



SFML shape:
Code: [Select]

sf::Shape rect = sf::Shape::Rectangle(windowWidth-300, 0, windowWidth, 50, sf::Color(255, 255, 255, 255));

glPushName(-1);
App.Draw(rect);
glPopName();


(App is a SFML RenderWindow).



EDIT:

Did more searching on the forums for issues that seemed similar.  Looks like using PreserveOpenGLStates may have fixed the issue.

2ND EDIT:

Changed topic to solved.  Preserving the OGL state fixed the issue (and a couple others actually).

 

anything