Obtaining a pointer to the video buffer

This is a discussion on Obtaining a pointer to the video buffer within the Game Programming forums, part of the General Programming Boards category; Is there any way to obtain a pointer to the video buffer without using a graphics API like SDL? I ...

  1. #1
    Supermassive black hole cboard_member's Avatar
    Join Date
    Jul 2005
    Posts
    1,709

    Obtaining a pointer to the video buffer

    Is there any way to obtain a pointer to the video buffer without using a graphics API like SDL?

    I mean if you know where it is could you manually assign a pointer to it? I guess it starts at the same place on every machine?

    Something like

    Code:
    unsigned char *video = (unsigned char *) 0x00ABCDEF
    Good class architecture is not like a Swiss Army Knife; it should be more like a well balanced throwing knife.

    - Mike McShaffry

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,832
    Well assuming you can get past the virtual memory protection of your OS,
    and can find the physical address where the card video memory is mapped,
    and can figure out how that memory is mapped to pixels and screen resolutions,
    and ....

    What is your question?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Supermassive black hole cboard_member's Avatar
    Join Date
    Jul 2005
    Posts
    1,709
    I'll be quiet now.
    Good class architecture is not like a Swiss Army Knife; it should be more like a well balanced throwing knife.

    - Mike McShaffry

  4. #4
    Supermassive black hole cboard_member's Avatar
    Join Date
    Jul 2005
    Posts
    1,709
    Hang on, so how do OpenGL and SDL get hold of it then? Is there an API call?
    Good class architecture is not like a Swiss Army Knife; it should be more like a well balanced throwing knife.

    - Mike McShaffry

  5. #5
    Call me AirBronto
    Join Date
    Sep 2004
    Location
    Indianapolis, Indiana
    Posts
    195
    i think you would need to do some assembly, but i really have no idea

  6. #6
    Supermassive black hole cboard_member's Avatar
    Join Date
    Jul 2005
    Posts
    1,709
    Quote Originally Posted by loopshot
    i think you would need to do some assembly, but i really have no idea
    I'm not sure. Using assembly would surely mean having to use API calls or interrupts.

    Someone must know. I don't need to know, I'm just interested.
    Good class architecture is not like a Swiss Army Knife; it should be more like a well balanced throwing knife.

    - Mike McShaffry

  7. #7
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,832
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  8. #8
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,598
    You cannot get a pointer to video memory in XP unless you are in the DOS emulator. Even in DJGPP 32-bit you cannot get a pointer to the Linear Frame Buffer or LFB by using a near pointer hack. The near pointer hack works under DOS and Windows 98SE, but not XP.

    To obtain a pointer to video memory in 16-bit DOS:

    Code:
    typedef unsigned char BYTE;
    
    BYTE far *pScreen=(BYTE far *)MK_FP(0xA000,0);
    
    BYTE far *Buffer=new BYTE[64000L];
    
    void Flip13h(BYTE far *pScreen,BYTE far *pBuffer)
    {
      //Wait for vertical retrace.
      //....while (!(inp(0x03DA))....  I forget the code sorry
    
      asm {
        les di,pScreen
        
        push ds
        lds si,pBuffer
        mov cx,32000d
        rep movsw
    
        pop ds
      }
    }
    I forget the wait for retrace code but it's still available on the net.

    You can gain access to the primary buffer and all buffers in Direct3D via the IDirect3DSurface9::Lock() method. I would not make use of this as it will result in degraded performance.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 07-11-2008, 08:39 AM
  2. buffer contents swapping
    By daluu in forum C++ Programming
    Replies: 7
    Last Post: 10-14-2004, 03:34 PM
  3. Tetris Questions
    By KneeGrow in forum Game Programming
    Replies: 19
    Last Post: 10-28-2003, 11:12 PM
  4. getline problem
    By Unregistered in forum C++ Programming
    Replies: 4
    Last Post: 10-06-2001, 10:28 AM
  5. Does anyone Know How to..?
    By kwigibo in forum C Programming
    Replies: 12
    Last Post: 09-20-2001, 09:16 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21