PDA

View Full Version : Hardware Acceleration using "3dfxOGL.dll"



Ebola
08-25-2000, 03:49 PM
Yes it is me . . . I have returned . .

. . . No wait I've never been here before . . err . . anyway . . .

Look bare with me OK it's quarter to two in the morning and I **really** want to get this to work . . .


I started programming in OpenGL a few weeks ago, but each time I make a Program it using my 2D Graphics card for for the OpenGL stuff - I have an S3 Virge linked to a Voodoo 1 on PCI - . . .

How can I get my Programs to work with my Voodoo card (latest Drivers) . . . I tried a tutorial from GameDev.netbut by using it I can't access any Glaux stuff . . . I need help . . .


Thanx . . . http://www.opengl.org/discussion_boards/ubb/smile.gif


PS.
I only wanna use the Glaux stuff, because my own rather hacky BMP loader causes NASTY crashes inside "3dfxOGL.dll" that drop my normally 1024x768 system to 640x480 and bugger up my desktop http://www.opengl.org/discussion_boards/ubb/frown.gif

PPS.
If anybody is willing to have a look at my code and see if they can tell what is wrong with my BMP loader then Thanx again.

PPPS.
Sorry it was so long . . . wait this isn't helping . . D'OH!

[This message has been edited by Ebola (edited 08-25-2000).]

Humus
08-25-2000, 05:44 PM
Sure, I can look at your bmploading routine.
Here's my working bmploader, you may use it directly or as a reference if you want.

unsigned int FileTexture::loadBmp(char *File){
HANDLE FileHandle;
BY_HANDLE_FILE_INFORMATION info;
unsigned int FileSize,pos,x,y,col;
unsigned char *Data;

FileHandle = CreateFile(File,GENERIC_READ,0,NULL,OPEN_EXISTING, 0,NULL);
if (FileHandle == INVALID_HANDLE_VALUE) return 0;
GetFileInformationByHandle(FileHandle,&info);

Data = (unsigned char *) malloc(info.nFileSizeLow);

ReadFile(FileHandle,Data,info.nFileSizeLow,(unsign ed long *) &FileSize,NULL);
CloseHandle(FileHandle);

width = ((unsigned __int16 *) Data)[9];
height = ((unsigned __int16 *) Data)[11];
channels = 3;

switch (((unsigned __int16 *) Data)[14]){
case 8:
pixels = (unsigned char *) malloc(3 * width * height);
pos = 0;

for (y = 0; y < height; y++)
for (x = 0; x < width; x++){
col = Data[pos + 1078];
pixels[3 * (width * (height - y - 1) + x) ] = Data[56 + (col << 2)];
pixels[3 * (width * (height - y - 1) + x) + 1] = Data[55 + (col << 2)];
pixels[3 * (width * (height - y - 1) + x) + 2] = Data[54 + (col << 2)];
pos++;
}
break;
case 24:
pixels = (unsigned char *) malloc(3 * width * height);
pos = 0;

for (y = 0; y < height; y++){
for (x = 0; x < width; x++){
pixels[3 * (width * (height - y - 1) + x) ] = Data[56 + pos];
pixels[3 * (width * (height - y - 1) + x) + 1] = Data[55 + pos];
pixels[3 * (width * (height - y - 1) + x) + 2] = Data[54 + pos];
pos += 3;
}
}
break;
default:
free(Data);
return 0;
}

free(Data);

return 1;
}

Ebola
08-25-2000, 05:58 PM
Hmm . . 03:53 in the morning, ah well I had to live in England didn't I.


Thanx for the loader I'll try it;

- - -
I'm assuming pixels and height are members of the FileTexture class right?

So how'd I use glTexImage2D like this:

FileTexture cTexture;
glTexImage2D( ..., cTexture->pixels );

- Just have to clarify it, my brain don't work right, haven't had a coffee for six hours or more.
- - -

Any thought on the other problems ?

[This message has been edited by Ebola (edited 08-25-2000).]

Ebola
08-25-2000, 06:20 PM
Just so you can all look and laugh . . . here's my BMP Loader . . . It's kinda been borrowed from a book and screwed around with to meet needs for a previous project, I ported it so I've probably broken it somewhere along the line . . . I've checked and it seems OK, so anybody know watssup?

- - - -

typedef struct BitmapFile_s
{
BITMAPFILEHEADER BMP_FileHeader;
BITMAPINFOHEADER BMP_InfoHeader;

PALETTEENTRY Palette[256];

UCHAR *Data;
} BitmapFile_t;


BitmapFile_t *LoadBMP( char *FileName )
{

int File;

OFSTRUCT FileData;

if( (File = OpenFile( FileName, &FileData, OF_READ )) == 1 )
return( FAILURE );

_lread( File, &Bitmap.BMP_FileHeader, sizeof( BITMAPFILEHEADER ) );

if( Bitmap.BMP_FileHeader.bfType != BITMAP_ID ){
_lclose( File );
return( FAILURE );
}

_lread( File, &Bitmap.BMP_InfoHeader, sizeof( BITMAPINFOHEADER ) );

if( Bitmap.BMP_InfoHeader.biBitCount == 8 ){

_lread( File, &Bitmap.Palette, MAX_COLORS_PALETTE*sizeof( PALETTEENTRY ) );

for ( int i = 0; i < MAX_COLORS_PALETTE; i++ )
{
int j = Bitmap.Palette[i].peRed;
Bitmap.Palette[i].peRed = Bitmap.Palette[i].peBlue;
Bitmap.Palette[i].peBlue = j;

Bitmap.Palette[i].peFlags = PC_NOCOLLAPSE;
}

}

_lseek( File, -(int)(Bitmap.BMP_InfoHeader.biSizeImage), SEEK_END );

if( Bitmap.BMP_InfoHeader.biBitCount == 8 &#0124; &#0124; Bitmap.BMP_InfoHeader.biBitCount == 16 ){
if( Bitmap.Data )
free( Bitmap.Data );

if( !(Bitmap.Data = (UCHAR *)malloc( Bitmap.BMP_InfoHeader.biSizeImage )) ){
_lclose( File );
return( FAILURE );
}

_lread( File, Bitmap.Data, Bitmap.BMP_InfoHeader.biSizeImage );
} else {
return( FAILURE );
}

_lclose( File );

return( &Bitmap );
}

- - - -

Humus
08-25-2000, 08:10 PM
Yes, that's right. That's the way to use it.