.ico & .cur loader

Post those lines of code you feel like sharing or find what you require for your project here; or simply use them as tutorials.
Post Reply
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

.ico & .cur loader

Post by bitplane »

This is implemented as an archive loader, you add an .ico file to the filesystem and it adds a PNG (for PNGs) and TGA (for two layer BMPs) for each icon.

Should also work with .cur files but that's currently untested. See readme.txt for full info.

code: http://svn.bitplane.net/misc/trunk/irr/ ... aders/ICO/

usage:

Code: Select all

#include <irrlicht.h>

#include "CIcoLoader.h"

using namespace irr;

#ifdef _IRR_WINDOWS_
#pragma comment(lib, "Irrlicht.lib")
#endif

int main()
{

	IrrlichtDevice *device =
		createDevice( video::EDT_OPENGL, core::dimension2d<u32>(800, 600), 32);

	if (!device)
		return 1;

	io::IFileSystem* fs = device->getFileSystem();
	video::IVideoDriver* driver = device->getVideoDriver();
	scene::ISceneManager* smgr = device->getSceneManager();
	gui::IGUIEnvironment* guienv = device->getGUIEnvironment();

	// create an instance of the loader and add it to the filesystem
	io::CArchiveLoaderICO* icoLoader = new io::CArchiveLoaderICO(fs);
	fs->addArchiveLoader(icoLoader);

	// we created it with new, we are finished with it so we must drop it.
	icoLoader->drop(); 

	// now we can add an .ICO archive to the filesystem, in order to extract TGAs and PNGs from it
	fs->addFileArchive("bitplane.ico");

	// doing it this way looks inside the file
	//fs->addFileArchive("../../bin/Win32-VisualStudio/irrlicht.ico", true, true, io::E_FILE_ARCHIVE_TYPE(MAKE_IRR_ID('i', 'c', 'o', 0)));

	guienv->addImage(driver->getTexture("bitplane.ico.2.tga"), core::vector2di(0,0));

	while(device->run())
	{
		driver->beginScene(true, true, video::SColor(255,100,101,140));

		smgr->drawAll();
		guienv->drawAll();

		driver->endScene();
	}

	device->drop();

	return 0;
}
Last edited by bitplane on Mon Jul 13, 2009 8:07 am, edited 1 time in total.
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
FuzzYspo0N
Posts: 914
Joined: Fri Aug 03, 2007 12:43 pm
Location: South Africa
Contact:

Post by FuzzYspo0N »

lol, another one night wonder. Nice bitplane
d3jake
Posts: 198
Joined: Sat Mar 22, 2008 7:49 pm
Location: United States of America

Post by d3jake »

Very nice! This would be something handy to have included with Irrlicht at some point.
The Open Descent Foundation is always looking for programmers! http://www.odf-online.org
"I'll find out if what I deleted was vital here shortly..." -d3jake
Post Reply