mirror of
https://github.com/aap/librw.git
synced 2025-12-19 17:09:51 +00:00
changed pipe new to explicit create
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user