MapList=glGenLists(1); // We are going to start off with one list for map
glNewList(MapList,GL_COMPILE);
// All that goes into our display list goes here
for(int x=0;x<20;x++)
{
for(int y=0;y<12;y++)
{
// Get the tile number from the array
int Tile = Maps[(y*MapWidth)+x].Tile;
// Calculate the texture coords required
if(Tile < 16)
{
CellX = Tile;
CellY = 0;
BLeftX = CellX * (XSize);
BLeftY = 1.0f-(1*YSize);
}
else
{
CellY= (Tile/16)+1;
CellX = Tile -((CellY-1)*16);
BLeftX = CellX*XSize;
BLeftY = 1.0f-(CellY*YSize);
}
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);
glColor4f(1.0f,1.0f,1.0f,AlphaVal);
// Draw the quad with the relevant texture position
glBegin(GL_QUADS);
glTexCoord2f(BLeftX, BLeftY);
glVertex2f(XOffset+ScrStartX, TileSize+YOffset+ScrStartY);
glTexCoord2f(BLeftX+XSize, BLeftY);
glVertex2f(TileSize+XOffset+ScrStartX, TileSize+YOffset+ScrStartY);
glTexCoord2f(BLeftX+XSize, BLeftY+YSize);
glVertex2f(TileSize+XOffset+ScrStartX, YOffset+ScrStartY);
glTexCoord2f(BLeftX, BLeftY+YSize);
glVertex2f(XOffset+ScrStartX, YOffset+ScrStartY);
glEnd();
YOffset+=TileSize;
}
XOffset+=TileSize;
YOffset=0;
}
glEndList();
Display Lists...Aaarrrhhhhh
Hi everyone,
Having a little trouble with creating a display list: The display list should display a tiled map which s 20 tiles wide x 12 tiles high...is the code below feasible as nothing is displayed when the list is called......what am I doing wrong?
Help anyone?
No the Alpha Val is Not Zero...I have tried hard coding it to no avail....
Is the code I presented okay for building a list?
If so I will keep playing with it......!
Is the code I presented okay for building a list?
If so I will keep playing with it......!
Make sure you create the list after you have a valid rendeing context created. Otherwise your list will contain nothing. If this list is getting created in a constructor of a static object, or you just call the map loader (which calls the list creator) before you have a valid openGl window, that is what will happen.
I also suggest you look at the drawing code itself without the display list and see if it draws. If so, then you may be doing it as Vampyre said. The code itself looked fine to me though.
In a similar vein I was experiencing similar glErrors regarding glGenTextures. Very frustrating. Anyway, Vamp's suggestion was right on spot with my problem: I was building textures from the constructor of my TextureMGR, which happened to be instantiate before my OpenGL window was constructed.
++Vampyre_Dark->rate
++Vampyre_Dark->rate
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement