Announcement

Collapse
No announcement yet.

how to write directly to display

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    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.

    Comment


    • #3
      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.

      Comment


      • #4
        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..

        Comment


        • #5
          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.

          Comment


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

            Comment


            • #7
              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.

              Comment


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

                Comment


                • #9
                  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.

                  Comment

                  Working...
                  X