Advertisement

Sprites using DisplayList

Started by August 24, 2001 01:16 PM
2 comments, last by Frank Henry 23 years, 5 months ago
hi again. building on Tutorial 17, i wanted to make my own sprite-engine. i have a BMP-file with multiple pics, all the same size in a row. i.e.: [mask/texture][texture].... i load the bmp using nehe''s code, after the texture is bound i get the x+y dimensions from the file. then i create the displaylist with y/x number of lists, and then fill the lists. and, guess what, it doesn''t work! surprise! ;-) can anyone help me out??? thanks again here''s the code: #define FRAME (float)0.01 /*************************************************************/ /* Loads a BMP-Sprite-Image */ /*************************************************************/ int LoadBMPSprite(SPRITE_HANDLE &Sprite, char *Filename) // Loads A Bitmap Image { int Status=FALSE; AUX_RGBImageRec *TextureImage[1]; memset(TextureImage,0,sizeof(void *)*1); FILE *File=NULL; if (!Filename) { return NULL; } File=fopen(Filename,"r"); if (!File) return Status; else { fclose(File); TextureImage[0]=auxDIBImageLoad(Filename); } Status=TRUE; Sprite.sizeX = TextureImage[0]->sizeX; Sprite.sizeY = TextureImage[0]->sizeY; glGenTextures(1, &Sprite.Texture); glBindTexture(GL_TEXTURE_2D, Sprite.Texture); glTexImage2D(GL_TEXTURE_2D, 0, 3, TextureImage[0]->sizeX, TextureImage[0]->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[0]->data); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); if (TextureImage[0]) { if (TextureImage[0]->data) { free(TextureImage[0]->data); } free(TextureImage[0]); } Sprite.Number_Of_Images = Sprite.sizeX / Sprite.sizeY; Sprite.List=glGenLists(Sprite.Number_Of_Images); int Size = Sprite.sizeY / 2; for (int loop=0; loop= Sprite.Number_Of_Images) return; glBindTexture(GL_TEXTURE_2D, Sprite.Texture); glEnable(GL_TEXTURE_2D); glDisable(GL_DEPTH_TEST); SetShadeModel (true, GL_SMOOTH); SetCorrectionHint (true, GL_NICEST); SetubColor (FullBright); glPushMatrix (); glLoadIdentity(); GLDoPosRot (Position); glPushAttrib (GL_LIST_BIT); glListBase(Sprite.List); glCallLists(1,GL_UNSIGNED_BYTE, &Index); glPopAttrib (); SetBlending (false, 0,0); SetDepthTest (true, GL_EQUAL); glDisable(GL_TEXTURE_2D); glPopMatrix (); }
Try glCallList(1)

========================
Leyder Dylan
http://ibelgique.ifrance.com/Slug-Production/
========================Leyder Dylan (dylan.leyder@slug-production.be.tf http://users.skynet.be/fa550206/Slug-Production/Index.htm/
Advertisement
hi!
yeah i already thought of that.
here''s the current status:
i partially got it to work,
problem is that it will NOT work with more then
2 parts of a texture.
all i get then is a white texture.

thanks

i can supply the code if needed!
(intended as open source anyway!)
help?
anyone????
argh!

This topic is closed to new replies.

Advertisement