Problem rendering a (hehe) rotating pyramid.

static void redraw (void)
{
static float rotateBy=0;
int a,b;
unsigned int CurrentVert;

    rotateBy+=1;
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    glPushMatrix();


                   glTranslatef(0,0,-100);
                   glRotatef(rotateBy,1,0,0);

                   glBegin(GL_TRIANGLES);

                   for (a=0;a<4;++a)
                   {
                    for (b=0;b<3;++b)
                    {
                     CurrentVert=Pyramid.Tri[a].Ver[b];

                     glColor3fv(Pyramid.Ver[ CurrentVert ].col);
                     glVertex3fv(Pyramid.Ver[ CurrentVert ].pos);
                    }
                   }

 glEnd;
 glPopMatrix;

 glutSwapBuffers;
 glutPostRedisplay;

}

I THINK the problem is somewhere up in there, though I may be wrong… It compiles, but the window doesn’t display properly–It has the outline, but the inside looks exactly the same as the stuff behind it.

Changed:
glEnd;
glPopMatrix;

glutSwapBuffers;
glutPostRedisplay;

to:

glEnd();
glPopMatrix();

glutSwapBuffers();
glutPostRedisplay();
}

Now it’s drawing a black screen in the window, I think the error is somewhere else, if I can’t find it I’ll give y’all a ring.

Well, I’m stumped…Here’s the full source:

#include <windows.h>
#include <gl/gl.h>
#include <gl/glu.h>
#include <gl/glut.h>
static void redraw (void);
void initPyramid (void);
int main(int argc, char **argv);

struct Pyramid
{
struct Tri
{
unsigned int Ver[3];
}Tri[4];
struct Ver
{
float pos[3];
float col[3];
}Ver[3];
}Pyramid;

int main(int argc, char **argv)
{
glutInit(&argc,argv);
glutInitDisplayMode (GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
glutCreateWindow(“Pyramid”);

glutDisplayFunc(redraw);

glMatrixMode(GL_PROJECTION);
gluPerspective(45,
1.0,
10.0,
200.0);
glMatrixMode(GL_MODELVIEW);

glEnable(GL_CULL_FACE);

glutMainLoop();

return 0;
};

void initPyramid (void)
{
float vertPos[4][3]=
{
{0, 10, 0}, //Top vertice
{-10,-10,10}, //Left Vertice
{10,-10,10}, //Right Vertice
{0,-10,-10} //Bottom Vertice
};

float vertCol[4][3]=
{
{1,0,0}, //red
{0,1,0}, //blue
{0,0,1}, //green
{1,1,0} //purple
};
unsigned int triVerts[4][3]=
{
{0,1,2}, //Front Triangle
{0,1,3}, //Left Triangle
{0,2,3}, //Right Triangle
{1,2,3}, //Bottom Triangle
};

   int a,b;
   for(a=0;a&lt;4;++a)
   {
                   for(b=0;b&lt;3;++b)
                   {
                    Pyramid.Ver[a].pos[b]=vertPos[a][b];
                    Pyramid.Ver[a].col[b]=vertCol[a][b];
                   }
   }

   for(a=0;a&lt;4;++a)
   {
    for(b=0;b&lt;3;++b)
    {
      Pyramid.Tri[a].Ver[b]=triVerts[a][b];
    }
}

}
static void redraw(void)
{
static float rotateBy=0;
int a,b;
unsigned int CurrentVert;

    rotateBy+=1;
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    glPushMatrix();


                   glTranslatef(0,0,-50);
                   glRotatef(rotateBy,1,0,0);

                   glBegin(GL_TRIANGLES);

                   for (a=0;a&lt;4;++a)
                   {
                    for (b=0;b&lt;3;++b)
                    {
                     CurrentVert=Pyramid.Tri[a].Ver[b];

                     glColor3fv(Pyramid.Ver[CurrentVert].col);
                     glVertex3fv(Pyramid.Ver[CurrentVert].pos);
                    }
                   }

 glEnd();
 glPopMatrix();

 glutSwapBuffers();
 glutPostRedisplay();

}

Any ideas?

Try moving that post redisplay call outside your drawing function (redraw).

Have you looked at any introductory tutorials on OpenGL? Nehe is quite popular these days. They will probably help you structure your code a bit better.

mad