ERY.AgateLib.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 DrawRect (Rectangle 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 DisableLighting ()
 Turns lighting functions off.

Static Public Attributes

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

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.


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.

        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 ERY.AgateLib.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 ERY.AgateLib.Display.Dispose (  )  [static]

Disposes of the display.

delegate void ERY.AgateLib.Display.DisposeDisplayHandler (  ) 

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

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

Clears the buffer to black.

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

Clears the buffer to the specified color.

Parameters:
a Alpha value
b Blue value
g Green value
r Red value

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

Clears the buffer to the specified color.

Parameters:
color 

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

Clears the buffer to the specified color.

Parameters:
color 

static void ERY.AgateLib.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 
dest 

static void ERY.AgateLib.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 ERY.AgateLib.Display.BeginFrame (  )  [static]

Must be called at the start of each frame.

static void ERY.AgateLib.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 void ERY.AgateLib.Display.SetDeltaTime ( double  deltaTime  )  [static]

Provides a means to set the value returned by DeltaTime.

Parameters:
deltaTime 

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

Set the current clipping rect.

Parameters:
newClipRect 

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

Pushes a clip rect onto the clip rect stack.

Parameters:
newClipRect 

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

Pops the clip rect and restores the previous clip rect.

static void ERY.AgateLib.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 ScreenMode [] ERY.AgateLib.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 ERY.AgateLib.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 ERY.AgateLib.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 

static void ERY.AgateLib.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 ERY.AgateLib.Display.DrawEllipse ( Rectangle  rect,
Color  color 
) [static]

Draws an ellispe within the specified rectangle.

Parameters:
rect 
color 

static void ERY.AgateLib.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 ERY.AgateLib.Display.DrawLine ( Point  a,
Point  b,
Color  color 
) [static]

Draws a line between the two points specified.

Parameters:
a 
b 
color 

static void ERY.AgateLib.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 ERY.AgateLib.Display.DrawRect ( Rectangle  rect,
Color  color 
) [static]

Draws the outline of a rectangle.

Parameters:
rect 
color 

static void ERY.AgateLib.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 ERY.AgateLib.Display.FillRect ( Rectangle  rect,
Color  color 
) [static]

Draws a filled rectangle.

Parameters:
rect 
color 

static void ERY.AgateLib.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 ERY.AgateLib.Display.DisableLighting (  )  [static]

Turns lighting functions off.


Member Data Documentation

event DisposeDisplayHandler ERY.AgateLib.Display.DisposeDisplay [static]

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


Property Documentation

DisplayImpl ERY.AgateLib.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.

PixelFormat ERY.AgateLib.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.

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

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

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

Gets the last render target used which was a DisplayWindow.

double ERY.AgateLib.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.

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

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

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

Gets the framerate.

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

Returns the maximum size a surface object can be.

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

Gets the object which handles packing of all surfaces.

bool ERY.AgateLib.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.

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

Gets the capabilities of the Display object.


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