Advertisement

Loading TGA-file from resource

Started by October 28, 2000 09:55 AM
4 comments, last by bumbu 24 years ago
I have saved all my small TGA-texture files in the exe, using Visual Studio. But I can''t load ''em in my program, ''cause the code only exports external textures. How can I modify Nehe''s TGA-loading code to make it load TGA-files inside the .exe-file? I''m using Visual Studio 6, but I think it''s the same in Borland etc. /* Johan Lindqvist */
Why haven''t anyone replied to this question? Strange, because I can bet that I have seen demos here on Nehe that does exactly the same thing I want to do. Maybe a lot of people haven''t noticed this topic, but they will know when it will be in the top of the page.

/* Johan Lindqvist */
Advertisement
You''re not the only one inerested
(you can find me on IRC : #opengl on undernet)
i am also interested in this subject.
what i need is to load a .xm file and some bitmaps
for the xm, im using fmod library www.fmod.org



//Wizerah
//Wizerah
Wizerra I had the same problem with loasing a .xm in msvc++ you can search through the msdn docs but that''s a pain in the ass, see if I can remember exactly how I did it..
... loading up msvc++ ....
ok here''s step by step instructions

1) go to Insert->resource

2) that brings up a window for selecting the type of resource you want to add, choose custom

3) name it, this part is actually important, when I first tried to load in the xm, I didn''t think it would be important, but it is. I named mine to song.

4)I then copied and pasted the binary info of the xm into the the resource (mine is called IDR_SONG1)

5) here''s the code that would be used in the function for memopen (which I ripped from the minifmod example):

/* handles for the resource */
HRSRC rec;
HGLOBAL handle;

/* this line represents three goddamn days of research!!! */
rec = FindResource(NULL, MAKEINTRESOURCE(IDR_SONG1), "SONG" );

/* load the found resource */
handle = LoadResource(NULL, rec);
memfile->data = LockResource(handle);
memfile->length = SizeofResource(NULL, rec);
memfile->pos = 0;

Wizera, the memfile was defined in the minifmod exmaple. that''s where that whole part comes from.

Bumbu, don''t know if it helps but you can use LockResource to get a pointer to the data of the tga, and use SizeofResource to get the length of the file and you may be able to port over the tga loading code pretty easily. Hope this helps, if it doesn''t just reply I''ll check this thread the next couple of days.. or email me serun@irev.net (I prefer a reply)


- Serun
- Serun
i wanted to do this a while ago and couldn''t get a response either, so i modified a tga loader to output a text file containing the colours as 0-255 integers ( = GLubyte)...and included this text as an array defined in a header file - this requires a lot of memory at compilation time, but not any more when the prog runs...

the prog i wrote is available on my website, as is the sourcecode so you can add other import filters if you want. its called gfx2tex

alistair

http://freespace.virginnet.co.uk/al.braidwood/html/downloads_2_.htm

This topic is closed to new replies.

Advertisement