by Guest » Feb 20, 2002 @ 1:22pm
Sorry to take peoples time up here but one more question if I may.
I am following the tutorials and am trying to load in a TGA file and display it on screen.
As instructed, I have included this code at the correct place in my program:
#include "easyce.h"
void loadtga( unsigned short* file, int w, int h, PIXEL* dest )
{
DWORD size = w * 2 * h + 20, bytesread;
BYTE* tgabuff = new BYTE[size];
HANDLE tga = CreateFile( file, GENERIC_READ, FILE_SHARE_READ,
0, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0 );
ReadFile( tga, tgabuff, size, &bytesread, 0 );
CloseHandle( tga );
unsigned short* src = (unsigned short*)tgabuff + 9 + (h - 1) * w;
unsigned short* dst = (unsigned short*)dest;
for ( int i = 0; i < h; i++ )
{
for ( int x = 0; x < w; x++ )
{
int red = (*(src + x) & (31 << 10)) >> 10;
int green = (*(src + x) & (31 << 5)) >> 5;
int blue = *(src + x) & 31;
*(dst + x) = (red << 11) + (green << 6) + blue;
}
dst += w;
src -= w;
}
delete tgabuff;
}
void main()
{main code here}
Problem is - this gives this error:
C:\Documents and Settings\Steven McDonald\Desktop\EasyCE 1.6 (Custom)\Rock Crush 2002 - Project Files\RC2002.cpp(10) : error C2664: 'CreateFileA' : cannot convert parameter 1 from 'unsigned short *' to 'const char *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
Error executing cl.exe.
RC2002.exe - 1 error(s), 0 warning(s)
Something to do with C versus C++ ??
Anyone know how to fix?
Thanks.