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.
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]
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]
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}
here is what i have so far, does it look like i am on the right track? The reading i think should be easy, it was the structures and things i was confused on.
Public Class tga Structure headerinfo Dim header() As Byte End Structure Structure Texturest Dim imageData As Byte Dim bpp As Integer Dim width As Integer Dim height As Integer Dim texid As Integer Dim type As Integer End Structure Structure TGA Dim header() As Byte Dim bytesperpixel As Integer Dim imagesize As Integer Dim imageheight As Integer Dim imagewidth As Integer Dim type As Integer Dim bpp As Integer End Structure Public Function loadTga(ByVal TexStruc As Texturest, ByVal Path As String) Dim MyFile As IO.FileInfo = New IO.FileInfo(Path) Dim reader As IO.Stream Dim myheader As headerinfo = New headerinfo If MyFile.Exists Then reader = MyFile.OpenRead If reader.CanRead Then reader.Read(myheader.header, 0, 12) End If End If End FunctionEnd Class
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement