OpenGL problem

Thread Solved

Join Date: Nov 2007
Posts: 6
Reputation: eenceo is an unknown quantity at this point 
Solved Threads: 0
eenceo eenceo is offline Offline
Newbie Poster

OpenGL problem

 
0
  #1
Feb 23rd, 2009
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.
Reply With Quote Quick reply to this message  
Join Date: Jul 2006
Posts: 1,091
Reputation: MattEvans is a jewel in the rough MattEvans is a jewel in the rough MattEvans is a jewel in the rough 
Solved Threads: 63
Moderator
Featured Poster
MattEvans's Avatar
MattEvans MattEvans is offline Offline
Veteran Poster

Re: OpenGL problem

 
0
  #2
Feb 24th, 2009
looks like you have not called glEnable ( GL_DEPTH_TEST );
otherwise, post code
Plato forgot the nullahedron..
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 6
Reputation: eenceo is an unknown quantity at this point 
Solved Threads: 0
eenceo eenceo is offline Offline
Newbie Poster

Re: OpenGL problem

 
0
  #3
Feb 24th, 2009
  1. procedure TForm1.Draw;
  2. const ambientLight : TGLArrayf4 = (0.3, 0.3, 0.3, 1.0);
  3. lightColor : TGLArrayf4 = (0.7, 0.7, 0.7, 1.0);
  4. lightPos : TGLArrayf4 = (-2 * 6, 6, 4 * 6, 1.0);
  5. var c : CCube;
  6. begin
  7. glViewport(0, 0, Width, Height);
  8. glMatrixMode(GL_PROJECTION);
  9. glLoadIdentity();
  10. gluPerspective(45.0, width / height, 1.0, 200.0);
  11.  
  12. c := CCube.Create;
  13. c.posx := 0;
  14. c.posy := 0;
  15. c.posz := 0;
  16. c.sizex := 6;
  17. c.sizey := 2;
  18. c.sizez := 6;
  19.  
  20. glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT);
  21.  
  22. glMatrixMode(GL_MODELVIEW);
  23. glLoadIdentity();
  24.  
  25. glTranslatef(0.0, 0.0, -20.0);
  26.  
  27. glLightModelfv(GL_LIGHT_MODEL_AMBIENT, @ambientLight);
  28. glLightfv(GL_LIGHT0, GL_DIFFUSE, @lightColor);
  29. glLightfv(GL_LIGHT0, GL_POSITION, @lightPos);
  30.  
  31. glRotatef(-45, 1.0, 1.0, 0.0);
  32.  
  33. //glShadeModel(GL_FLAT);
  34.  
  35. c.Draw;
  36. SwapBuffers(wglGetCurrentDC);
  37. 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.

  1. glEnable(GL_DEPTH_TEST);
  2. glEnable(GL_LIGHTING);
  3. glEnable(GL_LIGHT0);
  4. glEnable(GL_NORMALIZE);
  5. glEnable(GL_COLOR_MATERIAL);

above is the code that is called after opengl is initialized.
Last edited by eenceo; Feb 24th, 2009 at 4:53 pm.
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 6
Reputation: eenceo is an unknown quantity at this point 
Solved Threads: 0
eenceo eenceo is offline Offline
Newbie Poster

Re: OpenGL problem

 
0
  #4
Feb 24th, 2009
Problem solved! I used polygons instead of GL_QUADS!
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC