本文整理汇总了C++中IReadFile类的典型用法代码示例。如果您正苦于以下问题:C++ IReadFile类的具体用法?C++ IReadFile怎么用?C++ IReadFile使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了IReadFile类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: writeXMLHeader
void IXMLWriterTest::writeXMLHeader()
{
IWriteFile* fWrite = IFileSystem::createWriteFile(
"assets/io/fileXMLEmpty.xml");
IXMLWriter* fxml = IFileSystem::createXMLWriter(fWrite);
if (fWrite)
fWrite->drop();
fxml->writeXMLHeader();
if (fxml)
fxml->drop();
IReadFile* fRead = IFileSystem::createReadFile(
"assets/io/fileXMLEmpty.xml");
IXMLReader* fxmlR = IFileSystem::createXMLReader(fRead);
fxmlR->read();
if (fxmlR->getNodeType() != EXNT_UNKNOWN)
mes.append(
"\n writeXMLHeader: does not write the XMLHeader");
if (fxmlR)
fxmlR->drop();
if (fRead)
fRead->drop();
}
示例2: openFile
//! returns fileindex
s32 CUnZipReader::findFile(const c8* filename)
{
IReadFile *file = openFile ( filename );
if ( 0 == file )
return -1;
file->drop ();
return 1;
}
示例3: createAndOpenFile
//! Creates a XML Reader from a file.
IXMLReader* CFileSystem::createXMLReader(const core::string<c16>& filename)
{
IReadFile* file = createAndOpenFile(filename);
if (!file)
return 0;
IXMLReader* reader = createXMLReader(file);
file->drop();
return reader;
}
示例4: createAndOpenFile
//! Creates a XML Reader from a file.
IXMLReaderUTF8* CFileSystem::createXMLReaderUTF8(const c8* filename)
{
IReadFile* file = createAndOpenFile(filename);
if (!file)
return 0;
IXMLReaderUTF8* reader = createIXMLReaderUTF8(file);
file->drop();
return reader;
}
示例5: createAndOpenFile
//! Creates a XML Reader from a file.
IXMLReader* CFileSystem::createXMLReader(const io::path& filename)
{
IReadFile* file = createAndOpenFile(filename);
if (!file)
return 0;
IXMLReader* reader = createXMLReader(file);
file->drop();
return reader;
}
示例6: createArchive
/** \param file File handle to check.
\return Pointer to newly created archive, or 0 upon error. */
IFileArchive* CArchiveLoaderNPK::createArchive(const path& filename, bool ignoreCase, bool ignorePaths) const
{
IFileArchive *archive = 0;
IReadFile* file = FileSystem->createAndOpenFile(filename);
if (file)
{
archive = createArchive(file, ignoreCase, ignorePaths);
file->drop();
}
return archive;
}
示例7: findTexture
//! loads a Texture
ITexture* CNullDriver::getTexture(const path& filename)
{
// Identify textures by their absolute filenames if possible.
const path absolutePath = FileSystem->getAbsolutePath(filename);
ITexture* texture = findTexture(absolutePath);
if (texture)
return texture;
// Then try the raw filename, which might be in an Archive
texture = findTexture(filename);
if (texture)
return texture;
// Now try to open the file using the complete path.
IReadFile* file = FileSystem->createAndOpenFile(absolutePath);
if (!file)
{
// Try to open it using the raw filename.
file = FileSystem->createAndOpenFile(filename);
}
if (file)
{
// Re-check name for actual archive names
texture = findTexture(file->getFileName());
if (texture)
{
file->releaseRef();
return texture;
}
texture = loadTextureFromFile(file);
file->releaseRef();
if (texture)
{
addTexture(texture);
texture->releaseRef(); // drop it because we created it, one grab too much
}
else
Printer::log("Could not load texture", filename, ELL_ERROR);
return texture;
}
else
{
Printer::log("Could not open file of texture", filename, ELL_WARNING);
return 0;
}
}
示例8: createReadFile
/** See IXMLReader for more information on how to use the parser.
\return 0, if file could not be opened, otherwise a pointer to the created
IXMLReader is returned. After use, the reader
has to be deleted using its IXMLReader::drop() method.
See IReferenceCounted::drop() for more information. */
IXMLReader* SharedFileSystem::createXMLReader(
const core::stringc& filename)
{
// Create the file using an absolute path so that it matches
// the scheme used by CNullDriver::getTexture().
IReadFile * file = createReadFile(this->getAbsolutePath(filename));
IXMLReader* reader = irrgame::io::createXMLReader(file);
if (file)
file->drop();
return reader;
}
示例9: createImageFromFile
//! Creates a software image from a file.
IImage* CNullDriver::createImageFromFile(const path& filename)
{
if (!filename.size())
return 0;
IImage* image = 0;
IReadFile* file = FileSystem->createAndOpenFile(filename);
if (file)
{
image = createImageFromFile(file);
file->releaseRef();
}
else
Printer::log("Could not open file of image", filename, ELL_WARNING);
return image;
}
示例10: addShaderMaterialFromFiles
//! Like IGPUProgrammingServices::addShaderMaterial(), but tries to load the
//! programs from files.
s32 CNullDriver::addShaderMaterialFromFiles(const path& vertexShaderProgramFileName,
const path& pixelShaderProgramFileName,
IShaderConstantSetCallBack* callback,
E_MATERIAL_TYPE baseMaterial,
s32 userData)
{
IReadFile* vsfile = 0;
IReadFile* psfile = 0;
if (vertexShaderProgramFileName.size())
{
vsfile = FileSystem->createAndOpenFile(vertexShaderProgramFileName);
if (!vsfile)
{
Printer::log("Could not open vertex shader program file",
vertexShaderProgramFileName, ELL_WARNING);
return -1;
}
}
if (pixelShaderProgramFileName.size())
{
psfile = FileSystem->createAndOpenFile(pixelShaderProgramFileName);
if (!psfile)
{
Printer::log("Could not open pixel shader program file",
pixelShaderProgramFileName, ELL_WARNING);
if (vsfile)
vsfile->releaseRef();
return -1;
}
}
s32 result = addShaderMaterialFromFiles(vsfile, psfile, callback,
baseMaterial, userData);
if (psfile)
psfile->releaseRef();
if (vsfile)
vsfile->releaseRef();
return result;
}
示例11: createReadFile
//! adds an zip archive to the filesystem
bool CFileSystem::addZipFileArchive(const c8* filename, bool ignoreCase, bool ignorePaths)
{
IReadFile* file = createReadFile(filename);
if (file)
{
CZipReader* zr = new CZipReader(file, ignoreCase, ignorePaths);
if (zr)
ZipFileSystems.push_back(zr);
file->drop();
bool ret = (zr != 0);
_IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX;
return ret;
}
#ifdef _DEBUG
os::Printer::log("Could not open file. Zipfile not added", filename, ELL_ERROR);
#endif
_IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX;
return false;
}
示例12: disambiguateTextures
bool disambiguateTextures(void)
{
IrrlichtDevice *device =
createDevice( video::EDT_SOFTWARE, dimension2d<s32>(640, 480), 16,
false, false, false, 0);
if (!device)
return false;
IVideoDriver * driver = device->getVideoDriver();
ITexture * tex1 = driver->getTexture("../media/tools.png");
ITexture * tex2 = driver->getTexture("../media/tools.png");
IReadFile * readFile = device->getFileSystem()->createAndOpenFile("../media/tools.png");
assert(readFile);
ITexture * tex3 = driver->getTexture(readFile);
readFile->drop();
// Expects an empty tmp/tmp directory under this app's wd and
// a media directory under this apps' directory with tools.png in it.
stringc wd = device->getFileSystem()->getWorkingDirectory();
stringc newWd = wd + "/empty/empty";
bool changed = device->getFileSystem()->changeWorkingDirectoryTo(newWd.c_str());
assert(changed);
ITexture * tex4 = driver->getTexture("../../media/tools.png");
assert(tex4);
assert(tex1 == tex2 && tex1 == tex3 && tex1 != tex4);
changed &= device->getFileSystem()->changeWorkingDirectoryTo(wd.c_str());
device->drop();
return (changed && tex1 == tex2 && tex1 == tex3 && tex1 != tex4) ? true : false;
}
示例13: main
int main(int argc, char **argv) {
// Help?
if (argv[1] && argv[1][0] == '-') die(helpmsg);
putenv((char *) "vblank_mode=0"); // No vsync for us, thanks.
MyEventReceiver *r = new MyEventReceiver();
IrrlichtDevice *dev = createDevice(EDT_OPENGL, core::dimension2d<u32>(1024,768), 32,
false, false, false, r);
if (!dev) die("Can't initialize Irrlicht");
IVideoDriver *drv = dev->getVideoDriver();
ISceneManager *smgr = dev->getSceneManager();
IGPUProgrammingServices *gpu = drv->getGPUProgrammingServices();
ICameraSceneNode *cam = NULL;
ITexture *pic = NULL;
IMeshSceneNode *ball = NULL;
bool showpic = false;
IReadFile *areamap = createMemoryReadFile(AreaMap33, sizeof(AreaMap33), "AreaMap33", false);
if (!areamap) die("Failed to load areamap");
ITexture *areamaptex = drv->getTexture(areamap);
areamap->drop();
// If there's an argument, assume it is a pic to load; otherwise, draw a sphere
if (argv[1] && access(argv[1], R_OK) == 0) {
showpic = true;
pic = drv->getTexture(argv[1]);
if (!pic) die("Can't load image");
cam = smgr->addCameraSceneNode();
} else {
cam = smgr->addCameraSceneNodeMaya();
cam->setTarget(vector3df(0, 0, 0));
ball = smgr->addSphereSceneNode(40, 8);
int ballshader = gpu->addHighLevelShaderMaterial(rnd,0,EVST_VS_1_1,0);
ball->setMaterialType((E_MATERIAL_TYPE) ballshader);
ISceneNodeAnimator *cool = smgr->createRotationAnimator(vector3df(-0.1, 0.1, -0.1));
ball->addAnimator(cool);
cool->drop();
}
// Set up static defines, RTTs, quads
dimension2d<u32> screensize = drv->getScreenSize();
char defines[128];
snprintf(defines, 128,
"#define PIXEL_SIZE vec2(1.0f / %u.0, 1.0f / %u.0)\n"
"#define MAX_SEARCH_STEPS 8.0\n#define MAX_DISTANCE 33.0\n",
screensize.Width, screensize.Height);
ITexture *rt1 = drv->addRenderTargetTexture(screensize, "rt1", ECF_A8R8G8B8);
ITexture *rt2 = drv->addRenderTargetTexture(screensize, "rt2", ECF_A8R8G8B8);
ITexture *rt3 = drv->addRenderTargetTexture(screensize, "rt3", ECF_A8R8G8B8);
if (!rt1 || !rt2 || !rt3) die("No RTT");
ScreenQuad *def = new ScreenQuad(drv);
ScreenQuad *sq = new ScreenQuad(drv);
ScreenQuad *sq2 = new ScreenQuad(drv);
ScreenQuad *sq3 = new ScreenQuad(drv);
ScreenQuad *norm = new ScreenQuad(drv);
if (showpic) def->SetTexture(pic);
sq->SetTexture(rt1);
sq->GetMaterial().setFlag(EMF_BILINEAR_FILTER, false);
norm->SetTexture(rt1);
norm->GetMaterial().setFlag(EMF_BILINEAR_FILTER, false);
sq2->SetTexture(rt2);
sq2->SetTexture(rt2, 1);
sq2->SetTexture(areamaptex, 2);
sq2->GetMaterial().TextureLayer[2].BilinearFilter = false;
sq3->SetTexture(rt3);
sq3->GetMaterial().setFlag(EMF_BILINEAR_FILTER, false);
sq3->SetTexture(rt1,1);
state_t state = MLAA_OFF;
stringc tmp1, tmp2;
tmp1 = defines;
tmp1 += offsetvs;
tmp2 = defines;
tmp2 += color1fs;
// Load shaders
int edge = gpu->addHighLevelShaderMaterial(tmp1.c_str(),0,EVST_VS_1_1,tmp2.c_str());
sq->SetMaterialType((E_MATERIAL_TYPE) edge);
tmp2 = defines;
tmp2 += blend2fs;
blendcb *bcb = new blendcb();
edge = gpu->addHighLevelShaderMaterial(tmp1.c_str(),0,EVST_VS_1_1,tmp2.c_str(),0,EPST_PS_1_1,bcb);
sq2->SetMaterialType((E_MATERIAL_TYPE) edge);
tmp2 = defines;
tmp2 += neigh3fs;
//.........这里部分代码省略.........
示例14: disambiguateTextures
/** This tests verifies that textures opened from different places in the filesystem
can be distinguished, even if they have the same filename. */
bool disambiguateTextures(void)
{
IrrlichtDevice *device =
createDevice( video::EDT_NULL, dimension2d<s32>(640, 480));
if (!device)
{
logTestString("Unable to create EDT_NULL device\n");
return false;
}
// Expects an empty tmp/tmp directory under this app's wd and
// a media directory under this apps' directory with tools.png in it.
stringc wd = device->getFileSystem()->getWorkingDirectory();
if(-1 == wd.find("/tests") && -1 == wd.find("\\tests"))
{
logTestString("The tests must be run from the /tests directory, regardless of where\n"\
"the test executable was built.\n");
device->drop();
return false;
}
IVideoDriver * driver = device->getVideoDriver();
ITexture * tex1 = driver->getTexture("../media/tools.png");
assert(tex1);
if(!tex1)
logTestString("Unable to open ../media/tools.png\n");
ITexture * tex2 = driver->getTexture("../media/tools.png");
assert(tex2);
if(!tex2)
logTestString("Unable to open ../media/tools.png\n");
IReadFile * readFile = device->getFileSystem()->createAndOpenFile("../media/tools.png");
assert(readFile);
if(!readFile)
logTestString("Unable to open ../media/tools.png\n");
ITexture * tex3 = driver->getTexture(readFile);
assert(tex3);
if(!readFile)
logTestString("Unable to create texture from ../media/tools.png\n");
readFile->drop();
// All 3 of the above textures should be identical.
assert(tex1 == tex2 && tex1 == tex3);
stringc newWd = wd + "/empty/empty";
bool changed = device->getFileSystem()->changeWorkingDirectoryTo(newWd.c_str());
assert(changed);
ITexture * tex4 = driver->getTexture("../../media/tools.png");
assert(tex4);
if(!tex4)
logTestString("Unable to open ../../media/tools.png\n");
assert(tex1 != tex4);
// The working directory must be restored for the other tests to work.
changed &= device->getFileSystem()->changeWorkingDirectoryTo(wd.c_str());
device->drop();
return (changed && tex1 == tex2 && tex1 == tex3 && tex1 != tex4) ? true : false;
}
示例15: loadFromFileFolder
/** This tests verifies that textures opened from different places in the
filesystem don't create duplicated textures. */
bool loadFromFileFolder(void)
{
IrrlichtDevice *device =
createDevice( video::EDT_NULL, dimension2du(160, 120));
if (!device)
{
logTestString("Unable to create EDT_NULL device\n");
return false;
}
IVideoDriver * driver = device->getVideoDriver();
u32 numTexs = driver->getTextureCount();
ITexture * tex1 = driver->getTexture("../media/tools.png");
assert_log(tex1);
if(!tex1)
logTestString("Unable to open ../media/tools.png\n");
if (driver->getTextureCount()!=numTexs+1)
{
logTestString("No additional texture in the texture cache %s:%d\n", __FILE__, __LINE__);
return false;
}
IReadFile * readFile = device->getFileSystem()->createAndOpenFile("../media/tools.png");
assert_log(readFile);
if(!readFile)
logTestString("Unable to open ../media/tools.png\n");
if (driver->getTextureCount()!=numTexs+1)
{
logTestString("Additional texture in the texture cache %s:%d\n", __FILE__, __LINE__);
return false;
}
ITexture * tex2 = driver->getTexture(readFile);
assert_log(tex2);
if(!readFile)
logTestString("Unable to create texture from ../media/tools.png\n");
if (driver->getTextureCount()!=numTexs+1)
{
logTestString("Additional texture in the texture cache %s:%d\n", __FILE__, __LINE__);
return false;
}
readFile->drop();
// adding a folder archive
device->getFileSystem()->addFileArchive( "../media/" );
ITexture * tex3 = driver->getTexture("tools.png");
assert_log(tex3);
if(!tex3)
logTestString("Unable to open tools.png\n");
if (driver->getTextureCount()!=numTexs+1)
{
logTestString("Additional texture in the texture cache %s:%d\n", __FILE__, __LINE__);
return false;
}
ITexture * tex4 = driver->getTexture("tools.png");
assert_log(tex4);
if(!tex4)
logTestString("Unable to open tools.png\n");
if (driver->getTextureCount()!=numTexs+1)
{
logTestString("Additional texture in the texture cache %s:%d\n", __FILE__, __LINE__);
return false;
}
device->closeDevice();
device->run();
device->drop();
return ((tex1 == tex2) && (tex1 == tex3) && (tex1 == tex4));
}