lesson01.pp 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. var
  18. keys: integer;
  19. begin
  20. // Setup the Main screen for 3D
  21. videoSetMode(MODE_0_3D);
  22. // initialize the geometry engine
  23. glInit();
  24. // enable antialiasing
  25. glEnable(GL_ANTIALIAS);
  26. // setup the rear plane
  27. glClearColor(0, 0, 0, 31); // BG must be opaque for AA to work
  28. glClearPolyID(63); // BG must have a unique polygon ID for AA to work
  29. glClearDepth($7FFF);
  30. // Set our viewport to be the same size as the screen
  31. glViewport(0, 0, 255, 191);
  32. // setup the view
  33. glMatrixMode(GL_PROJECTION);
  34. glLoadIdentity();
  35. gluPerspective(70, 256.0 / 192.0, 0.1, 100);
  36. //ds specific, several attributes can be set here
  37. glPolyFmt(POLY_ALPHA(31) or POLY_CULL_NONE);
  38. while true do
  39. begin
  40. // Set the current matrix to be the model matrix
  41. glMatrixMode(GL_MODELVIEW);
  42. glColor3f(1, 1, 1); // Set the color..not in nehe source...ds gl default will be black
  43. //Push our original Matrix onto the stack (save state)
  44. glPushMatrix();
  45. DrawGLScene();
  46. // Pop our Matrix from the stack (restore state)
  47. glPopMatrix(1);
  48. //a handy little built in function to wait for a screen refresh
  49. swiWaitForVBlank();
  50. // flush to screen
  51. glFlush(0);
  52. scanKeys();
  53. keys := keysDown();
  54. if (keys and KEY_START) <> 0 then break;
  55. end;
  56. end.