#include <graphicengine.h>
Public Member Functions | |
GraphicEngine (Kernel *pKernel) | |
bool | init (int width=800, int height=600, int bitDepth=16, int backbufferCount=2) |
bool | startFrame (bool updateAll=false) |
bool | endFrame () |
void | drawDebugLine (const Vertex &start, const Vertex &end, uint color=(0xFF000000|((255)<< 16)|((255)<< 8)|((255)<< 0))) |
bool | saveThumbnailScreenshot (const Common::String &filename) |
RenderObjectPtr< Panel > | getMainPanel () |
int | getLastFrameDurationMicro () const |
float | getLastFrameDuration () const |
void | stopMainTimer () |
void | resumeMainTimer () |
float | getSecondaryFrameDuration () const |
int | getDisplayWidth () const |
int | getDisplayHeight () const |
Common::Rect & | getDisplayRect () |
int | getBitDepth () |
void | setVsync (bool vsync) |
bool | getVsync () const |
bool | isWindowed () |
bool | fill (const Common::Rect *fillRectPtr=0, uint color=(0xFF000000|((0)<< 16)|((0)<< 8)|((0)<< 0))) |
Graphics::ManagedSurface * | getSurface () |
Common::SeekableReadStream * | getThumbnail () |
Resource * | loadResource (const Common::String &fileName) override |
bool | canLoadResource (const Common::String &fileName) override |
bool | persist (OutputPersistenceBlock &writer) override |
bool | unpersist (InputPersistenceBlock &reader) override |
bool | isRTL () |
Public Member Functions inherited from Sword25::ResourceService | |
ResourceService (Kernel *pKernel) | |
Static Public Member Functions | |
static void | ARGBColorToLuaColor (lua_State *L, uint color) |
static uint | luaColorToARGBColor (lua_State *L, int stackIndex) |
Public Attributes | |
Graphics::ManagedSurface | _backSurface |
Common::SeekableReadStream * | _thumbnail |
Protected Member Functions | |
void | updateLastFrameDuration () |
Protected Member Functions inherited from Sword25::Service | |
Service (Kernel *pKernel) | |
Kernel * | GetKernel () const |
Protected Attributes | |
int | _width |
int | _height |
Common::Rect | _screenRect |
int | _bitDepth |
This is the graphics engine. Unlike the original code, this is not an interface that needs to be subclassed, but rather already contains all required functionality.
bool Sword25::GraphicEngine::init | ( | int | width = 800 , |
int | height = 600 , |
||
int | bitDepth = 16 , |
||
int | backbufferCount = 2 |
||
) |
Initializes the graphics engine and sets the screen mode. Returns true if initialisation failed.
Height | The height of the output buffer in pixels. The default value is 600 |
BitDepth | The bit depth of the desired output buffer in bits. The default value is 16 |
BackbufferCount | The number of back buffers to be created. The default value is 2 |
bool Sword25::GraphicEngine::startFrame | ( | bool | updateAll = false | ) |
Begins rendering a new frame. Notes: This method must be called at the beginning of the main loop, before any rendering methods are used. Notes: Implementations of this method must call _UpdateLastFrameDuration()
UpdateAll | Specifies whether the renderer should redraw everything on the next frame. This feature can be useful if the renderer with Dirty Rectangles works, but sometimes the client may |
bool Sword25::GraphicEngine::endFrame | ( | ) |
Ends the rendering of a frame and draws it on the screen.
This method must be at the end of the main loop. After this call, no further Render method may be called. This should only be called once for a given previous call to #StartFrame.
void Sword25::GraphicEngine::drawDebugLine | ( | const Vertex & | start, |
const Vertex & | end, | ||
uint | color = (0xFF000000|((255)<< 16)|((255)<< 8)|((255)<< 0)) |
||
) |
Draws a line in the frame buffer
This method must be called between calls to StartFrame() and EndFrame(), and is intended only for debugging purposes. The line will only appear for a single frame. If the line is to be shown permanently, it must be called for every frame.
Start | The starting point of the line |
End | The ending point of the line |
Color | The color of the line. The default is BS_RGB (255,255,255) (White) |
bool Sword25::GraphicEngine::saveThumbnailScreenshot | ( | const Common::String & | filename | ) |
Creates a thumbnail with the dimensions of 200x125. This will not include the top and bottom of the screen.. the interface boards the image as a 16th of it's original size. Notes: This method should only be called after a call to EndFrame(), and before the next call to StartFrame(). The frame buffer must have a resolution of 800x600.
Filename | The filename for the screenshot |
|
inline |
Specifies the time (in microseconds) since the last frame has passed
|
inline |
Specifies the time (in microseconds) the previous frame took
|
inline |
Returns the width of the output buffer in pixels
|
inline |
Returns the height of the output buffer in pixels
|
inline |
Returns the bounding box of the output buffer: (0, 0, Width, Height)
|
inline |
Returns the bit depth of the output buffer
void Sword25::GraphicEngine::setVsync | ( | bool | vsync | ) |
Determines whether the frame buffer change is to be synchronised with Vsync. This is turned on by default. Notes: In windowed mode, this setting has no effect.
Vsync | Indicates whether the frame buffer changes are to be synchronised with Vsync. |
bool Sword25::GraphicEngine::getVsync | ( | ) | const |
Returns true if V-Sync is on. Notes: In windowed mode, this setting has no effect.
|
inline |
Returns true if the engine is running in Windowed mode.
bool Sword25::GraphicEngine::fill | ( | const Common::Rect * | fillRectPtr = 0 , |
uint | color = (0xFF000000|((0)<< 16)|((0)<< 8)|((0)<< 0)) |
||
) |
Fills a rectangular area of the frame buffer with a color. Notes: It is possible to create transparent rectangles by passing a color with an Alpha value of 255.
FillRectPtr | Pointer to a Common::Rect, which specifies the section of the frame buffer to be filled. If the rectangle falls partly off-screen, then it is automatically trimmed. If a NULL value is passed, then the entire image is to be filled. |
Color | The 32-bit color with which the area is to be filled. The default is BS_RGB(0, 0, 0) (black) |
|
overridevirtual |
Loads a resource
Implements Sword25::ResourceService.
|
overridevirtual |
Checks whether the given name can be loaded by the resource service
FileName | Dateiname |
Implements Sword25::ResourceService.
|
protected |
Calculates the time since the last frame beginning has passed.