Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

89 lines
1.8 KiB

  1. /* A simple program to build a circle with display lists */
  2. #include <windows.h>
  3. #include <stdio.h>
  4. #include <math.h>
  5. #include <GL/gl.h>
  6. #include "glaux.h"
  7. #define MY_CIRCLE_LIST 1
  8. #define PI 3.1415926535897
  9. void
  10. buildCircle()
  11. {
  12. GLint i;
  13. GLfloat cosine, sine;
  14. glNewList(MY_CIRCLE_LIST, GL_COMPILE);
  15. glBegin(GL_LINE_STRIP);
  16. glColor3f(1.0F, 0.0F, 0.0F);
  17. for (i=0; i<100; i++) {
  18. cosine = cos(i*2*PI/100.0);
  19. sine = sin(i*2*PI/100.0);
  20. glVertex2f(cosine, sine);
  21. }
  22. glEnd();
  23. glEndList();
  24. }
  25. void myReshape(GLsizei w, GLsizei h)
  26. {
  27. glViewport(0, 0, w, h);
  28. glMatrixMode(GL_PROJECTION);
  29. glLoadIdentity();
  30. glMatrixMode(GL_MODELVIEW);
  31. glLoadIdentity();
  32. }
  33. void display(void)
  34. {
  35. printf("display called\n");
  36. glClear(GL_COLOR_BUFFER_BIT);
  37. glCallList(MY_CIRCLE_LIST);
  38. glFlush();
  39. }
  40. void myinit(void)
  41. {
  42. glClearColor(0.0F, 0.0F, 0.4F, 1.0F);
  43. glShadeModel(GL_FLAT);
  44. glDisable(GL_DEPTH_TEST);
  45. buildCircle();
  46. }
  47. void apressed(key, mask)
  48. {
  49. printf("key is %d, mask is 0x%x\n", key, mask);
  50. }
  51. void LeftPressed(AUX_EVENTREC *event)
  52. {
  53. printf("Left pressed (%d, %d)\n", event->data[AUX_MOUSEX],
  54. event->data[AUX_MOUSEY]);
  55. }
  56. void LeftReleased(AUX_EVENTREC *event)
  57. {
  58. printf("Left released (%d, %d)\n", event->data[AUX_MOUSEX],
  59. event->data[AUX_MOUSEY]);
  60. }
  61. int main(int argc, char *argv[])
  62. {
  63. auxInitDisplayMode(AUX_SINGLE | AUX_RGBA);
  64. auxInitPosition(100, 150, 300, 300);
  65. auxInitWindow("Tri");
  66. myinit();
  67. auxKeyFunc(AUX_a, apressed);
  68. auxMouseFunc(AUX_LEFTBUTTON, AUX_MOUSEDOWN, LeftPressed);
  69. auxMouseFunc(AUX_LEFTBUTTON, AUX_MOUSEUP, LeftReleased);
  70. auxReshapeFunc (myReshape);
  71. auxMainLoop(display);
  72. return 0;
  73. }