frameBuffer
-
Hi!
I've only been using Fuze4 for a few weeks, and I think it's FANTASTIC :D
I've been studying the 'Old Skool Racing' demo (which has a really cool collision detection method, and an interesting data() function).
On line 77 it refers to a 'frameBuffer'. What is that? The only explanation I've been able to find in the help section is in the 'setDrawTarget()' explanation, and it only mentions 'frameBuffer', but doesn't explain it!
Cheers,
- Jack
-
@Jack_Blue Hi Glad you are enjoying it! The frameBuffer is the buffer that gets drawn to the screen when update() is called. By default draw and print operations go the frameBuffer. You can use setDrawTarget to redirect draw operations to in image instead.
-
Just as an extra thing on how that's useful ... I tend to write clones of ZX Spectrum games, and rather than using
setMode( 256, 192 )
for the screen display (which is the Spectum resolution) it's better for me to do something like this;float scale = 3.5 // As in ... each byte occupies 8 bits/ pixels * how much we want to enlarge the display. float tile_size = 8 * scale struct game bool active int frame_count int rows int cols endStruct game game game.active = false game.frame_count = 0 // https://en.wikipedia.org/wiki/ZX_Spectrum game.rows = 24 game.cols = 32 offset_x = ( gWidth() - ( tile_size * game.cols ) ) / 2 offset_y = ( gHeight() - ( tile_size * game.rows ) ) / 2 spectrum_buffer = createimage( game.cols * 8, game.rows * 8, false, image_rgba ) loop // Clear down the Spectrum frame buffer. setDrawTarget( spectrum_buffer ) clear() // DO SOME STUFF! // Clear down the main frame buffer. setDrawTarget( framebuffer ) clear() // Output the Spectrum buffer scaled appropriately. drawImage( spectrum_buffer, offset_x, offset_y, scale ) update() game.frame_count += 1 repeat
...reasons being;
- If I draw/ print to an area, it's then the same as it is on a Spectrum so all the coordinates match (looking at you https://skoolkit.ca)
- I can then "emulate" the ZX Spectrum border command, as the centered Spectrum image has an area around it