Jump to content

Video Memory Access in C++

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
5 replies to this topic

#1
roboticforest

roboticforest

    Programmer

  • Members
  • PipPipPipPip
  • 110 posts
Hello all. It's been quite a while now since I've visited. I guess moving, and not having internet at home really makes a dent in your online life. :)

I'd like to know how to obtain a raw linear chunk of video memory.

I'm trying to make my own Surface class, and memory managment is a bit of an issue, so I can't just rely on a surface structure provided by, for example, the SDL, DirectX, or what not.

I need a chunk of raw video memory that I can divide between a number of surfaces myself. How do I do this?

I'm at work now, and I may not respond for a day or so. Feel free to make a few assumptions, and suggest anything that comes to mind. I'll answer any questions when I get the chance.
Dave

#2
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
Off hand, it seems like it would depend on the video card.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#3
roboticforest

roboticforest

    Programmer

  • Members
  • PipPipPipPip
  • 110 posts
Indeed. I'm sure it does. However it's the OS's job to abstract those details away. DirectX, and SDL each provide a "surface", but my problem is that I'm trying to design my own surface object.

I could just make use of the raw memory pointer in an SDL_Surface, but that sounds unsafe and stupid considering its supposed to be a private data member. What I need is to obtain such a pointer myself, yet I don't know how the SDL got one.
Dave

#4
dargueta

dargueta

    Writes binary right handed and hex left handed

  • Moderators
  • 4,715 posts
It depends on the operating system. Either way you'd have to make some system-dependent calls. The actual layout of the memory is device-dependent and would require the use of a device driver. Why is memory such an issue? Is this for an embedded system or something? Because that's the only thing I can think of that would require such stringent requirements on your part. Libraries such as DX and OGL are pretty highly optimized for this kind of thing.

#5
roboticforest

roboticforest

    Programmer

  • Members
  • PipPipPipPip
  • 110 posts
I know it's system dependant, so lets assume I'm on Windows. (I would also like to know about Linux and Mac at some point.)

I'm trying to get a pointer to a chunk of video memory in some form. I'm not trying to get a pointer to anything in the monitor, or currently on the screen. Specifically, I'm trying to get a pointer to any memory the video card says that it has.

How do I get such a pointer?
Dave

#6
dargueta

dargueta

    Writes binary right handed and hex left handed

  • Moderators
  • 4,715 posts
It depends on the version of Windows, but either way you'd have to access the appropriate device driver. Look herefor more information. It doesn't tell you how exactly, but it does give you a good overview and some links.
sudo rm -rf /