1
General / Re: SFML 2.0 + Code::Blocks' autocompletion = problem
« on: May 13, 2013, 08:27:27 pm »
It happened to me when working with project stored in directory path with special characters (space, exclamation mark etc.)
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
fscanf(FileHandle, "%d\n", &AreaSize);
int ID=0;
for(int X = 0; X < AreaSize; X++)
{
for(int Y = 0; Y < AreaSize; Y++)
{
char MapFile[255];
fscanf(FileHandle, "%s ", MapFile);
CMap tempMap;
MapList.push_back(tempMap);
if(MapList[ID].OnLoad(MapFile) == false)
{
fclose(FileHandle);
cout<<"error loading map";
return false;
}
MapList[ID].m_TilesetTexture.LoadFromFile(TilesetFile);
MapList[ID].m_TilesetSprite.SetTexture(MapList[ID].m_TilesetTexture);
ID++;
}
I found that vector::push_back may sometime reallocate memory http://www.cplusplus.com/reference/stl/vector/push_back/ effectively increases the vector size by one, which causes a reallocation of the internal allocated storage if the vector size was equal to the vector capacity before the call. Reallocations invalidate all previously obtained iterators, references and pointers.I'm new to c++, can someone confirm, that because sf::Texture contains reference it's unsafe to use it with std::vector, is there some other workaround?
bool CArea::OnLoad(char* File) {
MapList.clear();
FILE* FileHandle = fopen(File, "r");
if(FileHandle == NULL) {
return false;
}
char TilesetFile[255];
fscanf(FileHandle, "%s\n", TilesetFile);
if((Surf_Tileset = CSurface::OnLoad(TilesetFile)) == false) {
fclose(FileHandle);
return false;
}
fscanf(FileHandle, "%d\n", &AreaSize);
for(int X = 0;X < AreaSize;X++) {
for(int Y = 0;Y < AreaSize;Y++) {
char MapFile[255];
fscanf(FileHandle, "%s ", MapFile);
CMap tempMap;
if(tempMap.OnLoad(MapFile) == false) {
fclose(FileHandle);
return false;
}
tempMap.Surf_Tileset = Surf_Tileset;
MapList.push_back(tempMap);
}
fscanf(FileHandle, "\n");
}
fclose(FileHandle);
return true;
}
Surf_Tileset = CSurface::OnLoad(TilesetFile)
to m_TilesetTexture1.LoadFromFile(TilesetFile)
tempMap.Surf_Tileset = Surf_Tileset;
which I changed totempMap.m_TilesetTexture=m_TilesetTexture1;
tempMap.m_TilesetSprite.SetTexture(tempMap.m_TilesetTexture);
and later it shows map with white instead of texture.tempMap.m_TilesetTexture=m_TilesetTexture1;
tempMap.m_TilesetSprite.SetTexture(m_TilesetTexture1);
and it shows map fine this time.tempMap.m_TilesetTexture=m_TilesetTexture1;
tempMap.m_TilesetSprite.SetTexture(tempMap.m_TilesetTexture);
shows white surface?
"omfg what u done its not simple anymore"
When building SFML with CMake, you can choose the option to generate the doc. When compiling the INSTALL project/rule, Doxygen is run.Thanks, it helped.
Wow, fast!Quoteminor inconvenience sf::Text default Color is Black, while documentation says it's White.
It's fixed, thanks.