Results 1 to 9 of 9

Thread: how to write directly to display

  1. #1
    Join Date
    Dec 2008
    Posts
    4

    Default how to write directly to display

    I want to output a pixel on the screen by directly accessing the video memory. How do I do that in C ?

    ps : I know how to do it using xlib.

  2. #2
    Join Date
    Nov 2007
    Posts
    1,024

    Default

    Quote Originally Posted by digitalgeek View Post
    I want to output a pixel on the screen by directly accessing the video memory. How do I do that in C ?
    You don't.

    Directly accessing video memory is a very complex thing on modern GPUs, and essentially not possible without a metric crapload of supporting code to figure out where you need to write, what format to write it in, and so on. Writing may involve a lot of complex GPU rendering commands and not even allow directly writing to the video memory, or memory might only be accessible through special interfaces (not something you can mmap). Tiled displays and the like make this even more difficult.

    Even if someone could provide some code for you, it would likely work on only a specific single chipset. It certainly wouldn't work while the rest of the graphics stack was running.

    This isn't the 80s anymore. Or even the 90s. Writing directly to framebuffer memory is not the way to accomplish whatever it is you're trying to do. You're almost certainly better off rendering whatever it is you're doing into a regular block of memory and then using SDL/GL/xlib to blit it to your app's window/buffer.

  3. #3
    Join Date
    Jul 2007
    Posts
    404

    Default

    The only ways I can think of to do this (write to the framebuffer) is to use the Linux framebuffer, or the new kms with gem (I think that allows you to write to the framebuffer.

    As far as directly modifying video memory, that's not something most sane people want to attempt. The GPU is almost a computer unto itself these days, with it's own memory management and threading system.

  4. #4
    Join Date
    Dec 2008
    Posts
    4

    Default

    Thanks for the replies

    I am trying to build a experimental x server that I have in mind. So I need to learn the low level hair pulling stuff I dont want to use the xlib/x.org.

    I will try using the framebuffer for now..

  5. #5
    Join Date
    Nov 2007
    Posts
    1,024

    Default

    You might be better off looking into KMS and EGL for your low-level graphics support. e.g, Kristian's Wayland project that's been recently reported on here on Phoronix.

  6. #6
    Join Date
    Dec 2008
    Posts
    4

    Default

    my display card (some old via chipset) does not support kms I am using the vesa drivers.

  7. #7
    Join Date
    Jul 2007
    Posts
    404

    Default

    If you don't have KMS support, you'll basically have to write your own driver, I'm afraid. That's why the Xserver hasn't been replaced yet.

  8. #8
    Join Date
    Dec 2008
    Posts
    4

    Default

    I got the /dev/fb0 working. Any guides on how to write to the framebuffer directly without going through Xlib/DirectFb/etc..

  9. #9
    Join Date
    Nov 2007
    Posts
    1,024

    Default

    Quote Originally Posted by digitalgeek View Post
    I got the /dev/fb0 working. Any guides on how to write to the framebuffer directly without going through Xlib/DirectFb/etc..
    You could checkout the sources of those projects. I'm a bit confused why you don't just use an existing complete low-level graphics library, though -- DirectFB itself might be perfect for your needs.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •