Jump to content
  • Advertisement
Sign in to follow this  
Fantastic Jason

Display Lists...Aaarrrhhhhh

This topic is 4700 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
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
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.

Share this post


Link to post
Share on other sites
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!