DirectDraw :: Loading Targa (tga) files

Started by
7 comments, last by mr_slipgate 23 years, 11 months ago
Hey everyone, Can someone help me out or post some solid code where i can load a 24 or 32 bit targa image into my directdraw buffer? My buffer is "lpddsprimary" if i need to create a backbuffer, i''ll just refer it to "lpddsback".
Advertisement
There is code in D3DFrame for loading 24 and 32bit TGA into textures, the process shouldn''t be need to much changing to load it into the framebuffer.

You should look at the file ''d3dtextr.cpp''. It''s located in ''C:\mssdk\samples\Multimedia\D3DIM\src\D3DFrame''

- WitchLord

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

Hey i got some of it to work but i got a problem =\

ok heres my function:

void LoadTGA (FILE *fin);

Now The problem is when i call the function like this:
LoadTGA ("TGASample.tga");
I get this error: error C2664: ''LoadTGA'' : cannot convert parameter 1 from ''char [14]'' to ''struct _iobuf *''

HELLP!!!
Why don''t you take a closer look at what parameter LoadTGA is asking for, it obviously isn''t a pointer to an array of char''s..... It wants a FILE*, so use fopen or something to open a file and pass the handle/pointer/whatever as the parameter...
Alright, I am not trying to be a jerk or anything and I don''t want to start a big thing(which is why I am remaining anonymous), but it seems to me that if you cannot figure out why you have recieved that error, then you REALLY should not be trying to program an application as complex as a game.

My suggestion would be to start on smaller simply applications and work up to a game. Don''t make a game because you read "Learn C++ In A Week" and think you know the language. You need some real experience with your programming language of choice, and reading a thousand pages does not cut it, before trying to make a game.
that is a very crued thing to say!!?!!?!!?!
Yeah, actually im quite a newbie toward C++ and Directx. Ive read a lot of C books but i never did stuff with graphics program and the like. I can load bitmaps and things like that, but its these damn tga files. Its these lame little errors that screw me over.

But this problem that i had today had nothing to do with DirectX or COM, i just wanted a function right there that i didnt want to think about much. I considered using DJGPP because allegro has those built in features (such as loading tga files) but i have Visual Studio. Why let it collect dust? I also considered using the Scitech MGL, but i have the DirectX7 SDK (127mb) and and a few DirectX books.

Anyway my point is, we all have to start somewhere, do we not? Im sure that you (or anyone) had the same problems. The same newbieish problems. My field right now just isnt C, C++. So im learning.


Don´t let Mr. Anonymous Poster bring you down..

Programming is hard to begin with, nothing wrong with that.
Besides...You did not say that you were working on a game.
Where did he get info from ?
-------------Ban KalvinB !
Don''t know if it''s of any use, but I load my TGA images manually. First I import them into my resources...then use the following function:

//---------------------------------------------------------------------------
void __fastcall LoadTexture()
{
typedef struct
{ char CompressionHeader[12];
WORD Width;
WORD Height;
WORD BitsPerPixel;
unsigned char Data[1];
}
TGAHEADER, *PTGAHEADER;

void *pResTexture;
unsigned char *pTexture;

pResTexture= LockResource(LoadResource(NULL, FindResource(NULL, MAKEINTRESOURCE(IDT_TEXTURE), "TGA")));
pTexture = ((PTGAHEADER)pResTexture)->Data;
for(int j=0; j<256; j++)
for(int i=0; i<256; i++)
{ Texture[(255-j)*256 + i].r = *pTexture++;
Texture[(255-j)*256 + i].g = *pTexture++;
Texture[(255-j)*256 + i].b = *pTexture++;
}
}

This topic is closed to new replies.

Advertisement