Hello folks,
I am developing a library to interface graphical displays (TFTs) and touchscreens with microcontrollers, also providing a simple GUI toolkit. To make the development easier, I’d like to create a simple display simulator so I can develop everything on my computer without the need of physical hardware in order to try it out and debug it.
I thought it should be possible to do this quite easily using Xlib and OpenGL (I am on a linux machine). I need the Xlib in order to create the window as well as to get the events from the mouse to simulate a touchscreen input.
Now to my problem: I guess I am misunderstanding the “workflow” in which Xlib and OpenGL work together. My driver API looks like the following:
void gdisp_lld_init(void); // here I create the window and set everything else up
void gdisp_lld_clear(color_t color);
void gdisp_lld_draw_pixel(coord_t x, coord_t y, color_t color);
void gdisp_lld_draw_line(coord_t x0, coord_t y0, coord_t x1, coord_t y1, color_t color);
...
Now, after I get the window created in the init routine, I thought I would be able to simply draw something within the glBegin() and glEnd() calls and then I simply redraw the screen, without deleting the old content. However, I don’t really understand how this should be done. My main problem is that I don’t really see how I can just tell OpenGL to redraw the scene without deleting the old content.
I found this example[1], but there, the content is always redrawn when the display is supposed to be refreshed. This is not what I want. I want to be able to add a drawing without the need to redraw the old content.
So, can anyone tell me what’s the way to archive what I want?
Thanks in advance,
~ Tectu
[1] ht tp://www-f9.ijs.si/~matevz/docs/007-2392-003/sgi_html/ch03.html#LE92780-PARENT