• Advertisement
Sign in to follow this  

[SFML] Visual Studio RELEASE MODE - Don't see the text

This topic is 2913 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

This is my "main.cpp"
//
//  Headers
//
#include "GameManager.h"


//
// Main
//
int main(void)
{

	GameManager gameManager;

	gameManager.Run();

	return EXIT_SUCCESS;

}


This is my "GameManager.h"

#ifndef GAMEMANAGER_H
#define GAMEMANAGER_H


//------------------------------------------------------------------------
//
//  Name:   GameManager.h
//
//  Desc:   Machine that manages the game's states.
//
//  Author: Nikko Bertoa 2010 (nicobertoa@gmail.com)
//
//------------------------------------------------------------------------


//
// Headers
//
#include <SFML/Graphics.hpp>


class GameManager
{

public:

	GameManager(); 

	virtual ~GameManager(); 

	void Run();


private:

	sf::RenderWindow m_screen;

	sf::Font* m_font;
	sf::String* m_fpsText;

};


#endif // GAMEMANAGER_H

And this is my "GameManager.cpp"

//------------------------------------------------------------------------
//
//  Name:   GameManager.cpp
//
//  Desc:   Machine that manages the game's states.
//
//  Author: Nikko Bertoa 2010 (nicobertoa@gmail.com)
//
//------------------------------------------------------------------------


//
// Headers
//
#include "GameManager.h"
#include <cassert>


// Constructor
GameManager::GameManager() 
			:  m_screen(sf::VideoMode::GetDesktopMode(),"CaperucitaPlusPlus",
			sf::Style::Fullscreen | sf::Style::Close)
{

	m_font = new sf::Font();
	assert(m_font->LoadFromFile("resources/fonts/arial.ttf"));
	m_fpsText = new sf::String("Test Text", *m_font);
	m_fpsText->SetSize(30.0f);
	float xCoord = 10.0f;
	float yCoord = 10.0f;
	m_fpsText->SetPosition(xCoord, yCoord);
	m_fpsText->SetStyle(sf::String::Regular);
	m_fpsText->SetColor(sf::Color::White);
	
}


// Destructor
GameManager::~GameManager()
{

	if(m_font != 0)
	{
	
		delete m_font;
		m_font = 0;

	}

	if(m_fpsText != 0)
	{

		delete m_fpsText;
		m_fpsText = 0;

	}

		
}


void GameManager::Run()
{

	// Start game loop
	while (m_screen.IsOpened())
	{
		// Process events
		sf::Event Event;
		while (m_screen.GetEvent(Event))
		{

			// Close window : exit
			if (Event.Type == sf::Event::Closed)
				m_screen.Close();

		}

		// Clear the screen (fill it with black color)
		m_screen.Clear();

		m_screen.Draw(*m_fpsText);		

		// Display window contents on screen
		m_screen.Display();

	}

}

When I run the application in DEBUG MODE, I see the text. When I run the application in RELEASE MODE, I don't see the text. I'm using Visual Studio 2008.

Share this post


Link to post
Share on other sites
Advertisement
Isn't that because you are loading the font inside the assert-statement?
In release mode, Visual Studio defines 'NDEBUG'.

If you look inside assert.h
you will find the following:


#ifdef NDEBUG
#define assert(_Expression) ((void)0)
#else
...
#endif




That should translate to you not loading any font.

Share this post


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

  • Advertisement