Hehe... Yeah... Too much Wolfenstein gets boring =)
1) Clipping rectangle. Basically you can define the clipping rectangle and all rendering primitives will be clipped against this rectangle. The default rectangle is set to cover the entire size of the rendering target (surface). I am unsure how to properly explain this? Say you want to draw a line and one (or both) endpoint is outside the surface... The clipping rectangle will be used to properly cut the piece of line that will be visible. You can also use this to define where rendering is to take place on the surface. For example, SetClipping( Rect(10,10,40,40) will make this rectangle "drawable" and everything outside it won't be overdrawn by calls to the primitives.
2) Custom pixel shaders are used to define custom pixel blending effects. Say for example that you want to create an "Easy-CE infrared"-like effect: the idea is to only draw the RED channel of the color. You would first define a pixel shader:
- Code:
struct InfraredShader : public PixelShader
{
Pixel operator()( Pixel src, Pixel dest ) const
{
return (src & RED_MASK);
}
};
Then you hand this to the rasterizer:
- Code:
InfraredShader ir_shader;
GetDisplay()->SetPixelShader( &ir_shader );
Try it in the GameInit() function of the Blit() sample and you will see all rendering becoming red (the green/blue channels are dropped).
The PixelShader accepts two parameter: "src" and "dest" color. Basically, "src" is the source color specified to the primitive (line, circle, ...) and "dest" is the color already in the rendering target (backbuffer). The value returned is the final color that will be output to the rendering buffer.
The custom pixel shader is a really strong feature that begs to be exploited.
3) Saving a surface is as simple as calling the SaveImage() function. You specify the surface and the filename. For example, if you want to take a screenshot of your game, you would use:
- Code:
SaveImage( GetDisplay()->GetBackBuffer(), _T("screen001.bmp") );
And voila! A screen shot named "screen001.bmp" will be created. By default, it will be placed in the same directory as your executable. If you want it somewhere else, you can specify the fullpath.
Hope this helps! I'm looking forward to your next articles!
Thierry