Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

mr_slipgate

DirectDraw :: Loading Targa (tga) files

This topic is 6913 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

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".

Share this post


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

Share this post


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

Share this post


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

Share this post


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

Share this post


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

Share this post


Link to post
Share on other sites

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 ?

Share this post


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

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!