Subversion Repositories Kolibri OS

Rev

Rev 4464 | Blame | Compare with Previous | Last modification | View Log | RSS feed

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <math.h>
  5.  
  6. #include <GL/gl.h>
  7. #include <GL/glu.h>
  8.  
  9. #ifndef GLAPIENTRY
  10. #define GLAPIENTRY
  11. #endif
  12.  
  13. #include "EGL/egl.h"
  14.  
  15. #include "eglut.h"
  16.  
  17. GLint list;
  18.  
  19. static void init(void)
  20. {
  21. //   fprintf(stderr, "GL_RENDERER   = %s\n", (char *) glGetString(GL_RENDERER));
  22. //   fprintf(stderr, "GL_VERSION    = %s\n", (char *) glGetString(GL_VERSION));
  23. //   fprintf(stderr, "GL_VENDOR     = %s\n", (char *) glGetString(GL_VENDOR));
  24. //   fflush(stderr);
  25.  
  26.    list = glGenLists(1);
  27.    glNewList(list, GL_COMPILE);
  28.  
  29.    /* XXX: this state-change will only be executed if list is called
  30.     * from outside a begin/end pair:
  31.     */
  32.    glShadeModel( GL_FLAT );
  33.    glBegin(GL_TRIANGLES);
  34.    glColor3f(0,0,0.7);
  35.    glVertex3f( -0.9,  0.9, -30.0);
  36.    glColor3f(0,0.9,0);
  37.    glVertex3f( -0.9, -0.9, -30.0);
  38.    glColor3f(0.8,0,0);
  39.    glVertex3f(  0.9,  0.0, -30.0);
  40.    glEnd();
  41.  
  42.    glEndList();
  43. }
  44.  
  45. static void
  46. idle(void)
  47. {
  48.     eglutPostRedisplay();
  49. }
  50.  
  51. static void reshape(int width, int height)
  52. {
  53.  
  54. /*
  55.     glViewport(0, 0, (GLint)width, (GLint)height);
  56.  
  57.     glMatrixMode(GL_PROJECTION);
  58.     glLoadIdentity();
  59.     glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 100.0);
  60.     glMatrixMode(GL_MODELVIEW);
  61.     glLoadIdentity();
  62. */
  63.  
  64.     GLfloat h = (GLfloat) height / (GLfloat) width;
  65.  
  66.     glViewport(0, 0, (GLint) width, (GLint) height);
  67.  
  68.     glMatrixMode(GL_PROJECTION);
  69.     glLoadIdentity();
  70.     glFrustum(-1.0, 1.0, -h, h, 5.0, 60.0);
  71.  
  72.     glMatrixMode(GL_MODELVIEW);
  73.     glLoadIdentity();
  74. }
  75.  
  76. static void draw(void)
  77. {
  78.    asm volatile ("int3");
  79.  
  80.    glClear(GL_COLOR_BUFFER_BIT);
  81.  
  82.    glShadeModel( GL_SMOOTH );
  83.  
  84.    glBegin(GL_TRIANGLES);
  85.  
  86.    /* Note: call the list from inside a begin/end pair.  The end is
  87.     * provided by the display list...
  88.     */
  89.    glCallList(list);
  90.  
  91.  //  glFlush();
  92.  
  93. }
  94.  
  95. int
  96. main(int argc, char *argv[])
  97. {
  98.    eglutInitWindowSize(384, 384);
  99.    eglutInitAPIMask(EGLUT_OPENGL_BIT);
  100.    eglutInit(argc, argv);
  101.  
  102.    eglutCreateWindow("gl-render");
  103.  
  104.    eglutIdleFunc(idle);
  105.    eglutReshapeFunc(reshape);
  106.    eglutDisplayFunc(draw);
  107.  
  108.    glClearColor( 0, 0, 0, 1);
  109.  
  110.  //  init();
  111.    glDrawBuffer(GL_BACK);
  112.  
  113.    eglutMainLoop();
  114.  
  115.    return 0;
  116. }
  117.  
  118.