EMI: Implement Specialty Textures in OpenGL
This commit is contained in:
parent
640889b805
commit
78ec6f4aa9
9 changed files with 89 additions and 14 deletions
|
@ -33,6 +33,7 @@
|
||||||
|
|
||||||
#include "engines/grim/set.h"
|
#include "engines/grim/set.h"
|
||||||
#include "engines/grim/grim.h"
|
#include "engines/grim/grim.h"
|
||||||
|
#include "engines/grim/gfx_base.h"
|
||||||
|
|
||||||
#include "engines/grim/movie/movie.h"
|
#include "engines/grim/movie/movie.h"
|
||||||
|
|
||||||
|
@ -105,15 +106,14 @@ void Lua_V2::MakeScreenTextures() {
|
||||||
lua_Object indexObj = lua_getparam(1);
|
lua_Object indexObj = lua_getparam(1);
|
||||||
|
|
||||||
if (!lua_isnil(indexObj) && lua_isnumber(indexObj)) {
|
if (!lua_isnil(indexObj) && lua_isnumber(indexObj)) {
|
||||||
int index = (int)lua_getnumber(indexObj);
|
/*int index = (int)lua_getnumber(indexObj);*/
|
||||||
warning("Lua_V2::MakeScreenTextures, index: %d", index);
|
// The index does not seem to matter
|
||||||
// FIXME: implement missing function
|
|
||||||
// if (func(index)) {
|
g_driver->createSpecialtyTextures();
|
||||||
lua_pushnumber(1.0);
|
lua_pushnumber(1.0);
|
||||||
return;
|
} else {
|
||||||
// }
|
|
||||||
}
|
|
||||||
lua_pushnil();
|
lua_pushnil();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Lua_V2::LoadBundle() {
|
void Lua_V2::LoadBundle() {
|
||||||
|
|
|
@ -247,7 +247,7 @@ void EMIModel::prepareTextures() {
|
||||||
if (!_texNames[i].contains("specialty"))
|
if (!_texNames[i].contains("specialty"))
|
||||||
_mats[i] = g_resourceloader->loadMaterial(_texNames[i].c_str(), NULL);
|
_mats[i] = g_resourceloader->loadMaterial(_texNames[i].c_str(), NULL);
|
||||||
else
|
else
|
||||||
_mats[i] = NULL;
|
_mats[i] = g_driver->getSpecialtyTexture(_texNames[i][9] - '0');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -87,4 +87,20 @@ GfxBase *CreateGfxOpenGL() {
|
||||||
}
|
}
|
||||||
#endif // USE_OPENGL
|
#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);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,8 @@
|
||||||
|
|
||||||
#include "graphics/pixelformat.h"
|
#include "graphics/pixelformat.h"
|
||||||
|
|
||||||
|
#include "engines/grim/material.h"
|
||||||
|
|
||||||
namespace Graphics {
|
namespace Graphics {
|
||||||
struct Surface;
|
struct Surface;
|
||||||
}
|
}
|
||||||
|
@ -52,6 +54,15 @@ struct Sprite;
|
||||||
class Light;
|
class Light;
|
||||||
class Texture;
|
class Texture;
|
||||||
|
|
||||||
|
class SpecialtyMaterial : public Material {
|
||||||
|
public:
|
||||||
|
SpecialtyMaterial() { _texture = NULL; }
|
||||||
|
~SpecialtyMaterial() { delete _texture; }
|
||||||
|
void create(const char *data, int width, int height);
|
||||||
|
virtual void select() const;
|
||||||
|
Texture *_texture;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Color-formats used for bitmaps in Grim Fandango/Escape From Monkey Island
|
* The Color-formats used for bitmaps in Grim Fandango/Escape From Monkey Island
|
||||||
*/
|
*/
|
||||||
|
@ -237,6 +248,9 @@ public:
|
||||||
virtual void selectCleanBuffer() {}
|
virtual void selectCleanBuffer() {}
|
||||||
virtual void clearCleanBuffer() {}
|
virtual void clearCleanBuffer() {}
|
||||||
|
|
||||||
|
virtual void createSpecialtyTextures() = 0;
|
||||||
|
virtual Material *getSpecialtyTexture(int n) { return &_specialty[n]; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
static const int _gameHeight = 480;
|
static const int _gameHeight = 480;
|
||||||
static const int _gameWidth = 640;
|
static const int _gameWidth = 640;
|
||||||
|
@ -251,6 +265,7 @@ protected:
|
||||||
bool _renderZBitmaps;
|
bool _renderZBitmaps;
|
||||||
bool _shadowModeActive;
|
bool _shadowModeActive;
|
||||||
Graphics::PixelFormat _pixelFormat;
|
Graphics::PixelFormat _pixelFormat;
|
||||||
|
SpecialtyMaterial _specialty[8];
|
||||||
};
|
};
|
||||||
|
|
||||||
// Factory-like functions:
|
// Factory-like functions:
|
||||||
|
|
|
@ -1587,6 +1587,37 @@ void GfxOpenGL::drawPolygon(PrimitiveObject *primitive) {
|
||||||
glEnable(GL_LIGHTING);
|
glEnable(GL_LIGHTING);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GfxOpenGL::createSpecialtyTextures() {
|
||||||
|
//make a buffer big enough to hold any of the textures
|
||||||
|
char *buffer = new char[256*256*4];
|
||||||
|
|
||||||
|
glReadPixels(0, 0, 256, 256, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
|
||||||
|
_specialty[0].create(buffer, 256, 256);
|
||||||
|
|
||||||
|
glReadPixels(256, 0, 256, 256, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
|
||||||
|
_specialty[1].create(buffer, 256, 256);
|
||||||
|
|
||||||
|
glReadPixels(512, 0, 128, 128, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
|
||||||
|
_specialty[2].create(buffer, 128, 128);
|
||||||
|
|
||||||
|
glReadPixels(512, 128, 128, 128, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
|
||||||
|
_specialty[3].create(buffer, 128, 128);
|
||||||
|
|
||||||
|
glReadPixels(0, 256, 256, 256, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
|
||||||
|
_specialty[4].create(buffer, 256, 256);
|
||||||
|
|
||||||
|
glReadPixels(256, 256, 256, 256, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
|
||||||
|
_specialty[5].create(buffer, 256, 256);
|
||||||
|
|
||||||
|
glReadPixels(512, 256, 128, 128, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
|
||||||
|
_specialty[6].create(buffer, 128, 128);
|
||||||
|
|
||||||
|
glReadPixels(512, 384, 128, 128, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
|
||||||
|
_specialty[7].create(buffer, 128, 128);
|
||||||
|
|
||||||
|
delete[] buffer;
|
||||||
|
}
|
||||||
|
|
||||||
} // end of namespace Grim
|
} // end of namespace Grim
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -120,6 +120,8 @@ public:
|
||||||
void drawMovieFrame(int offsetX, int offsetY);
|
void drawMovieFrame(int offsetX, int offsetY);
|
||||||
void releaseMovieFrame();
|
void releaseMovieFrame();
|
||||||
|
|
||||||
|
void createSpecialtyTextures();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void drawDepthBitmap(int x, int y, int w, int h, char *data);
|
void drawDepthBitmap(int x, int y, int w, int h, char *data);
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -117,6 +117,8 @@ public:
|
||||||
void selectCleanBuffer();
|
void selectCleanBuffer();
|
||||||
void clearCleanBuffer();
|
void clearCleanBuffer();
|
||||||
|
|
||||||
|
void createSpecialtyTextures() { };
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -238,6 +238,10 @@ Material::Material(const Common::String &filename, Common::SeekableReadStream *d
|
||||||
_data = MaterialData::getMaterialData(filename, data, cmap);
|
_data = MaterialData::getMaterialData(filename, data, cmap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Material::Material() :
|
||||||
|
Object(), _currImage(0), _data(NULL) {
|
||||||
|
}
|
||||||
|
|
||||||
void Material::reload(CMap *cmap) {
|
void Material::reload(CMap *cmap) {
|
||||||
Common::String fname = _data->_fname;
|
Common::String fname = _data->_fname;
|
||||||
--_data->_refCount;
|
--_data->_refCount;
|
||||||
|
@ -265,10 +269,12 @@ void Material::select() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
Material::~Material() {
|
Material::~Material() {
|
||||||
|
if (_data) {
|
||||||
--_data->_refCount;
|
--_data->_refCount;
|
||||||
if (_data->_refCount < 1) {
|
if (_data->_refCount < 1) {
|
||||||
delete _data;
|
delete _data;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Material::setActiveTexture(int n) {
|
void Material::setActiveTexture(int n) {
|
||||||
|
|
|
@ -66,7 +66,7 @@ public:
|
||||||
|
|
||||||
void reload(CMap *cmap);
|
void reload(CMap *cmap);
|
||||||
// Load this texture into the GL context
|
// Load this texture into the GL context
|
||||||
void select() const;
|
virtual void select() const;
|
||||||
|
|
||||||
// Set which image in an animated texture to use
|
// Set which image in an animated texture to use
|
||||||
void setActiveTexture(int n);
|
void setActiveTexture(int n);
|
||||||
|
@ -77,7 +77,10 @@ public:
|
||||||
const Common::String &getFilename() const;
|
const Common::String &getFilename() const;
|
||||||
MaterialData *getData() const;
|
MaterialData *getData() const;
|
||||||
|
|
||||||
~Material();
|
virtual ~Material();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
Material();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
MaterialData *_data;
|
MaterialData *_data;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue