Can explain when will we use Overlay?

Started by
3 comments, last by wah_on_2 22 years, 3 months ago
If i have a map, that make up with 2 layers call background image(e.g, wall, tree root...) and background object(e.g, desk, flower..) Should i make 2 sets of overlay? I know overlay is machine dependent, when will we use overlay that will valueable? Please explain. Thanks!
Advertisement
Let me explain,

Without overlays, this is what happens,

1) A graphics card has a "screen" of colors to be drawn every single refresh of the monitor. This is called the frame buffer.

2) Between the frame buffer (video memory to be displayed) and the program you are writing is the graphics card rendering CPU and the DirectX pipeline.

a. DirectX Pipeline... This will take the polygons from 3D space (x,y,z) and convert it to 2D (x,y)... You can specify in DX to write your program in 3D or 2D... This is called "Transformed and untransformed vertices." You can still write 2D games or 2D programs using DirectX D3D in DX8.0+ by using the right kind of vertices.

b. Since the video card is doing everything in 2D (since monitors aren''t 3D). DirectX then takes the 2D polygons (no matter if you are transformed or untransformed, DX will always sent to graphics card as 2D - it will do the converting internally as it is needed - you can even blend DX programs to use both) and tells the graphics card to draw this triangle (in 2D) and put this texture (scaling it to appear 3D) and the graphics card does. It takes these commands from DirectX and applies these commands to the frame buffer.

Now when the refresh occurs, the objects are displayed. Wa la!

3) Now an overlay is another thing entirely, and you will see why they are not used or supported often.

When the framebuffer is being sent to the monitor, and overlay is a seperate "mask" completely independant from the framebuffer... It has its own depth, its own resolution, etc.

The overlay processor will merge the 2 things together, pixels not written to in the overlay mask will be transparent.

Lets say we have a Framebuffer of 640x480... And an overlay buffer of 320x240... When nothing is written to the overlay its transparent. Write pixels to the overlay, they go directly ontop of the framebuffer. They are not removed until you clear the overlay. The stuff in the overlay will look on the screen 320x240 resolution while the stuff under the overlay is normal 640x480... They are completely independant... Monitor refresh rate, etc is based off framebuffer.

Whats unique is the windows and direct3d work directly with the framebuffer. If you have your Windows in 256 colors, everything will be 256. But if the overlay is 16 million colors, its 16 million colors =) They are completely independant...

So that means, when you start writing pixels to the overlay, they go ontop of EVERYTHING, no matter what... You shutdown your program without clearing the overlay. The overlay is still on the screen, while your program is shut down... Windows will erase the framebuffer and draw its windows back onto it... (task bar etc) but overlay is seperate and will be drawn on the monitor no matter what.

The statistics on overlay is graphics card dependant. Some might not have an overlay at all. Some might be different resolutions/sizes (they can''t change), and Windows does NOT interact with it...

But they are super fast since they are very bare-bones processor that don''t do much...

----

Any normal program should not use Overlay... Overlays should only be used for special purpose programs that have to run on specific hardware. And you won''t get to page-flip or have a back buffer with them (the only commands they usually support, pixel on/off and color)

And the effects are displayed as the monitor refreshes.

But it all depends on the overlay processor for the graphics card... =) Some might support alpha or lines, or squares, or whatever... Who knows, thats the problem. Most cards probably don''t even bother to support them since windows and directx only usually deal with framebuffer.
wow......I am a beginner in DX. Thanks your explaination.

But if i do not use overlay, i will draw all the things(i mean the background image and object) for a small chnage(a flower was shake by wind)

Or, there have another methods to do that(2 layers effect)?
Yes,

Normally, when rendering, you have to redraw all objects on the screen every single time you want the screen to change.

Everytime the flower changes, you have to clear the screen, draw the wall then draw the new flower ontop of wall.

There are things you can do to speed things up. Like draw the wall, take a picture of the wall that is around the flower (smaller than the entire wall.) Paint the flower... Then when you want to change just the flower, paint your smaller wall pic there (without any flower at all) and the new flower picture ontop of that.

But thats when programming starts to get tedious. It''s easier to just redraw the entire thing if doesn''t slow down too much. =)
oic.

yes, just redraw the changed area is a good idea. Thanks a lot of. ^^

This topic is closed to new replies.

Advertisement