diff options
author | Simei Yin | 2017-07-15 15:58:28 +0200 |
---|---|---|
committer | Simei Yin | 2017-07-15 17:51:57 +0200 |
commit | 3672d99d4e8b892473723e867b7ad1cfcf095363 (patch) | |
tree | d4358ab8bda1a9c6f1ced383c8bf749c1f5f41c6 /engines/sludge | |
parent | c25a6ba4af63cf7f59cb0bd3945243b38607ff88 (diff) | |
download | scummvm-rg350-3672d99d4e8b892473723e867b7ad1cfcf095363.tar.gz scummvm-rg350-3672d99d4e8b892473723e867b7ad1cfcf095363.tar.bz2 scummvm-rg350-3672d99d4e8b892473723e867b7ad1cfcf095363.zip |
SLUDGE: Complete parallax
Diffstat (limited to 'engines/sludge')
-rw-r--r-- | engines/sludge/backdrop.cpp | 103 | ||||
-rw-r--r-- | engines/sludge/backdrop.h | 7 | ||||
-rw-r--r-- | engines/sludge/freeze.cpp | 1 |
3 files changed, 30 insertions, 81 deletions
diff --git a/engines/sludge/backdrop.cpp b/engines/sludge/backdrop.cpp index 84d68fb3fa..c23cd6aaa2 100644 --- a/engines/sludge/backdrop.cpp +++ b/engines/sludge/backdrop.cpp @@ -389,46 +389,26 @@ inline int sortOutPCamera(int cX, int fX, int sceneMax, int boxMax) { void drawBackDrop() { if (!backdropExists) return; - renderSurface.copyRectToSurface(backdropSurface, 0, 0, Common::Rect(0, 0, backdropSurface.w, backdropSurface.h)); -#if 0 - setPrimaryColor(1.0, 1.0, 1.0, 1.0); - - //glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); - glEnable(GL_BLEND); - glUseProgram(shader.smartScaler); - GLuint uniform = glGetUniformLocation(shader.smartScaler, "useLightTexture"); - if (uniform >= 0) glUniform1i(uniform, 0); - - setPMVMatrix(shader.smartScaler); - - if (gameSettings.antiAlias == 1) { - glUniform1i(glGetUniformLocation(shader.smartScaler, "antialias"), 1); - } else { - glUniform1i(glGetUniformLocation(shader.smartScaler, "antialias"), 0); - } + // TODO: apply lightmap shader + // draw parallaxStuff if (parallaxStuff) { + // TODO: simulate image repeating effect + warning("Drawing parallaxStuff"); +#if 0 parallaxLayer *ps = parallaxStuff; + // go to the parallax at bottom while (ps->next) ps = ps->next; + // draw parallax one by one while (ps) { - ps->cameraX = sortOutPCamera(cameraX, ps->fractionX, (int)(sceneWidth - (float)winWidth / cameraZoom), (int)(ps->width - (float)winWidth / cameraZoom)); - ps->cameraY = sortOutPCamera(cameraY, ps->fractionY, (int)(sceneHeight - (float)winHeight / cameraZoom), (int)(ps->height - (float)winHeight / cameraZoom)); - glBindTexture(GL_TEXTURE_2D, ps->textureName); - - float w = (ps->wrapS) ? sceneWidth : ps->width; - float h = (ps->wrapT) ? sceneHeight : ps->height; - float texw; - float texh; - if (!NPOT_textures) { - texw = (ps->wrapS) ? (float) sceneWidth / ps->width : (float) ps->width / getNextPOT(ps->width); - texh = (ps->wrapT) ? (float) sceneHeight / ps->height : (float) ps->height / getNextPOT(ps->height); - } else { - texw = (ps->wrapS) ? (float) sceneWidth / ps->width : 1.0; - texh = (ps->wrapT) ? (float) sceneHeight / ps->height : 1.0; - } + ps->cameraX = sortOutPCamera(cameraX, ps->fractionX, (int)(sceneWidth - (float)winWidth / cameraZoom), (int)(ps->surface.w - (float)winWidth / cameraZoom)); + ps->cameraY = sortOutPCamera(cameraY, ps->fractionY, (int)(sceneHeight - (float)winHeight / cameraZoom), (int)(ps->surface.h - (float)winHeight / cameraZoom)); + + uint w = (ps->wrapS) ? sceneWidth : ps->surface.w; + uint h = (ps->wrapT) ? sceneHeight : ps->surface.h; const GLfloat vertices[] = { (GLfloat) - ps->cameraX, (GLfloat) - ps->cameraY, 0.1f, @@ -447,30 +427,12 @@ void drawBackDrop() { ps = ps->prev; } +#endif } - glBindTexture(GL_TEXTURE_2D, backdropTextureName); - - const GLfloat backdropTexCoords[] = { - 0.0f, 0.0f, - backdropTexW, 0.0f, - 0.0f, backdropTexH, - backdropTexW, backdropTexH - }; - - const GLfloat vertices[] = { - (GLfloat) - cameraX, (GLfloat) - cameraY, 0., - (GLfloat)sceneWidth - (GLfloat)cameraX, (GLfloat) - cameraY, 0., - (GLfloat) - cameraX, (GLfloat)sceneHeight - (GLfloat)cameraY, 0., - (GLfloat)sceneWidth - (GLfloat)cameraX, (GLfloat)sceneHeight - (GLfloat)cameraY, 0. - }; - - drawQuad(shader.smartScaler, vertices, 1, backdropTexCoords); - - glDisable(GL_BLEND); - - glUseProgram(0); -#endif + // draw backdrop + Graphics::TransparentSurface tmp(backdropSurface, false); + tmp.blit(renderSurface, 0, 0); } bool loadLightMap(int v) { @@ -578,22 +540,14 @@ bool loadParallax(uint16 v, uint16 fracX, uint16 fracY) { } nP->prev = NULL; -#if 0 - int picWidth; - int picHeight; - if (!ImgLoader::loadImage(bigDataFile, &nP->surface, 0)) return false; - if (!NPOT_textures) { - picWidth = getNextPOT(picWidth); - picHeight = getNextPOT(picHeight); - } - nP->fileNum = v; nP->fractionX = fracX; nP->fractionY = fracY; + // 65535 is the value of AUTOFIT constant in Sludge if (fracX == 65535) { nP->wrapS = false; if (nP->surface.w < winWidth) { @@ -614,27 +568,18 @@ bool loadParallax(uint16 v, uint16 fracX, uint16 fracY) { nP->wrapT = true; } - glGenTextures(1, &nP->textureName); - glBindTexture(GL_TEXTURE_2D, nP->textureName); + // TODO: reinterpret this part +#if 0 if (nP->wrapS) - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); else - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); if (nP->wrapT) - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); else - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - - if (gameSettings.antiAlias < 0) { - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - } else { - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - } - - texImage2D(GL_TEXTURE_2D, 0, GL_RGBA, picWidth, picHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, nP->texture, nP->textureName); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); #endif + finishAccess(); setResourceForFatal(-1); return true; diff --git a/engines/sludge/backdrop.h b/engines/sludge/backdrop.h index 14a31eb33f..30d5fe2218 100644 --- a/engines/sludge/backdrop.h +++ b/engines/sludge/backdrop.h @@ -38,6 +38,12 @@ enum { extern uint winWidth, winHeight, sceneWidth, sceneHeight; extern int lightMapMode; + +/** + * parallax layers can scroll at different speeds + * to the background image, giving the illusion of + * depth to a scene as it moves. + */ struct parallaxLayer { Graphics::Surface surface; int speedX, speedY; @@ -77,7 +83,6 @@ extern Graphics::Surface lightMap; void killParallax(); bool loadParallax(uint16 v, uint16 fracX, uint16 fracY); void saveParallaxRecursive(parallaxLayer *me, Common::WriteStream *fp); -void reloadParallaxTextures(); void nosnapshot(); bool snapshot(); diff --git a/engines/sludge/freeze.cpp b/engines/sludge/freeze.cpp index deaa4eb7d1..01bc9a669e 100644 --- a/engines/sludge/freeze.cpp +++ b/engines/sludge/freeze.cpp @@ -206,7 +206,6 @@ void unfreeze(bool killImage) { killParallax(); parallaxStuff = frozenStuff->parallaxStuff; - reloadParallaxTextures(); deleteAnim(mouseCursorAnim); mouseCursorAnim = frozenStuff->mouseCursorAnim; |