Author Topic: GLBasic version of incbin  (Read 3482 times)

MrTAToad

  • Guest
GLBasic version of incbin
« 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

Offline Ian Price

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 4158
  • On the shoulders of giants.
    • View Profile
    • My Apps
Re: GLBasic version of incbin
« Reply #1 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?
I came. I saw. I played.

MrTAToad

  • Guest
Re: GLBasic version of incbin
« Reply #2 on: 2010-Oct-06 »
Yes will do soon-ish!

MrTAToad

  • Guest
Re: GLBasic version of incbin
« Reply #3 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]

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10732
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
Re: GLBasic version of incbin
« Reply #4 on: 2010-Oct-12 »
incbin is sort of packing a binary file into your program?

Offline Ian Price

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 4158
  • On the shoulders of giants.
    • View Profile
    • My Apps
Re: GLBasic version of incbin
« Reply #5 on: 2010-Oct-12 »
Quote
incbin 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.

Offline Sokurah

  • Mr. Polyvector
  • ***
  • Posts: 177
    • View Profile
Re: GLBasic version of incbin
« Reply #6 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.
Website: Tardis remakes / Mostly remakes of Arcade and ZX Spectrum games. All freeware. :-)
Twitter: Sokurah

Offline Scott_AW

  • Mr. Polyvector
  • ***
  • Posts: 214
    • View Profile
    • SAW Game Design
Re: GLBasic version of incbin
« Reply #7 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.
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

  • Guest
Re: GLBasic version of incbin
« Reply #8 on: 2010-Oct-13 »
Shoebox should work on the Mac...

Offline caffeinekid

  • Mr. Drawsprite
  • **
  • Posts: 53
    • View Profile
    • TCKSOFT
Re: GLBasic version of incbin
« Reply #9 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?

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10732
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
Re: GLBasic version of incbin
« Reply #10 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.