Sign in to follow this  

glListBase & differently sized structures created with call lists

This topic is 3306 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

Ok - I have a 2d tile-based game that I display with quads that are looked at head-on. I have each of the 16 x 16 tiles associated with a call list that I create. I read the bmp into memeory then create the call lists at a certain size then if I want to zoom in I have a very inefficient way of doing it - I build the call list over again in the new dimensions - I have two types of display functions with the one I call glListBase(gl_base) and it prints to whatever size I currently have built with the other one I call glListBase(1) and it prints to the original size that I built at the beginning of the progaam running and does not change based upon my rebuilding the call list with new dimensions - my question is why does this happen?

Share this post


Link to post
Share on other sites
I don't really understand your question either, but just a couple of notes. First, if it's only about scaling and/or rotating, you don't need to change the lists at all. All you need is to modify the root transformation matrix before rendering, and use the same list everywhere. And second, you shouldn't be using display lists anyway. It's an old and obsolete system. You should be using VBOs instead, which incidentally make everything much easier and cleaner.

Share this post


Link to post
Share on other sites
I got these from the NeHe tutorial # 17 - rendering text:

I call build_font() at the beginning of my program with texSizeR and texSizeP determining the dimensions of the quad - this creates 4096 call lists.

Later on, after my program has been running I press my zoom key which causes the inefficient zoom in/out function I have set up to change texSizeR and texSizeP and then call build_font() again.

My first display function, glPrint() (which prints up to three layers of quads onto one section of the screen), always displays the quads at dimensions texSizeR/texSizeP. My other display function, glPrintS3() (which prints one solidly-colored quad as the background and then another one on top of it) always displays the quads at the original texSizeR/texSizeP dimensions.

The thing that causes this change is when I call glListBase() at the beginning of the two print functions. When I call glListBase(g_base) it prints the quads at the current texSizeR/texSizeP dimensions (the call list that I built most recently) - when I call glListBase(1), is prints the quads at the original texSizeR/texSizeP dimensions even though I destroyed the original call list.


So how would I change the root transformation matrix to alter the dimensions of the quad? I guess if I knew how to do that I would not care about my original question.



I have been looking over VBOs and I am not getting it right away, or something and I have already wasted too much of my time not programming while I was drawing the tiles so I will hold off on that until later on.
But, would I be creating static VBOs? or would wanting to change the dimensions of the quad mean that it is no longer static?



build_font:
void build_font(void)								
{

LoadBitmap("texture1.bmp");
int i;
float cx; // Holds Our X Character Coord
float cy; // Holds Our Y Character Coord

g_base = glGenLists(1206); // Creating 256 Display Lists - I don't think this really makes a
// difference since it is still at 1206 and I am now creating 4096
// call lists
glListBase(g_base);
glBindTexture(GL_TEXTURE_2D, g_texid[0]); // Select Our Font Texture
for (i=0 ; i<4096 ; i++)
{ // Loop Through All 256 Lists //4096
cx = float(i%64)/64.0f; // X Position Of Current Character
cy = float(i/64)/64.0f; // Y Position Of Current Character
glNewList(g_base+i,GL_COMPILE); // Start Building A List
glBegin(GL_QUADS); // Use A Quad For Each Character
glTexCoord2f(cx,1-cy-.015625+.001); // Texture Coord (Bottom Left) //.015625
//.0078125

glVertex2i(0,0); // Vertex Coord (Bottom Left)
glTexCoord2f(cx+.015625f,1-cy-.015625+.001); // Texture Coord (Bottom Right)
glVertex2i(texSizeR,0); // Vertex Coord (Bottom Right)
glTexCoord2f(cx+.015625f,1-cy-.001); // Texture Coord (Top Right)
glVertex2i(texSizeR,texSizeP); // Vertex Coord (Top Right)
glTexCoord2f(cx,1-cy-.001); // Texture Coord (Top Left)
glVertex2i(0,texSizeP); // Vertex Coord (Top Left)
glEnd(); // Done Building Our Quad (Character)
glTranslated(texSizeR,0,0); // Move To The Right Of The Character
glEndList(); // Done Building The Display List
} // Loop Until All 256 Are Built




glPrint:

void glPrint(GLint x, GLint y, int set, int fore, int set2, int fore2, int set3, int fore3, int level)
{
COLORS cp;
int testSize;
//unsigned int outR[1]={427};
unsigned int outt[1]={set};
unsigned int outR[1]={set2};
unsigned int outQ[1]={set3};

glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
glPushMatrix(); // Store The Projection Matrix
glLoadIdentity(); // Reset The Projection Matrix
glOrtho(0,WCX,0,WCY,-100,100); // Set Up An Ortho Screen
glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
glPushMatrix(); // Store The Modelview Matrix
glLoadIdentity(); // Reset The Modelview Matrix

glTranslated(x,y,level);
glListBase(g_base);
color1=cp.colors[fore];
glColor3f(color1.R,color1.G,color1.B);
glListBase(g_base); // Choose The Font Set (0 or 1)
glCallLists(1,GL_UNSIGNED_INT,outt); // Write The Text To The Screen
if(set2!=-1)
{
glTranslated(-texSizeR,0,level+1);
color1=cp.colors[fore2];
glColor3f(color1.R,color1.G,color1.B);
glCallLists(1,GL_UNSIGNED_SHORT,outR);
}
if(set3!=-1)
{
glTranslated(-texSizeR,0,level+2);
color1=cp.colors[fore3];
glColor3f(color1.R,color1.G,color1.B);
glCallLists(1,GL_UNSIGNED_SHORT,outQ);
}
glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
glPopMatrix(); // Restore The Old Projection Matrix
glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
glPopMatrix(); // Restore The Old Projection Matrix
glEnable(GL_DEPTH_TEST); // Enables Depth Testing
}



glPrintS3:

void glPrintS3(GLint x, GLint y, int set, int fore, int back)
{
//this prints out one normally sized character
COLORS cp;
int testSize;
unsigned int outt[1]={set};
glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
glPushMatrix(); // Store The Projection Matrix
glLoadIdentity(); // Reset The Projection Matrix
glOrtho(0,WCX,0,WCY,-100,100); // Set Up An Ortho Screen
glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
glPushMatrix(); // Store The Modelview Matrix
glLoadIdentity(); // Reset The Modelview Matrix

glTranslated(x,y,20);
color1=cp.colors[fore];
glColor3f(color1.R,color1.G,color1.B);
glListBase(1);

glCallLists(1,GL_UNSIGNED_INT,outt); // Write The Text To The Screen
glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
glPopMatrix(); // Restore The Old Projection Matrix
glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
glPopMatrix(); // Restore The Old Projection Matrix
glEnable(GL_DEPTH_TEST); // Enables Depth Testing}

}

Share this post


Link to post
Share on other sites

This topic is 3306 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.

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