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.

79 lines
1.5 KiB

  1. #include <stdlib.h>
  2. #include <stdio.h>
  3. #include <windows.h>
  4. #include <GL/gl.h>
  5. #include <GL/glu.h>
  6. #include "glaux.h"
  7. void Initialize(void)
  8. {
  9. glDrawBuffer(GL_FRONT_AND_BACK);
  10. }
  11. void TriangleAt(GLfloat x, GLfloat y, GLfloat z, GLfloat size, BOOL colors)
  12. {
  13. glPushMatrix();
  14. glTranslatef(x, y, z);
  15. glBegin (GL_TRIANGLES);
  16. if (colors)
  17. {
  18. glColor3f(1.0f, 0.0f, 0.0f);
  19. }
  20. glVertex2f (0.0f, 0.0f);
  21. if (colors)
  22. {
  23. glColor3f(0.0f, 1.0f, 0.0f);
  24. }
  25. glVertex2f (size, size);
  26. if (colors)
  27. {
  28. glColor3f(0.0f, 0.0f, 1.0f);
  29. }
  30. glVertex2f (0.0f, size);
  31. glEnd ();
  32. glPopMatrix();
  33. }
  34. void Test(void)
  35. {
  36. TriangleAt(1.0f, 1.0f, 0.0f, 98.0f, TRUE);
  37. glFlush();
  38. Sleep(1000);
  39. auxSwapBuffers();
  40. }
  41. void display(void)
  42. {
  43. glClear (GL_COLOR_BUFFER_BIT);
  44. Test ();
  45. glFlush ();
  46. }
  47. void myReshape(GLsizei w, GLsizei h)
  48. {
  49. glViewport(0, 0, w, h);
  50. glMatrixMode(GL_PROJECTION);
  51. glLoadIdentity();
  52. if (w <= h)
  53. gluOrtho2D (0.0, 100.0, 0.0, 100.0 * (GLfloat) h/(GLfloat) w);
  54. else
  55. gluOrtho2D (0.0, 100.0 * (GLfloat) w/(GLfloat) h, 0.0, 100.0);
  56. glMatrixMode(GL_MODELVIEW);
  57. }
  58. /* Main Loop
  59. * Open window with initial window size, title bar,
  60. * RGBA display mode, and handle input events.
  61. */
  62. int __cdecl main(int argc, char** argv)
  63. {
  64. auxInitDisplayMode (AUX_DOUBLE | AUX_RGB);
  65. auxInitPosition (15, 15, 500, 500);
  66. auxInitWindow ("GL_FRONT_AND_BACK Test");
  67. Initialize();
  68. auxReshapeFunc (myReshape);
  69. auxMainLoop(display);
  70. return 0;
  71. }