Introduction
Downloads
Documentation
Tutorials
Pixie Lite
Forum

Home

Platform_Screen Class Reference
[Platform]

Platform independent abstraction of the display device. More...

Inheritance diagram for Platform_Screen:

Platform_NULL_Screen Platform_Win32_Screen

List of all members.


Public Member Functions

virtual ~Platform_Screen ()
virtual void Present (unsigned short *bitmapData, int bitmapWidth, int bitmapHeight, unsigned short modulate=0xffff, unsigned short backgroundColor=0x0000)=0
virtual void SetFullscreen (bool fullscreen)=0
virtual bool GetFullscreen ()=0
virtual void SetSize (int width, int height)=0
virtual int GetWidth ()=0
virtual int GetHeight ()=0
virtual void SetInterpolationMode (bool enabled)=0
virtual bool GetInterpolationMode ()=0
virtual void TransformCursorCoordinates (float &x, float &y)=0

Detailed Description

Platform independent abstraction of the display device.

Author:
Mattias Gustavsson
This is a platform abstraction of the physical screen, the display device. This is what you use to display things, and it is really quite simple: you simply call Present, passing it the pixel data you want to display. The idea is that you keep drawing your sprites and background to a pixel buffer you have created, and every frame you call the Present method of Platform_Screen to display the results.

Platform_Screen also includes functionality to set screen size and toggle fullscreen mode. It is not guaranteed that every platform makes use of this information, so consider it more of a hint than an actual directive. What you DO have control over is the size of your own bitmap, as that is what you will be drawing to.

For platform specific behavior, please refer to the header file of the platform specific implementation of Platform_Screen.

Definition at line 34 of file Platform_Screen.h.


Constructor & Destructor Documentation

virtual Platform_Screen::~Platform_Screen (  )  [virtual]

Destructor

Definition at line 40 of file Platform_Screen.h.


Member Function Documentation

virtual void Platform_Screen::Present ( unsigned short *  bitmapData,
int  bitmapWidth,
int  bitmapHeight,
unsigned short  modulate = 0xffff,
unsigned short  backgroundColor = 0x0000 
) [pure virtual]

Displays the specified bitmap on the screen. This is generally implemented in the fastest way possible for the platform, and the bitmap does not have to match the screen size, as it will do what it can to make it fit (stretch/shrink with or without interpolation, depending on settings and the current platform). Aspect ratio will be maintained, so there might be borders at the sides or top/bottom of the screen.

Parameters:
bitmapData Bitmap data (pixels) in 16-bit RGB565 format
bitmapWidth Width of the bitmap data, in pixels
bitmapHeight Height of the bitmap data, in pixels
modulate Optional color modifier. Every pixel of the bitmap will be multiplied by this RGB565 color value, in the fastest way possible for the platform.
backgroundColor Optional background color. In the case where the bitmap won't fit tightly on the screen, there will be borders above/below or to the left/right (or both). They will be the RGB565 color specified here

Implemented in Platform_NULL_Screen, and Platform_Win32_Screen.

virtual void Platform_Screen::SetFullscreen ( bool  fullscreen  )  [pure virtual]

Enables or disables fullscreen mode. On some platforms, it is possible to run the game in a window, instead of having it cover the whole screen (which is the default behavior, unless you specify the command line parameter -window in which case the default will be to run in windowed mode).

When the game is running in windowed mode, the values set by the SetSize method are used for the size of the window (when running in fullscreen mode, those values will be ignored, and the bitmap passed to Present will be scaled to fill the actual screen).

On some platforms, it is possible for the user to change the window size when running in windowed mode. This will be handled automatically, and the GetWidth and GetHeight methods can be used to retrieve the current window size. If you need to override the users change, you can call SetSize to adjust the window dimensions.

Note that windowed mode might not be available on all platforms, and in that case, toggling this setting will have no effect.

