video.videodriver
Video driver base class.
- class VideoDriverException: object.Exception;
Exception thrown at video driver related errors.
- enum DrawMode;
Video driver draw modes.
Implementations do not need to support all draw modes, but must support at least one and be able to fall back to a supported draw mode.
- abstract class VideoDriver: monitor.monitorable.Monitorable;
Handles all drawing functionality.
- protected FontManager fontManager_;
FontManager used to work with fonts.
- this(FontManager fontManager);
Construct a VideoDriver.
Parameters:FontManager fontManager Font manager to use for font rendering and management. - void setVideoMode(const uint width, const uint height, const ColorFormat format, const bool fullscreen);
Sets video mode.
Parameters:Throws:uint width Video mode width in pixels; uint height Video mode height in pixels; ColorFormat format Video mode color format. bool fullscreen If true, use fullscreen, otherwise windowed. VideoDriverException on failure.- void startFrame();
Start drawing a frame.
Frame must not already be in progress. Must be called before any draw calls.
- void endFrame();
Finish drawing a frame. Must be called after startFrame.
- void scissor(ref const Recti scissorArea);
Enable scissor test using specified rectangle as scissor area.
Until the scissor test is disabled, only specified area of the screen will be drawn to. This can be used e.g. for 2D clipping of GUI elements.
Parameters:
Can only be called between startFrame and endFrame.Recti scissorArea Scissor area in screen coordinates. - void disableScissor();
Disable scissor test.
Can only be called between startFrame and endFrame.
- void drawLine(const Vector2f v1, const Vector2f v2, const Color c1, const Color c2);
Draw a line between specified points with specified colors.
Colors are interpolated from start to end of the line.
Parameters:
Can only be called between startFrame and endFrame.Vector2f v1 Start point of the line. Vector2f v2 End point of the line. Color c1 Color at the start point. Color c2 Color at the end point. - void drawLineStrip(const Vector2!(float)[] v, const Color c);
Draw a line strip through specified points with specified colors.
Can only be called between startFrame and endFrame.
Parameters:Vector2!(float)[] v Vertices of the strip. Color c Colors of the vertices. - void drawCircle(const Vector2f center, const float radius, const Color color, const uint vertexCount = 32);
Draw a stroked circle.
Can only be called between startFrame and endFrame.
Parameters:Vector2f center Center of the circle. float radius Radius of the circle. Color color Color of the circle stroke. uint vertexCount Number of vertices in the circle. - void drawRect(const Vector2f min, const Vector2f max, const Color color);
Draw a stroked rectangle.
Can only be called between startFrame and endFrame.
Parameters:Vector2f min Minimum extents of the rectangle. Vector2f max Maximum extents of the rectangle. Color color Color of the rectangle stroke. - void drawFilledRect(const Vector2f min, const Vector2f max, const Color color);
Draw a filled rectangle.
Can only be called between startFrame and endFrame.
Parameters:Vector2f min Minimum extents of the rectangle. Vector2f max Maximum extents of the rectangle. Color color Color of the rectangle. - void drawTexture(const Vector2i position, ref const Texture texture);
Draw a texture.
Can only be called between startFrame and endFrame.
Parameters:Vector2i position Position of the upper-left corner of the texture. Texture texture Texture to draw. - void drawText(const Vector2i position, const string text, const Color color = (Color).white);
Draw a text string.
Can only be called between startFrame and endFrame.
Parameters:Vector2i position Position to draw the text at. string text Text to draw. Color color Text color. - DrawMode drawMode(const DrawMode mode);
Set draw mode.
Not all implementations support all draw modes. If specified draw mode is not supported, video driver falls back to a supported draw mode. Draw mode actually applied is returned.
Parameters:
Must not be called between calls to startFrame and endFrame.Returns:DrawMode mode Draw mode to set. Draw mode that was actually set.- Vector2u textSize(const string text);
Get the size a text string would have if it was drawn.
Parameters:Returns:string text Text to measure. Size of the text in pixels.- @property void lineAA(const bool aa);
Set line antialiasing.
- @property void lineWidth(const float width);
Set line width.
- @property void font(const string fontName);
Set font to draw text with. If fontName is "default", default font will be used.
- @property void fontSize(const uint size);
Set font size to draw text with.
- @property void zoom(const real zoom);
- const @property real zoom();
- @property void viewOffset(const Vector2d offset);
Set view offset.
- const @property Vector2d viewOffset();
Get view offset.
- const @property uint screenWidth();
Get screen width.
- const @property uint screenHeight();
Get screen height.
- const uint maxTextureSize(const ColorFormat format);
Get maximum square texture size supported with specified color format.
Parameters:Returns:ColorFormat format Texture color format. Maximum square texture size supported with specified color format.- Texture createTexture(ref const Image image, const bool forcePage = false);
Create a texture from given image.
Parameters:Returns:Image image Image to create a texture from. bool forcePage Force the texture to be on a separate texture page? Handle to the created texture.Throws:TextureException if texture of needed size could not be created.- void deleteTexture(const Texture texture);
Delete a texture.
If deleted during a frame, this texture must not be used in drawing in that frame.
- void screenshot(ref Image image);
Capture a screenshot. Can't be called during an update.
Must not be called between calls to startFrame and endFrame.
Parameters: