I've been having some trouble using OpenGl in Delphi. Can anyone tell me what I might have done wrong.
Click here for a screen shot.

looks like you have not called glEnable ( GL_DEPTH_TEST ); otherwise, post code

procedure TForm1.Draw;
const ambientLight : TGLArrayf4 = (0.3, 0.3, 0.3, 1.0);
      lightColor   : TGLArrayf4 = (0.7, 0.7, 0.7, 1.0);
      lightPos     : TGLArrayf4 = (-2 * 6, 6, 4 * 6, 1.0);
var c : CCube;
begin
  glViewport(0, 0, Width, Height);
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
  gluPerspective(45.0, width / height, 1.0, 200.0);

  c := CCube.Create;
  c.posx := 0;
  c.posy := 0;
  c.posz := 0;
  c.sizex := 6;
  c.sizey := 2;
  c.sizez := 6;

  glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT);
	
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();
	
	glTranslatef(0.0, 0.0, -20.0);

  glLightModelfv(GL_LIGHT_MODEL_AMBIENT, @ambientLight);
  glLightfv(GL_LIGHT0, GL_DIFFUSE, @lightColor);
	glLightfv(GL_LIGHT0, GL_POSITION, @lightPos);

  glRotatef(-45, 1.0, 1.0, 0.0);

  //glShadeModel(GL_FLAT);
  
  c.Draw;
  SwapBuffers(wglGetCurrentDC);
end;

this code is ran on draw. c.draw; calls a function in my CCube class which does the actual drawing which i don't think the problem is in.

glEnable(GL_DEPTH_TEST);
	glEnable(GL_LIGHTING);
	glEnable(GL_LIGHT0);
	glEnable(GL_NORMALIZE);
	glEnable(GL_COLOR_MATERIAL);

above is the code that is called after opengl is initialized.

Problem solved! I used polygons instead of GL_QUADS!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.