OnPaint:
Code: Alles auswählen
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45.0,width/height,0.1,100.0);
glMatrixMode(GL_MODELVIEW);
glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT);
glLoadIdentity;
glTranslatef(0.0, 0.0, Distance);
glRotatef(RotationX,1.0,0.0,0.0);
glRotatef(RotationY,0.0,1.0,0.0);
glRotatef(RotationZ,0.0,0.0,1.0);
PaintCubes; //sub routine
SwapBuffers;
PaintCubes:
Code: Alles auswählen
for x:=0 to FBoardSize-1 do
for y:=0 to FBoardSize-1 do
for z:=0 to FBoardSize-1 do
begin
glPushMatrix;
glEnable(GL_BLEND);
glDisable(GL_TEXTURE_2D);
glTranslatef(x-fb2,y-fb2,z-fb2);
glColor4f(r,g,b,a);
if IsLetter then
begin
glDisable(GL_BLEND);
glEnable(GL_TEXTURE_2D);
glTexImage2D(GL_TEXTURE_2D,0,3,...,GL_RGB,GL_UNSIGNED_BYTE,Texture);
end;
glCallList(Cube);
glPopMatrix;
end;
Code: Alles auswählen
Cube:=glGenLists(1);
glNewList(Cube, GL_COMPILE);
glBegin(GL_QUADS);
{Front Face}
glNormal3f( 0.0, 0.0, 1.0);
glTexCoord2f( 1.0, 0.0); glVertex3f( 0.5, 0.5, 0.5);
glTexCoord2f( 0.0, 0.0); glVertex3f(-0.5, 0.5, 0.5);
glTexCoord2f( 0.0, 1.0); glVertex3f(-0.5,-0.5, 0.5);
glTexCoord2f( 1.0, 1.0); glVertex3f( 0.5,-0.5, 0.5);
{Back Face}
glNormal3f( 0.0, 0.0,-1.0);
glTexCoord2f( 0.0, 0.0); glVertex3f( 0.5, 0.5,-0.5);
glTexCoord2f( 0.0, 1.0); glVertex3f( 0.5,-0.5,-0.5);
glTexCoord2f( 1.0, 1.0); glVertex3f(-0.5,-0.5,-0.5);
glTexCoord2f( 1.0, 0.0); glVertex3f(-0.5, 0.5,-0.5);
...
glEnd;
glEndList;

