Jump to content
  • Advertisement
Sign in to follow this  
Meerul264

[SFML] Text not drawn problem

This topic is 2158 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I've a problem where, when I show another window on the screen, everything works fine except the text isn't printed out on the screen. I've already called the loadText() in the int main(). Help me fix this problem.

 

 

#include "ErrorMessages.h"
#include "Global.h"
 
#include <SFML/Graphics.hpp>
 
ErrorMessages::ErrorMessages()
{
    //ctor
}
 
ErrorMessages::~ErrorMessages()
{
    //dtor
}
 
void ErrorMessages::loadText()
{
    if(ErrorFont.loadFromFile("monospa1.ttf"))
        ErrorText.setFont(ErrorFont);
}
void ErrorMessages::sendErrorBox_alreadyvote()
{
    sf::RenderWindow AlreadyVoted(sf::VideoMode(570,50,32), "ERROR - multiple votes not allowed");
 
    while(AlreadyVoted.isOpen())
    {
        sf::Event Event;
        while(AlreadyVoted.pollEvent(Event))
        {
            if(sf::Keyboard::isKeyPressed(sf::Keyboard::Escape) || Event.type == sf::Event::Closed)
                AlreadyVoted.close();
        }
 
        ErrorText.setString("You already vote this officer!");
        ErrorText.setColor(sf::Color::White);
 
        AlreadyVoted.draw(ErrorText);
        AlreadyVoted.display();
 
    }
}
 
void ErrorMessages::sendErrorBox_incompleteVote()
{
    sf::RenderWindow IncompleteVotes(sf::VideoMode(570,50,32),"ERROR - incomplete votes");
 
    while(IncompleteVotes.isOpen())
    {
        sf::Event Event;
        while(IncompleteVotes.pollEvent(Event))
        {
            if(sf::Keyboard::isKeyPressed(sf::Keyboard::Escape) || Event.type == sf::Event::Closed)
                IncompleteVotes.close();
        }
    }
 
    ErrorText.setString("You must vote all officers!");
    ErrorText.setColor(sf::Color::White);
 
    IncompleteVotes.draw(ErrorText);
    IncompleteVotes.display();
 
}
 
Thank you.
Edited by Meerul264

Share this post


Link to post
Share on other sites
Advertisement

I don't see where you specify where in the window to draw the text.

 

BTW, these SFML specific questions can readily be answered at the very active SFML forums at sfml-dev.org.

 

Good Luck

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!