Basically the loop amounts to clearing the whole screen with FramebufferDeviceFillRect, drawing some rectangles again with FramebufferDeviceFillRect and finally waiting with FramebufferDeviceWaitSync. I was quite happy with that and moved on to other things... now all those other things are done and I am back doing some drawing code.
Today I finished implementing some input logic to handle button presses and did a quick test of moving a rectangle around the screen. I realised that the drawing of the rectangles isn't smooth in all sections of the screen, everything is fine in the left half, the right half seems to work fine at the top, and the bottom right of the screen looks like is not able to keep up with the drawing speed at all, the rectangle flickers a lot and some pixels are not even drawn, as it get's closer to the edges the drawing works well again, which is very odd.
I tried just clearing the area behind the rectangle instead of the whole screen, but it didn't make any difference.
Here is a snippet of what y main loop looks like
Code: Select all
while (True) do
// Clear the area behind the rectangle
FramebufferDeviceFillRect(FramebufferDevice, x, y, 40, 40, $00000000, FRAMEBUFFER_TRANSFER_DMA);
// The input logic to move the rectangle around
if IsButtonDown(BUTTON_UP) then
y := y - 1;
if IsButtonDown(BUTTON_DOWN) then
y := y + 1;
if IsButtonDown(BUTTON_LEFT) then
x := x - 1;
if IsButtonDown(BUTTON_RIGTH) then
x := x + 1;
// Draw a red rectangle
FramebufferDeviceFillRect(FramebufferDevice, x, y, 40, 40, $FFFF0000, FRAMEBUFFER_TRANSFER_DMA);
I also tried using FramebufferDeviceSetOffset to try an implement a back buffer, to see if that would help, but I am not sure I am doing that right. What I did was insert a call to set the frame buffer offset in between the wait for sync call and the fill rect call, and I added a little bit of code to change the offset in each iteration of the loop, much like the Bounding Boxes examples does.
Would I be able to implement a decent back buffer using Ultibo's built in frame buffer drawing methods? Or do I need to roll out an implementation of my own? I was thinking about that, because the Bouncing Boxes example doesn't use the built in methods and instead has custom functions doing the work.