mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-04 01:46:42 +00:00
FREESCAPE: make sure thumbnail image is always created from the screen
This commit is contained in:
parent
8b310f1271
commit
ae0620cbf4
@ -100,6 +100,17 @@ bool Renderer::getRGBAt(uint8 index, uint8 &r, uint8 &g, uint8 &b) {
|
||||
return true;
|
||||
}
|
||||
|
||||
void Renderer::flipVertical(Graphics::Surface *s) {
|
||||
for (int y = 0; y < s->h / 2; ++y) {
|
||||
// Flip the lines
|
||||
byte *line1P = (byte *)s->getBasePtr(0, y);
|
||||
byte *line2P = (byte *)s->getBasePtr(0, s->h - y - 1);
|
||||
|
||||
for (int x = 0; x < s->pitch; ++x)
|
||||
SWAP(line1P[x], line2P[x]);
|
||||
}
|
||||
}
|
||||
|
||||
void Renderer::convertImageFormatIfNecessary(Graphics::Surface *surface) {
|
||||
if (!surface)
|
||||
return;
|
||||
|
@ -113,7 +113,7 @@ public:
|
||||
virtual void updateProjectionMatrix(float fov, float nearClipPlane, float farClipPlane) = 0;
|
||||
|
||||
Math::Matrix4 getMvpMatrix() const { return _mvpMatrix; }
|
||||
|
||||
virtual Graphics::Surface *getScreenshot() = 0;
|
||||
void flipVertical(Graphics::Surface *s);
|
||||
|
||||
int _screenW;
|
||||
|
@ -298,4 +298,18 @@ void OpenGLRenderer::drawFloor(uint8 color) {
|
||||
|
||||
void OpenGLRenderer::flipBuffer() {}
|
||||
|
||||
Graphics::Surface *OpenGLRenderer::getScreenshot() {
|
||||
Common::Rect screen = viewport();
|
||||
|
||||
Graphics::Surface *s = new Graphics::Surface();
|
||||
s->create(screen.width(), screen.height(), OpenGLTexture::getRGBAPixelFormat());
|
||||
|
||||
glReadPixels(screen.left, screen.top, screen.width(), screen.height(), GL_RGBA, GL_UNSIGNED_BYTE, s->getPixels());
|
||||
|
||||
flipVertical(s);
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
} // End of namespace Freescape
|
||||
|
@ -79,6 +79,8 @@ public:
|
||||
|
||||
virtual void flipBuffer() override;
|
||||
virtual void drawFloor(uint8 color) override;
|
||||
|
||||
virtual Graphics::Surface *getScreenshot() override;
|
||||
};
|
||||
|
||||
} // End of namespace Freescape
|
||||
|
@ -255,4 +255,15 @@ void TinyGLRenderer::flipBuffer() {
|
||||
}
|
||||
}
|
||||
|
||||
Graphics::Surface *TinyGLRenderer::getScreenshot() {
|
||||
Graphics::Surface glBuffer;
|
||||
TinyGL::getSurfaceRef(glBuffer);
|
||||
|
||||
Graphics::Surface *s = new Graphics::Surface();
|
||||
s->create(_screenW, _screenH, TinyGLTexture::getRGBAPixelFormat());
|
||||
s->copyFrom(glBuffer);
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
} // End of namespace Freescape
|
||||
|
@ -65,6 +65,7 @@ public:
|
||||
|
||||
virtual void flipBuffer() override;
|
||||
virtual void drawFloor(uint8 color) override;
|
||||
virtual Graphics::Surface *getScreenshot() override;
|
||||
};
|
||||
|
||||
} // End of namespace Freescape
|
||||
|
@ -20,10 +20,14 @@
|
||||
*/
|
||||
|
||||
#include "common/translation.h"
|
||||
#include "graphics/thumbnail.h"
|
||||
#include "graphics/scaler.h"
|
||||
|
||||
|
||||
#include "freescape/freescape.h"
|
||||
#include "freescape/detection.h"
|
||||
|
||||
|
||||
static const ADExtraGuiOptionsMap optionsList[] = {
|
||||
{
|
||||
GAMEOPTION_PRERECORDED_SOUNDS,
|
||||
@ -84,6 +88,7 @@ public:
|
||||
}
|
||||
|
||||
Common::Error createInstance(OSystem *syst, Engine **engine, const ADGameDescription *gd) const override;
|
||||
void getSavegameThumbnail(Graphics::Surface &thumb) override;
|
||||
};
|
||||
|
||||
Common::Error FreescapeMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *gd) const {
|
||||
@ -101,6 +106,21 @@ Common::Error FreescapeMetaEngine::createInstance(OSystem *syst, Engine **engine
|
||||
return Common::kNoError;
|
||||
}
|
||||
|
||||
void FreescapeMetaEngine::getSavegameThumbnail(Graphics::Surface &thumb) {
|
||||
Freescape::FreescapeEngine *engine = (Freescape::FreescapeEngine *)g_engine;
|
||||
Graphics::Surface *savedScreen = engine->_gfx->getScreenshot();
|
||||
assert(savedScreen);
|
||||
Graphics::Surface *scaledSavedScreen = scale(*savedScreen, kThumbnailWidth, kThumbnailHeight2);
|
||||
assert(scaledSavedScreen);
|
||||
thumb.copyFrom(*scaledSavedScreen);
|
||||
|
||||
scaledSavedScreen->free();
|
||||
delete scaledSavedScreen;
|
||||
|
||||
savedScreen->free();
|
||||
delete savedScreen;
|
||||
}
|
||||
|
||||
namespace Freescape {
|
||||
|
||||
bool FreescapeEngine::isDemo() const {
|
||||
|
Loading…
x
Reference in New Issue
Block a user