TINYGL: Ported viewport fix
This commit is contained in:
parent
56d15c1d14
commit
c929bda592
3 changed files with 12 additions and 15 deletions
|
@ -78,30 +78,26 @@ void TinyGLRenderer::init() {
|
|||
}
|
||||
|
||||
void TinyGLRenderer::clear() {
|
||||
tglClearColor(0.f, 0.f, 0.f, 1.f); // Solid black
|
||||
tglClear(TGL_COLOR_BUFFER_BIT | TGL_DEPTH_BUFFER_BIT);
|
||||
tglColor3f(1.0f, 1.0f, 1.0f);
|
||||
}
|
||||
|
||||
void TinyGLRenderer::selectTargetWindow(Window *window, bool is3D, bool scaled) {
|
||||
// NOTE: tinyGL viewport implementation needs to be checked as it doesn't behave the same as openGL
|
||||
|
||||
if (!window) {
|
||||
// No window found ...
|
||||
if (scaled) {
|
||||
// ... in scaled mode draw in the original game screen area
|
||||
Common::Rect vp = viewport();
|
||||
tglViewport(vp.left, vp.top, vp.width(), vp.height());
|
||||
//tglViewport(vp.left, _system->getHeight() - vp.top - vp.height(), vp.width(), vp.height());
|
||||
_viewport = viewport();
|
||||
} else {
|
||||
// ... otherwise, draw on the whole screen
|
||||
tglViewport(0, 0, _system->getWidth(), _system->getHeight());
|
||||
_viewport = Common::Rect(_system->getWidth(), _system->getHeight());
|
||||
}
|
||||
} else {
|
||||
// Found a window, draw inside it
|
||||
Common::Rect vp = window->getPosition();
|
||||
tglViewport(vp.left, vp.top, vp.width(), vp.height());
|
||||
//tglViewport(vp.left, _system->getHeight() - vp.top - vp.height(), vp.width(), vp.height());
|
||||
_viewport = window->getPosition();
|
||||
}
|
||||
tglViewport(_viewport.left, _system->getHeight() - _viewport.top - _viewport.height(), _viewport.width(), _viewport.height());
|
||||
|
||||
if (is3D) {
|
||||
tglMatrixMode(TGL_PROJECTION);
|
||||
|
@ -171,14 +167,11 @@ void TinyGLRenderer::drawTexturedRect2D(const Common::Rect &screenRect, const Co
|
|||
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);
|
||||
|
||||
Graphics::BlitTransform transform(sLeft + viewPort[0], sTop + viewPort[1]);
|
||||
// HACK: tglBlit is not affected by the viewport, so we offset the draw coordinates here
|
||||
Graphics::BlitTransform transform(sLeft + _viewport.left, sTop + _viewport.top);
|
||||
transform.sourceRectangle(textureRect.left, textureRect.top, sWidth, sHeight);
|
||||
transform.tint(transparency);
|
||||
tglBlit(((TinyGLTexture *)texture)->getBlitTexture(), transform);
|
||||
|
|
|
@ -62,6 +62,7 @@ private:
|
|||
void drawFace(uint face, Texture *texture);
|
||||
|
||||
TinyGL::FrameBuffer *_fb;
|
||||
Common::Rect _viewport;
|
||||
};
|
||||
|
||||
} // End of namespace Myst3
|
||||
|
|
|
@ -74,11 +74,14 @@ void gl_eval_viewport(GLContext *c) {
|
|||
|
||||
v = &c->viewport;
|
||||
|
||||
// v->ymin needs to be upside down for transformation
|
||||
int ymin = c->fb->ysize - v->ysize - v->ymin;
|
||||
v->trans.X = (float)(((v->xsize - 0.5) / 2.0) + v->xmin);
|
||||
v->trans.Y = (float)(((v->ysize - 0.5) / 2.0) + v->ymin);
|
||||
v->trans.Y = (float)(((v->ysize - 0.5) / 2.0) + ymin);
|
||||
v->trans.Z = (float)(((zsize - 0.5) / 2.0) + ((1 << ZB_POINT_Z_FRAC_BITS)) / 2);
|
||||
|
||||
v->scale.X = (float)((v->xsize - 0.5) / 2.0);
|
||||
// v->ysize needs to be upside down for scaling
|
||||
v->scale.Y = (float)(-(v->ysize - 0.5) / 2.0);
|
||||
v->scale.Z = (float)(-((zsize - 0.5) / 2.0));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue