I seriously cannot figure this out. Here is the server code:
rfbScreenInfoPtr server = rfbGetScreen(nullptr, nullptr, 8, 8, 8, 3, 4);
if (!server)
return 1;
server->frameBuffer = (char*)malloc(8 * 8 * 4);
std::fill_n(server->frameBuffer, 8 * 8 * 4, 0xff);
print_framebuffer_bits((uint8_t*)server->frameBuffer, 8, 8);
rfbInitServer(server);
vnc_thread = std::thread(vnc_server_thread_func, server);`
And here is the resize function for the client
static rfbBool resize(rfbClient* client) {
int width = client->width;
int height = client->height;
int depth = client->format.bitsPerPixel;
// 1. Clean up old buffer allocations
if (vncBuffer) {
delete[] vncBuffer;
vncBuffer = nullptr;
}
// 2. Allocate a tightly packed buffer (Width * 4 bytes, ZERO alignment padding)
vncBuffer = new uint8_t[width * height * 4];
std::memset(vncBuffer, 0, width * height * 4);
rfbClientSetClientData(client, SDL_Init, vncBuffer);
// 3. Bind LibVNC straight to this raw buffer
client->frameBuffer = vncBuffer;
SetFormatAndEncodings(client);
// 5. Recreate the streaming texture using XRGB8888
// This aligns the little-endian bytes perfectly to [Pad][B][G][R]
if (sdlTexture)
SDL_DestroyTexture(sdlTexture);
sdlTexture = SDL_CreateTexture(renderer,
SDL_PIXELFORMAT_XRGB8888,
SDL_TEXTUREACCESS_STREAMING,
width, height);
if (!sdlTexture)
std::printf("resize: error creating texture: %s\n", SDL_GetError());
return TRUE;
}
No matter what I try the first two pixels on the first row are always black. Can someone tell me what I am doing wrong?
I seriously cannot figure this out. Here is the server code:
And here is the resize function for the client
No matter what I try the first two pixels on the first row are always black. Can someone tell me what I am doing wrong?