2012-01-06 23:29:45 +01:00
|
|
|
/* ResidualVM - A 3D game interpreter
|
2011-04-24 15:58:33 +02:00
|
|
|
*
|
2012-01-06 23:29:45 +01:00
|
|
|
* ResidualVM is the legal property of its developers, whose names
|
2011-04-24 15:58:33 +02:00
|
|
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
|
|
|
* file distributed with this source distribution.
|
|
|
|
*
|
2012-12-19 23:15:43 +01:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
2011-04-24 15:58:33 +02:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2012-12-19 23:15:43 +01:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2011-04-24 15:58:33 +02:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "engines/grim/gfx_base.h"
|
|
|
|
#include "engines/grim/savegame.h"
|
|
|
|
|
2013-02-20 23:02:37 +01:00
|
|
|
#include "engines/grim/model.h"
|
|
|
|
|
2011-04-24 15:58:33 +02:00
|
|
|
namespace Grim {
|
|
|
|
|
2011-07-29 23:02:52 +02:00
|
|
|
GfxBase::GfxBase() :
|
2013-10-26 13:57:55 -07:00
|
|
|
_renderBitmaps(true), _renderZBitmaps(true), _shadowModeActive(false),
|
2014-01-06 19:55:47 +01:00
|
|
|
_currentPos(0, 0, 0), _currentQuat(0, 0, 0, 1), _dimLevel(0.0f),
|
|
|
|
_screenWidth(0), _screenHeight(0), _screenSize(0), _isFullscreen(false),
|
|
|
|
_scaleW(1.0f), _scaleH(1.0f), _currentShadowArray(NULL),
|
|
|
|
_shadowColorR(255), _shadowColorG(255), _shadowColorB(255) {
|
2011-07-29 23:02:52 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2011-12-12 18:57:17 +01:00
|
|
|
void GfxBase::setShadowMode() {
|
|
|
|
_shadowModeActive = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void GfxBase::clearShadowMode() {
|
|
|
|
_shadowModeActive = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool GfxBase::isShadowModeActive() {
|
|
|
|
return _shadowModeActive;
|
|
|
|
}
|
|
|
|
|
2011-04-24 15:58:33 +02:00
|
|
|
void GfxBase::saveState(SaveGame *state) {
|
|
|
|
state->beginSection('DRVR');
|
|
|
|
|
|
|
|
byte r, g, b;
|
|
|
|
getShadowColor(&r, &g, &b);
|
2013-07-09 21:14:11 +02:00
|
|
|
state->writeByte(r);
|
|
|
|
state->writeByte(g);
|
|
|
|
state->writeByte(b);
|
2012-01-27 15:09:13 -08:00
|
|
|
state->writeBool(_renderBitmaps);
|
|
|
|
state->writeBool(_renderZBitmaps);
|
2011-04-24 15:58:33 +02:00
|
|
|
|
|
|
|
state->endSection();
|
|
|
|
}
|
|
|
|
|
|
|
|
void GfxBase::restoreState(SaveGame *state) {
|
|
|
|
state->beginSection('DRVR');
|
|
|
|
|
|
|
|
byte r, g, b;
|
|
|
|
r = state->readByte();
|
|
|
|
g = state->readByte();
|
|
|
|
b = state->readByte();
|
2013-07-09 21:12:55 +02:00
|
|
|
setShadowColor(r, g , b);
|
2012-01-27 15:09:13 -08:00
|
|
|
_renderBitmaps = state->readBool();
|
|
|
|
_renderZBitmaps = state->readBool();
|
2011-04-24 15:58:33 +02:00
|
|
|
|
|
|
|
state->endSection();
|
|
|
|
}
|
|
|
|
|
2011-07-29 23:02:52 +02:00
|
|
|
void GfxBase::renderBitmaps(bool render) {
|
|
|
|
_renderBitmaps = render;
|
|
|
|
}
|
|
|
|
|
|
|
|
void GfxBase::renderZBitmaps(bool render) {
|
|
|
|
_renderZBitmaps = render;
|
|
|
|
}
|
|
|
|
|
2013-02-20 23:02:37 +01:00
|
|
|
void GfxBase::drawMesh(const Mesh *mesh) {
|
|
|
|
for (int i = 0; i < mesh->_numFaces; i++)
|
|
|
|
mesh->_faces[i].draw(mesh);
|
|
|
|
}
|
|
|
|
|
2012-01-29 11:40:11 +01:00
|
|
|
#ifndef USE_OPENGL
|
|
|
|
// Allow CreateGfxOpenGL to be called even if OpenGL isn't included
|
|
|
|
GfxBase *CreateGfxOpenGL() {
|
|
|
|
return CreateGfxTinyGL();
|
|
|
|
}
|
|
|
|
#endif // USE_OPENGL
|
|
|
|
|
2012-04-12 17:53:03 -07:00
|
|
|
void SpecialtyMaterial::select() const {
|
|
|
|
if (_texture) {
|
|
|
|
g_driver->selectMaterial(_texture);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SpecialtyMaterial::create(const char *data, int width, int height) {
|
|
|
|
delete _texture;
|
|
|
|
_texture = new Texture();
|
|
|
|
_texture->_width = width;
|
|
|
|
_texture->_height = height;
|
|
|
|
_texture->_bpp = 4;
|
|
|
|
_texture->_colorFormat = BM_RGBA;
|
|
|
|
g_driver->createMaterial(_texture, data, NULL);
|
|
|
|
}
|
|
|
|
|
2011-04-24 15:58:33 +02:00
|
|
|
}
|