Displaying bitmap logo

Hi
I’m making an interface for my game and would like to know how can I display a logo(bitmap format).

I would like the logo to remain fixed on the screen(e.g top right corner) while I may be moving around.

I’ve already written a function to read and load bitmap. what I need is a command to display the bitmap or something like that

Load the bitmap logic in as a texture and put is on a quad, this would be a good way to do it.
That way you can add transparent area’s to the logo and also use blend functions on it.

There is a draw pixel’s command but is not as fast as using it textured quad.

Originally posted by CLoNA:
[b]Hi
I’m making an interface for my game and would like to know how can I display a logo(bitmap format).

I would like the logo to remain fixed on the screen(e.g top right corner) while I may be moving around.

I’ve already written a function to read and load bitmap. what I need is a command to display the bitmap or something like that[/b]

And don’t forget to use the apropriate ortho projection.By apropriate I mean one that maps opengl units to screen pixels.For a 640x480 window using gluOrtho2D(0,640,0,480) will setup a projection matrix so that:

glBegin(GL_LINES);
glVertex2i(0,0);
glVertex2i(640,480);
glEnd();

Will create a line from the lower left corner of you window to the upper right one.I know you wanted a quad but I wa too bored to type the extra 2 glVertex calls…

Thx…Really helped

Hi

my Bmp loader :
/* image structure */
typedef struct {
BITMAPFILEHEADER bmfHeader;//file header
BITMAPINFOHEADER bmiHeader;//file header info
GLubyte *image_data;//image data

} BITMAP_IMAGE;

BITMAP_IMAGE image;

/* load the BMP,in default rep :NOM_REPERTOIRE_GRAPHIQUE , and nom_repertoire */
void LectureFichierBMP(const char *nom_repertoire, const char *filename,BITMAP_IMAGE *b)
{
FILE *fp;
int memory;
char repertoire_par_defaut[MAX_PATH];

 /* memoriser le repertoire courant */
 getcwd(repertoire_par_defaut,MAX_PATH);
 /* selection du repertoire graphique */
 chdir(NOM_REPERTOIRE_GRAPHIQUE);
 /* selection du repertoire choisit : interface ou territoire_couleur ou mask_territoire*/
 chdir(nom_repertoire);
 
 char* str = new char[strlen(filename)+5];

if (!str)
{
/* erreur allocation chaine */
}

/* concatenation de l'extension bmp du fichier image */

strcpy(str,filename);
strcat(str,".bmp");

 /* ouverture du fichier */

fp = fopen(str, “rb”);

// lecture en 14 bytes pour le file header
fread(&b -> bmfHeader, 1, 14, fp);

// lecture en 40 bytes pour le header info
fread(&b -> bmiHeader, 1, 40, fp);

// allocation memoire
if (b->bmiHeader.biSizeImage == 0)
{
memory = b->bmiHeader.biWidth * b->bmiHeader.biHeight * 4;
}
else
{
memory = b->bmiHeader.biSizeImage;
}
/* allouer de la memoire */
b->image_data = (GLubyte *)malloc(memory);

// lecture des data de l’image
fread(b->image_data , 1, memory, fp);

// fermeture du fichier
fclose(fp);
/* reselection du repertoire par defaut (application) */
chdir(repertoire_par_defaut);
}

/* texture mapping on a QUAD : */

glEnable(GL_TEXTURE_2D);

glGenTextures(1, &texture[0]);

glBindTexture(GL_TEXTURE_2D, texture[0]);

glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);

glPixelStorei(GL_UNPACK_ALIGNMENT, 1);

glTexImage2D(GL_TEXTURE_2D,0,3,256,256,0,GL_BGR_EXT,GL_UNSIGNED_BYTE,image.image_data);

free(image.image_data);
glDisable(GL_TEXTURE_2D);

PROJECTION :

glViewport(0,0,LARGEUR_FENETRE,HAUTEUR_FENETRE);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(-(LARGEUR_FENETRE/2),LARGEUR_FENETRE/2,-(HAUTEUR_FENETRE/2),HAUTEUR_FENETRE/2);

draw the quad with texture :

void afficher_sprite(int x_dest,int y_dest,int largeur,int hauteur,GLuint texture_id)
{
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, texture[texture_id]);
glBegin(GL_QUADS);
glTexCoord2d(0, 0);glVertex2d(x_dest, y_dest);
glTexCoord2d(1, 0);glVertex2d(x_dest + largeur, y_dest);
glTexCoord2d(1, 1);glVertex2d(x_dest + largeur,y_dest + hauteur);
glTexCoord2d(0, 1);glVertex2d(x_dest, y_dest + hauteur);
glEnd();
glDisable (GL_TEXTURE_2D);

}