scummvm/engines/grim/gfx_base.cpp

110 lines
2.6 KiB
C++
Raw Normal View History

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.
*
* 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
* 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"
namespace Grim {
2011-07-29 23:02:52 +02:00
GfxBase::GfxBase() :
_renderBitmaps(true),
_renderZBitmaps(true),
_shadowModeActive(false),
_currentPos(0, 0, 0),
_currentQuat(0, 0, 0, 1),
_dimLevel(0.0f) {
2011-07-29 23:02:52 +02: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);
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();
setShadowColor(r, g , b);
_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;
}
#ifndef USE_OPENGL
// Allow CreateGfxOpenGL to be called even if OpenGL isn't included
GfxBase *CreateGfxOpenGL() {
return CreateGfxTinyGL();
}
#endif // USE_OPENGL
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
}