Accessing on video surface from two processes

Dear all,

I would like to access a video surface from a second process.

I would like to open a window in a program and leave it open for a
while.

*SDL_SetVideoMode to opens a window and returns a pointer to access that
window.

How can I “draw things” from a second process on that window opened by
the first process ?

Maybe I’m lacking some very basic understanding of pointers and C/C++
but I would be grateful for a some help.

Thanks Thomas.–
Thomas Mueller
Laboratory of Neurobiology @ UCL
phone: +44 (020) 7679 3905
email: @Thomas_Mueller
WWW : www.vislab.ucl.ac.uk

Thomas Mueller wrote:

I would like to access a video surface from a second process.

The short answer is you cannot, but see below.

I would like to open a window in a program and leave it open for a while.
*SDL_SetVideoMode to opens a window and returns a pointer to access that
window.
How can I “draw things” from a second process on that window opened by
the first process ?

On many SDL-supported platforms a pointer is only valid within the process
that created the pointer (or rather the memory area the pointer points to).
This is due to Virtual Address space used by most modern OSes.
On these platforms you would normally resort to some way of inter-process
communication (like pipes) to deliver the rendering commands to the first
process (the owner of the SDL surface). The first process essentially
becomes a rendering driver for the second process.
All of this is beyond the scope of SDL, however, and I would recommend
finding a different solution to your problem (you did not say what the
problem was, btw).

-Alex.

Dear Alex,

Thank you very much for your reply.

My problem:

I would like to use SDL commands from a scripted environment. Precisely
I want to use “octave” (http://www.gnu.org/software/octave/) to produce
some SDL graphics.

Yours Thomas.On Wed, 2006-06-14 at 13:31 -0400, Alex Volkov wrote:

Thomas Mueller wrote:

I would like to access a video surface from a second process.

The short answer is you cannot, but see below.

I would like to open a window in a program and leave it open for a while.
*SDL_SetVideoMode to opens a window and returns a pointer to access that
window.
How can I “draw things” from a second process on that window opened by
the first process ?

On many SDL-supported platforms a pointer is only valid within the process
that created the pointer (or rather the memory area the pointer points to).
This is due to Virtual Address space used by most modern OSes.
On these platforms you would normally resort to some way of inter-process
communication (like pipes) to deliver the rendering commands to the first
process (the owner of the SDL surface). The first process essentially
becomes a rendering driver for the second process.
All of this is beyond the scope of SDL, however, and I would recommend
finding a different solution to your problem (you did not say what the
problem was, btw).

-Alex.


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


Thomas Mueller
Laboratory of Neurobiology @ UCL
phone: +44 (020) 7679 3905
email: @Thomas_Mueller
WWW : www.vislab.ucl.ac.uk

Thomas Mueller wrote:

My problem:
I would like to use SDL commands from a scripted environment.
Precisely I want to use “octave” (http://www.gnu.org/software/octave/)
to produce some SDL graphics.

Thomas Mueller wrote:

I would like to access a video surface from a second process.

Yeah, if you want to do it this way, you should definitely create an
SDL-window owner process that will act as a graphics server for your
octave(?) clients. Just come up with a minimal gfx interface that you need
(i.e. Point, Line, Rect, Ellipse, Text primitives) and send these commands
from clients to your server over pipes or sockets, for example.
Since octave uses gnuplot to do the drawing, I suppose you could hack
gnuplot to do some of the work for you, or perhaps write a printer driver
that will forward the rendering commands to your SDL-window server. This
will be, however, already outside the SDL mailing list topics.

-Alex.

Dear Alex,

Thanks for dealing with my problem.
I did a bit of “RTFM” and found out that with octave you can dynamically
link external functions. That means I could write a function which opens
a window, declaring the “SDL_Surface *screen;” as a global variable.
A second function can now access the previously opened window, because
it’s all one process and “*screen” is global.

It seems all easy now and I don’t need to have a server, pipes and
sockets, which I would not have know how to deal with.

Thanks for your kindness.

Yours Thomas.On Mon, 2006-06-19 at 17:23 -0400, Alex Volkov wrote:

Thomas Mueller wrote:

My problem:
I would like to use SDL commands from a scripted environment.
Precisely I want to use “octave” (http://www.gnu.org/software/octave/)
to produce some SDL graphics.

Thomas Mueller wrote:

I would like to access a video surface from a second process.

Yeah, if you want to do it this way, you should definitely create an
SDL-window owner process that will act as a graphics server for your
octave(?) clients. Just come up with a minimal gfx interface that you need
(i.e. Point, Line, Rect, Ellipse, Text primitives) and send these commands
from clients to your server over pipes or sockets, for example.
Since octave uses gnuplot to do the drawing, I suppose you could hack
gnuplot to do some of the work for you, or perhaps write a printer driver
that will forward the rendering commands to your SDL-window server. This
will be, however, already outside the SDL mailing list topics.

-Alex.


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


Thomas Mueller
Laboratory of Neurobiology @ UCL
phone: +44 (020) 7679 3905
email: @Thomas_Mueller
WWW : www.vislab.ucl.ac.uk