mirror of
https://github.com/XProger/OpenLara.git
synced 2025-08-13 08:34:32 +02:00
#15 web version - add dummy files for local file cache
This commit is contained in:
@@ -34,10 +34,10 @@ const char GUI[] =
|
||||
struct ShaderCache {
|
||||
enum Effect { FX_NONE = 0, FX_UNDERWATER = 1, FX_ALPHA_TEST = 2, FX_CLIP_PLANE = 4 };
|
||||
|
||||
IGame *game;
|
||||
MeshBuilder *mesh;
|
||||
Shader *shaders[Core::passMAX][Shader::MAX][(FX_UNDERWATER | FX_ALPHA_TEST | FX_CLIP_PLANE) + 1];
|
||||
|
||||
ShaderCache(IGame *game) : game(game) {
|
||||
ShaderCache(MeshBuilder *mesh) : mesh(mesh) {
|
||||
memset(shaders, 0, sizeof(shaders));
|
||||
|
||||
LOG("shader: cache warm up...\n");
|
||||
@@ -129,8 +129,8 @@ struct ShaderCache {
|
||||
|
||||
src = SHADER;
|
||||
typ = typeNames[type];
|
||||
int animTexRangesCount = game->getMesh()->animTexRangesCount;
|
||||
int animTexOffsetsCount = game->getMesh()->animTexOffsetsCount;
|
||||
int animTexRangesCount = mesh->animTexRangesCount;
|
||||
int animTexOffsetsCount = mesh->animTexOffsetsCount;
|
||||
sprintf(def, "%s#define PASS_%s\n#define TYPE_%s\n#define MAX_LIGHTS %d\n#define MAX_RANGES %d\n#define MAX_OFFSETS %d\n#define MAX_CONTACTS %d\n#define FOG_DIST (1.0/%d.0)\n#define WATER_FOG_DIST (1.0/%d.0)\n#define SHADOW_TEX_SIZE %d.0\n", ext, passNames[pass], typ, MAX_LIGHTS, animTexRangesCount, animTexOffsetsCount, MAX_CONTACTS, FOG_DIST, WATER_FOG_DIST, SHADOW_TEX_SIZE);
|
||||
if (fx & FX_UNDERWATER) strcat(def, "#define UNDERWATER\n" UNDERWATER_COLOR);
|
||||
if (fx & FX_ALPHA_TEST) strcat(def, "#define ALPHA_TEST\n");
|
||||
@@ -184,7 +184,6 @@ struct ShaderCache {
|
||||
shader->setParam(uLightProj, Core::mLightProj);
|
||||
shader->setParam(uViewPos, Core::viewPos);
|
||||
shader->setParam(uParam, Core::params);
|
||||
MeshBuilder *mesh = game->getMesh();
|
||||
shader->setParam(uAnimTexRanges, mesh->animTexRanges[0], mesh->animTexRangesCount);
|
||||
shader->setParam(uAnimTexOffsets, mesh->animTexOffsets[0], mesh->animTexOffsetsCount);
|
||||
}
|
||||
|
@@ -55,6 +55,7 @@ struct Level : IGame {
|
||||
// IGame implementation ========
|
||||
virtual void loadLevel(TR::LevelID id) {
|
||||
if (isEnded) return;
|
||||
Sound::stopAll();
|
||||
|
||||
isEnded = true;
|
||||
char buf[64];
|
||||
@@ -258,7 +259,7 @@ struct Level : IGame {
|
||||
initTextures();
|
||||
mesh = new MeshBuilder(level);
|
||||
|
||||
shaderCache = new ShaderCache(this);
|
||||
shaderCache = new ShaderCache(mesh);
|
||||
initOverrides();
|
||||
|
||||
for (int i = 0; i < level.entitiesBaseCount; i++) {
|
||||
@@ -1447,6 +1448,7 @@ struct Level : IGame {
|
||||
lastTitle = title;
|
||||
|
||||
if (isEnded) {
|
||||
Core::setTarget(NULL, true);
|
||||
UI::begin();
|
||||
UI::textOut(vec2(0, 480 - 16), STR_LOADING, UI::aCenter, UI::width);
|
||||
UI::end();
|
||||
|
0
src/platform/web/audio/dummy
Normal file
0
src/platform/web/audio/dummy
Normal file
@@ -4,5 +4,5 @@ set SRC=main.cpp ../../libs/stb_vorbis/stb_vorbis.c
|
||||
set PROJ=OpenLara
|
||||
set FLAGS=-O3 -Wno-deprecated-register --llvm-opts 2 -fmax-type-align=2 -std=c++11 -Wall -I../../
|
||||
echo.
|
||||
call em++ %SRC% %FLAGS% -o %PROJ%.js --preload-file ./level/TITLE.PSX --preload-file ./level/TITLEH.PCX
|
||||
call em++ %SRC% %FLAGS% -o %PROJ%.js --preload-file ./level/TITLE.PSX --preload-file ./level/TITLEH.PCX --preload-file ./audio/dummy
|
||||
gzip.exe -9 -f %PROJ%.data %PROJ%.js %PROJ%.js.mem
|
0
src/platform/web/level/dummy
Normal file
0
src/platform/web/level/dummy
Normal file
@@ -236,30 +236,34 @@ EM_BOOL mouseCallback(int eventType, const EmscriptenMouseEvent *e, void *userDa
|
||||
const char *IDB = "db";
|
||||
|
||||
void onError(void *str) {
|
||||
LOG("! IDB error: %s\n", str);
|
||||
LOG("! IDB error: %s\n", str);
|
||||
}
|
||||
|
||||
void onLoad(void *arg, void *data, int size) {
|
||||
Stream *stream = (Stream*)arg;
|
||||
stream->data = (char*)data;
|
||||
stream->size = size;
|
||||
stream->callback(stream, stream->userData);
|
||||
Stream *stream = (Stream*)arg;
|
||||
|
||||
FILE *f = fopen(stream->name, "wb");
|
||||
fwrite(data, size, 1, f);
|
||||
fclose(f);
|
||||
|
||||
stream->callback(new Stream(stream->name), stream->userData);
|
||||
delete stream;
|
||||
}
|
||||
|
||||
void onLoadAndStore(void *arg, void *data, int size) {
|
||||
onLoad(arg, data, size);
|
||||
emscripten_idb_async_store(IDB, ((Stream*)arg)->name, data, size, NULL, NULL, onError);
|
||||
emscripten_idb_async_store(IDB, ((Stream*)arg)->name, data, size, NULL, NULL, onError);
|
||||
onLoad(arg, data, size);
|
||||
}
|
||||
|
||||
void onExists(void *arg, int exists) {
|
||||
if (exists)
|
||||
emscripten_idb_async_load(IDB, ((Stream*)arg)->name, arg, onLoad, onError);
|
||||
else
|
||||
emscripten_async_wget_data(((Stream*)arg)->name, arg, onLoadAndStore, onError);
|
||||
if (exists)
|
||||
emscripten_idb_async_load(IDB, ((Stream*)arg)->name, arg, onLoad, onError);
|
||||
else
|
||||
emscripten_async_wget_data(((Stream*)arg)->name, arg, onLoadAndStore, onError);
|
||||
}
|
||||
|
||||
void osDownload(Stream *stream) {
|
||||
emscripten_idb_async_exists(IDB, stream->name, stream, onExists, onError);
|
||||
emscripten_idb_async_exists(IDB, stream->name, stream, onExists, onError);
|
||||
}
|
||||
|
||||
char Stream::cacheDir[255];
|
||||
|
Reference in New Issue
Block a user