943,704 Members | Top Members by Rank

Ad:
Feb 23rd, 2009
0

OpenGL problem

Expand Post »
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.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
eenceo is offline Offline
8 posts
since Nov 2007
Feb 24th, 2009
0

Re: OpenGL problem

looks like you have not called glEnable ( GL_DEPTH_TEST );
otherwise, post code
Moderator
Featured Poster
Reputation Points: 522
Solved Threads: 64
Veteran Poster
MattEvans is offline Offline
1,091 posts
since Jul 2006
Feb 24th, 2009
0

Re: OpenGL problem

delphi Syntax (Toggle Plain Text)
  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.

delphi Syntax (Toggle Plain Text)
  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.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
eenceo is offline Offline
8 posts
since Nov 2007
Feb 24th, 2009
0

Re: OpenGL problem

Problem solved! I used polygons instead of GL_QUADS!
Reputation Points: 10
Solved Threads: 0
Newbie Poster
eenceo is offline Offline
8 posts
since Nov 2007

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Game Development Forum Timeline: DirectX - Collision detection
Next Thread in Game Development Forum Timeline: Directx Input / Movement Q





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC