2
Contributors
3
Replies
4
Views
8 Years
Discussion Span
Last Post by eenceo
0
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.

0

Problem solved! I used polygons instead of GL_QUADS!

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.