2016-06-16 14:08:09 +02:00
|
|
|
namespace rw {
|
|
|
|
|
2016-07-05 11:36:43 +02:00
|
|
|
enum RenderState
|
|
|
|
{
|
|
|
|
VERTEXALPHA = 0,
|
|
|
|
SRCBLEND,
|
|
|
|
DESTBLEND,
|
|
|
|
ZTESTENABLE,
|
|
|
|
ZWRITEENABLE,
|
2016-07-05 18:22:22 +02:00
|
|
|
FOGENABLE,
|
|
|
|
FOGCOLOR,
|
2016-07-05 11:36:43 +02:00
|
|
|
// TODO:
|
2016-07-05 18:22:22 +02:00
|
|
|
// fog type, density ?
|
2016-07-05 11:36:43 +02:00
|
|
|
// ? cullmode
|
|
|
|
// ? shademode
|
|
|
|
// ???? stencil
|
|
|
|
|
|
|
|
// platform specific or opaque?
|
|
|
|
ALPHATESTFUNC,
|
|
|
|
ALPHATESTREF,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum AlphaTestFunc
|
|
|
|
{
|
2017-08-09 10:57:32 +02:00
|
|
|
ALPHAALWAYS = 0,
|
|
|
|
ALPHAGREATEREQUAL,
|
|
|
|
ALPHALESS
|
2016-07-05 11:36:43 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
enum BlendFunction
|
|
|
|
{
|
|
|
|
BLENDZERO = 0,
|
|
|
|
BLENDONE,
|
|
|
|
BLENDSRCCOLOR,
|
|
|
|
BLENDINVSRCCOLOR,
|
|
|
|
BLENDSRCALPHA,
|
|
|
|
BLENDINVSRCALPHA,
|
|
|
|
BLENDDESTALPHA,
|
|
|
|
BLENDINVDESTALPHA,
|
|
|
|
BLENDDESTCOLOR,
|
|
|
|
BLENDINVDESTCOLOR,
|
|
|
|
BLENDSRCALPHASAT,
|
|
|
|
// TODO: add more perhaps
|
|
|
|
};
|
|
|
|
|
2017-08-09 10:57:32 +02:00
|
|
|
enum DeviceReq
|
2016-06-21 23:16:09 +02:00
|
|
|
{
|
2017-08-09 10:57:32 +02:00
|
|
|
// Device/Context creation
|
|
|
|
DEVICESTART,
|
|
|
|
// Device initialization before Engine/Driver plugins are opened
|
|
|
|
DEVICEINIT,
|
|
|
|
// Device/Context shutdown
|
|
|
|
DEVICESTOP,
|
|
|
|
};
|
2016-08-05 01:13:41 +02:00
|
|
|
|
2017-08-09 10:57:32 +02:00
|
|
|
typedef int DeviceSystem(DeviceReq req, void *arg0);
|
2016-06-21 23:16:09 +02:00
|
|
|
|
2017-08-09 10:57:32 +02:00
|
|
|
// This is for the render device, we only have one
|
|
|
|
struct Device
|
|
|
|
{
|
2016-07-06 11:44:59 +02:00
|
|
|
float32 zNear, zFar;
|
2016-07-15 11:55:52 +02:00
|
|
|
void (*beginUpdate)(Camera*);
|
|
|
|
void (*endUpdate)(Camera*);
|
|
|
|
void (*clearCamera)(Camera*, RGBA *col, uint32 mode);
|
2017-08-09 10:57:32 +02:00
|
|
|
void (*showRaster)(Raster *raster);
|
2016-07-06 11:44:59 +02:00
|
|
|
void (*setRenderState)(int32 state, uint32 value);
|
|
|
|
uint32 (*getRenderState)(int32 state);
|
2016-08-21 18:20:27 +02:00
|
|
|
void (*im2DRenderIndexedPrimitive)(PrimitiveType,
|
|
|
|
void*, int32, void*, int32);
|
2017-08-09 10:57:32 +02:00
|
|
|
DeviceSystem *system;
|
2016-06-25 17:58:52 +02:00
|
|
|
};
|
2016-06-21 23:16:09 +02:00
|
|
|
|
2017-08-09 10:57:32 +02:00
|
|
|
// This is for platform-dependent but portable things
|
|
|
|
// so the engine has one for every platform
|
2016-06-21 23:16:09 +02:00
|
|
|
struct Driver
|
2016-06-16 14:08:09 +02:00
|
|
|
{
|
|
|
|
ObjPipeline *defaultPipeline;
|
|
|
|
int32 rasterNativeOffset;
|
|
|
|
|
|
|
|
void (*rasterCreate)(Raster*);
|
|
|
|
uint8 *(*rasterLock)(Raster*, int32 level);
|
|
|
|
void (*rasterUnlock)(Raster*, int32 level);
|
|
|
|
int32 (*rasterNumLevels)(Raster*);
|
|
|
|
void (*rasterFromImage)(Raster*, Image*);
|
2016-07-15 11:55:52 +02:00
|
|
|
Image *(*rasterToImage)(Raster*);
|
2016-06-27 21:59:35 +02:00
|
|
|
|
|
|
|
static PluginList s_plglist[NUM_PLATFORMS];
|
2016-06-29 12:53:02 +02:00
|
|
|
static int32 registerPlugin(int32 platform, int32 size, uint32 id,
|
2016-06-27 21:59:35 +02:00
|
|
|
Constructor ctor, Destructor dtor){
|
|
|
|
return s_plglist[platform].registerPlugin(size, id,
|
|
|
|
ctor, dtor, nil);
|
|
|
|
}
|
2016-06-16 14:08:09 +02:00
|
|
|
};
|
|
|
|
|
2017-08-09 10:57:32 +02:00
|
|
|
struct EngineStartParams;
|
|
|
|
|
|
|
|
// This is for platform independent things
|
|
|
|
// TODO: move more stuff into this
|
|
|
|
// TODO: make this have plugins and allocate in Engine::open
|
|
|
|
struct Engine
|
|
|
|
{
|
|
|
|
enum State {
|
|
|
|
Dead = 0,
|
|
|
|
Initialized,
|
|
|
|
Opened,
|
|
|
|
Started
|
|
|
|
};
|
|
|
|
void *currentCamera;
|
|
|
|
void *currentWorld;
|
|
|
|
Texture *imtexture;
|
|
|
|
|
|
|
|
TexDictionary *currentTexDictionary;
|
|
|
|
// load textures from files
|
|
|
|
bool32 loadTextures;
|
|
|
|
// create dummy textures to store just names
|
|
|
|
bool32 makeDummies;
|
|
|
|
// Dynamically allocated because of plugins
|
|
|
|
Driver *driver[NUM_PLATFORMS];
|
|
|
|
Device device;
|
|
|
|
|
|
|
|
static State state;
|
|
|
|
|
|
|
|
static bool32 init(void);
|
|
|
|
static bool32 open(void);
|
|
|
|
static bool32 start(EngineStartParams*);
|
2017-08-10 00:42:33 +02:00
|
|
|
static void term(void);
|
|
|
|
static void close(void);
|
2017-08-09 10:57:32 +02:00
|
|
|
static void stop(void);
|
|
|
|
};
|
|
|
|
|
|
|
|
extern Engine *engine;
|
2016-06-16 14:08:09 +02:00
|
|
|
|
2017-07-12 10:10:57 +02:00
|
|
|
inline void SetRenderState(int32 state, uint32 value){
|
2017-08-09 10:57:32 +02:00
|
|
|
engine->device.setRenderState(state, value); }
|
2016-07-05 11:36:43 +02:00
|
|
|
|
2017-07-12 10:10:57 +02:00
|
|
|
inline uint32 GetRenderState(int32 state){
|
2017-08-09 10:57:32 +02:00
|
|
|
return engine->device.getRenderState(state); }
|
2016-07-05 11:36:43 +02:00
|
|
|
|
2016-06-16 14:08:09 +02:00
|
|
|
namespace null {
|
2016-06-21 23:16:09 +02:00
|
|
|
void beginUpdate(Camera*);
|
|
|
|
void endUpdate(Camera*);
|
2016-07-05 18:22:22 +02:00
|
|
|
void clearCamera(Camera*, RGBA *col, uint32 mode);
|
2016-06-21 23:16:09 +02:00
|
|
|
|
2016-07-05 11:36:43 +02:00
|
|
|
void setRenderState(int32 state, uint32 value);
|
|
|
|
uint32 getRenderState(int32 state);
|
|
|
|
|
2016-06-16 14:08:09 +02:00
|
|
|
void rasterCreate(Raster*);
|
|
|
|
uint8 *rasterLock(Raster*, int32 level);
|
|
|
|
void rasterUnlock(Raster*, int32 level);
|
|
|
|
int32 rasterNumLevels(Raster*);
|
|
|
|
void rasterFromImage(Raster*, Image*);
|
2016-07-15 11:55:52 +02:00
|
|
|
Image *rasterToImage(Raster*);
|
2016-08-21 18:20:27 +02:00
|
|
|
|
|
|
|
void im2DRenderIndexedPrimitive(PrimitiveType,
|
|
|
|
void*, int32, void*, int32);
|
2017-08-09 10:57:32 +02:00
|
|
|
|
|
|
|
int deviceSystem(DeviceReq req);
|
|
|
|
|
|
|
|
extern Device renderdevice;
|
2016-06-16 14:08:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|