AgateLib.DisplayLib.Display Class Reference

Static class which contains all basic functions for drawing onto the Display. This class is most central to game rendering. At the beginning and end of each frame Display.BeginFrame() and Display.EndFrame() must be called. All drawing calls must occur between BeginFrame and EndFrame. More...

List of all members.

Public Member Functions

delegate void DisposeDisplayHandler ()
 Delegate type for functions which are called when Display.Dispose is called at the end of execution of the program.

Static Public Member Functions

static void Initialize (DisplayTypeID displayType)
 Initializes the display by instantiating the driver with the given DisplayTypeID. The display driver must be registered with the Registrar class.
static void Dispose ()
 Disposes of the Display.
static void Clear ()
 Clears the buffer to black.
static void Clear (byte a, byte r, byte g, byte b)
 Clears the buffer to the specified color.
static void Clear (Color color)
 Clears the buffer to the specified color.
static void Clear (int color)
 Clears the buffer to the specified color.
static void Clear (Color color, Rectangle dest)
 Clears a region of the buffer to the specified color. Should be essentially the same as DrawRect(dest, color), except that alpha is not significant in the use of Clear.
static void Clear (int color, Rectangle dest)
 Clears a region of the buffer to the specified color. Should be essentially the same as DrawRect(dest, color), except that alpha is not significant in the use of Clear.
static void BeginFrame ()
 Must be called at the start of each frame.
static void EndFrame ()
 EndFrame must be called at the end of each frame. By default, this waits for the vertical blank before rendering. However, some renderers (ie. System.Drawing) may not support that.
static void SetDeltaTime (double deltaTime)
 Provides a means to set the value returned by DeltaTime.
static void SetClipRect (Rectangle newClipRect)
 Set the current clipping rect.
static void PushClipRect (Rectangle newClipRect)
 Pushes a clip rect onto the clip rect stack.
static void PopClipRect ()
 Pops the clip rect and restores the previous clip rect.
static void PackAllSurfaces ()
 Takes all surfaces and packs them into a large surface. This should minimize swapping of surfaces, and may result in a performance increase when using Direct3D or OpenGL.
static ScreenMode[] EnumScreenModes ()
 Returns an array containing information about all available full-screen modes. If full screen mode switching is not supported, the array returned has a Length of zero.
static void FlushDrawBuffer ()
 When using Direct3D or OpenGL, calls to Surface.Draw are cached to be sent to the 3D API all as a batch. Calling Display.FlushDrawBuffer forces all cached vertices to be sent to the rendering system. You should not need to call this function in normal operation of your application.
static void SetOrthoProjection (int left, int top, int right, int bottom)
 Sets the orthogonal projection for rendering. This allows redefinition of the coordinates used to address pixels in the window.
static void SetOrthoProjection (Rectangle region)
 Sets the orthogonal projection for rendering. This allows redefinition of the coordinates used to address pixels in the window.
static void DrawEllipse (Rectangle rect, Color color)
 Draws an ellispe within the specified rectangle.
static void DrawLine (int x1, int y1, int x2, int y2, Color color)
 Draws a line between the two points specified.
static void DrawLine (Point a, Point b, Color color)
 Draws a line between the two points specified.
static void DrawLines (Point[] pts, Color color)
 Draws a bunch of connected lines. The last point and the first point are not connected.
static void DrawLineSegments (Point[] pts, Color color)
 Draws a bunch of line segments. Each pair of points represents a line segment which is drawn. No connections between the line segments are made, so there must be an even number of points.
static void DrawRect (Rectangle rect, Color color)
 Draws the outline of a rectangle.
static void DrawRect (RectangleF rect, Color color)
 Draws the outline of a rectangle.
static void DrawRect (int x, int y, int width, int height, Color color)
 Draws the outline of a rectangle.
static void FillRect (Rectangle rect, Color color)
 Draws a filled rectangle.
static void FillRect (int x, int y, int width, int height, Color color)
 Draws a filled rectangle.
static void FillRect (Rectangle rect, Gradient color)
 Draws a filled rectangle with a gradient.
static void FillRect (int x, int y, int width, int height, Gradient color)
 Draws a filled rectangle with a gradient.
static void FillRect (RectangleF rect, Color color)
 Draws a filled rectangle.
static void FillRect (RectangleF rect, Gradient color)
 Draws a filled rectangle with a gradient.
static void DisableLighting ()
 Turns lighting functions off.

Properties

