changed pipe new to explicit create
This commit is contained in:
parent
5e299fb12e
commit
2568e77fac
@ -344,9 +344,10 @@ render(rw::ObjPipeline *rwpipe, Atomic *atomic)
|
||||
pipe->renderCB(atomic, (InstanceDataHeader*)geo->instData);
|
||||
}
|
||||
|
||||
ObjPipeline::ObjPipeline(uint32 platform)
|
||||
: rw::ObjPipeline(platform)
|
||||
void
|
||||
ObjPipeline::init(void)
|
||||
{
|
||||
this->rw::ObjPipeline::init(PLATFORM_D3D8);
|
||||
this->impl.instance = d3d8::instance;
|
||||
this->impl.uninstance = d3d8::uninstance;
|
||||
this->impl.render = d3d8::render;
|
||||
@ -355,6 +356,14 @@ ObjPipeline::ObjPipeline(uint32 platform)
|
||||
this->renderCB = nil;
|
||||
}
|
||||
|
||||
ObjPipeline*
|
||||
ObjPipeline::create(void)
|
||||
{
|
||||
ObjPipeline *pipe = rwNewT(ObjPipeline, 1, MEMDUR_GLOBAL);
|
||||
pipe->init();
|
||||
return pipe;
|
||||
}
|
||||
|
||||
void
|
||||
defaultInstanceCB(Geometry *geo, InstanceData *inst)
|
||||
{
|
||||
@ -428,7 +437,7 @@ defaultUninstanceCB(Geometry *geo, InstanceData *inst)
|
||||
ObjPipeline*
|
||||
makeDefaultPipeline(void)
|
||||
{
|
||||
ObjPipeline *pipe = new ObjPipeline(PLATFORM_D3D8);
|
||||
ObjPipeline *pipe = ObjPipeline::create();
|
||||
pipe->instanceCB = defaultInstanceCB;
|
||||
pipe->uninstanceCB = defaultUninstanceCB;
|
||||
pipe->renderCB = defaultRenderCB;
|
||||
|
@ -28,6 +28,8 @@ matfxOpen(void *o, int32, int32)
|
||||
static void*
|
||||
matfxClose(void *o, int32, int32)
|
||||
{
|
||||
((ObjPipeline*)matFXGlobals.pipelines[PLATFORM_D3D8])->destroy();
|
||||
matFXGlobals.pipelines[PLATFORM_D3D8] = nil;
|
||||
return o;
|
||||
}
|
||||
|
||||
@ -41,7 +43,7 @@ initMatFX(void)
|
||||
ObjPipeline*
|
||||
makeMatFXPipeline(void)
|
||||
{
|
||||
ObjPipeline *pipe = new ObjPipeline(PLATFORM_D3D8);
|
||||
ObjPipeline *pipe = ObjPipeline::create();
|
||||
pipe->instanceCB = defaultInstanceCB;
|
||||
pipe->uninstanceCB = defaultUninstanceCB;
|
||||
pipe->renderCB = defaultRenderCB;
|
||||
|
@ -28,6 +28,8 @@ skinOpen(void *o, int32, int32)
|
||||
static void*
|
||||
skinClose(void *o, int32, int32)
|
||||
{
|
||||
((ObjPipeline*)skinGlobals.pipelines[PLATFORM_D3D8])->destroy();
|
||||
skinGlobals.pipelines[PLATFORM_D3D8] = nil;
|
||||
return o;
|
||||
}
|
||||
|
||||
@ -41,7 +43,7 @@ initSkin(void)
|
||||
ObjPipeline*
|
||||
makeSkinPipeline(void)
|
||||
{
|
||||
ObjPipeline *pipe = new ObjPipeline(PLATFORM_D3D8);
|
||||
ObjPipeline *pipe = ObjPipeline::create();
|
||||
pipe->instanceCB = defaultInstanceCB;
|
||||
pipe->uninstanceCB = defaultUninstanceCB;
|
||||
pipe->renderCB = defaultRenderCB;
|
||||
|
@ -464,9 +464,10 @@ render(rw::ObjPipeline *rwpipe, Atomic *atomic)
|
||||
pipe->renderCB(atomic, (InstanceDataHeader*)geo->instData);
|
||||
}
|
||||
|
||||
ObjPipeline::ObjPipeline(uint32 platform)
|
||||
: rw::ObjPipeline(platform)
|
||||
void
|
||||
ObjPipeline::init(void)
|
||||
{
|
||||
this->rw::ObjPipeline::init(PLATFORM_D3D9);
|
||||
this->impl.instance = d3d9::instance;
|
||||
this->impl.uninstance = d3d9::uninstance;
|
||||
this->impl.render = d3d9::render;
|
||||
@ -475,6 +476,14 @@ ObjPipeline::ObjPipeline(uint32 platform)
|
||||
this->renderCB = nil;
|
||||
}
|
||||
|
||||
ObjPipeline*
|
||||
ObjPipeline::create(void)
|
||||
{
|
||||
ObjPipeline *pipe = rwNewT(ObjPipeline, 1, MEMDUR_GLOBAL);
|
||||
pipe->init();
|
||||
return pipe;
|
||||
}
|
||||
|
||||
void
|
||||
defaultInstanceCB(Geometry *geo, InstanceDataHeader *header, bool32 reinstance)
|
||||
{
|
||||
@ -682,7 +691,7 @@ defaultUninstanceCB(Geometry *geo, InstanceDataHeader *header)
|
||||
ObjPipeline*
|
||||
makeDefaultPipeline(void)
|
||||
{
|
||||
ObjPipeline *pipe = new ObjPipeline(PLATFORM_D3D9);
|
||||
ObjPipeline *pipe = ObjPipeline::create();
|
||||
pipe->instanceCB = defaultInstanceCB;
|
||||
pipe->uninstanceCB = defaultUninstanceCB;
|
||||
pipe->renderCB = defaultRenderCB_Shader;
|
||||
|
@ -274,6 +274,8 @@ matfxClose(void *o, int32, int32)
|
||||
destroyMatFXShaders();
|
||||
#endif
|
||||
|
||||
((ObjPipeline*)matFXGlobals.pipelines[PLATFORM_D3D9])->destroy();
|
||||
matFXGlobals.pipelines[PLATFORM_D3D9] = nil;
|
||||
return o;
|
||||
}
|
||||
|
||||
@ -287,7 +289,7 @@ initMatFX(void)
|
||||
ObjPipeline*
|
||||
makeMatFXPipeline(void)
|
||||
{
|
||||
ObjPipeline *pipe = new ObjPipeline(PLATFORM_D3D9);
|
||||
ObjPipeline *pipe = ObjPipeline::create();
|
||||
pipe->instanceCB = defaultInstanceCB;
|
||||
pipe->uninstanceCB = defaultUninstanceCB;
|
||||
pipe->renderCB = matfxRenderCB_Shader;
|
||||
|
@ -366,6 +366,8 @@ skinClose(void *o, int32, int32)
|
||||
destroySkinShaders();
|
||||
#endif
|
||||
|
||||
((ObjPipeline*)skinGlobals.pipelines[PLATFORM_D3D9])->destroy();
|
||||
skinGlobals.pipelines[PLATFORM_D3D9] = nil;
|
||||
return o;
|
||||
}
|
||||
|
||||
@ -379,7 +381,7 @@ initSkin(void)
|
||||
ObjPipeline*
|
||||
makeSkinPipeline(void)
|
||||
{
|
||||
ObjPipeline *pipe = new ObjPipeline(PLATFORM_D3D9);
|
||||
ObjPipeline *pipe = ObjPipeline::create();
|
||||
pipe->instanceCB = skinInstanceCB;
|
||||
pipe->uninstanceCB = nil;
|
||||
pipe->renderCB = skinRenderCB;
|
||||
|
@ -40,11 +40,12 @@ void registerNativeDataPlugin(void);
|
||||
class ObjPipeline : public rw::ObjPipeline
|
||||
{
|
||||
public:
|
||||
void init(void);
|
||||
static ObjPipeline *create(void);
|
||||
|
||||
void (*instanceCB)(Geometry *geo, InstanceData *header);
|
||||
void (*uninstanceCB)(Geometry *geo, InstanceData *header);
|
||||
void (*renderCB)(Atomic *atomic, InstanceDataHeader *header);
|
||||
|
||||
ObjPipeline(uint32 platform);
|
||||
};
|
||||
|
||||
void defaultInstanceCB(Geometry *geo, InstanceData *header);
|
||||
|
@ -73,11 +73,12 @@ void registerNativeDataPlugin(void);
|
||||
class ObjPipeline : public rw::ObjPipeline
|
||||
{
|
||||
public:
|
||||
void init(void);
|
||||
static ObjPipeline *create(void);
|
||||
|
||||
void (*instanceCB)(Geometry *geo, InstanceDataHeader *header, bool32 reinstance);
|
||||
void (*uninstanceCB)(Geometry *geo, InstanceDataHeader *header);
|
||||
void (*renderCB)(Atomic *atomic, InstanceDataHeader *header);
|
||||
|
||||
ObjPipeline(uint32 platform);
|
||||
};
|
||||
|
||||
void defaultInstanceCB(Geometry *geo, InstanceDataHeader *header, bool32 reinstance);
|
||||
|
@ -41,10 +41,11 @@ void registerNativeDataPlugin(void);
|
||||
class ObjPipeline : public rw::ObjPipeline
|
||||
{
|
||||
public:
|
||||
void init(void);
|
||||
static ObjPipeline *create(void);
|
||||
|
||||
void (*instanceCB)(Geometry *geo, InstanceDataHeader *header);
|
||||
void (*uninstanceCB)(Geometry *geo, InstanceDataHeader *header);
|
||||
|
||||
ObjPipeline(uint32 platform);
|
||||
};
|
||||
|
||||
ObjPipeline *makeDefaultPipeline(void);
|
||||
|
@ -286,15 +286,23 @@ uninstance(rw::ObjPipeline *rwpipe, Atomic *atomic)
|
||||
destroyNativeData(geo, 0, 0);
|
||||
}
|
||||
|
||||
ObjPipeline::ObjPipeline(uint32 platform)
|
||||
: rw::ObjPipeline(platform)
|
||||
void
|
||||
ObjPipeline::init(void)
|
||||
{
|
||||
this->rw::ObjPipeline::init(PLATFORM_XBOX);
|
||||
this->impl.instance = xbox::instance;
|
||||
this->impl.uninstance = xbox::uninstance;
|
||||
this->instanceCB = nil;
|
||||
this->uninstanceCB = nil;
|
||||
}
|
||||
|
||||
ObjPipeline*
|
||||
ObjPipeline::create(void)
|
||||
{
|
||||
ObjPipeline *pipe = rwNewT(ObjPipeline, 1, MEMDUR_GLOBAL);
|
||||
pipe->init();
|
||||
return pipe;
|
||||
}
|
||||
|
||||
int v3dFormatMap[] = {
|
||||
-1, VERT_BYTE3, VERT_SHORT3, VERT_NORMSHORT3, VERT_COMPNORM, VERT_FLOAT3
|
||||
@ -385,7 +393,7 @@ defaultUninstanceCB(Geometry *geo, InstanceDataHeader *header)
|
||||
ObjPipeline*
|
||||
makeDefaultPipeline(void)
|
||||
{
|
||||
ObjPipeline *pipe = new ObjPipeline(PLATFORM_XBOX);
|
||||
ObjPipeline *pipe = ObjPipeline::create();
|
||||
pipe->instanceCB = defaultInstanceCB;
|
||||
pipe->uninstanceCB = defaultUninstanceCB;
|
||||
return pipe;
|
||||
|
@ -26,6 +26,8 @@ matfxOpen(void *o, int32, int32)
|
||||
static void*
|
||||
matfxClose(void *o, int32, int32)
|
||||
{
|
||||
((ObjPipeline*)matFXGlobals.pipelines[PLATFORM_XBOX])->destroy();
|
||||
matFXGlobals.pipelines[PLATFORM_XBOX] = nil;
|
||||
return o;
|
||||
}
|
||||
|
||||
@ -39,7 +41,7 @@ initMatFX(void)
|
||||
ObjPipeline*
|
||||
makeMatFXPipeline(void)
|
||||
{
|
||||
ObjPipeline *pipe = new ObjPipeline(PLATFORM_XBOX);
|
||||
ObjPipeline *pipe = ObjPipeline::create();
|
||||
pipe->instanceCB = defaultInstanceCB;
|
||||
pipe->uninstanceCB = defaultUninstanceCB;
|
||||
pipe->pluginID = ID_MATFX;
|
||||
|
@ -225,6 +225,8 @@ skinOpen(void *o, int32, int32)
|
||||
static void*
|
||||
skinClose(void *o, int32, int32)
|
||||
{
|
||||
((ObjPipeline*)skinGlobals.pipelines[PLATFORM_XBOX])->destroy();
|
||||
skinGlobals.pipelines[PLATFORM_XBOX] = nil;
|
||||
return o;
|
||||
}
|
||||
|
||||
@ -238,7 +240,7 @@ initSkin(void)
|
||||
ObjPipeline*
|
||||
makeSkinPipeline(void)
|
||||
{
|
||||
ObjPipeline *pipe = new ObjPipeline(PLATFORM_XBOX);
|
||||
ObjPipeline *pipe = ObjPipeline::create();
|
||||
pipe->instanceCB = skinInstanceCB;
|
||||
pipe->uninstanceCB = skinUninstanceCB;
|
||||
pipe->pluginID = ID_SKIN;
|
||||
|
@ -240,12 +240,12 @@ Engine::open(EngineOpenParams *p)
|
||||
|
||||
engine->device.system(DEVICEOPEN, (void*)p, 0);
|
||||
|
||||
ObjPipeline *defpipe = new ObjPipeline(PLATFORM_NULL);
|
||||
engine->dummyDefaultPipeline = ObjPipeline::create();
|
||||
for(uint i = 0; i < NUM_PLATFORMS; i++){
|
||||
rw::engine->driver[i] = (Driver*)rwNew(Driver::s_plglist[i].size,
|
||||
MEMDUR_GLOBAL);
|
||||
|
||||
engine->driver[i]->defaultPipeline = defpipe;
|
||||
engine->driver[i]->defaultPipeline = engine->dummyDefaultPipeline;
|
||||
|
||||
engine->driver[i]->rasterCreate = null::rasterCreate;
|
||||
engine->driver[i]->rasterLock = null::rasterLock;
|
||||
@ -324,6 +324,7 @@ Engine::close(void)
|
||||
engine->device.system(DEVICECLOSE, nil, 0);
|
||||
for(uint i = 0; i < NUM_PLATFORMS; i++)
|
||||
rwFree(rw::engine->driver[i]);
|
||||
engine->dummyDefaultPipeline->destroy();
|
||||
rwFree(engine);
|
||||
engine = nil;
|
||||
Engine::state = Initialized;
|
||||
|
@ -33,41 +33,6 @@ static int32 u_texMatrix;
|
||||
static int32 u_fxparams;
|
||||
static int32 u_colorClamp;
|
||||
|
||||
static void*
|
||||
matfxOpen(void *o, int32, int32)
|
||||
{
|
||||
u_texMatrix = registerUniform("u_texMatrix");
|
||||
u_fxparams = registerUniform("u_fxparams");
|
||||
u_colorClamp = registerUniform("u_colorClamp");
|
||||
matFXGlobals.pipelines[PLATFORM_GL3] = makeMatFXPipeline();
|
||||
|
||||
#ifdef RW_GLES2
|
||||
#include "gl2_shaders/matfx_gl2.inc"
|
||||
#else
|
||||
#include "shaders/matfx_gl3.inc"
|
||||
#endif
|
||||
const char *vs[] = { shaderDecl, header_vert_src, matfx_env_vert_src, nil };
|
||||
const char *fs[] = { shaderDecl, header_frag_src, matfx_env_frag_src, nil };
|
||||
envShader = Shader::create(vs, fs);
|
||||
assert(envShader);
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
static void*
|
||||
matfxClose(void *o, int32, int32)
|
||||
{
|
||||
return o;
|
||||
}
|
||||
|
||||
void
|
||||
initMatFX(void)
|
||||
{
|
||||
Driver::registerPlugin(PLATFORM_GL3, 0, ID_MATFX,
|
||||
matfxOpen, matfxClose);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
matfxDefaultRender(InstanceDataHeader *header, InstanceData *inst)
|
||||
{
|
||||
@ -197,7 +162,7 @@ matfxRenderCB(Atomic *atomic, InstanceDataHeader *header)
|
||||
ObjPipeline*
|
||||
makeMatFXPipeline(void)
|
||||
{
|
||||
ObjPipeline *pipe = new ObjPipeline(PLATFORM_GL3);
|
||||
ObjPipeline *pipe = ObjPipeline::create();
|
||||
pipe->instanceCB = defaultInstanceCB;
|
||||
pipe->uninstanceCB = defaultUninstanceCB;
|
||||
pipe->renderCB = matfxRenderCB;
|
||||
@ -206,6 +171,47 @@ makeMatFXPipeline(void)
|
||||
return pipe;
|
||||
}
|
||||
|
||||
static void*
|
||||
matfxOpen(void *o, int32, int32)
|
||||
{
|
||||
matFXGlobals.pipelines[PLATFORM_GL3] = makeMatFXPipeline();
|
||||
|
||||
#ifdef RW_GLES2
|
||||
#include "gl2_shaders/matfx_gl2.inc"
|
||||
#else
|
||||
#include "shaders/matfx_gl3.inc"
|
||||
#endif
|
||||
const char *vs[] = { shaderDecl, header_vert_src, matfx_env_vert_src, nil };
|
||||
const char *fs[] = { shaderDecl, header_frag_src, matfx_env_frag_src, nil };
|
||||
envShader = Shader::create(vs, fs);
|
||||
assert(envShader);
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
static void*
|
||||
matfxClose(void *o, int32, int32)
|
||||
{
|
||||
((ObjPipeline*)matFXGlobals.pipelines[PLATFORM_GL3])->destroy();
|
||||
matFXGlobals.pipelines[PLATFORM_GL3] = nil;
|
||||
|
||||
envShader->destroy();
|
||||
envShader = nil;
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
void
|
||||
initMatFX(void)
|
||||
{
|
||||
u_texMatrix = registerUniform("u_texMatrix");
|
||||
u_fxparams = registerUniform("u_fxparams");
|
||||
u_colorClamp = registerUniform("u_colorClamp");
|
||||
|
||||
Driver::registerPlugin(PLATFORM_GL3, 0, ID_MATFX,
|
||||
matfxOpen, matfxClose);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
void initMatFX(void) { }
|
||||
|
@ -148,9 +148,10 @@ render(rw::ObjPipeline *rwpipe, Atomic *atomic)
|
||||
pipe->renderCB(atomic, (InstanceDataHeader*)geo->instData);
|
||||
}
|
||||
|
||||
ObjPipeline::ObjPipeline(uint32 platform)
|
||||
: rw::ObjPipeline(platform)
|
||||
void
|
||||
ObjPipeline::init(void)
|
||||
{
|
||||
this->rw::ObjPipeline::init(PLATFORM_GL3);
|
||||
this->impl.instance = gl3::instance;
|
||||
this->impl.uninstance = gl3::uninstance;
|
||||
this->impl.render = gl3::render;
|
||||
@ -159,6 +160,14 @@ ObjPipeline::ObjPipeline(uint32 platform)
|
||||
this->renderCB = nil;
|
||||
}
|
||||
|
||||
ObjPipeline*
|
||||
ObjPipeline::create(void)
|
||||
{
|
||||
ObjPipeline *pipe = rwNewT(ObjPipeline, 1, MEMDUR_GLOBAL);
|
||||
pipe->init();
|
||||
return pipe;
|
||||
}
|
||||
|
||||
void
|
||||
defaultInstanceCB(Geometry *geo, InstanceDataHeader *header, bool32 reinstance)
|
||||
{
|
||||
@ -310,7 +319,7 @@ defaultUninstanceCB(Geometry *geo, InstanceDataHeader *header)
|
||||
ObjPipeline*
|
||||
makeDefaultPipeline(void)
|
||||
{
|
||||
ObjPipeline *pipe = new ObjPipeline(PLATFORM_GL3);
|
||||
ObjPipeline *pipe = ObjPipeline::create();
|
||||
pipe->instanceCB = defaultInstanceCB;
|
||||
pipe->uninstanceCB = defaultUninstanceCB;
|
||||
pipe->renderCB = defaultRenderCB;
|
||||
|
@ -31,40 +31,6 @@ namespace gl3 {
|
||||
static Shader *skinShader;
|
||||
static int32 u_boneMatrices;
|
||||
|
||||
static void*
|
||||
skinOpen(void *o, int32, int32)
|
||||
{
|
||||
u_boneMatrices = registerUniform("u_boneMatrices");
|
||||
skinGlobals.pipelines[PLATFORM_GL3] = makeSkinPipeline();
|
||||
|
||||
#ifdef RW_GLES2
|
||||
#include "gl2_shaders/simple_fs_gl2.inc"
|
||||
#include "gl2_shaders/skin_gl2.inc"
|
||||
#else
|
||||
#include "shaders/simple_fs_gl3.inc"
|
||||
#include "shaders/skin_gl3.inc"
|
||||
#endif
|
||||
const char *vs[] = { shaderDecl, header_vert_src, skin_vert_src, nil };
|
||||
const char *fs[] = { shaderDecl, header_frag_src, simple_frag_src, nil };
|
||||
skinShader = Shader::create(vs, fs);
|
||||
assert(skinShader);
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
static void*
|
||||
skinClose(void *o, int32, int32)
|
||||
{
|
||||
return o;
|
||||
}
|
||||
|
||||
void
|
||||
initSkin(void)
|
||||
{
|
||||
Driver::registerPlugin(PLATFORM_GL3, 0, ID_SKIN,
|
||||
skinOpen, skinClose);
|
||||
}
|
||||
|
||||
void
|
||||
skinInstanceCB(Geometry *geo, InstanceDataHeader *header, bool32 reinstance)
|
||||
{
|
||||
@ -318,10 +284,51 @@ skinRenderCB(Atomic *atomic, InstanceDataHeader *header)
|
||||
#endif
|
||||
}
|
||||
|
||||
static void*
|
||||
skinOpen(void *o, int32, int32)
|
||||
{
|
||||
skinGlobals.pipelines[PLATFORM_GL3] = makeSkinPipeline();
|
||||
|
||||
#ifdef RW_GLES2
|
||||
#include "gl2_shaders/simple_fs_gl2.inc"
|
||||
#include "gl2_shaders/skin_gl2.inc"
|
||||
#else
|
||||
#include "shaders/simple_fs_gl3.inc"
|
||||
#include "shaders/skin_gl3.inc"
|
||||
#endif
|
||||
const char *vs[] = { shaderDecl, header_vert_src, skin_vert_src, nil };
|
||||
const char *fs[] = { shaderDecl, header_frag_src, simple_frag_src, nil };
|
||||
skinShader = Shader::create(vs, fs);
|
||||
assert(skinShader);
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
static void*
|
||||
skinClose(void *o, int32, int32)
|
||||
{
|
||||
((ObjPipeline*)skinGlobals.pipelines[PLATFORM_GL3])->destroy();
|
||||
skinGlobals.pipelines[PLATFORM_GL3] = nil;
|
||||
|
||||
skinShader->destroy();
|
||||
skinShader = nil;
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
void
|
||||
initSkin(void)
|
||||
{
|
||||
u_boneMatrices = registerUniform("u_boneMatrices");
|
||||
|
||||
Driver::registerPlugin(PLATFORM_GL3, 0, ID_SKIN,
|
||||
skinOpen, skinClose);
|
||||
}
|
||||
|
||||
ObjPipeline*
|
||||
makeSkinPipeline(void)
|
||||
{
|
||||
ObjPipeline *pipe = new ObjPipeline(PLATFORM_GL3);
|
||||
ObjPipeline *pipe = ObjPipeline::create();
|
||||
pipe->instanceCB = skinInstanceCB;
|
||||
pipe->uninstanceCB = skinUninstanceCB;
|
||||
pipe->renderCB = skinRenderCB;
|
||||
|
@ -197,11 +197,12 @@ void flushCache(void);
|
||||
class ObjPipeline : public rw::ObjPipeline
|
||||
{
|
||||
public:
|
||||
void init(void);
|
||||
static ObjPipeline *create(void);
|
||||
|
||||
void (*instanceCB)(Geometry *geo, InstanceDataHeader *header, bool32 reinstance);
|
||||
void (*uninstanceCB)(Geometry *geo, InstanceDataHeader *header);
|
||||
void (*renderCB)(Atomic *atomic, InstanceDataHeader *header);
|
||||
|
||||
ObjPipeline(uint32 platform);
|
||||
};
|
||||
|
||||
void defaultInstanceCB(Geometry *geo, InstanceDataHeader *header, bool32 reinstance);
|
||||
|
@ -49,11 +49,12 @@ void printPipeinfo(Atomic *a);
|
||||
class ObjPipeline : public rw::ObjPipeline
|
||||
{
|
||||
public:
|
||||
void init(void);
|
||||
static ObjPipeline *create(void);
|
||||
|
||||
uint32 numCustomAttribs;
|
||||
uint32 (*instanceCB)(Geometry *g, int32 i, uint32 offset);
|
||||
void (*uninstanceCB)(Geometry *g);
|
||||
|
||||
ObjPipeline(uint32 platform);
|
||||
};
|
||||
|
||||
ObjPipeline *makeDefaultPipeline(void);
|
||||
|
@ -519,9 +519,10 @@ uninstance(rw::ObjPipeline *rwpipe, Atomic *atomic)
|
||||
destroyNativeData(geo, 0, 0);
|
||||
}
|
||||
|
||||
ObjPipeline::ObjPipeline(uint32 platform)
|
||||
: rw::ObjPipeline(platform)
|
||||
void
|
||||
ObjPipeline::init(void)
|
||||
{
|
||||
this->rw::ObjPipeline::init(PLATFORM_GL3);
|
||||
this->numCustomAttribs = 0;
|
||||
this->impl.instance = wdgl::instance;
|
||||
this->impl.uninstance = wdgl::uninstance;
|
||||
@ -529,10 +530,18 @@ ObjPipeline::ObjPipeline(uint32 platform)
|
||||
this->uninstanceCB = nil;
|
||||
}
|
||||
|
||||
ObjPipeline*
|
||||
ObjPipeline::create(void)
|
||||
{
|
||||
ObjPipeline *pipe = rwNewT(ObjPipeline, 1, MEMDUR_GLOBAL);
|
||||
pipe->init();
|
||||
return pipe;
|
||||
}
|
||||
|
||||
ObjPipeline*
|
||||
makeDefaultPipeline(void)
|
||||
{
|
||||
ObjPipeline *pipe = new ObjPipeline(PLATFORM_WDGL);
|
||||
ObjPipeline *pipe = ObjPipeline::create();
|
||||
return pipe;
|
||||
}
|
||||
|
||||
@ -696,6 +705,8 @@ skinOpen(void *o, int32, int32)
|
||||
static void*
|
||||
skinClose(void *o, int32, int32)
|
||||
{
|
||||
((ObjPipeline*)skinGlobals.pipelines[PLATFORM_WDGL])->destroy();
|
||||
skinGlobals.pipelines[PLATFORM_WDGL] = nil;
|
||||
return o;
|
||||
}
|
||||
|
||||
@ -709,7 +720,7 @@ initSkin(void)
|
||||
ObjPipeline*
|
||||
makeSkinPipeline(void)
|
||||
{
|
||||
ObjPipeline *pipe = new ObjPipeline(PLATFORM_WDGL);
|
||||
ObjPipeline *pipe = ObjPipeline::create();
|
||||
pipe->pluginID = ID_SKIN;
|
||||
pipe->pluginData = 1;
|
||||
pipe->numCustomAttribs = 2;
|
||||
@ -730,6 +741,8 @@ matfxOpen(void *o, int32, int32)
|
||||
static void*
|
||||
matfxClose(void *o, int32, int32)
|
||||
{
|
||||
((ObjPipeline*)matFXGlobals.pipelines[PLATFORM_WDGL])->destroy();
|
||||
matFXGlobals.pipelines[PLATFORM_WDGL] = nil;
|
||||
return o;
|
||||
}
|
||||
|
||||
@ -743,7 +756,7 @@ initMatFX(void)
|
||||
ObjPipeline*
|
||||
makeMatFXPipeline(void)
|
||||
{
|
||||
ObjPipeline *pipe = new ObjPipeline(PLATFORM_WDGL);
|
||||
ObjPipeline *pipe = ObjPipeline::create();
|
||||
pipe->pluginID = ID_MATFX;
|
||||
pipe->pluginData = 0;
|
||||
return pipe;
|
||||
|
@ -585,17 +585,21 @@ static void*
|
||||
matfxOpen(void *o, int32, int32)
|
||||
{
|
||||
// init dummy pipelines
|
||||
ObjPipeline *defpipe = new ObjPipeline(PLATFORM_NULL);
|
||||
defpipe->pluginID = 0; //ID_MATFX;
|
||||
defpipe->pluginData = 0;
|
||||
matFXGlobals.dummypipe = ObjPipeline::create();
|
||||
matFXGlobals.dummypipe->pluginID = 0; //ID_MATFX;
|
||||
matFXGlobals.dummypipe->pluginData = 0;
|
||||
for(uint i = 0; i < nelem(matFXGlobals.pipelines); i++)
|
||||
matFXGlobals.pipelines[i] = defpipe;
|
||||
matFXGlobals.pipelines[i] = matFXGlobals.dummypipe;
|
||||
return o;
|
||||
}
|
||||
|
||||
static void*
|
||||
matfxClose(void *o, int32, int32)
|
||||
{
|
||||
matFXGlobals.dummypipe->destroy();
|
||||
matFXGlobals.dummypipe = nil;
|
||||
for(uint i = 0; i < nelem(matFXGlobals.pipelines); i++)
|
||||
matFXGlobals.pipelines[i] = nil;
|
||||
return o;
|
||||
}
|
||||
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include "rwplg.h"
|
||||
#include "rwpipeline.h"
|
||||
#include "rwobjects.h"
|
||||
#include "rwengine.h"
|
||||
|
||||
#define COLOR_ARGB(a,r,g,b) \
|
||||
((uint32)((((a)&0xff)<<24)|(((r)&0xff)<<16)|(((g)&0xff)<<8)|((b)&0xff)))
|
||||
@ -15,21 +16,29 @@ namespace rw {
|
||||
|
||||
static void nothing(ObjPipeline *, Atomic*) {}
|
||||
|
||||
Pipeline::Pipeline(uint32 platform)
|
||||
{
|
||||
this->pluginID = 0;
|
||||
this->pluginData = 0;
|
||||
this->platform = platform;
|
||||
}
|
||||
|
||||
ObjPipeline::ObjPipeline(uint32 platform)
|
||||
: Pipeline(platform)
|
||||
void
|
||||
ObjPipeline::init(uint32 platform)
|
||||
{
|
||||
Pipeline::init(platform);
|
||||
this->impl.instance = nothing;
|
||||
this->impl.uninstance = nothing;
|
||||
this->impl.render = nothing;
|
||||
}
|
||||
|
||||
ObjPipeline*
|
||||
ObjPipeline::create(void)
|
||||
{
|
||||
ObjPipeline *pipe = rwNewT(ObjPipeline, 1, MEMDUR_GLOBAL);
|
||||
pipe->init(PLATFORM_NULL);
|
||||
return pipe;
|
||||
}
|
||||
|
||||
void
|
||||
ObjPipeline::destroy(void)
|
||||
{
|
||||
rwFree(this);
|
||||
}
|
||||
|
||||
// helper functions
|
||||
|
||||
void
|
||||
|
@ -84,8 +84,10 @@ registerPDSPlugin(int32 n)
|
||||
void
|
||||
registerPluginPDSPipes(void)
|
||||
{
|
||||
// TODO: how do we destroy them?
|
||||
|
||||
// rwPDS_G3_Skin_GrpMatPipeID
|
||||
MatPipeline *pipe = new MatPipeline(PLATFORM_PS2);
|
||||
MatPipeline *pipe = MatPipeline::create();
|
||||
pipe->pluginID = ID_PDS;
|
||||
pipe->pluginData = 0x11001;
|
||||
pipe->attribs[AT_XYZ] = &attribXYZ;
|
||||
@ -103,14 +105,14 @@ registerPluginPDSPipes(void)
|
||||
registerPDSPipe(pipe);
|
||||
|
||||
// rwPDS_G3_Skin_GrpAtmPipeID
|
||||
ObjPipeline *opipe = new ObjPipeline(PLATFORM_PS2);
|
||||
ObjPipeline *opipe = ObjPipeline::create();
|
||||
opipe->pluginID = ID_PDS;
|
||||
opipe->pluginData = 0x11002;
|
||||
opipe->groupPipeline = pipe;
|
||||
registerPDSPipe(opipe);
|
||||
|
||||
// rwPDS_G3_MatfxUV1_GrpMatPipeID
|
||||
pipe = new MatPipeline(PLATFORM_PS2);
|
||||
pipe = MatPipeline::create();
|
||||
pipe->pluginID = ID_PDS;
|
||||
pipe->pluginData = 0x1100b;
|
||||
pipe->attribs[AT_XYZ] = &attribXYZ;
|
||||
@ -124,14 +126,14 @@ registerPluginPDSPipes(void)
|
||||
registerPDSPipe(pipe);
|
||||
|
||||
// rwPDS_G3_MatfxUV1_GrpAtmPipeID
|
||||
opipe = new ObjPipeline(PLATFORM_PS2);
|
||||
opipe = ObjPipeline::create();
|
||||
opipe->pluginID = ID_PDS;
|
||||
opipe->pluginData = 0x1100d;
|
||||
opipe->groupPipeline = pipe;
|
||||
registerPDSPipe(opipe);
|
||||
|
||||
// rwPDS_G3_MatfxUV2_GrpMatPipeID
|
||||
pipe = new MatPipeline(PLATFORM_PS2);
|
||||
pipe = MatPipeline::create();
|
||||
pipe->pluginID = ID_PDS;
|
||||
pipe->pluginData = 0x1100c;
|
||||
pipe->attribs[AT_XYZ] = &attribXYZ;
|
||||
@ -145,7 +147,7 @@ registerPluginPDSPipes(void)
|
||||
registerPDSPipe(pipe);
|
||||
|
||||
// rwPDS_G3_MatfxUV2_GrpAtmPipeID
|
||||
opipe = new ObjPipeline(PLATFORM_PS2);
|
||||
opipe = ObjPipeline::create();
|
||||
opipe->pluginID = ID_PDS;
|
||||
opipe->pluginData = 0x1100e;
|
||||
opipe->groupPipeline = pipe;
|
||||
@ -154,19 +156,19 @@ registerPluginPDSPipes(void)
|
||||
// RW World plugin
|
||||
|
||||
// rwPDS_G3x_Generic_AtmPipeID
|
||||
opipe = new ObjPipeline(PLATFORM_PS2);
|
||||
opipe = ObjPipeline::create();
|
||||
opipe->pluginID = ID_PDS;
|
||||
opipe->pluginData = 0x50001;
|
||||
registerPDSPipe(opipe);
|
||||
|
||||
// rwPDS_G3x_Skin_AtmPipeID
|
||||
opipe = new ObjPipeline(PLATFORM_PS2);
|
||||
opipe = ObjPipeline::create();
|
||||
opipe->pluginID = ID_PDS;
|
||||
opipe->pluginData = 0x5000b;
|
||||
registerPDSPipe(opipe);
|
||||
|
||||
// rwPDS_G3xd_A4D_MatPipeID
|
||||
pipe = new MatPipeline(PLATFORM_PS2);
|
||||
pipe = MatPipeline::create();
|
||||
pipe->pluginID = ID_PDS;
|
||||
pipe->pluginData = 0x5002f;
|
||||
pipe->attribs[0] = &attribXYZW;
|
||||
@ -180,7 +182,7 @@ registerPluginPDSPipes(void)
|
||||
registerPDSPipe(pipe);
|
||||
|
||||
// rwPDS_G3xd_A4DSkin_MatPipeID
|
||||
pipe = new MatPipeline(PLATFORM_PS2);
|
||||
pipe = MatPipeline::create();
|
||||
pipe->pluginID = ID_PDS;
|
||||
pipe->pluginData = 0x5003e;
|
||||
pipe->attribs[0] = &attribXYZW;
|
||||
|
@ -437,12 +437,30 @@ instanceNormal(uint32 *wp, Geometry *g, Mesh *m, uint32 idx, uint32 n)
|
||||
return (uint32*)p;
|
||||
}
|
||||
|
||||
MatPipeline::MatPipeline(uint32 platform)
|
||||
: rw::Pipeline(platform), instanceCB(nil), uninstanceCB(nil),
|
||||
preUninstCB(nil), postUninstCB(nil)
|
||||
void
|
||||
MatPipeline::init(void)
|
||||
{
|
||||
this->rw::Pipeline::init(PLATFORM_PS2);
|
||||
for(int i = 0; i < 10; i++)
|
||||
this->attribs[i] = nil;
|
||||
this->instanceCB = nil;
|
||||
this->uninstanceCB = nil;
|
||||
this->preUninstCB = nil;
|
||||
this->postUninstCB = nil;
|
||||
}
|
||||
|
||||
MatPipeline*
|
||||
MatPipeline::create(void)
|
||||
{
|
||||
MatPipeline *pipe = rwNewT(MatPipeline, 1, MEMDUR_GLOBAL);
|
||||
pipe->init();
|
||||
return pipe;
|
||||
}
|
||||
|
||||
void
|
||||
MatPipeline::destroy(void)
|
||||
{
|
||||
rwFree(this);
|
||||
}
|
||||
|
||||
void
|
||||
@ -911,14 +929,23 @@ objUninstance(rw::ObjPipeline *rwpipe, Atomic *atomic)
|
||||
*/
|
||||
}
|
||||
|
||||
ObjPipeline::ObjPipeline(uint32 platform)
|
||||
: rw::ObjPipeline(platform)
|
||||
void
|
||||
ObjPipeline::init(void)
|
||||
{
|
||||
this->rw::ObjPipeline::init(PLATFORM_PS2);
|
||||
this->groupPipeline = nil;
|
||||
this->impl.instance = objInstance;
|
||||
this->impl.uninstance = objUninstance;
|
||||
}
|
||||
|
||||
ObjPipeline*
|
||||
ObjPipeline::create(void)
|
||||
{
|
||||
ObjPipeline *pipe = rwNewT(ObjPipeline, 1, MEMDUR_GLOBAL);
|
||||
pipe->init();
|
||||
return pipe;
|
||||
}
|
||||
|
||||
void
|
||||
insertVertex(Geometry *geo, int32 i, uint32 mask, Vertex *v)
|
||||
{
|
||||
@ -1082,7 +1109,7 @@ ObjPipeline*
|
||||
makeDefaultPipeline(void)
|
||||
{
|
||||
if(defaultMatPipe == nil){
|
||||
MatPipeline *pipe = new MatPipeline(PLATFORM_PS2);
|
||||
MatPipeline *pipe = MatPipeline::create();
|
||||
pipe->attribs[AT_XYZ] = &attribXYZ;
|
||||
pipe->attribs[AT_UV] = &attribUV;
|
||||
pipe->attribs[AT_RGBA] = &attribRGBA;
|
||||
@ -1095,7 +1122,7 @@ makeDefaultPipeline(void)
|
||||
}
|
||||
|
||||
if(defaultObjPipe == nil){
|
||||
ObjPipeline *opipe = new ObjPipeline(PLATFORM_PS2);
|
||||
ObjPipeline *opipe = ObjPipeline::create();
|
||||
defaultObjPipe = opipe;
|
||||
}
|
||||
return defaultObjPipe;
|
||||
|
@ -29,6 +29,9 @@ matfxOpen(void *o, int32, int32)
|
||||
static void*
|
||||
matfxClose(void *o, int32, int32)
|
||||
{
|
||||
((ObjPipeline*)matFXGlobals.pipelines[PLATFORM_PS2])->groupPipeline->destroy();
|
||||
((ObjPipeline*)matFXGlobals.pipelines[PLATFORM_PS2])->destroy();
|
||||
matFXGlobals.pipelines[PLATFORM_PS2] = nil;
|
||||
return o;
|
||||
}
|
||||
|
||||
@ -42,7 +45,7 @@ initMatFX(void)
|
||||
ObjPipeline*
|
||||
makeMatFXPipeline(void)
|
||||
{
|
||||
MatPipeline *pipe = new MatPipeline(PLATFORM_PS2);
|
||||
MatPipeline *pipe = MatPipeline::create();
|
||||
pipe->pluginID = ID_MATFX;
|
||||
pipe->pluginData = 0;
|
||||
pipe->attribs[AT_XYZ] = &attribXYZ;
|
||||
@ -54,7 +57,7 @@ makeMatFXPipeline(void)
|
||||
pipe->vifOffset = pipe->inputStride*vertCount;
|
||||
pipe->uninstanceCB = genericUninstanceCB;
|
||||
|
||||
ObjPipeline *opipe = new ObjPipeline(PLATFORM_PS2);
|
||||
ObjPipeline *opipe = ObjPipeline::create();
|
||||
opipe->pluginID = ID_MATFX;
|
||||
opipe->pluginData = 0;
|
||||
opipe->groupPipeline = pipe;
|
||||
|
@ -31,6 +31,10 @@ skinOpen(void *o, int32, int32)
|
||||
static void*
|
||||
skinClose(void *o, int32, int32)
|
||||
{
|
||||
((ObjPipeline*)skinGlobals.pipelines[PLATFORM_PS2])->groupPipeline->destroy();
|
||||
((ObjPipeline*)skinGlobals.pipelines[PLATFORM_PS2])->groupPipeline = nil;
|
||||
((ObjPipeline*)skinGlobals.pipelines[PLATFORM_PS2])->destroy();
|
||||
skinGlobals.pipelines[PLATFORM_PS2] = nil;
|
||||
return o;
|
||||
}
|
||||
|
||||
@ -44,7 +48,7 @@ initSkin(void)
|
||||
ObjPipeline*
|
||||
makeSkinPipeline(void)
|
||||
{
|
||||
MatPipeline *pipe = new MatPipeline(PLATFORM_PS2);
|
||||
MatPipeline *pipe = MatPipeline::create();
|
||||
pipe->pluginID = ID_SKIN;
|
||||
pipe->pluginData = 1;
|
||||
pipe->attribs[AT_XYZ] = &attribXYZ;
|
||||
@ -60,7 +64,7 @@ makeSkinPipeline(void)
|
||||
pipe->preUninstCB = skinPreCB;
|
||||
pipe->postUninstCB = skinPostCB;
|
||||
|
||||
ObjPipeline *opipe = new ObjPipeline(PLATFORM_PS2);
|
||||
ObjPipeline *opipe = ObjPipeline::create();
|
||||
opipe->pluginID = ID_SKIN;
|
||||
opipe->pluginData = 1;
|
||||
opipe->groupPipeline = pipe;
|
||||
|
@ -132,7 +132,9 @@ public:
|
||||
return (top-outBufs)/(inAttribs*2+outAttribs*outBufs);
|
||||
}
|
||||
|
||||
MatPipeline(uint32 platform);
|
||||
void init(void);
|
||||
static MatPipeline *create(void);
|
||||
void destroy(void);
|
||||
void dump(void);
|
||||
void setTriBufferSizes(uint32 inputStride, uint32 bufferSize);
|
||||
void instance(Geometry *g, InstanceData *inst, Mesh *m);
|
||||
@ -142,14 +144,15 @@ public:
|
||||
class ObjPipeline : public rw::ObjPipeline
|
||||
{
|
||||
public:
|
||||
void init(void);
|
||||
static ObjPipeline *create(void);
|
||||
|
||||
MatPipeline *groupPipeline;
|
||||
// RW has more:
|
||||
// setupCB()
|
||||
// finalizeCB()
|
||||
// lightOffset
|
||||
// lightSize
|
||||
|
||||
ObjPipeline(uint32 platform);
|
||||
};
|
||||
|
||||
struct Vertex {
|
||||
|
@ -153,6 +153,7 @@ struct Engine
|
||||
// Dynamically allocated because of plugins
|
||||
Driver *driver[NUM_PLATFORMS];
|
||||
Device device;
|
||||
ObjPipeline *dummyDefaultPipeline;
|
||||
|
||||
// These must always be available
|
||||
static MemoryFunctions memfuncs;
|
||||
|
@ -9,13 +9,20 @@ public:
|
||||
uint32 pluginData;
|
||||
int32 platform;
|
||||
|
||||
Pipeline(uint32 platform);
|
||||
void init(uint32 platform) {
|
||||
this->pluginID = 0;
|
||||
this->pluginData = 0;
|
||||
this->platform = platform;
|
||||
}
|
||||
};
|
||||
|
||||
class ObjPipeline : public Pipeline
|
||||
{
|
||||
public:
|
||||
ObjPipeline(uint32 platform);
|
||||
void init(uint32 platform);
|
||||
static ObjPipeline *create(void); // always PLATFORM_NULL
|
||||
void destroy(void);
|
||||
|
||||
// not the most beautiful way of doing things but still
|
||||
// better than virtual methods (i hope?).
|
||||
struct {
|
||||
|
@ -168,6 +168,7 @@ struct MatFXGlobals
|
||||
int32 atomicOffset;
|
||||
int32 materialOffset;
|
||||
ObjPipeline *pipelines[NUM_PLATFORMS];
|
||||
ObjPipeline *dummypipe;
|
||||
};
|
||||
extern MatFXGlobals matFXGlobals;
|
||||
void registerMatFXPlugin(void);
|
||||
@ -182,6 +183,7 @@ struct SkinGlobals
|
||||
int32 geoOffset;
|
||||
int32 atomicOffset;
|
||||
ObjPipeline *pipelines[NUM_PLATFORMS];
|
||||
ObjPipeline *dummypipe;
|
||||
};
|
||||
extern SkinGlobals skinGlobals;
|
||||
|
||||
|
12
src/skin.cpp
12
src/skin.cpp
@ -331,17 +331,21 @@ static void*
|
||||
skinOpen(void *o, int32, int32)
|
||||
{
|
||||
// init dummy pipelines
|
||||
ObjPipeline *defpipe = new ObjPipeline(PLATFORM_NULL);
|
||||
defpipe->pluginID = ID_SKIN;
|
||||
defpipe->pluginData = 1;
|
||||
skinGlobals.dummypipe = ObjPipeline::create();
|
||||
skinGlobals.dummypipe->pluginID = ID_SKIN;
|
||||
skinGlobals.dummypipe->pluginData = 1;
|
||||
for(uint i = 0; i < nelem(skinGlobals.pipelines); i++)
|
||||
skinGlobals.pipelines[i] = defpipe;
|
||||
skinGlobals.pipelines[i] = skinGlobals.dummypipe;
|
||||
return o;
|
||||
}
|
||||
|
||||
static void*
|
||||
skinClose(void *o, int32, int32)
|
||||
{
|
||||
skinGlobals.dummypipe->destroy();
|
||||
skinGlobals.dummypipe = nil;
|
||||
for(uint i = 0; i < nelem(skinGlobals.pipelines); i++)
|
||||
skinGlobals.pipelines[i] = nil;
|
||||
return o;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user