Jump to content
  • Advertisement
Sign in to follow this  
davcaw

tga

This topic is 5028 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post


Link to post
Share on other sites
Advertisement
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Try a bit of googling... it's not hard two find code that loads tga's.

Share this post


Link to post
Share on other sites
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
}

}

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
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.

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
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.

Share this post


Link to post
Share on other sites
Guest 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

Share this post


Link to post
Share on other sites
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 above

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
}

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!