FramebufferPresenter¶
Description¶
Incrementally present a Framebuffer to a Window using WINDOW_BLIT=146. Use it for software rendering after READY.
gaspardos::FramebufferPresenter — bindings/cpp/framebuffer_window.hpp, C++98.
Simple program example¶
#include "framebuffer_window.hpp"
#include <cstring>
int main()
{
gaspardos::Window window;
GO64_WindowOptions options = {};
options.width = 320;
options.height = 240;
std::strcpy(options.title, "Framebuffer");
if (window.create(options) < 0)
return 1;
gaspardos::Framebuffer image(320, 240);
image.clear(0x00201810);
image.circle(160, 120, 40, 0x00ffffff);
gaspardos::FramebufferPresenter presenter(window);
for (unsigned i = 0; i < 10000; ++i)
{
GO64_Event event = {};
int64_t result = window.event(event);
if (result < 0 && result != -11)
return 1;
if (result == 0 && (event.type == 15 || event.type == GO64_ERROR))
break;
if (window.ready())
{
result = presenter.present(image);
if (result == 0)
break;
if (result != -11)
return 1;
}
GO64_yield();
}
for (unsigned i = 0; i < 10000; ++i)
{
GO64_Event event = {};
if (window.event(event) == 0 && event.type == 15)
break;
GO64_yield();
}
return window.close() == 0 ? 0 : 1;
}
Building from Windows¶
From the repository root, save the program as build/api-examples/FramebufferPresenter.cpp.
New-Item -ItemType Directory -Force build/api-examples | Out-Null
& .\build-x64-install\bin\x86_64-gaspardos-gcc.exe -std=gnu1x -O2 -mno-red-zone -c bindings/native/gaspardos_x64_syscall.c -o build/api-examples/syscall.o
if ($LASTEXITCODE -ne 0) { throw "C build failed" }
& .\build-x64-install\bin\x86_64-gaspardos-g++.exe -std=c++98 -O2 -Ibindings/cpp build/api-examples/FramebufferPresenter.cpp build/api-examples/syscall.o -o build/api-examples/FramebufferPresenter.elf
if ($LASTEXITCODE -ne 0) { throw "C++ build failed" }
Executable for GaspardOS. Presentation requires WINDOW_BLIT=146 in the kernel; -38 means the extension is absent. Source files.
Methods and public data¶
explicit FramebufferPresenter(Window& window)¶
Non-owning reference; the window must outlive the presenter. Noncopyable.
bool pending() const¶
True when a presentation must resume after -11.
void cancel()¶
Discard local progress; tiles already copied remain queued in the kernel.
int64_t present(const Framebuffer& source, int x=0, int y=0)¶
Split into 256 × 256 tiles; zero means fully queued, -11 means retry with the same pixels and arguments, -16 means another source/storage/destination during a pending frame, -22 means invalid dimensions/coordinates. Other errors cancel progress. Keep the source alive and unchanged until zero or cancel. No VSync or atomic presentation.