Sign in to follow this  
Fantastic Jason

Display Lists...Aaarrrhhhhh

Recommended Posts

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?
    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();

Help anyone?

Share this post


Link to post
Share on other sites
Daaark    3553
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.

Share this post


Link to post
Share on other sites
Nit    533
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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this