GLBasic forum

Codesnippets => Code Snippets => Topic started by: MrTAToad on 2010-Oct-06

Title: GLBasic version of incbin
Post by: MrTAToad on 2010-Oct-06
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
Title: Re: GLBasic version of incbin
Post by: Ian Price on 2010-Oct-06
I really love BlitzMax's Incbin command - much simpler to use than Shoebox and less faffing about.

Can you post a working example?
Title: Re: GLBasic version of incbin
Post by: MrTAToad on 2010-Oct-06
Yes will do soon-ish!
Title: Re: GLBasic version of incbin
Post by: MrTAToad on 2010-Oct-06
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]
Title: Re: GLBasic version of incbin
Post by: Kitty Hello on 2010-Oct-12
incbin is sort of packing a binary file into your program?
Title: Re: GLBasic version of incbin
Post by: Ian Price on 2010-Oct-12
Quoteincbin is sort of packing a binary file into your program?

Yes - it packs all media into your .EXE. Incbin=Include Binary.
Title: Re: GLBasic version of incbin
Post by: Sokurah on 2010-Oct-12
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.
Title: Re: GLBasic version of incbin
Post by: Scott_AW on 2010-Oct-12
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.
Title: Re: GLBasic version of incbin
Post by: MrTAToad on 2010-Oct-13
Shoebox should work on the Mac...
Title: Re: GLBasic version of incbin
Post by: caffeinekid on 2011-Sep-25
I would love to see a BlitzMax style incbin command on GLBasic. Is there are possibility it might get included ;) at some point?
Title: Re: GLBasic version of incbin
Post by: Kitty Hello on 2011-Sep-26
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.