SpriteAnimation::SpriteAnimation( std::string filename, int framewidth, int frameheight ) : mNumRows( 0 ), mNumCols( 0 ), mFrameWidth( framewidth ), mFrameHeight( frameheight ), mIsLooping( true ), mResource ( NULL ) { /* Maybe I should throw an exception here? Our object is pretty useless if this is the case anyway. */ if( frameheight < 1 || framewidth < 1 ) { std::cerr << "Error in SpriteAnimation, either frame width, or frame height found to be less than one."; // Provide a usable width and height. frameheight = std::max(frameheight, 1); framewidth = std::max(framewidth, 1); } SDL_Surface* image = NULL; image = IMG_Load( filename.c_str() ); if( image == NULL ) { throw ImageLoadException( filename ); } mResource = image; const int imageWidth = mResource->w; const int imageHeight = mResource->h; mNumRows = imageWidth / framewidth; mNumCols = imageHeight / frameheight; }
const Texture TextureIO::loadTexture(const string &imgName) { string imgPath = searchFile(imgName); Mat img = imread(imgPath , -1); Texture ret; if(img.empty()) throw ImageLoadException(); //GLint maxSize; //glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxSize); //LOG_INFO<<"maximum texture size: "<< maxSize; #ifdef KINSKI_GLES if(img.channels() == 3) cv::cvtColor(img, img, CV_BGR2RGBA); #endif LOG_TRACE<<"loaded image '"<<searchFile(imgPath)<<"': "<<img.cols<<" x "<<img.rows<<" -- " <<img.channels()<<" channel(s)"; updateTexture(ret, img); return ret; }