main1.pp 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. (****************************************
  2. * NDS NeHe Lesson 02 *
  3. * Author: Dovoto *
  4. ****************************************)
  5. program main1;
  6. {$apptype arm9}
  7. {$define ARM9}
  8. {$mode objfpc}
  9. uses
  10. ctypes, nds9;
  11. function DrawGLScene(): boolean;
  12. begin
  13. glLoadIdentity(); // Reset The Current Modelview Matrix
  14. glTranslatef(-1.5,0.0,-6.0); // Move Left 1.5 Units And Into The Screen 6.0
  15. glBegin(GL_TRIANGLES); // Drawing Using Triangles
  16. glVertex3f( 0.0, 1.0, 0.0); // Top
  17. glVertex3f(-1.0,-1.0, 0.0); // Bottom Left
  18. glVertex3f( 1.0,-1.0, 0.0); // Bottom Right
  19. glEnd(); // Finished Drawing The Triangle
  20. glTranslatef(3.0,0.0,0.0); // Move Right 3 Units
  21. glBegin(GL_QUADS); // Draw A Quad
  22. glVertex3f(-1.0, 1.0, 0.0); // Top Left
  23. glVertex3f( 1.0, 1.0, 0.0); // Top Right
  24. glVertex3f( 1.0,-1.0, 0.0); // Bottom Right
  25. glVertex3f(-1.0,-1.0, 0.0); // Bottom Left
  26. glEnd(); // Done Drawing The Quad
  27. DrawGLScene := TRUE; // Keep Going
  28. end;
  29. begin
  30. // Turn on everything
  31. powerON(POWER_ALL);
  32. // Setup the Main screen for 3D
  33. videoSetMode(MODE_0_3D);
  34. // IRQ basic setup
  35. irqInit();
  36. irqSet(IRQ_VBLANK, nil);
  37. // initialize the geometry engine
  38. glInit();
  39. // enable antialiasing
  40. glEnable(GL_ANTIALIAS);
  41. // setup the rear plane
  42. glClearColor(0,0,0,31); // BG must be opaque for AA to work
  43. glClearPolyID(63); // BG must have a unique polygon ID for AA to work
  44. glClearDepth($7FFF);
  45. // Set our viewport to be the same size as the screen
  46. glViewPort(0,0,255,191);
  47. glMatrixMode(GL_PROJECTION);
  48. glLoadIdentity();
  49. gluPerspective(70, 256.0 / 192.0, 0.1, 100);
  50. // Set the color of the vertices
  51. glColor3f(1, 1, 1);
  52. while true do
  53. begin
  54. //ds specific, several attributes can be set here
  55. glPolyFmt(POLY_ALPHA(31) or POLY_CULL_NONE);
  56. // Set the current matrix to be the model matrix
  57. glMatrixMode(GL_MODELVIEW);
  58. //Push our original Matrix onto the stack (save state)
  59. glPushMatrix();
  60. DrawGLScene();
  61. // Pop our Matrix from the stack (restore state)
  62. glPopMatrix(1);
  63. //a handy little built in function to wait for a screen refresh
  64. swiWaitForVBlank();
  65. // flush to screen
  66. glFlush(0);
  67. end;
  68. end.