mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-19 16:33:50 +00:00
HPL1: implement thumbnail method in metaengine
This commit is contained in:
parent
8f8617a5d7
commit
fa822ef0c2
@ -25,6 +25,9 @@
|
||||
#include "common/translation.h"
|
||||
#include "hpl1/detection.h"
|
||||
#include "hpl1/hpl1.h"
|
||||
#include "hpl1/opengl.h"
|
||||
#include "graphics/scaler.h"
|
||||
#include "graphics/thumbnail.h"
|
||||
#include "common/savefile.h"
|
||||
#include "common/system.h"
|
||||
|
||||
@ -47,6 +50,15 @@ bool Hpl1MetaEngine::hasFeature(MetaEngineFeature f) const {
|
||||
(f == kSupportsLoadingDuringStartup);
|
||||
}
|
||||
|
||||
void Hpl1MetaEngine::getSavegameThumbnail(Graphics::Surface &thumbnail) {
|
||||
Common::ScopedPtr<Graphics::Surface> screen = Hpl1::createViewportScreenshot();
|
||||
Common::ScopedPtr<Graphics::Surface> scaledScreen(screen->scale( kThumbnailWidth, kThumbnailHeight2));
|
||||
scaledScreen->convertToInPlace(Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0));
|
||||
thumbnail.copyFrom(*scaledScreen);
|
||||
screen->free();
|
||||
scaledScreen->free();
|
||||
}
|
||||
|
||||
static Common::U32String formatSave(const Common::String &filename) {
|
||||
const int begin = filename.findFirstOf('.') + 1;
|
||||
const int len = filename.findLastOf('_') - begin;
|
||||
|
@ -39,6 +39,8 @@ public:
|
||||
|
||||
SaveStateList listSaves(const char *target) const override;
|
||||
|
||||
void getSavegameThumbnail(Graphics::Surface &thumbnail) override;
|
||||
|
||||
Common::Array<Common::Keymap *> initKeymaps(const char *target) const override;
|
||||
};
|
||||
|
||||
|
@ -21,6 +21,9 @@
|
||||
|
||||
#include "hpl1/opengl.h"
|
||||
#include "hpl1/debug.h"
|
||||
#include "common/rect.h"
|
||||
#include "graphics/surface.h"
|
||||
#include "common/system.h"
|
||||
|
||||
namespace Hpl1 {
|
||||
|
||||
@ -42,4 +45,28 @@ void checkOGLErrors(const char *function, const int line) {
|
||||
logError(kDebugOpenGL, "Opengl error: \'%s\' in function %s - %d\n", getErrorString(code), function, line);
|
||||
}
|
||||
|
||||
|
||||
static Common::Rect getGLViewport() {
|
||||
int viewportSize[4];
|
||||
GL_CHECK(glGetIntegerv(GL_VIEWPORT, viewportSize));
|
||||
return Common::Rect(viewportSize[0], viewportSize[1], viewportSize[2], viewportSize[3]);
|
||||
}
|
||||
|
||||
static Graphics::PixelFormat getRGBAPixelFormat() {
|
||||
#ifdef SCUMM_BIG_ENDIAN
|
||||
return Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0);
|
||||
#else
|
||||
return Graphics::PixelFormat(4, 8, 8, 8, 8, 0, 8, 16, 24);
|
||||
#endif
|
||||
}
|
||||
|
||||
Common::ScopedPtr<Graphics::Surface> createViewportScreenshot() {
|
||||
Common::ScopedPtr<Graphics::Surface> screen(new Graphics::Surface());
|
||||
Common::Rect viewportSize = getGLViewport();
|
||||
screen->create(viewportSize.width(), viewportSize.height(), getRGBAPixelFormat());
|
||||
GL_CHECK(glReadPixels(viewportSize.left, g_system->getHeight() - viewportSize.bottom, viewportSize.width(), viewportSize.height(), GL_RGBA, GL_UNSIGNED_BYTE, screen->getPixels()));
|
||||
screen->flipVertical(Common::Rect(screen->w, screen->h));
|
||||
return screen;
|
||||
}
|
||||
|
||||
} // End of namespace Hpl1
|
@ -26,11 +26,20 @@
|
||||
#define USE_GLAD
|
||||
#include "graphics/opengl/system_headers.h"
|
||||
#include "graphics/opengl/context.h"
|
||||
#include "common/ptr.h"
|
||||
|
||||
namespace Graphics {
|
||||
|
||||
class Surface;
|
||||
|
||||
}
|
||||
|
||||
namespace Hpl1 {
|
||||
|
||||
void checkOGLErrors(const char *function, int line);
|
||||
|
||||
Common::ScopedPtr<Graphics::Surface> createViewportScreenshot();
|
||||
|
||||
}
|
||||
|
||||
#define GL_CHECK(x) {x; ::Hpl1::checkOGLErrors(__func__, __LINE__);}
|
||||
|
Loading…
x
Reference in New Issue
Block a user