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

Author Topic: My Text and All Scene Gone ...  (Read 2062 times)

0 Members and 4 Guests are viewing this topic.

fuad

  • Newbie
  • *
  • Posts: 1
    • View Profile
My Text and All Scene Gone ...
« on: August 08, 2008, 04:16:09 am »
Hi, greetings.

I had problem with my code that use sf::string

I want to use it as fps information in my program. My program are OpenGL base. But all my OpenGL scene and the text are gone when I try to draw a text. I don't know what wrong with my program. This is my code

Code: [Select]

this->appWin = new sf::RenderWindow(sf::VideoMode(width,height,bpp),"Test");
this->appWin->PreserveOpenGLStates(true);
.
.
.
 GLuint fps = 0;
GLfloat time_elapsed = 0;
stringstream s;  
    s << fps;
sf::String fpsStr(s.str());
fpsStr.SetColor(sf::Color::White);

this->initEngine();

while (this->appWin->IsOpened())
    {    
        sf::Event Event;
        while (this->appWin->GetEvent(Event))
        {    
            if (Event.Type == sf::Event::Closed)
                this->appWin->Close();
           
            if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::Escape))
                this->appWin->Close();
        }

this->appWin->SetActive();
this->draw();
this->appWin->Draw(fpsStr);
        this->appWin->Display();

/*time_elapsed += this->appWin->GetFrameTime();
if (time_elapsed > 1.0f) {

}else {
fps++;
}*/
    }

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
My Text and All Scene Gone ...
« Reply #1 on: August 08, 2008, 07:35:36 am »
You should try to extract a minimal (but still complete) program which reproduces this bug.
Laurent Gomila - SFML developer

vpoqol5

  • Newbie
  • *
  • Posts: 5
    • View Profile
My Text and All Scene Gone ...
« Reply #2 on: May 30, 2009, 08:48:25 pm »
I see it's not solved, I made this minimalist example witch should reproduce  the same behavior ( It works for me)

Code: [Select]


glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

glLoadIdentity();

sf::String sText("Text");
sText.SetPosition(100, 100);
GameApp.Window.Draw(sText);

gluLookAt(...);

GameApp.mdRoom.Draw(); //Draws a model...or not :)



but if we put it like this

Code: [Select]


glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

glLoadIdentity();

sf::String sText("Text");
sText.SetPosition(100, 100);
GameApp.Window.Draw(sText);

gluPerspective(45.0f,(GLfloat)SCREEN_WIDTH/(GLfloat)SCREEN_HEIGHT,0.1f,1000000.0f);

gluLookAt(...);

GameApp.mdRoom.Draw(); //Draws a model...or not :)



It works almost correctly (everything what is drawn is in front of text but we haven't pushed stack so just forget it), so it can be problem in zFar parameter of gluPerspective function, but sometimes I had something drawn no matter where it was so it could be also zNear, anyway, you could investigate and see where the problem lies, and then fix it

preserveopenglstate doesn't have any effect on this

Peter

 

anything