xlib programing - Xwindows

This is a discussion on xlib programing - Xwindows ; hi guys. I'm making an application which involves a part that writes to a buffer, something like write( &souce_buff, offset, count) and another that should reflect the changes to that buffer in a window. A naive method that I use ...

+ Reply to Thread
Results 1 to 5 of 5

Thread: xlib programing

  1. xlib programing

    hi guys. I'm making an application which involves a part that writes
    to a buffer, something like write( &souce_buff, offset, count) and
    another that should reflect the changes to that buffer in a window. A
    naive method that I use was to draw each pixel like this
    XDrawPoint(...) to reflect those changes but it is incredibly slow. My
    question to you is: what concept should I use to speed things up. In
    other words is there a method to have a buffer displayed in a window
    fast and have fast access to that buffer ?

    Pixmaps, XImage, shared memory XImages perhaps? please help.

  2. Re: xlib programing

    Dan writes:

    > hi guys. I'm making an application which involves a part that writes
    > to a buffer, something like write( &souce_buff, offset, count) and
    > another that should reflect the changes to that buffer in a window. A
    > naive method that I use was to draw each pixel like this
    > XDrawPoint(...) to reflect those changes but it is incredibly slow. My
    > question to you is: what concept should I use to speed things up. In
    > other words is there a method to have a buffer displayed in a window
    > fast and have fast access to that buffer ?
    >
    > Pixmaps, XImage, shared memory XImages perhaps? please help.


    Looks like you're on the right track.

    --
    Måns Rullgård
    mans@mansr.com

  3. Re: xlib programing

    On May 6, 5:45*pm, Måns Rullgård wrote:
    > Dan writes:
    > > hi guys. I'm making an application which involves a part that writes
    > > to a buffer, something like write( &souce_buff, offset, count) and
    > > another that should reflect the changes to that buffer in a window. A
    > > naive method that I use was to draw each pixel like this
    > > XDrawPoint(...) to reflect those changes but it is incredibly slow. My
    > > question to you is: what concept should I use to speed things up. In
    > > other words is there a method to have a buffer displayed in a window
    > > fast and have fast access to that buffer ?

    >
    > > Pixmaps, XImage, shared memory XImages perhaps? please help.

    >
    > Looks like you're on the right track.
    >


    Yes, this is the right way. Create a pixmap the size of the window.
    use that pixmap as your bufffer, then just call XCopyArea to transfer
    to the screen.
    --
    Fred Kleinschmidt

  4. Re: xlib programing

    Dan wrote:

    > hi guys. I'm making an application which involves a part that writes
    > to a buffer, something like write( &souce_buff, offset, count) and
    > another that should reflect the changes to that buffer in a window. A
    > naive method that I use was to draw each pixel like this
    > XDrawPoint(...) to reflect those changes but it is incredibly slow. My
    > question to you is: what concept should I use to speed things up. In
    > other words is there a method to have a buffer displayed in a window
    > fast and have fast access to that buffer ?
    >
    > Pixmaps, XImage, shared memory XImages perhaps? please help.


    Yes, XImage and shared memory is the way to go. Pixmaps reside in the
    server, while XImages reside in the client/application. This means
    your application can twiddle the pixels of an XImage very quickly,
    and then periodically copy the image to the screen via XShmPutImage().

    If the server and client are running on different machines, then
    shared memory won't work, but one plain old XPutImage is often faster
    than a large number of XDrawPoint() calls anyway. Try to write your
    code so that it works with or without shared memory.

    In fact, I'd say you should try it with non-shared XImage to begin
    with, and then add shared memory support once you get that working.

    The documentation for shared memory XImage is at:

    http://www.xfree86.org/current/mit-shm.html

  5. Re: xlib programing

    fred.l.kleinschmidt@boeing.com wrote:
    > On May 6, 5:45*pm, Måns Rullgård wrote:
    >> Dan writes:
    >> > hi guys. I'm making an application which involves a part that writes
    >> > to a buffer, something like write( &souce_buff, offset, count) and
    >> > another that should reflect the changes to that buffer in a window. A
    >> > naive method that I use was to draw each pixel like this
    >> > XDrawPoint(...) to reflect those changes but it is incredibly slow. My
    >> > question to you is: what concept should I use to speed things up. In
    >> > other words is there a method to have a buffer displayed in a window
    >> > fast and have fast access to that buffer ?

    >>
    >> > Pixmaps, XImage, shared memory XImages perhaps? please help.

    >>
    >> Looks like you're on the right track.
    >>

    >
    > Yes, this is the right way. Create a pixmap the size of the window.
    > use that pixmap as your bufffer, then just call XCopyArea to transfer
    > to the screen.



    That's one option. For the best flicker-free appearance, usage of
    XCopyArea + DBE/XdbeSwapBuffers() is better, though the code should
    fallback to just XCopyArea when DBE isn't available on some X servers.


    George

+ Reply to Thread