scummvm/engines/myst3/nodeframe.cpp

75 lines
2.2 KiB
C++
Raw Normal View History

2011-09-05 20:13:48 +02:00
/* 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.
*
2012-01-05 10:07:48 +01:00
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
2011-09-05 20:13:48 +02:00
2012-01-05 10:07:48 +01:00
* This program is distributed in the hope that it will be useful,
2011-09-05 20:13:48 +02:00
* but WITHOUT ANY WARRANTY; without even the implied warranty of
2012-01-05 10:07:48 +01:00
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
2011-09-05 20:13:48 +02:00
2012-01-05 10:07:48 +01:00
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
2011-09-05 20:13:48 +02:00
*
*/
#include "engines/myst3/nodeframe.h"
#include "engines/myst3/scene.h"
2011-09-05 20:13:48 +02:00
namespace Myst3 {
NodeFrame::NodeFrame(Myst3Engine *vm, Archive *archive, uint16 id) :
Node(vm, archive, id) {
const DirectorySubEntry *jpegDesc = archive->getDescription(id, 1, DirectorySubEntry::kFrame);
Common::MemoryReadStream *jpegStream = archive->getData(jpegDesc);
2011-09-05 20:13:48 +02:00
if (jpegStream) {
Graphics::JPEG jpeg;
jpeg.read(jpegStream);
_faces[0] = new Face();
_faces[0]->setTextureFromJPEG(&jpeg);
_faces[0]->uploadTexture();
2011-09-05 20:13:48 +02:00
delete jpegStream;
}
}
NodeFrame::~NodeFrame() {
}
2011-09-05 20:13:48 +02:00
void NodeFrame::draw() {
// Size of the frame
static const float w = Scene::_originalWidth;
static const float h = Scene::_frameHeight;
// Position of the frame
static const float top = Scene::_topBorderHeight;
2011-09-05 20:13:48 +02:00
// Used fragment of texture
const float u = w / (float)_cubeTextureSize;
const float v = h / (float)_cubeTextureSize;
2011-09-05 20:13:48 +02:00
glEnable(GL_TEXTURE_2D);
2011-09-05 20:13:48 +02:00
glDepthMask(GL_FALSE);
glBindTexture(GL_TEXTURE_2D, _faces[0]->_textureId);
2011-09-05 20:13:48 +02:00
glBegin(GL_TRIANGLE_STRIP); // Z+
glTexCoord2f(0, v); glVertex3f( 0, top + h, 1.0f);
glTexCoord2f(u, v); glVertex3f( w, top + h, 1.0f);
glTexCoord2f(0, 0); glVertex3f( 0, top + 0, 1.0f);
glTexCoord2f(u, 0); glVertex3f( w, top + 0, 1.0f);
2011-09-05 20:13:48 +02:00
glEnd();
glDepthMask(GL_TRUE);
}
} /* namespace Myst3 */