I've Made a SDL-VNC Client Library

Hullo!

TL;DR: SDL2_vnc: A companion library to SDL for working with VNC servers

For a bit of fun recently, I’ve been working on a library that provides access to an RFB via SDL surfaces. Originally, I started writing this so I could manipulate output from QEMU guest machines (as QEMU has a VNC server built-in), but I realised that the code was getting close to something that might be useful to other people, so I’ve spent a little time cleaning it up in the hopes someone else finds it useful!

As a library, this project provides functionality for initialising a VNC connection, and creating a thread that continually requests framebuffer updates from the server. Users can access a surface that’s continually updated by the server-watching thread to be an up-to-date representation of the RFB. An SDL_Event entry is registered for when the server closes the connection. Users can also send pointer and key events to the VNC server using straightforward functions.

I’ve also included a simple VNC client that acts as an example usage of the library.

I’ve tried to mirror the core SDL projects (SDL, SDL_ttf etc.) in how the library looks and functions from the perspective of a user. If you look at the commit log, you’ll see I renamed a lot of identifiers to match the naming style of those projects. I also plan on adding doxygen documentation for the user-facing functions. My library is licensed under the zlib licence, same as SDL2, for ease of use.

Before writing this, I was getting by by adapting a different SDL-VNC library I came across, that had been written for SDL1. I ended up changing the code enough that I figured a re-write would be useful, but thanks to A. Schiffler for the prior art! Unfortunately, the email address mentioned in that library’s source code is hosted at a domain that seems to have expired; if anyone knows how I could contact the creator, I’d appreciate it.

The working title for the library has been SDL2_vnc, though I understand that’s a generic enough name that it might conflict with someone else’s project; I’d be happy to change the name in this case.

SDL2_vnc can be found at the link at the top of this topic. Code review/suggestions are more than welcome, as are issues and contributions. If issues/contributions are difficult to do on that platform (I barely use it usually), I’d be happy to move the project to a different home.

I have a lot of ideas on how to improve/add to this project (for example adding any testing at all), but I’d love to hear suggestions from any interested parties! In particular, I’d really appreciate comments on my use of SDL in this project: I’ve done some small projects using SDL in the past but I’m sure there are still SDL features/quirks/best-practices I’m sleeping on. I would also really appreciate suggestions on VNC servers to test with: the QEMU implementation only uses a portion of the standard, and in particular the VMs I have been using (mostly SerenityOS) don’t support hardware pointers in QEMU so I get laggy pointers.

So yeah, I’d be happy to answer any questions anyone has, and hope that someone can find a use for this lil library of mine (:

I ended up changing the code enough that I figured a re-write would be useful, but thanks to A. Schiffler for the prior art! Unfortunately, the email address mentioned in that library’s source code is hosted at a domain that seems to have expired; if anyone knows how I could contact the creator, I’d appreciate it.

SDL2_gfx: SDL2_gfx - Graphics primitives and surface functions for SDL2 mentions an e-mail address which is at ferzkopp.net (so it probably still works)

1 Like

Hi @mag, does this lib still exist? Page seems to be down?

1 Like

Whoops! I had this project hosted on a friend’s server, and they’ve since taken that server down.

I’ve rehosted it at my personal site, though I might have to clean up some things since this is an archived copy.

Thanks for pinging me, I don’t know how long I would have left this without noticing otherwise!

1 Like

Thanks for putting it back up!

It can’t be checked out with git though - sdl2_vnc - A companion library to SDL2 for working with VNC servers says

clone this repository from https://www.magnostherobot.co.uk/git.cgi/personal-projects/sdl2_vnc

But git clone says:

$ git clone https://www.magnostherobot.co.uk/git.cgi/personal-projects/sdl2_vnc
Cloning into 'sdl2_vnc'...
warning: remote HEAD refers to nonexistent ref, unable to checkout.
1 Like

Ah - when I initialised the bare git repo on my host, it assumed the HEAD would be on a “master” branch, though the repo uses a “main” branch instead.

I’ve remade the repo, and also pushed a little fix to some of the code. I’m able to clone the repo, and build the project on Pop_OS 21.04. Let me know if it works for you now (:

Cloning works now, thanks for fixing it!

1 Like