Loading A Bitmap

Is there a tutorial or a simple way to load a bitmap from file and stretch it to fit the window size.

  • VC6-OGL

loading as a texture could be :
AUX_RGBImageRec *Pic1 auxDibImageLoad(“dir”);
glGenTextures(1,&TextureBin[0]);
glBindTexture(GL_TEXTURE_2D,TextureBin[0]);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);

glTexImage2D(GL_TEXTURE_2D,0,3,Pic1->sizeX,Pic1->sizeY,0,GL_UNSIGNED_BYTE,GL_RGB,Pic1->data);
free(pic1->data);
free(pic1);

and to fit it use glOrtho and by glVertex2f draw GL_SQUAD ever hole window and put texture on it.

Thanx!!!

Real men write their own loaders!

void LoadTexture( unsigned int texture, char filename )
{
#define getLEushort(t) temp = (unsigned char
)(&(t)); temp[0] = getc(infile); temp[1] = getc(infile);
#define getLEuint(t) temp = (unsigned char*)(&(t)); temp[0] = getc(infile); temp[1] = getc(infile); temp[2] = getc(infile); temp[3] = getc(infile);
unsigned int i, row, numrows, numcols;
unsigned short bitsperpix;
FILE *infile = NULL;
unsigned char *temp, *data;

infile = fopen( filename, “rb” );
if (!infile) {
printf( “error opening file” ); exit( 0 ); }
for (i=0; i<18; i++)
getc( infile );
getLEuint( numcols );
getLEuint( numrows );
getc( infile ); getc( infile );
getLEushort( bitsperpix );
for (i=0; i<24; i++)
getc( infile );
if (bitsperpix != 24) {
printf( “Not a 24 bit image.” ); exit( 0 ); }
data = new unsigned char[numrows * numcols * 3];
if (!data) {
printf( “could not alloc enough mem” ); exit( 0 ); }
for (row=0; row < numrows; row++) {
for (i=0; i < numcols; i++) {
data[(row*numcols+i)3+2] = getc( infile ); // b
data[(row
numcols+i)3+1] = getc( infile ); // g
data[(row
numcols+i)*3] = getc( infile ); } // r
for (i=0; i < (((3 * numcols + 3) / 4) * 4) - 3 * numcols; i++)
getc( infile ); }
if (numrows == 1) {
glBindTexture( GL_TEXTURE_1D, texture );
glTexImage1D( GL_TEXTURE_1D, 0, 3, numcols, 0, GL_RGB, GL_UNSIGNED_BYTE, data );
glTexParameteri( GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
glTexParameteri( GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
} else {
glBindTexture( GL_TEXTURE_2D, texture );
glTexImage2D( GL_TEXTURE_2D, 0, 3, numcols, numrows, 0, GL_RGB, GL_UNSIGNED_BYTE, data );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); }
delete data;
fclose( infile );
}