ENGINE::GraphicsDeviceSingleton Class Reference

#include <GraphicsDevice.h>

Collaboration diagram for ENGINE::GraphicsDeviceSingleton:

Collaboration graph
[legend]

List of all members.


Detailed Description

Interface to the physical graphics device; The screen.

Author:
Richard Marks <ccpsceo@gmail.com>
This class is implemented as a Singleton class, since there should never be a need for multiple graphics devices. Multi-monitor support is not available in this engine.
There is a MACRO defined called GraphicsDevice that is just an alias to calling the GraphicsDeviceSingleton::GetInstance() function which returns a pointer to the singleton instance. There are several shortcut functions that give an easier to use interface such as the GraphicsDeviceSingleton::GetDisplayWidth() and GraphicsDeviceSingleton::GetDisplayHeight() functions will handle obtaining the values from the ENGINE::ImageResource class for you.

The first thing you should do is call the GraphicsDeviceSingleton::SetDisplayMode(), GraphicsDeviceSingleton::SetDisplayResolution(), GraphicsDeviceSingleton::SetDisplayColorDepth() functions to setup the graphics device. This needs to be done before you start drawing things.

The general idea is that you use the GraphicsDeviceSingleton::BeginScene() function to clear the scene, and then you call the GraphicsDeviceSingleton::GetSecondaryDisplayBuffer() function to get a pointer to the secondary display buffer, and you do all your drawing of your scene onto this, then you use the GraphicsDeviceSingleton::EndScene() function to copy the contents of the scene to the visible screen so that your scene is shown to the user.

Definition at line 79 of file GraphicsDevice.h.


Public Member Functions

void BeginScene (int color=0)
void EndScene ()
bool SetDisplayMode (GraphicsDeviceDisplayMode mode=GraphicsDevice_Windowed)
void SetDisplayResolution (int displayWidth, int displayHeight)
void SetDisplayColorDepth (GraphicsDeviceDisplayDepth bitsPerPixel=GraphicsDevice_16bit)
bool SetDisplay (int displayWidth, int displayHeight, GraphicsDeviceDisplayDepth bitsPerPixel, GraphicsDeviceDisplayMode mode)
GraphicsDeviceDisplayMode GetDisplayMode ()
int GetDisplayWidth ()
int GetDisplayHeight ()
GraphicsDeviceDisplayDepth GetDisplayBitsPerPixel ()
ImageResourceGetPrimaryDisplayBuffer ()
ImageResourceGetSecondaryDisplayBuffer ()
 ~GraphicsDeviceSingleton ()
void Destroy ()

Static Public Member Functions

static GraphicsDeviceSingletonGetInstance ()

Private Member Functions

 GraphicsDeviceSingleton ()
 GraphicsDeviceSingleton (const GraphicsDeviceSingleton &rhs)
const GraphicsDeviceSingletonoperator= (const GraphicsDeviceSingleton &rhs)

Private Attributes

ImageResourceprimaryDisplayBuffer_
 a pointer to an ImageResource that serves as the physical screen buffer
ImageResourcesecondaryDisplayBuffer_
 a pointer to an ImageResource that serves as the back-buffer that all drawing should be done on
GraphicsDeviceDisplayMode displayMode_
 the current state of the display mode. Windowed or Fullscreen.
int displayWidth_
 the display resolution width in pixels
int displayHeight_
 the display resolution height in pixels
GraphicsDeviceDisplayDepth displayBitsPerPixel_
 the color depth of the display

Constructor & Destructor Documentation

ENGINE::GraphicsDeviceSingleton::~GraphicsDeviceSingleton (  ) 

makes a call to the GraphicsDeviceSingleton::Destroy() function to de-allocate the allocated memory

Definition at line 231 of file GraphicsDevice.cpp.

ENGINE::GraphicsDeviceSingleton::GraphicsDeviceSingleton (  )  [private]

constructor is hidden because this is a singleton class

Definition at line 218 of file GraphicsDevice.cpp.

ENGINE::GraphicsDeviceSingleton::GraphicsDeviceSingleton ( const GraphicsDeviceSingleton rhs  )  [private]

copy constructor is hidden because this class cannot be copied


Member Function Documentation

