I wanted to learn to develop games so started with tetris. I encountered a problem right in the beginning. My game is 20% ready. There are five types of shapes viz YELL, BOX, LINE, TEE, YEL which are shapes of different kinds. I created five display lists like this
#define YELL 1
#define BOX 2
#define LINE 3
#define TEE 4
#define YEL 5
int bs=20;
void defineshapes()
{
glNewList(YELL,GL_COMPILE);
glPushMatrix();
glTranslated(-bs,0,0);
glColor3fv(color[color1]);
glBegin(GL_POLYGON);
glVertex2i(0,0);
glVertex2i(bs,0);
glVertex2i(bs,-bs);
glVertex2i(0,-bs);
glEnd();
glTranslated(bs,0,0);
glColor3fv(color[color2]);
glBegin(GL_POLYGON);
glVertex2i(0,0);
glVertex2i(bs,0);
glVertex2i(bs,-bs);
glVertex2i(0,-bs);
glEnd();
glTranslated(bs,0,0);
glColor3fv(color[color3]);
glBegin(GL_POLYGON);
glVertex2i(0,0);
glVertex2i(bs,0);
glVertex2i(bs,-bs);
glVertex2i(0,-bs);
glEnd();
glTranslated(-2*bs,-bs,0);
glColor3fv(color[color4]);
glBegin(GL_POLYGON);
glVertex2i(0,0);
glVertex2i(bs,0);
glVertex2i(bs,-bs);
glVertex2i(0,-bs);
glEnd();
glPopMatrix();
glEndList();
glNewList(BOX,GL_COMPILE);
glPushMatrix();
.....
and randomly picking one like this
srand(time(NULL));
color1=rand()%6;
color2=rand()%6;
color3=rand()%6;
color4=rand()%6;
defineshapes();
randshape=rand()%5+1;
and drawing in display function like this
void display()
{
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glPushMatrix();
glTranslated(x2,y2,0);
glCallList(randshape);
glPopMatrix();
glFlush();
}
I expected problem in the beginning itself when i used the display lists because i had to access the vertex values(x,y) of the shapes to check if they might overlap with another block below before moving them down. Is there a way of knowing the vertex values of objects drawn using display lists.
I encountered the same problem once before when i needed to create a tyre of a car. I wanted the tyre to be painted with colors so created a mesh by rotating a circle again using display lists. Then i needed to know the values of the intersection points of longitudes and latitudes which i didnt know how to get so i abandoned that task.
A YELL looks like this

What is the easiest method of getting around this problem. I am sure OpenGL has a way of getting this done but i am new to it.