corrected zbuffer data access, but screenblock not works for me (or rather never for me)

This commit is contained in:
Pawel Kolodziejski 2005-01-05 22:13:56 +00:00
parent 934c88961c
commit 3a6a28ff05
6 changed files with 30 additions and 26 deletions

View file

@ -42,6 +42,7 @@ public:
int y() const { return _y; } int y() const { return _y; }
char *getData() { return _data[_currImage]; } char *getData() { return _data[_currImage]; }
char *getZbufferData() { return _data[_currImage - 1]; }
~Bitmap(); ~Bitmap();

View file

@ -323,10 +323,10 @@ void Driver::updateMesh(const Model::Mesh *mesh) {
if(winZ > bestDepth) if(winZ > bestDepth)
bestDepth = winZ; bestDepth = winZ;
} }
//screenBlocksAddRectangle(top, right, left, bottom, bestDepth); // if (SCREENBLOCKS_GLOBAL)
// screenBlocksAddRectangle(top, right, left, bottom, bestDepth);
} }
glDisable(GL_DEPTH_TEST); glDisable(GL_DEPTH_TEST);

View file

@ -125,9 +125,6 @@ void Engine::mainLoop() {
} }
} }
} else if (_mode == ENGINE_MODE_NORMAL) { } else if (_mode == ENGINE_MODE_NORMAL) {
if (SCREENBLOCKS_GLOBAL)
screenBlocksReset();
if (_currScene != NULL) { if (_currScene != NULL) {
// Update actor costumes // Update actor costumes
for (ActorListType::iterator i = _actors.begin(); i != _actors.end(); i++) { for (ActorListType::iterator i = _actors.begin(); i != _actors.end(); i++) {
@ -137,6 +134,9 @@ void Engine::mainLoop() {
} }
} }
if (SCREENBLOCKS_GLOBAL)
screenBlocksReset();
g_driver->clearScreen(); g_driver->clearScreen();
if (SCREENBLOCKS_GLOBAL) if (SCREENBLOCKS_GLOBAL)
@ -176,7 +176,9 @@ void Engine::mainLoop() {
if (_currScene != NULL && a->inSet(_currScene->name()) && a->visible()) if (_currScene != NULL && a->inSet(_currScene->name()) && a->visible())
a->draw(); a->draw();
} }
//screenBlocksDrawDebug();
if (SCREENBLOCKS_GLOBAL)
screenBlocksDrawDebug();
} }
// Draw text // Draw text

View file

@ -172,7 +172,7 @@ void Scene::setSetup(int num) {
return; return;
if (_currSetup->_bkgndZBm) if (_currSetup->_bkgndZBm)
screenBlocksInit(_currSetup->_bkgndZBm->getData() ); screenBlocksInit(_currSetup->_bkgndZBm->getZbufferData());
else else
screenBlocksInitEmpty(); screenBlocksInitEmpty();
} }
@ -229,7 +229,7 @@ ObjectState *Scene::findState(const char *filename) {
void Scene::setSoundPosition(const char *soundName, Vector3d pos) { void Scene::setSoundPosition(const char *soundName, Vector3d pos) {
Vector3d cameraPos = _currSetup->_pos; Vector3d cameraPos = _currSetup->_pos;
Vector3d vector; Vector3d vector, vector2;
vector.set(fabs(cameraPos.x() - pos.x()), fabs(cameraPos.y() - pos.y()), fabs(cameraPos.z() - pos.z())); vector.set(fabs(cameraPos.x() - pos.x()), fabs(cameraPos.y() - pos.y()), fabs(cameraPos.z() - pos.z()));
float distance = vector.magnitude(); float distance = vector.magnitude();
float maxDistance = 8.0f; float maxDistance = 8.0f;
@ -238,8 +238,16 @@ void Scene::setSoundPosition(const char *soundName, Vector3d pos) {
newVolume += _minVolume; newVolume += _minVolume;
g_imuse->setVolume(soundName, newVolume); g_imuse->setVolume(soundName, newVolume);
// TODO: pan vector.set(_currSetup->_interest.x() - cameraPos.x(), _currSetup->_interest.y() - cameraPos.y(),
// roll, fov _currSetup->_interest.z() - cameraPos.z());
vector2.set(pos.x() - cameraPos.x(), pos.y() - cameraPos.y(), pos.z() - cameraPos.z());
// printf("a pos (%2.2f, %2.2f, %2.2f) i pos (%2.2f, %2.2f, %2.2f) c pos (%2.2f, %2.2f, %2.2f)\n", pos.x(), pos.y(), pos.z(),
// _currSetup->_interest.x(), _currSetup->_interest.y(), _currSetup->_interest.z(),
// cameraPos.x(), cameraPos.y(), cameraPos.z());
float a = angle(vector, vector2);
int pan = a * 127 * 1.5;
pan = (pan / 2) + 64;
// g_imuse->setPan(soundName, pan);
} }
void Scene::setSoundParameters(int minVolume, int maxVolume) { void Scene::setSoundParameters(int minVolume, int maxVolume) {

View file

@ -46,7 +46,7 @@ float getZbufferBlockDepth(char *zbuffer, int x, int y) {
unsigned short int bDepth = 0xFFFF; unsigned short int bDepth = 0xFFFF;
for (i = 0; i < SCREEN_BLOCK_SIZE; i++ ) { for (i = 0; i < SCREEN_BLOCK_SIZE; i++) {
if (bDepth > buffer[i]) if (bDepth > buffer[i])
bDepth = buffer[i]; bDepth = buffer[i];
} }
@ -105,19 +105,14 @@ void screenBlocksAddRectangle( int top, int right, int left, int bottom, float d
if ((left > right) || (top > bottom)) if ((left > right) || (top > bottom))
return; return;
int firstLeft; int firstLeft = left / 16;
int firstTop; int firstTop = top /16;
int width;
int height;
firstLeft = left / 16; int width = (right - left) / 16;
firstTop = top /16; if ((right - left) % 16)
width = (right - left) / 16;
if ((right-left) % 16)
width++; width++;
height = (bottom - top) / 16; int height = (bottom - top) / 16;
if ((bottom - top) % 16) if ((bottom - top) % 16)
height++; height++;
@ -142,7 +137,7 @@ void screenBlocksDrawDebug() {
glDisable(GL_DEPTH_TEST); glDisable(GL_DEPTH_TEST);
glColor4f(1.f, 0.3f, 1.f, 0.4f); glColor4f(1.f, 0.3f, 1.f, 0.4f);
glDisable(GL_TEXTURE_2D ); glDisable(GL_TEXTURE_2D);
glDisable(GL_LIGHTING); glDisable(GL_LIGHTING);
glEnable(GL_BLEND); glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
@ -176,7 +171,7 @@ void screenBlocksBlitDirtyBlocks() {
glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
glDepthMask(GL_TRUE); glDepthMask(GL_TRUE);
for (int j = 0;j < 30; j++) { for (int j = 0; j < 30; j++) {
for (int i = 0; i < 40; i++) { for (int i = 0; i < 40; i++) {
if (screenBlockData[i][j].isDirty) { if (screenBlockData[i][j].isDirty) {
int width = 1; int width = 1;
@ -197,4 +192,3 @@ void screenBlocksBlitDirtyBlocks() {
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
glDepthFunc(GL_LESS); glDepthFunc(GL_LESS);
} }

View file

@ -48,4 +48,3 @@ void screenBlocksDrawDebug();
void screenBlocksBlitDirtyBlocks(); void screenBlocksBlitDirtyBlocks();
#endif // _SCREEN_H_ #endif // _SCREEN_H_