Thread: graphics

  1. #1
    Unregistered User Yarin's Avatar
    Join Date
    Jul 2007
    Posts
    2,158

    graphics

    Is there a way to directly access the monitor's output?
    I mean, to draw to the screen, you always have to use GDI, OGL, D3D, or somthing else, isn't there some way to forget about all that stuff? How does windows draw?

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    > How does windows draw?
    By providing many hundreds of hardware specific libraries for accessing any imaginable graphics card that can run with a windows compatible PC. All those libraries present the same interface to the layers above, so you get a nice set of interfaces which allow your code to run easily pretty much anywhere (if you use OpenGL).
    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.

  3. #3
    Banned
    Join Date
    Nov 2007
    Posts
    678
    Yarin, you can also use crayons that can draw properly on a glass surface!

  4. #4
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by Yarin View Post
    Is there a way to directly access the monitor's output?
    I mean, to draw to the screen, you always have to use GDI, OGL, D3D, or somthing else, isn't there some way to forget about all that stuff? How does windows draw?
    Sure, although you probably won't be able to use it very effectively, as the framebuffer that the graphics card gives you is not normally mapped into the memory space of the user-mode application, so you can't actually get to it. But assuming you write a suitable driver to map it into user space you could just write the relevant data into the right position of the framebuffer. Of course, the relevant position depends on the hardware provided - most modern graphics cards do not store pixels in the obvious order of 8 bits of Red, 8 bits Green, 8 bits Blue and 8 bits of Alpha, but rather stores some number of red data items, then the green, the blue and alpha data in their own separate "tiles".

    So you don't only need to know where the pixels are stored, but also how they are organized.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  5. #5
    Unregistered User Yarin's Avatar
    Join Date
    Jul 2007
    Posts
    2,158
    Ohj, I was under the impression that all the graphics cards use a specific reserved memory space, regardless of what kind it is.

  6. #6
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    In days of old when VGA memory was just that, and the processor did all the pixel bashing then having the memory in the same place was good.

    Modern cards usually (AFAIK) sit at the same address, but there's no reason to assume so. Also, many cards have many acceleration functions which are far quicker than letting the host processor bash away at the pixels one at a time.
    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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Turtle Graphics, how does it work?
    By freddyvorhees in forum C++ Programming
    Replies: 15
    Last Post: 08-28-2009, 09:57 AM
  2. Graphics Programming :: Approach and Books
    By kuphryn in forum Windows Programming
    Replies: 4
    Last Post: 05-11-2004, 08:33 PM
  3. egavga.bgi problem
    By sunil21 in forum A Brief History of Cprogramming.com
    Replies: 3
    Last Post: 09-22-2003, 05:06 PM
  4. Graphics Devices and Cprintf clash
    By etnies in forum C Programming
    Replies: 6
    Last Post: 05-09-2002, 11:14 AM