diff --git a/group/librw.mmh b/group/librw.mmh index 1eba534..b38f518 100644 --- a/group/librw.mmh +++ b/group/librw.mmh @@ -14,7 +14,7 @@ SOURCE engine.cpp error.cpp frame.cpp geometry.cpp geoplg.cpp SOURCEPATH ../vendor/librw/src/gl SOURCE gl3.cpp gl3device.cpp gl3immed.cpp gl3matfx.cpp gl3pipe.cpp gl3raster.cpp gl3render.cpp gl3shader.cpp gl3skin.cpp wdgl.cpp SOURCEPATH ../vendor/librw/src/gles1 -SOURCE gl1.cpp gl1device.cpp gl1immed.cpp gl1pipe.cpp gl1raster.cpp gl1render.cpp +SOURCE gl1.cpp gl1device.cpp gl1immed.cpp gl1matfx.cpp gl1pipe.cpp gl1raster.cpp gl1render.cpp gl1skin.cpp SOURCEPATH ../vendor/librw/src SOURCE hanim.cpp image.cpp light.cpp SOURCEPATH ../vendor/librw/src/lodepng diff --git a/vendor/librw/src/gles1/gl1device.cpp b/vendor/librw/src/gles1/gl1device.cpp index 1dd9b6f..790dd5d 100644 --- a/vendor/librw/src/gles1/gl1device.cpp +++ b/vendor/librw/src/gles1/gl1device.cpp @@ -1033,9 +1033,7 @@ setMaterial(const RGBA &color, const SurfaceProperties &surfaceprops, float extr glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, specular); } -void -flushCache(void) -{ +void flushCache(void){ flushGlRenderState(); if(uniformStateDirty[RWGL_ALPHAFUNC] || uniformStateDirty[RWGL_ALPHAREF]){ diff --git a/vendor/librw/src/gles1/gl1matfx.cpp b/vendor/librw/src/gles1/gl1matfx.cpp new file mode 100644 index 0000000..b6a8f77 --- /dev/null +++ b/vendor/librw/src/gles1/gl1matfx.cpp @@ -0,0 +1,86 @@ +#include +#include +#include +#include + +#include "../rwbase.h" +#include "../rwplg.h" +#include "../rwpipeline.h" +#include "../rwobjects.h" +#include "../rwengine.h" +#include "../rwrender.h" +#include "../rwanim.h" +#include "../rwplugins.h" +#include "rwgles1.h" +#include "rwgles1plg.h" +#include "rwgles1impl.h" + +#ifdef RW_GLES1 + +namespace rw { +namespace gles1 { + +void +matfxRenderCB(Atomic *atomic, InstanceDataHeader *header) +{ + uint32 flags = atomic->geometry->flags; + setWorldMatrix(atomic->getFrame()->getLTM()); + glDisable(GL_LIGHTING); + + setupVertexInput(header); + + InstanceData *inst = header->inst; + int32 n = header->numMeshes; + + while(n--){ + MatFX *matfx = MatFX::get(inst->material); + Material *m = inst->material; + + // En GLES1 sin shaders: ignoramos env map, solo dibujamos textura base + setMaterial(flags, m->color, m->surfaceProps); + setTexture(0, m->texture); + rw::SetRenderState(VERTEXALPHA, inst->vertexAlpha || m->color.alpha != 0xFF); + drawInst(header, inst); + inst++; + } + + teardownVertexInput(header); +} + +ObjPipeline* +makeMatFXPipeline(void) +{ + ObjPipeline *pipe = ObjPipeline::create(); + pipe->instanceCB = defaultInstanceCB; + pipe->uninstanceCB = defaultUninstanceCB; + pipe->renderCB = matfxRenderCB; + pipe->pluginID = ID_MATFX; + pipe->pluginData = 0; + return pipe; +} + +static void* +matfxOpen(void *o, int32, int32) +{ + matFXGlobals.pipelines[PLATFORM_GLES1] = makeMatFXPipeline(); + return o; +} + +static void* +matfxClose(void *o, int32, int32) +{ + ((ObjPipeline*)matFXGlobals.pipelines[PLATFORM_GLES1])->destroy(); + matFXGlobals.pipelines[PLATFORM_GLES1] = nil; + return o; +} + +void +initMatFX(void) +{ + Driver::registerPlugin(PLATFORM_GLES1, 0, ID_MATFX, matfxOpen, matfxClose); +} + +} +} + +#endif diff --git a/vendor/librw/src/gles1/gl1pipe.cpp b/vendor/librw/src/gles1/gl1pipe.cpp index 27b2b59..4750375 100644 --- a/vendor/librw/src/gles1/gl1pipe.cpp +++ b/vendor/librw/src/gles1/gl1pipe.cpp @@ -127,9 +127,7 @@ uninstance(rw::ObjPipeline *rwpipe, Atomic *atomic) assert(0 && "can't uninstance"); } -static void -render(rw::ObjPipeline *rwpipe, Atomic *atomic) -{ +static void render(rw::ObjPipeline *rwpipe, Atomic *atomic){ ObjPipeline *pipe = (ObjPipeline*)rwpipe; Geometry *geo = atomic->geometry; pipe->instance(atomic); @@ -137,6 +135,10 @@ render(rw::ObjPipeline *rwpipe, Atomic *atomic) assert(geo->instData->platform == PLATFORM_GLES1); if(pipe->renderCB) pipe->renderCB(atomic, (InstanceDataHeader*)geo->instData); + else { + FILE *f = fopen("E:\\re3_debug.txt", "a"); + if(f){ fprintf(f, "render: renderCB is nil!\n"); fclose(f); } + } } void diff --git a/vendor/librw/src/gles1/gl1skin.cpp b/vendor/librw/src/gles1/gl1skin.cpp new file mode 100644 index 0000000..901923d --- /dev/null +++ b/vendor/librw/src/gles1/gl1skin.cpp @@ -0,0 +1,98 @@ +#include +#include +#include +#include + +#include "../rwbase.h" +#include "../rwplg.h" +#include "../rwpipeline.h" +#include "../rwobjects.h" +#include "../rwengine.h" +#include "../rwrender.h" +#include "../rwanim.h" +#include "../rwplugins.h" +#include "rwgles1.h" +#include "rwgles1plg.h" +#include "rwgles1impl.h" + +#ifdef RW_GLES1 + +namespace rw { +namespace gles1 { + +void +skinRenderCB(Atomic *atomic, InstanceDataHeader *header) +{ + Material *m; + uint32 flags = atomic->geometry->flags; + setWorldMatrix(atomic->getFrame()->getLTM()); + glDisable(GL_LIGHTING); + + setupVertexInput(header); + + InstanceData *inst = header->inst; + int32 n = header->numMeshes; + + while(n--){ + m = inst->material; + setMaterial(flags, m->color, m->surfaceProps); + setTexture(0, m->texture); + rw::SetRenderState(VERTEXALPHA, inst->vertexAlpha || m->color.alpha != 0xFF); + drawInst(header, inst); + inst++; + } + + teardownVertexInput(header); +} + +// skinInstanceCB: igual que defaultInstanceCB, sin pesos/indices +// porque GLES1 no puede hacer skinning en GPU +void +skinInstanceCB(Geometry *geo, InstanceDataHeader *header, bool32 reinstance) +{ + defaultInstanceCB(geo, header, reinstance); +} + +void +skinUninstanceCB(Geometry *geo, InstanceDataHeader *header) +{ + assert(0 && "can't uninstance"); +} + +ObjPipeline* +makeSkinPipeline(void) +{ + ObjPipeline *pipe = ObjPipeline::create(); + pipe->instanceCB = skinInstanceCB; + pipe->uninstanceCB = skinUninstanceCB; + pipe->renderCB = skinRenderCB; + pipe->pluginID = ID_SKIN; + pipe->pluginData = 1; + return pipe; +} + +static void* +skinOpen(void *o, int32, int32) +{ + skinGlobals.pipelines[PLATFORM_GLES1] = makeSkinPipeline(); + return o; +} + +static void* +skinClose(void *o, int32, int32) +{ + ((ObjPipeline*)skinGlobals.pipelines[PLATFORM_GLES1])->destroy(); + skinGlobals.pipelines[PLATFORM_GLES1] = nil; + return o; +} + +void +initSkin(void) +{ + Driver::registerPlugin(PLATFORM_GLES1, 0, ID_SKIN, skinOpen, skinClose); +} + +} +} + +#endif \ No newline at end of file diff --git a/vendor/librw/src/gles1/rwgles1plg.h b/vendor/librw/src/gles1/rwgles1plg.h new file mode 100644 index 0000000..8738929 --- /dev/null +++ b/vendor/librw/src/gles1/rwgles1plg.h @@ -0,0 +1,13 @@ +namespace rw { + namespace gles1 { + void initMatFX(void); + ObjPipeline *makeMatFXPipeline(void); + void matfxRenderCB(Atomic *atomic, InstanceDataHeader *header); + + void initSkin(void); + ObjPipeline *makeSkinPipeline(void); + void skinInstanceCB(Geometry *geo, InstanceDataHeader *header, bool32 reinstance); + void skinRenderCB(Atomic *atomic, InstanceDataHeader *header); + void uploadSkinMatrices(Atomic *atomic); + } +} \ No newline at end of file diff --git a/vendor/librw/src/matfx.cpp b/vendor/librw/src/matfx.cpp index c143fc1..d0ed0be 100644 --- a/vendor/librw/src/matfx.cpp +++ b/vendor/librw/src/matfx.cpp @@ -19,6 +19,8 @@ #include "gl/rwwdgl.h" #include "gl/rwgl3.h" #include "gl/rwgl3plg.h" +#include "gles1/rwgles1.h" +#include "gles1/rwgles1plg.h" #define PLUGIN_ID ID_MATFX @@ -619,6 +621,7 @@ registerMatFXPlugin(void) d3d9::initMatFX(); wdgl::initMatFX(); gl3::initMatFX(); + gles1::initMatFX(); matFXGlobals.atomicOffset = Atomic::registerPlugin(sizeof(int32), ID_MATFX, diff --git a/vendor/librw/src/skin.cpp b/vendor/librw/src/skin.cpp index abaa548..da8aee9 100644 --- a/vendor/librw/src/skin.cpp +++ b/vendor/librw/src/skin.cpp @@ -19,6 +19,8 @@ #include "gl/rwwdgl.h" #include "gl/rwgl3.h" #include "gl/rwgl3plg.h" +#include "gles1/rwgles1.h" +#include "gles1/rwgles1plg.h" #define PLUGIN_ID ID_SKIN @@ -373,6 +375,7 @@ registerSkinPlugin(void) d3d9::initSkin(); wdgl::initSkin(); gl3::initSkin(); + gles1::initSkin(); int32 o; o = Geometry::registerPlugin(sizeof(Skin*), ID_SKIN,