EMI: Draw background layers at intervals
Previously, we split the background layers into everything before SO 15 and after, and drew like that. However, this caused the pink ship in shi.setb to not be drawn. This patch draws the layers of the background at intervals of ten. So if a set has six layers, layer 5 is the background and 4,3,2,1,0 are rendered at sortorder 40,30,20,10,0.
This commit is contained in:
parent
d6fb41e77a
commit
a723b0e3f5
10 changed files with 44 additions and 67 deletions
|
@ -432,15 +432,15 @@ void Bitmap::draw(int x, int y) {
|
|||
if (_currImage == 0)
|
||||
return;
|
||||
|
||||
g_driver->drawBitmap(this, x, y);
|
||||
g_driver->drawBitmap(this, x, y, _data->_numLayers - 1);
|
||||
}
|
||||
|
||||
void Bitmap::drawForeground() {
|
||||
void Bitmap::drawLayer(uint32 layer) {
|
||||
_data->load();
|
||||
if (_currImage == 0)
|
||||
return;
|
||||
|
||||
g_driver->drawBitmap(this, _data->_x, _data->_y, false);
|
||||
g_driver->drawBitmap(this, _data->_x, _data->_y, layer);
|
||||
}
|
||||
|
||||
void Bitmap::setActiveImage(int n) {
|
||||
|
|
|
@ -145,7 +145,7 @@ public:
|
|||
void draw();
|
||||
void draw(int x, int y);
|
||||
|
||||
void drawForeground();
|
||||
void drawLayer(uint32 layer);
|
||||
|
||||
/**
|
||||
* Set which image in an animated bitmap to use
|
||||
|
|
|
@ -169,7 +169,7 @@ public:
|
|||
* @see createBitmap
|
||||
* @see destroyBitmap
|
||||
*/
|
||||
virtual void drawBitmap(const Bitmap *bitmap, int x, int y, bool initialDraw = true) = 0;
|
||||
virtual void drawBitmap(const Bitmap *bitmap, int x, int y, uint32 layer = 0) = 0;
|
||||
|
||||
/**
|
||||
* Deletes any internal references and representations of a bitmap
|
||||
|
|
|
@ -838,7 +838,7 @@ void GfxOpenGL::createBitmap(BitmapData *bitmap) {
|
|||
}
|
||||
}
|
||||
|
||||
void GfxOpenGL::drawBitmap(const Bitmap *bitmap, int dx, int dy, bool initialDraw) {
|
||||
void GfxOpenGL::drawBitmap(const Bitmap *bitmap, int dx, int dy, uint32 layer) {
|
||||
|
||||
// The PS2 version of EMI uses a TGA for it's splash-screen
|
||||
// avoid using the TIL-code below for that, by checking
|
||||
|
@ -864,28 +864,17 @@ void GfxOpenGL::drawBitmap(const Bitmap *bitmap, int dx, int dy, bool initialDra
|
|||
GLuint *textures = (GLuint *)bitmap->getTexIds();
|
||||
float *texc = data->_texc;
|
||||
|
||||
int curLayer, frontLayer;
|
||||
if (initialDraw) {
|
||||
curLayer = frontLayer = data->_numLayers - 1;
|
||||
} else {
|
||||
curLayer = data->_numLayers - 2;
|
||||
frontLayer = 0;
|
||||
}
|
||||
|
||||
while (frontLayer <= curLayer) {
|
||||
uint32 offset = data->_layers[curLayer]._offset;
|
||||
for (uint32 i = offset; i < offset + data->_layers[curLayer]._numImages; ++i) {
|
||||
glBindTexture(GL_TEXTURE_2D, textures[data->_verts[i]._texid]);
|
||||
glBegin(GL_QUADS);
|
||||
uint32 ntex = data->_verts[i]._pos * 4;
|
||||
for (uint32 x = 0; x < data->_verts[i]._verts; ++x) {
|
||||
glTexCoord2f(texc[ntex + 2], texc[ntex + 3]);
|
||||
glVertex2f(texc[ntex + 0], texc[ntex + 1]);
|
||||
ntex += 4;
|
||||
}
|
||||
glEnd();
|
||||
uint32 offset = data->_layers[layer]._offset;
|
||||
for (uint32 i = offset; i < offset + data->_layers[layer]._numImages; ++i) {
|
||||
glBindTexture(GL_TEXTURE_2D, textures[data->_verts[i]._texid]);
|
||||
glBegin(GL_QUADS);
|
||||
uint32 ntex = data->_verts[i]._pos * 4;
|
||||
for (uint32 x = 0; x < data->_verts[i]._verts; ++x) {
|
||||
glTexCoord2f(texc[ntex + 2], texc[ntex + 3]);
|
||||
glVertex2f(texc[ntex + 0], texc[ntex + 1]);
|
||||
ntex += 4;
|
||||
}
|
||||
curLayer--;
|
||||
glEnd();
|
||||
}
|
||||
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
|
|
|
@ -92,7 +92,7 @@ public:
|
|||
void destroyMaterial(Texture *material);
|
||||
|
||||
void createBitmap(BitmapData *bitmap);
|
||||
void drawBitmap(const Bitmap *bitmap, int x, int y, bool initialDraw = true);
|
||||
void drawBitmap(const Bitmap *bitmap, int x, int y, uint32 layer);
|
||||
void destroyBitmap(BitmapData *bitmap);
|
||||
|
||||
void createFont(Font *font);
|
||||
|
|
|
@ -953,7 +953,7 @@ void GfxTinyGL::blit(const Graphics::PixelFormat &format, BlitImage *image, byte
|
|||
}
|
||||
}
|
||||
|
||||
void GfxTinyGL::drawBitmap(const Bitmap *bitmap, int x, int y, bool initialDraw) {
|
||||
void GfxTinyGL::drawBitmap(const Bitmap *bitmap, int x, int y, uint32 layer) {
|
||||
|
||||
// PS2 EMI uses a TGA for it's splash-screen, avoid using the following
|
||||
// code for drawing that (as it has no tiles).
|
||||
|
@ -963,37 +963,26 @@ void GfxTinyGL::drawBitmap(const Bitmap *bitmap, int x, int y, bool initialDraw)
|
|||
BitmapData *data = bitmap->_data;
|
||||
float *texc = data->_texc;
|
||||
|
||||
int curLayer, frontLayer;
|
||||
if (initialDraw) {
|
||||
curLayer = frontLayer = data->_numLayers - 1;
|
||||
} else {
|
||||
curLayer = data->_numLayers - 2;
|
||||
frontLayer = 0;
|
||||
}
|
||||
|
||||
BlitImage *b = (BlitImage *)bitmap->getTexIds();
|
||||
|
||||
while (frontLayer <= curLayer) {
|
||||
uint32 offset = data->_layers[curLayer]._offset;
|
||||
for (uint32 i = offset; i < offset + data->_layers[curLayer]._numImages; ++i) {
|
||||
const BitmapData::Vert & v = data->_verts[i];
|
||||
uint32 texId = v._texid;
|
||||
uint32 ntex = data->_verts[i]._pos * 4;
|
||||
uint32 numRects = data->_verts[i]._verts / 4;
|
||||
while (numRects-- > 0) {
|
||||
int dx1 = ((texc[ntex+0] + 1) * _screenWidth) / 2;
|
||||
int dy1 = ((1 - texc[ntex+1]) * _screenHeight) / 2;
|
||||
int dx2 = ((texc[ntex+8] + 1) * _screenWidth) / 2;
|
||||
int dy2 = ((1 - texc[ntex+9]) * _screenHeight) / 2;
|
||||
int srcX = texc[ntex+2] * bitmap->getWidth();
|
||||
int srcY = texc[ntex+3] * bitmap->getHeight();
|
||||
uint32 offset = data->_layers[layer]._offset;
|
||||
for (uint32 i = offset; i < offset + data->_layers[layer]._numImages; ++i) {
|
||||
const BitmapData::Vert & v = data->_verts[i];
|
||||
uint32 texId = v._texid;
|
||||
uint32 ntex = data->_verts[i]._pos * 4;
|
||||
uint32 numRects = data->_verts[i]._verts / 4;
|
||||
while (numRects-- > 0) {
|
||||
int dx1 = ((texc[ntex+0] + 1) * _screenWidth) / 2;
|
||||
int dy1 = ((1 - texc[ntex+1]) * _screenHeight) / 2;
|
||||
int dx2 = ((texc[ntex+8] + 1) * _screenWidth) / 2;
|
||||
int dy2 = ((1 - texc[ntex+9]) * _screenHeight) / 2;
|
||||
int srcX = texc[ntex+2] * bitmap->getWidth();
|
||||
int srcY = texc[ntex+3] * bitmap->getHeight();
|
||||
|
||||
blit(bitmap->getPixelFormat(texId), &b[texId], _zb->pbuf.getRawBuffer(), bitmap->getData(texId).getRawBuffer(),
|
||||
x + dx1, y + dy1, srcX, srcY, dx2 - dx1, dy2 - dy1, b[texId]._width, b[texId]._height, !initialDraw);
|
||||
ntex += 16;
|
||||
}
|
||||
blit(bitmap->getPixelFormat(texId), &b[texId], _zb->pbuf.getRawBuffer(), bitmap->getData(texId).getRawBuffer(),
|
||||
x + dx1, y + dy1, srcX, srcY, dx2 - dx1, dy2 - dy1, b[texId]._width, b[texId]._height, true);
|
||||
ntex += 16;
|
||||
}
|
||||
curLayer--;
|
||||
}
|
||||
|
||||
return;
|
||||
|
|
|
@ -88,7 +88,7 @@ public:
|
|||
void destroyMaterial(Texture *material);
|
||||
|
||||
void createBitmap(BitmapData *bitmap);
|
||||
void drawBitmap(const Bitmap *bitmap, int x, int y, bool initialDraw = true);
|
||||
void drawBitmap(const Bitmap *bitmap, int x, int y, uint32 layer);
|
||||
void destroyBitmap(BitmapData *bitmap);
|
||||
|
||||
void createFont(Font *font);
|
||||
|
|
|
@ -562,12 +562,17 @@ void GrimEngine::updateDisplayScene() {
|
|||
a->draw();
|
||||
}
|
||||
} else {
|
||||
bool drewForeground = false;
|
||||
Bitmap *background = _currSet->_currSetup->_bkgndBm;
|
||||
uint32 numLayers = background->_data->_numLayers;
|
||||
int32 currentLayer = numLayers - 1;
|
||||
foreach (Actor *a, _activeActors) {
|
||||
if (a->getSortOrder() < 15 && !drewForeground) {
|
||||
drewForeground = true;
|
||||
_currSet->drawForeground();
|
||||
if (a->getSortOrder() < 0)
|
||||
break;
|
||||
|
||||
while (a->getSortOrder() < currentLayer * 10 && currentLayer >= 0) {
|
||||
background->drawLayer(currentLayer--);
|
||||
}
|
||||
|
||||
if (a->isVisible() && a->getSortOrder() < 100)
|
||||
a->draw();
|
||||
}
|
||||
|
|
|
@ -568,11 +568,6 @@ void Set::setSetup(int num) {
|
|||
g_grim->flagRefreshShadowMask(true);
|
||||
}
|
||||
|
||||
void Set::drawForeground() const {
|
||||
assert(g_grim->getGameType() == GType_MONKEY4);
|
||||
_currSetup->_bkgndBm->drawForeground();
|
||||
}
|
||||
|
||||
void Set::drawBackground() const {
|
||||
if (_currSetup->_bkgndZBm) // Some screens have no zbuffer mask (eg, Alley)
|
||||
_currSetup->_bkgndZBm->draw();
|
||||
|
|
|
@ -56,7 +56,6 @@ public:
|
|||
int _maxVolume;
|
||||
|
||||
void drawBackground() const;
|
||||
void drawForeground() const;
|
||||
void drawBitmaps(ObjectState::Position stage);
|
||||
void setupCamera() {
|
||||
_currSetup->setupCamera();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue