diff --git a/gfx.h b/gfx.h deleted file mode 100644 index 814f0f418aa..00000000000 --- a/gfx.h +++ /dev/null @@ -1,52 +0,0 @@ -/* Residual - A 3D game interpreter - * - * Residual is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the AUTHORS - * file distributed with this source distribution. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * $URL$ - * $Id$ - * - */ - -#ifndef STARK_GFX_H -#define STARK_GFX_H - -#include "common/sys.h" - -namespace Stark { - -struct Surface { - Surface(uint32 width, uint32 height) { - _pixels = (byte *)malloc(width * (height & 1 ? height + 1 : height)* 3); - assert(_pixels); - _width = width; - _height = height; - } - - ~Surface() { - free(_pixels); - } - - byte *_pixels; // Must be in 24-bit RGB format! - uint32 _width, _height; -}; - -} // end of namespace Stark - -#endif - diff --git a/gfx_base.h b/gfx_base.h index a014e8afc13..fb20feb09c6 100644 --- a/gfx_base.h +++ b/gfx_base.h @@ -27,8 +27,8 @@ #define STARK_GFX_BASE_H #include "engines/stark/color.h" +#include "graphics/surface.h" #include "graphics/vector3d.h" -#include "engines/stark/gfx.h" namespace Stark { @@ -63,7 +63,7 @@ public: virtual void translateViewpointStart(Graphics::Vector3d pos, float pitch, float yaw, float roll) = 0; virtual void translateViewpointFinish() = 0; - virtual void drawBitmap(Surface* bmp) = 0; + virtual void drawSurface(Graphics::Surface* surface) = 0; /* virtual void disableLights() = 0; diff --git a/gfx_opengl.cpp b/gfx_opengl.cpp index 78cfae9a029..cce7f6c1336 100644 --- a/gfx_opengl.cpp +++ b/gfx_opengl.cpp @@ -35,13 +35,10 @@ namespace Stark { GfxOpenGL::GfxOpenGL() { _storedDisplay = NULL; - _emergFont = 0; } GfxOpenGL::~GfxOpenGL() { delete[] _storedDisplay; - if (_emergFont && glIsList(_emergFont)) - glDeleteLists(_emergFont, 128); } byte *GfxOpenGL::setupScreen(int screenW, int screenH, bool fullscreen) { @@ -172,11 +169,11 @@ void GfxOpenGL::translateViewpointFinish() { glPopMatrix(); } -void GfxOpenGL::drawBitmap(Surface* bmp) { +void GfxOpenGL::drawSurface(Graphics::Surface* surface) { glPixelZoom(1.0f, -1.0f); glPixelStorei(GL_UNPACK_ALIGNMENT, 1); glRasterPos2f(-1.0f, 0.75f); - glDrawPixels(bmp->_width, bmp->_height, GL_RGB, GL_UNSIGNED_BYTE, bmp->_pixels); + glDrawPixels(surface->w, surface->h, GL_RGB, GL_UNSIGNED_BYTE, surface->pixels); } } // end of namespace Stark diff --git a/gfx_opengl.h b/gfx_opengl.h index cfa336dc856..fb9a8f1b483 100644 --- a/gfx_opengl.h +++ b/gfx_opengl.h @@ -61,16 +61,11 @@ byte *setupScreen(int screenW, int screenH, bool fullscreen); void translateViewpointStart(Graphics::Vector3d pos, float pitch, float yaw, float roll); void translateViewpointFinish(); - void drawBitmap(Surface* bmp); + void drawSurface(Graphics::Surface* bmp); protected: private: - GLuint _emergFont; - int _smushNumTex; - GLuint *_smushTexIds; - int _smushWidth; - int _smushHeight; byte *_storedDisplay; }; diff --git a/stark.cpp b/stark.cpp index 090fef682d3..a6bc3135ff6 100644 --- a/stark.cpp +++ b/stark.cpp @@ -120,11 +120,11 @@ void StarkEngine::updateDisplayScene(){ Common::File _f; _f.open("house_layercenter.xmg"); Common::SeekableReadStream *dat = _f.readStream(_f.size()); - Surface *bmp; - bmp = xmg->decodeImage(dat); - g_driver->drawBitmap(bmp); + Graphics::Surface *surf; + surf = xmg->decodeImage(dat); + g_driver->drawSurface(surf); delete xmg; - delete bmp; + delete surf; delete dat; _f.close(); diff --git a/xmg.cpp b/xmg.cpp index f7da7669e56..f1e2fe842b8 100644 --- a/xmg.cpp +++ b/xmg.cpp @@ -29,7 +29,7 @@ namespace Stark { -Surface *XMGDecoder::decodeImage(Common::SeekableReadStream *stream) { +Graphics::Surface *XMGDecoder::decodeImage(Common::SeekableReadStream *stream) { _stream = stream; @@ -43,10 +43,12 @@ Surface *XMGDecoder::decodeImage(Common::SeekableReadStream *stream) { header.unknown2 = stream->readUint32LE(); header.unknown3 = stream->readUint32LE(); - Surface *surface = new Surface(header.width, header.height); + Graphics::Surface *surface = new Graphics::Surface(); + surface->create(header.width, header.height, 3); + _width = header.width; - _pixels = surface->_pixels; + _pixels = (byte *)surface->pixels; _currX = 0; _currY = 0; @@ -55,7 +57,7 @@ Surface *XMGDecoder::decodeImage(Common::SeekableReadStream *stream) { if (_currX >= header.width) { _currX -= 640; _currY += 2; - _pixels = surface->_pixels + (3 * (_width * _currY + _currX)); + _pixels = (byte *)surface->getBasePtr(_currX, _currY); if (_currY >= header.height) break; } diff --git a/xmg.h b/xmg.h index f12aec9de2b..8f54cf84212 100644 --- a/xmg.h +++ b/xmg.h @@ -29,7 +29,7 @@ #include "common/sys.h" #include "common/stream.h" -#include "engines/stark/gfx.h" +#include "graphics/surface.h" namespace Stark { @@ -55,7 +55,7 @@ public: XMGDecoder() {} ~XMGDecoder() {} - Surface *decodeImage(Common::SeekableReadStream *stream); + Graphics::Surface *decodeImage(Common::SeekableReadStream *stream); private: void processYCrCb(uint16 count);