User avatar
ab1jx
Posts: 885
Joined: Thu Sep 26, 2013 1:54 pm
Location: Heath, MA USA
Contact: Website

Writing VNC output into a program?

Sun Jul 23, 2017 9:20 pm

I don't know if this is done much, never heard of it, but it seems feasible. Instead of writing a program that outputs to drive a certain type of display, write it to connect to a VNC client. Then somebody that wants to use it provides a VNC client for their hardware, either locally or remotely.

I'm considering writing a GUI program that outputs to a Raspi framebuffer. I want motion, which is difficult under X without something like OpenGL. Except I'd like to be able to run it from my OpenBSD machines too but there's no framebuffer there. VNC is essentially Remote Frame Buffer. There's even a VNC client for Androids, I have one on a phone. This would be different from running a VNC server and the program on a computer, the program could output to what it thinks is a local framebuffer but it could actually be remote (or local). I haven't seen a good description of the protocol yet from a programming standpoint. Seems like it could be handled by linking in a library. On the client machine it would be just another window, I'm not sure what I'd do about forwarding mouse and keyboard events.

https://en.wikipedia.org/wiki/RFB_protocol and
https://en.wikipedia.org/wiki/Virtual_Network_Computing

User avatar
ab1jx
Posts: 885
Joined: Thu Sep 26, 2013 1:54 pm
Location: Heath, MA USA
Contact: Website

Re: Writing VNC output into a program?

Mon Jul 24, 2017 12:01 am

Never mind, I wasn't within reach of my Synaptic because my VNC wouldn't connect for some reason.

I see a few things that might work if I'm not misreading the descriptions.

Happy upgrade if I'm not back on before then. I wouldn't have guessed this forum was in PHP which I associate with bloat and slowness. I forget what I used to try to run 10 years ago or so but it was awful. I like this a lot better than what bitcointalk.org is running for forum software.

ghans
Posts: 7882
Joined: Mon Dec 12, 2011 8:30 pm
Location: Germany

Re: Writing VNC output into a program?

Mon Jul 24, 2017 8:39 am

There is a project called libvncserver. I think it does what i says on the tin.

ghans
• Don't like the board ? Missing features ? Change to the prosilver theme ! You can find it in your settings.
• Don't like to search the forum BEFORE posting 'cos it's useless ? Try googling : yoursearchtermshere site:raspberrypi.org

User avatar
ab1jx
Posts: 885
Joined: Thu Sep 26, 2013 1:54 pm
Location: Heath, MA USA
Contact: Website

Re: Writing VNC output into a program?

Mon Jul 24, 2017 2:28 pm

Yes, thank you, https://libvnc.github.io/ We'll see.

The cover example is just:

Code: Select all

#include <rfb/rfb.h>

int main(int argc,char** argv)
{
  rfbScreenInfoPtr server=rfbGetScreen(&argc,argv,400,300,8,3,4);
  server->frameBuffer=malloc(400*300*4);
  rfbInitServer(server);
  rfbRunEventLoop(server,-1,FALSE);
  return(0);
}
Sounds too good to be true.

User avatar
ab1jx
Posts: 885
Joined: Thu Sep 26, 2013 1:54 pm
Location: Heath, MA USA
Contact: Website

Re: Writing VNC output into a program?

Tue Jul 25, 2017 2:02 am

If anybody's trying to do this, libvnc is already in the standard Raspbian debs. I built it from source. Oh well.

Return to “Graphics programming”