Parameters:
fullscreen True if you want the game to run in fullscreen mode, false if you want it to run in windowed mode

Implemented in Platform_NULL_Screen, and Platform_Win32_Screen.

virtual bool Platform_Screen::GetFullscreen (  )  [pure virtual]

This method is used to determine if the game is running in windowed or fullscreen mode. See the SetFullscreen method for an explanation of windowed and fullscreen mode.

Returns:
True if running in fullscreen mode, False if running in windowed mode

Implemented in Platform_NULL_Screen, and Platform_Win32_Screen.

virtual void Platform_Screen::SetSize ( int  width,
int  height 
) [pure virtual]

Sets the size of the window, if running in windowed mode. This method might not do anything on some platforms. See the SetFullscreen method for an explanation of windowed and fullscreen mode.

Parameters:
width The desired window width in pixels
height The desired window height in pixels

Implemented in Platform_NULL_Screen, and Platform_Win32_Screen.

virtual int Platform_Screen::GetWidth (  )  [pure virtual]

Retrieves the current window width, if running in windowed mode. See the SetFullscreen method for an explanation of windowed and fullscreen mode.

Returns:
The current width of the window

Implemented in Platform_NULL_Screen, and Platform_Win32_Screen.

virtual int Platform_Screen::GetHeight (  )  [pure virtual]

Retrieves the current window height, if running in windowed mode. See the SetFullscreen method for an explanation of windowed and fullscreen mode.

Returns:
The current height of the window

Implemented in Platform_NULL_Screen, and Platform_Win32_Screen.

virtual void Platform_Screen::SetInterpolationMode ( bool  enabled  )  [pure virtual]

Enables or disables interpolation mode. If interpolation mode is on, it means that bitmaps of a size that doesn't match the screen size, and therefor needs to be scaled, will be interpolated using some interpolation scheme available on the platform (for example, it might use bilinear interpolation) which makes the image smoother, but a bit more blurry. If interpolation mode is off, there will be no interpolation applied to the bitmap, and it will also not be scaled by fractional amounts (meaning it might be scaled x2, x3, x4 etc, but not, for example, x2.5). You're likely to get larger border areas with interpolation turned off, but your pixels will stay sharp and crisp, with no distortion.

In general, you want to turn off interpolation if the graphics for your game falls into the "pixel art" category, and leave it on (which is the default) for highres or rendered art.

Note that interpolation might not be available on all platforms, and in that case, toggling this setting will have no effect.

Parameters:
enabled True if you want to turn on the interpolation mode, false if you want to turn it off

Implemented in Platform_NULL_Screen, and Platform_Win32_Screen.

virtual bool Platform_Screen::GetInterpolationMode (  )  [pure virtual]

This method is used to determine if interpolation mode is currently on or off. See SetInterpolationMode method for an explanation of the interpolation mode

Returns:
True if interpolation mode is on, False if interpolation mode is off

Implemented in Platform_NULL_Screen, and Platform_Win32_Screen.

virtual void Platform_Screen::TransformCursorCoordinates ( float &  x,
float &  y 
) [pure virtual]

When retrieving the position of the mouse cursor, you will get them in relation to the window (or the screen, if running in fullscreen mode). As Platform_Screen will do its own things (which might differ for different platform implementations) to scale, clamp or border the bitmap data passed to its Present method, it can be difficult or impossible to translate the mouse cursor position to coordinates in relation to the back buffer bitmap you're working with in your game. This method will transform the provided coordinates (as retrieved from Platform_Input_MouseDevice) to be relative to the bitmap passed in on the most recent Present call. If no Present call have been made yet, the coordinates will be left untransformed.

Parameters:
x X-coordinate to transform
y Y-coordinate to transform

Implemented in Platform_NULL_Screen, and Platform_Win32_Screen.



Pixie University and the Pixie Game Engine is created and managed by Mattias Gustavsson.
Reproduction/republishing of any material on this site without permission is strictly prohibited.