#include "irrlichtwrapper.h" #include "constants.h" #include "string.h" #include "strfnd.h" IrrlichtWrapper::IrrlichtWrapper(IrrlichtDevice *device) { m_running = true; m_main_thread = get_current_thread_id(); m_device_mutex.Init(); m_device = device; } void IrrlichtWrapper::Run() { /* Fetch textures */ if(m_get_texture_queue.size() > 0) { GetRequest request = m_get_texture_queue.pop(); dstream<<"got texture request with" <<" key.tids[0]="<getVideoDriver(); /* An image will be built from files and then converted into a texture. */ video::IImage *baseimg = NULL; /* Irrlicht requires a name for every texture, with which it will be stored internally in irrlicht. */ std::string texture_name; for(u32 i=0; igetTexture(path.c_str()); driver->renameTexture(t, texture_name.c_str()); return t; }*/ video::IImage *image = driver->createImageFromFile(path.c_str()); if(image == NULL) { dstream<<"WARNING: Could not load image \""<createImage(video::ECF_A8R8G8B8, image); core::dimension2d dim = image->getDimension(); baseimg = driver->createImage(video::ECF_A8R8G8B8, dim); image->copyTo(baseimg); image->drop(); //baseimg = image; } // Else blit on base. else { dstream<<"Blitting "< dim = image->getDimension(); //core::dimension2d dim(16,16); // Position to copy the blitted to in the base image core::position2d pos_to(0,0); // Position to copy the blitted from in the blitted image core::position2d pos_from(0,0); // Blit image->copyToWithAlpha(baseimg, pos_to, core::rect(pos_from, dim), video::SColor(255,255,255,255), NULL); // Drop image image->drop(); } } else { // A special texture modification dstream<<"getTextureDirect(): generating \""< dim(16, 16); // Size of the crack image //core::dimension2d dim_crack(16, 16 * CRACK_ANIMATION_LENGTH); // Position to copy the crack to in the base image core::position2d pos_base(0, 0); // Position to copy the crack from in the crack image core::position2d pos_other(0, 16 * progression); video::IImage *crackimage = driver->createImageFromFile( porting::getDataPath("crack.png").c_str()); crackimage->copyToWithAlpha(baseimg, v2s32(0,0), core::rect(pos_other, dim), video::SColor(255,255,255,255), NULL); crackimage->drop(); } else if(name.substr(0,12) == "[progressbar") { float value = stof(name.substr(12)); make_progressbar(value, baseimg); } else { dstream<<"WARNING: getTextureDirect(): Invalid " " texture: \""<setPixel(1,1, c); baseimg->setPixel(1,14, c); baseimg->setPixel(14,1, c); baseimg->setPixel(14,14, c);*/ // Create texture from resulting image t = driver->addTexture(texture_name.c_str(), baseimg); baseimg->drop(); dstream<<"getTextureDirect(): created texture \""< size = image->getDimension(); u32 barheight = 1; u32 barpad_x = 1; u32 barpad_y = 1; u32 barwidth = size.Width - barpad_x*2; v2u32 barpos(barpad_x, size.Height - barheight - barpad_y); u32 barvalue_i = (u32)(((float)barwidth * value) + 0.5); video::SColor active(255,255,0,0); video::SColor inactive(255,0,0,0); for(u32 x0=0; x0setPixel(x,y, *c); } } }