Direct video buffer access

1.7k views Asked by At

when I comes to rendering things on screen using video card, only three options are available, if I understand correctly. These are

  1. DirectX (or XNA)
  2. OpenGL
  3. Windows Driver Kit and creating minimal implementation of graphics driver

I have very little experience with DirectX or OpenGL, but from what I know you have to write a pixel shader program that tells rendering pipeline what to do with each pixel. These shaders are programmed in HLSL. But as far as I know, neither DirectX, nor OpenGL is able to return a pointer to a memory that I could write some byte[] buffer to from my C# program and get it rendered. Or am I mistaken here?

WDK might be a better choice, because it would be possible to implement absolutely minimal implementation of graphics driver that does nothing but returns pointer to a memory where I could write RGB data. So at one hand I could get rid of all the abstraction DirectX or OpenGL provides (and which I don't need), but at the other complexity of driver development is not exactly a time-saver.

Also, from what I have found while searching more information on this, in the old days of DOS there was an address 0B00 or similar that allowed developers to draw directly onto screen buffer. It's gone of course and no longer usable I guess, but I have read for compatibility reasons this memory spaces are still reserved. Is it possible to utilize this somehow?

What is the easiest way to get access to video memory from C# so I can write directly onto screen? Does DirectX or OpenGL provide such functionality, that would enable me to directly copy and array of bytes somewhere and get it rendered?

1

There are 1 answers

4
Oskar On

By using OpenGL's or Direct3D's built-in texture rendering capabilities, you can copy the pixel data from client side memory to server side memory and then have it render the texture on screen.

Note: With client side memory I mean the memory accessible from the program (on the CPU and in the RAM) and with server side memory I mean the memory on the graphics card. This has nothing to do with networking