i am using openGL with Visual Basic.net. when i try and load a tga using the built in image classes, i get an error saying invalid paramter (probably doesn't support tga). How can i load tga's then?
The TGA formet is pretty simple, its just a short header followed by the image data. The compressed version is RLE, but in my code I never bothered implementing that.
I would share code, but its C++, for VB try here, or just grab the file format from wotsit.org and start from scratch.
Alan
I would share code, but its C++, for VB try here, or just grab the file format from wotsit.org and start from scratch.
Alan
"There will come a time when you believe everything is finished. That will be the beginning." -Louis L'Amour
so i have to create a function to parse the tga myself? that will take longer than what i was planning on, but i guess it is doable. thanks.
September 12, 2004 03:58 PM
Try a bit of googling... it's not hard two find code that loads tga's.
who needs to google around, just take a look at lesson #33, that code only need a few lines of code more and it should work for most tga files.
And I beleve it goes something like this(put this in after it reads the header and before i reads the image data).
if(tgaheader[0])
{
if(fread(&tgaID, tgaheader[0], 1, fTGA) == 0) // Read TGA ID
{
if(fTGA != NULL) // if file is still open
{
fclose(fTGA); // Close it
}
return false; // Return failular
}
}
And I beleve it goes something like this(put this in after it reads the header and before i reads the image data).
if(tgaheader[0])
{
if(fread(&tgaID, tgaheader[0], 1, fTGA) == 0) // Read TGA ID
{
if(fTGA != NULL) // if file is still open
{
fclose(fTGA); // Close it
}
return false; // Return failular
}
}
www.flashbang.se | www.thegeekstate.com | nehe.gamedev.net | glAux fix for lesson 6 | [twitter]thegeekstate[/twitter]
September 13, 2004 02:57 PM
Quote: Original post by lc_overlord
who needs to google around, just take a look at lesson #33, that code only need a few lines of code more and it should work for most tga files.
And I beleve it goes something like this(put this in after it reads the header and before i reads the image data).
if(tgaheader[0])
{
if(fread(&tgaID, tgaheader[0], 1, fTGA) == 0) // Read TGA ID
{
if(fTGA != NULL) // if file is still open
{
fclose(fTGA); // Close it
}
return false; // Return failular
}
}
yes i have read through the tutorial, but stated above, i am using visual basic .net and it is hard to convert that code.
allthough the file loading thingies could be different, the rest of the code should be pretty straightforward to port.
Witch brings us to the question, why are you using VB.net?
Witch brings us to the question, why are you using VB.net?
www.flashbang.se | www.thegeekstate.com | nehe.gamedev.net | glAux fix for lesson 6 | [twitter]thegeekstate[/twitter]
September 13, 2004 03:55 PM
i am using vb .net because i know almost no C or C++ code. i know most vb .net programmers use directx, but i have never really liked any of directx. OpenGL is faster and has better quality. Anyway i found a control wich allows me to call OpenGL from vb .net (the CsGL control). I am looking at the tutorial now and trying to convert it, but the syntax of structures and arrays are very different.
September 13, 2004 03:57 PM
i am sorry this seems to be more than i wanted. i just expected a simple yes or no answer as to if there is an easy way to load tga's
Quote: Original post by Anonymous Poster
i am sorry this seems to be more than i wanted. i just expected a simple yes or no answer as to if there is an easy way to load tga's
i'd say the answer is yes, and the code looks like the following. as for porting to vb, i think you'd only need to replace the fread method to be whatever method vb calls to read files. i think everything else should basically be the same (granted i don't know vb):
//repost from aboveif(tgaheader[0]){ if(fread(&tgaID, tgaheader[0], 1, fTGA) == 0) // Read TGA ID { if(fTGA != NULL) // if file is still open { fclose(fTGA); // Close it } return false; // Return failular}
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement