mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-03 17:33:05 +00:00
SWORD25: Enforce code naming conventions in gfx/graphicengine*
svn-id: r53621
This commit is contained in:
parent
0d1d481894
commit
d94435eebd
@ -73,15 +73,15 @@ bool MoviePlayer::loadMovie(const Common::String &filename, uint z) {
|
||||
GraphicEngine *pGfx = Kernel::GetInstance()->GetGfx();
|
||||
|
||||
#if INDIRECTRENDERING
|
||||
_outputBitmap = pGfx->GetMainPanel()->addDynamicBitmap(_decoder.getWidth(), _decoder.getHeight());
|
||||
_outputBitmap = pGfx->getMainPanel()->addDynamicBitmap(_decoder.getWidth(), _decoder.getHeight());
|
||||
if (!_outputBitmap.isValid()) {
|
||||
BS_LOG_ERRORLN("Output bitmap for movie playback could not be created.");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Skalierung des Ausgabebitmaps berechnen, so dass es möglichst viel Bildschirmfläche einnimmt.
|
||||
float screenToVideoWidth = (float)pGfx->GetDisplayWidth() / (float)_outputBitmap->getWidth();
|
||||
float screenToVideoHeight = (float)pGfx->GetDisplayHeight() / (float)_outputBitmap->getHeight();
|
||||
float screenToVideoWidth = (float)pGfx->getDisplayWidth() / (float)_outputBitmap->getWidth();
|
||||
float screenToVideoHeight = (float)pGfx->getDisplayHeight() / (float)_outputBitmap->getHeight();
|
||||
float scaleFactor = MIN(screenToVideoWidth, screenToVideoHeight);
|
||||
|
||||
if (abs((int)(scaleFactor - 1.0f)) < FLT_EPSILON)
|
||||
@ -93,13 +93,13 @@ bool MoviePlayer::loadMovie(const Common::String &filename, uint z) {
|
||||
_outputBitmap->setZ(z);
|
||||
|
||||
// Ausgabebitmap auf dem Bildschirm zentrieren
|
||||
_outputBitmap->setX((pGfx->GetDisplayWidth() - _outputBitmap->getWidth()) / 2);
|
||||
_outputBitmap->setY((pGfx->GetDisplayHeight() - _outputBitmap->getHeight()) / 2);
|
||||
_outputBitmap->setX((pGfx->getDisplayWidth() - _outputBitmap->getWidth()) / 2);
|
||||
_outputBitmap->setY((pGfx->getDisplayHeight() - _outputBitmap->getHeight()) / 2);
|
||||
#else
|
||||
_backSurface = pGfx->getSurface();
|
||||
|
||||
_outX = (pGfx->GetDisplayWidth() - _decoder.getWidth()) / 2;
|
||||
_outY = (pGfx->GetDisplayHeight() - _decoder.getHeight()) / 2;
|
||||
_outX = (pGfx->getDisplayWidth() - _decoder.getWidth()) / 2;
|
||||
_outY = (pGfx->getDisplayHeight() - _decoder.getHeight()) / 2;
|
||||
|
||||
if (_outX < 0)
|
||||
_outX = 0;
|
||||
@ -169,8 +169,8 @@ void MoviePlayer::setScaleFactor(float scaleFactor) {
|
||||
|
||||
// Ausgabebitmap auf dem Bildschirm zentrieren
|
||||
GraphicEngine *gfxPtr = Kernel::GetInstance()->GetGfx();
|
||||
_outputBitmap->setX((gfxPtr->GetDisplayWidth() - _outputBitmap->getWidth()) / 2);
|
||||
_outputBitmap->setY((gfxPtr->GetDisplayHeight() - _outputBitmap->getHeight()) / 2);
|
||||
_outputBitmap->setX((gfxPtr->getDisplayWidth() - _outputBitmap->getWidth()) / 2);
|
||||
_outputBitmap->setY((gfxPtr->getDisplayHeight() - _outputBitmap->getHeight()) / 2);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -37,30 +37,30 @@
|
||||
|
||||
namespace Sword25 {
|
||||
|
||||
Framecounter::Framecounter(int UpdateFrequency) :
|
||||
m_FPS(0),
|
||||
m_FPSCount(0),
|
||||
m_LastUpdateTime(-1) {
|
||||
SetUpdateFrequency(UpdateFrequency);
|
||||
Framecounter::Framecounter(int updateFrequency) :
|
||||
_FPS(0),
|
||||
_FPSCount(0),
|
||||
_lastUpdateTime(-1) {
|
||||
setUpdateFrequency(updateFrequency);
|
||||
}
|
||||
|
||||
void Framecounter::Update() {
|
||||
void Framecounter::update() {
|
||||
// Aktuellen Systemtimerstand auslesen
|
||||
uint64 Timer = g_system->getMillis() * 1000;
|
||||
uint64 timer = g_system->getMillis() * 1000;
|
||||
|
||||
// Falls m_LastUpdateTime == -1 ist, wird der Frame-Counter zum ersten Mal aufgerufen und der aktuelle Systemtimer als erster
|
||||
// Messzeitpunkt genommen.
|
||||
if (m_LastUpdateTime == -1)
|
||||
m_LastUpdateTime = Timer;
|
||||
if (_lastUpdateTime == -1)
|
||||
_lastUpdateTime = timer;
|
||||
else {
|
||||
// Die Anzahl der Frames im aktuellen Messzeitraum wird erhöht.
|
||||
m_FPSCount++;
|
||||
_FPSCount++;
|
||||
|
||||
// Falls der Messzeitraum verstrichen ist, wird die durchschnittliche Framerate berechnet und ein neuer Messzeitraum begonnen.
|
||||
if (Timer - m_LastUpdateTime >= m_UpdateDelay) {
|
||||
m_FPS = static_cast<int>((1000000 * (uint64)m_FPSCount) / (Timer - m_LastUpdateTime));
|
||||
m_LastUpdateTime = Timer;
|
||||
m_FPSCount = 0;
|
||||
if (timer - _lastUpdateTime >= _updateDelay) {
|
||||
_FPS = static_cast<int>((1000000 * (uint64)_FPSCount) / (timer - _lastUpdateTime));
|
||||
_lastUpdateTime = timer;
|
||||
_FPSCount = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -40,7 +40,6 @@
|
||||
|
||||
namespace Sword25 {
|
||||
|
||||
|
||||
/**
|
||||
* A simple class that implements a frame counter
|
||||
*/
|
||||
@ -62,37 +61,37 @@ public:
|
||||
* @param UpdateFrequency Specifies how often the frame counter should be updated in a sceond.
|
||||
* The default value is 10.
|
||||
*/
|
||||
Framecounter(int UpdateFrequency = DEFAULT_UPDATE_FREQUENCY);
|
||||
Framecounter(int updateFrequency = DEFAULT_UPDATE_FREQUENCY);
|
||||
|
||||
/**
|
||||
* Determines how often the frame counter should be updated in a second.
|
||||
* @param UpdateFrequency Specifies how often the frame counter should be updated in a second.
|
||||
*/
|
||||
inline void SetUpdateFrequency(int UpdateFrequency);
|
||||
inline void setUpdateFrequency(int updateFrequency);
|
||||
|
||||
/**
|
||||
* This method must be called once per frame.
|
||||
*/
|
||||
void Update();
|
||||
void update();
|
||||
|
||||
/**
|
||||
* Returns the current FPS value.
|
||||
*/
|
||||
int GetFPS() const {
|
||||
return m_FPS;
|
||||
int getFPS() const {
|
||||
return _FPS;
|
||||
}
|
||||
|
||||
private:
|
||||
int m_FPS;
|
||||
int m_FPSCount;
|
||||
int64 m_LastUpdateTime;
|
||||
uint64 m_UpdateDelay;
|
||||
int _FPS;
|
||||
int _FPSCount;
|
||||
int64 _lastUpdateTime;
|
||||
uint64 _updateDelay;
|
||||
};
|
||||
|
||||
// Inlines
|
||||
void Framecounter::SetUpdateFrequency(int UpdateFrequency) {
|
||||
void Framecounter::setUpdateFrequency(int updateFrequency) {
|
||||
// Frequency in time (converted to microseconds)
|
||||
m_UpdateDelay = 1000000 / UpdateFrequency;
|
||||
_updateDelay = 1000000 / updateFrequency;
|
||||
}
|
||||
|
||||
} // End of namespace Sword25
|
||||
|
@ -68,17 +68,17 @@ GraphicEngine::GraphicEngine(Kernel *pKernel) :
|
||||
_width(0),
|
||||
_height(0),
|
||||
_bitDepth(0),
|
||||
m_Windowed(0),
|
||||
m_LastTimeStamp((uint) -1), // max. BS_INT64 um beim ersten Aufruf von _UpdateLastFrameDuration() einen Reset zu erzwingen
|
||||
m_LastFrameDuration(0),
|
||||
m_TimerActive(true),
|
||||
m_FrameTimeSampleSlot(0),
|
||||
m_RepaintedPixels(0),
|
||||
_windowed(0),
|
||||
_lastTimeStamp((uint) -1), // max. BS_INT64 um beim ersten Aufruf von _UpdateLastFrameDuration() einen Reset zu erzwingen
|
||||
_lastFrameDuration(0),
|
||||
_timerActive(true),
|
||||
_frameTimeSampleSlot(0),
|
||||
_repaintedPixels(0),
|
||||
_thumbnail(NULL),
|
||||
ResourceService(pKernel) {
|
||||
m_FrameTimeSamples.resize(FRAMETIME_SAMPLE_COUNT);
|
||||
_frameTimeSamples.resize(FRAMETIME_SAMPLE_COUNT);
|
||||
|
||||
if (!RegisterScriptBindings())
|
||||
if (!registerScriptBindings())
|
||||
BS_LOG_ERRORLN("Script bindings could not be registered.");
|
||||
else
|
||||
BS_LOGLN("Script bindings registered.");
|
||||
@ -94,7 +94,7 @@ Service *GraphicEngine_CreateObject(Kernel *pKernel) {
|
||||
return new GraphicEngine(pKernel);
|
||||
}
|
||||
|
||||
bool GraphicEngine::Init(int width, int height, int bitDepth, int backbufferCount, bool isWindowed) {
|
||||
bool GraphicEngine::init(int width, int height, int bitDepth, int backbufferCount, bool isWindowed_) {
|
||||
// Warnung ausgeben, wenn eine nicht unterstützte Bittiefe gewählt wurde.
|
||||
if (bitDepth != BIT_DEPTH) {
|
||||
BS_LOG_WARNINGLN("Can't use a bit depth of %d (not supported). Falling back to %d.", bitDepth, BIT_DEPTH);
|
||||
@ -111,7 +111,7 @@ bool GraphicEngine::Init(int width, int height, int bitDepth, int backbufferCoun
|
||||
_width = width;
|
||||
_height = height;
|
||||
_bitDepth = bitDepth;
|
||||
m_Windowed = isWindowed;
|
||||
_windowed = isWindowed_;
|
||||
_screenRect.left = 0;
|
||||
_screenRect.top = 0;
|
||||
_screenRect.right = _width;
|
||||
@ -121,26 +121,24 @@ bool GraphicEngine::Init(int width, int height, int bitDepth, int backbufferCoun
|
||||
_frameBuffer.create(width, height, 4);
|
||||
|
||||
// Standardmäßig ist Vsync an.
|
||||
SetVsync(true);
|
||||
setVsync(true);
|
||||
|
||||
// Layer-Manager initialisieren.
|
||||
_renderObjectManagerPtr.reset(new RenderObjectManager(width, height, backbufferCount + 1));
|
||||
|
||||
// Hauptpanel erstellen
|
||||
m_MainPanelPtr = _renderObjectManagerPtr->getTreeRoot()->addPanel(width, height, BS_ARGB(0, 0, 0, 0));
|
||||
if (!m_MainPanelPtr.isValid())
|
||||
_mainPanelPtr = _renderObjectManagerPtr->getTreeRoot()->addPanel(width, height, BS_ARGB(0, 0, 0, 0));
|
||||
if (!_mainPanelPtr.isValid())
|
||||
return false;
|
||||
m_MainPanelPtr->setVisible(true);
|
||||
_mainPanelPtr->setVisible(true);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
bool GraphicEngine::StartFrame(bool UpdateAll) {
|
||||
bool GraphicEngine::startFrame(bool updateAll) {
|
||||
// Berechnen, wie viel Zeit seit dem letzten Frame vergangen ist.
|
||||
// Dieser Wert kann über GetLastFrameDuration() von Modulen abgefragt werden, die zeitabhängig arbeiten.
|
||||
UpdateLastFrameDuration();
|
||||
updateLastFrameDuration();
|
||||
|
||||
// Den Layer-Manager auf den nächsten Frame vorbereiten
|
||||
_renderObjectManagerPtr->startFrame();
|
||||
@ -148,9 +146,7 @@ bool GraphicEngine::StartFrame(bool UpdateAll) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
bool GraphicEngine::EndFrame() {
|
||||
bool GraphicEngine::endFrame() {
|
||||
// Scene zeichnen
|
||||
_renderObjectManagerPtr->render();
|
||||
|
||||
@ -166,7 +162,7 @@ bool GraphicEngine::EndFrame() {
|
||||
g_system->updateScreen();
|
||||
|
||||
// Debug-Lines zeichnen
|
||||
if (!m_DebugLines.empty()) {
|
||||
if (!_debugLines.empty()) {
|
||||
#if 0
|
||||
glEnable(GL_LINE_SMOOTH);
|
||||
glBegin(GL_LINES);
|
||||
@ -188,37 +184,29 @@ bool GraphicEngine::EndFrame() {
|
||||
|
||||
warning("STUB: Drawing debug lines");
|
||||
|
||||
m_DebugLines.clear();
|
||||
_debugLines.clear();
|
||||
}
|
||||
|
||||
// Framecounter aktualisieren
|
||||
m_FPSCounter.Update();
|
||||
_FPSCounter.update();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
RenderObjectPtr<Panel> GraphicEngine::GetMainPanel() {
|
||||
return m_MainPanelPtr;
|
||||
RenderObjectPtr<Panel> GraphicEngine::getMainPanel() {
|
||||
return _mainPanelPtr;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void GraphicEngine::SetVsync(bool Vsync) {
|
||||
warning("STUB: SetVsync(%d)", Vsync);
|
||||
void GraphicEngine::setVsync(bool vsync) {
|
||||
warning("STUB: SetVsync(%d)", vsync);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
bool GraphicEngine::GetVsync() const {
|
||||
warning("STUB: GetVsync()");
|
||||
bool GraphicEngine::getVsync() const {
|
||||
warning("STUB: getVsync()");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
bool GraphicEngine::fill(const Common::Rect *fillRectPtr, uint color) {
|
||||
Common::Rect rect(_width - 1, _height - 1);
|
||||
|
||||
@ -268,9 +256,7 @@ bool GraphicEngine::fill(const Common::Rect *fillRectPtr, uint color) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
Graphics::Surface *GraphicEngine::GetScreenshot() {
|
||||
Graphics::Surface *GraphicEngine::getScreenshot() {
|
||||
return &_frameBuffer;
|
||||
}
|
||||
|
||||
@ -283,9 +269,9 @@ Resource *GraphicEngine::loadResource(const Common::String &filename) {
|
||||
|
||||
// Load image for "software buffer" (FIXME: Whatever that means?)
|
||||
if (filename.hasSuffix("_s.png")) {
|
||||
bool Result = false;
|
||||
SWImage *pImage = new SWImage(filename, Result);
|
||||
if (!Result) {
|
||||
bool result = false;
|
||||
SWImage *pImage = new SWImage(filename, result);
|
||||
if (!result) {
|
||||
delete pImage;
|
||||
return 0;
|
||||
}
|
||||
@ -301,9 +287,9 @@ Resource *GraphicEngine::loadResource(const Common::String &filename) {
|
||||
|
||||
// Load sprite image
|
||||
if (filename.hasSuffix(".png") || filename.hasSuffix(".b25s")) {
|
||||
bool Result = false;
|
||||
RenderedImage *pImage = new RenderedImage(filename, Result);
|
||||
if (!Result) {
|
||||
bool result = false;
|
||||
RenderedImage *pImage = new RenderedImage(filename, result);
|
||||
if (!result) {
|
||||
delete pImage;
|
||||
return 0;
|
||||
}
|
||||
@ -328,17 +314,17 @@ Resource *GraphicEngine::loadResource(const Common::String &filename) {
|
||||
|
||||
// Datei laden
|
||||
byte *pFileData;
|
||||
uint FileSize;
|
||||
if (!(pFileData = static_cast<byte *>(pPackage->getFile(filename, &FileSize)))) {
|
||||
uint fileSize;
|
||||
if (!(pFileData = static_cast<byte *>(pPackage->getFile(filename, &fileSize)))) {
|
||||
BS_LOG_ERRORLN("File \"%s\" could not be loaded.", filename.c_str());
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool Result = false;
|
||||
VectorImage *pImage = new VectorImage(pFileData, FileSize, Result, filename);
|
||||
if (!Result) {
|
||||
bool result = false;
|
||||
VectorImage *pImage = new VectorImage(pFileData, fileSize, result, filename);
|
||||
if (!result) {
|
||||
delete pImage;
|
||||
delete [] pFileData;
|
||||
delete[] pFileData;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -394,35 +380,35 @@ bool GraphicEngine::canLoadResource(const Common::String &filename) {
|
||||
// DEBUGGING
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void GraphicEngine::DrawDebugLine(const Vertex &Start, const Vertex &End, uint Color) {
|
||||
m_DebugLines.push_back(DebugLine(Start, End, Color));
|
||||
void GraphicEngine::drawDebugLine(const Vertex &start, const Vertex &end, uint color) {
|
||||
_debugLines.push_back(DebugLine(start, end, color));
|
||||
}
|
||||
|
||||
void GraphicEngine::UpdateLastFrameDuration() {
|
||||
void GraphicEngine::updateLastFrameDuration() {
|
||||
// Record current time
|
||||
const uint currentTime = Kernel::GetInstance()->GetMilliTicks();
|
||||
|
||||
// Compute the elapsed time since the last frame and prevent too big ( > 250 msecs) time jumps.
|
||||
// These can occur when loading save states, during debugging or due to hardware inaccuracies.
|
||||
m_FrameTimeSamples[m_FrameTimeSampleSlot] = static_cast<uint>(currentTime - m_LastTimeStamp);
|
||||
if (m_FrameTimeSamples[m_FrameTimeSampleSlot] > 250000)
|
||||
m_FrameTimeSamples[m_FrameTimeSampleSlot] = 250000;
|
||||
m_FrameTimeSampleSlot = (m_FrameTimeSampleSlot + 1) % FRAMETIME_SAMPLE_COUNT;
|
||||
_frameTimeSamples[_frameTimeSampleSlot] = static_cast<uint>(currentTime - _lastTimeStamp);
|
||||
if (_frameTimeSamples[_frameTimeSampleSlot] > 250000)
|
||||
_frameTimeSamples[_frameTimeSampleSlot] = 250000;
|
||||
_frameTimeSampleSlot = (_frameTimeSampleSlot + 1) % FRAMETIME_SAMPLE_COUNT;
|
||||
|
||||
// Compute the average frame duration over multiple frames to eliminate outliers.
|
||||
Common::Array<uint>::const_iterator it = m_FrameTimeSamples.begin();
|
||||
Common::Array<uint>::const_iterator it = _frameTimeSamples.begin();
|
||||
uint sum = *it;
|
||||
for (it++; it != m_FrameTimeSamples.end(); it++)
|
||||
for (it++; it != _frameTimeSamples.end(); it++)
|
||||
sum += *it;
|
||||
m_LastFrameDuration = sum * 1000 / FRAMETIME_SAMPLE_COUNT;
|
||||
_lastFrameDuration = sum * 1000 / FRAMETIME_SAMPLE_COUNT;
|
||||
|
||||
// Update m_LastTimeStamp with the current frame's timestamp
|
||||
m_LastTimeStamp = currentTime;
|
||||
_lastTimeStamp = currentTime;
|
||||
}
|
||||
|
||||
namespace {
|
||||
bool DoSaveScreenshot(GraphicEngine &graphicEngine, const Common::String &filename) {
|
||||
Graphics::Surface *data = graphicEngine.GetScreenshot();
|
||||
bool doSaveScreenshot(GraphicEngine &graphicEngine, const Common::String &filename) {
|
||||
Graphics::Surface *data = graphicEngine.getScreenshot();
|
||||
if (!data) {
|
||||
BS_LOG_ERRORLN("Call to GetScreenshot() failed. Cannot save screenshot.");
|
||||
return false;
|
||||
@ -442,11 +428,11 @@ bool DoSaveScreenshot(GraphicEngine &graphicEngine, const Common::String &filena
|
||||
}
|
||||
}
|
||||
|
||||
bool GraphicEngine::SaveScreenshot(const Common::String &filename) {
|
||||
return DoSaveScreenshot(*this, filename);
|
||||
bool GraphicEngine::saveScreenshot(const Common::String &filename) {
|
||||
return doSaveScreenshot(*this, filename);
|
||||
}
|
||||
|
||||
bool GraphicEngine::SaveThumbnailScreenshot(const Common::String &filename) {
|
||||
bool GraphicEngine::saveThumbnailScreenshot(const Common::String &filename) {
|
||||
// Note: In ScumMVM, rather than saivng the thumbnail to a file, we store it in memory
|
||||
// until needed when creating savegame files
|
||||
delete _thumbnail;
|
||||
@ -454,59 +440,64 @@ bool GraphicEngine::SaveThumbnailScreenshot(const Common::String &filename) {
|
||||
return true;
|
||||
}
|
||||
|
||||
void GraphicEngine::ARGBColorToLuaColor(lua_State *L, uint Color) {
|
||||
lua_Number Components[4] = {
|
||||
(Color >> 16) & 0xff, // Rot
|
||||
(Color >> 8) & 0xff, // Grün
|
||||
Color & 0xff, // Blau
|
||||
Color >> 24, // Alpha
|
||||
void GraphicEngine::ARGBColorToLuaColor(lua_State *L, uint color) {
|
||||
lua_Number components[4] = {
|
||||
(color >> 16) & 0xff, // Rot
|
||||
(color >> 8) & 0xff, // Grün
|
||||
color & 0xff, // Blau
|
||||
color >> 24, // Alpha
|
||||
};
|
||||
|
||||
lua_newtable(L);
|
||||
|
||||
for (uint i = 1; i <= 4; i++) {
|
||||
lua_pushnumber(L, i);
|
||||
lua_pushnumber(L, Components[i - 1]);
|
||||
lua_pushnumber(L, components[i - 1]);
|
||||
lua_settable(L, -3);
|
||||
}
|
||||
}
|
||||
|
||||
uint GraphicEngine::LuaColorToARGBColor(lua_State *L, int StackIndex) {
|
||||
uint GraphicEngine::luaColorToARGBColor(lua_State *L, int stackIndex) {
|
||||
#ifdef DEBUG
|
||||
int __startStackDepth = lua_gettop(L);
|
||||
#endif
|
||||
|
||||
// Sicherstellen, dass wir wirklich eine Tabelle betrachten
|
||||
luaL_checktype(L, StackIndex, LUA_TTABLE);
|
||||
luaL_checktype(L, stackIndex, LUA_TTABLE);
|
||||
// Größe der Tabelle auslesen
|
||||
uint n = luaL_getn(L, StackIndex);
|
||||
uint n = luaL_getn(L, stackIndex);
|
||||
// RGB oder RGBA Farben werden unterstützt und sonst keine
|
||||
if (n != 3 && n != 4) luaL_argcheck(L, 0, StackIndex, "at least 3 of the 4 color components have to be specified");
|
||||
if (n != 3 && n != 4)
|
||||
luaL_argcheck(L, 0, stackIndex, "at least 3 of the 4 color components have to be specified");
|
||||
|
||||
// Rote Farbkomponente auslesen
|
||||
lua_rawgeti(L, StackIndex, 1);
|
||||
uint Red = static_cast<uint>(lua_tonumber(L, -1));
|
||||
if (!lua_isnumber(L, -1) || Red >= 256) luaL_argcheck(L, 0, StackIndex, "red color component must be an integer between 0 and 255");
|
||||
// Red color component reading
|
||||
lua_rawgeti(L, stackIndex, 1);
|
||||
uint red = static_cast<uint>(lua_tonumber(L, -1));
|
||||
if (!lua_isnumber(L, -1) || red >= 256)
|
||||
luaL_argcheck(L, 0, stackIndex, "red color component must be an integer between 0 and 255");
|
||||
lua_pop(L, 1);
|
||||
|
||||
// Grüne Farbkomponente auslesen
|
||||
lua_rawgeti(L, StackIndex, 2);
|
||||
uint Green = static_cast<uint>(lua_tonumber(L, -1));
|
||||
if (!lua_isnumber(L, -1) || Green >= 256) luaL_argcheck(L, 0, StackIndex, "green color component must be an integer between 0 and 255");
|
||||
// Green color component reading
|
||||
lua_rawgeti(L, stackIndex, 2);
|
||||
uint green = static_cast<uint>(lua_tonumber(L, -1));
|
||||
if (!lua_isnumber(L, -1) || green >= 256)
|
||||
luaL_argcheck(L, 0, stackIndex, "green color component must be an integer between 0 and 255");
|
||||
lua_pop(L, 1);
|
||||
|
||||
// Blaue Farbkomponente auslesen
|
||||
lua_rawgeti(L, StackIndex, 3);
|
||||
uint Blue = static_cast<uint>(lua_tonumber(L, -1));
|
||||
if (!lua_isnumber(L, -1) || Blue >= 256) luaL_argcheck(L, 0, StackIndex, "blue color component must be an integer between 0 and 255");
|
||||
// Blue color component reading
|
||||
lua_rawgeti(L, stackIndex, 3);
|
||||
uint blue = static_cast<uint>(lua_tonumber(L, -1));
|
||||
if (!lua_isnumber(L, -1) || blue >= 256)
|
||||
luaL_argcheck(L, 0, stackIndex, "blue color component must be an integer between 0 and 255");
|
||||
lua_pop(L, 1);
|
||||
|
||||
// Alpha Farbkomponente auslesen
|
||||
uint Alpha = 0xff;
|
||||
// Alpha color component reading
|
||||
uint alpha = 0xff;
|
||||
if (n == 4) {
|
||||
lua_rawgeti(L, StackIndex, 4);
|
||||
Alpha = static_cast<uint>(lua_tonumber(L, -1));
|
||||
if (!lua_isnumber(L, -1) || Alpha >= 256) luaL_argcheck(L, 0, StackIndex, "alpha color component must be an integer between 0 and 255");
|
||||
lua_rawgeti(L, stackIndex, 4);
|
||||
alpha = static_cast<uint>(lua_tonumber(L, -1));
|
||||
if (!lua_isnumber(L, -1) || alpha >= 256)
|
||||
luaL_argcheck(L, 0, stackIndex, "alpha color component must be an integer between 0 and 255");
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
|
||||
@ -514,11 +505,11 @@ uint GraphicEngine::LuaColorToARGBColor(lua_State *L, int StackIndex) {
|
||||
BS_ASSERT(__startStackDepth == lua_gettop(L));
|
||||
#endif
|
||||
|
||||
return (Alpha << 24) | (Red << 16) | (Green << 8) | Blue;
|
||||
return (alpha << 24) | (red << 16) | (green << 8) | blue;
|
||||
}
|
||||
|
||||
bool GraphicEngine::persist(OutputPersistenceBlock &writer) {
|
||||
writer.write(m_TimerActive);
|
||||
writer.write(_timerActive);
|
||||
|
||||
bool result = _renderObjectManagerPtr->persist(writer);
|
||||
|
||||
@ -526,7 +517,7 @@ bool GraphicEngine::persist(OutputPersistenceBlock &writer) {
|
||||
}
|
||||
|
||||
bool GraphicEngine::unpersist(InputPersistenceBlock &reader) {
|
||||
reader.read(m_TimerActive);
|
||||
reader.read(_timerActive);
|
||||
_renderObjectManagerPtr->unpersist(reader);
|
||||
|
||||
return reader.isGood();
|
||||
|
@ -33,7 +33,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* BS_GraphicEngine
|
||||
* GraphicEngine
|
||||
* ----------------
|
||||
* This the graphics engine interface.
|
||||
*
|
||||
@ -64,10 +64,8 @@ class Panel;
|
||||
class Screenshot;
|
||||
class RenderObjectManager;
|
||||
|
||||
// Types
|
||||
typedef uint BS_COLOR;
|
||||
|
||||
// Macros
|
||||
#define BS_RGB(R,G,B) (0xFF000000 | ((R) << 16) | ((G) << 8) | (B))
|
||||
#define BS_ARGB(A,R,G,B) (((A) << 24) | ((R) << 16) | ((G) << 8) | (B))
|
||||
|
||||
@ -122,7 +120,7 @@ public:
|
||||
* @param BackbufferCount The number of back buffers to be created. The default value is 2
|
||||
* @param Windowed Indicates whether the engine is to run in windowed mode.
|
||||
*/
|
||||
bool Init(int Width = 800, int Height = 600, int BitDepth = 16, int BackbufferCount = 2, bool Windowed = false);
|
||||
bool init(int width = 800, int height = 600, int bitDepth = 16, int backbufferCount = 2, bool windowed = false);
|
||||
|
||||
/**
|
||||
* Begins rendering a new frame.
|
||||
@ -131,7 +129,7 @@ public:
|
||||
* @param 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 StartFrame(bool UpdateAll = false);
|
||||
bool startFrame(bool updateAll = false);
|
||||
|
||||
/**
|
||||
* Ends the rendering of a frame and draws it on the screen.
|
||||
@ -139,7 +137,7 @@ public:
|
||||
* 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.
|
||||
*/
|
||||
bool EndFrame();
|
||||
bool endFrame();
|
||||
|
||||
// Debug methods
|
||||
|
||||
@ -153,7 +151,7 @@ public:
|
||||
* @param End The ending point of the line
|
||||
* @param Color The colour of the line. The default is BS_RGB (255,255,255) (White)
|
||||
*/
|
||||
void DrawDebugLine(const Vertex &Start, const Vertex &End, uint Color = BS_RGB(255, 255, 255));
|
||||
void drawDebugLine(const Vertex &start, const Vertex &end, uint color = BS_RGB(255, 255, 255));
|
||||
|
||||
/**
|
||||
* Creates a screenshot of the current frame buffer and writes it to a graphic file in PNG format.
|
||||
@ -161,7 +159,7 @@ public:
|
||||
* Notes: This method should only be called after a call to EndFrame(), and before the next call to StartFrame().
|
||||
* @param Filename The filename for the screenshot
|
||||
*/
|
||||
bool SaveScreenshot(const Common::String &Filename);
|
||||
bool saveScreenshot(const Common::String &filename);
|
||||
|
||||
/**
|
||||
* Creates a thumbnail with the dimensions of 200x125. This will not include the top and bottom of the screen..
|
||||
@ -170,7 +168,7 @@ public:
|
||||
* The frame buffer must have a resolution of 800x600.
|
||||
* @param Filename The filename for the screenshot
|
||||
*/
|
||||
bool SaveThumbnailScreenshot(const Common::String &Filename);
|
||||
bool saveThumbnailScreenshot(const Common::String &filename);
|
||||
|
||||
/**
|
||||
* Reads the current contents of the frame buffer
|
||||
@ -180,37 +178,39 @@ public:
|
||||
* @param Height Returns the height of the frame buffer
|
||||
* @param Data Returns the raw data of the frame buffer as an array of 32-bit colour values.
|
||||
*/
|
||||
Graphics::Surface *GetScreenshot();
|
||||
Graphics::Surface *getScreenshot();
|
||||
|
||||
|
||||
RenderObjectPtr<Panel> GetMainPanel();
|
||||
RenderObjectPtr<Panel> getMainPanel();
|
||||
|
||||
/**
|
||||
* Specifies the time (in microseconds) since the last frame has passed
|
||||
*/
|
||||
int GetLastFrameDurationMicro() const {
|
||||
if (!m_TimerActive)
|
||||
int getLastFrameDurationMicro() const {
|
||||
if (!_timerActive)
|
||||
return 0;
|
||||
return m_LastFrameDuration;
|
||||
return _lastFrameDuration;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specifies the time (in microseconds) the previous frame took
|
||||
*/
|
||||
float GetLastFrameDuration() const {
|
||||
if (!m_TimerActive)
|
||||
float getLastFrameDuration() const {
|
||||
if (!_timerActive)
|
||||
return 0;
|
||||
return static_cast<float>(m_LastFrameDuration) / 1000000.0f;
|
||||
return static_cast<float>(_lastFrameDuration) / 1000000.0f;
|
||||
}
|
||||
|
||||
void StopMainTimer() {
|
||||
m_TimerActive = false;
|
||||
void stopMainTimer() {
|
||||
_timerActive = false;
|
||||
}
|
||||
void ResumeMainTimer() {
|
||||
m_TimerActive = true;
|
||||
|
||||
void resumeMainTimer() {
|
||||
_timerActive = true;
|
||||
}
|
||||
float GetSecondaryFrameDuration() const {
|
||||
return static_cast<float>(m_LastFrameDuration) / 1000000.0f;
|
||||
|
||||
float getSecondaryFrameDuration() const {
|
||||
return static_cast<float>(_lastFrameDuration) / 1000000.0f;
|
||||
}
|
||||
|
||||
// Accessor methods
|
||||
@ -218,28 +218,28 @@ public:
|
||||
/**
|
||||
* Returns the width of the output buffer in pixels
|
||||
*/
|
||||
int GetDisplayWidth() const {
|
||||
int getDisplayWidth() const {
|
||||
return _width;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the height of the output buffer in pixels
|
||||
*/
|
||||
int GetDisplayHeight() const {
|
||||
int getDisplayHeight() const {
|
||||
return _height;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the bounding box of the output buffer: (0, 0, Width, Height)
|
||||
*/
|
||||
Common::Rect &GetDisplayRect() {
|
||||
Common::Rect &getDisplayRect() {
|
||||
return _screenRect;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the bit depth of the output buffer
|
||||
*/
|
||||
int GetBitDepth() {
|
||||
int getBitDepth() {
|
||||
return _bitDepth;
|
||||
}
|
||||
|
||||
@ -248,19 +248,19 @@ public:
|
||||
* Notes: In windowed mode, this setting has no effect.
|
||||
* @param Vsync Indicates whether the frame buffer changes are to be synchronised with Vsync.
|
||||
*/
|
||||
void SetVsync(bool Vsync);
|
||||
void setVsync(bool vsync);
|
||||
|
||||
/**
|
||||
* Returns true if V-Sync is on.
|
||||
* Notes: In windowed mode, this setting has no effect.
|
||||
*/
|
||||
bool GetVsync() const;
|
||||
bool getVsync() const;
|
||||
|
||||
/**
|
||||
* Returns true if the engine is running in Windowed mode.
|
||||
*/
|
||||
bool IsWindowed() {
|
||||
return m_Windowed;
|
||||
bool isWindowed() {
|
||||
return _windowed;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -272,15 +272,15 @@ public:
|
||||
* @param Color The 32-bit colour 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.
|
||||
*/
|
||||
bool fill(const Common::Rect *FillRectPtr = 0, uint Color = BS_RGB(0, 0, 0));
|
||||
bool fill(const Common::Rect *fillRectPtr = 0, uint color = BS_RGB(0, 0, 0));
|
||||
|
||||
// Debugging Methods
|
||||
|
||||
int GetFPSCount() const {
|
||||
return m_FPSCounter.GetFPS();
|
||||
int getFPSCount() const {
|
||||
return _FPSCounter.getFPS();
|
||||
}
|
||||
int GetRepaintedPixels() const {
|
||||
return m_RepaintedPixels;
|
||||
int getRepaintedPixels() const {
|
||||
return _repaintedPixels;
|
||||
}
|
||||
|
||||
Graphics::Surface _backSurface;
|
||||
@ -299,8 +299,8 @@ public:
|
||||
* @param ColorFormat The desired colour format. The parameter must be of type COLOR_FORMATS
|
||||
* @return Returns the size of a pixel in bytes. If the colour format is unknown, -1 is returned.
|
||||
*/
|
||||
static int GetPixelSize(GraphicEngine::COLOR_FORMATS ColorFormat) {
|
||||
switch (ColorFormat) {
|
||||
static int getPixelSize(GraphicEngine::COLOR_FORMATS colorFormat) {
|
||||
switch (colorFormat) {
|
||||
case GraphicEngine::CF_ARGB32:
|
||||
return 4;
|
||||
default:
|
||||
@ -315,10 +315,10 @@ public:
|
||||
* @return Reflects the length of the line in bytes. If the colour format is
|
||||
* unknown, -1 is returned
|
||||
*/
|
||||
static int CalcPitch(GraphicEngine::COLOR_FORMATS ColorFormat, int Width) {
|
||||
switch (ColorFormat) {
|
||||
static int calcPitch(GraphicEngine::COLOR_FORMATS colorFormat, int width) {
|
||||
switch (colorFormat) {
|
||||
case GraphicEngine::CF_ARGB32:
|
||||
return Width * 4;
|
||||
return width * 4;
|
||||
|
||||
default:
|
||||
BS_ASSERT(false);
|
||||
@ -329,69 +329,69 @@ public:
|
||||
|
||||
// Resource-Managing Methods
|
||||
// --------------------------
|
||||
virtual Resource *loadResource(const Common::String &fileName);
|
||||
virtual bool canLoadResource(const Common::String &fileName);
|
||||
virtual Resource *loadResource(const Common::String &fileName);
|
||||
virtual bool canLoadResource(const Common::String &fileName);
|
||||
|
||||
// Persistence Methods
|
||||
// -------------------
|
||||
virtual bool persist(OutputPersistenceBlock &Writer);
|
||||
virtual bool unpersist(InputPersistenceBlock &Reader);
|
||||
virtual bool persist(OutputPersistenceBlock &writer);
|
||||
virtual bool unpersist(InputPersistenceBlock &reader);
|
||||
|
||||
static void ARGBColorToLuaColor(lua_State *L, uint Color);
|
||||
static uint LuaColorToARGBColor(lua_State *L, int StackIndex);
|
||||
static void ARGBColorToLuaColor(lua_State *L, uint color);
|
||||
static uint luaColorToARGBColor(lua_State *L, int stackIndex);
|
||||
|
||||
protected:
|
||||
|
||||
// Display Variables
|
||||
// -----------------
|
||||
int _width;
|
||||
int _height;
|
||||
int _width;
|
||||
int _height;
|
||||
Common::Rect _screenRect;
|
||||
int _bitDepth;
|
||||
bool m_Windowed;
|
||||
int _bitDepth;
|
||||
bool _windowed;
|
||||
|
||||
// Debugging Variables
|
||||
// -------------------
|
||||
Framecounter m_FPSCounter;
|
||||
Framecounter _FPSCounter;
|
||||
|
||||
uint m_RepaintedPixels;
|
||||
uint _repaintedPixels;
|
||||
|
||||
/**
|
||||
* Calculates the time since the last frame beginning has passed.
|
||||
*/
|
||||
void UpdateLastFrameDuration();
|
||||
void updateLastFrameDuration();
|
||||
|
||||
private:
|
||||
bool RegisterScriptBindings();
|
||||
bool registerScriptBindings();
|
||||
|
||||
// LastFrameDuration Variables
|
||||
// ---------------------------
|
||||
uint m_LastTimeStamp;
|
||||
uint m_LastFrameDuration;
|
||||
bool m_TimerActive;
|
||||
Common::Array<uint> m_FrameTimeSamples;
|
||||
uint m_FrameTimeSampleSlot;
|
||||
uint _lastTimeStamp;
|
||||
uint _lastFrameDuration;
|
||||
bool _timerActive;
|
||||
Common::Array<uint> _frameTimeSamples;
|
||||
uint _frameTimeSampleSlot;
|
||||
|
||||
private:
|
||||
byte *_backBuffer;
|
||||
|
||||
RenderObjectPtr<Panel> m_MainPanelPtr;
|
||||
RenderObjectPtr<Panel> _mainPanelPtr;
|
||||
|
||||
Common::ScopedPtr<RenderObjectManager> _renderObjectManagerPtr;
|
||||
Common::ScopedPtr<RenderObjectManager> _renderObjectManagerPtr;
|
||||
|
||||
struct DebugLine {
|
||||
DebugLine(const Vertex &_Start, const Vertex &_End, uint _Color) :
|
||||
Start(_Start),
|
||||
End(_End),
|
||||
Color(_Color) {}
|
||||
DebugLine(const Vertex &start, const Vertex &end, uint color) :
|
||||
_start(start),
|
||||
_end(end),
|
||||
_color(color) {}
|
||||
DebugLine() {}
|
||||
|
||||
Vertex Start;
|
||||
Vertex End;
|
||||
uint Color;
|
||||
Vertex _start;
|
||||
Vertex _end;
|
||||
uint _color;
|
||||
};
|
||||
|
||||
Common::Array<DebugLine> m_DebugLines;
|
||||
Common::Array<DebugLine> _debugLines;
|
||||
};
|
||||
|
||||
} // End of namespace Sword25
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -108,7 +108,7 @@ bool PNGLoader::DoDecodeImage(const byte *FileDataPtr, uint FileSize, GraphicEn
|
||||
png_get_IHDR(png_ptr, info_ptr, (png_uint_32 *)&Width, (png_uint_32 *)&Height, &BitDepth, &ColorType, &InterlaceType, NULL, NULL);
|
||||
|
||||
// Pitch des Ausgabebildes berechnen
|
||||
Pitch = GraphicEngine::CalcPitch(ColorFormat, Width);
|
||||
Pitch = GraphicEngine::calcPitch(ColorFormat, Width);
|
||||
|
||||
// Speicher für die endgültigen Bilddaten reservieren
|
||||
// Dieses geschieht vor dem reservieren von Speicher für temporäre Bilddaten um die Fragmentierung des Speichers gering zu halten
|
||||
|
@ -63,7 +63,7 @@ void RenderObjectManager::startFrame() {
|
||||
_frameStarted = true;
|
||||
|
||||
// Verstrichene Zeit bestimmen
|
||||
int timeElapsed = Kernel::GetInstance()->GetGfx()->GetLastFrameDurationMicro();
|
||||
int timeElapsed = Kernel::GetInstance()->GetGfx()->getLastFrameDurationMicro();
|
||||
|
||||
// Alle BS_TimedRenderObject Objekte über den Framestart und die verstrichene Zeit in Kenntnis setzen
|
||||
RenderObjectList::iterator iter = _timedRenderObjects.begin();
|
||||
|
@ -368,9 +368,9 @@ static void drawPolygon(const Polygon &polygon, uint color, const Vertex &offset
|
||||
BS_ASSERT(pGE);
|
||||
|
||||
for (int i = 0; i < polygon.vertexCount - 1; i++)
|
||||
pGE->DrawDebugLine(polygon.vertices[i] + offset, polygon.vertices[i + 1] + offset, color);
|
||||
pGE->drawDebugLine(polygon.vertices[i] + offset, polygon.vertices[i + 1] + offset, color);
|
||||
|
||||
pGE->DrawDebugLine(polygon.vertices[polygon.vertexCount - 1] + offset, polygon.vertices[0] + offset, color);
|
||||
pGE->drawDebugLine(polygon.vertices[polygon.vertexCount - 1] + offset, polygon.vertices[0] + offset, color);
|
||||
}
|
||||
|
||||
static void drawRegion(const Region ®ion, uint color, const Vertex &offset) {
|
||||
@ -387,12 +387,12 @@ static int r_draw(lua_State *L) {
|
||||
case 3: {
|
||||
Vertex offset;
|
||||
Vertex::luaVertexToVertex(L, 3, offset);
|
||||
drawRegion(*pR, GraphicEngine::LuaColorToARGBColor(L, 2), offset);
|
||||
drawRegion(*pR, GraphicEngine::luaColorToARGBColor(L, 2), offset);
|
||||
}
|
||||
break;
|
||||
|
||||
case 2:
|
||||
drawRegion(*pR, GraphicEngine::LuaColorToARGBColor(L, 2), Vertex(0, 0));
|
||||
drawRegion(*pR, GraphicEngine::luaColorToARGBColor(L, 2), Vertex(0, 0));
|
||||
break;
|
||||
|
||||
default:
|
||||
|
Loading…
x
Reference in New Issue
Block a user