static DisplayImpl Impl [get]
 Gets the object which handles all of the actual calls to Display functions. This may be cast to a surface object in whatever rendering library is being used (eg. if using the MDX_1_1 library, this can be cast to an MDX1_Display object). You only need to use this if you want to access features which are specific to the graphics library you're using.
static PixelFormat DefaultSurfaceFormat [get]
 Returns the PixelFormat of Surfaces which are created to be compatible with the display mode. If you want to create a PixelBuffer which does not require a conversion when written to a Surface, use this format.
static IRenderTarget RenderTarget [get, set]
 Gets or sets the current render target. Must be called outside of BeginFrame..EndFrame blocks (usually just before BeginFrame).
static DisplayWindow CurrentWindow [get]
 Gets the last render target used which was a DisplayWindow.
static double AlphaThreshold [get, set]
 Gets or sets the threshold value for alpha transparency below which pixels are considered completely transparent, and may not be drawn. Acceptable values are within the range of 0 to 1.
static double DeltaTime [get]
 Gets the amount of time in milliseconds that has passed between this frame and the last one.
static double FramesPerSecond [get]
 Gets the framerate.
static Size MaxSurfaceSize [get]
 Returns the maximum size a surface object can be.
static SurfacePacker SurfacePacker [get]
 Gets the object which handles packing of all surfaces.
static bool VSync [get, set]
 Gets or sets the VSync flag. If VSync is off, tearing might occur. If VSync is on, the framerate will be capped at the monitor's refresh rate.
static IDisplayCaps Caps [get]
 Gets the capabilities of the Display object.

Events

static DisposeDisplayHandler DisposeDisplay
 Event that is called when Display.Dispose() is invoked, to shut down the display system and release all resources.


Detailed Description

Static class which contains all basic functions for drawing onto the Display. This class is most central to game rendering. At the beginning and end of each frame Display.BeginFrame() and Display.EndFrame() must be called. All drawing calls must occur between BeginFrame and EndFrame.

Display.Dispose() must be called before the program exits.

This example shows how a basic render loop works.

            // These usings should be at the top.
            using AgateLib;
            using AgateLib.DisplayLib;

            void MyRenderLoop()
            {
                Display.BeginFrame();
                Display.Clear(Color.Black);

                Display.DrawRect(new Rectangle(10, 10, 30, 30), Color.Red);

                Display.EndFrame();
                Core.KeepAlive();
            }

Member Function Documentation

static void AgateLib.DisplayLib.Display.BeginFrame (  )  [static]

Must be called at the start of each frame.

static void AgateLib.DisplayLib.Display.Clear ( int  color,
Rectangle  dest 
) [static]

Clears a region of the buffer to the specified color. Should be essentially the same as DrawRect(dest, color), except that alpha is not significant in the use of Clear.

Parameters:
color 
dest 

static void AgateLib.DisplayLib.Display.Clear ( Color  color,
Rectangle  dest 
) [static]

Clears a region of the buffer to the specified color. Should be essentially the same as DrawRect(dest, color), except that alpha is not significant in the use of Clear.

Parameters:
color Color to clear to.
dest Destination rectangle to clear.

static void AgateLib.DisplayLib.Display.Clear ( int  color  )  [static]

Clears the buffer to the specified color.

Parameters:
color 32-bit integer indicating the color. The color will be constructed from Color.FromArgb.

static void AgateLib.DisplayLib.Display.Clear ( Color  color  )  [static]

Clears the buffer to the specified color.

Parameters:
color 

static void AgateLib.DisplayLib.Display.Clear ( byte  a,
byte  r,
byte  g,
byte  b 
) [static]

Clears the buffer to the specified color.

Parameters:
a Alpha value, between 0 and 255.
b Blue value, between 0 and 255.
g Green value, between 0 and 255.
r Red value, between 0 and 255.

static void AgateLib.DisplayLib.Display.Clear (  )  [static]

Clears the buffer to black.

static void AgateLib.DisplayLib.Display.DisableLighting (  )  [static]

Turns lighting functions off.

static void AgateLib.DisplayLib.Display.Dispose (  )  [static]

Disposes of the Display.

delegate void AgateLib.DisplayLib.Display.DisposeDisplayHandler (  ) 

Delegate type for functions which are called when Display.Dispose is called at the end of execution of the program.

static void AgateLib.DisplayLib.Display.DrawEllipse ( Rectangle  rect,
Color  color 
) [static]

