Sign in to follow this  
Josheir

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

Recommended Posts

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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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

 

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

  • Announcements

  • Forum Statistics

    • Total Topics
      628378
    • Total Posts
      2982348
  • Similar Content

    • By Kazuma506
      I am trying to recreate the combat system in the game Life is Feudal but make it more complex. The fighting system works by taking in the direction of the mouse movement and if you press the left click it will swing in that direction, though stab, overhead, left (up, down, left right) and right are the only swings that you can do. If you wanted to you could also hold the swing by holding left click so you are able to swing at the perfect moment in the battle. I want to change this so add in more swing directions but I also want to code this from scratch in Unreal. Can anyone give me any pointers or maybe a few snippets of code that work in Unreal that could help me start to implement this type of system?
       
       
    • By rXpSwiss
      Hello,
      I am sending compressed json data from the UE4 client to a C++ server made with boost.
      I am using ZLib to compress and decompress all json but it doesn't work. I am now encoding it in base64 to avoid some issues but that doesn't change a thing.
      I currently stopped trying to send the data and I am writing it in a file from the client and trying to read the file and decompress on the server side.
      When the server is trying to decompress it I get an error from ZLib : zlib error: iostream error
      My question is the following : Did anyone manage to compress and decompress data between a UE4 client and a C++ server ?
      I cannot really configure anything on the server side (because boost has its ZLib compressor) and I don't know what is wrong with the decompression.
      Any idea ?
      rXp
    • By noodleBowl
      I was wondering if someone could explain this to me
      I'm working on using the windows WIC apis to load in textures for DirectX 11. I see that sometimes the WIC Pixel Formats do not directly match a DXGI Format that is used in DirectX. I see that in cases like this the original WIC Pixel Format is converted into a WIC Pixel Format that does directly match a DXGI Format. And doing this conversion is easy, but I do not understand the reason behind 2 of the WIC Pixel Formats that are converted based on Microsoft's guide
      I was wondering if someone could tell me why Microsoft's guide on this topic says that GUID_WICPixelFormat40bppCMYKAlpha should be converted into GUID_WICPixelFormat64bppRGBA and why GUID_WICPixelFormat80bppCMYKAlpha should be converted into GUID_WICPixelFormat64bppRGBA
      In one case I would think that: 
      GUID_WICPixelFormat40bppCMYKAlpha would convert to GUID_WICPixelFormat32bppRGBA and that GUID_WICPixelFormat80bppCMYKAlpha would convert to GUID_WICPixelFormat64bppRGBA, because the black channel (k) values would get readded / "swallowed" into into the CMY channels
      In the second case I would think that:
      GUID_WICPixelFormat40bppCMYKAlpha would convert to GUID_WICPixelFormat64bppRGBA and that GUID_WICPixelFormat80bppCMYKAlpha would convert to GUID_WICPixelFormat128bppRGBA, because the black channel (k) bits would get redistributed amongst the remaining 4 channels (CYMA) and those "new bits" added to those channels would fit in the GUID_WICPixelFormat64bppRGBA and GUID_WICPixelFormat128bppRGBA formats. But also seeing as there is no GUID_WICPixelFormat128bppRGBA format this case is kind of null and void
      I basically do not understand why Microsoft says GUID_WICPixelFormat40bppCMYKAlpha and GUID_WICPixelFormat80bppCMYKAlpha should convert to GUID_WICPixelFormat64bppRGBA in the end
       
    • By HD86
      As far as I know, the size of XMMATRIX must be 64 bytes, which is way too big to be returned by a function. However, DirectXMath functions do return this struct. I suppose this has something to do with the SIMD optimization. Should I return this huge struct from my own functions or should I pass it by a reference or pointer?
      This question will look silly to you if you know how SIMD works, but I don't.
    • By pristondev
      Hey, Im using directx allocate hierarchy from dx9 to use a skinned mesh system.
      one mesh will be only the skeleton with all animations others meshes will be armor, head etc, already skinned with skeleton above. No animation, idle position with skin, thats all I want to use the animation from skeleton to other meshes, so this way I can customize character with different head, armor etc. What I was thinking its copy bone matrices from skeleton mesh to others meshes, but Im a bit confused yet what way I can do this.
       
      Thanks.
  • Popular Now