Hey guys,
I'm trying to display some simple text and im getting weird errors, now this piece of code works
gEntity.h
#ifndef g_Entity_H
#define g_Entity_H
//includes
#include "g_Rec.h"
#include "g_Image_Manager.h"
#include <iostream>
#include <string>
//Game Includes
#include <SFML/System.hpp>
#include <SFML/Window.hpp>
#include <SFML/Graphics.hpp>
class gEntity{
private:
sf::Sprite tex;
bool spr,txt,btn;
rect pos;
sf::Font fontStyle;
sf::Text textDisplay;
public:
gEntity();
void setup(int id, gImageManager& imgManage);
sf::Sprite rtnTex(){return tex;}
bool rtnSpr(){return spr;}
bool rtnTxt(){return txt;}
bool rtnBtn(){return btn;}
rect rtnPos(){return pos;}
void intText(int set);
void stringText(std::string set);
sf::Text rtnText(){return textDisplay;}
};
#endif
//skip alot of the cpp file
case 1:
{
fontStyle.loadFromFile("arial.ttf");
//textDisplay.setFont(fontStyle);
textDisplay.setString("Booty Swag");
textDisplay.setPosition(100,100);
spr = false; btn = false; txt = true;
break;
gState code just to draw stuff
for(int i = 0; i < entities.size(); i++ )
{
if (entities.at(i).rtnBtn() == true)
{
}
if (entities.at(i).rtnTxt() == true)
{
screen.draw(entities.at(i).rtnText());
}
if (entities.at(i).rtnSpr() == true)
{
screen.draw(entities.at(i).rtnTex());
}
}
now this works fine, but if i close my window sometimes it will stay status is 0 or a random number and throw a error as i close, and the other error is if i uncomment the line which sets the font style at the draw method for the rtnText it displays memory violation... im using SFML 2.0, can anyone help me out?
Cheers
Is there a way i can pass a sf::Font via parameters?
Yes as (const) reference or (smart) pointer.
void foo(const sf::Font& font)
Nope no global instances or variables, we both running ATI chips as we on laptops, what debugger would help? the visual studios express 2010 C++ says that status is 0, this is what we get
crt0dat.c
this is the method it displays
void __cdecl __crtExitProcess (
int status
)
{
__crtCorExitProcess(status);
/*
* Either mscoree.dll isn't loaded,
* or CorExitProcess isn't exported from mscoree.dll,
* or CorExitProcess returned (should never happen).
* Just call ExitProcess.
*/
ExitProcess(status);
}
he has mscoree.dll in System32,
we are using SFML 2.0 RC