Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | RSS feed

  1. /*
  2.  * Copyright (C) 1999-2001  Brian Paul   All Rights Reserved.
  3.  *
  4.  * Permission is hereby granted, free of charge, to any person obtaining a
  5.  * copy of this software and associated documentation files (the "Software"),
  6.  * to deal in the Software without restriction, including without limitation
  7.  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  8.  * and/or sell copies of the Software, and to permit persons to whom the
  9.  * Software is furnished to do so, subject to the following conditions:
  10.  *
  11.  * The above copyright notice and this permission notice shall be included
  12.  * in all copies or substantial portions of the Software.
  13.  *
  14.  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  15.  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16.  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
  17.  * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
  18.  * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  19.  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  20.  */
  21.  
  22. /*
  23.  * This is a port of the infamous "glxgears" demo to straight EGL
  24.  * Port by Dane Rushton 10 July 2005
  25.  *
  26.  * No command line options.
  27.  * Program runs for 5 seconds then exits, outputing framerate to console
  28.  */
  29.  
  30. #include <math.h>
  31. #include <sys/time.h>
  32. #include <GL/gl.h>
  33. #include <GL/glu.h>
  34.  
  35. #ifndef GLAPIENTRY
  36. #define GLAPIENTRY
  37. #endif
  38.  
  39. #include <EGL/egl.h>
  40. #include <kos32sys.h>
  41. #include "eglut.h"
  42.  
  43. void init(void);
  44. void reshape(int width, int height);
  45. void draw(void);
  46. void keyboard(unsigned char key);
  47.  
  48. extern GLfloat angle;
  49.  
  50. void idle(void)
  51. {
  52.     static uint32_t t0;
  53.     uint32_t t, dt;
  54.  
  55.     t = get_tick_count();
  56.  
  57.     dt = t - t0;
  58.     t0 = t;
  59.  
  60.     angle += 70.0 * dt / 100;  /* 70 degrees per second */
  61.     if (angle > 3600.0)
  62.         angle -= 3600.0;
  63.  
  64.     eglutPostRedisplay();
  65. }
  66.  
  67. int main(int argc, char *argv[])
  68. {
  69.    eglutInitWindowSize(384, 384);
  70.    eglutInitAPIMask(EGLUT_OPENGL_BIT);
  71.    eglutInit(argc, argv);
  72.  
  73.    eglutCreateWindow("eglgears");
  74.  
  75.    eglutIdleFunc(idle);
  76.    eglutReshapeFunc(reshape);
  77.    eglutDisplayFunc(draw);
  78.    eglutKeyboardFunc(keyboard);
  79.  
  80.    glClearColor( 0, 0, 0, 1);
  81.  
  82.    init();
  83.    glDrawBuffer(GL_BACK);
  84.  
  85.    eglutMainLoop();
  86.  
  87.    return 0;
  88. }
  89.  
  90.