GRIM: Merge branch 'remastered'
This commit is contained in:
commit
6e619ca714
36 changed files with 1917 additions and 38 deletions
|
@ -49,6 +49,7 @@
|
|||
#include "engines/grim/model.h"
|
||||
#include "engines/grim/set.h"
|
||||
#include "engines/grim/emi/modelemi.h"
|
||||
#include "engines/grim/remastered/overlay.h"
|
||||
#include "engines/grim/registry.h"
|
||||
|
||||
|
||||
|
@ -135,6 +136,9 @@ void GfxOpenGL::setupScreen(int screenW, int screenH, bool fullscreen) {
|
|||
_scaleW = _screenWidth / (float)_gameWidth;
|
||||
_scaleH = _screenHeight / (float)_gameHeight;
|
||||
|
||||
_globalScaleW = _screenWidth / (float)_globalWidth;
|
||||
_globalScaleH = _screenHeight / (float)_globalHeight;
|
||||
|
||||
_useDepthShader = false;
|
||||
_useDimShader = false;
|
||||
|
||||
|
@ -924,6 +928,55 @@ void GfxOpenGL::drawSprite(const Sprite *sprite) {
|
|||
glPopMatrix();
|
||||
}
|
||||
|
||||
void GfxOpenGL::drawOverlay(const Overlay *overlay) {
|
||||
glMatrixMode(GL_TEXTURE);
|
||||
glLoadIdentity();
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
|
||||
glDisable(GL_LIGHTING);
|
||||
|
||||
|
||||
glEnable(GL_ALPHA_TEST);
|
||||
glAlphaFunc(GL_GEQUAL, 0.5f);
|
||||
|
||||
|
||||
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
|
||||
|
||||
float height = overlay->getHeight() * _globalScaleH;
|
||||
float width = overlay->getWidth() * _globalScaleW;
|
||||
float x = overlay->_x * _globalScaleW;
|
||||
float y = overlay->_y * _globalScaleH;
|
||||
|
||||
glBegin(GL_QUADS);
|
||||
glTexCoord2f(0.0f, 0.0f);
|
||||
glVertex2f(x, y);
|
||||
glTexCoord2f(1.0f, 0.0f);
|
||||
glVertex2f((x + width), y);
|
||||
glTexCoord2f(1.0f, 1.0f);
|
||||
glVertex2f((x + width), (y + height));
|
||||
glTexCoord2f(0.0f, 1.0f);
|
||||
glVertex2f(x, (y + height));
|
||||
glEnd();
|
||||
|
||||
|
||||
|
||||
glEnable(GL_LIGHTING);
|
||||
glDisable(GL_ALPHA_TEST);
|
||||
glDepthMask(GL_TRUE);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glDisable(GL_BLEND);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
void GfxOpenGL::translateViewpointStart() {
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glPushMatrix();
|
||||
|
@ -1374,7 +1427,43 @@ void GfxOpenGL::destroyFont(Font *font) {
|
|||
}
|
||||
}
|
||||
|
||||
struct TextObjectUserData {
|
||||
GLuint *_texids;
|
||||
};
|
||||
|
||||
void GfxOpenGL::createTextObject(TextObject *text) {
|
||||
//error("Could not get font userdata");
|
||||
const Font *font = text->getFont();
|
||||
const FontTTF *f = static_cast<const FontTTF *>(font);
|
||||
Graphics::Font *gf = f->_font;
|
||||
int numLines = text->getNumLines();
|
||||
GLuint *texids = new GLuint[numLines];
|
||||
glGenTextures(numLines, texids);
|
||||
// Not at all correct for line-wrapping, but atleast we get all the lines now.
|
||||
for (int i = 0; i < numLines; i++) {
|
||||
Graphics::Surface surface;
|
||||
|
||||
int width = gf->getStringWidth(text->getLines()[i]);
|
||||
int height = width;
|
||||
surface.create(height, width, Graphics::PixelFormat(4, 8, 8, 8, 8, 0, 8, 16, 24));
|
||||
gf->drawString(&surface, text->getLines()[i], 0, 0, width, 0xFFFFFFFF);
|
||||
|
||||
byte *bitmap = (byte *)surface.getPixels();
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, texids[i]);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, bitmap);
|
||||
|
||||
surface.free();
|
||||
}
|
||||
TextObjectUserData *ud = new TextObjectUserData;
|
||||
|
||||
ud->_texids = texids;
|
||||
text->setUserData(ud);
|
||||
|
||||
}
|
||||
|
||||
void GfxOpenGL::drawTextObject(const TextObject *text) {
|
||||
|
@ -1401,8 +1490,60 @@ void GfxOpenGL::drawTextObject(const TextObject *text) {
|
|||
|
||||
glColor3ub(color.getRed(), color.getGreen(), color.getBlue());
|
||||
const FontUserData *userData = (const FontUserData *)font->getUserData();
|
||||
if (!userData)
|
||||
error("Could not get font userdata");
|
||||
if (!userData) {
|
||||
const FontTTF *f = static_cast<const FontTTF *>(font);
|
||||
Graphics::Font *gf = f->_font;
|
||||
|
||||
|
||||
const TextObjectUserData *ud = (const TextObjectUserData *)text->getUserData();
|
||||
|
||||
int numLines = text->getNumLines();
|
||||
for (int i = 0; i < numLines; ++i) {
|
||||
float width = gf->getStringWidth(text->getLines()[i]);
|
||||
float height = width;
|
||||
float x = text->getLineX(i);
|
||||
|
||||
float y = text->getLineY(i);
|
||||
|
||||
if (text->getCoords() == 2 || text->getCoords() == 1) {
|
||||
x *= _globalScaleW;
|
||||
y *= _globalScaleH;
|
||||
|
||||
width *= _globalScaleW;
|
||||
height *= _globalScaleH;
|
||||
} else if (text->getCoords() == 0) {
|
||||
x *= _scaleW;
|
||||
y *= _scaleH;
|
||||
|
||||
width *= _scaleW;
|
||||
height *= _scaleH;
|
||||
}
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, ud->_texids[i]);
|
||||
glBegin(GL_QUADS);
|
||||
glTexCoord2f(0.0f, 0.0f);
|
||||
glVertex2f(x, y);
|
||||
glTexCoord2f(1.0f, 0.0f);
|
||||
glVertex2f((x + width), y);
|
||||
glTexCoord2f(1.0f, 1.0f);
|
||||
glVertex2f((x + width), (y + height));
|
||||
glTexCoord2f(0.0f, 1.0f);
|
||||
glVertex2f(x, (y + height));
|
||||
glEnd();
|
||||
|
||||
|
||||
}
|
||||
|
||||
glColor3f(1, 1, 1);
|
||||
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
glDisable(GL_BLEND);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glEnable(GL_LIGHTING);
|
||||
glDepthMask(GL_TRUE);
|
||||
return;
|
||||
}
|
||||
|
||||
float sizeW = userData->size * _scaleW;
|
||||
float sizeH = userData->size * _scaleH;
|
||||
GLuint texture = userData->texture;
|
||||
|
@ -1448,6 +1589,9 @@ void GfxOpenGL::drawTextObject(const TextObject *text) {
|
|||
}
|
||||
|
||||
void GfxOpenGL::destroyTextObject(TextObject *text) {
|
||||
TextObjectUserData *ud = (TextObjectUserData *)text->getUserData();
|
||||
glDeleteTextures(text->getNumLines(), ud->_texids);
|
||||
delete ud;
|
||||
}
|
||||
|
||||
void GfxOpenGL::createTexture(Texture *texture, const uint8 *data, const CMap *cmap, bool clamp) {
|
||||
|
@ -1575,6 +1719,14 @@ void GfxOpenGL::prepareMovieFrame(Graphics::Surface *frame) {
|
|||
int width = frame->w;
|
||||
byte *bitmap = (byte *)frame->getPixels();
|
||||
|
||||
double scaleW = _scaleW;
|
||||
double scaleH = _scaleH;
|
||||
// Remastered hack, don't scale full-screen videos for now.
|
||||
if (height == 1080) {
|
||||
_scaleW = 1.0f;
|
||||
_scaleH = 1.0f;
|
||||
}
|
||||
|
||||
GLenum format;
|
||||
GLenum dataType;
|
||||
int bytesPerPixel = frame->format.bytesPerPixel;
|
||||
|
@ -1646,9 +1798,18 @@ void GfxOpenGL::prepareMovieFrame(Graphics::Surface *frame) {
|
|||
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
|
||||
_smushWidth = (int)(width * _scaleW);
|
||||
_smushHeight = (int)(height * _scaleH);
|
||||
_scaleW = scaleW;
|
||||
_scaleH = scaleH;
|
||||
}
|
||||
|
||||
void GfxOpenGL::drawMovieFrame(int offsetX, int offsetY) {
|
||||
double scaleW = _scaleW;
|
||||
double scaleH = _scaleH;
|
||||
// Remastered hack, don't scale full-screen videos for now.
|
||||
if (_smushHeight == 1080) {
|
||||
_scaleW = 1.0f;
|
||||
_scaleH = 1.0f;
|
||||
}
|
||||
// prepare view
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
|
@ -1695,6 +1856,9 @@ void GfxOpenGL::drawMovieFrame(int offsetX, int offsetY) {
|
|||
glDepthMask(GL_TRUE);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glEnable(GL_LIGHTING);
|
||||
|
||||
_scaleW = scaleW;
|
||||
_scaleH = scaleH;
|
||||
}
|
||||
|
||||
void GfxOpenGL::releaseMovieFrame() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue