c++ - Faster than xlib -


i've searched lightweight guis , found several (e.g. fltk) want fast library on linux/ubuntu. not need cross-platform. has fast.

my application simple. have canvas 800x800 , on am: - drawing 200x200 squares in grid - few strings of text - hotspots person can press mouse.

i'm trying push frame rate fast can. i've found sample x11 c++ code.

is there faster library x?

tia


update: here sample code in glut. looks can 1 frame in 20ms on laptop (sony vaio i7-3632qm 2.2ghz running ubuntu 12.04). aside, looks tv "snow" when runs...

i not equivalent sample run xlib. keeps terminating errors similar to: "xio: fatal io error 11 (resource temporarily unavailable) on x server ":0" after 86 requests (86 known processed) 10 events remaining."

#include <gl/glut.h> #include <cstdlib> #include <pthread.h> #include <unistd.h>  int win_w = 0.0; int win_h = 0.0;  #include <pthread.h> #include <iostream>  void drawgrid(int size)   {   const int cellsize = 3;   const int gridsize = size * cellsize;   (int y = 0; y < gridsize; y += cellsize)     {     (int x = 0; x < gridsize; x += cellsize)       {       int c = rand() % 100;       if (c < 33)         glcolor3f(1.0, 0.0, 0.0);       else if (c < 66)         glcolor3f(0.0, 1.0, 0.0);       else         glcolor3f(0.0, 0.0, 1.0);        glrecti(x, y, x + cellsize, y + cellsize);       }     }   }  void display(void)   {   glclear(gl_color_buffer_bit | gl_depth_buffer_bit);   glmatrixmode(gl_projection);   glloadidentity();   glortho(0, win_w, 0, win_h, -1, 1);   glcolor3f(0.0, 0.0, 1.0);   gltranslatef(30, 30, 0);   drawgrid(200);   glflush();   glutswapbuffers();   }  void reshape(int w, int h)   {   win_w = w;   win_h = h;   glviewport(0, 0, w, h);   }  static int lasttime = 0l; void idle()   {   const int timeperframe = 19; //ms   int t = glutget(glut_elapsed_time);   int delay = timeperframe - (t - lasttime);   if (delay < 0)     {     std::cout << t << "  " << lasttime << "  " << delay << "\n";     }   else     {     ::usleep(delay * 1000);     }   glutpostredisplay();   lasttime = glutget(glut_elapsed_time);   }  int main(int argc, char **argv)   {   glutinit(&argc, argv);   glutinitdisplaymode(glut_rgba | glut_depth | glut_double);   glutinitwindowsize(800, 800);   glutcreatewindow("test glut");   glutdisplayfunc(display);   glutreshapefunc(reshape);   glutidlefunc(idle);   glutmainloop();   return 0;   } 

there 2 "x libraries". good, old xlib , xcb. xcb should "faster" has modern architecture. if not happy performance of these two, can avoid them using linux framebuffer directly, or using directfb (http://www.directfb.org).

however, framebuffer not run in x window. so, need simplest possible xlib or xcb code create window application, , use glx render onto window's surface.

finally, best option sdl believe. url: http://www.libsdl.org .


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -