moved d3d rendering code here

This commit is contained in:
aap 2016-02-14 12:28:03 +01:00
parent dc4011ba7a
commit ad81510267
6 changed files with 31 additions and 13 deletions

View File

@ -191,7 +191,10 @@
<ClCompile Include="src\clump.cpp" /> <ClCompile Include="src\clump.cpp" />
<ClCompile Include="src\d3d.cpp" /> <ClCompile Include="src\d3d.cpp" />
<ClCompile Include="src\d3d8.cpp" /> <ClCompile Include="src\d3d8.cpp" />
<ClCompile Include="src\d3d8render.cpp" />
<ClCompile Include="src\d3d9.cpp" /> <ClCompile Include="src\d3d9.cpp" />
<ClCompile Include="src\d3d9render.cpp" />
<ClCompile Include="src\d3ddriver.cpp" />
<ClCompile Include="src\geometry.cpp" /> <ClCompile Include="src\geometry.cpp" />
<ClCompile Include="src\image.cpp" /> <ClCompile Include="src\image.cpp" />
<ClCompile Include="src\ogl.cpp" /> <ClCompile Include="src\ogl.cpp" />

View File

@ -10,8 +10,6 @@
#include "rwd3d.h" #include "rwd3d.h"
#include "rwd3d9.h" #include "rwd3d9.h"
using namespace std;
namespace rw { namespace rw {
namespace d3d9 { namespace d3d9 {
using namespace d3d; using namespace d3d;
@ -346,13 +344,28 @@ uninstance(rw::ObjPipeline *rwpipe, Atomic *atomic)
destroyNativeData(geo, 0, 0); destroyNativeData(geo, 0, 0);
} }
static void
render(rw::ObjPipeline *rwpipe, Atomic *atomic)
{
ObjPipeline *pipe = (ObjPipeline*)rwpipe;
Geometry *geo = atomic->geometry;
if((geo->geoflags & Geometry::NATIVE) == 0)
pipe->instance(atomic);
assert(geo->instData != NULL);
assert(geo->instData->platform == PLATFORM_D3D9);
if(pipe->renderCB)
pipe->renderCB(atomic, (InstanceDataHeader*)geo->instData);
}
ObjPipeline::ObjPipeline(uint32 platform) ObjPipeline::ObjPipeline(uint32 platform)
: rw::ObjPipeline(platform) : rw::ObjPipeline(platform)
{ {
this->impl.instance = d3d9::instance; this->impl.instance = d3d9::instance;
this->impl.uninstance = d3d9::uninstance; this->impl.uninstance = d3d9::uninstance;
this->impl.render = d3d9::render;
this->instanceCB = NULL; this->instanceCB = NULL;
this->uninstanceCB = NULL; this->uninstanceCB = NULL;
this->renderCB = NULL;
} }
void void
@ -494,6 +507,7 @@ makeDefaultPipeline(void)
ObjPipeline *pipe = new ObjPipeline(PLATFORM_D3D9); ObjPipeline *pipe = new ObjPipeline(PLATFORM_D3D9);
pipe->instanceCB = defaultInstanceCB; pipe->instanceCB = defaultInstanceCB;
pipe->uninstanceCB = defaultUninstanceCB; pipe->uninstanceCB = defaultUninstanceCB;
pipe->renderCB = defaultRenderCB;
return pipe; return pipe;
} }
@ -503,6 +517,7 @@ makeSkinPipeline(void)
ObjPipeline *pipe = new ObjPipeline(PLATFORM_D3D9); ObjPipeline *pipe = new ObjPipeline(PLATFORM_D3D9);
pipe->instanceCB = defaultInstanceCB; pipe->instanceCB = defaultInstanceCB;
pipe->uninstanceCB = defaultUninstanceCB; pipe->uninstanceCB = defaultUninstanceCB;
pipe->renderCB = defaultRenderCB;
pipe->pluginID = ID_SKIN; pipe->pluginID = ID_SKIN;
pipe->pluginData = 1; pipe->pluginData = 1;
return pipe; return pipe;
@ -514,6 +529,7 @@ makeMatFXPipeline(void)
ObjPipeline *pipe = new ObjPipeline(PLATFORM_D3D9); ObjPipeline *pipe = new ObjPipeline(PLATFORM_D3D9);
pipe->instanceCB = defaultInstanceCB; pipe->instanceCB = defaultInstanceCB;
pipe->uninstanceCB = defaultUninstanceCB; pipe->uninstanceCB = defaultUninstanceCB;
pipe->renderCB = defaultRenderCB;
pipe->pluginID = ID_MATFX; pipe->pluginID = ID_MATFX;
pipe->pluginData = 0; pipe->pluginData = 0;
return pipe; return pipe;

View File

@ -16,8 +16,6 @@ using namespace std;
namespace rw { namespace rw {
void (*defaultRenderCBs[rw::NUM_PLATFORMS])(Atomic*);
static void nothing(ObjPipeline *, Atomic*) {} static void nothing(ObjPipeline *, Atomic*) {}
Pipeline::Pipeline(uint32 platform) Pipeline::Pipeline(uint32 platform)
@ -35,13 +33,6 @@ ObjPipeline::ObjPipeline(uint32 platform)
this->impl.render = nothing; this->impl.render = nothing;
} }
//void
//ObjPipeline::render(Atomic *atomic)
//{
// if(defaultRenderCBs[rw::platform])
// defaultRenderCBs[rw::platform](atomic);
//}
// helper functions // helper functions
void void

View File

@ -95,5 +95,10 @@ void setTexels(Raster *raster, void *texels, int32 level);
extern int32 nativeRasterOffset; extern int32 nativeRasterOffset;
void registerNativeRaster(void); void registerNativeRaster(void);
// Rendering
void setTexture(Texture *tex);
void setMaterial(Material *mat);
} }
} }

View File

@ -63,10 +63,15 @@ class ObjPipeline : public rw::ObjPipeline
public: public:
void (*instanceCB)(Geometry *geo, InstanceDataHeader *header); void (*instanceCB)(Geometry *geo, InstanceDataHeader *header);
void (*uninstanceCB)(Geometry *geo, InstanceDataHeader *header); void (*uninstanceCB)(Geometry *geo, InstanceDataHeader *header);
void (*renderCB)(Atomic *atomic, InstanceDataHeader *header);
ObjPipeline(uint32 platform); ObjPipeline(uint32 platform);
}; };
void defaultInstanceCB(Geometry *geo, InstanceDataHeader *header);
void defaultUninstanceCB(Geometry *geo, InstanceDataHeader *header);
void defaultRenderCB(Atomic *atomic, InstanceDataHeader *header);
ObjPipeline *makeDefaultPipeline(void); ObjPipeline *makeDefaultPipeline(void);
ObjPipeline *makeSkinPipeline(void); ObjPipeline *makeSkinPipeline(void);

View File

@ -29,8 +29,6 @@ public:
void render(Atomic *atomic) { this->impl.render(this, atomic); } void render(Atomic *atomic) { this->impl.render(this, atomic); }
}; };
extern void (*defaultRenderCBs[rw::NUM_PLATFORMS])(Atomic*);
void findMinVertAndNumVertices(uint16 *indices, uint32 numIndices, uint32 *minVert, int32 *numVertices); void findMinVertAndNumVertices(uint16 *indices, uint32 numIndices, uint32 *minVert, int32 *numVertices);
// everything xbox, d3d8 and d3d9 may want to use // everything xbox, d3d8 and d3d9 may want to use