mirror of
https://github.com/XProger/OpenLara.git
synced 2025-08-16 10:04:28 +02:00
platform and API defines, add GAPI namespace and basic Pipeline State Object structure
This commit is contained in:
168
src/cache.h
168
src/cache.h
@@ -12,28 +12,11 @@
|
||||
//#define WATER_USE_GRID
|
||||
#define UNDERWATER_COLOR "#define UNDERWATER_COLOR vec3(0.6, 0.9, 0.9)\n"
|
||||
|
||||
#ifndef FFP
|
||||
const char SHADER[] =
|
||||
#include "shaders/shader.glsl"
|
||||
;
|
||||
|
||||
const char WATER[] =
|
||||
#include "shaders/water.glsl"
|
||||
;
|
||||
|
||||
const char FILTER[] =
|
||||
#include "shaders/filter.glsl"
|
||||
;
|
||||
|
||||
const char GUI[] =
|
||||
#include "shaders/gui.glsl"
|
||||
;
|
||||
#endif
|
||||
|
||||
struct ShaderCache {
|
||||
enum Effect { FX_NONE = 0, FX_UNDERWATER = 1, FX_ALPHA_TEST = 2, FX_CLIP_PLANE = 4 };
|
||||
|
||||
Shader *shaders[Core::passMAX][Shader::MAX][(FX_UNDERWATER | FX_ALPHA_TEST | FX_CLIP_PLANE) + 1];
|
||||
PSO *pso[Core::passMAX][Shader::MAX][(FX_UNDERWATER | FX_ALPHA_TEST | FX_CLIP_PLANE) + 1][bmMAX];
|
||||
|
||||
ShaderCache() {
|
||||
memset(shaders, 0, sizeof(shaders));
|
||||
@@ -64,64 +47,77 @@ struct ShaderCache {
|
||||
delete shaders[pass][type][fx];
|
||||
}
|
||||
|
||||
void prepareCompose(int fx) {
|
||||
compile(Core::passCompose, Shader::MIRROR, fx | FX_NONE);
|
||||
compile(Core::passCompose, Shader::ROOM, fx | FX_NONE);
|
||||
compile(Core::passCompose, Shader::ROOM, fx | FX_ALPHA_TEST);
|
||||
compile(Core::passCompose, Shader::ROOM, fx | FX_UNDERWATER);
|
||||
compile(Core::passCompose, Shader::ROOM, fx | FX_UNDERWATER | FX_ALPHA_TEST);
|
||||
#define rsBase (RS_COLOR_WRITE | RS_DEPTH_TEST | RS_DEPTH_WRITE | RS_CULL_FRONT)
|
||||
#define rsBlend (RS_BLEND_ALPHA | RS_BLEND_ADD)
|
||||
#define rsFull (rsBase | rsBlend)
|
||||
#define rsShadow (RS_DEPTH_TEST | RS_DEPTH_WRITE | RS_CULL_BACK)
|
||||
|
||||
compile(Core::passCompose, Shader::ENTITY, fx | FX_NONE);
|
||||
compile(Core::passCompose, Shader::ENTITY, fx | FX_UNDERWATER);
|
||||
compile(Core::passCompose, Shader::ENTITY, fx | FX_UNDERWATER | FX_ALPHA_TEST);
|
||||
compile(Core::passCompose, Shader::ENTITY, fx | FX_ALPHA_TEST);
|
||||
compile(Core::passCompose, Shader::SPRITE, fx | FX_ALPHA_TEST);
|
||||
compile(Core::passCompose, Shader::SPRITE, fx | FX_UNDERWATER | FX_ALPHA_TEST);
|
||||
compile(Core::passCompose, Shader::FLASH, fx | FX_NONE);
|
||||
compile(Core::passCompose, Shader::FLASH, fx | FX_ALPHA_TEST);
|
||||
void prepareCompose(int fx) {
|
||||
compile(Core::passCompose, Shader::MIRROR, fx, rsBase);
|
||||
compile(Core::passCompose, Shader::ROOM, fx, rsFull);
|
||||
compile(Core::passCompose, Shader::ROOM, fx, rsFull | RS_DISCARD);
|
||||
compile(Core::passCompose, Shader::ROOM, fx | FX_UNDERWATER, rsFull);
|
||||
compile(Core::passCompose, Shader::ROOM, fx | FX_UNDERWATER, rsFull | RS_DISCARD);
|
||||
|
||||
compile(Core::passCompose, Shader::ENTITY, fx, rsFull);
|
||||
compile(Core::passCompose, Shader::ENTITY, fx | FX_UNDERWATER, rsFull);
|
||||
compile(Core::passCompose, Shader::ENTITY, fx | FX_UNDERWATER, rsFull | RS_DISCARD);
|
||||
compile(Core::passCompose, Shader::ENTITY, fx, rsFull | RS_DISCARD);
|
||||
compile(Core::passCompose, Shader::SPRITE, fx, rsFull | RS_DISCARD);
|
||||
compile(Core::passCompose, Shader::SPRITE, fx | FX_UNDERWATER, rsFull | RS_DISCARD);
|
||||
compile(Core::passCompose, Shader::FLASH, fx, rsFull | RS_BLEND_MULT);
|
||||
compile(Core::passCompose, Shader::FLASH, fx, rsFull | RS_BLEND_MULT | RS_DISCARD);
|
||||
}
|
||||
|
||||
void prepareAmbient(int fx) {
|
||||
compile(Core::passAmbient, Shader::ROOM, fx | FX_NONE);
|
||||
compile(Core::passAmbient, Shader::ROOM, fx | FX_ALPHA_TEST);
|
||||
compile(Core::passAmbient, Shader::ROOM, fx | FX_UNDERWATER);
|
||||
compile(Core::passAmbient, Shader::ROOM, fx | FX_UNDERWATER | FX_ALPHA_TEST);
|
||||
compile(Core::passAmbient, Shader::SPRITE, fx | FX_ALPHA_TEST);
|
||||
compile(Core::passAmbient, Shader::SPRITE, fx | FX_UNDERWATER | FX_ALPHA_TEST);
|
||||
compile(Core::passAmbient, Shader::ROOM, fx, rsFull);
|
||||
compile(Core::passAmbient, Shader::ROOM, fx, rsFull | RS_DISCARD);
|
||||
compile(Core::passAmbient, Shader::ROOM, fx | FX_UNDERWATER, rsFull);
|
||||
compile(Core::passAmbient, Shader::ROOM, fx | FX_UNDERWATER, rsFull | RS_DISCARD);
|
||||
compile(Core::passAmbient, Shader::SPRITE, fx, rsFull | RS_DISCARD);
|
||||
compile(Core::passAmbient, Shader::SPRITE, fx | FX_UNDERWATER, rsFull | RS_DISCARD);
|
||||
}
|
||||
|
||||
void prepareShadows(int fx) {
|
||||
compile(Core::passShadow, Shader::ENTITY, fx | FX_NONE);
|
||||
compile(Core::passShadow, Shader::ENTITY, fx | FX_ALPHA_TEST);
|
||||
compile(Core::passShadow, Shader::ENTITY, fx, rsShadow);
|
||||
compile(Core::passShadow, Shader::ENTITY, fx, rsShadow | RS_DISCARD);
|
||||
}
|
||||
|
||||
void prepareWater(int fx) {
|
||||
compile(Core::passWater, Shader::WATER_MASK, fx | FX_NONE);
|
||||
compile(Core::passWater, Shader::WATER_STEP, fx | FX_NONE);
|
||||
compile(Core::passWater, Shader::WATER_CAUSTICS, fx | FX_NONE);
|
||||
compile(Core::passWater, Shader::WATER_COMPOSE, fx | FX_NONE);
|
||||
compile(Core::passWater, Shader::WATER_DROP, fx | FX_NONE);
|
||||
compile(Core::passWater, Shader::WATER_MASK, fx, RS_COLOR_WRITE_A | RS_DEPTH_TEST);
|
||||
compile(Core::passWater, Shader::WATER_STEP, fx, RS_COLOR_WRITE);
|
||||
compile(Core::passWater, Shader::WATER_DROP, fx, RS_COLOR_WRITE);
|
||||
compile(Core::passWater, Shader::WATER_CAUSTICS, fx, RS_COLOR_WRITE);
|
||||
compile(Core::passWater, Shader::WATER_COMPOSE, fx, RS_COLOR_WRITE | RS_DEPTH_TEST);
|
||||
}
|
||||
|
||||
void prepareFilter(int fx) {
|
||||
compile(Core::passFilter, Shader::DEFAULT, fx | FX_NONE);
|
||||
compile(Core::passFilter, Shader::FILTER_DOWNSAMPLE, fx | FX_NONE);
|
||||
compile(Core::passFilter, Shader::FILTER_GRAYSCALE, fx | FX_NONE);
|
||||
compile(Core::passFilter, Shader::FILTER_BLUR, fx | FX_NONE);
|
||||
compile(Core::passFilter, Shader::FILTER_MIXER, fx | FX_NONE);
|
||||
compile(Core::passFilter, Shader::DEFAULT, fx, RS_COLOR_WRITE);
|
||||
compile(Core::passFilter, Shader::FILTER_DOWNSAMPLE, fx, RS_COLOR_WRITE);
|
||||
compile(Core::passFilter, Shader::FILTER_GRAYSCALE, fx, RS_COLOR_WRITE);
|
||||
compile(Core::passFilter, Shader::FILTER_BLUR, fx, RS_COLOR_WRITE);
|
||||
compile(Core::passFilter, Shader::FILTER_MIXER, fx, RS_COLOR_WRITE);
|
||||
}
|
||||
|
||||
void prepareGUI(int fx) {
|
||||
compile(Core::passGUI, Shader::DEFAULT, fx | FX_NONE);
|
||||
compile(Core::passGUI, Shader::DEFAULT, fx, RS_COLOR_WRITE | RS_BLEND_ALPHA);
|
||||
}
|
||||
|
||||
Shader* compile(Core::Pass pass, Shader::Type type, int fx) {
|
||||
#undef rsBase
|
||||
#undef rsBlend
|
||||
#undef rsFull
|
||||
#undef rsShadow
|
||||
|
||||
Shader* compile(Core::Pass pass, Shader::Type type, int fx, uint32 rs) {
|
||||
if (rs & RS_DISCARD)
|
||||
fx |= FX_ALPHA_TEST;
|
||||
|
||||
#ifndef FFP
|
||||
char def[1024], ext[255];
|
||||
ext[0] = 0;
|
||||
if (Core::settings.detail.shadows) {
|
||||
if (Core::support.shadowSampler) {
|
||||
#ifdef MOBILE
|
||||
#ifdef _GAPI_GLES
|
||||
strcat(ext, "#extension GL_EXT_shadow_samplers : require\n");
|
||||
#endif
|
||||
strcat(ext, "#define SHADOW_SAMPLER\n");
|
||||
@@ -142,7 +138,7 @@ struct ShaderCache {
|
||||
case Core::passAmbient : {
|
||||
static const char *typeNames[] = { "SPRITE", "FLASH", "ROOM", "ENTITY", "MIRROR" };
|
||||
|
||||
src = SHADER;
|
||||
src = GAPI::SHADER_BASE;
|
||||
typ = typeNames[type];
|
||||
sprintf(def, "%s#define PASS_%s\n#define TYPE_%s\n#define MAX_LIGHTS %d\n#define MAX_CONTACTS %d\n#define WATER_FOG_DIST (1.0/%d.0)\n", ext, passNames[pass], typ, MAX_LIGHTS, MAX_CONTACTS, WATER_FOG_DIST);
|
||||
#ifdef MERGE_SPRITES
|
||||
@@ -177,7 +173,7 @@ struct ShaderCache {
|
||||
}
|
||||
case Core::passWater : {
|
||||
static const char *typeNames[] = { "DROP", "STEP", "CAUSTICS", "MASK", "COMPOSE" };
|
||||
src = WATER;
|
||||
src = GAPI::SHADER_WATER;
|
||||
typ = typeNames[type];
|
||||
sprintf(def, "%s#define PASS_%s\n#define WATER_%s\n#define WATER_FOG_DIST (1.0/%d.0)\n" UNDERWATER_COLOR, ext, passNames[pass], typ, WATER_FOG_DIST);
|
||||
#ifdef WATER_USE_GRID
|
||||
@@ -187,14 +183,14 @@ struct ShaderCache {
|
||||
}
|
||||
case Core::passFilter : {
|
||||
static const char *typeNames[] = { "DEFAULT", "DOWNSAMPLE", "GRAYSCALE", "BLUR", "MIXER", "EQUIRECTANGULAR" };
|
||||
src = FILTER;
|
||||
src = GAPI::SHADER_FILTER;
|
||||
typ = typeNames[type];
|
||||
sprintf(def, "%s#define PASS_%s\n#define FILTER_%s\n", ext, passNames[pass], typ);
|
||||
break;
|
||||
}
|
||||
case Core::passGUI : {
|
||||
static const char *typeNames[] = { "DEFAULT" };
|
||||
src = GUI;
|
||||
src = GAPI::SHADER_GUI;
|
||||
typ = typeNames[type];
|
||||
sprintf(def, "%s#define PASS_%s\n", ext, passNames[pass]);
|
||||
break;
|
||||
@@ -208,25 +204,20 @@ struct ShaderCache {
|
||||
#endif
|
||||
}
|
||||
|
||||
void bind(Core::Pass pass, Shader::Type type, int fx, IGame *game) {
|
||||
Core::pass = pass;
|
||||
#ifndef FFP
|
||||
Shader *getShader(Core::Pass pass, Shader::Type type, int fx) {
|
||||
Shader *shader = shaders[pass][type][fx];
|
||||
if (!shader)
|
||||
shader = compile(pass, type, fx);
|
||||
ASSERT(shader != NULL);
|
||||
shader->bind();
|
||||
// TODO: bindable uniform block
|
||||
shader->setParam(uViewProj, Core::mViewProj);
|
||||
shader->setParam(uLightProj, Core::mLightProj[0], Core::settings.detail.shadows > Core::Settings::Quality::MEDIUM ? SHADOW_OBJ_MAX : 1);
|
||||
shader->setParam(uViewPos, Core::viewPos);
|
||||
shader->setParam(uParam, Core::params);
|
||||
shader->setParam(uFogParams, Core::fogParams);
|
||||
#else
|
||||
Core::setAlphaTest((fx & FX_ALPHA_TEST) != 0);
|
||||
#endif
|
||||
return shader;
|
||||
}
|
||||
|
||||
void bind(Core::Pass pass, Shader::Type type, int fx) {
|
||||
Core::pass = pass;
|
||||
|
||||
Shader *shader = getShader(pass, type, fx);
|
||||
|
||||
shader->bind();
|
||||
Core::setAlphaTest((fx & FX_ALPHA_TEST) != 0);
|
||||
}
|
||||
};
|
||||
|
||||
struct AmbientCache {
|
||||
@@ -266,7 +257,7 @@ struct AmbientCache {
|
||||
// init downsample textures
|
||||
for (int j = 0; j < 6; j++)
|
||||
for (int i = 0; i < 4; i++)
|
||||
textures[j * 4 + i] = new Texture(64 >> (i << 1), 64 >> (i << 1), Texture::RGBA, false);
|
||||
textures[j * 4 + i] = new Texture(64 >> (i << 1), 64 >> (i << 1), FMT_RGBA, false);
|
||||
}
|
||||
|
||||
~AmbientCache() {
|
||||
@@ -472,7 +463,7 @@ struct WaterCache {
|
||||
|
||||
m[(x - minX) + w * (z - minZ)] = hasWater ? 0xF800 : 0;
|
||||
}
|
||||
mask = new Texture(w, h, Texture::RGB16, Texture::NEAREST, m);
|
||||
mask = new Texture(w, h, FMT_RGB16, Texture::NEAREST, m);
|
||||
delete[] m;
|
||||
|
||||
size = vec3(float((maxX - minX) * 512), 1.0f, float((maxZ - minZ) * 512)); // half size
|
||||
@@ -480,11 +471,11 @@ struct WaterCache {
|
||||
|
||||
int *mf = new int[4 * w * 64 * h * 64];
|
||||
memset(mf, 0, sizeof(int) * 4 * w * 64 * h * 64);
|
||||
data[0] = new Texture(w * 64, h * 64, Texture::RGBA_HALF, 0, mf);
|
||||
data[1] = new Texture(w * 64, h * 64, Texture::RGBA_HALF);
|
||||
data[0] = new Texture(w * 64, h * 64, FMT_RGBA_HALF, 0, mf);
|
||||
data[1] = new Texture(w * 64, h * 64, FMT_RGBA_HALF);
|
||||
delete[] mf;
|
||||
|
||||
caustics = Core::settings.detail.water > Core::Settings::MEDIUM ? new Texture(512, 512, Texture::RGBA) : NULL;
|
||||
caustics = Core::settings.detail.water > Core::Settings::MEDIUM ? new Texture(512, 512, FMT_RGBA) : NULL;
|
||||
#ifdef BLUR_CAUSTICS
|
||||
caustics_tmp = Core::settings.detail.water > Core::Settings::MEDIUM ? new Texture(512, 512, Texture::RGBA) : NULL;
|
||||
#endif
|
||||
@@ -516,7 +507,7 @@ struct WaterCache {
|
||||
} drops[MAX_DROPS];
|
||||
|
||||
WaterCache(IGame *game) : game(game), level(game->getLevel()), refract(NULL), count(0), dropCount(0) {
|
||||
reflect = new Texture(512, 512, Texture::RGB16);
|
||||
reflect = new Texture(512, 512, FMT_RGBA);
|
||||
}
|
||||
|
||||
~WaterCache() {
|
||||
@@ -710,7 +701,7 @@ struct WaterCache {
|
||||
|
||||
Core::setColorWrite(false, false, false, true);
|
||||
Core::setDepthWrite(false);
|
||||
Core::setCulling(cfNone);
|
||||
Core::setCullMode(cmNone);
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
Item &item = items[i];
|
||||
@@ -723,7 +714,7 @@ struct WaterCache {
|
||||
|
||||
Core::setColorWrite(true, true, true, true);
|
||||
Core::setDepthWrite(true);
|
||||
Core::setCulling(cfFront);
|
||||
Core::setCullMode(cmFront);
|
||||
}
|
||||
|
||||
void getTargetSize(int &w, int &h) {
|
||||
@@ -744,7 +735,12 @@ struct WaterCache {
|
||||
// get refraction texture
|
||||
if (!refract || w != refract->origWidth || h != refract->origHeight) {
|
||||
delete refract;
|
||||
refract = new Texture(w, h, Texture::RGBA);
|
||||
refract = new Texture(w, h, FMT_RGBA);
|
||||
|
||||
Core::setTarget(refract, RT_CLEAR_COLOR | RT_STORE_COLOR);
|
||||
Core::validateRenderState();
|
||||
Core::setTarget(NULL, RT_STORE_COLOR);
|
||||
Core::validateRenderState();
|
||||
}
|
||||
Core::copyTarget(refract, 0, 0, int(Core::viewportDef.x), int(Core::viewportDef.y), w, h); // copy framebuffer into refraction texture
|
||||
}
|
||||
@@ -753,7 +749,7 @@ struct WaterCache {
|
||||
PROFILE_MARKER("WATER_SIMULATE");
|
||||
// simulate water
|
||||
Core::setDepthTest(false);
|
||||
Core::setBlending(bmNone);
|
||||
Core::setBlendMode(bmNone);
|
||||
for (int i = 0; i < count; i++) {
|
||||
Item &item = items[i];
|
||||
if (!item.visible) continue;
|
||||
@@ -865,8 +861,8 @@ struct WaterCache {
|
||||
reflect->bind(sReflect);
|
||||
item.mask->bind(sMask);
|
||||
item.data[0]->bind(sNormal);
|
||||
Core::setCulling(cfNone);
|
||||
Core::setBlending(bmAlpha);
|
||||
Core::setCullMode(cmNone);
|
||||
Core::setBlendMode(bmAlpha);
|
||||
#ifdef WATER_USE_GRID
|
||||
vec3 rPosScale[2] = { item.pos, item.size * vec3(1.0f / PLANE_DETAIL, 512.0f, 1.0f / PLANE_DETAIL) };
|
||||
Core::active.shader->setParam(uPosScale, rPosScale[0], 2);
|
||||
@@ -875,8 +871,8 @@ struct WaterCache {
|
||||
Core::active.shader->setParam(uPosScale, item.pos, 2);
|
||||
game->getMesh()->renderQuad();
|
||||
#endif
|
||||
Core::setCulling(cfFront);
|
||||
Core::setBlending(bmNone);
|
||||
Core::setCullMode(cmFront);
|
||||
Core::setBlendMode(bmNone);
|
||||
}
|
||||
dropCount = 0;
|
||||
}
|
||||
|
@@ -531,7 +531,7 @@ struct Camera : ICamera {
|
||||
|
||||
fov = firstPerson ? 90.0f : 65.0f;
|
||||
znear = firstPerson ? 8.0f : 32.0f;
|
||||
#ifdef _PSP
|
||||
#ifdef _OS_PSP
|
||||
znear = 256.0f;
|
||||
#endif
|
||||
zfar = 45.0f * 1024.0f;
|
||||
|
1001
src/core.h
1001
src/core.h
File diff suppressed because it is too large
Load Diff
18
src/debug.h
18
src/debug.h
@@ -11,7 +11,7 @@ namespace Debug {
|
||||
static GLuint font;
|
||||
|
||||
void init() {
|
||||
#ifdef WIN32
|
||||
#ifdef _OS_WINDOWS
|
||||
font = glGenLists(256);
|
||||
HDC hdc = GetDC(0);
|
||||
HFONT hfont = CreateFontA(-MulDiv(10, GetDeviceCaps(hdc, LOGPIXELSY), 72), 0,
|
||||
@@ -21,7 +21,7 @@ namespace Debug {
|
||||
SelectObject(hdc, hfont);
|
||||
wglUseFontBitmaps(hdc, 0, 256, font);
|
||||
DeleteObject(hfont);
|
||||
#elif LINUX
|
||||
#elif _OS_LINUX
|
||||
XFontStruct *fontInfo;
|
||||
Font id;
|
||||
unsigned int first, last;
|
||||
@@ -182,7 +182,7 @@ namespace Debug {
|
||||
glOrtho(0, Core::width, Core::height, 0, 0, 1);
|
||||
|
||||
Core::setDepthTest(false);
|
||||
Core::setCulling(cfNone);
|
||||
Core::setCullMode(cmNone);
|
||||
Core::validateRenderState();
|
||||
|
||||
glColor4fv((GLfloat*)&color);
|
||||
@@ -190,7 +190,7 @@ namespace Debug {
|
||||
glListBase(font);
|
||||
glCallLists(strlen(str), GL_UNSIGNED_BYTE, str);
|
||||
Core::setDepthTest(true);
|
||||
Core::setCulling(cfFront);
|
||||
Core::setCullMode(cmFront);
|
||||
|
||||
glPopMatrix();
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
@@ -400,7 +400,7 @@ namespace Debug {
|
||||
sprintf(str, "%d", boxIndex);
|
||||
Draw::text(vec3((b.maxX + b.minX) * 0.5f, b.floor, (b.maxZ + b.minZ) * 0.5f), vec4(0, 1, 0, 1), str);
|
||||
glColor4f(0.0f, 1.0f, 0.0f, 0.25f);
|
||||
Core::setBlending(bmAlpha);
|
||||
Core::setBlendMode(bmAlpha);
|
||||
debugBox(b);
|
||||
|
||||
TR::Overlap *o = &level.overlaps[level.boxes[boxIndex].overlap.index];
|
||||
@@ -409,7 +409,7 @@ namespace Debug {
|
||||
sprintf(str, "%d", o->boxIndex);
|
||||
Draw::text(vec3((b.maxX + b.minX) * 0.5f, b.floor, (b.maxZ + b.minZ) * 0.5f), vec4(0, 0, 1, 1), str);
|
||||
glColor4f(0.0f, 0.0f, 1.0f, 0.25f);
|
||||
Core::setBlending(bmAlpha);
|
||||
Core::setBlendMode(bmAlpha);
|
||||
debugBox(b);
|
||||
} while (!(o++)->end);
|
||||
}
|
||||
@@ -418,7 +418,7 @@ namespace Debug {
|
||||
if (!boxes) return;
|
||||
|
||||
glColor4f(0.0f, 1.0f, 0.0f, 0.25f);
|
||||
Core::setBlending(bmAlpha);
|
||||
Core::setBlendMode(bmAlpha);
|
||||
Core::setDepthTest(false);
|
||||
Core::validateRenderState();
|
||||
for (int i = 0; i < count; i++)
|
||||
@@ -455,7 +455,7 @@ namespace Debug {
|
||||
}
|
||||
|
||||
void portals(const TR::Level &level) {
|
||||
Core::setBlending(bmAdd);
|
||||
Core::setBlendMode(bmAdd);
|
||||
glColor3f(0, 0.25f, 0.25f);
|
||||
glDepthMask(GL_FALSE);
|
||||
|
||||
@@ -473,7 +473,7 @@ namespace Debug {
|
||||
glEnd();
|
||||
|
||||
glDepthMask(GL_TRUE);
|
||||
Core::setBlending(bmNone);
|
||||
Core::setBlendMode(bmNone);
|
||||
}
|
||||
|
||||
void entities(const TR::Level &level) {
|
||||
|
@@ -39,12 +39,14 @@ void loadSettings(Stream *stream, void *userData) {
|
||||
delete stream;
|
||||
}
|
||||
|
||||
#ifdef ANDROID
|
||||
#ifdef _OS_ANDROID
|
||||
if (Core::settings.detail.stereo == Core::Settings::STEREO_VR)
|
||||
osToggleVR(true);
|
||||
#endif
|
||||
|
||||
Core::settings.version = SETTINGS_VERSION;
|
||||
Core::setVSync(Core::settings.detail.vsync != 0);
|
||||
|
||||
shaderCache = new ShaderCache();
|
||||
Game::startLevel((Stream*)userData);
|
||||
UI::init(Game::level);
|
||||
|
@@ -555,7 +555,7 @@ namespace TR {
|
||||
if (version & VER_TR3) strcat(dst, "3/");
|
||||
strcat(dst, LEVEL_INFO[id].name);
|
||||
|
||||
#ifdef __EMSCRIPTEN__
|
||||
#ifdef _OS_WEB
|
||||
strcat(dst, ".PSX");
|
||||
#else
|
||||
switch (version) {
|
||||
@@ -692,7 +692,7 @@ namespace TR {
|
||||
break;
|
||||
case VER_TR3_PC :
|
||||
case VER_TR3_PSX :
|
||||
#ifndef __EMSCRIPTEN__
|
||||
#ifndef _OS_WEB
|
||||
callback(Sound::openCDAudioWAD("audio/3/cdaudio.wad", track), userData);
|
||||
return;
|
||||
#else
|
||||
|
555
src/gapi_gl.h
Normal file
555
src/gapi_gl.h
Normal file
@@ -0,0 +1,555 @@
|
||||
#ifndef H_GAPI_GL
|
||||
#define H_GAPI_GL
|
||||
|
||||
#include "core.h"
|
||||
|
||||
#if defined(_OS_WINDOWS) || (defined(_OS_LINUX) && !defined(_OS_RPI)) || defined(_OS_ANDROID)
|
||||
|
||||
#ifdef _OS_ANDROID
|
||||
#define GetProc(x) dlsym(libGL, x);
|
||||
#else
|
||||
void* GetProc(const char *name) {
|
||||
#ifdef _OS_WINDOWS
|
||||
return (void*)wglGetProcAddress(name);
|
||||
#elif _OS_LINUX
|
||||
return (void*)glXGetProcAddress((GLubyte*)name);
|
||||
#elif _OS_RPI
|
||||
return (void*)eglGetProcAddress(name);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#define GetProcOGL(x) x=(decltype(x))GetProc(#x);
|
||||
|
||||
// Texture
|
||||
#ifdef _OS_WINDOWS
|
||||
PFNGLACTIVETEXTUREPROC glActiveTexture;
|
||||
#endif
|
||||
|
||||
// VSync
|
||||
#ifdef _OS_WINDOWS
|
||||
typedef BOOL (WINAPI * PFNWGLSWAPINTERVALEXTPROC) (int interval);
|
||||
PFNWGLSWAPINTERVALEXTPROC wglSwapIntervalEXT;
|
||||
#elif _OS_LINUX
|
||||
typedef int (*PFNGLXSWAPINTERVALSGIPROC) (int interval);
|
||||
PFNGLXSWAPINTERVALSGIPROC glXSwapIntervalSGI;
|
||||
#endif
|
||||
|
||||
#if defined(_OS_WINDOWS) || defined(_OS_LINUX)
|
||||
PFNGLGENERATEMIPMAPPROC glGenerateMipmap;
|
||||
// Profiling
|
||||
#ifdef PROFILE
|
||||
PFNGLOBJECTLABELPROC glObjectLabel;
|
||||
PFNGLPUSHDEBUGGROUPPROC glPushDebugGroup;
|
||||
PFNGLPOPDEBUGGROUPPROC glPopDebugGroup;
|
||||
PFNGLGENQUERIESPROC glGenQueries;
|
||||
PFNGLDELETEQUERIESPROC glDeleteQueries;
|
||||
PFNGLGETQUERYOBJECTIVPROC glGetQueryObjectiv;
|
||||
PFNGLBEGINQUERYPROC glBeginQuery;
|
||||
PFNGLENDQUERYPROC glEndQuery;
|
||||
#endif
|
||||
// Shader
|
||||
PFNGLCREATEPROGRAMPROC glCreateProgram;
|
||||
PFNGLDELETEPROGRAMPROC glDeleteProgram;
|
||||
PFNGLLINKPROGRAMPROC glLinkProgram;
|
||||
PFNGLUSEPROGRAMPROC glUseProgram;
|
||||
PFNGLGETPROGRAMINFOLOGPROC glGetProgramInfoLog;
|
||||
PFNGLCREATESHADERPROC glCreateShader;
|
||||
PFNGLDELETESHADERPROC glDeleteShader;
|
||||
PFNGLSHADERSOURCEPROC glShaderSource;
|
||||
PFNGLATTACHSHADERPROC glAttachShader;
|
||||
PFNGLCOMPILESHADERPROC glCompileShader;
|
||||
PFNGLGETSHADERINFOLOGPROC glGetShaderInfoLog;
|
||||
PFNGLGETUNIFORMLOCATIONPROC glGetUniformLocation;
|
||||
PFNGLUNIFORM1IVPROC glUniform1iv;
|
||||
PFNGLUNIFORM1FVPROC glUniform1fv;
|
||||
PFNGLUNIFORM2FVPROC glUniform2fv;
|
||||
PFNGLUNIFORM3FVPROC glUniform3fv;
|
||||
PFNGLUNIFORM4FVPROC glUniform4fv;
|
||||
PFNGLUNIFORMMATRIX4FVPROC glUniformMatrix4fv;
|
||||
PFNGLBINDATTRIBLOCATIONPROC glBindAttribLocation;
|
||||
PFNGLENABLEVERTEXATTRIBARRAYPROC glEnableVertexAttribArray;
|
||||
PFNGLDISABLEVERTEXATTRIBARRAYPROC glDisableVertexAttribArray;
|
||||
PFNGLVERTEXATTRIBPOINTERPROC glVertexAttribPointer;
|
||||
PFNGLGETPROGRAMIVPROC glGetProgramiv;
|
||||
// Render to texture
|
||||
PFNGLGENFRAMEBUFFERSPROC glGenFramebuffers;
|
||||
PFNGLBINDFRAMEBUFFERPROC glBindFramebuffer;
|
||||
PFNGLGENRENDERBUFFERSPROC glGenRenderbuffers;
|
||||
PFNGLBINDRENDERBUFFERPROC glBindRenderbuffer;
|
||||
PFNGLFRAMEBUFFERTEXTURE2DPROC glFramebufferTexture2D;
|
||||
PFNGLFRAMEBUFFERRENDERBUFFERPROC glFramebufferRenderbuffer;
|
||||
PFNGLRENDERBUFFERSTORAGEPROC glRenderbufferStorage;
|
||||
PFNGLCHECKFRAMEBUFFERSTATUSPROC glCheckFramebufferStatus;
|
||||
PFNGLDELETEFRAMEBUFFERSPROC glDeleteFramebuffers;
|
||||
PFNGLDELETERENDERBUFFERSPROC glDeleteRenderbuffers;
|
||||
// Mesh
|
||||
PFNGLGENBUFFERSARBPROC glGenBuffers;
|
||||
PFNGLDELETEBUFFERSARBPROC glDeleteBuffers;
|
||||
PFNGLBINDBUFFERARBPROC glBindBuffer;
|
||||
PFNGLBUFFERDATAARBPROC glBufferData;
|
||||
PFNGLBUFFERSUBDATAARBPROC glBufferSubData;
|
||||
#endif
|
||||
|
||||
PFNGLGENVERTEXARRAYSPROC glGenVertexArrays;
|
||||
PFNGLDELETEVERTEXARRAYSPROC glDeleteVertexArrays;
|
||||
PFNGLBINDVERTEXARRAYPROC glBindVertexArray;
|
||||
PFNGLGETPROGRAMBINARYPROC glGetProgramBinary;
|
||||
PFNGLPROGRAMBINARYPROC glProgramBinary;
|
||||
#endif
|
||||
|
||||
#if defined(_GAPI_GLES)
|
||||
PFNGLDISCARDFRAMEBUFFEREXTPROC glDiscardFramebufferEXT;
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef PROFILE
|
||||
//#define USE_CV_MARKERS
|
||||
|
||||
#ifdef USE_CV_MARKERS
|
||||
#include <libs/cvmarkers/cvmarkersobj.h>
|
||||
using namespace Concurrency::diagnostic;
|
||||
|
||||
marker_series *series[256];
|
||||
int seriesIndex;
|
||||
#endif
|
||||
|
||||
struct Marker {
|
||||
#ifdef USE_CV_MARKERS
|
||||
span *cvSpan;
|
||||
#endif
|
||||
|
||||
Marker(const char *title) {
|
||||
if (Core::support.profMarker) glPushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 1, -1, title);
|
||||
#ifdef USE_CV_MARKERS
|
||||
marker_series *&s = series[seriesIndex];
|
||||
if (s == NULL) {
|
||||
char seriesTitle[64];
|
||||
sprintf(seriesTitle, "events - %d", seriesIndex);
|
||||
s = new marker_series(seriesTitle);
|
||||
}
|
||||
cvSpan = new span(*s, normal_importance, _T(title));
|
||||
seriesIndex++;
|
||||
#endif
|
||||
}
|
||||
|
||||
~Marker() {
|
||||
if (Core::support.profMarker) glPopDebugGroup();
|
||||
#ifdef USE_CV_MARKERS
|
||||
delete cvSpan;
|
||||
seriesIndex--;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void setLabel(GLenum id, GLuint name, const char *label) {
|
||||
if (Core::support.profMarker) glObjectLabel(id, name, -1, label);
|
||||
}
|
||||
};
|
||||
|
||||
struct Timing {
|
||||
GLuint ID;
|
||||
int &result;
|
||||
|
||||
Timing(int &result) : result(result) {
|
||||
if (!Core::support.profTiming) return;
|
||||
glGenQueries(1, &ID);
|
||||
glBeginQuery(GL_TIME_ELAPSED, ID);
|
||||
}
|
||||
|
||||
~Timing() {
|
||||
if (!Core::support.profTiming) return;
|
||||
glEndQuery(GL_TIME_ELAPSED);
|
||||
glGetQueryObjectiv(ID, GL_QUERY_RESULT, (GLint*)&result);
|
||||
glDeleteQueries(1, &ID);
|
||||
}
|
||||
};
|
||||
|
||||
#define PROFILE_MARKER(title) Marker marker(title)
|
||||
#define PROFILE_LABEL(id, name, label) Marker::setLabel(GL_##id, name, label)
|
||||
#define PROFILE_TIMING(result) Timing timing(result)
|
||||
#else
|
||||
#define PROFILE_MARKER(title)
|
||||
#define PROFILE_LABEL(id, name, label)
|
||||
#define PROFILE_TIMING(time)
|
||||
#endif
|
||||
|
||||
|
||||
namespace GAPI {
|
||||
|
||||
#ifndef FFP
|
||||
const char SHADER_BASE[] =
|
||||
#include "shaders/shader.glsl"
|
||||
;
|
||||
|
||||
const char SHADER_WATER[] =
|
||||
#include "shaders/water.glsl"
|
||||
;
|
||||
|
||||
const char SHADER_FILTER[] =
|
||||
#include "shaders/filter.glsl"
|
||||
;
|
||||
|
||||
const char SHADER_GUI[] =
|
||||
#include "shaders/gui.glsl"
|
||||
;
|
||||
#endif
|
||||
|
||||
using namespace Core;
|
||||
|
||||
typedef ::Vertex Vertex;
|
||||
|
||||
int cullMode, blendMode;
|
||||
|
||||
bool extSupport(const char *str, const char *ext) {
|
||||
return strstr(str, ext) != NULL;
|
||||
}
|
||||
|
||||
void init() {
|
||||
#ifdef _OS_ANDROID
|
||||
void *libGL = dlopen("libGLESv2.so", RTLD_LAZY);
|
||||
#endif
|
||||
|
||||
#if defined(_OS_WINDOWS) || (defined(_OS_LINUX) && !defined(_OS_RPI)) || defined(_OS_ANDROID)
|
||||
#ifdef _OS_WINDOWS
|
||||
GetProcOGL(glActiveTexture);
|
||||
#endif
|
||||
|
||||
#ifdef _OS_WINDOWS
|
||||
GetProcOGL(wglSwapIntervalEXT);
|
||||
#elif _OS_LINUX
|
||||
GetProcOGL(glXSwapIntervalSGI);
|
||||
#endif
|
||||
|
||||
#if defined(_OS_WINDOWS) || defined(_OS_LINUX)
|
||||
GetProcOGL(glGenerateMipmap);
|
||||
|
||||
#ifdef PROFILE
|
||||
GetProcOGL(glObjectLabel);
|
||||
GetProcOGL(glPushDebugGroup);
|
||||
GetProcOGL(glPopDebugGroup);
|
||||
GetProcOGL(glGenQueries);
|
||||
GetProcOGL(glDeleteQueries);
|
||||
GetProcOGL(glGetQueryObjectiv);
|
||||
GetProcOGL(glBeginQuery);
|
||||
GetProcOGL(glEndQuery);
|
||||
#endif
|
||||
|
||||
GetProcOGL(glCreateProgram);
|
||||
GetProcOGL(glDeleteProgram);
|
||||
GetProcOGL(glLinkProgram);
|
||||
GetProcOGL(glUseProgram);
|
||||
GetProcOGL(glGetProgramInfoLog);
|
||||
GetProcOGL(glCreateShader);
|
||||
GetProcOGL(glDeleteShader);
|
||||
GetProcOGL(glShaderSource);
|
||||
GetProcOGL(glAttachShader);
|
||||
GetProcOGL(glCompileShader);
|
||||
GetProcOGL(glGetShaderInfoLog);
|
||||
GetProcOGL(glGetUniformLocation);
|
||||
GetProcOGL(glUniform1iv);
|
||||
GetProcOGL(glUniform1fv);
|
||||
GetProcOGL(glUniform2fv);
|
||||
GetProcOGL(glUniform3fv);
|
||||
GetProcOGL(glUniform4fv);
|
||||
GetProcOGL(glUniformMatrix4fv);
|
||||
GetProcOGL(glBindAttribLocation);
|
||||
GetProcOGL(glEnableVertexAttribArray);
|
||||
GetProcOGL(glDisableVertexAttribArray);
|
||||
GetProcOGL(glVertexAttribPointer);
|
||||
GetProcOGL(glGetProgramiv);
|
||||
|
||||
GetProcOGL(glGenFramebuffers);
|
||||
GetProcOGL(glBindFramebuffer);
|
||||
GetProcOGL(glGenRenderbuffers);
|
||||
GetProcOGL(glBindRenderbuffer);
|
||||
GetProcOGL(glFramebufferTexture2D);
|
||||
GetProcOGL(glFramebufferRenderbuffer);
|
||||
GetProcOGL(glRenderbufferStorage);
|
||||
GetProcOGL(glCheckFramebufferStatus);
|
||||
GetProcOGL(glDeleteFramebuffers);
|
||||
GetProcOGL(glDeleteRenderbuffers);
|
||||
|
||||
GetProcOGL(glGenBuffers);
|
||||
GetProcOGL(glDeleteBuffers);
|
||||
GetProcOGL(glBindBuffer);
|
||||
GetProcOGL(glBufferData);
|
||||
GetProcOGL(glBufferSubData);
|
||||
#endif
|
||||
|
||||
#ifdef _GAPI_GLES
|
||||
GetProcOGL(glDiscardFramebufferEXT);
|
||||
#endif
|
||||
|
||||
GetProcOGL(glGenVertexArrays);
|
||||
GetProcOGL(glDeleteVertexArrays);
|
||||
GetProcOGL(glBindVertexArray);
|
||||
GetProcOGL(glGetProgramBinary);
|
||||
GetProcOGL(glProgramBinary);
|
||||
#endif
|
||||
|
||||
LOG("Vendor : %s\n", (char*)glGetString(GL_VENDOR));
|
||||
LOG("Renderer : %s\n", (char*)glGetString(GL_RENDERER));
|
||||
LOG("Version : %s\n", (char*)glGetString(GL_VERSION));
|
||||
|
||||
char *ext = (char*)glGetString(GL_EXTENSIONS);
|
||||
/*
|
||||
if (ext != NULL) {
|
||||
char buf[255];
|
||||
int len = strlen(ext);
|
||||
int start = 0;
|
||||
for (int i = 0; i < len; i++)
|
||||
if (ext[i] == ' ' || (i == len - 1)) {
|
||||
memcpy(buf, &ext[start], i - start);
|
||||
buf[i - start] = 0;
|
||||
LOG("%s\n", buf);
|
||||
start = i + 1;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
#ifdef FFP
|
||||
support.maxAniso = 1;
|
||||
support.maxVectors = 0;
|
||||
support.shaderBinary = false;
|
||||
support.VAO = false;
|
||||
support.depthTexture = false;
|
||||
support.shadowSampler = false;
|
||||
support.discardFrame = false;
|
||||
support.texNPOT = false;
|
||||
support.texRG = false;
|
||||
support.texBorder = false;
|
||||
support.maxAniso = false;
|
||||
support.colorFloat = false;
|
||||
support.colorHalf = false;
|
||||
support.texFloatLinear = false;
|
||||
support.texFloat = false;
|
||||
support.texHalfLinear = false;
|
||||
support.texHalf = false;
|
||||
#else
|
||||
support.shaderBinary = extSupport(ext, "_program_binary");
|
||||
support.VAO = extSupport(ext, "_vertex_array_object");
|
||||
support.depthTexture = extSupport(ext, "_depth_texture");
|
||||
support.shadowSampler = support.depthTexture && (extSupport(ext, "_shadow_samplers") || extSupport(ext, "GL_ARB_shadow"));
|
||||
support.discardFrame = extSupport(ext, "_discard_framebuffer");
|
||||
support.texNPOT = extSupport(ext, "_texture_npot") || extSupport(ext, "_texture_non_power_of_two");
|
||||
support.texRG = extSupport(ext, "_texture_rg "); // hope that isn't last extension in string ;)
|
||||
support.texBorder = extSupport(ext, "_texture_border_clamp");
|
||||
support.maxAniso = extSupport(ext, "_texture_filter_anisotropic");
|
||||
support.colorFloat = extSupport(ext, "_color_buffer_float");
|
||||
support.colorHalf = extSupport(ext, "_color_buffer_half_float") || extSupport(ext, "GL_ARB_half_float_pixel");
|
||||
support.texFloatLinear = support.colorFloat || extSupport(ext, "GL_ARB_texture_float") || extSupport(ext, "_texture_float_linear");
|
||||
support.texFloat = support.texFloatLinear || extSupport(ext, "_texture_float");
|
||||
support.texHalfLinear = support.colorHalf || extSupport(ext, "GL_ARB_texture_float") || extSupport(ext, "_texture_half_float_linear") || extSupport(ext, "_color_buffer_half_float");
|
||||
support.texHalf = support.texHalfLinear || extSupport(ext, "_texture_half_float");
|
||||
|
||||
#ifdef PROFILE
|
||||
support.profMarker = extSupport(ext, "_KHR_debug");
|
||||
support.profTiming = extSupport(ext, "_timer_query");
|
||||
#endif
|
||||
|
||||
if (support.maxAniso)
|
||||
glGetIntegerv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &support.maxAniso);
|
||||
#ifdef _GAPI_GLES
|
||||
glGetIntegerv(GL_MAX_VARYING_VECTORS, &support.maxVectors);
|
||||
#else
|
||||
support.maxVectors = 16;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
glEnable(GL_SCISSOR_TEST);
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||
|
||||
glGetIntegerv(GL_FRAMEBUFFER_BINDING, (GLint*)&defaultFBO);
|
||||
glGenFramebuffers(1, &FBO);
|
||||
glDepthFunc(GL_LEQUAL);
|
||||
|
||||
#ifdef FFP
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
glEnableClientState(GL_COLOR_ARRAY);
|
||||
glEnableClientState(GL_NORMAL_ARRAY);
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
|
||||
glAlphaFunc(GL_GREATER, 0.5f);
|
||||
|
||||
glMatrixMode(GL_TEXTURE);
|
||||
glLoadIdentity();
|
||||
glScalef(1.0f / 32767.0f, 1.0f / 32767.0f, 1.0f / 32767.0f);
|
||||
|
||||
glClearColor(0, 0, 0, 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
void deinit() {
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
glDeleteFramebuffers(1, &FBO);
|
||||
|
||||
glBindRenderbuffer(GL_RENDERBUFFER, 0);
|
||||
for (int b = 0; b < 2; b++)
|
||||
for (int i = 0; i < rtCache[b].count; i++)
|
||||
glDeleteRenderbuffers(1, &rtCache[b].items[i].ID);
|
||||
}
|
||||
|
||||
void resetState() {
|
||||
if (glBindVertexArray)
|
||||
glBindVertexArray(0);
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
glUseProgram(0);
|
||||
}
|
||||
|
||||
void discardTarget(bool color, bool depth) {
|
||||
#ifdef _GAPI_GLES
|
||||
if (Core::support.discardFrame) {
|
||||
int count = 0;
|
||||
GLenum discard[2];
|
||||
if (color) discard[count++] = Core::active.target ? GL_COLOR_ATTACHMENT0 : GL_COLOR_EXT;
|
||||
if (depth) discard[count++] = Core::active.target ? GL_DEPTH_ATTACHMENT : GL_DEPTH_EXT;
|
||||
if (count)
|
||||
glDiscardFramebufferEXT(GL_FRAMEBUFFER, count, discard);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void setVSync(bool enable) {
|
||||
#ifdef _OS_WINDOWS
|
||||
if (wglSwapIntervalEXT) wglSwapIntervalEXT(enable ? 1 : 0);
|
||||
#elif _OS_LINUX
|
||||
if (glXSwapIntervalSGI) glXSwapIntervalSGI(enable ? 1 : 0);
|
||||
#elif _OS_RPI
|
||||
eglSwapInterval(display, enable ? 1 : 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
void waitVBlank() {}
|
||||
|
||||
void clear(bool color, bool depth) {
|
||||
uint32 mask = (color ? GL_COLOR_BUFFER_BIT : 0) | (depth ? GL_DEPTH_BUFFER_BIT : 0);
|
||||
if (mask) glClear(mask);
|
||||
}
|
||||
|
||||
void setClearColor(const vec4 &color) {
|
||||
glClearColor(color.x, color.y, color.z, color.w);
|
||||
}
|
||||
|
||||
void setViewport(int x, int y, int w, int h) {
|
||||
glViewport(x, y, w, h);
|
||||
glScissor(int(viewport.x), int(viewport.y), int(viewport.z), int(viewport.w));
|
||||
}
|
||||
|
||||
void setDepthTest(bool enable) {
|
||||
if (enable)
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
else
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
}
|
||||
|
||||
void setDepthWrite(bool enable) {
|
||||
glDepthMask(enable ? GL_TRUE : GL_FALSE);
|
||||
}
|
||||
|
||||
void setColorWrite(bool r, bool g, bool b, bool a) {
|
||||
glColorMask(r, g, b, a);
|
||||
}
|
||||
|
||||
void setAlphaTest(bool enable) {
|
||||
if (enable)
|
||||
glEnable(GL_ALPHA_TEST);
|
||||
else
|
||||
glDisable(GL_ALPHA_TEST);
|
||||
}
|
||||
|
||||
void setCullMode(int rsMask) {
|
||||
cullMode = rsMask;
|
||||
switch (rsMask) {
|
||||
case RS_CULL_BACK : glCullFace(GL_BACK); break;
|
||||
case RS_CULL_FRONT : glCullFace(GL_FRONT); break;
|
||||
default : glDisable(GL_CULL_FACE); return;
|
||||
}
|
||||
glEnable(GL_CULL_FACE);
|
||||
}
|
||||
|
||||
void setBlendMode(int rsMask) {
|
||||
blendMode = rsMask;
|
||||
switch (rsMask) {
|
||||
case RS_BLEND_ALPHA : glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); break;
|
||||
case RS_BLEND_ADD : glBlendFunc(GL_ONE, GL_ONE); break;
|
||||
case RS_BLEND_MULT : glBlendFunc(GL_DST_COLOR, GL_ZERO); break;
|
||||
case RS_BLEND_PREMULT : glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); break;
|
||||
default : glDisable(GL_BLEND); return;
|
||||
}
|
||||
glEnable(GL_BLEND);
|
||||
}
|
||||
|
||||
void setViewProj(const mat4 &mView, const mat4 &mProj) {
|
||||
#ifdef FFP
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadMatrixf((float*)&mProj);
|
||||
#endif
|
||||
}
|
||||
|
||||
void DIP(int iStart, int iCount, Index *iBuffer) {
|
||||
#ifdef FFP
|
||||
mat4 m = mView * mModel;
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadMatrixf((GLfloat*)&m);
|
||||
#endif
|
||||
|
||||
glDrawElements(GL_TRIANGLES, iCount, GL_UNSIGNED_SHORT, iBuffer + iStart);
|
||||
}
|
||||
|
||||
vec4 copyPixel(int x, int y) {
|
||||
ubyte4 c;
|
||||
glReadPixels(x, y, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &c);
|
||||
return vec4(float(c.x), float(c.y), float(c.z), float(c.w)) * (1.0f / 255.0f);
|
||||
}
|
||||
|
||||
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) {
|
||||
ASSERT(pso);
|
||||
ASSERT(pso->data != NULL);
|
||||
|
||||
uint32 state = pso->renderState;
|
||||
uint32 mask = mask;
|
||||
|
||||
if (Core::active.pso)
|
||||
mask ^= Core::active.pso->renderState;
|
||||
|
||||
if (!Core::active.pso || Core::active.pso->clearColor != pso->clearColor)
|
||||
setClearColor(pso->clearColor);
|
||||
|
||||
if (mask & RS_DEPTH_TEST)
|
||||
setDepthTest((state & RS_DEPTH_TEST) != 0);
|
||||
|
||||
if (mask & RS_DEPTH_WRITE)
|
||||
setDepthWrite((state & RS_DEPTH_WRITE) != 0);
|
||||
|
||||
if (mask & RS_COLOR_WRITE)
|
||||
setColorWrite((state & RS_COLOR_WRITE_R) != 0, (state & RS_COLOR_WRITE_G) != 0, (state & RS_COLOR_WRITE_B) != 0, (state & RS_COLOR_WRITE_A) != 0);
|
||||
|
||||
if (mask & RS_CULL)
|
||||
setCullMode(state & RS_CULL);
|
||||
|
||||
if (mask & RS_BLEND)
|
||||
setBlendMode(state & RS_BLEND);
|
||||
|
||||
#ifdef FFP
|
||||
if (mask & RS_DISCARD)
|
||||
setAlphaTest((state & RS_DISCARD) != 0);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
215
src/gapi_gu.h
Normal file
215
src/gapi_gu.h
Normal file
@@ -0,0 +1,215 @@
|
||||
#ifndef H_GAPI_GU
|
||||
#define H_GAPI_GU
|
||||
|
||||
#include "core.h"
|
||||
|
||||
namespace GAPI {
|
||||
|
||||
using namespace Core;
|
||||
|
||||
struct Vertex {
|
||||
short2 texCoord;
|
||||
ubyte4 color;
|
||||
short3 normal;
|
||||
short3 coord;
|
||||
};
|
||||
|
||||
int cullMode, blendMode;
|
||||
|
||||
uint32 *cmdBuf = NULL;
|
||||
|
||||
static int EDRAM_OFFSET;
|
||||
static int EDRAM_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));
|
||||
if (Core::EDRAM_OFFSET + size > EDRAM_SIZE)
|
||||
LOG("! EDRAM overflow !\n");
|
||||
|
||||
void *ptr = ((char*)sceGeEdramGetAddr()) + EDRAM_OFFSET;
|
||||
EDRAM_OFFSET += (size + 15) / 16 * 16;
|
||||
return ptr;
|
||||
}
|
||||
|
||||
void freeEDRAM() {
|
||||
EDRAM_OFFSET = (512 * 272 * 2 * 2) + (512 * 272 * 2);
|
||||
LOG("EDRAM FREE: offset: %d\n", EDRAM_OFFSET);
|
||||
}
|
||||
|
||||
void beginCmdBuf() {
|
||||
if (!cmdBuf)
|
||||
cmdBuf = new uint32[262144];
|
||||
sceGuStart(GU_DIRECT, cmdBuf);
|
||||
}
|
||||
|
||||
void submitCmdBuf() {
|
||||
ASSERT(cmdBuf);
|
||||
sceGuFinish();
|
||||
sceGuSync(GU_SYNC_WAIT, GU_SYNC_FINISH);
|
||||
}
|
||||
|
||||
void init() {
|
||||
LOG("Vendor : %s\n", "Sony");
|
||||
LOG("Renderer : %s\n", "SCE GU");
|
||||
LOG("Version : %s\n", "1.0");
|
||||
|
||||
EDRAM_SIZE = sceGeEdramGetSize();
|
||||
LOG("VRAM : %d\n", EDRAM_SIZE);
|
||||
freeEDRAM();
|
||||
|
||||
|
||||
support.maxAniso = 1;
|
||||
support.maxVectors = 0;
|
||||
support.shaderBinary = false;
|
||||
support.VAO = false;
|
||||
support.depthTexture = false;
|
||||
support.shadowSampler = false;
|
||||
support.discardFrame = false;
|
||||
support.texNPOT = false;
|
||||
support.texRG = false;
|
||||
support.texBorder = false;
|
||||
support.maxAniso = false;
|
||||
support.colorFloat = false;
|
||||
support.colorHalf = false;
|
||||
support.texFloatLinear = false;
|
||||
support.texFloat = false;
|
||||
support.texHalfLinear = false;
|
||||
support.texHalf = false;
|
||||
|
||||
Core::width = 480;
|
||||
Core::height = 272;
|
||||
|
||||
sceGuEnable(GU_TEXTURE_2D);
|
||||
sceGuDepthFunc(GU_LEQUAL);
|
||||
sceGuDepthRange(0x0000, 0xFFFF);
|
||||
sceGuClearDepth(0xFFFF);
|
||||
|
||||
sceGuShadeModel(GU_SMOOTH);
|
||||
sceGuAlphaFunc(GU_GREATER, 127, 255);
|
||||
|
||||
int swizzle = GU_FALSE;
|
||||
#ifdef TEX_SWIZZLE
|
||||
swizzle = GU_TRUE;
|
||||
#endif
|
||||
|
||||
sceGuClutMode(GU_PSM_5551, 0, 0xFF, 0);
|
||||
sceGuTexMode(GU_PSM_T4, 0, 0, swizzle);
|
||||
sceGuTexFunc(GU_TFX_MODULATE, GU_TCC_RGBA);
|
||||
sceGuTexScale(1.0f, 1.0f);
|
||||
sceGuTexOffset(0.0f, 0.0f);
|
||||
sceGuTexFilter(GU_LINEAR, GU_LINEAR);
|
||||
//sceGuTexFilter(GU_NEAREST, GU_NEAREST);
|
||||
sceGuEnable(GU_CLIP_PLANES);
|
||||
|
||||
const ScePspIMatrix4 dith =
|
||||
{ {-4, 0, -3, 1},
|
||||
{ 2, -2, 3, -1},
|
||||
{-3, 1, -4, 0},
|
||||
{ 3, -1, 2, -2} };
|
||||
sceGuSetDither(&dith);
|
||||
sceGuEnable(GU_DITHER);
|
||||
|
||||
sceGuAmbientColor(0xFFFFFFFF);
|
||||
sceGuColor(0xFFFFFFFF);
|
||||
sceGuClearColor(0x00000000);
|
||||
sceGuColorMaterial(GU_AMBIENT | GU_DIFFUSE);
|
||||
}
|
||||
|
||||
void deinit() {
|
||||
delete[] cmdBuf;
|
||||
}
|
||||
|
||||
void resetState() {}
|
||||
|
||||
void discardTarget(bool color, bool depth) {}
|
||||
|
||||
void setVSync(bool enable) {}
|
||||
|
||||
void waitVBlank() {
|
||||
sceDisplayWaitVblankStart();
|
||||
}
|
||||
|
||||
void clear(bool color, bool depth) {
|
||||
uint32 mask = (color ? GU_COLOR_BUFFER_BIT : 0) | (depth ? GU_DEPTH_BUFFER_BIT : 0);
|
||||
if (mask) sceGuClear(mask | GU_FAST_CLEAR_BIT);
|
||||
}
|
||||
|
||||
void setClearColor(const vec4 &color) {
|
||||
ubyte4 c(clamp(int(color.x * 255), 0, 255),
|
||||
clamp(int(color.y * 255), 0, 255),
|
||||
clamp(int(color.z * 255), 0, 255),
|
||||
clamp(int(color.w * 255), 0, 255));
|
||||
sceGuClearColor(*((uint32*)&c));
|
||||
}
|
||||
|
||||
void setViewport(int x, int y, int w, int h) {
|
||||
sceGuOffset(2048 - w / 2, 2048 - h / 2);
|
||||
sceGuViewport(2048 + x, 2048 + y, w, h);
|
||||
}
|
||||
|
||||
void setDepthTest(bool enable) {
|
||||
if (enable)
|
||||
sceGuEnable(GU_DEPTH_TEST);
|
||||
else
|
||||
sceGuDisable(GU_DEPTH_TEST);
|
||||
}
|
||||
|
||||
void setDepthWrite(bool enable) {
|
||||
sceGuDepthMask(enable ? GU_FALSE : GU_TRUE);
|
||||
}
|
||||
|
||||
void setColorWrite(bool r, bool g, bool b, bool a) {
|
||||
sceGuPixelMask(~((r ? 0x000000FF : 0) | (g ? 0x0000FF00 : 0) | (b ? 0x00FF0000 : 0) | (a ? 0xFF000000 : 0)));
|
||||
}
|
||||
|
||||
void setAlphaTest(bool enable) {
|
||||
if (enable)
|
||||
sceGuEnable(GU_ALPHA_TEST);
|
||||
else
|
||||
sceGuDisable(GU_ALPHA_TEST);
|
||||
}
|
||||
|
||||
void setCullMode(int rsMask) {
|
||||
cullMode = rsMask;
|
||||
switch (rsMask) {
|
||||
case RS_CULL_BACK : sceGuFrontFace(GU_CCW); break;
|
||||
case RS_CULL_FRONT : sceGuFrontFace(GU_CW); break;
|
||||
default : sceGuDisable(GU_CULL_FACE); return;
|
||||
}
|
||||
sceGuEnable(GU_CULL_FACE);
|
||||
}
|
||||
|
||||
void setBlendMode(int rsMask) {
|
||||
blendMode = rsMask;
|
||||
switch (rsMask) {
|
||||
case RS_BLEND_ALPHA : sceGuBlendFunc(GU_ADD, GU_SRC_ALPHA, GU_ONE_MINUS_SRC_ALPHA, 0, 0); break;
|
||||
case RS_BLEND_ADD : sceGuBlendFunc(GU_ADD, GU_FIX, GU_FIX, 0xffffffff, 0xffffffff); break;
|
||||
case RS_BLEND_MULT : sceGuBlendFunc(GU_ADD, GU_DST_COLOR, GU_FIX, 0, 0); break;
|
||||
case RS_BLEND_PREMULT : sceGuBlendFunc(GU_ADD, GU_FIX, GU_ONE_MINUS_SRC_ALPHA, 0xffffffff, 0); break;
|
||||
default : sceGuDisable(GU_BLEND); return;
|
||||
}
|
||||
sceGuEnable(GU_BLEND);
|
||||
}
|
||||
|
||||
void setViewProj(const mat4 &mView, const mat4 &mProj) {
|
||||
sceGumMatrixMode(GU_PROJECTION);
|
||||
sceGumLoadMatrix((ScePspFMatrix4*)&mProj);
|
||||
sceGumMatrixMode(GU_VIEW);
|
||||
sceGumLoadMatrix((ScePspFMatrix4*)&mView);
|
||||
}
|
||||
|
||||
void DIP(int iStart, int iCount, Index *iBuffer) {
|
||||
mat4 m = mModel;
|
||||
m.scale(vec3(32767.0f));
|
||||
sceGumMatrixMode(GU_MODEL);
|
||||
sceGumLoadMatrix((ScePspFMatrix4*)&m);
|
||||
|
||||
sceGumDrawArray(GU_TRIANGLES, GU_TEXTURE_16BIT | GU_COLOR_8888 | GU_NORMAL_16BIT | GU_VERTEX_16BIT | GU_INDEX_16BIT | GU_TRANSFORM_3D, iCount, active.iBuffer + iStart, active.vBuffer);
|
||||
}
|
||||
|
||||
vec4 copyPixel(int x, int y) {
|
||||
return vec4(0.0f); // TODO: read from framebuffer
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
6
src/gapi_gx.h
Normal file
6
src/gapi_gx.h
Normal file
@@ -0,0 +1,6 @@
|
||||
#ifndef H_GAPI_GX
|
||||
#define H_GAPI_GX
|
||||
|
||||
// TODO
|
||||
|
||||
#endif
|
6
src/gapi_vk.h
Normal file
6
src/gapi_vk.h
Normal file
@@ -0,0 +1,6 @@
|
||||
#ifndef H_GAPI_VK
|
||||
#define H_GAPI_VK
|
||||
|
||||
// TODO
|
||||
|
||||
#endif
|
@@ -7,7 +7,7 @@
|
||||
|
||||
#define INVENTORY_MAX_ITEMS 32
|
||||
#define INVENTORY_MAX_RADIUS 688.0f
|
||||
#ifdef _PSP
|
||||
#ifdef _OS_PSP
|
||||
#define INVENTORY_BG_SIZE 256
|
||||
#else
|
||||
#define INVENTORY_BG_SIZE 512
|
||||
@@ -125,12 +125,12 @@ static const OptionItem optDetail[] = {
|
||||
OptionItem( OptionItem::TYPE_PARAM, STR_OPT_DETAIL_LIGHTING, SETTINGS( detail.lighting ), STR_QUALITY_LOW, 0, 2 ),
|
||||
OptionItem( OptionItem::TYPE_PARAM, STR_OPT_DETAIL_SHADOWS, SETTINGS( detail.shadows ), STR_QUALITY_LOW, 0, 2 ),
|
||||
OptionItem( OptionItem::TYPE_PARAM, STR_OPT_DETAIL_WATER, SETTINGS( detail.water ), STR_QUALITY_LOW, 0, 2 ),
|
||||
#if defined(WIN32) || defined(LINUX) || defined(_PSP) || defined(__RPI__)
|
||||
#if defined(_OS_WINDOWS) || defined(_OS_LINUX) || defined(_OS_PSP) || defined(_OS_RPI)
|
||||
OptionItem( OptionItem::TYPE_PARAM, STR_OPT_DETAIL_VSYNC, SETTINGS( detail.vsync ), STR_OFF, 0, 1 ),
|
||||
#endif
|
||||
#ifndef _PSP
|
||||
#ifndef _OS_PSP
|
||||
OptionItem( OptionItem::TYPE_PARAM, STR_OPT_DETAIL_STEREO, SETTINGS( detail.stereo ), STR_OFF, 0,
|
||||
#if /*defined(_WIN32) ||*/ defined(ANDROID)
|
||||
#if /*defined(_OS_WINDOWS) ||*/ defined(_OS_ANDROID)
|
||||
3 /* with VR option */
|
||||
#else
|
||||
2 /* without VR support */
|
||||
@@ -154,7 +154,7 @@ static const OptionItem optControls[] = {
|
||||
OptionItem( ),
|
||||
OptionItem( OptionItem::TYPE_PARAM, STR_NOT_IMPLEMENTED , SETTINGS( playerIndex ), STR_PLAYER_1, 0, 1 ),
|
||||
OptionItem( OptionItem::TYPE_PARAM, STR_OPT_CONTROLS_GAMEPAD , SETTINGS( controls[0].joyIndex ), STR_GAMEPAD_1, 0, 3 ),
|
||||
#ifdef WIN32
|
||||
#ifdef _OS_WINDOWS
|
||||
OptionItem( OptionItem::TYPE_PARAM, STR_OPT_CONTROLS_VIBRATION , SETTINGS( controls[0].vibration ), STR_OFF, 0, 1 ),
|
||||
#endif
|
||||
OptionItem( OptionItem::TYPE_PARAM, STR_OPT_CONTROLS_RETARGET , SETTINGS( controls[0].retarget ), STR_OFF, 0, 1 ),
|
||||
@@ -431,18 +431,18 @@ struct Inventory {
|
||||
|
||||
Core::setBasis(joints, m.mCount);
|
||||
|
||||
Core::setBlending(bmAlpha);
|
||||
Core::setBlendMode(bmAlpha);
|
||||
mesh->transparent = 0;
|
||||
mesh->renderModel(desc.model);
|
||||
mesh->transparent = 1;
|
||||
mesh->renderModel(desc.model);
|
||||
Core::setBlending(bmAdd);
|
||||
Core::setBlendMode(bmAdd);
|
||||
Core::setDepthWrite(false);
|
||||
mesh->transparent = 2;
|
||||
mesh->renderModel(desc.model);
|
||||
Core::setDepthWrite(true);
|
||||
|
||||
Core::setBlending(bmNone);
|
||||
Core::setBlendMode(bmNone);
|
||||
}
|
||||
|
||||
void choose() {
|
||||
@@ -760,7 +760,7 @@ struct Inventory {
|
||||
|
||||
switch (level->version & TR::VER_VERSION) {
|
||||
case TR::VER_TR1 :
|
||||
#ifdef __EMSCRIPTEN__
|
||||
#ifdef _OS_WEB
|
||||
passportSlotCount = 2;
|
||||
passportSlots[0] = TR::LVL_TR1_1;
|
||||
passportSlots[1] = TR::LVL_TR1_2;
|
||||
@@ -773,7 +773,7 @@ struct Inventory {
|
||||
#endif
|
||||
break;
|
||||
case TR::VER_TR2 :
|
||||
#ifdef __EMSCRIPTEN__
|
||||
#ifdef _OS_WEB
|
||||
passportSlotCount = 2;
|
||||
passportSlots[0] = TR::LVL_TR2_WALL;
|
||||
passportSlots[1] = TR::LVL_TR2_BOAT;
|
||||
@@ -786,7 +786,7 @@ struct Inventory {
|
||||
#endif
|
||||
break;
|
||||
case TR::VER_TR3 :
|
||||
#ifdef __EMSCRIPTEN__
|
||||
#ifdef _OS_WEB
|
||||
passportSlotCount = 1;
|
||||
passportSlots[0] = TR::LVL_TR3_JUNGLE;
|
||||
#else
|
||||
@@ -1107,7 +1107,7 @@ struct Inventory {
|
||||
|
||||
for (int i = 0; i < COUNT(background); i++)
|
||||
if (!background[i])
|
||||
background[i] = new Texture(INVENTORY_BG_SIZE, INVENTORY_BG_SIZE, Texture::RGBA);
|
||||
background[i] = new Texture(INVENTORY_BG_SIZE, INVENTORY_BG_SIZE, FMT_RGBA);
|
||||
|
||||
return background[0];
|
||||
}
|
||||
@@ -1116,7 +1116,7 @@ struct Inventory {
|
||||
if (Core::settings.detail.stereo == Core::Settings::STEREO_VR)
|
||||
return;
|
||||
|
||||
#ifdef _PSP
|
||||
#ifdef _OS_PSP
|
||||
return;
|
||||
#endif
|
||||
Core::defaultTarget = getBackgroundTarget();
|
||||
@@ -1124,7 +1124,7 @@ struct Inventory {
|
||||
Core::defaultTarget = NULL;
|
||||
|
||||
Core::setDepthTest(false);
|
||||
Core::setBlending(bmNone);
|
||||
Core::setBlendMode(bmNone);
|
||||
|
||||
#ifdef FFP
|
||||
mat4 m;
|
||||
@@ -1133,7 +1133,7 @@ struct Inventory {
|
||||
Core::mModel.identity();
|
||||
#endif
|
||||
|
||||
#ifdef _PSP
|
||||
#ifdef _OS_PSP
|
||||
//
|
||||
#else
|
||||
// vertical blur
|
||||
@@ -1331,10 +1331,10 @@ struct Inventory {
|
||||
|
||||
uint8 alpha;
|
||||
if (!isActive() && titleTimer > 0.0f && titleTimer < 1.0f) {
|
||||
Core::setBlending(bmAlpha);
|
||||
Core::setBlendMode(bmAlpha);
|
||||
alpha = uint8(titleTimer * 255);
|
||||
} else {
|
||||
Core::setBlending(bmNone);
|
||||
Core::setBlendMode(bmNone);
|
||||
alpha = 255;
|
||||
}
|
||||
|
||||
@@ -1417,7 +1417,7 @@ struct Inventory {
|
||||
}
|
||||
|
||||
void renderGameBG() {
|
||||
#ifdef _PSP
|
||||
#ifdef _OS_PSP
|
||||
return;
|
||||
#endif
|
||||
Index indices[6] = { 0, 1, 2, 0, 2, 3 };
|
||||
@@ -1443,7 +1443,7 @@ struct Inventory {
|
||||
} else
|
||||
background[0]->bind(sDiffuse); // blured grayscale image
|
||||
|
||||
Core::setBlending(phaseRing < 1.0f ? bmAlpha : bmNone);
|
||||
Core::setBlendMode(phaseRing < 1.0f ? bmAlpha : bmNone);
|
||||
game->getMesh()->renderBuffer(indices, COUNT(indices), vertices, COUNT(vertices));
|
||||
}
|
||||
|
||||
@@ -1465,7 +1465,7 @@ struct Inventory {
|
||||
renderTitleBG();
|
||||
}
|
||||
|
||||
Core::setBlending(bmAlpha);
|
||||
Core::setBlendMode(bmAlpha);
|
||||
Core::setDepthTest(true);
|
||||
}
|
||||
|
||||
|
@@ -1443,7 +1443,7 @@ struct Lara : Character {
|
||||
void bakeEnvironment() {
|
||||
flags.invisible = true;
|
||||
if (!environment)
|
||||
environment = new Texture(256, 256, Texture::RGBA, Texture::CUBEMAP | Texture::MIPMAPS);
|
||||
environment = new Texture(256, 256, FMT_RGBA, Texture::CUBEMAP | Texture::MIPMAPS);
|
||||
game->renderEnvironment(getRoomIndex(), pos - vec3(0.0f, 384.0f, 0.0f), &environment, 0, Core::passCompose);
|
||||
environment->generateMipMap();
|
||||
flags.invisible = false;
|
||||
@@ -3282,11 +3282,11 @@ struct Lara : Character {
|
||||
Core::active.shader->setParam(uLightPos, Core::lightPos[0], MAX_LIGHTS);
|
||||
*/
|
||||
environment->bind(sEnvironment);
|
||||
Core::setBlending(bmAlpha);
|
||||
Core::setBlendMode(bmAlpha);
|
||||
visibleMask ^= 0xFFFFFFFF;
|
||||
Controller::render(frustum, mesh, type, caustics);
|
||||
visibleMask ^= 0xFFFFFFFF;
|
||||
Core::setBlending(bmNone);
|
||||
Core::setBlendMode(bmNone);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
66
src/level.h
66
src/level.h
@@ -70,7 +70,7 @@ struct Level : IGame {
|
||||
}
|
||||
|
||||
virtual void loadNextLevel() {
|
||||
#ifdef __EMSCRIPTEN__
|
||||
#ifdef _OS_WEB
|
||||
if (level.id == TR::LVL_TR1_2 && level.version != TR::VER_TR1_PC) {
|
||||
loadLevel(TR::LVL_TR1_TITLE);
|
||||
return;
|
||||
@@ -226,9 +226,9 @@ struct Level : IGame {
|
||||
void initShadow() {
|
||||
delete shadow;
|
||||
if (Core::settings.detail.shadows > Core::Settings::MEDIUM)
|
||||
shadow = new Texture(SHADOW_TEX_WIDTH, SHADOW_TEX_HEIGHT, Texture::SHADOW);
|
||||
shadow = new Texture(SHADOW_TEX_WIDTH, SHADOW_TEX_HEIGHT, FMT_SHADOW);
|
||||
else if (Core::settings.detail.shadows > Core::Settings::LOW)
|
||||
shadow = new Texture(SHADOW_TEX_BIG_WIDTH, SHADOW_TEX_BIG_HEIGHT, Texture::SHADOW);
|
||||
shadow = new Texture(SHADOW_TEX_BIG_WIDTH, SHADOW_TEX_BIG_HEIGHT, FMT_SHADOW);
|
||||
else
|
||||
shadow = NULL;
|
||||
}
|
||||
@@ -245,13 +245,15 @@ struct Level : IGame {
|
||||
|
||||
bool redraw = settings.detail.stereo != Core::settings.detail.stereo;
|
||||
|
||||
#ifdef ANDROID
|
||||
#ifdef _OS_ANDROID
|
||||
if ((settings.detail.stereo == Core::Settings::STEREO_VR) ^ (Core::settings.detail.stereo == Core::Settings::STEREO_VR))
|
||||
osToggleVR(settings.detail.stereo == Core::Settings::STEREO_VR);
|
||||
#endif
|
||||
|
||||
Core::settings = settings;
|
||||
|
||||
Core::setVSync(Core::settings.detail.vsync != 0);
|
||||
|
||||
Stream::cacheWrite("settings", (char*)&settings, sizeof(settings));
|
||||
|
||||
if (rebuildShaders) {
|
||||
@@ -366,7 +368,7 @@ struct Level : IGame {
|
||||
}
|
||||
|
||||
virtual void setShader(Core::Pass pass, Shader::Type type, bool underwater = false, bool alphaTest = false) {
|
||||
shaderCache->bind(pass, type, (underwater ? ShaderCache::FX_UNDERWATER : 0) | (alphaTest ? ShaderCache::FX_ALPHA_TEST : 0) | ((params->clipHeight != NO_CLIP_PLANE && pass == Core::passCompose) ? ShaderCache::FX_CLIP_PLANE : 0), this);
|
||||
shaderCache->bind(pass, type, (underwater ? ShaderCache::FX_UNDERWATER : 0) | (alphaTest ? ShaderCache::FX_ALPHA_TEST : 0) | ((params->clipHeight != NO_CLIP_PLANE && pass == Core::passCompose) ? ShaderCache::FX_CLIP_PLANE : 0));
|
||||
}
|
||||
|
||||
virtual void setRoomParams(int roomIndex, Shader::Type type, float diffuse, float ambient, float specular, float alpha, bool alphaTest = false) {
|
||||
@@ -657,7 +659,7 @@ struct Level : IGame {
|
||||
//==============================
|
||||
|
||||
Level(Stream &stream) : level(stream), inventory(this), waitTrack(false), isEnded(false), cutsceneWaitTimer(0.0f), animTexTimer(0.0f) {
|
||||
#ifdef _PSP
|
||||
#ifdef _OS_PSP
|
||||
Core::freeEDRAM();
|
||||
#endif
|
||||
params = (Params*)&Core::params;
|
||||
@@ -1080,7 +1082,7 @@ struct Level : IGame {
|
||||
|
||||
#ifndef SPLIT_BY_TILE
|
||||
|
||||
#ifdef _PSP
|
||||
#ifdef _OS_PSP
|
||||
#error atlas packing is not allowed for this platform
|
||||
#endif
|
||||
|
||||
@@ -1137,7 +1139,7 @@ struct Level : IGame {
|
||||
delete[] level.tiles;
|
||||
level.tiles = NULL;
|
||||
#else
|
||||
#ifdef _PSP
|
||||
#ifdef _OS_PSP
|
||||
atlas = new Texture(level.tiles4, level.tilesCount, level.cluts, level.clutsCount);
|
||||
#else
|
||||
level.initTiles();
|
||||
@@ -1257,7 +1259,7 @@ struct Level : IGame {
|
||||
else
|
||||
b = Basis(quat(0, 0, 0, 1), vec3(0));
|
||||
|
||||
Core::setBlending(bmNone);
|
||||
Core::setBlendMode(bmNone);
|
||||
Core::setDepthTest(false);
|
||||
setShader(Core::pass, Shader::FLASH, false, false);
|
||||
Core::active.shader->setParam(uMaterial, vec4(0.5f, 0.0f, 0.0f, 0.0f));
|
||||
@@ -1315,9 +1317,9 @@ struct Level : IGame {
|
||||
Core::mModel.identity();
|
||||
|
||||
switch (transp) {
|
||||
case 0 : Core::setBlending(bmNone); break;
|
||||
case 1 : Core::setBlending(bmAlpha); break;
|
||||
case 2 : Core::setBlending(bmAdd); Core::setDepthWrite(false); break;
|
||||
case 0 : Core::setBlendMode(bmNone); break;
|
||||
case 1 : Core::setBlendMode(bmAlpha); break;
|
||||
case 2 : Core::setBlendMode(bmAdd); Core::setDepthWrite(false); break;
|
||||
}
|
||||
|
||||
int i = 0;
|
||||
@@ -1362,7 +1364,7 @@ struct Level : IGame {
|
||||
Core::setDepthWrite(true);
|
||||
|
||||
if (transp == 1) {
|
||||
Core::setBlending(bmAlpha);
|
||||
Core::setBlendMode(bmAlpha);
|
||||
|
||||
#ifdef MERGE_SPRITES
|
||||
basis.rot = Core::mViewInv.getRot();
|
||||
@@ -1393,7 +1395,7 @@ struct Level : IGame {
|
||||
}
|
||||
endLighting();
|
||||
|
||||
Core::setBlending(bmNone);
|
||||
Core::setBlendMode(bmNone);
|
||||
}
|
||||
|
||||
void renderEntity(const TR::Entity &entity) {
|
||||
@@ -1583,7 +1585,7 @@ struct Level : IGame {
|
||||
|
||||
void updateLighting() {
|
||||
#ifdef FFP
|
||||
#ifdef _PSP
|
||||
#ifdef _OS_PSP
|
||||
ubyte4 ambient;
|
||||
ambient.x = ambient.y = ambient.z = clamp(int(Core::active.material.y * 255), 0, 255);
|
||||
ambient.w = 255;
|
||||
@@ -1627,7 +1629,7 @@ struct Level : IGame {
|
||||
void beginLighting(bool room) {
|
||||
#ifdef FFP
|
||||
Core::mModel.identity();
|
||||
#ifdef _PSP
|
||||
#ifdef _OS_PSP
|
||||
sceGuEnable(GU_LIGHTING);
|
||||
if (room)
|
||||
sceGuDisable(GU_LIGHT0);
|
||||
@@ -1648,7 +1650,7 @@ struct Level : IGame {
|
||||
|
||||
void endLighting() {
|
||||
#ifdef FFP
|
||||
#ifdef _PSP
|
||||
#ifdef _OS_PSP
|
||||
sceGuDisable(GU_LIGHTING);
|
||||
#else
|
||||
glDisable(GL_COLOR_MATERIAL);
|
||||
@@ -1680,27 +1682,27 @@ struct Level : IGame {
|
||||
beginLighting(false);
|
||||
|
||||
if (transp == 0) {
|
||||
Core::setBlending(bmNone);
|
||||
Core::setBlendMode(bmNone);
|
||||
renderEntitiesTransp(transp);
|
||||
}
|
||||
|
||||
if (transp == 1) {
|
||||
Core::setBlending(bmAlpha);
|
||||
Core::setBlendMode(bmAlpha);
|
||||
renderEntitiesTransp(transp);
|
||||
|
||||
Core::setBlending(bmMult);
|
||||
Core::setBlendMode(bmMult);
|
||||
for (int i = 0; i < level.entitiesCount; i++) {
|
||||
TR::Entity &entity = level.entities[i];
|
||||
Controller *controller = (Controller*)entity.controller;
|
||||
if (controller && controller->flags.rendered && controller->getEntity().castShadow())
|
||||
controller->renderShadow(mesh);
|
||||
}
|
||||
Core::setBlending(bmNone);
|
||||
Core::setBlendMode(bmNone);
|
||||
}
|
||||
|
||||
if (transp == 2) {
|
||||
Core::setDepthWrite(false);
|
||||
Core::setBlending(bmAdd);
|
||||
Core::setBlendMode(bmAdd);
|
||||
renderEntitiesTransp(transp);
|
||||
Core::setDepthWrite(true);
|
||||
}
|
||||
@@ -1900,7 +1902,7 @@ struct Level : IGame {
|
||||
if (camera->isUnderwater())
|
||||
renderAdditive(roomsList, roomsCount);
|
||||
|
||||
Core::setBlending(bmNone);
|
||||
Core::setBlendMode(bmNone);
|
||||
if (water && waterCache && waterCache->visible) {
|
||||
Core::Pass pass = Core::pass;
|
||||
waterCache->renderMask();
|
||||
@@ -1914,7 +1916,7 @@ struct Level : IGame {
|
||||
if (!camera->isUnderwater())
|
||||
renderAdditive(roomsList, roomsCount);
|
||||
|
||||
Core::setBlending(bmNone);
|
||||
Core::setBlendMode(bmNone);
|
||||
|
||||
if (showUI) {
|
||||
Core::Pass pass = Core::pass;
|
||||
@@ -1995,7 +1997,7 @@ struct Level : IGame {
|
||||
bias.e00 = bias.e11 = bias.e22 = bias.e03 = bias.e13 = bias.e23 = 0.5f;
|
||||
Core::mLightProj[index] = bias * (Core::mProj * Core::mView);
|
||||
|
||||
Core::setBlending(bmNone);
|
||||
Core::setBlendMode(bmNone);
|
||||
|
||||
mesh->transparent = 0;
|
||||
if (mesh->models[controller->getEntity().modelIndex - 1].geometry[mesh->transparent].count) {
|
||||
@@ -2076,13 +2078,13 @@ struct Level : IGame {
|
||||
|
||||
Core::pass = Core::passShadow;
|
||||
shadow->unbind(sShadow);
|
||||
bool colorShadow = shadow->format == Texture::RGBA ? true : false;
|
||||
bool colorShadow = shadow->format == FMT_RGBA ? true : false;
|
||||
if (colorShadow)
|
||||
Core::setClearColor(vec4(1.0f));
|
||||
Core::setTarget(shadow, RT_CLEAR_DEPTH | (colorShadow ? (RT_CLEAR_COLOR | RT_STORE_COLOR) : RT_STORE_DEPTH));
|
||||
Core::validateRenderState();
|
||||
|
||||
Core::setCulling(cfBack);
|
||||
Core::setCullMode(cmBack);
|
||||
|
||||
if (Core::settings.detail.shadows > Core::Settings::Quality::MEDIUM) { // per-object shadow map (atlas)
|
||||
NearObj nearObj[SHADOW_OBJ_MAX];
|
||||
@@ -2098,7 +2100,7 @@ struct Level : IGame {
|
||||
} else // all-in-one shadow map
|
||||
renderShadowView(roomIndex);
|
||||
|
||||
Core::setCulling(cfFront);
|
||||
Core::setCullMode(cmFront);
|
||||
if (colorShadow)
|
||||
Core::setClearColor(vec4(0.0f));
|
||||
|
||||
@@ -2165,9 +2167,9 @@ struct Level : IGame {
|
||||
else
|
||||
atlas->bind(sDiffuse);
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
Core::setCulling(cfNone);
|
||||
Core::setCullMode(cmNone);
|
||||
Core::setDepthTest(false);
|
||||
Core::setBlending(bmNone);
|
||||
Core::setBlendMode(bmNone);
|
||||
Core::validateRenderState();
|
||||
|
||||
glColor3f(10, 10, 10);
|
||||
@@ -2203,7 +2205,7 @@ struct Level : IGame {
|
||||
// Box bbox = lara->getBoundingBox();
|
||||
// Debug::Draw::box(bbox.min, bbox.max, vec4(1, 0, 1, 1));
|
||||
|
||||
Core::setBlending(bmAlpha);
|
||||
Core::setBlendMode(bmAlpha);
|
||||
Core::setDepthTest(false);
|
||||
Core::validateRenderState();
|
||||
// Debug::Level::rooms(level, lara->pos, lara->getEntity().room);
|
||||
@@ -2220,7 +2222,7 @@ struct Level : IGame {
|
||||
// Debug::Level::debugOverlaps(level, lara->box);
|
||||
// Debug::Level::debugBoxes(level, lara->dbgBoxes, lara->dbgBoxesCount);
|
||||
Core::setDepthTest(true);
|
||||
Core::setBlending(bmNone);
|
||||
Core::setBlendMode(bmNone);
|
||||
/*
|
||||
Core::validateRenderState();
|
||||
|
||||
|
60
src/mesh.h
60
src/mesh.h
@@ -19,13 +19,13 @@ struct MeshRange {
|
||||
MeshRange() : iStart(0), iCount(0), vStart(0), aIndex(-1), tile(0), clut(0) {}
|
||||
|
||||
#ifdef FFP
|
||||
#ifdef _PSP
|
||||
#ifdef _OS_PSP
|
||||
void setup() const {
|
||||
Core::active.vBuffer += vStart;
|
||||
}
|
||||
#else
|
||||
void setup() const {
|
||||
VertexGPU *v = (VertexGPU*)NULL + vStart;
|
||||
GAPI::Vertex *v = (GAPI::Vertex*)NULL + vStart;
|
||||
glTexCoordPointer (2, GL_SHORT, sizeof(*v), &v->texCoord);
|
||||
glColorPointer (4, GL_UNSIGNED_BYTE, sizeof(*v), &v->light);
|
||||
glNormalPointer ( GL_SHORT, sizeof(*v), &v->normal);
|
||||
@@ -42,7 +42,7 @@ struct MeshRange {
|
||||
glEnableVertexAttribArray(aColor);
|
||||
glEnableVertexAttribArray(aLight);
|
||||
|
||||
VertexGPU *v = (VertexGPU*)vBuffer + vStart;
|
||||
GAPI::Vertex *v = (GAPI::Vertex*)vBuffer + vStart;
|
||||
glVertexAttribPointer(aCoord, 4, GL_SHORT, false, sizeof(*v), &v->coord);
|
||||
glVertexAttribPointer(aNormal, 4, GL_SHORT, true, sizeof(*v), &v->normal);
|
||||
glVertexAttribPointer(aTexCoord, 4, GL_SHORT, true, sizeof(*v), &v->texCoord);
|
||||
@@ -66,9 +66,9 @@ struct MeshRange {
|
||||
#define MAX_ROOM_DYN_FACES 512
|
||||
|
||||
struct Mesh {
|
||||
Index *iBuffer;
|
||||
VertexGPU *vBuffer;
|
||||
#ifndef _PSP
|
||||
Index *iBuffer;
|
||||
GAPI::Vertex *vBuffer;
|
||||
#ifndef _OS_PSP
|
||||
GLuint ID[2];
|
||||
GLuint *VAO;
|
||||
#endif
|
||||
@@ -79,21 +79,21 @@ struct Mesh {
|
||||
int aIndex;
|
||||
bool cmdBufAlloc;
|
||||
|
||||
#ifdef _PSP
|
||||
#ifdef _OS_PSP
|
||||
Mesh(int iCount, int vCount, bool dynamic) : iCount(iCount), vCount(vCount), aCount(0), aIndex(-1), cmdBufAlloc(true) {
|
||||
iBuffer = (Index*)sceGuGetMemory(iCount * sizeof(Index));
|
||||
vBuffer = (VertexGPU*)sceGuGetMemory(vCount * sizeof(VertexGPU));
|
||||
vBuffer = (GAPI::Vertex*)sceGuGetMemory(vCount * sizeof(GAPI::Vertex));
|
||||
}
|
||||
#endif
|
||||
|
||||
Mesh(Index *indices, int iCount, Vertex *vertices, int vCount, int aCount) : iCount(iCount), vCount(vCount), aCount(aCount), aIndex(0), cmdBufAlloc(false) {
|
||||
#ifdef _PSP
|
||||
#ifdef _OS_PSP
|
||||
#ifdef EDRAM_MESH
|
||||
iBuffer = (Index*)Core::allocEDRAM(iCount * sizeof(Index));
|
||||
vBuffer = (VertexGPU*)Core::allocEDRAM(vCount * sizeof(VertexGPU));
|
||||
vBuffer = (GAPI::Vertex*)Core::allocEDRAM(vCount * sizeof(GAPI::Vertex));
|
||||
#else
|
||||
iBuffer = new Index[iCount];
|
||||
vBuffer = new VertexGPU[vCount];
|
||||
vBuffer = new GAPI::Vertex[vCount];
|
||||
#endif
|
||||
|
||||
update(indices, iCount, vertices, vCount);
|
||||
@@ -106,7 +106,7 @@ struct Mesh {
|
||||
if (!vertices && !indices) {
|
||||
ID[0] = ID[1] = 0;
|
||||
iBuffer = new Index[iCount];
|
||||
vBuffer = new VertexGPU[vCount];
|
||||
vBuffer = new GAPI::Vertex[vCount];
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
@@ -114,7 +114,7 @@ struct Mesh {
|
||||
glGenBuffers(2, ID);
|
||||
bind(true);
|
||||
glBufferData(GL_ELEMENT_ARRAY_BUFFER, iCount * sizeof(Index), indices, GL_STATIC_DRAW);
|
||||
glBufferData(GL_ARRAY_BUFFER, vCount * sizeof(VertexGPU), vertices, GL_STATIC_DRAW);
|
||||
glBufferData(GL_ARRAY_BUFFER, vCount * sizeof(GAPI::Vertex), vertices, GL_STATIC_DRAW);
|
||||
|
||||
if (Core::support.VAO && aCount) {
|
||||
VAO = new GLuint[aCount];
|
||||
@@ -126,13 +126,13 @@ struct Mesh {
|
||||
}
|
||||
|
||||
void update(Index *indices, int iCount, Vertex *vertices, int vCount) {
|
||||
#ifdef _PSP
|
||||
#ifdef _OS_PSP
|
||||
if (indices)
|
||||
memcpy(iBuffer, indices, iCount * sizeof(indices[0]));
|
||||
|
||||
if (vertices) {
|
||||
Vertex *src = vertices;
|
||||
VertexGPU *dst = vBuffer;
|
||||
GAPI::Vertex *dst = vBuffer;
|
||||
|
||||
for (int i = 0; i < vCount; i++) {
|
||||
dst->texCoord = short2(src->texCoord.x, src->texCoord.y);
|
||||
@@ -145,8 +145,8 @@ struct Mesh {
|
||||
}
|
||||
}
|
||||
#else
|
||||
// !!! typeof vertices[0] == Vertex == VertexGPU
|
||||
ASSERT(sizeof(VertexGPU) == sizeof(Vertex));
|
||||
// !!! typeof vertices[0] == Vertex == GAPI::Vertex
|
||||
ASSERT(sizeof(GAPI::Vertex) == sizeof(Vertex));
|
||||
|
||||
if (Core::support.VAO)
|
||||
glBindVertexArray(Core::active.VAO = 0);
|
||||
@@ -161,17 +161,17 @@ struct Mesh {
|
||||
}
|
||||
if (vertices && vCount) {
|
||||
if (vBuffer) {
|
||||
memcpy(vBuffer, vertices, vCount * sizeof(VertexGPU));
|
||||
memcpy(vBuffer, vertices, vCount * sizeof(GAPI::Vertex));
|
||||
} else {
|
||||
glBindBuffer(GL_ARRAY_BUFFER, Core::active.vBuffer = ID[1]);
|
||||
glBufferSubData(GL_ARRAY_BUFFER, 0, vCount * sizeof(VertexGPU), vertices);
|
||||
glBufferSubData(GL_ARRAY_BUFFER, 0, vCount * sizeof(GAPI::Vertex), vertices);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
virtual ~Mesh() {
|
||||
#ifdef _PSP
|
||||
#ifdef _OS_PSP
|
||||
#ifndef EDRAM_MESH
|
||||
if (!cmdBufAlloc) {
|
||||
delete[] iBuffer;
|
||||
@@ -193,7 +193,7 @@ struct Mesh {
|
||||
}
|
||||
|
||||
void initRange(MeshRange &range) {
|
||||
#ifndef _PSP
|
||||
#ifndef _OS_PSP
|
||||
if (Core::support.VAO && VAO) {
|
||||
ASSERT(aIndex < aCount);
|
||||
range.aIndex = aIndex++;
|
||||
@@ -207,7 +207,7 @@ struct Mesh {
|
||||
}
|
||||
|
||||
void bind(bool force = false) {
|
||||
#ifdef _PSP
|
||||
#ifdef _OS_PSP
|
||||
Core::active.iBuffer = iBuffer;
|
||||
Core::active.vBuffer = vBuffer;
|
||||
#else
|
||||
@@ -229,7 +229,7 @@ struct Mesh {
|
||||
if (range.aIndex == -1)
|
||||
bind();
|
||||
|
||||
#ifndef _PSP
|
||||
#ifndef _OS_PSP
|
||||
range.bind(VAO);
|
||||
#endif
|
||||
|
||||
@@ -277,7 +277,7 @@ uint8 intensity(int lighting) {
|
||||
}
|
||||
|
||||
struct MeshBuilder {
|
||||
#ifndef _PSP
|
||||
#ifndef _OS_PSP
|
||||
MeshRange dynRange;
|
||||
Mesh *dynMesh;
|
||||
#endif
|
||||
@@ -374,7 +374,7 @@ struct MeshBuilder {
|
||||
};
|
||||
|
||||
MeshBuilder(TR::Level &level, Texture *atlas) : atlas(atlas), level(&level) {
|
||||
#ifndef _PSP
|
||||
#ifndef _OS_PSP
|
||||
dynMesh = new Mesh(NULL, DYN_MESH_QUADS * 6, NULL, DYN_MESH_QUADS * 4, 1);
|
||||
dynRange.vStart = 0;
|
||||
dynRange.iStart = 0;
|
||||
@@ -739,7 +739,7 @@ struct MeshBuilder {
|
||||
plane.iCount = 0;
|
||||
#endif
|
||||
|
||||
LOG("MegaMesh (i:%d v:%d a:%d, size:%d)\n", iCount, vCount, aCount, int(iCount * sizeof(Index) + vCount * sizeof(VertexGPU)));
|
||||
LOG("MegaMesh (i:%d v:%d a:%d, size:%d)\n", iCount, vCount, aCount, int(iCount * sizeof(Index) + vCount * sizeof(GAPI::Vertex)));
|
||||
|
||||
// compile buffer and ranges
|
||||
mesh = new Mesh(indices, iCount, vertices, vCount, aCount);
|
||||
@@ -805,7 +805,7 @@ struct MeshBuilder {
|
||||
delete[] models;
|
||||
delete[] sequences;
|
||||
delete mesh;
|
||||
#ifndef _PSP
|
||||
#ifndef _OS_PSP
|
||||
delete dynMesh;
|
||||
#endif
|
||||
}
|
||||
@@ -1235,7 +1235,7 @@ struct MeshBuilder {
|
||||
if (!iCount) return;
|
||||
ASSERT(vCount > 0);
|
||||
|
||||
#ifdef _PSP
|
||||
#ifdef _OS_PSP
|
||||
MeshRange dynRange;
|
||||
Mesh cmdBufMesh(iCount, vCount);
|
||||
Mesh *dynMesh = &cmdBufMesh;
|
||||
@@ -1427,13 +1427,13 @@ struct MeshBuilder {
|
||||
}
|
||||
|
||||
void renderShadowBlob() {
|
||||
#ifdef _PSP
|
||||
#ifdef _OS_PSP
|
||||
sceGuDisable(GU_TEXTURE_2D);
|
||||
#endif
|
||||
|
||||
mesh->render(shadowBlob);
|
||||
|
||||
#ifdef _PSP
|
||||
#ifdef _OS_PSP
|
||||
sceGuEnable(GU_TEXTURE_2D);
|
||||
#endif
|
||||
}
|
||||
|
@@ -148,7 +148,7 @@ int main() {
|
||||
|
||||
sceGuInit();
|
||||
|
||||
Core::beginCmdBuf();
|
||||
GAPI::beginCmdBuf();
|
||||
|
||||
sceGuDrawBuffer(GU_PSM_5650, (void*)0, BUF_WIDTH);
|
||||
sceGuDispBuffer(SCR_WIDTH, SCR_HEIGHT, (void*)(BUF_WIDTH * SCR_HEIGHT * 2), BUF_WIDTH);
|
||||
@@ -165,7 +165,7 @@ int main() {
|
||||
|
||||
Game::init();
|
||||
|
||||
Core::submitCmdBuf();
|
||||
GAPI::submitCmdBuf();
|
||||
|
||||
sceDisplayWaitVblankStart();
|
||||
sceGuDisplay(GU_TRUE);
|
||||
@@ -173,12 +173,12 @@ int main() {
|
||||
Core::curBackBuffer = 0;
|
||||
|
||||
while (!Core::isQuit) {
|
||||
Core::beginCmdBuf();
|
||||
GAPI::beginCmdBuf();
|
||||
|
||||
joyUpdate();
|
||||
Game::update();
|
||||
Game::render();
|
||||
Core::submitCmdBuf();
|
||||
GAPI::submitCmdBuf();
|
||||
Core::waitVBlank();
|
||||
Core::curBackBuffer = sceGuSwapBuffers();
|
||||
}
|
||||
|
@@ -22,10 +22,10 @@
|
||||
</style>
|
||||
<meta charset="utf-8">
|
||||
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||
<meta name="viewport" content="width=854px, user-scalable=no">
|
||||
<meta name="viewport" content="width=854, user-scalable=no">
|
||||
</head>
|
||||
<body>
|
||||
<canvas class="game" id="canvas" width="854px" height="480px" oncontextmenu="event.preventDefault()"></canvas><br>
|
||||
<canvas class="game" id="canvas" width="854" height="480" oncontextmenu="event.preventDefault()"></canvas><br>
|
||||
<div id="status">Starting...</div>
|
||||
<script type='text/javascript'>
|
||||
window.onload = function() { window.focus(); }
|
||||
@@ -119,7 +119,7 @@
|
||||
<input type="button" value="Browse Level" onclick="document.getElementById('browseFile').click();" /> (.PHD, .PSX, .TR2)
|
||||
<p style="margin:8px">
|
||||
OpenLara on <a target="_blank" href="https://github.com/XProger/OpenLara">github</a> & <a target="_blank" href="https://www.facebook.com/OpenLaraTR">facebook</a><br>
|
||||
<br><i>last update: 7.04.2018</i><br>
|
||||
<br><i>last update: 20.04.2018</i><br>
|
||||
</p>
|
||||
</span>
|
||||
|
||||
|
@@ -168,6 +168,13 @@ void main_loop() {
|
||||
|
||||
if (Game::update()) {
|
||||
Game::render();
|
||||
|
||||
// clear backbuffer alpha by 1.0f to make opaque canvas layer
|
||||
glColorMask(false, false, false, true);
|
||||
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
glColorMask(true, true, true, true);
|
||||
|
||||
eglSwapBuffers(display, surface);
|
||||
}
|
||||
}
|
||||
|
@@ -22,12 +22,13 @@
|
||||
<ProjectGuid>{6935E070-59B8-418A-9241-70BACB4217B5}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>OpenLara</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v120_xp</PlatformToolset>
|
||||
<PlatformToolset>v140_xp</PlatformToolset>
|
||||
<CharacterSet>NotSet</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Editor|Win32'" Label="Configuration">
|
||||
@@ -39,14 +40,14 @@
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v120_xp</PlatformToolset>
|
||||
<PlatformToolset>v140_xp</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>NotSet</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Profile|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v120_xp</PlatformToolset>
|
||||
<PlatformToolset>v140_xp</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>NotSet</CharacterSet>
|
||||
</PropertyGroup>
|
||||
@@ -70,6 +71,7 @@
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<OutDir>..\..\..\bin\</OutDir>
|
||||
<IncludePath>..\..\;$(VC_IncludePath);$(WindowsSdk_71A_IncludePath);</IncludePath>
|
||||
<LibraryPath>..\..\libs\openvr\;$(VC_LibraryPath_x86);$(WindowsSdk_71A_LibraryPath_x86);</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Editor|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
@@ -81,12 +83,14 @@
|
||||
<OutDir>..\..\..\bin\</OutDir>
|
||||
<GenerateManifest>false</GenerateManifest>
|
||||
<IncludePath>..\..\;$(VC_IncludePath);$(WindowsSdk_71A_IncludePath);</IncludePath>
|
||||
<LibraryPath>..\..\libs\openvr\;$(VC_LibraryPath_x86);$(WindowsSdk_71A_LibraryPath_x86);</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Profile|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<OutDir>..\..\..\bin\</OutDir>
|
||||
<GenerateManifest>false</GenerateManifest>
|
||||
<IncludePath>..\..\;$(VC_IncludePath);$(WindowsSdk_71A_IncludePath);</IncludePath>
|
||||
<LibraryPath>..\..\libs\openvr\;$(VC_LibraryPath_x86);$(WindowsSdk_71A_LibraryPath_x86);</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
@@ -102,7 +106,7 @@
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>opengl32.lib;winmm.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalDependencies>openvr_api.lib;opengl32.lib;winmm.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Editor|Win32'">
|
||||
@@ -145,7 +149,7 @@
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalDependencies>wcrt.lib;opengl32.lib;winmm.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalDependencies>wcrt.lib;openvr_api.lib;opengl32.lib;winmm.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<IgnoreAllDefaultLibraries>true</IgnoreAllDefaultLibraries>
|
||||
<ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
@@ -160,7 +164,7 @@
|
||||
<Optimization>Full</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>PROFILE;MINIMAL;STB_VORBIS_NO_STDIO;NOMINMAX;_CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>PROFILE;MINIMAL;NOMINMAX;_CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ExceptionHandling>false</ExceptionHandling>
|
||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
@@ -175,7 +179,7 @@
|
||||
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalDependencies>wcrt.lib;opengl32.lib;winmm.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalDependencies>wcrt.lib;openvr_api.lib;opengl32.lib;winmm.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<IgnoreAllDefaultLibraries>true</IgnoreAllDefaultLibraries>
|
||||
<ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
@@ -195,6 +199,10 @@
|
||||
<ClInclude Include="..\..\collision.h" />
|
||||
<ClInclude Include="..\..\controller.h" />
|
||||
<ClInclude Include="..\..\core.h" />
|
||||
<ClInclude Include="..\..\gapi_gl.h" />
|
||||
<ClInclude Include="..\..\gapi_gu.h" />
|
||||
<ClInclude Include="..\..\gapi_gx.h" />
|
||||
<ClInclude Include="..\..\gapi_vk.h" />
|
||||
<ClInclude Include="..\..\debug.h" />
|
||||
<ClInclude Include="..\..\enemy.h" />
|
||||
<ClInclude Include="..\..\frustum.h" />
|
||||
|
@@ -37,6 +37,10 @@
|
||||
<ClInclude Include="..\..\format.h" />
|
||||
<ClInclude Include="..\..\trigger.h" />
|
||||
<ClInclude Include="..\..\utils.h" />
|
||||
<ClInclude Include="..\..\gapi_gl.h" />
|
||||
<ClInclude Include="..\..\gapi_gu.h" />
|
||||
<ClInclude Include="..\..\gapi_vk.h" />
|
||||
<ClInclude Include="..\..\gapi_gx.h" />
|
||||
<ClInclude Include="..\..\libs\minimp3\minimp3.h">
|
||||
<Filter>libs\minimp3</Filter>
|
||||
</ClInclude>
|
||||
|
@@ -537,7 +537,8 @@ void vrInit() {
|
||||
void vrInitTargets() {
|
||||
uint32_t width, height;
|
||||
hmd->GetRecommendedRenderTargetSize( &width, &height);
|
||||
Core::initVR(width, height);
|
||||
eyeTex[0] = new Texture(width, height, Texture::RGBA);
|
||||
eyeTex[1] = new Texture(width, height, Texture::RGBA);
|
||||
}
|
||||
|
||||
void vrFree() {
|
||||
|
14
src/shader.h
14
src/shader.h
@@ -87,7 +87,7 @@ struct Shader {
|
||||
|
||||
if (!(Core::support.shaderBinary && linkBinary(fileName))) // try to load cached shader
|
||||
if (linkSource(source, defines) && Core::support.shaderBinary) { // compile shader from source and dump it into cache
|
||||
#ifndef __EMSCRIPTEN__
|
||||
#ifndef _OS_WEB
|
||||
GLenum format, size;
|
||||
glGetProgramiv(ID, GL_PROGRAM_BINARY_LENGTH, (GLsizei*)&size);
|
||||
char *data = new char[8 + size];
|
||||
@@ -103,7 +103,7 @@ struct Shader {
|
||||
}
|
||||
|
||||
bool linkSource(const char *text, const char *defines = "") {
|
||||
#ifdef MOBILE
|
||||
#ifdef _GAPI_GLES
|
||||
#define GLSL_DEFINE ""
|
||||
#define GLSL_VERT ""
|
||||
#define GLSL_FRAG "#extension GL_OES_standard_derivatives : enable\n"
|
||||
@@ -193,13 +193,17 @@ struct Shader {
|
||||
memset(params, 0, sizeof(params));
|
||||
}
|
||||
|
||||
bool bind() {
|
||||
void bind() {
|
||||
if (Core::active.shader != this) {
|
||||
Core::active.shader = this;
|
||||
glUseProgram(ID);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
setParam(uViewProj, Core::mViewProj);
|
||||
setParam(uLightProj, Core::mLightProj[0], Core::settings.detail.shadows > Core::Settings::Quality::MEDIUM ? SHADOW_OBJ_MAX : 1);
|
||||
setParam(uViewPos, Core::viewPos);
|
||||
setParam(uParam, Core::params);
|
||||
setParam(uFogParams, Core::fogParams);
|
||||
}
|
||||
|
||||
void setParam(UniformType uType, const int &value, int count = 1) {
|
||||
|
@@ -6,10 +6,8 @@
|
||||
|
||||
#define DECODE_OGG
|
||||
|
||||
#ifndef _PSP
|
||||
#ifndef __EMSCRIPTEN__
|
||||
#define DECODE_MP3
|
||||
#endif
|
||||
#if !defined(_OS_PSP) && !defined(_OS_WEB)
|
||||
#define DECODE_MP3
|
||||
#endif
|
||||
|
||||
#include "utils.h"
|
||||
|
@@ -5,14 +5,13 @@
|
||||
#include "format.h"
|
||||
|
||||
struct Texture {
|
||||
enum Format { LUMINANCE, RGBA, RGB16, RGBA16, RGBA_FLOAT, RGBA_HALF, DEPTH, DEPTH_STENCIL, SHADOW, MAX };
|
||||
enum Option { CUBEMAP = 1, MIPMAPS = 2, NEAREST = 4 };
|
||||
|
||||
int width, height, origWidth, origHeight;
|
||||
Format format;
|
||||
uint32 opt;
|
||||
|
||||
#ifdef _PSP
|
||||
#ifdef _OS_PSP
|
||||
TR::Tile4 *tiles;
|
||||
TR::CLUT *cluts;
|
||||
uint8 *memory;
|
||||
@@ -41,7 +40,7 @@ struct Texture {
|
||||
|
||||
#ifdef SPLIT_BY_TILE
|
||||
|
||||
#ifdef _PSP
|
||||
#ifdef _OS_PSP
|
||||
Texture(TR::Tile4 *tiles, int tilesCount, TR::CLUT *cluts, int clutsCount) : width(256), height(256), memory(NULL) {
|
||||
#ifdef EDRAM_TEX
|
||||
this->tiles = (TR::Tile4*)Core::allocEDRAM(tilesCount * sizeof(tiles[0]));
|
||||
@@ -69,7 +68,7 @@ struct Texture {
|
||||
#endif
|
||||
|
||||
void bind(uint16 tile, uint16 clut) {
|
||||
#ifdef _PSP
|
||||
#ifdef _OS_PSP
|
||||
int swizzle = GU_FALSE;
|
||||
#ifdef TEX_SWIZZLE
|
||||
swizzle = GU_TRUE;
|
||||
@@ -86,7 +85,7 @@ struct Texture {
|
||||
Texture(int width, int height, Format format, uint32 opt = 0, void *data = NULL) : opt(opt) {
|
||||
// LOG("create texture %d x %d (%d)\n", width, height, format);
|
||||
|
||||
#ifndef _PSP
|
||||
#ifndef _OS_PSP
|
||||
#ifdef SPLIT_BY_TILE
|
||||
memset(this->tiles, 0, sizeof(tiles));
|
||||
#endif
|
||||
@@ -105,37 +104,37 @@ struct Texture {
|
||||
bool filter = (opt & NEAREST) == 0;
|
||||
bool cube = (opt & CUBEMAP) != 0;
|
||||
bool mipmaps = (opt & MIPMAPS) != 0;
|
||||
bool isShadow = format == SHADOW;
|
||||
bool isShadow = format == FMT_SHADOW;
|
||||
|
||||
if (format == SHADOW && !Core::support.shadowSampler) {
|
||||
format = DEPTH;
|
||||
if (format == FMT_SHADOW && !Core::support.shadowSampler) {
|
||||
format = FMT_DEPTH;
|
||||
filter = false;
|
||||
}
|
||||
|
||||
if (format == DEPTH) {
|
||||
if (format == FMT_DEPTH) {
|
||||
if (Core::support.depthTexture)
|
||||
filter = false;
|
||||
else
|
||||
format = RGBA;
|
||||
format = FMT_RGBA;
|
||||
}
|
||||
|
||||
if (format == RGBA_HALF) {
|
||||
if (format == FMT_RGBA_HALF) {
|
||||
if (Core::support.texHalf)
|
||||
filter = filter && Core::support.texHalfLinear;
|
||||
else
|
||||
format = RGBA_FLOAT;
|
||||
format = FMT_RGBA_FLOAT;
|
||||
}
|
||||
|
||||
if (format == RGBA_FLOAT) {
|
||||
if (format == FMT_RGBA_FLOAT) {
|
||||
if (Core::support.texFloat)
|
||||
filter = filter && Core::support.texFloatLinear;
|
||||
else
|
||||
format = RGBA;
|
||||
format = FMT_RGBA;
|
||||
}
|
||||
|
||||
this->format = format;
|
||||
|
||||
#ifdef _PSP
|
||||
#ifdef _OS_PSP
|
||||
if (data) {
|
||||
memory = new uint8[width * height * 4];
|
||||
#ifdef TEX_SWIZZLE
|
||||
@@ -151,7 +150,7 @@ struct Texture {
|
||||
|
||||
GLenum target = (opt & CUBEMAP) ? GL_TEXTURE_CUBE_MAP : GL_TEXTURE_2D;
|
||||
|
||||
if (format == SHADOW) {
|
||||
if (format == FMT_SHADOW) {
|
||||
glTexParameteri(target, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_REF_TO_TEXTURE);
|
||||
glTexParameteri(target, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL);
|
||||
}
|
||||
@@ -170,7 +169,7 @@ struct Texture {
|
||||
struct FormatDesc {
|
||||
GLuint ifmt, fmt;
|
||||
GLenum type;
|
||||
} formats[MAX] = {
|
||||
} formats[FMT_MAX] = {
|
||||
{ GL_LUMINANCE, GL_LUMINANCE, GL_UNSIGNED_BYTE }, // LUMINANCE
|
||||
{ GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE }, // RGBA
|
||||
{ GL_RGB, GL_RGB, GL_UNSIGNED_SHORT_5_6_5 }, // RGB16
|
||||
@@ -184,27 +183,25 @@ struct Texture {
|
||||
|
||||
FormatDesc desc = formats[format];
|
||||
|
||||
#ifdef __EMSCRIPTEN__ // fucking firefox!
|
||||
if (format == RGBA_FLOAT) {
|
||||
#ifdef _OS_WEB // fucking firefox!
|
||||
if (format == FMT_RGBA_FLOAT) {
|
||||
if (Core::support.texFloat) {
|
||||
desc.ifmt = GL_RGBA;
|
||||
desc.type = GL_FLOAT;
|
||||
}
|
||||
}
|
||||
|
||||
if (format == RGBA_HALF) {
|
||||
if (format == FMT_RGBA_HALF) {
|
||||
if (Core::support.texHalf) {
|
||||
desc.ifmt = GL_RGBA;
|
||||
#ifdef MOBILE
|
||||
desc.type = GL_HALF_FLOAT_OES;
|
||||
#endif
|
||||
desc.type = GL_HALF_FLOAT_OES;
|
||||
}
|
||||
}
|
||||
#else
|
||||
if ((format == RGBA_FLOAT && !Core::support.colorFloat) || (format == RGBA_HALF && !Core::support.colorHalf)) {
|
||||
if ((format == FMT_RGBA_FLOAT && !Core::support.colorFloat) || (format == FMT_RGBA_HALF && !Core::support.colorHalf)) {
|
||||
desc.ifmt = GL_RGBA;
|
||||
#ifdef MOBILE
|
||||
if (format == RGBA_HALF)
|
||||
#ifdef _GAPI_GLES
|
||||
if (format == FMT_RGBA_HALF)
|
||||
desc.type = GL_HALF_FLOAT_OES;
|
||||
#endif
|
||||
}
|
||||
@@ -226,7 +223,7 @@ struct Texture {
|
||||
}
|
||||
|
||||
void generateMipMap() {
|
||||
#ifdef _PSP
|
||||
#ifdef _OS_PSP
|
||||
// TODO
|
||||
#else
|
||||
bind(0);
|
||||
@@ -240,7 +237,7 @@ struct Texture {
|
||||
}
|
||||
|
||||
virtual ~Texture() {
|
||||
#ifdef _PSP
|
||||
#ifdef _OS_PSP
|
||||
delete[] memory;
|
||||
#else
|
||||
#ifdef SPLIT_BY_TILE
|
||||
@@ -258,7 +255,7 @@ struct Texture {
|
||||
bool filter = value > Core::Settings::LOW;
|
||||
bool mipmaps = value > Core::Settings::MEDIUM;
|
||||
|
||||
#ifdef _PSP
|
||||
#ifdef _OS_PSP
|
||||
if (filter)
|
||||
opt &= ~NEAREST;
|
||||
else
|
||||
@@ -279,7 +276,7 @@ struct Texture {
|
||||
}
|
||||
|
||||
void bind(int sampler) {
|
||||
#ifdef _PSP
|
||||
#ifdef _OS_PSP
|
||||
if (this && !sampler && memory) {
|
||||
int swizzle = GU_FALSE;
|
||||
#ifdef TEX_SWIZZLE
|
||||
@@ -302,7 +299,7 @@ struct Texture {
|
||||
}
|
||||
|
||||
void unbind(int sampler) {
|
||||
#ifdef _PSP
|
||||
#ifdef _OS_PSP
|
||||
//
|
||||
#else
|
||||
if (Core::active.textures[sampler]) {
|
||||
@@ -821,7 +818,7 @@ struct Texture {
|
||||
((uint32*)data)[y * dw] = ((uint32*)data)[y * dw + dw - 1] = 0xFF000000;
|
||||
}
|
||||
|
||||
Texture *tex = new Texture(dw, dh, Texture::RGBA, 0, data);
|
||||
Texture *tex = new Texture(dw, dh, FMT_RGBA, 0, data);
|
||||
tex->origWidth = width;
|
||||
tex->origHeight = height;
|
||||
|
||||
@@ -983,7 +980,7 @@ struct Atlas {
|
||||
fill(root, data);
|
||||
fillInstances();
|
||||
|
||||
Texture *atlas = new Texture(width, height, Texture::RGBA, Texture::MIPMAPS, data);
|
||||
Texture *atlas = new Texture(width, height, FMT_RGBA, Texture::MIPMAPS, data);
|
||||
|
||||
//Texture::SaveBMP("atlas.bmp", (char*)data, width, height);
|
||||
|
||||
|
@@ -762,7 +762,7 @@ struct Crystal : Controller {
|
||||
Texture *environment;
|
||||
|
||||
Crystal(IGame *game, int entity) : Controller(game, entity) {
|
||||
environment = new Texture(64, 64, Texture::RGBA, Texture::CUBEMAP | Texture::MIPMAPS);
|
||||
environment = new Texture(64, 64, FMT_RGBA, Texture::CUBEMAP | Texture::MIPMAPS);
|
||||
activate();
|
||||
}
|
||||
|
||||
@@ -1172,15 +1172,15 @@ struct Lightning : Controller {
|
||||
Core::active.shader->setParam(uMaterial, vec4(0.0f, 0.0f, 0.0f, 1.0f));
|
||||
Core::active.shader->setParam(uBasis, b);
|
||||
|
||||
Core::setCulling(cfNone);
|
||||
Core::setBlending(bmAdd);
|
||||
Core::setCullMode(cmNone);
|
||||
Core::setBlendMode(bmAdd);
|
||||
Core::setDepthWrite(false);
|
||||
|
||||
renderPolyline(vec3(0.0f), target - b.pos, 64.0f, 512.0f, 1);
|
||||
|
||||
Core::setDepthWrite(true);
|
||||
Core::setBlending(bmNone);
|
||||
Core::setCulling(cfFront);
|
||||
Core::setBlendMode(bmNone);
|
||||
Core::setCullMode(cmFront);
|
||||
}
|
||||
};
|
||||
|
||||
|
16
src/ui.h
16
src/ui.h
@@ -287,8 +287,8 @@ namespace UI {
|
||||
|
||||
void begin() {
|
||||
Core::setDepthTest(false);
|
||||
Core::setBlending(bmAlpha);
|
||||
Core::setCulling(cfNone);
|
||||
Core::setBlendMode(bmAlpha);
|
||||
Core::setCullMode(cmNone);
|
||||
game->setupBinding();
|
||||
|
||||
Core::mView.identity();
|
||||
@@ -318,8 +318,8 @@ namespace UI {
|
||||
|
||||
void end() {
|
||||
flush();
|
||||
Core::setCulling(cfFront);
|
||||
Core::setBlending(bmNone);
|
||||
Core::setCullMode(cmFront);
|
||||
Core::setBlendMode(bmNone);
|
||||
Core::setDepthTest(true);
|
||||
}
|
||||
|
||||
@@ -487,8 +487,8 @@ namespace UI {
|
||||
if (Input::touchTimerVis <= 0.0f) return;
|
||||
|
||||
Core::setDepthTest(false);
|
||||
Core::setBlending(bmAlpha);
|
||||
Core::setCulling(cfNone);
|
||||
Core::setBlendMode(bmAlpha);
|
||||
Core::setCullMode(cmNone);
|
||||
|
||||
Core::mViewProj = mat4(0.0f, float(Core::width), float(Core::height), 0.0f, 0.0f, 1.0f);
|
||||
|
||||
@@ -507,8 +507,8 @@ namespace UI {
|
||||
for (int i = Input::bWeapon; i < Input::bMAX; i++)
|
||||
renderControl(Input::btnPos[i], Input::btnRadius, Input::btn == i);
|
||||
|
||||
Core::setCulling(cfFront);
|
||||
Core::setBlending(bmNone);
|
||||
Core::setCullMode(cmFront);
|
||||
Core::setBlendMode(bmNone);
|
||||
Core::setDepthTest(true);
|
||||
}
|
||||
|
||||
|
14
src/utils.h
14
src/utils.h
@@ -6,7 +6,7 @@
|
||||
#include <float.h>
|
||||
|
||||
#ifdef _DEBUG
|
||||
#ifdef LINUX
|
||||
#ifdef _OS_LINUX
|
||||
#define debugBreak() raise(SIGTRAP);
|
||||
#else
|
||||
#define debugBreak() _asm { int 3 }
|
||||
@@ -14,13 +14,13 @@
|
||||
|
||||
#define ASSERT(expr) if (expr) {} else { LOG("ASSERT:\n %s:%d\n %s => %s\n", __FILE__, __LINE__, __FUNCTION__, #expr); debugBreak(); }
|
||||
|
||||
#ifndef ANDROID
|
||||
#ifndef _OS_ANDROID
|
||||
#define LOG(...) printf(__VA_ARGS__)
|
||||
#endif
|
||||
|
||||
#else
|
||||
#define ASSERT(expr)
|
||||
#ifdef LINUX
|
||||
#ifdef _OS_LINUX
|
||||
#define LOG(...) printf(__VA_ARGS__); fflush(stdout)
|
||||
#else
|
||||
#define LOG(...) printf(__VA_ARGS__)
|
||||
@@ -28,13 +28,13 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef ANDROID
|
||||
#ifdef _OS_ANDROID
|
||||
#include <android/log.h>
|
||||
#undef LOG
|
||||
#define LOG(...) __android_log_print(ANDROID_LOG_INFO,"OpenLara",__VA_ARGS__)
|
||||
#endif
|
||||
|
||||
#ifdef _PSP
|
||||
#ifdef _OS_PSP
|
||||
extern "C" {
|
||||
// pspmath.h
|
||||
extern float vfpu_sinf(float x);
|
||||
@@ -1153,7 +1153,7 @@ extern void osCacheRead (Stream *stream);
|
||||
extern void osSaveGame (Stream *stream);
|
||||
extern void osLoadGame (Stream *stream);
|
||||
|
||||
#ifdef __EMSCRIPTEN__
|
||||
#ifdef _OS_WEB
|
||||
extern void osDownload (Stream *stream);
|
||||
#endif
|
||||
|
||||
@@ -1190,7 +1190,7 @@ struct Stream {
|
||||
f = fopen(name, "rb");
|
||||
|
||||
if (!f) {
|
||||
#ifdef __EMSCRIPTEN__
|
||||
#ifdef _OS_WEB
|
||||
if (name) {
|
||||
this->name = new char[strlen(name) + 1];
|
||||
strcpy(this->name, name);
|
||||
|
Reference in New Issue
Block a user