More display lists not working...

Member
Posts: 70
Joined: 2004.06
Post: #1
I am trying to create a display list that is bigger than the screen, made of textured quads. I intend to use it to render the ocean in a top-down game. The following code is used to generate the list:
Code:
// create a display list for the ocean
    xCount = screenSize[0] / width + 1;
    yCount = screenSize[1] / height + 1;
    
    oceanDisplayList = glGenLists(1);
    if (oceanDisplayList == 0)
    {
        std::cout << "Error: unable to create display list for ocean.\n";
        return FALSE;
    }
    
    glNewList(oceanDisplayList, GL_COMPILE);
        glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
                
        glBegin(GL_QUADS);
            for (i = 0; i < yCount; i++)
            {
                startY = i * height;
                
                for (j = 0; j < xCount; j++)
                {
                    startX = j * width;
                    
                    glTexCoord2f(0.0f, 0.0f);
                    glVertex2f(startX, startY);
                    
                    glTexCoord2f(1.0f, 0.0f);
                    glVertex2f(startX + width, startY);
                    
                    glTexCoord2f(1.0f, 1.0f);
                    glVertex2f(startX + width, startY + height);
                    
                    glTexCoord2f(0.0f, 1.0f);
                    glVertex2f(startX, startY + height);
                }
            }
        glEnd();
    glEndList();
[x,y]Count stores the number of quads along the x and y axis. startX and Y store the bottom left coords of the current quad. oceanDisplayList is a class variable, and is valid (with value 1) in every instance that I use it.

This is the code that I use to draw it:
Code:
glClear(GL_COLOR_BUFFER_BIT);
    
    glLoadIdentity();
    glTranslatef(0.0f, 0.0f, -5.0f);
        
    glBindTexture(GL_TEXTURE_2D, textures[FRT_WATER].textureID);
    glCallList(oceanDisplayList);
    
    glFlush();
    SDL_GL_SwapBuffers();
The texture I'm trying to use is valid. Nothing renders on screen, however. If I'm right, then because 0,0 is at the bottom left of the window, the bottom left corner of the display list should be in the bottom left corner of the window, and it extends up and out. If I add in a 100x100px quad drawn in immediate mode after I call the DL, a quad is rendered on screen. If I make another display list with a 100x100px quad in it and call that, it also renders.

I know the two for loops I use to generate the actual vertices for the list work, because if I copy/paste them where I would normally call the list and use immediate mode to render it, then the ocean is rendered.

There is a valid GL context when I generate the list; I know this because immediately before the list is made I load a few textures succesfully, and immediately after it I generated a test list with one quad in it which does work.

I have tried binding the texture during the list's compilation, too, rather than only before calling the list. The reason I want to not bind it during compilation normally is because I want to be able to use multiple textures on the one list, to animate the water later.

Can anyone see *any* reason why my ocean display list might not work?
Quote this message in a reply
Member
Posts: 70
Joined: 2004.06
Post: #2
Just to add further confusion, if I remove the for loops and put in a basic textured quad, it works.

So, the list itself is ok. The for loops do generate the right stuff, because they work in immediate mode. It simply doesn't work when the for loops are inside the list. Why on earth is it doing this?!
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Display Lists and Obj. File Loader Problems merrill541 0 1,984 Oct 17, 2008 06:42 PM
Last Post: merrill541
  Display Lists or Vertex Arrays with texturing seven 6 3,900 Oct 17, 2005 09:24 AM
Last Post: seven
  Slowing Frame Rates and Display Lists Nick 4 3,076 Mar 27, 2005 06:08 AM
Last Post: wadesworld
  Display Lists not working Jake 6 3,892 Dec 8, 2004 04:10 PM
Last Post: TomorrowPlusX
  Will VBOs be faster than display lists for simple meshes? TomorrowPlusX 14 6,005 Nov 30, 2004 03:32 PM
Last Post: arekkusu