finished lights example

This commit is contained in:
aap
2021-03-03 02:00:52 +01:00
parent af20de4522
commit 0921a2b003
10 changed files with 708 additions and 173 deletions

View File

@@ -3,6 +3,7 @@
#include "rwbase.h"
#include "rwplg.h"
#include "rwengine.h"
#include "rwrender.h"
namespace rw {
@@ -57,6 +58,23 @@ Transform(void *vertices, int32 numVertices, Matrix *world, uint32 flags)
engine->device.im3DTransform(vertices, numVertices, world, flags);
}
void
RenderLine(int32 vert1, int32 vert2)
{
int16 indices[2];
indices[0] = vert1;
indices[1] = vert2;
RenderIndexedPrimitive(rw::PRIMTYPELINELIST, indices, 2);
}
void
RenderTriangle(int32 vert1, int32 vert2, int32 vert3)
{
int16 indices[3];
indices[0] = vert1;
indices[1] = vert2;
indices[2] = vert3;
RenderIndexedPrimitive(rw::PRIMTYPETRILIST, indices, 3);
}
void
RenderPrimitive(PrimitiveType primType)
{
engine->device.im3DRenderPrimitive(primType);

View File

@@ -860,7 +860,7 @@ struct World
static int32 numAllocated;
static World *create(void);
static World *create(BBox *bbox = nil); // TODO: should probably make this non-optional
void destroy(void);
void addLight(Light *light);
void removeLight(Light *light);

View File

@@ -127,6 +127,8 @@ enum TransformFlags
};
void Transform(void *vertices, int32 numVertices, Matrix *world, uint32 flags);
void RenderLine(int32 vert1, int32 vert2);
void RenderTriangle(int32 vert1, int32 vert2, int32 vert3);
void RenderPrimitive(PrimitiveType primType);
void RenderIndexedPrimitive(PrimitiveType primType, void *indices, int32 numIndices);
void End(void);

View File

@@ -19,7 +19,7 @@ int32 World::numAllocated = 0;
PluginList World::s_plglist(sizeof(World));
World*
World::create(void)
World::create(BBox *bbox)
{
World *world = (World*)rwMalloc(s_plglist.size, MEMDUR_EVENT | ID_WORLD);
if(world == nil){