04-11-2012 04:48 AM
I am a bit confused and I hope someone can set me straight on this.
In the sample code for 'Drawing using Blits, Pixmaps, and Buffers. The example states that the code is using a double buffer for drawing to the screen, which is reflected in the code given as:
On every iteration of the main loop the example gets a pointer to those buffers using the code:
screen_buffer_t screen_buf; screen_get_window_property_pv(screen_win, SCREEN_PROPERTY_RENDER_BUFFERS, (void **)screen_buf);
However all drawing seems to be done to screen_buf which is only 1 of the buffers, code as below:
screen_blit(screen_ctx, screen_buf, screen_pbuf, hg); screen_post_window(screen_win, screen_buf, 1, rect, 0);
So my questions are as follows:
1) is it necessary to get a a pointer to the buffers on each iteration of the main loop?
2) Does the example fail to use both buffers, even though it stated that It would be using a double buffer?
3) or does the buffer swap occur automatically perhaps on a call to screen_post_window() which is why the example is re-obtaining the pointers to the buffer on each iteration and why drawing is always done to screen_buf?
I am confused because, If 'I' (the programmer) am supposed to handle the swap of the buffers then the example would appear to be incorrect in that it is not using both buffers. If the swap occurs automatically the example does not make clear at what point that occurs and that you should only draw to screen_buf as it is constantly pointing to the current back buffer.
I hope that you find the above straight forward to follow. All help is appreciated.
04-12-2012 01:50 AM