Compiling media into your exe?

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
MasterGod
Posts: 2061
Joined: Fri May 25, 2007 8:06 pm
Location: Israel
Contact:

Post by MasterGod »

CodyCer0 wrote:
MasterGod wrote:The way I'm suggesting is much more easier and it's exactly what you asked for.
Ok I got it running now, not from a guide on how to use commandline exe's, just troubleshooted my way into running it right.

But my question is how would I be able to put this into practice with irrlicht. How would I manage to um like use the value created from this exe to have this act as a replacement for the actual file itself?
Oh, now the interesting part.
Well Irrlicht IO system has methods to load a file from a path, or from memory. Now because our array's data is the same as it would be if it was loaded to memory (which it actually is cause its a global array..nevermind), you can use it as the "memory" parameter in LoadFromMemory method (the equivalent in irrlicht yes, I don't remember the method's name).

P.S
Its seems we posted together, hehe..

Edit:
MasterGod wrote:Check out: BuiltInFont.h
I didn't say to check this file out for nothing.
You had two problems:
1. How to make a binary array of a given file in a C\C++ header. Solved.
2. How to load that data which is now an array in a header file.

To solve that by Yourself check out Irrlicht code and how they loaded the font bmp file which they converted to a header with the array of its data (like you now know how to do).

Kapish? ( 8) )
Image
Dev State: Abandoned (For now..)
Requirements Analysis Doc: ~87%
UML: ~0.5%
Jookia
Posts: 170
Joined: Wed Nov 19, 2008 1:11 am

Post by Jookia »

io::createMemoryReadFile(BuiltInFontData, BuiltInFontDataSize, filename, false);
CodyCer0
Posts: 41
Joined: Mon Dec 08, 2008 3:07 am

Post by CodyCer0 »

Jookia wrote:io::createMemoryReadFile(BuiltInFontData, BuiltInFontDataSize, filename, false);
I wish I read this comment before I went off googling because I just found it. But thanks anyways man XD.

Anyways, from this link... http://www.mindfloaters.de/irrlicht/fil ... t.cpp.html

I am getting that you createMemoryReadFile and put that file into use as what ever you want? Like in that usage of the fontdata in the link.

I understand, ty guys vm.

I'm going to try it out now. Rest assured that I will comment again for help if I run into impossible to get passed seeming problems.
CodyCer0
Posts: 41
Joined: Mon Dec 08, 2008 3:07 am

Post by CodyCer0 »

I do have a problem, what do I type in for filename. It doesn't seem to be asking for the actual filename of what I'm using to do it. So um... What do I do?

I see const c8* filename = "#DefaultFont"; at http://www.mindfloaters.de/irrlicht/fil ... t.cpp.html but I don't understand what I need to type in, in replacement of "#DefaultFont".

Yeah I keep getting this error

