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.

77 lines
1.5 KiB

  1. /* A simple triangle program */
  2. #include <windows.h>
  3. #include <stdlib.h>
  4. #include <GL/gl.h>
  5. #include "glaux.h"
  6. #define WIDTH 300
  7. #define HEIGHT 300
  8. void display(void)
  9. {
  10. int i;
  11. GLfloat r, g, b, x, y;
  12. //printf("display called\n");
  13. glClear(GL_COLOR_BUFFER_BIT);
  14. glColor3f(1.0F, 0.0F, 0.0F);
  15. glBegin(GL_POINTS);
  16. for (i=0; i< 2000; i++) {
  17. r = (rand() % 10) / 10.0;
  18. g = (rand() % 10) / 10.0;
  19. b = (rand() % 10) / 10.0;
  20. x = rand() % WIDTH;
  21. y = rand() % HEIGHT;
  22. glColor3f(r, g, b);
  23. glVertex2f(x, y);
  24. }
  25. glEnd();
  26. //printf("sleep 10\n");
  27. Sleep(10*1000);
  28. //printf("Flush\n");
  29. glFlush();
  30. }
  31. void myinit(void)
  32. {
  33. glClearColor(0.0F, 0.0F, 0.4F, 1.0F);
  34. glShadeModel(GL_SMOOTH);
  35. }
  36. void apressed(key, mask)
  37. {
  38. // printf("key is %d, mask is 0x%x\n", key, mask);
  39. }
  40. void LeftPressed(AUX_EVENTREC *event)
  41. {
  42. //printf("Left pressed (%d, %d)\n", event->data[AUX_MOUSEX],
  43. // event->data[AUX_MOUSEY]);
  44. }
  45. void LeftReleased(AUX_EVENTREC *event)
  46. {
  47. //printf("Left released (%d, %d)\n", event->data[AUX_MOUSEX],
  48. // event->data[AUX_MOUSEY]);
  49. }
  50. int main(int argc, char *argv[])
  51. {
  52. auxInitDisplayMode(AUX_SINGLE | AUX_RGBA);
  53. auxInitPosition(100, 150, WIDTH, HEIGHT);
  54. auxInitWindow("Tri");
  55. myinit();
  56. auxKeyFunc(AUX_a, apressed);
  57. auxMouseFunc(AUX_LEFTBUTTON, AUX_MOUSEDOWN, LeftPressed);
  58. auxMouseFunc(AUX_LEFTBUTTON, AUX_MOUSEUP, LeftReleased);
  59. auxMainLoop(display);
  60. return 0;
  61. }