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

Author Topic: Displaying text: Visual Studio RELEASE Mode.  (Read 3302 times)

0 Members and 1 Guest are viewing this topic.

Nikko_Bertoa

  • Newbie
  • *
  • Posts: 10
    • MSN Messenger - nikko_bertoa@hotmail.com
    • View Profile
    • https://sites.google.com/site/nicolasbertoa/
Displaying text: Visual Studio RELEASE Mode.
« on: February 24, 2010, 07:25:01 pm »
Hi community.

I'm making a game and I display text for health, FPS, etc.
When I compile and run in DEBUG MODE the text displays correctly, but when I compile the same code in RELEASE MODE the text doesn't display.

I have both modes with SFML_DYNAMIC, I setted the same libraries with -d for DEBUG MODE and without -d for RELEASE MODE.
My Game Programming Portfolio:

https://sites.google.com/site/nicolasbertoa/

Nikko_Bertoa

  • Newbie
  • *
  • Posts: 10
    • MSN Messenger - nikko_bertoa@hotmail.com
    • View Profile
    • https://sites.google.com/site/nicolasbertoa/
Displaying text: Visual Studio RELEASE Mode.
« Reply #1 on: February 25, 2010, 05:29:48 am »
I found the problem. I wrote SFML_DINAMIC not SFML_DYNAMIC in the Release Mode options.
My Game Programming Portfolio:

https://sites.google.com/site/nicolasbertoa/

Nikko_Bertoa

  • Newbie
  • *
  • Posts: 10
    • MSN Messenger - nikko_bertoa@hotmail.com
    • View Profile
    • https://sites.google.com/site/nicolasbertoa/
Displaying text: Visual Studio RELEASE Mode.
« Reply #2 on: February 26, 2010, 02:18:42 am »
I'm having the same problem. What can it be??
My Game Programming Portfolio:

https://sites.google.com/site/nicolasbertoa/

Nikko_Bertoa

  • Newbie
  • *
  • Posts: 10
    • MSN Messenger - nikko_bertoa@hotmail.com
    • View Profile
    • https://sites.google.com/site/nicolasbertoa/
Displaying text: Visual Studio RELEASE Mode.
« Reply #3 on: February 26, 2010, 04:41:25 pm »
This is my "main.cpp"

Code: [Select]

//
//  Headers
//
#include "GameManager.h"


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

GameManager gameManager;

gameManager.Run();

return EXIT_SUCCESS;

}




This is my "GameManager.h"
Code: [Select]


#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"
Code: [Select]


//------------------------------------------------------------------------
//
//  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.
My Game Programming Portfolio:

https://sites.google.com/site/nicolasbertoa/

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Displaying text: Visual Studio RELEASE Mode.
« Reply #4 on: February 26, 2010, 04:55:36 pm »
Here is the definition of the assert macro in release mode:
Code: [Select]
#define assert(cond)
It evaluates to nothing, so whatever you put inside is never compiled in release mode.

So you should only put tests and comparisons into your asserts, not direct calls to functions that do something useful.
Laurent Gomila - SFML developer

Nikko_Bertoa

  • Newbie
  • *
  • Posts: 10
    • MSN Messenger - nikko_bertoa@hotmail.com
    • View Profile
    • https://sites.google.com/site/nicolasbertoa/
Displaying text: Visual Studio RELEASE Mode.
« Reply #5 on: February 26, 2010, 07:04:53 pm »
Thanks!!! I wrote:

Code: [Select]

bool correctLoading = m_font->LoadFromFile("resources/fonts/arial.ttf");
assert(correctLoading);


and now my application works!
My Game Programming Portfolio:

https://sites.google.com/site/nicolasbertoa/