GraphicsDeviceSingleton * ENGINE::GraphicsDeviceSingleton::GetInstance (  )  [static]

Returns:
a pointer to the graphics device singleton class instance

Definition at line 35 of file GraphicsDevice.cpp.

void ENGINE::GraphicsDeviceSingleton::BeginScene ( int  color = 0  ) 

Fills the entire secondary display buffer with the specified color. Calling without any parameters will fill with BLACK.

Parameters:
color is the color to fill the image with. Get an int value for an RGB color using using Allegro's makecol(red,green,blue) function. The default is BLACK

Definition at line 44 of file GraphicsDevice.cpp.

References ENGINE::ImageResource::Clear(), LogFatal, primaryDisplayBuffer_, and secondaryDisplayBuffer_.

Here is the call graph for this function:

void ENGINE::GraphicsDeviceSingleton::EndScene (  ) 

Flips the secondary display buffer to the primary display buffer so that the user can see the scene.

Definition at line 57 of file GraphicsDevice.cpp.

References ENGINE::ImageResource::Blit(), displayHeight_, displayWidth_, LogFatal, primaryDisplayBuffer_, and secondaryDisplayBuffer_.

Here is the call graph for this function:

bool ENGINE::GraphicsDeviceSingleton::SetDisplayMode ( GraphicsDeviceDisplayMode  mode = GraphicsDevice_Windowed  ) 

Attempts to set the display mode to either fullscreen or windowed modes. This function requires that the display resolution and color depth have already been set.

Parameters:
mode can be GraphicsDevice_Windowed or GraphicsDevice_Fullscreen
Returns:
true on success, false on failure

Definition at line 70 of file GraphicsDevice.cpp.

References Destroy(), displayBitsPerPixel_, displayHeight_, displayMode_, displayWidth_, ENGINE::GraphicsDevice_Fullscreen, ENGINE::GraphicsDevice_Windowed, LogFatal, primaryDisplayBuffer_, and secondaryDisplayBuffer_.

Referenced by SetDisplay().

Here is the call graph for this function:

Here is the caller graph for this function:

void ENGINE::GraphicsDeviceSingleton::SetDisplayResolution ( int  displayWidth,
int  displayHeight 
)

Attempts to set the display resolution. This function requires that the display color depth have already been set.

Parameters:
displayWidth is the width of the display resolution in pixels.
displayHeight is the height of the display resolution in pixels.

Definition at line 118 of file GraphicsDevice.cpp.

References displayHeight_, and displayWidth_.

Referenced by SetDisplay().

Here is the caller graph for this function:

void ENGINE::GraphicsDeviceSingleton::SetDisplayColorDepth ( GraphicsDeviceDisplayDepth  bitsPerPixel = GraphicsDevice_16bit  ) 

Attempts to set the display color depth. When called with no parameter, the default of 16 bits per pixel is used.

Parameters:
bitsPerPixel is the color depth. Possible values are GraphicsDevice_8bit, GraphicsDevice_16bit, GraphicsDevice_24bit, and GraphicsDevice_32bit

Definition at line 126 of file GraphicsDevice.cpp.

References displayBitsPerPixel_, ENGINE::GraphicsDevice_15bit, ENGINE::GraphicsDevice_16bit, ENGINE::GraphicsDevice_24bit, ENGINE::GraphicsDevice_32bit, and ENGINE::GraphicsDevice_8bit.

Referenced by SetDisplay().

Here is the caller graph for this function:

bool ENGINE::GraphicsDeviceSingleton::SetDisplay ( int  displayWidth,
int  displayHeight,
GraphicsDeviceDisplayDepth  bitsPerPixel,
GraphicsDeviceDisplayMode  mode 
)

Attempts to setup the display resolution, color depth, and mode by calling the single SetDisplay functions.

See also:
GraphicsDeviceSingleton::SetDisplayResolution(), GraphicsDeviceSingleton::SetDisplayColorDepth(), GraphicsDeviceSingleton::SetDisplayMode()
Parameters:
displayWidth is the width of the display resolution in pixels.
displayHeight is the height of the display resolution in pixels.
bitsPerPixel is the color depth. Possible values are GraphicsDevice_8bit, GraphicsDevice_16bit, GraphicsDevice_24bit, and GraphicsDevice_32bit
mode can be GraphicsDevice_Windowed or GraphicsDevice_Fullscreen
Returns:
true on success, false on failure

