Well I tried a few things.. I made a map in the main loop (outside of the class it is in) with the same structure and it worked so something is going wrong with it inside the class. I commented out all the code in my class and tried a clear and it still doesn't seem to want to work.. the code I'm using isn't too terribley big so I'm gonna post what I have (without the commented out part).
texture manager header
#ifndef TEXTMAN#define TEXTMAN#include "sTexture.h"#include "../globals.h"#include "SDL/SDL_Image.h"//for windows#ifndef GL_BGR #define GL_BGR GL_BGR_EXT#endif#ifndef GL_BGRA #define GL_BGRA GL_BGRA_EXT#endifclass cTextureManager{ public: cTextureManager(); ~cTextureManager(); uint LoadTextureFromFile(std::string filename); uint LoadTextureFromMemory(SDL_Surface* Surface, std::string filename = ""); uint CreateTextureSection(uint TextureId, sSection Section); void RemoveTexture(uint TextureId); void RemoveTextureSection(uint SectionId); void DrawTextureSection(uint SectionId, GLfloat X, GLfloat Y, GLfloat Scale = 1, GLfloat Rotatation = 0); void DrawTexture(uint SectionId, GLfloat X, GLfloat Y, GLfloat Scale = 1, GLfloat Rotatation = 0); //sTexture* getTexture(uint TextureId); //sTextureSection* getTextureSection(uint SectionId); void RemoveAllTextures(); void RemoveAllTextureSections(); protected: std::map< uint, sTexture > m_Textures; std::map< uint, sTextureSection > m_TextureSections;};#endif
offending functions
uint cTextureManager::LoadTextureFromFile(std::string filename){ SDL_Surface* surface; return LoadTextureFromMemory(surface, filename);}uint cTextureManager::LoadTextureFromMemory(SDL_Surface* Surface, std::string filename){ m_Textures.clear();}
When my main gameloop runs it call LoadTextureFromFile("valid filename");
then it gets to the textures.clear line and segfaults.
keep in mind that this code doesn't actually do anything since I commented it, the commented code runs fine without the map stuff in there as well. I'm preety sure I'm doing something wrong but I don't know what. For reference I have posted my whole program on my site
http://www.seoushi.com/misc/Kore.zip if you have codeblocks, sdl image, sdl and opengl installed it compiles fine.
thanks for the help so far.
Edit:
here is the backtrace to my error
#0 0x0043fd32 std::_Rb_tree<unsigned int, std::pair<unsigned int const, sTexture>, std::_Select1st<std::pair<unsigned int const, sTexture> >, std::less<unsigned int>, std::allocator<std::pair<unsigned int const, sTexture> > >::_M_begin (??:??)
#1 0x0043fb46 std::_Rb_tree<unsigned int, std::pair<unsigned int const, sTexture>, std::_Select1st<std::pair<unsigned int const, sTexture> >, std::less<unsigned int>, std::allocator<std::pair<unsigned int const, sTexture> > >::clear (??:??)
#2 0x0043e1dd std::map<unsigned int, sTexture, std::less<unsigned int>, std::allocator<std::pair<unsigned int const, sTexture> > >::clear (??:??)
#3 0x004036c9 cTextureManager::LoadTextureFromMemory (??:??)
#4 0x00403649 cTextureManager::LoadTextureFromFile (??:??)
#5 0x004047a1 Example::Run (??:??)
#6 0x00404ab4 SDL_main (??:??)
#7 0x00405c01 console_main (win32/SDL_win32_main.c:249)
#8 0x00405db1 WinMain (win32/SDL_win32_main.c:361)
#9 0x004056da main (??:??)
[Edited by - Seoushi on November 29, 2005 3:54:18 PM]