ENGINES: Use ScummVM's 2D API for blitting the TinyGL framebuffer (#2516)

* GRIM: Use ScummVM's 2D API for blitting the TinyGL framebuffer

* MYST3: Use ScummVM's 2D API for blitting the TinyGL framebuffer

* ICB: Use ScummVM's 2D API for blitting the TinyGL framebuffer
This commit is contained in:
Cameron Cawley 2020-10-13 21:12:10 +01:00 committed by GitHub
parent 4c9dd2ce3c
commit b19857bd8c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 21 additions and 11 deletions

View File

@ -78,8 +78,6 @@ GfxTinyGL::~GfxTinyGL() {
}
void GfxTinyGL::setupScreen(int screenW, int screenH, bool fullscreen) {
Graphics::PixelBuffer buf = g_system->getScreenPixelBuffer();
_screenWidth = screenW;
_screenHeight = screenH;
_scaleW = _screenWidth / (float)_gameWidth;
@ -87,9 +85,9 @@ void GfxTinyGL::setupScreen(int screenW, int screenH, bool fullscreen) {
g_system->showMouse(!fullscreen);
_pixelFormat = buf.getFormat();
_pixelFormat = g_system->getScreenFormat();
debug("INFO: TinyGL front buffer pixel format: %s", _pixelFormat.toString().c_str());
_zb = new TinyGL::FrameBuffer(screenW, screenH, buf);
_zb = new TinyGL::FrameBuffer(screenW, screenH, _pixelFormat);
TinyGL::glInit(_zb, 256);
tglEnableDirtyRects(ConfMan.getBool("dirtyrects"));
@ -176,6 +174,8 @@ void GfxTinyGL::clearDepthBuffer() {
void GfxTinyGL::flipBuffer() {
TinyGL::tglPresentBuffer();
g_system->copyRectToScreen(_zb->getPixelBuffer(), _zb->linesize,
0, 0, _zb->xsize, _zb->ysize);
g_system->updateScreen();
}

View File

@ -269,7 +269,11 @@ GfxBase *GrimEngine::createRenderer(int screenW, int screenH, bool fullscreen) {
Graphics::RendererType matchingRendererType = Graphics::getBestMatchingAvailableRendererType(desiredRendererType);
_softRenderer = matchingRendererType == Graphics::kRendererTypeTinyGL;
initGraphics3d(screenW, screenH, fullscreen, !_softRenderer);
if (!_softRenderer) {
initGraphics3d(screenW, screenH, fullscreen, true);
} else {
initGraphics(screenW, screenH, nullptr);
}
#if defined(USE_OPENGL_GAME)
// Check the OpenGL context actually supports shaders

View File

@ -193,10 +193,9 @@ unsigned int _surface_manager::Init_direct_draw() {
Zdebug("*SURFACE_MANAGER* Initalizing the SDL video interface");
g_system->setWindowCaption("In Cold Blood (C)2000 Revolution Software Ltd");
initGraphics3d(640, 480, ConfMan.getBool("fullscreen"), false);
initGraphics(640, 480, nullptr);
Graphics::PixelBuffer pixBuff = g_system->getScreenPixelBuffer();
_zb = new TinyGL::FrameBuffer(640, 480, pixBuff); // TODO: delete
_zb = new TinyGL::FrameBuffer(640, 480, g_system->getScreenFormat()); // TODO: delete
TinyGL::glInit(_zb, 256);
sdl_screen = new Graphics::Surface();
@ -413,6 +412,8 @@ void _surface_manager::Flip() {
Graphics::tglUploadBlitImage(blitImage, *sdl_screen, 0, false);
Graphics::tglBlitFast(blitImage, 0, 0);
TinyGL::tglPresentBuffer();
g_system->copyRectToScreen(_zb->getPixelBuffer(), _zb->linesize,
0, 0, _zb->xsize, _zb->ysize);
g_system->updateScreen();
Graphics::tglDeleteBlitImage(blitImage);
#endif

View File

@ -204,7 +204,11 @@ Renderer *createRenderer(OSystem *system) {
width = Renderer::kOriginalWidth;
}
initGraphics3d(width, height, fullscreen, isAccelerated);
if (isAccelerated) {
initGraphics3d(width, height, fullscreen, true);
} else {
initGraphics(width, height, nullptr);
}
#if defined(USE_OPENGL_GAME)
// Check the OpenGL context actually supports shaders

View File

@ -63,8 +63,7 @@ void TinyGLRenderer::init() {
computeScreenViewport();
Graphics::PixelBuffer screenBuffer = _system->getScreenPixelBuffer();
_fb = new TinyGL::FrameBuffer(kOriginalWidth, kOriginalHeight, screenBuffer);
_fb = new TinyGL::FrameBuffer(kOriginalWidth, kOriginalHeight, g_system->getScreenFormat());
TinyGL::glInit(_fb, 512);
tglEnableDirtyRects(ConfMan.getBool("dirtyrects"));
@ -291,6 +290,8 @@ Graphics::Surface *TinyGLRenderer::getScreenshot() {
void TinyGLRenderer::flipBuffer() {
TinyGL::tglPresentBuffer();
g_system->copyRectToScreen(_fb->getPixelBuffer(), _fb->linesize,
0, 0, _fb->xsize, _fb->ysize);
}
} // End of namespace Myst3