mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-04 09:56:30 +00:00
FREESCAPE: basic support for border rendering in driller
This commit is contained in:
parent
cc1bfdf84e
commit
03291ca0b0
@ -80,11 +80,7 @@ void FreescapeEngine::drawBorder() {
|
||||
if (!_borderTexture)
|
||||
_borderTexture = _gfx->createTexture(_border);
|
||||
const Common::Rect rect(0, 0, _screenW, _screenH);
|
||||
|
||||
_gfx->drawTexturedRect2D(rect, rect, _borderTexture, 1.0, false);
|
||||
// _gfx->flipBuffer();
|
||||
// _system->updateScreen();
|
||||
// _gfx->freeTexture(t);
|
||||
_gfx->drawTexturedRect2D(rect, rect, _borderTexture);
|
||||
}
|
||||
|
||||
void FreescapeEngine::loadAssets() {
|
||||
@ -149,7 +145,7 @@ void FreescapeEngine::loadAssets() {
|
||||
// Courtyard -> 0x93c1 -> 0x8cbc,3
|
||||
// Beds -> 0x867d
|
||||
// All? -> 0x845d or 0x80ed?
|
||||
load8bitBinary(file, 0x1000, 16);
|
||||
load8bitBinary(file, 0x8465, 16);
|
||||
} else
|
||||
error("'%s' is an invalid game", _targetName.c_str());
|
||||
|
||||
@ -174,7 +170,7 @@ void FreescapeEngine::drawFrame() {
|
||||
_gfx->positionCamera(_position, _position + _cameraFront);
|
||||
_currentArea->draw(_gfx);
|
||||
_gfx->renderCrossair(0);
|
||||
//drawBorder();
|
||||
drawBorder();
|
||||
}
|
||||
|
||||
void FreescapeEngine::processInput() {
|
||||
@ -270,6 +266,17 @@ Common::Error FreescapeEngine::run() {
|
||||
} else {
|
||||
_farClipPlane = 8192.f;
|
||||
}
|
||||
|
||||
drawBorder();
|
||||
_gfx->flipBuffer();
|
||||
g_system->updateScreen();
|
||||
g_system->delayMillis(1000);
|
||||
|
||||
_borderTexture = nullptr;
|
||||
|
||||
Common::Rect viewArea(40, 16, 279, 116);
|
||||
_border->fillRect(viewArea, 0xA0A0A0FF);
|
||||
|
||||
debug("Starting area %d", _currentArea->getAreaID());
|
||||
while (!shouldQuit()) {
|
||||
drawFrame();
|
||||
|
@ -89,8 +89,7 @@ public:
|
||||
virtual void freeTexture(Texture *texture) = 0;
|
||||
|
||||
virtual void drawRect2D(const Common::Rect &rect, uint8 a, uint8 r, uint8 g, uint8 b) = 0;
|
||||
virtual void drawTexturedRect2D(const Common::Rect &screenRect, const Common::Rect &textureRect, Texture *texture,
|
||||
float transparency = -1.0, bool additiveBlending = false) = 0;
|
||||
virtual void drawTexturedRect2D(const Common::Rect &screenRect, const Common::Rect &textureRect, Texture *texture) = 0;
|
||||
|
||||
virtual void draw2DText(const Common::String &text, const Common::Point &position) = 0;
|
||||
|
||||
|
@ -103,38 +103,19 @@ void TinyGLRenderer::drawRect2D(const Common::Rect &rect, uint8 a, uint8 r, uint
|
||||
tglDisable(TGL_BLEND);
|
||||
}
|
||||
|
||||
void TinyGLRenderer::drawTexturedRect2D(const Common::Rect &screenRect, const Common::Rect &textureRect,
|
||||
Texture *texture, float transparency, bool additiveBlending) {
|
||||
void TinyGLRenderer::drawTexturedRect2D(const Common::Rect &screenRect, const Common::Rect &textureRect, Texture *texture) {
|
||||
const float sLeft = screenRect.left;
|
||||
const float sTop = screenRect.top;
|
||||
const float sWidth = screenRect.width();
|
||||
const float sHeight = screenRect.height();
|
||||
|
||||
if (transparency >= 0.0) {
|
||||
if (additiveBlending) {
|
||||
tglBlendFunc(TGL_SRC_ALPHA, TGL_ONE);
|
||||
} else {
|
||||
tglBlendFunc(TGL_SRC_ALPHA, TGL_ONE_MINUS_SRC_ALPHA);
|
||||
}
|
||||
tglEnable(TGL_BLEND);
|
||||
} else {
|
||||
transparency = 1.0;
|
||||
}
|
||||
|
||||
// HACK: tglBlit is not affected by the viewport, so we offset the draw coordinates here
|
||||
int viewPort[4];
|
||||
tglGetIntegerv(TGL_VIEWPORT, viewPort);
|
||||
|
||||
tglEnable(TGL_TEXTURE_2D);
|
||||
tglDepthMask(TGL_FALSE);
|
||||
|
||||
TinyGL::BlitTransform transform(sLeft + viewPort[0], sTop + viewPort[1]);
|
||||
transform.sourceRectangle(textureRect.left, textureRect.top, sWidth, sHeight);
|
||||
transform.tint(transparency);
|
||||
tglBlit(((TinyGLTexture *)texture)->getBlitTexture(), transform);
|
||||
|
||||
tglDisable(TGL_BLEND);
|
||||
tglDepthMask(TGL_TRUE);
|
||||
}
|
||||
|
||||
void TinyGLRenderer::draw2DText(const Common::String &text, const Common::Point &position) {
|
||||
|
@ -46,8 +46,7 @@ public:
|
||||
void freeTexture(Texture *texture) override;
|
||||
|
||||
virtual void drawRect2D(const Common::Rect &rect, uint8 a, uint8 r, uint8 g, uint8 b) override;
|
||||
virtual void drawTexturedRect2D(const Common::Rect &screenRect, const Common::Rect &textureRect, Texture *texture,
|
||||
float transparency = -1.0, bool additiveBlending = false) override;
|
||||
virtual void drawTexturedRect2D(const Common::Rect &screenRect, const Common::Rect &textureRect, Texture *texture) override;
|
||||
virtual void draw2DText(const Common::String &text, const Common::Point &position) override;
|
||||
|
||||
virtual void renderCrossair(byte color) override;
|
||||
|
@ -30,24 +30,6 @@ TinyGLTexture::TinyGLTexture(const Graphics::Surface *surface) {
|
||||
height = surface->h;
|
||||
format = surface->format;
|
||||
|
||||
if (format.bytesPerPixel == 4) {
|
||||
internalFormat = TGL_RGBA;
|
||||
sourceFormat = TGL_UNSIGNED_BYTE;
|
||||
} else if (format.bytesPerPixel == 2) {
|
||||
internalFormat = TGL_RGB;
|
||||
sourceFormat = TGL_UNSIGNED_SHORT_5_6_5;
|
||||
} else
|
||||
error("Unknown pixel format");
|
||||
|
||||
tglGenTextures(1, &id);
|
||||
tglBindTexture(TGL_TEXTURE_2D, id);
|
||||
tglTexImage2D(TGL_TEXTURE_2D, 0, 3, width, height, 0, internalFormat, sourceFormat, 0);
|
||||
tglTexParameteri(TGL_TEXTURE_2D, TGL_TEXTURE_MIN_FILTER, TGL_LINEAR);
|
||||
tglTexParameteri(TGL_TEXTURE_2D, TGL_TEXTURE_MAG_FILTER, TGL_LINEAR);
|
||||
|
||||
// NOTE: TinyGL doesn't have issues with white lines so doesn't need use TGL_CLAMP_TO_EDGE
|
||||
tglTexParameteri(TGL_TEXTURE_2D, TGL_TEXTURE_WRAP_S, TGL_REPEAT);
|
||||
tglTexParameteri(TGL_TEXTURE_2D, TGL_TEXTURE_WRAP_T, TGL_REPEAT);
|
||||
_blitImage = tglGenBlitImage();
|
||||
|
||||
update(surface);
|
||||
@ -59,10 +41,7 @@ TinyGLTexture::~TinyGLTexture() {
|
||||
}
|
||||
|
||||
void TinyGLTexture::update(const Graphics::Surface *surface) {
|
||||
tglBindTexture(TGL_TEXTURE_2D, id);
|
||||
tglTexImage2D(TGL_TEXTURE_2D, 0, 3, width, height, 0,
|
||||
internalFormat, sourceFormat, const_cast<void *>(surface->getPixels())); // TESTME: Not sure if it works.
|
||||
tglUploadBlitImage(_blitImage, *surface, 0, false);
|
||||
tglUploadBlitImage(_blitImage, *surface, 0xA0A0A0FF, true);
|
||||
}
|
||||
|
||||
void TinyGLTexture::updatePartial(const Graphics::Surface *surface, const Common::Rect &rect) {
|
||||
|
@ -1,6 +1,7 @@
|
||||
#include "common/array.h"
|
||||
#include "common/debug.h"
|
||||
#include "common/file.h"
|
||||
#include "image/bmp.h"
|
||||
|
||||
#include "freescape/freescape.h"
|
||||
#include "freescape/area.h"
|
||||
@ -278,11 +279,14 @@ Area *FreescapeEngine::load8bitArea(Common::SeekableReadStream *file, uint16 nco
|
||||
// };
|
||||
|
||||
void FreescapeEngine::load8bitBinary(Common::SeekableReadStream *file, int offset, int ncolors) {
|
||||
//const uint32 fileSize = file->size();
|
||||
file->seek(0x210);
|
||||
uint16 frameSize = file->readUint16BE();
|
||||
//Common::Array<uint8> *raw_border = streamLoader.nextBytes(frameSize);
|
||||
debug("Found border image of size %x", frameSize);
|
||||
Image::BitmapDecoder decoder;
|
||||
Common::File borderFile;
|
||||
|
||||
if (_renderMode == "ega" && borderFile.open("ega.bmp")) {
|
||||
decoder.loadStream(borderFile);
|
||||
_border = new Graphics::Surface();
|
||||
_border->copyFrom(*decoder.getSurface());
|
||||
}
|
||||
|
||||
file->seek(offset);
|
||||
uint8 numberOfAreas = file->readByte();
|
||||
|
Loading…
x
Reference in New Issue
Block a user