Advertisement

SFML display() Problem, not Displaying ON SECOND FUNCTION CALL?

Started by October 21, 2017 03:28 PM
3 comments, last by Josheir 7 years, 1 month ago

I am working on a SFML c++ program that uses two rendering windows passed from main to the function drawmessage in a class textmessage.  I was using the second window for displaying debug information that is displayed because I could not get the appropriate information from the SFML object.

With that said, here is the part of that function that works the first time through and does not on the second usage.  I really have changed the code to try and get it working.   For example I created the two objects locally here for testing.  I am sorry about the extra commented statements they help convey the message too.

There is the same problem though, the statement :     string test =     message_holder10.getString(); is working and shows "asty" on every run.  On the first run of the program there is a display of the text correctly however on the second call there is no display of it.  (I am stepping through until the display command.)

I feel like I have exhausted my tries so I am asking for help please.

If it is the font I will just die, I really don't think it is.

 

 

 

            sf::Text message_holder10;
            sf::RenderWindow windowtype3(sf::VideoMode(700, 1000), "a");


            if ((space_is_used && on_last_line) || (space_is_used && ((line_number) == (total_lines - 2))))
            {


                //string temp_string = message::Get_Out_Bound_String();

                //int length_of_string = temp_string.length();

                sf::Font Fontforscore;

                if (gflag == 0)
                {
                    gflag = 1;

                    

                    if (!Fontforscore.loadFromFile("ARIALBD.ttf"))
                    {
                        exit(1);
                    }


                    message_holder10.setFont(Fontforscore);
                    message_holder10.setCharacterSize(100);
                    message_holder10.setFillColor(sf::Color::Red);

                    message_holder10.setOrigin(0, 0);

                    message_holder10.setPosition(0, 0);
                    windowtype2.close();

                }

                message_holder10.setString("asty");
                    
                    //int y_for_space = display_y_setting + (total_lines - 2) * each_vertical_offset_is;

                    //int this_width = 0;
                    
                    //float x = message_holder.getLocalBounds().width;


                    
                    
                    //message_holder.setPosition( ( (first_width - x )/2), y_for_space);
                    
            
                    //windowtype2.close();


                    string test =     message_holder10.getString();
                    
                    windowtype3.clear();
                    windowtype3.draw(message_holder10);
                    windowtype3.display();
                    
                    
                     

 
                    //windowtype.display();

                


                 Wait_For_Space_Press();

                

 

/////////////////////////

 

Before, the :      windowtype3.display()  without the clear was drawing other text in this call, just not this one particular text message with it!

 

Thank you so much I am wondering what it can be,

 

Josheir

I have two suggestions:

  1. Boil down the code to the simplest program that displays the problem. You may find a mistake in the process of doing that, and if you don't you can post the complete small program here, so we can try to reproduce the problem ourselves.
  2. Try the forum on the SFML website. I haven't used it in years, but they used to be really helpful there.
Advertisement

Thank you Alvaro, It's the same code again so it's strange I thought maybe it's some over-bound array or uninitialized object.  I'll try doing what you said.  Maybe someone else will comment too.

Have a happy Halloween your image looks like you may do just that!

Appreciatively,

Josheir

 

Okay I boiled down the program and got it working like Alvaro said, funny how it happened though; confusedly I never did find the exact problem.  I did however reprogram with a revert and the newer copy and it is now working.

 

Thanks Alvaro,

Josheir

This topic is closed to new replies.

Advertisement