Draws an ellispe within the specified rectangle.

Parameters:
rect 
color 

static void AgateLib.DisplayLib.Display.DrawLine ( Point  a,
Point  b,
Color  color 
) [static]

Draws a line between the two points specified.

Parameters:
a 
b 
color 

static void AgateLib.DisplayLib.Display.DrawLine ( int  x1,
int  y1,
int  x2,
int  y2,
Color  color 
) [static]

Draws a line between the two points specified.

Parameters:
x1 
y1 
x2 
y2 
color 

static void AgateLib.DisplayLib.Display.DrawLines ( Point[]  pts,
Color  color 
) [static]

Draws a bunch of connected lines. The last point and the first point are not connected.

Parameters:
pts 
color 

static void AgateLib.DisplayLib.Display.DrawLineSegments ( Point[]  pts,
Color  color 
) [static]

Draws a bunch of line segments. Each pair of points represents a line segment which is drawn. No connections between the line segments are made, so there must be an even number of points.

Parameters:
pts 
color 

static void AgateLib.DisplayLib.Display.DrawRect ( int  x,
int  y,
int  width,
int  height,
Color  color 
) [static]

Draws the outline of a rectangle.

Parameters:
x 
y 
width 
height 
color 

static void AgateLib.DisplayLib.Display.DrawRect ( RectangleF  rect,
Color  color 
) [static]

Draws the outline of a rectangle.

Parameters:
rect 
color 

static void AgateLib.DisplayLib.Display.DrawRect ( Rectangle  rect,
Color  color 
) [static]

Draws the outline of a rectangle.

Parameters:
rect 
color 

static void AgateLib.DisplayLib.Display.EndFrame (  )  [static]

EndFrame must be called at the end of each frame. By default, this waits for the vertical blank before rendering. However, some renderers (ie. System.Drawing) may not support that.

static ScreenMode [] AgateLib.DisplayLib.Display.EnumScreenModes (  )  [static]

Returns an array containing information about all available full-screen modes. If full screen mode switching is not supported, the array returned has a Length of zero.

Returns:
An array of available full-screen modes.

static void AgateLib.DisplayLib.Display.FillRect ( RectangleF  rect,
Gradient  color 
) [static]

Draws a filled rectangle with a gradient.

Parameters:
rect 
color 

static void AgateLib.DisplayLib.Display.FillRect ( RectangleF  rect,
Color  color 
) [static]

Draws a filled rectangle.

Parameters:
rect 
color 

static void AgateLib.DisplayLib.Display.FillRect ( int  x,
int  y,
int  width,
int  height,
Gradient  color 
) [static]

Draws a filled rectangle with a gradient.

Parameters:
x 
y 
width 
height 
color 

static void AgateLib.DisplayLib.Display.FillRect ( Rectangle  rect,
Gradient  color 
) [static]

Draws a filled rectangle with a gradient.

Parameters:
rect 
color 

static void AgateLib.DisplayLib.Display.FillRect ( int  x,
int  y,
int  width,
int  height,
Color  color 
) [static]

Draws a filled rectangle.

Parameters:
x 
y 
width 
height 
color 

static void AgateLib.DisplayLib.Display.FillRect ( Rectangle  rect,
Color  color 
) [static]

Draws a filled rectangle.

Parameters:
rect 
color 

static void AgateLib.DisplayLib.Display.FlushDrawBuffer (  )  [static]

When using Direct3D or OpenGL, calls to Surface.Draw are cached to be sent to the 3D API all as a batch. Calling Display.FlushDrawBuffer forces all cached vertices to be sent to the rendering system. You should not need to call this function in normal operation of your application.

static void AgateLib.DisplayLib.Display.Initialize ( DisplayTypeID  displayType  )  [static]

Initializes the display by instantiating the driver with the given DisplayTypeID. The display driver must be registered with the Registrar class.

It is recommended that you instantiate a SetupDisplay object from within a using block, to ensure that the Display is disposed of properly.

Parameters:
displayType 

static void AgateLib.DisplayLib.Display.PackAllSurfaces (  )  [static]

Takes all surfaces and packs them into a large surface. This should minimize swapping of surfaces, and may result in a performance increase when using Direct3D or OpenGL.

If you use this, it is best to load all your surfaces into memory, mark any you don't want packed (surfaces which may be used as render targets, for example), then call Display.PackAllSurfaces().

static void AgateLib.DisplayLib.Display.PopClipRect (  )  [static]

