ScummVM API documentation
Sword25::GraphicEngine Class Reference

#include <graphicengine.h>

Inheritance diagram for Sword25::GraphicEngine:
Sword25::ResourceService Sword25::Persistable Sword25::Service

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 ()
 
bool saveThumbnailScreenshot (const Common::String &filename)
 
RenderObjectPtr< PanelgetMainPanel ()
 
int getLastFrameDurationMicro () const
 
float getLastFrameDuration () const
 
void stopMainTimer ()
 
void resumeMainTimer ()
 
float getSecondaryFrameDuration () const
 
int getDisplayWidth () const
 
int getDisplayHeight () const
 
Common::RectgetDisplayRect ()
 
int getBitDepth ()
 
void setVsync (bool vsync)
 
bool getVsync () const
 
bool fill (const Common::Rect *fillRectPtr=0, uint color=(0xFF000000|((0)<< 16)|((0)<< 8)|((0)<< 0)))
 
Graphics::ManagedSurfacegetSurface ()
 
Common::SeekableReadStreamgetThumbnail ()
 
ResourceloadResource (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)
 
KernelGetKernel () const
 

Protected Attributes

int _width
 
int _height
 
Common::Rect _screenRect
 
int _bitDepth
 

Detailed Description

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.

Member Function Documentation

◆ init()

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.

Note
This method should be called immediately after the initialisation of all services.
Parameters
HeightThe height of the output buffer in pixels. The default value is 600
BitDepthThe bit depth of the desired output buffer in bits. The default value is 16
BackbufferCountThe number of back buffers to be created. The default value is 2

◆ startFrame()

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()

Parameters
UpdateAllSpecifies 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

◆ endFrame()

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.

◆ saveThumbnailScreenshot()

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.

Parameters
FilenameThe filename for the screenshot

◆ getLastFrameDurationMicro()

int Sword25::GraphicEngine::getLastFrameDurationMicro ( ) const
inline

Specifies the time (in microseconds) since the last frame has passed

◆ getLastFrameDuration()

float Sword25::GraphicEngine::getLastFrameDuration ( ) const
inline

Specifies the time (in microseconds) the previous frame took

◆ getDisplayWidth()

int Sword25::GraphicEngine::getDisplayWidth ( ) const
inline

Returns the width of the output buffer in pixels

◆ getDisplayHeight()

int Sword25::GraphicEngine::getDisplayHeight ( ) const
inline

Returns the height of the output buffer in pixels

◆ getDisplayRect()

Common::Rect& Sword25::GraphicEngine::getDisplayRect ( )
inline

Returns the bounding box of the output buffer: (0, 0, Width, Height)

◆ getBitDepth()

int Sword25::GraphicEngine::getBitDepth ( )
inline

Returns the bit depth of the output buffer

◆ setVsync()

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.

Parameters
VsyncIndicates whether the frame buffer changes are to be synchronised with Vsync.

◆ getVsync()

bool Sword25::GraphicEngine::getVsync ( ) const

Returns true if V-Sync is on. Notes: In windowed mode, this setting has no effect.

◆ fill()

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.

Parameters
FillRectPtrPointer 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.
ColorThe 32-bit color with which the area is to be filled. The default is BS_RGB(0, 0, 0) (black)
Note
FIf the rectangle is not completely inside the screen, it is automatically clipped.

◆ loadResource()

Resource* Sword25::GraphicEngine::loadResource ( const Common::String fileName)
overridevirtual

Loads a resource

Returns
Returns the resource if successful, otherwise NULL

Implements Sword25::ResourceService.

◆ canLoadResource()

bool Sword25::GraphicEngine::canLoadResource ( const Common::String fileName)
overridevirtual

Checks whether the given name can be loaded by the resource service

Parameters
FileNameDateiname
Returns
Returns true if the resource can be loaded.

Implements Sword25::ResourceService.

◆ updateLastFrameDuration()

void Sword25::GraphicEngine::updateLastFrameDuration ( )
protected

Calculates the time since the last frame beginning has passed.


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