I have read a number of tutorials on DirectX, but there is always one thing holding me back from grasping the API. What (exacly, technically, and realistically) is a surface?
I have read a number of tutorials on DirectX, but there is always one thing holding me back from grasping the API. What (exacly, technically, and realistically) is a surface?
"If you tell the truth, you don't have to remember anything"
-Mark Twain
They represent areas of memory that hold graphics. The following
explanation is from "Tricks of the Windows Game Programming
Gurus."
They're rectangular regions of memory that can hold bitmap data.
There are two kinds of surfaces: primary and secondary. A
Primary Surface directly corresponds to the actual video memory
being rasterized by the video card and is visible at all times. Hence,
you will only have one primary surface, and it refers directly to the
screen image and usually resides in VRAM. When you manipulate
it, you see the results instantly on the screen. If you set the
video mode to 640x480x256, you must create a primary surface
that is also 640x480x456 and then attach it to the display device.
So, you have a primary surface that represents the screen; then
you can have a secondary surface that acts as a double buffer
that you draw to, then copy to the primary surface. Or you can
use a secondary surface to hold your actual bitmaps images,
this way you can use hardware acceleration on your graphics.
A surface is just a great block of data thats filled with image data. Depending on how its used or where it is, it can be hardware accelerated. Thats about it.
For some reason MS always feels the need to invent a new dictionary every time they program an API or application. There is an 'official' name for everything - but don't let it scare you - once you get past the semantics the API is very easy to use.
But, I feel your pain.
primary surfaces don't always represent JUST the screen.
*All hail OpenGL*