diff --git a/Makefile.common b/Makefile.common
index d1e11679686..72269939abc 100644
--- a/Makefile.common
+++ b/Makefile.common
@@ -54,7 +54,6 @@ OBJS =\
registry.o \
resource.o \
scene.o \
- screen.o \
smush.o \
textobject.o \
textsplit.o \
diff --git a/README b/README
index 4ad5eeefe62..44f36671b04 100644
--- a/README
+++ b/README
@@ -38,9 +38,7 @@ the lines:
DataDir=.
good_times=TRUE
-Residual understands two command-line options: '-zbuffer' which enables masking
-and '-screenblocks' which is a (currently broken) attempt to speed up masking
-on older cards.
+Residual understands two command-line options: '-zbuffer' which enables masking.
It runs really slow when using -zbuffer!
----------------------------------------
diff --git a/TODO b/TODO
index fa9e67bccda..f43572de606 100644
--- a/TODO
+++ b/TODO
@@ -14,7 +14,6 @@ Unassigned (help wanted):
* Finish Save/Load support for rest of Engine except Lua
* Implement 2D primitives
* Proper vsscanf implementation in textsplit.cpp for platforms without it (MSVC, etc)
- * Fix the screenblocks zBuffer code
* Abstract rendering code and implement software renderer (partianly done)
* Fix drawEmergString() to work with Mesa
* Make SMUSH work on Linux/PPC (whats wrong with it, exactly? - ender :)
diff --git a/debug.h b/debug.h
index d87996708b6..84635b5c5c5 100644
--- a/debug.h
+++ b/debug.h
@@ -21,7 +21,7 @@
#define DEBUG_H
// Hacky toggles for experimental / debug code (defined/set in main.cpp)
-extern bool ZBUFFER_GLOBAL, SCREENBLOCKS_GLOBAL, SHOWFPS_GLOBAL;
+extern bool ZBUFFER_GLOBAL, SHOWFPS_GLOBAL;
void warning(const char *fmt, ...);
void error(const char *fmt, ...);
diff --git a/dists/msvc8/residual.vcproj b/dists/msvc8/residual.vcproj
index 1cd7701547b..d99a6d64bb0 100644
--- a/dists/msvc8/residual.vcproj
+++ b/dists/msvc8/residual.vcproj
@@ -652,14 +652,6 @@
RelativePath="..\..\scene.h"
>
-
-
-
-
diff --git a/driver_gl.cpp b/driver_gl.cpp
index 9ccc91180b7..7fe3acd0799 100644
--- a/driver_gl.cpp
+++ b/driver_gl.cpp
@@ -16,7 +16,6 @@
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#include "debug.h"
-#include "screen.h"
#include "colormap.h"
#include "material.h"
#include "driver_gl.h"
@@ -68,10 +67,7 @@ void Driver::positionCamera(Vector3d pos, Vector3d interest) {
if (pos.x() == interest.x() && pos.y() == interest.y())
up_vec = Vector3d(0, 1, 0);
- gluLookAt(pos.x(), pos.y(), pos.z(),
- interest.x(), interest.y(), interest.z(),
- up_vec.x(), up_vec.y(), up_vec.z());
-
+ gluLookAt(pos.x(), pos.y(), pos.z(), interest.x(), interest.y(), interest.z(), up_vec.x(), up_vec.y(), up_vec.z());
}
void Driver::clearScreen() {
@@ -103,7 +99,39 @@ void Driver::set3DMode() {
glEnable(GL_DEPTH_TEST);
}
-void Driver::drawModel(const Model::Mesh *model) {
+void Driver::drawModelNodeDebug(const Model::Mesh *model) {
+ // debug
+ // this draw the model node in red
+
+ GLdouble modelView[500];
+ GLdouble projection[500];
+ GLint viewPort[500];
+
+ glGetDoublev(GL_MODELVIEW_MATRIX, modelView);
+ glGetDoublev(GL_PROJECTION_MATRIX, projection);
+ glGetIntegerv(GL_VIEWPORT, viewPort);
+
+ glPushMatrix();
+ glLoadIdentity();
+
+ glDisable(GL_DEPTH_TEST);
+ glPointSize(3.f);
+ glColor4f(1.f, 0.f, 0.f, 1.f);
+ glDisable(GL_TEXTURE_2D);
+
+ glBegin(GL_POINTS);
+ glVertex3f(model->_matrix._pos.x(), model->_matrix._pos.y(), model->_matrix._pos.z());
+ glEnd();
+
+ glEnable(GL_DEPTH_TEST);
+ glPopMatrix();
+ glEnable(GL_TEXTURE_2D);
+}
+
+void Driver::drawModelPolygonPointsDebug(const Model::Mesh *model) {
+ // debug
+ // this draw the poly points
+
GLdouble modelView[500];
GLdouble projection[500];
GLint viewPort[500];
@@ -113,40 +141,14 @@ void Driver::drawModel(const Model::Mesh *model) {
glGetDoublev(GL_PROJECTION_MATRIX, projection);
glGetIntegerv(GL_VIEWPORT, viewPort);
- // Yaz: debug
- // this draw the model node in red
-/*
glPushMatrix();
glLoadIdentity();
- glGetDoublev(GL_MODELVIEW_MATRIX, modelView);
- glGetDoublev(GL_PROJECTION_MATRIX, projection);
- glGetIntegerv(GL_VIEWPORT, viewPort);
-
glDisable(GL_DEPTH_TEST);
glPointSize(3.f);
- glColor4f(1.f, 0.f, 0.f, 1.f);
- glDisable(GL_TEXTURE_2D );
- glBegin(GL_POINTS);
- glVertex3f(model->_matrix._pos.x(), model->_matrix._pos.y(), model->_matrix._pos.z());
- glEnd();
- glEnable(GL_DEPTH_TEST);
- glPopMatrix();
- glEnable(GL_TEXTURE_2D);
-*/
- // Yaz: debug
- // this draw the poly points
-/*
- glPushMatrix();
- glLoadIdentity();
- glPointSize(3.f);
glColor4f(0.f, 1.f, 0.f, 1.f);
glDisable(GL_TEXTURE_2D);
- glGetDoublev(GL_MODELVIEW_MATRIX, modelView);
- glGetDoublev(GL_PROJECTION_MATRIX, projection);
- glGetIntegerv(GL_VIEWPORT, viewPort);
-
glBegin(GL_POINTS);
for (i = 0; i < model->_numFaces; i++) {
@@ -159,7 +161,7 @@ void Driver::drawModel(const Model::Mesh *model) {
v.set(*(pVertices), *(pVertices + 1), *(pVertices + 2));
- tempMatrix._rot.transform(&v);
+// tempMatrix._rot.transform(&v);
v += tempMatrix._pos;
glVertex3f(v.x(), v.y(), v.z());
@@ -169,170 +171,7 @@ void Driver::drawModel(const Model::Mesh *model) {
glEnd();
glEnable(GL_DEPTH_TEST);
glPopMatrix();
- glEnable(GL_TEXTURE_2D );
-*/
-
- // Ender: HACK HACK HACK
- // Mannys head isn't computed correctly, so bail out to prevent memory corruption.
- // at least until it IS computed, or the DirtyScreen code has bounds checking :)
- //if (strstr(_name, "m_head_1"))
- // return;
-
- // Yaz: debug
- // this compute the dirty rect for the mesh
- glPushMatrix();
- glLoadIdentity();
-
- GLdouble top = 1000;
- GLdouble right = -1000;
- GLdouble left = 1000;
- GLdouble bottom = -1000;
-
- for (i = 0; i < model->_numFaces; i++) {
- Vector3d v;
- Matrix4 tempMatrix = model->_matrix;
- float* pVertices;
- float bestDepth = 0;
-
- for (j = 0; j < model->_faces[i]._numVertices; j++) {
- GLdouble modelView[500];
- GLdouble projection[500];
- GLint viewPort[500];
-
- glGetDoublev(GL_MODELVIEW_MATRIX, modelView);
- glGetDoublev(GL_PROJECTION_MATRIX, projection);
- glGetIntegerv(GL_VIEWPORT, viewPort);
-
- pVertices = model->_vertices + 3 * model->_faces[i]._vertices[j];
-
- v.set(*(pVertices), *(pVertices + 1), *(pVertices + 2));
-
- tempMatrix._rot.transform(&v);
- v += tempMatrix._pos;
-
- GLdouble winX;
- GLdouble winY;
- GLdouble winZ;
-
- gluProject(v.x(), v.y(), v.z(), modelView, projection, viewPort, &winX, &winY, &winZ);
-
- if (winX > right)
- right = winX;
- if (winX < left)
- left = winX;
- if (winY < top)
- top = winY;
- if (winY > bottom)
- bottom = winY;
-
- if (winZ > bestDepth )
- bestDepth = winZ;
- }
-
- if (SCREENBLOCKS_GLOBAL)
- screenBlocksAddRectangle((int)top, (int)right, (int)left, (int)bottom, (int)bestDepth);
- }
-
-/*
- glDisable(GL_DEPTH_TEST);
- glPointSize(3.f);
- glColor4f(1.f, 1.f, 0.f, 1.f);
- glDisable(GL_TEXTURE_2D);
-
- glBegin(GL_LINES);
-
- GLdouble objx;
- GLdouble objy;
- GLdouble objz;
-
- // top
- gluUnProject(left, top, 1.f, modelView, projection, viewPort, &objx, &objy, &objz);
- glVertex3f(objx, objy, objz);
- gluUnProject(right, top, 1.f, modelView, projection, viewPort, &objx, &objy, &objz);
- glVertex3f(objx, objy, objz);
-
- // bottom
- gluUnProject(left, bottom, 1.f, modelView, projection, viewPort, &objx, &objy, &objz);
- glVertex3f(objx, objy, objz);
- gluUnProject(right, bottom, 1.f, modelView, projection, viewPort, &objx, &objy, &objz);
- glVertex3f(objx, objy, objz);
-
- // left
- gluUnProject(left, top, 1.f, modelView, projection, viewPort, &objx, &objy, &objz);
- glVertex3f(objx, objy, objz);
- gluUnProject(left, bottom, 1.f, modelView, projection, viewPort, &objx, &objy, &objz);
- glVertex3f(objx, objy, objz);
-
- // right
- gluUnProject(right, top, 1.f, modelView, projection, viewPort, &objx, &objy, &objz);
- glVertex3f(objx, objy, objz);
- gluUnProject(right, bottom, 1.f, modelView, projection, viewPort, &objx, &objy, &objz);
- glVertex3f(objx, objy, objz);
-
- glEnd();
- glEnable(GL_DEPTH_TEST);
- glEnable(GL_TEXTURE_2D);
-*/
-
- glPopMatrix();
-}
-
-void Driver::updateMesh(const Model::Mesh *mesh) {
- GLdouble modelView[500];
- GLdouble projection[500];
- GLint viewPort[500];
-
- glGetDoublev(GL_MODELVIEW_MATRIX, modelView);
- glGetDoublev(GL_PROJECTION_MATRIX, projection);
- glGetIntegerv(GL_VIEWPORT, viewPort);
-
- GLdouble top = 1000;
- GLdouble right = -1000;
- GLdouble left = 1000;
- GLdouble bottom = -1000;
-
- for (int i = 0; i < mesh->_numFaces; i++) {
- Vector3d v;
- Matrix4 tempMatrix = mesh->_matrix;
- float *pVertices;
- int j;
- float bestDepth = 0;
-
- for (j = 0; j < mesh->_faces[i]._numVertices; j++) {
- pVertices = mesh->_vertices + 3 * mesh->_faces[i]._vertices[j];
-
- v.set(*(pVertices), *(pVertices + 1), *(pVertices + 2));
-
- tempMatrix._rot.transform(&v);
- v += tempMatrix._pos;
-
- GLdouble winX;
- GLdouble winY;
- GLdouble winZ;
-
- gluProject(v.x(), v.y(), v.z(), modelView, projection, viewPort, &winX, &winY, &winZ);
-
- if(winX > right)
- right = winX;
- if(winX < left)
- left = winX;
- if(winY < top)
- top = winY;
- if(winY > bottom)
- bottom = winY;
-
- if(winZ > bestDepth)
- bestDepth = winZ;
- }
-
-// if (SCREENBLOCKS_GLOBAL)
-// screenBlocksAddRectangle(top, right, left, bottom, bestDepth);
- }
-
- glDisable(GL_DEPTH_TEST);
- glPointSize(3.f);
- glColor4f(1.f, 1.f, 0.f, 1.f);
- glDisable(GL_TEXTURE_2D);
+ glEnable(GL_TEXTURE_2D);
}
void Driver::drawModelFace(const Model::Face *face, float *vertices, float *vertNormals, float *textureVerts) {
@@ -375,7 +214,7 @@ void Driver::drawHierachyNode(const Model::HierNode *node) {
node->_sibling->draw();
}
-void Driver::updateHierachyNode(const Model::HierNode *node) {
+void Driver::updateHierachyNode1(const Model::HierNode *node) {
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
@@ -383,7 +222,9 @@ void Driver::updateHierachyNode(const Model::HierNode *node) {
glRotatef(node->_animYaw / node->_totalWeight, 0, 0, 1);
glRotatef(node->_animPitch / node->_totalWeight, 1, 0, 0);
glRotatef(node->_animRoll / node->_totalWeight, 0, 1, 0);
+}
+void Driver::updateHierachyNode2(const Model::HierNode *node) {
if (node->_mesh != NULL) {
glPushMatrix();
glTranslatef(node->_pivot.x(), node->_pivot.y(), node->_pivot.z());
@@ -531,11 +372,9 @@ void Driver::drawBitmap(const Bitmap *bitmap) {
glDepthMask(GL_TRUE);
glEnable(GL_DEPTH_TEST);
} else if (bitmap->_format == 5) { // ZBuffer image
- // Only draw the manual zbuffer when we are not using screenblocks, and when enabled
- if ((!ZBUFFER_GLOBAL) || SCREENBLOCKS_GLOBAL)
- return;
-
- g_driver->drawDepthBitmap(bitmap->_x, bitmap->_y, bitmap->_width, bitmap->_height, bitmap->_data[bitmap->_currImage - 1]);
+ // Only draw the manual zbuffer when enabled
+ if (ZBUFFER_GLOBAL)
+ g_driver->drawDepthBitmap(bitmap->_x, bitmap->_y, bitmap->_width, bitmap->_height, bitmap->_data[bitmap->_currImage - 1]);
}
}
@@ -744,6 +583,6 @@ void Driver::drawEmergString(int x, int y, const char *text, const Color &fgColo
//glCallLists(strlen(strrchr(text, '/')) - 1, GL_UNSIGNED_BYTE, strrchr(text, '/') + 1);
glCallLists(strlen(text), GL_UNSIGNED_BYTE, (GLubyte *) text);
- glMatrixMode( GL_PROJECTION );
+ glMatrixMode(GL_PROJECTION);
glPopMatrix();
}
diff --git a/driver_gl.h b/driver_gl.h
index 44e13865d4c..49b66319bda 100644
--- a/driver_gl.h
+++ b/driver_gl.h
@@ -44,11 +44,11 @@ public:
void drawHierachyNode(const Model::HierNode *node);
void drawModelFace(const Model::Face *face, float *vertices, float *vertNormals, float *textureVerts);
- void drawModel(const Model::Mesh *model);
-
- void updateMesh(const Model::Mesh *mesh);
- void updateHierachyNode(const Model::HierNode *node);
+ void drawModelNodeDebug(const Model::Mesh *model);
+ void drawModelPolygonPointsDebug(const Model::Mesh *model);
+ void updateHierachyNode1(const Model::HierNode *node);
+ void updateHierachyNode2(const Model::HierNode *node);
void createMaterial(Material *material, const char *data, const CMap *cmap);
void selectMaterial(const Material *material);
diff --git a/engine.cpp b/engine.cpp
index 8fbaf4a28ea..5ea6ffc1345 100644
--- a/engine.cpp
+++ b/engine.cpp
@@ -22,7 +22,6 @@
#include "colormap.h"
#include "actor.h"
#include "textobject.h"
-#include "screen.h"
#include "smush.h"
#include "driver_gl.h"
@@ -125,22 +124,20 @@ void Engine::mainLoop() {
}
}
} else if (_mode == ENGINE_MODE_NORMAL) {
- if (_currScene != NULL) {
- // Update actor costumes
- for (ActorListType::iterator i = _actors.begin(); i != _actors.end(); i++) {
- Actor *a = *i;
- if (_currScene != NULL && a->inSet(_currScene->name()) && a->visible())
- a->update();
- }
- }
-
- if (SCREENBLOCKS_GLOBAL)
- screenBlocksReset();
-
g_driver->clearScreen();
- if (SCREENBLOCKS_GLOBAL)
- screenBlocksBlitDirtyBlocks();
+ g_driver->set3DMode();
+
+ if (_currScene != NULL) {
+ _currScene->setupCamera();
+ }
+
+ // Update actor costumes
+ for (ActorListType::iterator i = _actors.begin(); i != _actors.end(); i++) {
+ Actor *a = *i;
+ if (_currScene != NULL && a->inSet(_currScene->name()) && a->visible())
+ a->update();
+ }
if (_currScene != NULL) {
_currScene->drawBackground();
@@ -165,27 +162,23 @@ void Engine::mainLoop() {
if (SHOWFPS_GLOBAL)
g_driver->drawEmergString(550, 25, fps, Color(255, 255, 255));
- g_driver->set3DMode();
-
if (_currScene != NULL) {
_currScene->setupCamera();
-
- // Draw actors
- for (ActorListType::iterator i = _actors.begin(); i != _actors.end(); i++) {
- Actor *a = *i;
- if (_currScene != NULL && a->inSet(_currScene->name()) && a->visible())
- a->draw();
- }
-
- if (SCREENBLOCKS_GLOBAL)
- screenBlocksDrawDebug();
}
- // Draw text
- for (TextListType::iterator i = _textObjects.begin(); i != _textObjects.end(); i++) {
- (*i)->draw();
- }
+ g_driver->set3DMode();
+ // Draw actors
+ for (ActorListType::iterator i = _actors.begin(); i != _actors.end(); i++) {
+ Actor *a = *i;
+ if (_currScene != NULL && a->inSet(_currScene->name()) && a->visible())
+ a->draw();
+ }
+ }
+
+ // Draw text
+ for (TextListType::iterator i = _textObjects.begin(); i != _textObjects.end(); i++) {
+ (*i)->draw();
}
g_imuse->flushTracks();
diff --git a/keyframe.cpp b/keyframe.cpp
index 10e8e8ec0ee..4f65edad5e3 100644
--- a/keyframe.cpp
+++ b/keyframe.cpp
@@ -158,8 +158,7 @@ KeyframeAnim::KeyframeNode::~KeyframeNode() {
delete[] _entries;
}
-void KeyframeAnim::KeyframeNode::animate(Model::HierNode &node,
- float frame, int priority) const {
+void KeyframeAnim::KeyframeNode::animate(Model::HierNode &node, float frame, int priority) const {
if (_numEntries == 0)
return;
if (priority < node._priority)
diff --git a/main.cpp b/main.cpp
index 85caa1c3c65..68011df12bd 100644
--- a/main.cpp
+++ b/main.cpp
@@ -35,7 +35,7 @@
#include
// Hacky global toggles for experimental/debug code
-bool ZBUFFER_GLOBAL, SCREENBLOCKS_GLOBAL, SHOWFPS_GLOBAL;
+bool ZBUFFER_GLOBAL, SHOWFPS_GLOBAL;
#ifdef __MINGW32__
int PASCAL WinMain(HINSTANCE /*hInst*/, HINSTANCE /*hPrevInst*/, LPSTR /*lpCmdLine*/, int /*iShowCmd*/) {
@@ -98,17 +98,12 @@ int main(int argc, char *argv[]) {
// Parse command line
ZBUFFER_GLOBAL = parseBoolStr(g_registry->get("zbuffer"));
- SCREENBLOCKS_GLOBAL = parseBoolStr(g_registry->get("screenblocks"));
SHOWFPS_GLOBAL = parseBoolStr(g_registry->get("fps"));
for (i = 1; i < argc; i++) {
if (strcmp(argv[i], "-zbuffer") == 0)
ZBUFFER_GLOBAL = true;
else if (strcmp(argv[i], "-nozbuffer") == 0)
ZBUFFER_GLOBAL = false;
- else if (strcmp(argv[i], "-screenblocks") == 0)
- SCREENBLOCKS_GLOBAL = true;
- else if (strcmp(argv[i], "-noscreenblocks") == 0)
- SCREENBLOCKS_GLOBAL = false;
else if (strcmp(argv[i], "-fps") == 0)
SHOWFPS_GLOBAL = true;
else if (strcmp(argv[i], "-nofps") == 0)
@@ -118,7 +113,6 @@ int main(int argc, char *argv[]) {
printf("--------------------\n");
printf("Recognised options:\n");
printf("\t-[no]zbuffer\t\tEnable/disable ZBuffers (Very slow on older cards)\n");
- printf("\t-[no]screenblocks\t\tEnable/disable Screenblocks (Experimental zbuffer speedup on older cards - BROKEN!!\n");
printf("\t-[no]fps\t\tEnable/disable fps display in upper right corner\n");
exit(-1);
}
diff --git a/model.cpp b/model.cpp
index 38cc8564fbc..811d7113b28 100644
--- a/model.cpp
+++ b/model.cpp
@@ -20,7 +20,6 @@
#include "debug.h"
#include "model.h"
#include "resource.h"
-#include "screen.h"
#include "material.h"
#include "textsplit.h"
#include "driver_gl.h"
@@ -126,7 +125,6 @@ Model::Mesh::~Mesh() {
}
void Model::Mesh::update() {
- g_driver->updateMesh(this);
}
void Model::Face::loadBinary(const char *&data, ResPtr *materials) {
@@ -377,8 +375,7 @@ void Model::Mesh::loadText(TextSplitter &ts, ResPtr *materials) {
if (ts.eof())
error("Expected face data, got EOF\n");
- if (std::sscanf(ts.currentLine(), " %d: %d %i %d %d %d %f %d%n",
- &num, &material, &type, &geo, &light, &tex, &extralight, &verts, &readlen) < 8)
+ if (std::sscanf(ts.currentLine(), " %d: %d %i %d %d %d %f %d%n", &num, &material, &type, &geo, &light, &tex, &extralight, &verts, &readlen) < 8)
error("Expected face data, got `%s'\n", ts.currentLine());
_faces[num]._material = materials[material];
@@ -393,8 +390,7 @@ void Model::Mesh::loadText(TextSplitter &ts, ResPtr *materials) {
for (int j = 0; j < verts; j++) {
int readlen2;
- if (std::sscanf(ts.currentLine() + readlen, " %d, %d%n",
- _faces[num]._vertices + j, _faces[num]._texVertices + j, &readlen2) < 2)
+ if (std::sscanf(ts.currentLine() + readlen, " %d, %d%n", _faces[num]._vertices + j, _faces[num]._texVertices + j, &readlen2) < 2)
error("Could not read vertex indices in line `%s'\n",
ts.currentLine());
@@ -439,6 +435,8 @@ void Model::HierNode::setMatrix(Matrix4 matrix) {
}
void Model::HierNode::update() {
+ g_driver->updateHierachyNode1(this);
+
_localMatrix._pos.set(_animPos.x() / _totalWeight, _animPos.y() / _totalWeight, _animPos.z() / _totalWeight);
_localMatrix._rot.buildFromPitchYawRoll(_animPitch / _totalWeight, _animYaw / _totalWeight, _animRoll / _totalWeight);
@@ -448,14 +446,15 @@ void Model::HierNode::update() {
_pivotMatrix.translate(_pivot.x(), _pivot.y(), _pivot.z() );
- g_driver->updateHierachyNode(this);
+ g_driver->updateHierachyNode2(this);
}
void Model::Mesh::draw() const {
for (int i = 0; i < _numFaces; i++)
_faces[i].draw(_vertices, _vertNormals, _textureVerts);
- g_driver->drawModel(this);
+// g_driver->drawModelNodeDebug(this);
+// g_driver->drawModelPolygonPointsDebug(this);
}
void Model::Face::draw(float *vertices, float *vertNormals, float *textureVerts) const {
diff --git a/scene.cpp b/scene.cpp
index 53e60276045..e9494cec40e 100644
--- a/scene.cpp
+++ b/scene.cpp
@@ -23,7 +23,6 @@
#include "bitmap.h"
#include "colormap.h"
#include "vector3d.h"
-#include "screen.h"
#include "driver_gl.h"
#include "imuse/imuse.h"
@@ -167,14 +166,6 @@ void Scene::Setup::setupCamera() const {
void Scene::setSetup(int num) {
_currSetup = _setups + num;
-
- if (!SCREENBLOCKS_GLOBAL)
- return;
-
- if (_currSetup->_bkgndZBm)
- screenBlocksInit(_currSetup->_bkgndZBm->getZbufferData());
- else
- screenBlocksInitEmpty();
}
void Scene::drawBitmaps(ObjectState::Position stage) {
diff --git a/scene.h b/scene.h
index bbc45619494..7c37b2a5615 100644
--- a/scene.h
+++ b/scene.h
@@ -108,8 +108,9 @@ private:
Sector *_sectors;
Light *_lights;
Setup *_setups;
+public:
Setup *_currSetup;
-
+private:
typedef std::list StateList;
StateList _states;
};
diff --git a/screen.cpp b/screen.cpp
index 13f28aba5cb..41fffa7df0a 100644
--- a/screen.cpp
+++ b/screen.cpp
@@ -15,11 +15,14 @@
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#include "stdafx.h"
+#include "bits.h"
#include "screen.h"
#include
unsigned short int dataTemp[640 * 480];
+unsigned short int dataTemp2[640 * 480];
screenBlockDataStruct screenBlockData[NUM_SCREEN_BLOCK_WIDTH][NUM_SCREEN_BLOCK_HEIGHT];
@@ -56,11 +59,22 @@ float getZbufferBlockDepth(char *zbuffer, int x, int y) {
void screenBlocksInit(char* zbuffer) {
memcpy(dataTemp, zbuffer, 640 * 480 * 2);
+ memcpy(dataTemp2, zbuffer, 640 * 480 * 2);
+ uint16 *zbufPtr = reinterpret_cast(dataTemp);
+ for (int y = 0; y < 480 / 2; y++) {
+ uint16 *ptr1 = zbufPtr + y * 640;
+ uint16 *ptr2 = zbufPtr + (479 - y) * 640;
+ for (int x = 0; x < 640; x++, ptr1++, ptr2++) {
+ uint16 tmp = *ptr1;
+ *ptr1 = *ptr2;
+ *ptr2 = tmp;
+ }
+ }
for (int i = 0; i < NUM_SCREEN_BLOCK_WIDTH; i++) {
for(int j = 0; j < NUM_SCREEN_BLOCK_HEIGHT; j++) {
screenBlockData[i][j].isDirty = false;
- screenBlockData[i][j].depth = getZbufferBlockDepth(zbuffer, i, j);
+ screenBlockData[i][j].depth = getZbufferBlockDepth((char *)dataTemp, i, j);
}
}
}
@@ -181,10 +195,10 @@ void screenBlocksBlitDirtyBlocks() {
i++;
width++;
}
- for (int y = 0; y < 16; y++) {
- glRasterPos2i(start * 16, j * 16 + y + 1);
- glDrawPixels(16 * width, 1, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT, dataTemp + ((j * 16 + y) * 640) + (start * 16));
- }
+ glRasterPos2i(start * 16, 479 - (j * 16));
+ glPixelStorei(GL_UNPACK_ALIGNMENT, 2);
+ glDrawPixels(16 * width, 16, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT, dataTemp2 + (j * 16 * 640) + (start * 16));
+ glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
}
}
}