lesson01.pp 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. (****************************************
  2. * NDS NeHe Lesson 01 *
  3. * Author: Dovoto *
  4. ****************************************)
  5. program Lesson01;
  6. {$mode objfpc}
  7. uses
  8. ctypes, nds9;
  9. function DrawGLScene(): boolean;
  10. begin
  11. //we are going to use floating point for the tutorial...keep in mind the DS has no
  12. //floating point hardware. For real life use the built in fixed point types.
  13. //this is where the magic happens
  14. glLoadIdentity();
  15. result := true;
  16. end;
  17. begin
  18. // Setup the Main screen for 3D
  19. videoSetMode(MODE_0_3D);
  20. // initialize the geometry engine
  21. glInit();
  22. // enable antialiasing
  23. glEnable(GL_ANTIALIAS);
  24. // setup the rear plane
  25. glClearColor(0, 0, 0, 31); // BG must be opaque for AA to work
  26. glClearPolyID(63); // BG must have a unique polygon ID for AA to work
  27. glClearDepth($7FFF);
  28. // Set our viewport to be the same size as the screen
  29. glViewport(0, 0, 255, 191);
  30. // setup the view
  31. glMatrixMode(GL_PROJECTION);
  32. glLoadIdentity();
  33. gluPerspective(70, 256.0 / 192.0, 0.1, 100);
  34. //ds specific, several attributes can be set here
  35. glPolyFmt(POLY_ALPHA(31) or POLY_CULL_NONE);
  36. while true do
  37. begin
  38. // Set the current matrix to be the model matrix
  39. glMatrixMode(GL_MODELVIEW);
  40. glColor3f(1, 1, 1); // Set the color..not in nehe source...ds gl default will be black
  41. //Push our original Matrix onto the stack (save state)
  42. glPushMatrix();
  43. DrawGLScene();
  44. // Pop our Matrix from the stack (restore state)
  45. glPopMatrix(1);
  46. //a handy little built in function to wait for a screen refresh
  47. swiWaitForVBlank();
  48. // flush to screen
  49. glFlush(0);
  50. end;
  51. end.