Pops the clip rect and restores the previous clip rect.

static void AgateLib.DisplayLib.Display.PushClipRect ( Rectangle  newClipRect  )  [static]

Pushes a clip rect onto the clip rect stack.

Parameters:
newClipRect 

static void AgateLib.DisplayLib.Display.SetClipRect ( Rectangle  newClipRect  )  [static]

Set the current clipping rect.

Parameters:
newClipRect 

static void AgateLib.DisplayLib.Display.SetDeltaTime ( double  deltaTime  )  [static]

Provides a means to set the value returned by DeltaTime.

Parameters:
deltaTime 

static void AgateLib.DisplayLib.Display.SetOrthoProjection ( Rectangle  region  )  [static]

Sets the orthogonal projection for rendering. This allows redefinition of the coordinates used to address pixels in the window.

[Experimental - This member is not fully tested and may have bugs. The API is also likely to change in the future.]

Normally, the orthogonal projection used is set to (left, top) = (0,0), (right,bottom) = (RenderTarget.Width, RenderTarget.Height). This function provides a handy way to program an application for multiple resolutions. For example, if you set the OrthoProjection to (0,0,640,480), then all drawing calls can be made as if you were drawing to a 640x480 window, but they would be scaled to fill the entire window.

Parameters:
region 

static void AgateLib.DisplayLib.Display.SetOrthoProjection ( int  left,
int  top,
int  right,
int  bottom 
) [static]

Sets the orthogonal projection for rendering. This allows redefinition of the coordinates used to address pixels in the window.

[Experimental - This member is not fully tested and may have bugs. The API is also likely to change in the future.]

Normally, the orthogonal projection used is set to (left, top) = (0,0), (right,bottom) = (RenderTarget.Width, RenderTarget.Height). This function provides a handy way to program an application for multiple resolutions. For example, if you set the OrthoProjection to (0,0,640,480), then all drawing calls can be made as if you were drawing to a 640x480 window, but they would be scaled to fill the entire window.

Parameters:
left 
top 
right 
bottom 


Property Documentation

double AgateLib.DisplayLib.Display.AlphaThreshold [static, get, set]

Gets or sets the threshold value for alpha transparency below which pixels are considered completely transparent, and may not be drawn. Acceptable values are within the range of 0 to 1.

IDisplayCaps AgateLib.DisplayLib.Display.Caps [static, get]

Gets the capabilities of the Display object.

DisplayWindow AgateLib.DisplayLib.Display.CurrentWindow [static, get]

Gets the last render target used which was a DisplayWindow.

PixelFormat AgateLib.DisplayLib.Display.DefaultSurfaceFormat [static, get]

Returns the PixelFormat of Surfaces which are created to be compatible with the display mode. If you want to create a PixelBuffer which does not require a conversion when written to a Surface, use this format.

double AgateLib.DisplayLib.Display.DeltaTime [static, get]

Gets the amount of time in milliseconds that has passed between this frame and the last one.

double AgateLib.DisplayLib.Display.FramesPerSecond [static, get]

Gets the framerate.

DisplayImpl AgateLib.DisplayLib.Display.Impl [static, get]

Gets the object which handles all of the actual calls to Display functions. This may be cast to a surface object in whatever rendering library is being used (eg. if using the MDX_1_1 library, this can be cast to an MDX1_Display object). You only need to use this if you want to access features which are specific to the graphics library you're using.

Size AgateLib.DisplayLib.Display.MaxSurfaceSize [static, get]

Returns the maximum size a surface object can be.

IRenderTarget AgateLib.DisplayLib.Display.RenderTarget [static, get, set]

Gets or sets the current render target. Must be called outside of BeginFrame..EndFrame blocks (usually just before BeginFrame).

SurfacePacker AgateLib.DisplayLib.Display.SurfacePacker [static, get]

Gets the object which handles packing of all surfaces.

bool AgateLib.DisplayLib.Display.VSync [static, get, set]

Gets or sets the VSync flag. If VSync is off, tearing might occur. If VSync is on, the framerate will be capped at the monitor's refresh rate.


Event Documentation

DisposeDisplayHandler AgateLib.DisplayLib.Display.DisposeDisplay [static]

Event that is called when Display.Dispose() is invoked, to shut down the display system and release all resources.


The documentation for this class was generated from the following file:
AgateLib
Awesome Game and Tool Engine Library
SourceForge.net Logo