<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://maemo.octonezd.me/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=87.245.83.90</id>
	<title>Maemo Wiki Mirror - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://maemo.octonezd.me/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=87.245.83.90"/>
	<link rel="alternate" type="text/html" href="https://maemo.octonezd.me/index.php/Special:Contributions/87.245.83.90"/>
	<updated>2026-04-22T08:28:52Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.45.1</generator>
	<entry>
		<id>https://maemo.octonezd.me/index.php?title=SimpleGL_example&amp;diff=37629</id>
		<title>SimpleGL example</title>
		<link rel="alternate" type="text/html" href="https://maemo.octonezd.me/index.php?title=SimpleGL_example&amp;diff=37629"/>
		<updated>2010-11-10T21:39:10Z</updated>

		<summary type="html">&lt;p&gt;87.245.83.90: Source: http://talk.maemo.org/showthread.php?p=750107&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is a simple program demonstrating how to use [[OpenGL-ES#OpenGL_variants|OpenGL ES 2.0]]. It will output this animated spiral, which can be moved around on the screen:&lt;br /&gt;
&lt;br /&gt;
[[Image:Egl-example_output.png]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
/* Created by exoticorn ( http://talk.maemo.org/showthread.php?t=37356 )&lt;br /&gt;
 * edited and commented by André Bergner [endboss]&lt;br /&gt;
 *&lt;br /&gt;
 * libraries needed:   libx11-dev, libgles2-dev&lt;br /&gt;
 *&lt;br /&gt;
 * compile with:   g++  -lX11 -lEGL -lGLESv2  egl-example.cpp&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
#include  &amp;lt;iostream&amp;gt;&lt;br /&gt;
using namespace std;&lt;br /&gt;
&lt;br /&gt;
#include  &amp;lt;cmath&amp;gt;&lt;br /&gt;
#include  &amp;lt;sys/time.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#include  &amp;lt;X11/Xlib.h&amp;gt;&lt;br /&gt;
#include  &amp;lt;X11/Xatom.h&amp;gt;&lt;br /&gt;
#include  &amp;lt;X11/Xutil.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#include  &amp;lt;GLES2/gl2.h&amp;gt;&lt;br /&gt;
#include  &amp;lt;EGL/egl.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
const char vertex_src [] =&lt;br /&gt;
&amp;quot;                                        \&lt;br /&gt;
   attribute vec4        position;       \&lt;br /&gt;
   varying mediump vec2  pos;            \&lt;br /&gt;
   uniform vec4          offset;         \&lt;br /&gt;
                                         \&lt;br /&gt;
   void main()                           \&lt;br /&gt;
   {                                     \&lt;br /&gt;
      gl_Position = position + offset;   \&lt;br /&gt;
      pos = position.xy;                 \&lt;br /&gt;
   }                                     \&lt;br /&gt;
&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
const char fragment_src [] =&lt;br /&gt;
&amp;quot;                                                      \&lt;br /&gt;
   varying mediump vec2    pos;                        \&lt;br /&gt;
   uniform mediump float   phase;                      \&lt;br /&gt;
                                                       \&lt;br /&gt;
   void  main()                                        \&lt;br /&gt;
   {                                                   \&lt;br /&gt;
      gl_FragColor  =  vec4( 1., 0.9, 0.7, 1.0 ) *     \&lt;br /&gt;
        cos( 30.*sqrt(pos.x*pos.x + 1.5*pos.y*pos.y)   \&lt;br /&gt;
             + atan(pos.y,pos.x) - phase );            \&lt;br /&gt;
   }                                                   \&lt;br /&gt;
&amp;quot;;&lt;br /&gt;
//  some more formulas to play with...&lt;br /&gt;
//      cos( 20.*(pos.x*pos.x + pos.y*pos.y) - phase );&lt;br /&gt;
//      cos( 20.*sqrt(pos.x*pos.x + pos.y*pos.y) + atan(pos.y,pos.x) - phase );&lt;br /&gt;
//      cos( 30.*sqrt(pos.x*pos.x + 1.5*pos.y*pos.y - 1.8*pos.x*pos.y*pos.y)&lt;br /&gt;
//            + atan(pos.y,pos.x) - phase );&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
void&lt;br /&gt;
print_shader_info_log (&lt;br /&gt;
   GLuint  shader      // handle to the shader&lt;br /&gt;
)&lt;br /&gt;
{&lt;br /&gt;
   GLint  length;&lt;br /&gt;
&lt;br /&gt;
   glGetShaderiv ( shader , GL_INFO_LOG_LENGTH , &amp;amp;length );&lt;br /&gt;
&lt;br /&gt;
   if ( length ) {&lt;br /&gt;
      char* buffer  =  new char [ length ];&lt;br /&gt;
      glGetShaderInfoLog ( shader , length , NULL , buffer );&lt;br /&gt;
      cout &amp;lt;&amp;lt; &amp;quot;shader info: &amp;quot; &amp;lt;&amp;lt;  buffer &amp;lt;&amp;lt; flush;&lt;br /&gt;
      delete [] buffer;&lt;br /&gt;
&lt;br /&gt;
      GLint success;&lt;br /&gt;
      glGetShaderiv( shader, GL_COMPILE_STATUS, &amp;amp;success );&lt;br /&gt;
      if ( success != GL_TRUE )   exit ( 1 );&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
GLuint&lt;br /&gt;
load_shader (&lt;br /&gt;
   const char  *shader_source,&lt;br /&gt;
   GLenum       type&lt;br /&gt;
)&lt;br /&gt;
{&lt;br /&gt;
   GLuint  shader = glCreateShader( type );&lt;br /&gt;
&lt;br /&gt;
   glShaderSource  ( shader , 1 , &amp;amp;shader_source , NULL );&lt;br /&gt;
   glCompileShader ( shader );&lt;br /&gt;
&lt;br /&gt;
   print_shader_info_log ( shader );&lt;br /&gt;
&lt;br /&gt;
   return shader;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Display    *x_display;&lt;br /&gt;
Window      win;&lt;br /&gt;
EGLDisplay  egl_display;&lt;br /&gt;
EGLContext  egl_context;&lt;br /&gt;
&lt;br /&gt;
GLfloat&lt;br /&gt;
   norm_x    =  0.0,&lt;br /&gt;
   norm_y    =  0.0,&lt;br /&gt;
   offset_x  =  0.0,&lt;br /&gt;
   offset_y  =  0.0,&lt;br /&gt;
   p1_pos_x  =  0.0,&lt;br /&gt;
   p1_pos_y  =  0.0;&lt;br /&gt;
&lt;br /&gt;
GLint&lt;br /&gt;
   phase_loc,&lt;br /&gt;
   offset_loc,&lt;br /&gt;
   position_loc;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
EGLSurface  egl_surface;&lt;br /&gt;
bool        update_pos = false;&lt;br /&gt;
&lt;br /&gt;
const float vertexArray[] = {&lt;br /&gt;
   0.0,  0.5,  0.0,&lt;br /&gt;
  -0.5,  0.0,  0.0,&lt;br /&gt;
   0.0, -0.5,  0.0,&lt;br /&gt;
   0.5,  0.0,  0.0,&lt;br /&gt;
   0.0,  0.5,  0.0 &lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
void  render()&lt;br /&gt;
{&lt;br /&gt;
   static float  phase = 0;&lt;br /&gt;
   static int    donesetup = 0;&lt;br /&gt;
&lt;br /&gt;
   static XWindowAttributes gwa;&lt;br /&gt;
&lt;br /&gt;
   //// draw&lt;br /&gt;
&lt;br /&gt;
   if ( !donesetup ) {&lt;br /&gt;
      XWindowAttributes  gwa;&lt;br /&gt;
      XGetWindowAttributes ( x_display , win , &amp;amp;gwa );&lt;br /&gt;
      glViewport ( 0 , 0 , gwa.width , gwa.height );&lt;br /&gt;
      glClearColor ( 0.08 , 0.06 , 0.07 , 1.);    // background color&lt;br /&gt;
      donesetup = 1;&lt;br /&gt;
   }&lt;br /&gt;
   glClear ( GL_COLOR_BUFFER_BIT );&lt;br /&gt;
&lt;br /&gt;
   glUniform1f ( phase_loc , phase );  // write the value of phase to the shaders phase&lt;br /&gt;
   phase  =  fmodf ( phase + 0.5f , 2.f * 3.141f );    // and update the local variable&lt;br /&gt;
&lt;br /&gt;
   if ( update_pos ) {  // if the position of the texture has changed due to user action&lt;br /&gt;
      GLfloat old_offset_x  =  offset_x;&lt;br /&gt;
      GLfloat old_offset_y  =  offset_y;&lt;br /&gt;
&lt;br /&gt;
      offset_x  =  norm_x - p1_pos_x;&lt;br /&gt;
      offset_y  =  norm_y - p1_pos_y;&lt;br /&gt;
&lt;br /&gt;
      p1_pos_x  =  norm_x;&lt;br /&gt;
      p1_pos_y  =  norm_y;&lt;br /&gt;
&lt;br /&gt;
      offset_x  +=  old_offset_x;&lt;br /&gt;
      offset_y  +=  old_offset_y;&lt;br /&gt;
&lt;br /&gt;
      update_pos = false;&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   glUniform4f ( offset_loc  ,  offset_x , offset_y , 0.0 , 0.0 );&lt;br /&gt;
&lt;br /&gt;
   glVertexAttribPointer ( position_loc, 3, GL_FLOAT, false, 0, vertexArray );&lt;br /&gt;
   glEnableVertexAttribArray ( position_loc );&lt;br /&gt;
   glDrawArrays ( GL_TRIANGLE_STRIP, 0, 5 );&lt;br /&gt;
&lt;br /&gt;
   eglSwapBuffers ( egl_display, egl_surface );  // get the rendered buffer to the screen&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
////////////////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
int  main()&lt;br /&gt;
{&lt;br /&gt;
   ///////  the X11 part  //////////////////////////////////////////////////////////////////&lt;br /&gt;
   // in the first part the program opens a connection to the X11 window manager&lt;br /&gt;
   //&lt;br /&gt;
&lt;br /&gt;
   x_display = XOpenDisplay ( NULL );   // open the standard display (the primary screen)&lt;br /&gt;
   if ( x_display == NULL ) {&lt;br /&gt;
      cerr &amp;lt;&amp;lt; &amp;quot;cannot connect to X server&amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;
      return 1;&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   Window root  =  DefaultRootWindow( x_display );   // get the root window (usually the whole screen)&lt;br /&gt;
&lt;br /&gt;
   XSetWindowAttributes  swa;&lt;br /&gt;
   swa.event_mask  =  ExposureMask | PointerMotionMask | KeyPressMask;&lt;br /&gt;
&lt;br /&gt;
   win  =  XCreateWindow (   // create a window with the provided parameters&lt;br /&gt;
              x_display, root,&lt;br /&gt;
              0, 0, 800, 480,   0,&lt;br /&gt;
              CopyFromParent, InputOutput,&lt;br /&gt;
              CopyFromParent, CWEventMask,&lt;br /&gt;
              &amp;amp;swa );&lt;br /&gt;
&lt;br /&gt;
   XSetWindowAttributes  xattr;&lt;br /&gt;
   Atom  atom;&lt;br /&gt;
   int   one = 1;&lt;br /&gt;
&lt;br /&gt;
   xattr.override_redirect = False;&lt;br /&gt;
   XChangeWindowAttributes ( x_display, win, CWOverrideRedirect, &amp;amp;xattr );&lt;br /&gt;
&lt;br /&gt;
   atom = XInternAtom ( x_display, &amp;quot;_NET_WM_STATE_FULLSCREEN&amp;quot;, True );&lt;br /&gt;
   XChangeProperty (&lt;br /&gt;
      x_display, win,&lt;br /&gt;
      XInternAtom ( x_display, &amp;quot;_NET_WM_STATE&amp;quot;, True ),&lt;br /&gt;
      XA_ATOM,  32,  PropModeReplace,&lt;br /&gt;
      (unsigned char*) &amp;amp;atom,  1 );&lt;br /&gt;
&lt;br /&gt;
   XChangeProperty (&lt;br /&gt;
      x_display, win,&lt;br /&gt;
      XInternAtom ( x_display, &amp;quot;_HILDON_NON_COMPOSITED_WINDOW&amp;quot;, True ),&lt;br /&gt;
      XA_INTEGER,  32,  PropModeReplace,&lt;br /&gt;
      (unsigned char*) &amp;amp;one,  1);&lt;br /&gt;
&lt;br /&gt;
   XWMHints hints;&lt;br /&gt;
   hints.input = True;&lt;br /&gt;
   hints.flags = InputHint;&lt;br /&gt;
   XSetWMHints(x_display, win, &amp;amp;hints);&lt;br /&gt;
&lt;br /&gt;
   XMapWindow ( x_display , win );             // make the window visible on the screen&lt;br /&gt;
   XStoreName ( x_display , win , &amp;quot;GL test&amp;quot; ); // give the window a name&lt;br /&gt;
&lt;br /&gt;
   //// get identifiers for the provided atom name strings&lt;br /&gt;
   Atom wm_state   = XInternAtom ( x_display, &amp;quot;_NET_WM_STATE&amp;quot;, False );&lt;br /&gt;
   Atom fullscreen = XInternAtom ( x_display, &amp;quot;_NET_WM_STATE_FULLSCREEN&amp;quot;, False );&lt;br /&gt;
&lt;br /&gt;
   XEvent xev;&lt;br /&gt;
   memset ( &amp;amp;xev, 0, sizeof(xev) );&lt;br /&gt;
&lt;br /&gt;
   xev.type                 = ClientMessage;&lt;br /&gt;
   xev.xclient.window       = win;&lt;br /&gt;
   xev.xclient.message_type = wm_state;&lt;br /&gt;
   xev.xclient.format       = 32;&lt;br /&gt;
   xev.xclient.data.l[0]    = 1;&lt;br /&gt;
   xev.xclient.data.l[1]    = fullscreen;&lt;br /&gt;
   XSendEvent (                // send an event mask to the X-server&lt;br /&gt;
      x_display,&lt;br /&gt;
      DefaultRootWindow ( x_display ),&lt;br /&gt;
      False,&lt;br /&gt;
      SubstructureNotifyMask,&lt;br /&gt;
      &amp;amp;xev );&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   ///////  the egl part  //////////////////////////////////////////////////////////////////&lt;br /&gt;
   //  egl provides an interface to connect the graphics related functionality of openGL ES&lt;br /&gt;
   //  with the windowing interface and functionality of the native operation system (X11&lt;br /&gt;
   //  in our case.&lt;br /&gt;
&lt;br /&gt;
   egl_display  =  eglGetDisplay( (EGLNativeDisplayType) x_display );&lt;br /&gt;
   if ( egl_display == EGL_NO_DISPLAY ) {&lt;br /&gt;
      cerr &amp;lt;&amp;lt; &amp;quot;Got no EGL display.&amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;
      return 1;&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   if ( !eglInitialize( egl_display, NULL, NULL ) ) {&lt;br /&gt;
      cerr &amp;lt;&amp;lt; &amp;quot;Unable to initialize EGL&amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;
      return 1;&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   EGLint attr[] = {       // some attributes to set up our egl-interface&lt;br /&gt;
      EGL_BUFFER_SIZE, 16,&lt;br /&gt;
      EGL_RENDERABLE_TYPE,&lt;br /&gt;
      EGL_OPENGL_ES2_BIT,&lt;br /&gt;
      EGL_NONE&lt;br /&gt;
   };&lt;br /&gt;
&lt;br /&gt;
   EGLConfig  ecfg;&lt;br /&gt;
   EGLint     num_config;&lt;br /&gt;
   if ( !eglChooseConfig( egl_display, attr, &amp;amp;ecfg, 1, &amp;amp;num_config ) ) {&lt;br /&gt;
      cerr &amp;lt;&amp;lt; &amp;quot;Failed to choose config (eglError: &amp;quot; &amp;lt;&amp;lt; eglGetError() &amp;lt;&amp;lt; &amp;quot;)&amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;
      return 1;&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   if ( num_config != 1 ) {&lt;br /&gt;
      cerr &amp;lt;&amp;lt; &amp;quot;Didn&#039;t get exactly one config, but &amp;quot; &amp;lt;&amp;lt; num_config &amp;lt;&amp;lt; endl;&lt;br /&gt;
      return 1;&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   egl_surface = eglCreateWindowSurface ( egl_display, ecfg, win, NULL );&lt;br /&gt;
   if ( egl_surface == EGL_NO_SURFACE ) {&lt;br /&gt;
      cerr &amp;lt;&amp;lt; &amp;quot;Unable to create EGL surface (eglError: &amp;quot; &amp;lt;&amp;lt; eglGetError() &amp;lt;&amp;lt; &amp;quot;)&amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;
      return 1;&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   //// egl-contexts collect all state descriptions needed required for operation&lt;br /&gt;
   EGLint ctxattr[] = {&lt;br /&gt;
      EGL_CONTEXT_CLIENT_VERSION, 2,&lt;br /&gt;
      EGL_NONE&lt;br /&gt;
   };&lt;br /&gt;
   egl_context = eglCreateContext ( egl_display, ecfg, EGL_NO_CONTEXT, ctxattr );&lt;br /&gt;
   if ( egl_context == EGL_NO_CONTEXT ) {&lt;br /&gt;
      cerr &amp;lt;&amp;lt; &amp;quot;Unable to create EGL context (eglError: &amp;quot; &amp;lt;&amp;lt; eglGetError() &amp;lt;&amp;lt; &amp;quot;)&amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;
      return 1;&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   //// associate the egl-context with the egl-surface&lt;br /&gt;
   eglMakeCurrent( egl_display, egl_surface, egl_surface, egl_context );&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   ///////  the openGL part  ///////////////////////////////////////////////////////////////&lt;br /&gt;
&lt;br /&gt;
   GLuint vertexShader   = load_shader ( vertex_src , GL_VERTEX_SHADER  );     // load vertex shader&lt;br /&gt;
   GLuint fragmentShader = load_shader ( fragment_src , GL_FRAGMENT_SHADER );  // load fragment shader&lt;br /&gt;
&lt;br /&gt;
   GLuint shaderProgram  = glCreateProgram ();                 // create program object&lt;br /&gt;
   glAttachShader ( shaderProgram, vertexShader );             // and attach both...&lt;br /&gt;
   glAttachShader ( shaderProgram, fragmentShader );           // ... shaders to it&lt;br /&gt;
&lt;br /&gt;
   glLinkProgram ( shaderProgram );    // link the program&lt;br /&gt;
   glUseProgram  ( shaderProgram );    // and select it for usage&lt;br /&gt;
&lt;br /&gt;
   //// now get the locations (kind of handle) of the shaders variables&lt;br /&gt;
   position_loc  = glGetAttribLocation  ( shaderProgram , &amp;quot;position&amp;quot; );&lt;br /&gt;
   phase_loc     = glGetUniformLocation ( shaderProgram , &amp;quot;phase&amp;quot;    );&lt;br /&gt;
   offset_loc    = glGetUniformLocation ( shaderProgram , &amp;quot;offset&amp;quot;   );&lt;br /&gt;
   if ( position_loc &amp;lt; 0  ||  phase_loc &amp;lt; 0  ||  offset_loc &amp;lt; 0 ) {&lt;br /&gt;
      cerr &amp;lt;&amp;lt; &amp;quot;Unable to get uniform location&amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;
      return 1;&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   const float&lt;br /&gt;
      window_width  = 800.0,&lt;br /&gt;
      window_height = 480.0;&lt;br /&gt;
&lt;br /&gt;
   //// this is needed for time measuring  --&amp;gt;  frames per second&lt;br /&gt;
   struct  timezone  tz;&lt;br /&gt;
   timeval  t1, t2;&lt;br /&gt;
   gettimeofday ( &amp;amp;t1 , &amp;amp;tz );&lt;br /&gt;
   int  num_frames = 0;&lt;br /&gt;
&lt;br /&gt;
   bool quit = false;&lt;br /&gt;
   while ( !quit ) {    // the main loop&lt;br /&gt;
&lt;br /&gt;
      while ( XPending ( x_display ) ) {   // check for events from the x-server&lt;br /&gt;
&lt;br /&gt;
         XEvent  xev;&lt;br /&gt;
         XNextEvent( x_display, &amp;amp;xev );&lt;br /&gt;
&lt;br /&gt;
         if ( xev.type == MotionNotify ) {  // if mouse has moved&lt;br /&gt;
//            cout &amp;lt;&amp;lt; &amp;quot;move to: &amp;lt;&amp;lt; xev.xmotion.x &amp;lt;&amp;lt; &amp;quot;,&amp;quot; &amp;lt;&amp;lt; xev.xmotion.y &amp;lt;&amp;lt; endl;&lt;br /&gt;
            GLfloat window_y  =  (window_height - xev.xmotion.y) - window_height / 2.0;&lt;br /&gt;
            norm_y            =  window_y / (window_height / 2.0);&lt;br /&gt;
            GLfloat window_x  =  xev.xmotion.x - window_width / 2.0;&lt;br /&gt;
            norm_x            =  window_x / (window_width / 2.0);&lt;br /&gt;
            update_pos = true;&lt;br /&gt;
         }&lt;br /&gt;
&lt;br /&gt;
         if ( xev.type == KeyPress )   quit = true;&lt;br /&gt;
      }&lt;br /&gt;
&lt;br /&gt;
      render();   // now we finally put something on the screen&lt;br /&gt;
&lt;br /&gt;
      if ( ++num_frames % 100 == 0 ) {&lt;br /&gt;
         gettimeofday( &amp;amp;t2, &amp;amp;tz );&lt;br /&gt;
         float dt  =  t2.tv_sec - t1.tv_sec + (t2.tv_usec - t1.tv_usec) * 1e-6;&lt;br /&gt;
         cout &amp;lt;&amp;lt; &amp;quot;fps: &amp;quot; &amp;lt;&amp;lt; num_frames / dt &amp;lt;&amp;lt; endl;&lt;br /&gt;
         num_frames = 0;&lt;br /&gt;
         t1 = t2;&lt;br /&gt;
      }&lt;br /&gt;
//      usleep( 1000*10 );&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   ////  cleaning up...&lt;br /&gt;
   eglDestroyContext ( egl_display, egl_context );&lt;br /&gt;
   eglDestroySurface ( egl_display, egl_surface );&lt;br /&gt;
   eglTerminate      ( egl_display );&lt;br /&gt;
   XDestroyWindow    ( x_display, win );&lt;br /&gt;
   XCloseDisplay     ( x_display );&lt;br /&gt;
&lt;br /&gt;
   return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
[[Category:Development]]&lt;br /&gt;
[[Category:Fremantle]]&lt;/div&gt;</summary>
		<author><name>87.245.83.90</name></author>
	</entry>
	<entry>
		<id>https://maemo.octonezd.me/index.php?title=SimpleGL_example&amp;diff=37630</id>
		<title>SimpleGL example</title>
		<link rel="alternate" type="text/html" href="https://maemo.octonezd.me/index.php?title=SimpleGL_example&amp;diff=37630"/>
		<updated>2010-10-29T20:37:32Z</updated>

		<summary type="html">&lt;p&gt;87.245.83.90: not needed&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is a simple program demonstrating how to use [[OpenGL-ES#OpenGL_variants|OpenGL ES 2.0]]. It will output this animated spiral, which can be moved around on the screen:&lt;br /&gt;
&lt;br /&gt;
[[Image:Egl-example_output.png]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
/* Created by exoticorn ( http://talk.maemo.org/showthread.php?t=37356 )&lt;br /&gt;
 * edited and commented by André Bergner [endboss]&lt;br /&gt;
 *&lt;br /&gt;
 * libraries needed:   libx11-dev, libgles2-dev&lt;br /&gt;
 *&lt;br /&gt;
 * compile with:   g++  -lX11 -lEGL -lGLESv2  egl-example.cpp&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
#include  &amp;lt;iostream&amp;gt;&lt;br /&gt;
using namespace std;&lt;br /&gt;
&lt;br /&gt;
#include  &amp;lt;cmath&amp;gt;&lt;br /&gt;
#include  &amp;lt;sys/time.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#include  &amp;lt;X11/Xlib.h&amp;gt;&lt;br /&gt;
#include  &amp;lt;X11/Xatom.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#include  &amp;lt;GLES2/gl2.h&amp;gt;&lt;br /&gt;
#include  &amp;lt;EGL/egl.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
const char vertex_src [] =&lt;br /&gt;
&amp;quot;                                        \&lt;br /&gt;
   attribute vec4        position;       \&lt;br /&gt;
   varying mediump vec2  pos;            \&lt;br /&gt;
   uniform vec4          offset;         \&lt;br /&gt;
                                         \&lt;br /&gt;
   void main()                           \&lt;br /&gt;
   {                                     \&lt;br /&gt;
      gl_Position = position + offset;   \&lt;br /&gt;
      pos = position.xy;                 \&lt;br /&gt;
   }                                     \&lt;br /&gt;
&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
const char fragment_src [] =&lt;br /&gt;
&amp;quot;                                                      \&lt;br /&gt;
   varying mediump vec2    pos;                        \&lt;br /&gt;
   uniform mediump float   phase;                      \&lt;br /&gt;
                                                       \&lt;br /&gt;
   void  main()                                        \&lt;br /&gt;
   {                                                   \&lt;br /&gt;
      gl_FragColor  =  vec4( 1., 0.9, 0.7, 1.0 ) *     \&lt;br /&gt;
        cos( 30.*sqrt(pos.x*pos.x + 1.5*pos.y*pos.y)   \&lt;br /&gt;
             + atan(pos.y,pos.x) - phase );            \&lt;br /&gt;
   }                                                   \&lt;br /&gt;
&amp;quot;;&lt;br /&gt;
//  some more formulas to play with...&lt;br /&gt;
//      cos( 20.*(pos.x*pos.x + pos.y*pos.y) - phase );&lt;br /&gt;
//      cos( 20.*sqrt(pos.x*pos.x + pos.y*pos.y) + atan(pos.y,pos.x) - phase );&lt;br /&gt;
//      cos( 30.*sqrt(pos.x*pos.x + 1.5*pos.y*pos.y - 1.8*pos.x*pos.y*pos.y)&lt;br /&gt;
//            + atan(pos.y,pos.x) - phase );&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
void&lt;br /&gt;
print_shader_info_log (&lt;br /&gt;
   GLuint  shader      // handle to the shader&lt;br /&gt;
)&lt;br /&gt;
{&lt;br /&gt;
   GLint  length;&lt;br /&gt;
&lt;br /&gt;
   glGetShaderiv ( shader , GL_INFO_LOG_LENGTH , &amp;amp;length );&lt;br /&gt;
&lt;br /&gt;
   if ( length ) {&lt;br /&gt;
      char* buffer  =  new char [ length ];&lt;br /&gt;
      glGetShaderInfoLog ( shader , length , NULL , buffer );&lt;br /&gt;
      cout &amp;lt;&amp;lt; &amp;quot;shader info: &amp;quot; &amp;lt;&amp;lt;  buffer &amp;lt;&amp;lt; flush;&lt;br /&gt;
      delete [] buffer;&lt;br /&gt;
&lt;br /&gt;
      GLint success;&lt;br /&gt;
      glGetShaderiv( shader, GL_COMPILE_STATUS, &amp;amp;success );&lt;br /&gt;
      if ( success != GL_TRUE )   exit ( 1 );&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
GLuint&lt;br /&gt;
load_shader (&lt;br /&gt;
   const char  *shader_source,&lt;br /&gt;
   GLenum       type&lt;br /&gt;
)&lt;br /&gt;
{&lt;br /&gt;
   GLuint  shader = glCreateShader( type );&lt;br /&gt;
&lt;br /&gt;
   glShaderSource  ( shader , 1 , &amp;amp;shader_source , NULL );&lt;br /&gt;
   glCompileShader ( shader );&lt;br /&gt;
&lt;br /&gt;
   print_shader_info_log ( shader );&lt;br /&gt;
&lt;br /&gt;
   return shader;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Display    *x_display;&lt;br /&gt;
Window      win;&lt;br /&gt;
EGLDisplay  egl_display;&lt;br /&gt;
EGLContext  egl_context;&lt;br /&gt;
&lt;br /&gt;
GLfloat&lt;br /&gt;
   norm_x    =  0.0,&lt;br /&gt;
   norm_y    =  0.0,&lt;br /&gt;
   offset_x  =  0.0,&lt;br /&gt;
   offset_y  =  0.0,&lt;br /&gt;
   p1_pos_x  =  0.0,&lt;br /&gt;
   p1_pos_y  =  0.0;&lt;br /&gt;
&lt;br /&gt;
GLint&lt;br /&gt;
   phase_loc,&lt;br /&gt;
   offset_loc,&lt;br /&gt;
   position_loc;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
EGLSurface  egl_surface;&lt;br /&gt;
bool        update_pos = false;&lt;br /&gt;
&lt;br /&gt;
const float vertexArray[] = {&lt;br /&gt;
   0.0,  0.5,  0.0,&lt;br /&gt;
  -0.5,  0.0,  0.0,&lt;br /&gt;
   0.0, -0.5,  0.0,&lt;br /&gt;
   0.5,  0.0,  0.0,&lt;br /&gt;
   0.0,  0.5,  0.0 &lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
void  render()&lt;br /&gt;
{&lt;br /&gt;
   static float  phase = 0;&lt;br /&gt;
   static int    donesetup = 0;&lt;br /&gt;
&lt;br /&gt;
   static XWindowAttributes gwa;&lt;br /&gt;
&lt;br /&gt;
   //// draw&lt;br /&gt;
&lt;br /&gt;
   if ( !donesetup ) {&lt;br /&gt;
      XWindowAttributes  gwa;&lt;br /&gt;
      XGetWindowAttributes ( x_display , win , &amp;amp;gwa );&lt;br /&gt;
      glViewport ( 0 , 0 , gwa.width , gwa.height );&lt;br /&gt;
      glClearColor ( 0.08 , 0.06 , 0.07 , 1.);    // background color&lt;br /&gt;
      donesetup = 1;&lt;br /&gt;
   }&lt;br /&gt;
   glClear ( GL_COLOR_BUFFER_BIT );&lt;br /&gt;
&lt;br /&gt;
   glUniform1f ( phase_loc , phase );  // write the value of phase to the shaders phase&lt;br /&gt;
   phase  =  fmodf ( phase + 0.5f , 2.f * 3.141f );    // and update the local variable&lt;br /&gt;
&lt;br /&gt;
   if ( update_pos ) {  // if the position of the texture has changed due to user action&lt;br /&gt;
      GLfloat old_offset_x  =  offset_x;&lt;br /&gt;
      GLfloat old_offset_y  =  offset_y;&lt;br /&gt;
&lt;br /&gt;
      offset_x  =  norm_x - p1_pos_x;&lt;br /&gt;
      offset_y  =  norm_y - p1_pos_y;&lt;br /&gt;
&lt;br /&gt;
      p1_pos_x  =  norm_x;&lt;br /&gt;
      p1_pos_y  =  norm_y;&lt;br /&gt;
&lt;br /&gt;
      offset_x  +=  old_offset_x;&lt;br /&gt;
      offset_y  +=  old_offset_y;&lt;br /&gt;
&lt;br /&gt;
      update_pos = false;&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   glUniform4f ( offset_loc  ,  offset_x , offset_y , 0.0 , 0.0 );&lt;br /&gt;
&lt;br /&gt;
   glVertexAttribPointer ( position_loc, 3, GL_FLOAT, false, 0, vertexArray );&lt;br /&gt;
   glEnableVertexAttribArray ( position_loc );&lt;br /&gt;
   glDrawArrays ( GL_TRIANGLE_STRIP, 0, 5 );&lt;br /&gt;
&lt;br /&gt;
   eglSwapBuffers ( egl_display, egl_surface );  // get the rendered buffer to the screen&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
////////////////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
int  main()&lt;br /&gt;
{&lt;br /&gt;
   ///////  the X11 part  //////////////////////////////////////////////////////////////////&lt;br /&gt;
   // in the first part the program opens a connection to the X11 window manager&lt;br /&gt;
   //&lt;br /&gt;
&lt;br /&gt;
   x_display = XOpenDisplay ( NULL );   // open the standard display (the primary screen)&lt;br /&gt;
   if ( x_display == NULL ) {&lt;br /&gt;
      cerr &amp;lt;&amp;lt; &amp;quot;cannot connect to X server&amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;
      return 1;&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   Window root  =  DefaultRootWindow( x_display );   // get the root window (usually the whole screen)&lt;br /&gt;
&lt;br /&gt;
   XSetWindowAttributes  swa;&lt;br /&gt;
   swa.event_mask  =  ExposureMask | PointerMotionMask | KeyPressMask;&lt;br /&gt;
&lt;br /&gt;
   win  =  XCreateWindow (   // create a window with the provided parameters&lt;br /&gt;
              x_display, root,&lt;br /&gt;
              0, 0, 800, 480,   0,&lt;br /&gt;
              CopyFromParent, InputOutput,&lt;br /&gt;
              CopyFromParent, CWEventMask,&lt;br /&gt;
              &amp;amp;swa );&lt;br /&gt;
&lt;br /&gt;
   XSetWindowAttributes  xattr;&lt;br /&gt;
   Atom  atom;&lt;br /&gt;
   int   one = 1;&lt;br /&gt;
&lt;br /&gt;
   xattr.override_redirect = False;&lt;br /&gt;
   XChangeWindowAttributes ( x_display, win, CWOverrideRedirect, &amp;amp;xattr );&lt;br /&gt;
&lt;br /&gt;
   atom = XInternAtom ( x_display, &amp;quot;_NET_WM_STATE_FULLSCREEN&amp;quot;, True );&lt;br /&gt;
   XChangeProperty (&lt;br /&gt;
      x_display, win,&lt;br /&gt;
      XInternAtom ( x_display, &amp;quot;_NET_WM_STATE&amp;quot;, True ),&lt;br /&gt;
      XA_ATOM,  32,  PropModeReplace,&lt;br /&gt;
      (unsigned char*) &amp;amp;atom,  1 );&lt;br /&gt;
&lt;br /&gt;
   XChangeProperty (&lt;br /&gt;
      x_display, win,&lt;br /&gt;
      XInternAtom ( x_display, &amp;quot;_HILDON_NON_COMPOSITED_WINDOW&amp;quot;, True ),&lt;br /&gt;
      XA_INTEGER,  32,  PropModeReplace,&lt;br /&gt;
      (unsigned char*) &amp;amp;one,  1);&lt;br /&gt;
&lt;br /&gt;
   XMapWindow ( x_display , win );             // make the window visible on the screen&lt;br /&gt;
   XStoreName ( x_display , win , &amp;quot;GL test&amp;quot; ); // give the window a name&lt;br /&gt;
&lt;br /&gt;
   //// get identifiers for the provided atom name strings&lt;br /&gt;
   Atom wm_state   = XInternAtom ( x_display, &amp;quot;_NET_WM_STATE&amp;quot;, False );&lt;br /&gt;
   Atom fullscreen = XInternAtom ( x_display, &amp;quot;_NET_WM_STATE_FULLSCREEN&amp;quot;, False );&lt;br /&gt;
&lt;br /&gt;
   XEvent xev;&lt;br /&gt;
   memset ( &amp;amp;xev, 0, sizeof(xev) );&lt;br /&gt;
&lt;br /&gt;
   xev.type                 = ClientMessage;&lt;br /&gt;
   xev.xclient.window       = win;&lt;br /&gt;
   xev.xclient.message_type = wm_state;&lt;br /&gt;
   xev.xclient.format       = 32;&lt;br /&gt;
   xev.xclient.data.l[0]    = 1;&lt;br /&gt;
   xev.xclient.data.l[1]    = fullscreen;&lt;br /&gt;
   XSendEvent (                // send an event mask to the X-server&lt;br /&gt;
      x_display,&lt;br /&gt;
      DefaultRootWindow ( x_display ),&lt;br /&gt;
      False,&lt;br /&gt;
      SubstructureNotifyMask,&lt;br /&gt;
      &amp;amp;xev );&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   ///////  the egl part  //////////////////////////////////////////////////////////////////&lt;br /&gt;
   //  egl provides an interface to connect the graphics related functionality of openGL ES&lt;br /&gt;
   //  with the windowing interface and functionality of the native operation system (X11&lt;br /&gt;
   //  in our case.&lt;br /&gt;
&lt;br /&gt;
   egl_display  =  eglGetDisplay( (EGLNativeDisplayType) x_display );&lt;br /&gt;
   if ( egl_display == EGL_NO_DISPLAY ) {&lt;br /&gt;
      cerr &amp;lt;&amp;lt; &amp;quot;Got no EGL display.&amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;
      return 1;&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   if ( !eglInitialize( egl_display, NULL, NULL ) ) {&lt;br /&gt;
      cerr &amp;lt;&amp;lt; &amp;quot;Unable to initialize EGL&amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;
      return 1;&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   EGLint attr[] = {       // some attributes to set up our egl-interface&lt;br /&gt;
      EGL_BUFFER_SIZE, 16,&lt;br /&gt;
      EGL_RENDERABLE_TYPE,&lt;br /&gt;
      EGL_OPENGL_ES2_BIT,&lt;br /&gt;
      EGL_NONE&lt;br /&gt;
   };&lt;br /&gt;
&lt;br /&gt;
   EGLConfig  ecfg;&lt;br /&gt;
   EGLint     num_config;&lt;br /&gt;
   if ( !eglChooseConfig( egl_display, attr, &amp;amp;ecfg, 1, &amp;amp;num_config ) ) {&lt;br /&gt;
      cerr &amp;lt;&amp;lt; &amp;quot;Failed to choose config (eglError: &amp;quot; &amp;lt;&amp;lt; eglGetError() &amp;lt;&amp;lt; &amp;quot;)&amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;
      return 1;&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   if ( num_config != 1 ) {&lt;br /&gt;
      cerr &amp;lt;&amp;lt; &amp;quot;Didn&#039;t get exactly one config, but &amp;quot; &amp;lt;&amp;lt; num_config &amp;lt;&amp;lt; endl;&lt;br /&gt;
      return 1;&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   egl_surface = eglCreateWindowSurface ( egl_display, ecfg, win, NULL );&lt;br /&gt;
   if ( egl_surface == EGL_NO_SURFACE ) {&lt;br /&gt;
      cerr &amp;lt;&amp;lt; &amp;quot;Unable to create EGL surface (eglError: &amp;quot; &amp;lt;&amp;lt; eglGetError() &amp;lt;&amp;lt; &amp;quot;)&amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;
      return 1;&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   //// egl-contexts collect all state descriptions needed required for operation&lt;br /&gt;
   EGLint ctxattr[] = {&lt;br /&gt;
      EGL_CONTEXT_CLIENT_VERSION, 2,&lt;br /&gt;
      EGL_NONE&lt;br /&gt;
   };&lt;br /&gt;
   egl_context = eglCreateContext ( egl_display, ecfg, EGL_NO_CONTEXT, ctxattr );&lt;br /&gt;
   if ( egl_context == EGL_NO_CONTEXT ) {&lt;br /&gt;
      cerr &amp;lt;&amp;lt; &amp;quot;Unable to create EGL context (eglError: &amp;quot; &amp;lt;&amp;lt; eglGetError() &amp;lt;&amp;lt; &amp;quot;)&amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;
      return 1;&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   //// associate the egl-context with the egl-surface&lt;br /&gt;
   eglMakeCurrent( egl_display, egl_surface, egl_surface, egl_context );&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   ///////  the openGL part  ///////////////////////////////////////////////////////////////&lt;br /&gt;
&lt;br /&gt;
   GLuint vertexShader   = load_shader ( vertex_src , GL_VERTEX_SHADER  );     // load vertex shader&lt;br /&gt;
   GLuint fragmentShader = load_shader ( fragment_src , GL_FRAGMENT_SHADER );  // load fragment shader&lt;br /&gt;
&lt;br /&gt;
   GLuint shaderProgram  = glCreateProgram ();                 // create program object&lt;br /&gt;
   glAttachShader ( shaderProgram, vertexShader );             // and attach both...&lt;br /&gt;
   glAttachShader ( shaderProgram, fragmentShader );           // ... shaders to it&lt;br /&gt;
&lt;br /&gt;
   glLinkProgram ( shaderProgram );    // link the program&lt;br /&gt;
   glUseProgram  ( shaderProgram );    // and select it for usage&lt;br /&gt;
&lt;br /&gt;
   //// now get the locations (kind of handle) of the shaders variables&lt;br /&gt;
   position_loc  = glGetAttribLocation  ( shaderProgram , &amp;quot;position&amp;quot; );&lt;br /&gt;
   phase_loc     = glGetUniformLocation ( shaderProgram , &amp;quot;phase&amp;quot;    );&lt;br /&gt;
   offset_loc    = glGetUniformLocation ( shaderProgram , &amp;quot;offset&amp;quot;   );&lt;br /&gt;
   if ( position_loc &amp;lt; 0  ||  phase_loc &amp;lt; 0  ||  offset_loc &amp;lt; 0 ) {&lt;br /&gt;
      cerr &amp;lt;&amp;lt; &amp;quot;Unable to get uniform location&amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;
      return 1;&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   const float&lt;br /&gt;
      window_width  = 800.0,&lt;br /&gt;
      window_height = 480.0;&lt;br /&gt;
&lt;br /&gt;
   //// this is needed for time measuring  --&amp;gt;  frames per second&lt;br /&gt;
   struct  timezone  tz;&lt;br /&gt;
   timeval  t1, t2;&lt;br /&gt;
   gettimeofday ( &amp;amp;t1 , &amp;amp;tz );&lt;br /&gt;
   int  num_frames = 0;&lt;br /&gt;
&lt;br /&gt;
   bool quit = false;&lt;br /&gt;
   while ( !quit ) {    // the main loop&lt;br /&gt;
&lt;br /&gt;
      while ( XPending ( x_display ) ) {   // check for events from the x-server&lt;br /&gt;
&lt;br /&gt;
         XEvent  xev;&lt;br /&gt;
         XNextEvent( x_display, &amp;amp;xev );&lt;br /&gt;
&lt;br /&gt;
         if ( xev.type == MotionNotify ) {  // if mouse has moved&lt;br /&gt;
//            cout &amp;lt;&amp;lt; &amp;quot;move to: &amp;lt;&amp;lt; xev.xmotion.x &amp;lt;&amp;lt; &amp;quot;,&amp;quot; &amp;lt;&amp;lt; xev.xmotion.y &amp;lt;&amp;lt; endl;&lt;br /&gt;
            GLfloat window_y  =  (window_height - xev.xmotion.y) - window_height / 2.0;&lt;br /&gt;
            norm_y            =  window_y / (window_height / 2.0);&lt;br /&gt;
            GLfloat window_x  =  xev.xmotion.x - window_width / 2.0;&lt;br /&gt;
            norm_x            =  window_x / (window_width / 2.0);&lt;br /&gt;
            update_pos = true;&lt;br /&gt;
         }&lt;br /&gt;
&lt;br /&gt;
         if ( xev.type == KeyPress )   quit = true;&lt;br /&gt;
      }&lt;br /&gt;
&lt;br /&gt;
      render();   // now we finally put something on the screen&lt;br /&gt;
&lt;br /&gt;
      if ( ++num_frames % 100 == 0 ) {&lt;br /&gt;
         gettimeofday( &amp;amp;t2, &amp;amp;tz );&lt;br /&gt;
         float dt  =  t2.tv_sec - t1.tv_sec + (t2.tv_usec - t1.tv_usec) * 1e-6;&lt;br /&gt;
         cout &amp;lt;&amp;lt; &amp;quot;fps: &amp;quot; &amp;lt;&amp;lt; num_frames / dt &amp;lt;&amp;lt; endl;&lt;br /&gt;
         num_frames = 0;&lt;br /&gt;
         t1 = t2;&lt;br /&gt;
      }&lt;br /&gt;
//      usleep( 1000*10 );&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   ////  cleaning up...&lt;br /&gt;
   eglDestroyContext ( egl_display, egl_context );&lt;br /&gt;
   eglDestroySurface ( egl_display, egl_surface );&lt;br /&gt;
   eglTerminate      ( egl_display );&lt;br /&gt;
   XDestroyWindow    ( x_display, win );&lt;br /&gt;
   XCloseDisplay     ( x_display );&lt;br /&gt;
&lt;br /&gt;
   return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
[[Category:Development]]&lt;br /&gt;
[[Category:Fremantle]]&lt;/div&gt;</summary>
		<author><name>87.245.83.90</name></author>
	</entry>
</feed>