[Linker error] undefined reference to `irr::io::createMemoryReadFile(void*, long, char const*, bool)'

Does this mean the problem is not linked to the file name part?

Is there something wrong with my use of it or am I not including something that needs to be included?

I'm just using the helloworld example from irrlicht 1.4.2 (only sticking with it for now because I got a lil used to it back when I tried irr before and I don't want to go up till I get more understanding of irrlicht)
MasterGod
Posts: 2061
Joined: Fri May 25, 2007 8:06 pm
Location: Israel
Contact:

Post by MasterGod »

1. Use latest version.
2. Use latest version.
3. Use latest version.
(but that's just me..)

Now about your problem; first, we need to see the code you're using to help you find the error source - what's causing the error. (My guess is that Jookia said "io::createMemoryReadFile(void*, long, char const*, bool)" and you wrote in your code "irr::io::createMemoryReadFile(Filled, in, the, parameters)", which is wrong by the way.. hehe.)
Second, as far as I know the file name when reading from memory could be anything, I'd write there if I were you "I.Worship.MasterGod.And.Will.Give.Him.All.My.Money.TheActualFileYouMadeBinary.like.MyFont.bmp"

P.S
About the version thing, you said you wanned to know what the matrix is Neo... you'd have to see it for yourself.
Ooops, too much matrix lately :D .
I'm just using the helloworld example from irrlicht 1.4.2 (only sticking with it for now because I got a lil used to it back when I tried irr before and I don't want to go up till I get more understanding of irrlicht
You won't get that understanding if you don't use the latest version.
Image
Dev State: Abandoned (For now..)
Requirements Analysis Doc: ~87%
UML: ~0.5%
CodyCer0
Posts: 41
Joined: Mon Dec 08, 2008 3:07 am

Post by CodyCer0 »

MasterGod wrote:1. Use latest version.
2. Use latest version.
3. Use latest version.
(but that's just me..)

Now about your problem; first, we need to see the code you're using to help you find the error source - what's causing the error. (My guess is that Jookia said "io::createMemoryReadFile(void*, long, char const*, bool)" and you wrote in your code "irr::io::createMemoryReadFile(Filled, in, the, parameters)", which is wrong by the way.. hehe.)
Second, as far as I know the file name when reading from memory could be anything, I'd write there if I were you "I.Worship.MasterGod.And.Will.Give.Him.All.My.Money.TheActualFileYouMadeBinary.like.MyFont.bmp"

P.S
About the version thing, you said you wanned to know what the matrix is Neo... you'd have to see it for yourself.
Ooops, too much matrix lately :D .
I'm just using the helloworld example from irrlicht 1.4.2 (only sticking with it for now because I got a lil used to it back when I tried irr before and I don't want to go up till I get more understanding of irrlicht
You won't get that understanding if you don't use the latest version.

fine I will switch to latest version after this is problem is solved. But here is my code in the mean time, btw(nothing is changed, in fact the only erased part is the quotes, I didn't do any adding except this topic. Something tells me I need more included btw.

main.cpp:

Code: Select all

#include <irrlicht.h>
#include "BuildInSydneyModel.h"
#include "BuildInSydneyTexture.h"


using namespace irr;

using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;

IReadFile* file;
IReadFile* file2;

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

int main()
{
	IrrlichtDevice *device =
#ifdef _IRR_OSX_PLATFORM_
		createDevice( video::EDT_OPENGL, dimension2d<s32>(640, 480), 16,
			false, false, false, 0);
#else
		createDevice( video::EDT_SOFTWARE, dimension2d<s32>(640, 480), 16,
			false, false, false, 0);
#endif

	device->setWindowCaption(L"Hello World! - Irrlicht Engine Demo");
	const c8* filename2 = "sydney.md2";
	const c8* filename = "sydney.bmp";

	IVideoDriver* driver = device->getVideoDriver();
	ISceneManager* smgr = device->getSceneManager();
	IGUIEnvironment* guienv = device->getGUIEnvironment();

	guienv->addStaticText(L"Hello World! This is the Irrlicht Software renderer!",
		rect<s32>(10,10,260,22), true);
	file = io::createMemoryReadFile(mySydneyTextureData, mySydneyTextureData_size, filename, false);
	file2 = io::createMemoryReadFile(mySydneyModelData, mySydneyModelData_size, filename2, false);

	IAnimatedMesh* mesh = smgr->getMesh(file2);
	IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode( mesh );

	if (node)
	{
		node->setMaterialFlag(EMF_LIGHTING, false);
		node->setMD2Animation ( scene::EMAT_STAND );
		node->setMaterialTexture( 0, driver->getTexture(file) );
	}

	smgr->addCameraSceneNode(0, vector3df(0,30,-40), vector3df(0,5,0));

	while(device->run())
	{

		driver->beginScene(true, true, SColor(255,100,101,140));

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

		driver->endScene();
	}

	device->drop();

	return 0;
}
Something tells me something is wrong with the way I am trying to use the data for material and mesh, but I don't know what will happen really because the linker errors come in before it gets that far.

I'll make a seperate post for the 2 h's.
CodyCer0
Posts: 41
Joined: Mon Dec 08, 2008 3:07 am

The h's

Post by CodyCer0 »

I'm sorry if this is not how you are supposed to do a header of your own but I never actually tried using a header before (gives you an idea of how c++ clueless I am don't it) but there is a first time for everything.

BuildInSydneyModel.h:

Code: Select all

#ifndef __BUILD_IN_SYDNEYMODEL_H_INCLUDED__
#define __BUILD_IN_SYDNEYMODEL_H_INCLUDED__

namespace irr
{
namespace gui
{

s32 mySydneyModelData_size=302128;
s32 mySydneyModelData[] = {
//All the stuff produced by bin2h, too long to put in post
};
}
}
#endif
and BuildInSydneyTexture.h:

Code: Select all

#ifndef __BUILD_IN_SYDNEYTEXTURE_H_INCLUDED__
#define __BUILD_IN_SYDNEYTEXTURE_H_INCLUDED__

namespace irr
{
namespace gui
{
s32 mySydneyTextureData_size=60522;
s32 mySydneyTextureData[] = {
//Once again pretty long
};
}
}
#endif
CodyCer0
Posts: 41
Joined: Mon Dec 08, 2008 3:07 am

Post by CodyCer0 »

I figured out the problem with that, thank god for example 7, I saw that createMemoryReadFile was a part of file system so I called it the same way it called addZipFileArchive or what ever in collision example. Now the problem is a matter of getting the mesh up.
CodyCer0
Posts: 41
Joined: Mon Dec 08, 2008 3:07 am

Post by CodyCer0 »

Great now I'm stuck on using it for the actual mesh/texture. But something is telling me its that it can't read the data from header right. Not because it isn't getting the directions specified right.
Post Reply