2020-04-30 17:54:38 +02:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <assert.h>
|
2016-06-24 15:24:58 +02:00
|
|
|
|
2020-04-15 09:47:43 +02:00
|
|
|
#define WITH_D3D
|
2016-06-24 15:24:58 +02:00
|
|
|
#include "../rwbase.h"
|
|
|
|
#include "../rwplg.h"
|
|
|
|
#include "../rwpipeline.h"
|
|
|
|
#include "../rwobjects.h"
|
2017-08-09 10:57:32 +02:00
|
|
|
#include "../rwengine.h"
|
2016-06-24 15:24:58 +02:00
|
|
|
#include "rwd3d.h"
|
|
|
|
#include "rwd3d8.h"
|
|
|
|
|
|
|
|
namespace rw {
|
|
|
|
namespace d3d8 {
|
|
|
|
using namespace d3d;
|
|
|
|
|
|
|
|
#ifndef RW_D3D9
|
|
|
|
void defaultRenderCB(Atomic*, InstanceDataHeader*) {}
|
|
|
|
#else
|
|
|
|
|
2018-01-03 18:02:02 +01:00
|
|
|
// This is a bit abandoned, use d3d9 instead
|
|
|
|
|
2016-06-24 15:24:58 +02:00
|
|
|
void
|
|
|
|
defaultRenderCB(Atomic *atomic, InstanceDataHeader *header)
|
|
|
|
{
|
2017-08-04 19:54:03 +02:00
|
|
|
RawMatrix world;
|
|
|
|
|
2020-04-20 11:50:41 +02:00
|
|
|
d3d::lightingCB_Fix(atomic);
|
2017-08-09 10:57:32 +02:00
|
|
|
|
2016-06-24 15:24:58 +02:00
|
|
|
Geometry *geo = atomic->geometry;
|
2017-08-09 10:57:32 +02:00
|
|
|
d3d::setRenderState(D3DRS_LIGHTING, !!(geo->flags & rw::Geometry::LIGHT));
|
|
|
|
|
2016-06-24 15:24:58 +02:00
|
|
|
Frame *f = atomic->getFrame();
|
2017-08-04 19:54:03 +02:00
|
|
|
convMatrix(&world, f->getLTM());
|
2017-08-09 10:57:32 +02:00
|
|
|
d3ddevice->SetTransform(D3DTS_WORLD, (D3DMATRIX*)&world);
|
2016-06-24 15:24:58 +02:00
|
|
|
|
|
|
|
InstanceData *inst = header->inst;
|
|
|
|
for(uint32 i = 0; i < header->numMeshes; i++){
|
|
|
|
d3d::setTexture(0, inst->material->texture);
|
2020-08-10 17:02:13 +02:00
|
|
|
d3d::setMaterial(inst->material->color, inst->material->surfaceProps);
|
2018-01-03 18:02:02 +01:00
|
|
|
|
|
|
|
|
2016-06-24 15:24:58 +02:00
|
|
|
d3d::setRenderState(D3DRS_AMBIENTMATERIALSOURCE, D3DMCS_MATERIAL);
|
|
|
|
d3d::setRenderState(D3DRS_DIFFUSEMATERIALSOURCE, D3DMCS_MATERIAL);
|
2017-03-16 11:42:59 +01:00
|
|
|
if(geo->flags & Geometry::PRELIT)
|
2016-06-24 15:24:58 +02:00
|
|
|
d3d::setRenderState(D3DRS_EMISSIVEMATERIALSOURCE, D3DMCS_COLOR1);
|
2017-08-29 10:12:56 +02:00
|
|
|
else
|
|
|
|
d3d::setRenderState(D3DRS_EMISSIVEMATERIALSOURCE, D3DMCS_MATERIAL);
|
2016-06-24 15:24:58 +02:00
|
|
|
|
2017-08-09 10:57:32 +02:00
|
|
|
d3ddevice->SetFVF(inst->vertexShader);
|
2020-04-24 19:06:11 +02:00
|
|
|
setStreamSource(0, (IDirect3DVertexBuffer9*)inst->vertexBuffer, 0, inst->stride);
|
|
|
|
setIndices((IDirect3DIndexBuffer9*)inst->indexBuffer);
|
2016-06-24 15:24:58 +02:00
|
|
|
uint32 numPrim = inst->primType == D3DPT_TRIANGLESTRIP ? inst->numIndices-2 : inst->numIndices/3;
|
|
|
|
d3d::flushCache();
|
2017-08-09 10:57:32 +02:00
|
|
|
d3ddevice->DrawIndexedPrimitive((D3DPRIMITIVETYPE)inst->primType, inst->baseIndex,
|
|
|
|
0, inst->numVertices, 0, numPrim);
|
2016-06-24 15:24:58 +02:00
|
|
|
inst++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|