Definition at line 146 of file GraphicsDevice.cpp.

References SetDisplayColorDepth(), SetDisplayMode(), and SetDisplayResolution().

Here is the call graph for this function:

GraphicsDeviceDisplayMode ENGINE::GraphicsDeviceSingleton::GetDisplayMode (  ) 

Get the state of the display mode, its going to be either windowed, or fullscreen.

Returns:
the current value of GraphicsDeviceSingleton::displayMode_

Definition at line 159 of file GraphicsDevice.cpp.

References displayMode_.

int ENGINE::GraphicsDeviceSingleton::GetDisplayWidth (  ) 

Returns:
the display width in pixels

Definition at line 166 of file GraphicsDevice.cpp.

References displayWidth_.

int ENGINE::GraphicsDeviceSingleton::GetDisplayHeight (  ) 

Returns:
the display height in pixels

Definition at line 173 of file GraphicsDevice.cpp.

References displayHeight_.

GraphicsDeviceDisplayDepth ENGINE::GraphicsDeviceSingleton::GetDisplayBitsPerPixel (  ) 

Get the color depth of the display

Returns:
the current value of GraphicsDeviceSingleton::displayBitsPerPixel_

Definition at line 180 of file GraphicsDevice.cpp.

References displayBitsPerPixel_.

ImageResource * ENGINE::GraphicsDeviceSingleton::GetPrimaryDisplayBuffer (  ) 

Get a pointer to the primary display buffer

Returns:
GraphicsDeviceSingleton::primaryDisplayBuffer_ or 0 if the display has not been setup

Definition at line 187 of file GraphicsDevice.cpp.

References primaryDisplayBuffer_.

ImageResource * ENGINE::GraphicsDeviceSingleton::GetSecondaryDisplayBuffer (  ) 

Get a pointer to the secondary display buffer

Returns:
GraphicsDeviceSingleton::secondaryDisplayBuffer_ or 0 if the display has not been setup

Definition at line 194 of file GraphicsDevice.cpp.

References secondaryDisplayBuffer_.

void ENGINE::GraphicsDeviceSingleton::Destroy (  ) 

De-allocates any allocated memory

Definition at line 201 of file GraphicsDevice.cpp.

References primaryDisplayBuffer_, and secondaryDisplayBuffer_.

Referenced by SetDisplayMode().

Here is the caller graph for this function:

const GraphicsDeviceSingleton& ENGINE::GraphicsDeviceSingleton::operator= ( const GraphicsDeviceSingleton rhs  )  [private]

assignment operator is hidden because you cannot copy this class


Member Data Documentation

a pointer to an ImageResource that serves as the physical screen buffer

Definition at line 202 of file GraphicsDevice.h.

Referenced by BeginScene(), Destroy(), EndScene(), GetPrimaryDisplayBuffer(), and SetDisplayMode().

a pointer to an ImageResource that serves as the back-buffer that all drawing should be done on

Definition at line 208 of file GraphicsDevice.h.

Referenced by BeginScene(), Destroy(), EndScene(), GetSecondaryDisplayBuffer(), and SetDisplayMode().

the current state of the display mode. Windowed or Fullscreen.

Definition at line 214 of file GraphicsDevice.h.

Referenced by GetDisplayMode(), and SetDisplayMode().

the display resolution width in pixels

Definition at line 220 of file GraphicsDevice.h.

Referenced by EndScene(), GetDisplayWidth(), SetDisplayMode(), and SetDisplayResolution().

the display resolution height in pixels

Definition at line 226 of file GraphicsDevice.h.

Referenced by EndScene(), GetDisplayHeight(), SetDisplayMode(), and SetDisplayResolution().

the color depth of the display

Definition at line 232 of file GraphicsDevice.h.

Referenced by GetDisplayBitsPerPixel(), SetDisplayColorDepth(), and SetDisplayMode().


The documentation for this class was generated from the following files:

Generated on Tue Mar 3 20:11:37 2009 for ged101minimal by  doxygen 1.5.5