GLBasic version of incbin

Previous topic - Next topic

MrTAToad

I think I've found a fairly decent way of being able to embed data into a program at compile-time. 

The data needs to be in  C/C++, and needs to be REQUIRE'd (although using #include could work too).

You do need to have a slight bit of INLINE/ENDINLINE stuff to make the data available :

For example :

Code (glbasic) Select
REQUIRE "defaultLanguage.c"

INLINE
}

extern char *defaultLanguage[];

namespace __GLBASIC__ {
ENDINLINE


And then just access the data in an INLINE function (but not in an extended type), eg :

Code (glbasic) Select
FUNCTION Localise_TextHelper%:BYREF index%,BYREF token$,BYREF value$
token$=""
value$=""

INLINE
if (defaultLanguage[index])
{
token_Str=DGStr(defaultLanguage[(int) index]);
INC(index);
if (defaultLanguage[(int) index])
{
value_Str=DGStr(defaultLanguage[(int) index]);
INC(index);
}

return (DGNat) TRUE;
}

return (DGNat) FALSE;
ENDINLINE
ENDFUNCTION

Ian Price

I really love BlitzMax's Incbin command - much simpler to use than Shoebox and less faffing about.

Can you post a working example?
I came. I saw. I played.

MrTAToad

Yes will do soon-ish!

MrTAToad

I've included a very simple example with getting a value from one integer array, but character arrays and structures could all be used, and with a bit of effort, MEM2SPR could be used to create sprites from the data.



[attachment deleted by admin]

Kitty Hello

incbin is sort of packing a binary file into your program?

Ian Price

Quoteincbin is sort of packing a binary file into your program?

Yes - it packs all media into your .EXE. Incbin=Include Binary.
I came. I saw. I played.

Sokurah

I also asked about the possibility to have a function like it earlier, here; http://www.glbasic.com/forum/index.php?topic=3408.msg24964#msg24964

It's really easy to use in BlitzMax. You can check the link to see the syntax BM uses, Gernot.
Website: Tardis remakes / Mostly remakes of Arcade and ZX Spectrum games. All freeware. :-)
Twitter: Sokurah

Scott_AW

How about something for OSX packing?  So far it seems that an OSX distro will have its resources accessible since I haven't been able to get shoeboxes to work.
Current Project, Orbital Contract Defense
http://gamejolt.com/games/adventure/code-name-ocd/9887/

BlackShadow now open source/resource(requires duke3d)
http://gamejolt.com/games/adventure/black-shadow-3d/9885/

MrTAToad

Shoebox should work on the Mac...

caffeinekid

I would love to see a BlitzMax style incbin command on GLBasic. Is there are possibility it might get included ;) at some point?

Kitty Hello

I'll try to add it. It's pretty hard for all media and all platforms (with my current framework mess). I think about switching to SDL 1.3 for all platforms (static linking) and see what I can do with music playing.