mirror of
https://github.com/XProger/OpenLara.git
synced 2025-08-21 04:11:53 +02:00
#15 fix PSP build
This commit is contained in:
@@ -532,6 +532,10 @@ struct Camera : ICamera {
|
|||||||
fov = firstPerson ? 90.0f : 65.0f;
|
fov = firstPerson ? 90.0f : 65.0f;
|
||||||
znear = firstPerson ? 8.0f : 32.0f;
|
znear = firstPerson ? 8.0f : 32.0f;
|
||||||
zfar = 45.0f * 1024.0f;
|
zfar = 45.0f * 1024.0f;
|
||||||
|
|
||||||
|
#ifdef _OS_PSP
|
||||||
|
znear = 256.0f;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
12
src/core.h
12
src/core.h
@@ -246,17 +246,29 @@ namespace Core {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void setLighting(Quality value) {
|
void setLighting(Quality value) {
|
||||||
|
#ifdef _OS_PSP
|
||||||
|
lighting = LOW;
|
||||||
|
#else
|
||||||
lighting = value;
|
lighting = value;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void setShadows(Quality value) {
|
void setShadows(Quality value) {
|
||||||
|
#ifdef _OS_PSP
|
||||||
|
shadows = LOW;
|
||||||
|
#else
|
||||||
shadows = value;
|
shadows = value;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void setWater(Quality value) {
|
void setWater(Quality value) {
|
||||||
|
#ifdef _OS_PSP
|
||||||
|
water = LOW;
|
||||||
|
#else
|
||||||
if (value > LOW && !(support.texFloat || support.texHalf))
|
if (value > LOW && !(support.texFloat || support.texHalf))
|
||||||
value = LOW;
|
value = LOW;
|
||||||
water = value;
|
water = value;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
} detail;
|
} detail;
|
||||||
|
|
||||||
|
@@ -6,10 +6,9 @@
|
|||||||
#include <pspgu.h>
|
#include <pspgu.h>
|
||||||
#include <pspgum.h>
|
#include <pspgum.h>
|
||||||
|
|
||||||
#define FFP
|
#define PROFILE_MARKER(title)
|
||||||
#define TEX_SWIZZLE
|
#define PROFILE_LABEL(id, name, label)
|
||||||
//#define EDRAM_MESH
|
#define PROFILE_TIMING(time)
|
||||||
#define EDRAM_TEX
|
|
||||||
|
|
||||||
namespace GAPI {
|
namespace GAPI {
|
||||||
|
|
||||||
@@ -22,6 +21,16 @@ namespace GAPI {
|
|||||||
short3 coord;
|
short3 coord;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Shader
|
||||||
|
struct Shader {
|
||||||
|
void init(Core::Pass pass, int type, int *def, int defCount) {}
|
||||||
|
void deinit() {}
|
||||||
|
void bind() {}
|
||||||
|
void setParam(UniformType uType, const vec4 &value, int count = 1) {}
|
||||||
|
void setParam(UniformType uType, const mat4 &value, int count = 1) {}
|
||||||
|
void setParam(UniformType uType, const Basis &value, int count = 1) {}
|
||||||
|
};
|
||||||
|
|
||||||
// Texture
|
// Texture
|
||||||
struct Texture {
|
struct Texture {
|
||||||
uint8 *memory;
|
uint8 *memory;
|
||||||
@@ -100,9 +109,9 @@ namespace GAPI {
|
|||||||
|
|
||||||
void setFilterQuality(int value) {
|
void setFilterQuality(int value) {
|
||||||
if (value > Core::Settings::LOW)
|
if (value > Core::Settings::LOW)
|
||||||
opt &= ~NEAREST;
|
opt &= ~OPT_NEAREST;
|
||||||
else
|
else
|
||||||
opt |= NEAREST;
|
opt |= OPT_NEAREST;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -117,17 +126,16 @@ namespace GAPI {
|
|||||||
|
|
||||||
Mesh(bool dynamic) : iBuffer(NULL), vBuffer(NULL), dynamic(dynamic) {}
|
Mesh(bool dynamic) : iBuffer(NULL), vBuffer(NULL), dynamic(dynamic) {}
|
||||||
|
|
||||||
void init(Index *indices, int iCount, ::Vertex *vertices, int vCount, int aCount, bool dynamic) {
|
void init(Index *indices, int iCount, ::Vertex *vertices, int vCount, int aCount) {
|
||||||
this->iCount = iCount;
|
this->iCount = iCount;
|
||||||
this->vCount = vCount;
|
this->vCount = vCount;
|
||||||
this->dynamic = dynamic;
|
|
||||||
|
|
||||||
if (dynamic)
|
if (dynamic)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
#ifdef EDRAM_MESH
|
#ifdef EDRAM_MESH
|
||||||
iBuffer = (Index*)Core::allocEDRAM(iCount * sizeof(Index));
|
iBuffer = (Index*)allocEDRAM(iCount * sizeof(Index));
|
||||||
vBuffer = (Vertex*)Core::allocEDRAM(vCount * sizeof(Vertex));
|
vBuffer = (Vertex*)allocEDRAM(vCount * sizeof(Vertex));
|
||||||
#else
|
#else
|
||||||
iBuffer = new Index[iCount];
|
iBuffer = new Index[iCount];
|
||||||
vBuffer = new Vertex[vCount];
|
vBuffer = new Vertex[vCount];
|
||||||
@@ -171,12 +179,7 @@ namespace GAPI {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void bind(const MeshRange &range) const {
|
void bind(const MeshRange &range) const {}
|
||||||
ASSERT(iBuffer != NULL);
|
|
||||||
ASSERT(vBuffer != NULL);
|
|
||||||
Core::active.iBuffer = iBuffer;
|
|
||||||
Core::active.vBuffer = vBuffer + range.vStart;
|
|
||||||
}
|
|
||||||
|
|
||||||
void initNextRange(MeshRange &range, int &aIndex) const {
|
void initNextRange(MeshRange &range, int &aIndex) const {
|
||||||
range.aIndex = -1;
|
range.aIndex = -1;
|
||||||
@@ -193,8 +196,8 @@ namespace GAPI {
|
|||||||
static int EDRAM_SIZE;
|
static int EDRAM_SIZE;
|
||||||
|
|
||||||
void* allocEDRAM(int size) {
|
void* allocEDRAM(int size) {
|
||||||
LOG("EDRAM ALLOC: offset: %d size %d (free %d)\n", Core::EDRAM_OFFSET, size, EDRAM_SIZE - (Core::EDRAM_OFFSET + size));
|
LOG("EDRAM ALLOC: offset: %d size %d (free %d)\n", EDRAM_OFFSET, size, EDRAM_SIZE - (EDRAM_OFFSET + size));
|
||||||
if (Core::EDRAM_OFFSET + size > EDRAM_SIZE)
|
if (EDRAM_OFFSET + size > EDRAM_SIZE)
|
||||||
LOG("! EDRAM overflow !\n");
|
LOG("! EDRAM overflow !\n");
|
||||||
|
|
||||||
void *ptr = ((char*)sceGeEdramGetAddr()) + EDRAM_OFFSET;
|
void *ptr = ((char*)sceGeEdramGetAddr()) + EDRAM_OFFSET;
|
||||||
@@ -290,11 +293,11 @@ namespace GAPI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
mat4 ortho(float l, float r, float b, float t, float znear, float zfar) {
|
mat4 ortho(float l, float r, float b, float t, float znear, float zfar) {
|
||||||
return mat4(mat4::PROJ_ZERO_POS, l, r, b, t, znear, zfar);
|
return mat4(mat4::PROJ_NEG_POS, l, r, b, t, znear, zfar);
|
||||||
}
|
}
|
||||||
|
|
||||||
mat4 perspective(float fov, float aspect, float znear, float zfar) {
|
mat4 perspective(float fov, float aspect, float znear, float zfar) {
|
||||||
return mat4(mat4::PROJ_ZERO_POS, fov, aspect, znear, zfar);
|
return mat4(mat4::PROJ_NEG_POS, fov, aspect, znear, zfar);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool beginFrame() {
|
bool beginFrame() {
|
||||||
@@ -397,12 +400,28 @@ namespace GAPI {
|
|||||||
sceGumMatrixMode(GU_MODEL);
|
sceGumMatrixMode(GU_MODEL);
|
||||||
sceGumLoadMatrix((ScePspFMatrix4*)&m);
|
sceGumLoadMatrix((ScePspFMatrix4*)&m);
|
||||||
|
|
||||||
sceGumDrawArray(GU_TRIANGLES, GU_TEXTURE_16BIT | GU_COLOR_8888 | GU_NORMAL_16BIT | GU_VERTEX_16BIT | GU_INDEX_16BIT | GU_TRANSFORM_3D, range.iCount, mesh->iBuffer + range.iStart, mesh->vBuffer);
|
sceGumDrawArray(GU_TRIANGLES, GU_TEXTURE_16BIT | GU_COLOR_8888 | GU_NORMAL_16BIT | GU_VERTEX_16BIT | GU_INDEX_16BIT | GU_TRANSFORM_3D, range.iCount, mesh->iBuffer + range.iStart, mesh->vBuffer + range.vStart);
|
||||||
}
|
}
|
||||||
|
|
||||||
vec4 copyPixel(int x, int y) {
|
vec4 copyPixel(int x, int y) {
|
||||||
return vec4(0.0f); // TODO: read from framebuffer
|
return vec4(0.0f); // TODO: read from framebuffer
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void initPSO(PSO *pso) {
|
||||||
|
ASSERT(pso);
|
||||||
|
ASSERT(pso && pso->data == NULL);
|
||||||
|
pso->data = &pso;
|
||||||
|
}
|
||||||
|
|
||||||
|
void deinitPSO(PSO *pso) {
|
||||||
|
ASSERT(pso);
|
||||||
|
ASSERT(pso->data != NULL);
|
||||||
|
pso->data = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void bindPSO(const PSO *pso) {
|
||||||
|
//
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
@@ -1417,9 +1417,6 @@ struct Inventory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void renderGameBG() {
|
void renderGameBG() {
|
||||||
#ifdef _OS_PSP
|
|
||||||
return;
|
|
||||||
#endif
|
|
||||||
Index indices[6] = { 0, 1, 2, 0, 2, 3 };
|
Index indices[6] = { 0, 1, 2, 0, 2, 3 };
|
||||||
Vertex vertices[4];
|
Vertex vertices[4];
|
||||||
vertices[0].coord = short4(-32767, 32767, 0, 0);
|
vertices[0].coord = short4(-32767, 32767, 0, 0);
|
||||||
@@ -1437,9 +1434,7 @@ struct Inventory {
|
|||||||
|
|
||||||
game->setShader(Core::passFilter, Shader::DEFAULT, false, false);
|
game->setShader(Core::passFilter, Shader::DEFAULT, false, false);
|
||||||
if (Core::settings.detail.stereo == Core::Settings::STEREO_VR || !background[0]) {
|
if (Core::settings.detail.stereo == Core::Settings::STEREO_VR || !background[0]) {
|
||||||
for (int i = 0; i < 4; i++)
|
Core::blackTex->bind(sDiffuse); // black background
|
||||||
vertices[i].light.x = vertices[i].light.y = vertices[i].light.z = 0;
|
|
||||||
Core::whiteTex->bind(sDiffuse); // black background
|
|
||||||
} else
|
} else
|
||||||
background[0]->bind(sDiffuse); // blured grayscale image
|
background[0]->bind(sDiffuse); // blured grayscale image
|
||||||
|
|
||||||
|
173
src/level.h
173
src/level.h
@@ -417,6 +417,10 @@ struct Level : IGame {
|
|||||||
Core::active.shader->setParam(uParam, Core::params);
|
Core::active.shader->setParam(uParam, Core::params);
|
||||||
Core::setMaterial(diffuse, ambient, specular, alpha);
|
Core::setMaterial(diffuse, ambient, specular, alpha);
|
||||||
|
|
||||||
|
#ifdef FFP
|
||||||
|
updateLighting(type);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (Core::settings.detail.shadows > Core::Settings::MEDIUM)
|
if (Core::settings.detail.shadows > Core::Settings::MEDIUM)
|
||||||
Core::active.shader->setParam(uContacts, Core::contacts[0], MAX_CONTACTS);
|
Core::active.shader->setParam(uContacts, Core::contacts[0], MAX_CONTACTS);
|
||||||
}
|
}
|
||||||
@@ -659,7 +663,7 @@ struct Level : IGame {
|
|||||||
flags |= Sound::LOOP;
|
flags |= Sound::LOOP;
|
||||||
|
|
||||||
waitTrack = true;
|
waitTrack = true;
|
||||||
getGameTrack(level.version, track, playAsync, new TrackRequest(this, flags));
|
TR::getGameTrack(level.version, track, playAsync, new TrackRequest(this, flags));
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void stopTrack() {
|
virtual void stopTrack() {
|
||||||
@@ -669,7 +673,7 @@ struct Level : IGame {
|
|||||||
|
|
||||||
Level(Stream &stream) : level(stream), inventory(this), waitTrack(false), isEnded(false), cutsceneWaitTimer(0.0f), animTexTimer(0.0f) {
|
Level(Stream &stream) : level(stream), inventory(this), waitTrack(false), isEnded(false), cutsceneWaitTimer(0.0f), animTexTimer(0.0f) {
|
||||||
#ifdef _OS_PSP
|
#ifdef _OS_PSP
|
||||||
Core::freeEDRAM();
|
GAPI::freeEDRAM();
|
||||||
#endif
|
#endif
|
||||||
params = (Params*)&Core::params;
|
params = (Params*)&Core::params;
|
||||||
params->time = 0.0f;
|
params->time = 0.0f;
|
||||||
@@ -1158,43 +1162,54 @@ struct Level : IGame {
|
|||||||
#ifdef _OS_PSP
|
#ifdef _OS_PSP
|
||||||
atlas = new Texture(level.tiles4, level.tilesCount, level.cluts, level.clutsCount);
|
atlas = new Texture(level.tiles4, level.tilesCount, level.cluts, level.clutsCount);
|
||||||
#else
|
#else
|
||||||
level.initTiles();
|
TR::Tile32 *tiles = new TR::Tile32[level.tilesCount];
|
||||||
|
|
||||||
atlas = new Texture(level.tiles, level.tilesCount);
|
for (int i = 0; i < level.objectTexturesCount; i++) {
|
||||||
|
TR::ObjectTexture &t = level.objectTextures[i];
|
||||||
|
short4 uv = t.getMinMax();
|
||||||
|
level.fillObjectTexture(&tiles[t.tile.index], uv, t.tile.index, t.clut);
|
||||||
|
}
|
||||||
|
|
||||||
delete[] level.tiles;
|
for (int i = 0; i < level.spriteTexturesCount; i++) {
|
||||||
level.tiles = NULL;
|
TR::SpriteTexture &t = level.spriteTextures[i];
|
||||||
|
short4 uv = t.getMinMax();
|
||||||
|
level.fillObjectTexture(&tiles[t.tile], uv, t.tile, t.clut);
|
||||||
|
}
|
||||||
|
|
||||||
|
atlas = new Texture(tiles, level.tilesCount);
|
||||||
|
|
||||||
|
delete[] tiles;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
for (int i = 0; i < level.objectTexturesCount; i++) {
|
for (int i = 0; i < level.objectTexturesCount; i++) {
|
||||||
TR::ObjectTexture &t = level.objectTextures[i];
|
TR::ObjectTexture &t = level.objectTextures[i];
|
||||||
|
|
||||||
t.texCoord[0].x <<= 7;
|
t.texCoordAtlas[0].x <<= 7;
|
||||||
t.texCoord[0].y <<= 7;
|
t.texCoordAtlas[0].y <<= 7;
|
||||||
t.texCoord[1].x <<= 7;
|
t.texCoordAtlas[1].x <<= 7;
|
||||||
t.texCoord[1].y <<= 7;
|
t.texCoordAtlas[1].y <<= 7;
|
||||||
t.texCoord[2].x <<= 7;
|
t.texCoordAtlas[2].x <<= 7;
|
||||||
t.texCoord[2].y <<= 7;
|
t.texCoordAtlas[2].y <<= 7;
|
||||||
t.texCoord[3].x <<= 7;
|
t.texCoordAtlas[3].x <<= 7;
|
||||||
t.texCoord[3].y <<= 7;
|
t.texCoordAtlas[3].y <<= 7;
|
||||||
|
|
||||||
t.texCoord[0].x += 64;
|
t.texCoordAtlas[0].x += 64;
|
||||||
t.texCoord[0].y += 64;
|
t.texCoordAtlas[0].y += 64;
|
||||||
t.texCoord[1].x += 64;
|
t.texCoordAtlas[1].x += 64;
|
||||||
t.texCoord[1].y += 64;
|
t.texCoordAtlas[1].y += 64;
|
||||||
t.texCoord[2].x += 64;
|
t.texCoordAtlas[2].x += 64;
|
||||||
t.texCoord[2].y += 64;
|
t.texCoordAtlas[2].y += 64;
|
||||||
t.texCoord[3].x += 64;
|
t.texCoordAtlas[3].x += 64;
|
||||||
t.texCoord[3].y += 64;
|
t.texCoordAtlas[3].y += 64;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < level.spriteTexturesCount; i++) {
|
for (int i = 0; i < level.spriteTexturesCount; i++) {
|
||||||
TR::SpriteTexture &t = level.spriteTextures[i];
|
TR::SpriteTexture &t = level.spriteTextures[i];
|
||||||
|
|
||||||
t.texCoord[0].x <<= 7;
|
t.texCoordAtlas[0].x <<= 7;
|
||||||
t.texCoord[0].y <<= 7;
|
t.texCoordAtlas[0].y <<= 7;
|
||||||
t.texCoord[1].x <<= 7;
|
t.texCoordAtlas[1].x <<= 7;
|
||||||
t.texCoord[1].y <<= 7;
|
t.texCoordAtlas[1].y <<= 7;
|
||||||
/*
|
/*
|
||||||
t.texCoord[0].x += 16;
|
t.texCoord[0].x += 16;
|
||||||
t.texCoord[0].y += 16;
|
t.texCoord[0].y += 16;
|
||||||
@@ -1351,9 +1366,6 @@ struct Level : IGame {
|
|||||||
dir = -1;
|
dir = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
beginLighting(true);
|
|
||||||
updateLighting();
|
|
||||||
|
|
||||||
while (i != end) {
|
while (i != end) {
|
||||||
int roomIndex = roomsList[i];
|
int roomIndex = roomsList[i];
|
||||||
MeshBuilder::RoomRange &range = mesh->rooms[roomIndex];
|
MeshBuilder::RoomRange &range = mesh->rooms[roomIndex];
|
||||||
@@ -1412,7 +1424,6 @@ struct Level : IGame {
|
|||||||
mesh->renderRoomSprites(roomIndex);
|
mesh->renderRoomSprites(roomIndex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
endLighting();
|
|
||||||
|
|
||||||
Core::setBlendMode(bmNone);
|
Core::setBlendMode(bmNone);
|
||||||
}
|
}
|
||||||
@@ -1445,6 +1456,13 @@ struct Level : IGame {
|
|||||||
if (entity.type == TR::Entity::CRYSTAL)
|
if (entity.type == TR::Entity::CRYSTAL)
|
||||||
type = Shader::MIRROR;
|
type = Shader::MIRROR;
|
||||||
|
|
||||||
|
if (isModel) { // model
|
||||||
|
setMainLight(controller);
|
||||||
|
} else { // sprite
|
||||||
|
Core::lightPos[0] = vec4(0, 0, 0, 0);
|
||||||
|
Core::lightColor[0] = vec4(0, 0, 0, 1);
|
||||||
|
}
|
||||||
|
|
||||||
if (type == Shader::SPRITE) {
|
if (type == Shader::SPRITE) {
|
||||||
float alpha = (entity.type == TR::Entity::SMOKE || entity.type == TR::Entity::WATER_SPLASH || entity.type == TR::Entity::SPARKLES) ? 0.75f : 1.0f;
|
float alpha = (entity.type == TR::Entity::SMOKE || entity.type == TR::Entity::WATER_SPLASH || entity.type == TR::Entity::SPARKLES) ? 0.75f : 1.0f;
|
||||||
float diffuse = entity.isPickup() ? 1.0f : 0.5f;
|
float diffuse = entity.isPickup() ? 1.0f : 0.5f;
|
||||||
@@ -1452,8 +1470,6 @@ struct Level : IGame {
|
|||||||
} else
|
} else
|
||||||
setRoomParams(roomIndex, type, 1.0f, intensity, controller->specular, 1.0f, mesh->transparent == 1);
|
setRoomParams(roomIndex, type, 1.0f, intensity, controller->specular, 1.0f, mesh->transparent == 1);
|
||||||
|
|
||||||
updateLighting();
|
|
||||||
|
|
||||||
if (isModel) { // model
|
if (isModel) { // model
|
||||||
vec3 pos = controller->getPos();
|
vec3 pos = controller->getPos();
|
||||||
if (ambientCache) {
|
if (ambientCache) {
|
||||||
@@ -1463,11 +1479,6 @@ struct Level : IGame {
|
|||||||
memcpy(controller->ambient, cube.colors, sizeof(cube.colors)); // store last calculated ambient into controller
|
memcpy(controller->ambient, cube.colors, sizeof(cube.colors)); // store last calculated ambient into controller
|
||||||
Core::active.shader->setParam(uAmbient, controller->ambient[0], 6);
|
Core::active.shader->setParam(uAmbient, controller->ambient[0], 6);
|
||||||
}
|
}
|
||||||
|
|
||||||
setMainLight(controller);
|
|
||||||
} else { // sprite
|
|
||||||
Core::lightPos[0] = vec4(0, 0, 0, 0);
|
|
||||||
Core::lightColor[0] = vec4(0, 0, 0, 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Core::active.shader->setParam(uLightPos, Core::lightPos[0], MAX_LIGHTS);
|
Core::active.shader->setParam(uLightPos, Core::lightPos[0], MAX_LIGHTS);
|
||||||
@@ -1602,13 +1613,41 @@ struct Level : IGame {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateLighting() {
|
#ifdef FFP
|
||||||
#ifdef FFP
|
void updateLighting(Shader::Type type) {
|
||||||
|
float ambient = Core::active.material.y;
|
||||||
|
int lightMask = 0;
|
||||||
|
switch (type) {
|
||||||
|
case Shader::SPRITE :
|
||||||
|
case Shader::ROOM :
|
||||||
|
ambient = 1.0f;
|
||||||
|
lightMask = 2;
|
||||||
|
break;
|
||||||
|
case Shader::ENTITY :
|
||||||
|
lightMask = 1 | 2;
|
||||||
|
break;
|
||||||
|
case Shader::FLASH :
|
||||||
|
case Shader::MIRROR :
|
||||||
|
ambient = 1.0f;
|
||||||
|
break;
|
||||||
|
default : ;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef _OS_PSP
|
#ifdef _OS_PSP
|
||||||
ubyte4 ambient;
|
if (lightMask & 1)
|
||||||
ambient.x = ambient.y = ambient.z = clamp(int(Core::active.material.y * 255), 0, 255);
|
sceGuEnable(GU_LIGHT0);
|
||||||
ambient.w = 255;
|
else
|
||||||
sceGuAmbient(*(uint32*)&ambient);
|
sceGuDisable(GU_LIGHT0);
|
||||||
|
|
||||||
|
if (lightMask & 2)
|
||||||
|
sceGuEnable(GU_LIGHT1);
|
||||||
|
else
|
||||||
|
sceGuDisable(GU_LIGHT1);
|
||||||
|
|
||||||
|
ubyte4 amb;
|
||||||
|
amb.x = amb.y = amb.z = clamp(int(ambient * 255), 0, 255);
|
||||||
|
amb.w = 255;
|
||||||
|
sceGuAmbient(*(uint32*)&amb);
|
||||||
|
|
||||||
for (int i = 0; i < 2 /*MAX_LIGHTS*/; i++) {
|
for (int i = 0; i < 2 /*MAX_LIGHTS*/; i++) {
|
||||||
ScePspFVector3 pos;
|
ScePspFVector3 pos;
|
||||||
@@ -1628,8 +1667,18 @@ struct Level : IGame {
|
|||||||
sceGuLightAtt(i, 1.0f, 0.0f, Core::lightColor[i].w * Core::lightColor[i].w);
|
sceGuLightAtt(i, 1.0f, 0.0f, Core::lightColor[i].w * Core::lightColor[i].w);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
vec4 ambient(vec3(Core::active.material.y), 1.0f);
|
if (lightMask & 1)
|
||||||
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, (GLfloat*)&ambient);
|
glDisable(GL_LIGHT0);
|
||||||
|
else
|
||||||
|
glEnable(GL_LIGHT0);
|
||||||
|
|
||||||
|
if (lightMask & 2)
|
||||||
|
glDisable(GL_LIGHT1);
|
||||||
|
else
|
||||||
|
glEnable(GL_LIGHT1);
|
||||||
|
|
||||||
|
vec4 amb(vec3(ambient), 1.0f);
|
||||||
|
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, (GLfloat*)&amb);
|
||||||
|
|
||||||
for (int i = 0; i < 2 /*MAX_LIGHTS*/; i++) {
|
for (int i = 0; i < 2 /*MAX_LIGHTS*/; i++) {
|
||||||
vec4 pos(Core::lightPos[i].xyz(), 1.0f);
|
vec4 pos(Core::lightPos[i].xyz(), 1.0f);
|
||||||
@@ -1642,41 +1691,27 @@ struct Level : IGame {
|
|||||||
glLightfv(GL_LIGHT0 + i, GL_QUADRATIC_ATTENUATION, (GLfloat*)&att);
|
glLightfv(GL_LIGHT0 + i, GL_QUADRATIC_ATTENUATION, (GLfloat*)&att);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void beginLighting(bool room) {
|
void beginLighting() {
|
||||||
#ifdef FFP
|
|
||||||
Core::mModel.identity();
|
Core::mModel.identity();
|
||||||
#ifdef _OS_PSP
|
#ifdef _OS_PSP
|
||||||
sceGuEnable(GU_LIGHTING);
|
sceGuEnable(GU_LIGHTING);
|
||||||
if (room)
|
|
||||||
sceGuDisable(GU_LIGHT0);
|
|
||||||
else
|
|
||||||
sceGuEnable(GU_LIGHT0);
|
|
||||||
sceGuEnable(GU_LIGHT1);
|
|
||||||
#else
|
#else
|
||||||
glEnable(GL_COLOR_MATERIAL);
|
glEnable(GL_COLOR_MATERIAL);
|
||||||
glEnable(GL_LIGHTING);
|
glEnable(GL_LIGHTING);
|
||||||
if (room)
|
|
||||||
glDisable(GL_LIGHT0);
|
|
||||||
else
|
|
||||||
glEnable(GL_LIGHT0);
|
|
||||||
glEnable(GL_LIGHT1);
|
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void endLighting() {
|
void endLighting() {
|
||||||
#ifdef FFP
|
|
||||||
#ifdef _OS_PSP
|
#ifdef _OS_PSP
|
||||||
sceGuDisable(GU_LIGHTING);
|
sceGuDisable(GU_LIGHTING);
|
||||||
#else
|
#else
|
||||||
glDisable(GL_COLOR_MATERIAL);
|
glDisable(GL_COLOR_MATERIAL);
|
||||||
glDisable(GL_LIGHTING);
|
glDisable(GL_LIGHTING);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
camera->setup(Core::pass == Core::passCompose);
|
camera->setup(Core::pass == Core::passCompose);
|
||||||
@@ -1698,8 +1733,6 @@ struct Level : IGame {
|
|||||||
|
|
||||||
PROFILE_MARKER("ENTITIES");
|
PROFILE_MARKER("ENTITIES");
|
||||||
|
|
||||||
beginLighting(false);
|
|
||||||
|
|
||||||
if (transp == 0) {
|
if (transp == 0) {
|
||||||
Core::setBlendMode(bmNone);
|
Core::setBlendMode(bmNone);
|
||||||
renderEntitiesTransp(transp);
|
renderEntitiesTransp(transp);
|
||||||
@@ -1733,8 +1766,6 @@ struct Level : IGame {
|
|||||||
renderEntitiesTransp(transp);
|
renderEntitiesTransp(transp);
|
||||||
Core::setDepthWrite(true);
|
Core::setDepthWrite(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
endLighting();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool checkPortal(const TR::Room &room, const TR::Room::Portal &portal, const vec4 &viewPort, vec4 &clipPort) {
|
bool checkPortal(const TR::Room &room, const TR::Room::Portal &portal, const vec4 &viewPort, vec4 &clipPort) {
|
||||||
@@ -1921,11 +1952,17 @@ struct Level : IGame {
|
|||||||
|
|
||||||
prepareRooms(roomsList, roomsCount);
|
prepareRooms(roomsList, roomsCount);
|
||||||
|
|
||||||
updateLighting();
|
#ifdef FFP
|
||||||
|
beginLighting();
|
||||||
|
#endif
|
||||||
|
|
||||||
renderOpaque(roomsList, roomsCount);
|
renderOpaque(roomsList, roomsCount);
|
||||||
renderTransparent(roomsList, roomsCount);
|
renderTransparent(roomsList, roomsCount);
|
||||||
|
|
||||||
|
#ifdef FFP
|
||||||
|
endLighting();
|
||||||
|
#endif
|
||||||
|
|
||||||
if (camera->isUnderwater())
|
if (camera->isUnderwater())
|
||||||
renderAdditive(roomsList, roomsCount);
|
renderAdditive(roomsList, roomsCount);
|
||||||
|
|
||||||
@@ -2097,7 +2134,7 @@ struct Level : IGame {
|
|||||||
void renderShadows(int roomIndex) {
|
void renderShadows(int roomIndex) {
|
||||||
PROFILE_MARKER("PASS_SHADOW");
|
PROFILE_MARKER("PASS_SHADOW");
|
||||||
|
|
||||||
if (Core::settings.detail.shadows == Core::Settings::Quality::LOW)
|
if (Core::settings.detail.shadows == Core::Settings::LOW)
|
||||||
return;
|
return;
|
||||||
ASSERT(shadow);
|
ASSERT(shadow);
|
||||||
|
|
||||||
@@ -2422,7 +2459,7 @@ struct Level : IGame {
|
|||||||
params->waterHeight = params->clipHeight;
|
params->waterHeight = params->clipHeight;
|
||||||
|
|
||||||
if (shadow) {
|
if (shadow) {
|
||||||
if (view > 0 && Core::settings.detail.shadows < Core::Settings::Quality::HIGH)
|
if (view > 0 && Core::settings.detail.shadows < Core::Settings::HIGH)
|
||||||
renderShadows(player->getRoomIndex()); // render shadows for player2 for all-in-one shadow technique
|
renderShadows(player->getRoomIndex()); // render shadows for player2 for all-in-one shadow technique
|
||||||
shadow->bind(sShadow);
|
shadow->bind(sShadow);
|
||||||
}
|
}
|
||||||
|
@@ -352,14 +352,13 @@ struct MeshBuilder {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
int index = level.meshOffsets[model.mStart + j];
|
int index = level.meshOffsets[model.mStart + j];
|
||||||
if (!index && model.mStart + j > 0)
|
if (index || model.mStart + j <= 0) {
|
||||||
continue;
|
|
||||||
|
|
||||||
TR::Mesh &mesh = level.meshes[index];
|
TR::Mesh &mesh = level.meshes[index];
|
||||||
#ifndef MERGE_MODELS
|
#ifndef MERGE_MODELS
|
||||||
geom.getNextRange(vStartModel, iCount, 0xFFFF, 0xFFFF);
|
geom.getNextRange(vStartModel, iCount, 0xFFFF, 0xFFFF);
|
||||||
#endif
|
#endif
|
||||||
buildMesh(geom, blendMask, mesh, level, indices, vertices, iCount, vCount, vStartModel, j, 0, 0, 0, 0, COLOR_WHITE);
|
buildMesh(geom, blendMask, mesh, level, indices, vertices, iCount, vCount, vStartModel, j, 0, 0, 0, 0, COLOR_WHITE);
|
||||||
|
}
|
||||||
|
|
||||||
#ifndef MERGE_MODELS
|
#ifndef MERGE_MODELS
|
||||||
geom.finish(iCount);
|
geom.finish(iCount);
|
||||||
|
@@ -170,7 +170,7 @@ int main() {
|
|||||||
sceDisplayWaitVblankStart();
|
sceDisplayWaitVblankStart();
|
||||||
sceGuDisplay(GU_TRUE);
|
sceGuDisplay(GU_TRUE);
|
||||||
|
|
||||||
Core::curBackBuffer = 0;
|
GAPI::curBackBuffer = 0;
|
||||||
|
|
||||||
while (!Core::isQuit) {
|
while (!Core::isQuit) {
|
||||||
GAPI::beginCmdBuf();
|
GAPI::beginCmdBuf();
|
||||||
@@ -180,7 +180,7 @@ int main() {
|
|||||||
Game::render();
|
Game::render();
|
||||||
GAPI::submitCmdBuf();
|
GAPI::submitCmdBuf();
|
||||||
Core::waitVBlank();
|
Core::waitVBlank();
|
||||||
Core::curBackBuffer = sceGuSwapBuffers();
|
GAPI::curBackBuffer = sceGuSwapBuffers();
|
||||||
}
|
}
|
||||||
|
|
||||||
Game::deinit();
|
Game::deinit();
|
||||||
|
@@ -14,8 +14,8 @@ struct Texture : GAPI::Texture {
|
|||||||
|
|
||||||
Texture(TR::Tile4 *tiles, int tilesCount, TR::CLUT *cluts, int clutsCount) : GAPI::Texture(256, 256, OPT_PROXY) {
|
Texture(TR::Tile4 *tiles, int tilesCount, TR::CLUT *cluts, int clutsCount) : GAPI::Texture(256, 256, OPT_PROXY) {
|
||||||
#ifdef EDRAM_TEX
|
#ifdef EDRAM_TEX
|
||||||
this->tiles = (TR::Tile4*)Core::allocEDRAM(tilesCount * sizeof(tiles[0]));
|
this->tiles = (TR::Tile4*)GAPI::allocEDRAM(tilesCount * sizeof(tiles[0]));
|
||||||
this->cluts = (TR::CLUT*)Core::allocEDRAM(clutsCount * sizeof(cluts[0]));
|
this->cluts = (TR::CLUT*)GAPI::allocEDRAM(clutsCount * sizeof(cluts[0]));
|
||||||
memcpy(this->cluts, cluts, clutsCount * sizeof(cluts[0]));
|
memcpy(this->cluts, cluts, clutsCount * sizeof(cluts[0]));
|
||||||
#ifdef TEX_SWIZZLE
|
#ifdef TEX_SWIZZLE
|
||||||
for (int i = 0; i < tilesCount; i++)
|
for (int i = 0; i < tilesCount; i++)
|
||||||
@@ -102,10 +102,12 @@ struct Texture : GAPI::Texture {
|
|||||||
}
|
}
|
||||||
|
|
||||||
virtual ~Texture() {
|
virtual ~Texture() {
|
||||||
|
#ifndef _OS_PSP
|
||||||
#ifdef SPLIT_BY_TILE
|
#ifdef SPLIT_BY_TILE
|
||||||
for (int i = 0; i < COUNT(tiles); i++)
|
for (int i = 0; i < COUNT(tiles); i++)
|
||||||
delete tiles[i];
|
delete tiles[i];
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
deinit();
|
deinit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user