added im3d transform flags

This commit is contained in:
aap 2020-05-06 09:22:29 +02:00
parent b3ad490d1b
commit 40eae78e79
9 changed files with 26 additions and 10 deletions

View File

@ -252,13 +252,16 @@ closeIm3D(void)
} }
void void
im3DTransform(void *vertices, int32 numVertices, Matrix *world) im3DTransform(void *vertices, int32 numVertices, Matrix *world, uint32 flags)
{ {
if(world == nil) if(world == nil)
uploadMatrices(); uploadMatrices();
else else
uploadMatrices(world); uploadMatrices(world);
if((flags & im3d::VERTEXUV) == 0)
SetRenderStatePtr(TEXTURERASTER, nil);
d3ddevice->SetVertexShaderConstantF(VSLOC_fogData, (float*)&d3dShaderState.fogData, 1); d3ddevice->SetVertexShaderConstantF(VSLOC_fogData, (float*)&d3dShaderState.fogData, 1);
d3ddevice->SetPixelShaderConstantF(PSLOC_fogColor, (float*)&d3dShaderState.fogColor, 1); d3ddevice->SetPixelShaderConstantF(PSLOC_fogColor, (float*)&d3dShaderState.fogColor, 1);
static float surfprops[4] = { 0.0f, 0.0f, 0.0f, 1.0f }; static float surfprops[4] = { 0.0f, 0.0f, 0.0f, 1.0f };

View File

@ -11,7 +11,7 @@ void im2DRenderIndexedPrimitive(PrimitiveType primType, void *vertices, int32 nu
void openIm3D(void); void openIm3D(void);
void closeIm3D(void); void closeIm3D(void);
void im3DTransform(void *vertices, int32 numVertices, Matrix *world); void im3DTransform(void *vertices, int32 numVertices, Matrix *world, uint32 flags);
void im3DRenderPrimitive(PrimitiveType primType); void im3DRenderPrimitive(PrimitiveType primType);
void im3DRenderIndexedPrimitive(PrimitiveType primType, void *indices, int32 numIndices); void im3DRenderIndexedPrimitive(PrimitiveType primType, void *indices, int32 numIndices);
void im3DEnd(void); void im3DEnd(void);

View File

@ -417,7 +417,7 @@ void im2DRenderTriangle(void*, int32, int32, int32, int32) { }
void im2DRenderPrimitive(PrimitiveType, void*, int32) { } void im2DRenderPrimitive(PrimitiveType, void*, int32) { }
void im2DRenderIndexedPrimitive(PrimitiveType, void*, int32, void*, int32) { } void im2DRenderIndexedPrimitive(PrimitiveType, void*, int32, void*, int32) { }
void im3DTransform(void *vertices, int32 numVertices, Matrix *world) { } void im3DTransform(void *vertices, int32 numVertices, Matrix *world, uint32 flags) { }
void im3DRenderPrimitive(PrimitiveType primType) { } void im3DRenderPrimitive(PrimitiveType primType) { }
void im3DRenderIndexedPrimitive(PrimitiveType primType, void *indices, int32 numIndices) { } void im3DRenderIndexedPrimitive(PrimitiveType primType, void *indices, int32 numIndices) { }
void im3DEnd(void) { } void im3DEnd(void) { }

View File

@ -208,7 +208,7 @@ closeIm3D(void)
} }
void void
im3DTransform(void *vertices, int32 numVertices, Matrix *world) im3DTransform(void *vertices, int32 numVertices, Matrix *world, uint32 flags)
{ {
if(world == nil){ if(world == nil){
Matrix ident; Matrix ident;
@ -218,6 +218,9 @@ im3DTransform(void *vertices, int32 numVertices, Matrix *world)
setWorldMatrix(world); setWorldMatrix(world);
im3dShader->use(); im3dShader->use();
if((flags & im3d::VERTEXUV) == 0)
SetRenderStatePtr(TEXTURERASTER, nil);
// TODO: fixed size // TODO: fixed size
glBindBuffer(GL_ARRAY_BUFFER, im3DVbo); glBindBuffer(GL_ARRAY_BUFFER, im3DVbo);
glBufferData(GL_ARRAY_BUFFER, numVertices*sizeof(Im3DVertex), glBufferData(GL_ARRAY_BUFFER, numVertices*sizeof(Im3DVertex),

View File

@ -17,7 +17,7 @@ void im2DRenderIndexedPrimitive(PrimitiveType primType,
void openIm3D(void); void openIm3D(void);
void closeIm3D(void); void closeIm3D(void);
void im3DTransform(void *vertices, int32 numVertices, Matrix *world); void im3DTransform(void *vertices, int32 numVertices, Matrix *world, uint32 flags);
void im3DRenderPrimitive(PrimitiveType primType); void im3DRenderPrimitive(PrimitiveType primType);
void im3DRenderIndexedPrimitive(PrimitiveType primType, void *indices, int32 numIndices); void im3DRenderIndexedPrimitive(PrimitiveType primType, void *indices, int32 numIndices);
void im3DEnd(void); void im3DEnd(void);

View File

@ -52,9 +52,9 @@ RenderPrimitive(PrimitiveType type, void *verts, int32 numVerts)
namespace im3d { namespace im3d {
void void
Transform(void *vertices, int32 numVertices, Matrix *world) Transform(void *vertices, int32 numVertices, Matrix *world, uint32 flags)
{ {
engine->device.im3DTransform(vertices, numVertices, world); engine->device.im3DTransform(vertices, numVertices, world, flags);
} }
void void
RenderPrimitive(PrimitiveType primType) RenderPrimitive(PrimitiveType primType)

View File

@ -55,7 +55,7 @@ struct Device
void (*im2DRenderPrimitive)(PrimitiveType primType, void *vertices, int32 numVertices); void (*im2DRenderPrimitive)(PrimitiveType primType, void *vertices, int32 numVertices);
void (*im2DRenderIndexedPrimitive)(PrimitiveType primType, void *vertices, int32 numVertices, void *indices, int32 numIndices); void (*im2DRenderIndexedPrimitive)(PrimitiveType primType, void *vertices, int32 numVertices, void *indices, int32 numIndices);
void (*im3DTransform)(void *vertices, int32 numVertices, Matrix *world); void (*im3DTransform)(void *vertices, int32 numVertices, Matrix *world, uint32 flags);
void (*im3DRenderPrimitive)(PrimitiveType primType); void (*im3DRenderPrimitive)(PrimitiveType primType);
void (*im3DRenderIndexedPrimitive)(PrimitiveType primType, void *indices, int32 numIndices); void (*im3DRenderIndexedPrimitive)(PrimitiveType primType, void *indices, int32 numIndices);
void (*im3DEnd)(void); void (*im3DEnd)(void);

View File

@ -84,7 +84,17 @@ void RenderPrimitive(PrimitiveType type, void *verts, int32 numVerts);
namespace im3d { namespace im3d {
void Transform(void *vertices, int32 numVertices, Matrix *world); enum TransformFlags
{
VERTEXUV = 1, // has tex Coords
ALLOPAQUE = 2, // no vertex alpha
NOCLIP = 4, // don't frustum clip
VERTEXXYZ = 8, // has position
VERTEXRGBA = 16, // has color
EVERYTHING = VERTEXUV|VERTEXXYZ|VERTEXRGBA
};
void Transform(void *vertices, int32 numVertices, Matrix *world, uint32 flags);
void RenderPrimitive(PrimitiveType primType); void RenderPrimitive(PrimitiveType primType);
void RenderIndexedPrimitive(PrimitiveType primType, void *indices, int32 numIndices); void RenderIndexedPrimitive(PrimitiveType primType, void *indices, int32 numIndices);
void End(void); void End(void);

View File

@ -349,7 +349,7 @@ im3dtest(void)
genIm3DRenderIndexed(rw::PRIMTYPETRILIST, indices, 12); genIm3DRenderIndexed(rw::PRIMTYPETRILIST, indices, 12);
genIm3DEnd(); genIm3DEnd();
*/ */
rw::im3d::Transform(verts, 8, nil); rw::im3d::Transform(verts, 8, nil, rw::im3d::EVERYTHING);
rw::im3d::RenderIndexedPrimitive(rw::PRIMTYPETRILIST, indices, 12); rw::im3d::RenderIndexedPrimitive(rw::PRIMTYPETRILIST, indices, 12);
rw::im3d::End(); rw::im3d::End();
} }