more tidying up

This commit is contained in:
aap 2016-06-16 15:35:45 +02:00
parent 7a4fcce861
commit 416ee91bb7
21 changed files with 187 additions and 164 deletions

2
rw.h
View File

@ -13,4 +13,4 @@
#include "src/rwd3d.h"
#include "src/rwd3d8.h"
#include "src/rwd3d9.h"
#include "src/rwogl.h"
#include "src/rwwdgl.h"

View File

@ -10,10 +10,10 @@
#include "rwobjects.h"
#include "rwengine.h"
#include "rwps2.h"
#include "rwogl.h"
#include "rwxbox.h"
#include "rwd3d8.h"
#include "rwd3d9.h"
#include "rwwdgl.h"
using namespace std;

View File

@ -352,9 +352,10 @@ deleteObject(void *object)
int32 nativeRasterOffset;
void
D3dRaster::create(Raster *raster)
static void
rasterCreate(Raster *raster)
{
D3dRaster *natras = PLUGINOFFSET(D3dRaster, raster, nativeRasterOffset);
static uint32 formatMap[] = {
0,
D3DFMT_A1R5G5B5,
@ -384,45 +385,49 @@ D3dRaster::create(Raster *raster)
uint32 format;
if(raster->format & (Raster::PAL4 | Raster::PAL8)){
format = D3DFMT_P8;
this->palette = new uint8[4*256];
natras->palette = new uint8[4*256];
}else
format = formatMap[(raster->format >> 8) & 0xF];
this->format = 0;
this->hasAlpha = alphaMap[(raster->format >> 8) & 0xF];
natras->format = 0;
natras->hasAlpha = alphaMap[(raster->format >> 8) & 0xF];
int32 levels = Raster::calculateNumLevels(raster->width, raster->height);
this->texture = createTexture(raster->width, raster->height,
raster->format & Raster::MIPMAP ? levels : 1,
format);
natras->texture = createTexture(raster->width, raster->height,
raster->format & Raster::MIPMAP ? levels : 1,
format);
}
uint8*
D3dRaster::lock(Raster*, int32 level)
static uint8*
rasterLock(Raster *raster, int32 level)
{
return lockTexture(this->texture, level);
D3dRaster *natras = PLUGINOFFSET(D3dRaster, raster, nativeRasterOffset);
return lockTexture(natras->texture, level);
}
void
D3dRaster::unlock(Raster*, int32 level)
static void
rasterUnlock(Raster *raster, int32 level)
{
unlockTexture(this->texture, level);
D3dRaster *natras = PLUGINOFFSET(D3dRaster, raster, nativeRasterOffset);
unlockTexture(natras->texture, level);
}
int32
D3dRaster::getNumLevels(Raster*)
static int32
rasterNumLevels(Raster *raster)
{
D3dRaster *natras = PLUGINOFFSET(D3dRaster, raster, nativeRasterOffset);
#ifdef RW_D3D9
IDirect3DTexture9 *tex = (IDirect3DTexture9*)this->texture;
IDirect3DTexture9 *tex = (IDirect3DTexture9*)natras->texture;
return tex->GetLevelCount();
#else
RasterLevels *levels = (RasterLevels*)this->texture;
RasterLevels *levels = (RasterLevels*)natras->texture;
return levels->numlevels;
#endif
}
void
D3dRaster::fromImage(Raster *raster, Image *image)
static void
rasterFromImage(Raster *raster, Image *image)
{
int32 format;
D3dRaster *natras = PLUGINOFFSET(D3dRaster, raster, nativeRasterOffset);
switch(image->depth){
case 32:
format = image->hasAlpha() ? Raster::C8888 : Raster::C888;
@ -447,7 +452,7 @@ D3dRaster::fromImage(Raster *raster, Image *image)
raster->type = format & 0x7;
raster->flags = format & 0xF8;
raster->format = format & 0xFF00;
this->create(raster);
rasterCreate(raster);
uint8 *in, *out;
int pallength = 0;
@ -457,7 +462,7 @@ D3dRaster::fromImage(Raster *raster, Image *image)
pallength = 256;
if(pallength){
in = image->palette;
out = (uint8*)this->palette;
out = (uint8*)natras->palette;
for(int32 i = 0; i < pallength; i++){
out[0] = in[2];
out[1] = in[1];
@ -595,7 +600,18 @@ registerNativeRaster(void)
destroyNativeRaster,
copyNativeRaster);
engine[PLATFORM_D3D8].rasterNativeOffset = nativeRasterOffset;
engine[PLATFORM_D3D8].rasterCreate = rasterCreate;
engine[PLATFORM_D3D8].rasterLock = rasterLock;
engine[PLATFORM_D3D8].rasterUnlock = rasterUnlock;
engine[PLATFORM_D3D8].rasterNumLevels = rasterNumLevels;
engine[PLATFORM_D3D8].rasterFromImage = rasterFromImage;
engine[PLATFORM_D3D9].rasterNativeOffset = nativeRasterOffset;
engine[PLATFORM_D3D9].rasterCreate = rasterCreate;
engine[PLATFORM_D3D9].rasterLock = rasterLock;
engine[PLATFORM_D3D9].rasterUnlock = rasterUnlock;
engine[PLATFORM_D3D9].rasterNumLevels = rasterNumLevels;
engine[PLATFORM_D3D9].rasterFromImage = rasterFromImage;
}
}

View File

@ -7,6 +7,7 @@
#include "rwplg.h"
#include "rwpipeline.h"
#include "rwobjects.h"
#include "rwengine.h"
#include "rwd3d.h"
#include "rwd3d8.h"
@ -16,6 +17,12 @@ namespace rw {
namespace d3d8 {
using namespace d3d;
void
initializePlatform(void)
{
engine[PLATFORM_D3D8].defaultPipeline = makeDefaultPipeline();
}
uint32
makeFVFDeclaration(uint32 flags, int32 numTex)
{

View File

@ -7,6 +7,7 @@
#include "rwplg.h"
#include "rwpipeline.h"
#include "rwobjects.h"
#include "rwengine.h"
#include "rwd3d.h"
#include "rwd3d9.h"
@ -21,6 +22,12 @@ using namespace d3d;
#define NUMDECLELT 12
void
initializePlatform(void)
{
engine[PLATFORM_D3D9].defaultPipeline = makeDefaultPipeline();
}
void*
createVertexDeclaration(VertexElement *elements)
{

View File

@ -9,7 +9,7 @@
namespace rw {
Engine engines[NUM_PLATFORMS];
Engine engine[NUM_PLATFORMS];
namespace null {
@ -33,7 +33,7 @@ rasterUnlock(Raster*, int32)
}
int32
rasterNumLevels(Raster*, int32)
rasterNumLevels(Raster*)
{
assert(0 && "rasterNumLevels not implemented");
return 0;

View File

@ -644,13 +644,7 @@ Raster::create(int32 width, int32 height, int32 depth, int32 format, int32 platf
raster->texels = raster->palette = NULL;
raster->constructPlugins();
int32 offset = engine[raster->platform].rasterNativeOffset;
assert(offset != 0 && "unimplemented raster platform");
printf("%X %d\n", offset, raster->platform);
NativeRaster *nr = PLUGINOFFSET(NativeRaster, raster, offset);
printf("%p\n", nr);
nr->create(raster);
printf("created\n");
engine[raster->platform].rasterCreate(raster);
return raster;
}
@ -666,28 +660,19 @@ Raster::destroy(void)
uint8*
Raster::lock(int32 level)
{
int32 offset = engine[this->platform].rasterNativeOffset;
assert(offset != 0 && "unimplemented raster platform");
NativeRaster *nr = PLUGINOFFSET(NativeRaster, this, offset);
return nr->lock(this, level);
return engine[this->platform].rasterLock(this, level);
}
void
Raster::unlock(int32 level)
{
int32 offset = engine[this->platform].rasterNativeOffset;
assert(offset != 0 && "unimplemented raster platform");
NativeRaster *nr = PLUGINOFFSET(NativeRaster, this, offset);
nr->unlock(this, level);
engine[this->platform].rasterUnlock(this, level);
}
int32
Raster::getNumLevels(void)
{
int32 offset = engine[this->platform].rasterNativeOffset;
assert(offset != 0 && "unimplemented raster platform");
NativeRaster *nr = PLUGINOFFSET(NativeRaster, this, offset);
return nr->getNumLevels(this);
return engine[this->platform].rasterNumLevels(this);
}
int32
@ -705,10 +690,7 @@ Raster::createFromImage(Image *image)
{
Raster *raster = Raster::create(image->width, image->height,
image->depth, 4 | 0x80);
int32 offset = engine[raster->platform].rasterNativeOffset;
assert(offset != 0 && "unimplemented raster platform");
NativeRaster *nr = PLUGINOFFSET(NativeRaster, raster, offset);
nr->fromImage(raster, image);
engine[raster->platform].rasterFromImage(raster, image);
return raster;
}

View File

@ -10,10 +10,10 @@
#include "rwplugins.h"
#include "rwps2.h"
#include "rwps2plg.h"
#include "rwogl.h"
#include "rwxbox.h"
#include "rwd3d8.h"
#include "rwd3d9.h"
#include "rwwdgl.h"
using namespace std;
@ -336,7 +336,7 @@ writeMesh(Stream *stream, int32, void *object, int32, int32)
stream->write(buf, 8);
if(geo->geoflags & Geometry::NATIVE){
assert(geo->instData != NULL);
if(geo->instData->platform == PLATFORM_OGL)
if(geo->instData->platform == PLATFORM_WDGL)
stream->write(mesh->indices,
mesh->numIndices*2);
}else{
@ -363,7 +363,7 @@ getSizeMesh(void *object, int32, int32)
int32 size = 12 + geo->meshHeader->numMeshes*8;
if(geo->geoflags & Geometry::NATIVE){
assert(geo->instData != NULL);
if(geo->instData->platform == PLATFORM_OGL)
if(geo->instData->platform == PLATFORM_WDGL)
size += geo->meshHeader->totalIndices*2;
}else{
size += geo->meshHeader->totalIndices*4;
@ -407,8 +407,8 @@ destroyNativeData(void *object, int32 offset, int32 size)
return object;
if(geometry->instData->platform == PLATFORM_PS2)
return ps2::destroyNativeData(object, offset, size);
if(geometry->instData->platform == PLATFORM_OGL)
return gl::destroyNativeData(object, offset, size);
if(geometry->instData->platform == PLATFORM_WDGL)
return wdgl::destroyNativeData(object, offset, size);
if(geometry->instData->platform == PLATFORM_XBOX)
return xbox::destroyNativeData(object, offset, size);
if(geometry->instData->platform == PLATFORM_D3D8)
@ -446,7 +446,7 @@ readNativeData(Stream *stream, int32 len, void *object, int32 o, int32 s)
}
}else{
stream->seek(-12);
gl::readNativeData(stream, len, object, o, s);
wdgl::readNativeData(stream, len, object, o, s);
}
}
@ -458,8 +458,8 @@ writeNativeData(Stream *stream, int32 len, void *object, int32 o, int32 s)
return;
if(geometry->instData->platform == PLATFORM_PS2)
ps2::writeNativeData(stream, len, object, o, s);
else if(geometry->instData->platform == PLATFORM_OGL)
gl::writeNativeData(stream, len, object, o, s);
else if(geometry->instData->platform == PLATFORM_WDGL)
wdgl::writeNativeData(stream, len, object, o, s);
else if(geometry->instData->platform == PLATFORM_XBOX)
xbox::writeNativeData(stream, len, object, o, s);
else if(geometry->instData->platform == PLATFORM_D3D8)
@ -476,8 +476,8 @@ getSizeNativeData(void *object, int32 offset, int32 size)
return -1;
if(geometry->instData->platform == PLATFORM_PS2)
return ps2::getSizeNativeData(object, offset, size);
else if(geometry->instData->platform == PLATFORM_OGL)
return gl::getSizeNativeData(object, offset, size);
else if(geometry->instData->platform == PLATFORM_WDGL)
return wdgl::getSizeNativeData(object, offset, size);
else if(geometry->instData->platform == PLATFORM_XBOX)
return xbox::getSizeNativeData(object, offset, size);
else if(geometry->instData->platform == PLATFORM_D3D8)
@ -558,8 +558,8 @@ readSkin(Stream *stream, int32 len, void *object, int32 offset, int32)
// TODO: function pointers
if(geometry->instData->platform == PLATFORM_PS2)
ps2::readNativeSkin(stream, len, object, offset);
else if(geometry->instData->platform == PLATFORM_OGL)
gl::readNativeSkin(stream, len, object, offset);
else if(geometry->instData->platform == PLATFORM_WDGL)
wdgl::readNativeSkin(stream, len, object, offset);
else if(geometry->instData->platform == PLATFORM_XBOX)
xbox::readNativeSkin(stream, len, object, offset);
else
@ -625,8 +625,8 @@ writeSkin(Stream *stream, int32 len, void *object, int32 offset, int32)
if(geometry->instData){
if(geometry->instData->platform == PLATFORM_PS2)
ps2::writeNativeSkin(stream, len, object, offset);
else if(geometry->instData->platform == PLATFORM_OGL)
gl::writeNativeSkin(stream, len, object, offset);
else if(geometry->instData->platform == PLATFORM_WDGL)
wdgl::writeNativeSkin(stream, len, object, offset);
else if(geometry->instData->platform == PLATFORM_XBOX)
xbox::writeNativeSkin(stream, len, object, offset);
else
@ -672,8 +672,8 @@ getSizeSkin(void *object, int32 offset, int32)
if(geometry->instData){
if(geometry->instData->platform == PLATFORM_PS2)
return ps2::getSizeNativeSkin(object, offset);
if(geometry->instData->platform == PLATFORM_OGL)
return gl::getSizeNativeSkin(object, offset);
if(geometry->instData->platform == PLATFORM_WDGL)
return wdgl::getSizeNativeSkin(object, offset);
if(geometry->instData->platform == PLATFORM_XBOX)
return xbox::getSizeNativeSkin(object, offset);
if(geometry->instData->platform == PLATFORM_D3D8)
@ -713,8 +713,8 @@ registerSkinPlugin(void)
skinGlobals.pipelines[i] = defpipe;
skinGlobals.pipelines[PLATFORM_PS2] =
ps2::makeSkinPipeline();
skinGlobals.pipelines[PLATFORM_OGL] =
gl::makeSkinPipeline();
skinGlobals.pipelines[PLATFORM_WDGL] =
wdgl::makeSkinPipeline();
skinGlobals.pipelines[PLATFORM_XBOX] =
xbox::makeSkinPipeline();
skinGlobals.pipelines[PLATFORM_D3D8] =
@ -1200,8 +1200,8 @@ registerMatFXPlugin(void)
matFXGlobals.pipelines[i] = defpipe;
matFXGlobals.pipelines[PLATFORM_PS2] =
ps2::makeMatFXPipeline();
matFXGlobals.pipelines[PLATFORM_OGL] =
gl::makeMatFXPipeline();
matFXGlobals.pipelines[PLATFORM_WDGL] =
wdgl::makeMatFXPipeline();
matFXGlobals.pipelines[PLATFORM_XBOX] =
xbox::makeMatFXPipeline();
matFXGlobals.pipelines[PLATFORM_D3D8] =

View File

@ -7,6 +7,7 @@
#include "rwplg.h"
#include "rwpipeline.h"
#include "rwobjects.h"
#include "rwengine.h"
#include "rwplugins.h"
#include "rwps2.h"
#include "rwps2plg.h"
@ -14,6 +15,12 @@
namespace rw {
namespace ps2 {
void
initializePlatform(void)
{
engine[PLATFORM_PS2].defaultPipeline = makeDefaultPipeline();
}
ObjPipeline *defaultObjPipe;
MatPipeline *defaultMatPipe;

View File

@ -68,8 +68,8 @@ struct dword
#define ALIGN64(x) ((x) + 0x3F & ~0x3F)
void
Ps2Raster::create(Raster *raster)
static void
rasterCreate(Raster *raster)
{
uint64 bufferWidth[7], bufferBase[7];
int32 pageWidth, pageHeight;
@ -370,7 +370,7 @@ Ps2Raster::create(Raster *raster)
*p++ = 0;
// GIF tag
uint32 sz = paletteSize - 0x50 + 0xF >> 4;
uint32 sz = ras->paletteSize - 0x50 + 0xF >> 4;
*p++ = sz;
*p++ = 0x08000000; // IMAGE
*p++ = 0;
@ -379,8 +379,8 @@ Ps2Raster::create(Raster *raster)
}
}
uint8*
Ps2Raster::lock(Raster *raster, int32 level)
static uint8*
rasterLock(Raster *raster, int32 level)
{
// TODO
(void)raster;
@ -388,16 +388,16 @@ Ps2Raster::lock(Raster *raster, int32 level)
return NULL;
}
void
Ps2Raster::unlock(Raster *raster, int32 level)
static void
rasterUnlock(Raster *raster, int32 level)
{
// TODO
(void)raster;
(void)level;
}
int32
Ps2Raster::getNumLevels(Raster *raster)
static int32
rasterNumLevels(Raster *raster)
{
Ps2Raster *ras = PLUGINOFFSET(Ps2Raster, raster, nativeRasterOffset);
if(raster->texels == NULL) return 0;
@ -482,6 +482,11 @@ registerNativeRaster(void)
destroyNativeRaster,
copyNativeRaster);
engine[PLATFORM_PS2].rasterNativeOffset = nativeRasterOffset;
engine[PLATFORM_PS2].rasterCreate = rasterCreate;
engine[PLATFORM_PS2].rasterLock = rasterLock;
engine[PLATFORM_PS2].rasterUnlock = rasterUnlock;
engine[PLATFORM_PS2].rasterNumLevels = rasterNumLevels;
Texture::registerPlugin(0, ID_SKYMIPMAP, NULL, NULL, NULL);
Texture::registerPluginStream(ID_SKYMIPMAP, readMipmap, writeMipmap, getSizeMipmap);
}

View File

@ -12,10 +12,10 @@
#include "rwplugins.h"
#include "rwengine.h"
#include "rwps2.h"
#include "rwogl.h"
#include "rwxbox.h"
#include "rwd3d8.h"
#include "rwd3d9.h"
#include "rwwdgl.h"
using namespace std;
@ -26,7 +26,7 @@ int32 build = 0xFFFF;
#ifdef RW_PS2
int32 platform = PLATFORM_PS2;
#elif RW_OPENGL
int32 platform = PLATFORM_OGL;
int32 platform = PLATFORM_WDGL;
#elif RW_D3D9
int32 platform = PLATFORM_D3D9;
#else
@ -52,7 +52,10 @@ static Matrix3 identMat3 = {
void
initialize(void)
{
ObjPipeline *defpipe = new ObjPipeline(PLATFORM_NULL);
for(uint i = 0; i < NUM_PLATFORMS; i++){
engine[i].defaultPipeline = defpipe;
engine[i].rasterCreate = null::rasterCreate;
engine[i].rasterLock = null::rasterLock;
engine[i].rasterUnlock = null::rasterUnlock;
@ -60,20 +63,13 @@ initialize(void)
engine[i].rasterFromImage = null::rasterFromImage;
}
// Atomic pipelines
ObjPipeline *defpipe = new ObjPipeline(PLATFORM_NULL);
for(uint i = 0; i < NUM_PLATFORMS; i++)
engine[i].defaultPipeline = defpipe;
engine[PLATFORM_PS2].defaultPipeline =
ps2::makeDefaultPipeline();
engine[PLATFORM_OGL].defaultPipeline =
gl::makeDefaultPipeline();
engine[PLATFORM_XBOX].defaultPipeline =
xbox::makeDefaultPipeline();
engine[PLATFORM_D3D8].defaultPipeline =
d3d8::makeDefaultPipeline();
engine[PLATFORM_D3D9].defaultPipeline =
d3d9::makeDefaultPipeline();
ps2::initializePlatform();
xbox::initializePlatform();
d3d8::initializePlatform();
d3d9::initializePlatform();
wdgl::initializePlatform();
Frame::dirtyList.init();
}

View File

@ -227,7 +227,7 @@ enum Platform
{
PLATFORM_NULL = 0,
// D3D7
PLATFORM_OGL = 2, // TODO: remove, this is really WarDrum GL
PLATFORM_GL = 2,
// MAC
PLATFORM_PS2 = 4,
PLATFORM_XBOX = 5,
@ -236,9 +236,11 @@ enum Platform
PLATFORM_D3D8 = 8,
PLATFORM_D3D9 = 9,
// non stock-RW platforms
// non-stock-RW platforms
PLATFORM_WDGL = 10, // WarDrum OpenGL
PLATFORM_GL3 = 11, // my GL3 implementation
PLATFORM_GL3 = 10,
NUM_PLATFORMS,
FOURCC_PS2 = 0x00325350 // 'PS2\0'

View File

@ -74,19 +74,13 @@ void deleteObject(void *object);
// Native Texture and Raster
struct D3dRaster : NativeRaster
struct D3dRaster
{
void *texture;
void *palette;
uint32 format;
bool32 hasAlpha;
bool32 customFormat;
virtual void create(Raster *raster);
virtual uint8 *lock(Raster *raster, int32 level);
virtual void unlock(Raster *raster, int32 level);
virtual int32 getNumLevels(Raster *raster);
virtual void fromImage(Raster *raster, Image *img);
};
int32 getLevelSize(Raster *raster, int32 level);

View File

@ -1,6 +1,8 @@
namespace rw {
namespace d3d8 {
void initializePlatform(void);
struct InstanceData
{
uint32 minVert;

View File

@ -1,6 +1,8 @@
namespace rw {
namespace d3d9 {
void initializePlatform(void);
struct VertexElement
{
uint16 stream;

View File

@ -226,20 +226,6 @@ extern bool32 loadTextures;
#define IGNORERASTERIMP 0
struct NativeRaster
{
virtual void create(Raster*)
{ assert(IGNORERASTERIMP && "NativeRaster::create unimplemented"); };
virtual uint8 *lock(Raster*, int32)
{ assert(IGNORERASTERIMP && "NativeRaster::lock unimplemented"); return NULL; };
virtual void unlock(Raster*, int32)
{ assert(IGNORERASTERIMP && "NativeRaster::unlock unimplemented"); };
virtual int32 getNumLevels(Raster*)
{ assert(IGNORERASTERIMP && "NativeRaster::getNumLevels unimplemented"); return 0; };
virtual void fromImage(Raster*, Image *img)
{ assert(IGNORERASTERIMP && "NativeRaster::fromImage unimplemented"); };
};
struct TexDictionary;
struct Texture : PluginBase<Texture>

View File

@ -1,6 +1,8 @@
namespace rw {
namespace ps2 {
void initializePlatform(void);
struct InstanceData
{
// 0 - addresses in ref tags need fixing
@ -176,7 +178,7 @@ void registerPluginPDSPipes(void);
// Native Texture and Raster
struct Ps2Raster : NativeRaster
struct Ps2Raster
{
uint32 tex0[2];
uint32 tex1[2];
@ -189,11 +191,6 @@ struct Ps2Raster : NativeRaster
uint8 *data; //tmp
uint32 dataSize;
virtual void create(Raster *raster);
virtual uint8 *lock(Raster *raster, int32 level);
virtual void unlock(Raster *raster, int32 level);
virtual int32 getNumLevels(Raster *raster);
};
extern int32 nativeRasterOffset;

View File

@ -1,8 +1,10 @@
namespace rw {
namespace gl {
namespace wdgl {
// NOTE: This is not really RW OpenGL! It's specific to WarDrum's GTA ports
void initializePlatform(void);
struct AttribDesc
{
// arguments to glVertexAttribPointer (should use OpenGL types here)

View File

@ -1,6 +1,8 @@
namespace rw {
namespace xbox {
void initializePlatform(void);
struct InstanceData
{
uint32 minVert;
@ -66,18 +68,13 @@ void registerVertexFormatPlugin(void);
// Native Texture and Raster
struct XboxRaster : NativeRaster
struct XboxRaster
{
void *texture;
void *palette;
uint32 format;
bool32 hasAlpha;
bool32 unknownFlag;
virtual void create(Raster *raster);
virtual uint8 *lock(Raster *raster, int32 level);
virtual void unlock(Raster *raster, int32 level);
virtual int32 getNumLevels(Raster *raster);
};
int32 getLevelSize(Raster *raster, int32 level);

View File

@ -7,8 +7,9 @@
#include "rwplg.h"
#include "rwpipeline.h"
#include "rwobjects.h"
#include "rwengine.h"
#include "rwplugins.h"
#include "rwogl.h"
#include "rwwdgl.h"
#ifdef RW_OPENGL
#include <GL/glew.h>
@ -17,7 +18,14 @@
using namespace std;
namespace rw {
namespace gl {
namespace wdgl {
void
initializePlatform(void)
{
engine[PLATFORM_WDGL].defaultPipeline = makeDefaultPipeline();
}
// VC
// 8733 0 0 0 3
@ -209,7 +217,7 @@ void*
destroyNativeData(void *object, int32, int32)
{
Geometry *geometry = (Geometry*)object;
assert(geometry->instData->platform == PLATFORM_OGL);
assert(geometry->instData->platform == PLATFORM_WDGL);
InstanceDataHeader *header =
(InstanceDataHeader*)geometry->instData;
geometry->instData = NULL;
@ -226,7 +234,7 @@ readNativeData(Stream *stream, int32, void *object, int32, int32)
Geometry *geometry = (Geometry*)object;
InstanceDataHeader *header = new InstanceDataHeader;
geometry->instData = header;
header->platform = PLATFORM_OGL;
header->platform = PLATFORM_WDGL;
header->vbo = 0;
header->ibo = 0;
header->numAttribs = stream->readU32();
@ -242,7 +250,7 @@ void
writeNativeData(Stream *stream, int32, void *object, int32, int32)
{
Geometry *geometry = (Geometry*)object;
assert(geometry->instData->platform == PLATFORM_OGL);
assert(geometry->instData->platform == PLATFORM_WDGL);
InstanceDataHeader *header = (InstanceDataHeader*)geometry->instData;
stream->writeU32(header->numAttribs);
stream->write(header->attribs, header->numAttribs*sizeof(AttribDesc));
@ -253,7 +261,7 @@ int32
getSizeNativeData(void *object, int32, int32)
{
Geometry *geometry = (Geometry*)object;
assert(geometry->instData->platform == PLATFORM_OGL);
assert(geometry->instData->platform == PLATFORM_WDGL);
InstanceDataHeader *header = (InstanceDataHeader*)geometry->instData;
return 4 + header->numAttribs*sizeof(AttribDesc) + header->dataSize;
}
@ -273,7 +281,7 @@ void
printPipeinfo(Atomic *a)
{
Geometry *g = a->geometry;
if(g->instData == NULL || g->instData->platform != PLATFORM_OGL)
if(g->instData == NULL || g->instData->platform != PLATFORM_WDGL)
return;
int32 plgid = 0;
if(a->pipeline)
@ -294,7 +302,7 @@ instance(rw::ObjPipeline *rwpipe, Atomic *atomic)
return;
InstanceDataHeader *header = new InstanceDataHeader;
geo->instData = header;
header->platform = PLATFORM_OGL;
header->platform = PLATFORM_WDGL;
header->vbo = 0;
header->ibo = 0;
header->numAttribs =
@ -420,7 +428,7 @@ uninstance(rw::ObjPipeline *rwpipe, Atomic *atomic)
if((geo->geoflags & Geometry::NATIVE) == 0)
return;
assert(geo->instData != NULL);
assert(geo->instData->platform == PLATFORM_OGL);
assert(geo->instData->platform == PLATFORM_WDGL);
geo->geoflags &= ~Geometry::NATIVE;
geo->allocateData();
@ -488,8 +496,8 @@ ObjPipeline::ObjPipeline(uint32 platform)
: rw::ObjPipeline(platform)
{
this->numCustomAttribs = 0;
this->impl.instance = gl::instance;
this->impl.uninstance = gl::uninstance;
this->impl.instance = wdgl::instance;
this->impl.uninstance = wdgl::uninstance;
this->instanceCB = NULL;
this->uninstanceCB = NULL;
}
@ -497,7 +505,7 @@ ObjPipeline::ObjPipeline(uint32 platform)
ObjPipeline*
makeDefaultPipeline(void)
{
ObjPipeline *pipe = new ObjPipeline(PLATFORM_OGL);
ObjPipeline *pipe = new ObjPipeline(PLATFORM_WDGL);
return pipe;
}
@ -509,7 +517,7 @@ readNativeSkin(Stream *stream, int32, void *object, int32 offset)
uint32 vers;
Geometry *geometry = (Geometry*)object;
assert(findChunk(stream, ID_STRUCT, NULL, &vers));
assert(stream->readU32() == PLATFORM_OGL);
assert(stream->readU32() == PLATFORM_WDGL);
Skin *skin = new Skin;
*PLUGINOFFSET(Skin*, geometry, offset) = skin;
@ -522,7 +530,7 @@ void
writeNativeSkin(Stream *stream, int32 len, void *object, int32 offset)
{
writeChunkHeader(stream, ID_STRUCT, len-12);
stream->writeU32(PLATFORM_OGL);
stream->writeU32(PLATFORM_WDGL);
Skin *skin = *PLUGINOFFSET(Skin*, object, offset);
stream->writeI32(skin->numBones);
stream->write(skin->inverseMatrices, skin->numBones*64);
@ -636,7 +644,7 @@ skinUninstanceCB(Geometry *geo)
ObjPipeline*
makeSkinPipeline(void)
{
ObjPipeline *pipe = new ObjPipeline(PLATFORM_OGL);
ObjPipeline *pipe = new ObjPipeline(PLATFORM_WDGL);
pipe->pluginID = ID_SKIN;
pipe->pluginData = 1;
pipe->numCustomAttribs = 2;
@ -648,7 +656,7 @@ makeSkinPipeline(void)
ObjPipeline*
makeMatFXPipeline(void)
{
ObjPipeline *pipe = new ObjPipeline(PLATFORM_OGL);
ObjPipeline *pipe = new ObjPipeline(PLATFORM_WDGL);
pipe->pluginID = ID_MATFX;
pipe->pluginData = 0;
return pipe;
@ -690,7 +698,7 @@ void
registerNativeRaster(void)
{
nativeRasterOffset = Raster::registerPlugin(sizeof(GlRaster),
0x12340000 | PLATFORM_OGL,
0x12340000 | PLATFORM_WDGL,
createNativeRaster,
destroyNativeRaster,
copyNativeRaster);

View File

@ -18,6 +18,12 @@ using namespace std;
namespace rw {
namespace xbox {
void
initializePlatform(void)
{
engine[PLATFORM_XBOX].defaultPipeline = makeDefaultPipeline();
}
void*
destroyNativeData(void *object, int32, int32)
{
@ -753,9 +759,10 @@ createTexture(int32 width, int32 height, int32 numlevels, uint32 format)
return levels;
}
void
XboxRaster::create(Raster *raster)
static void
rasterCreate(Raster *raster)
{
XboxRaster *natras = PLUGINOFFSET(XboxRaster, raster, nativeRasterOffset);
static uint32 formatMap[] = {
D3DFMT_UNKNOWN,
D3DFMT_A1R5G5B5,
@ -791,33 +798,35 @@ XboxRaster::create(Raster *raster)
uint32 format;
if(raster->format & (Raster::PAL4 | Raster::PAL8)){
format = D3DFMT_P8;
this->palette = new uint8[4*256];
natras->palette = new uint8[4*256];
}else
format = formatMap[(raster->format >> 8) & 0xF];
this->format = 0;
this->hasAlpha = alphaMap[(raster->format >> 8) & 0xF];
natras->format = 0;
natras->hasAlpha = alphaMap[(raster->format >> 8) & 0xF];
int32 levels = Raster::calculateNumLevels(raster->width, raster->height);
this->texture = createTexture(raster->width, raster->height,
raster->format & Raster::MIPMAP ? levels : 1,
format);
natras->texture = createTexture(raster->width, raster->height,
raster->format & Raster::MIPMAP ? levels : 1,
format);
}
uint8*
XboxRaster::lock(Raster*, int32 level)
static uint8*
rasterLock(Raster *raster, int32 level)
{
RasterLevels *levels = (RasterLevels*)this->texture;
XboxRaster *natras = PLUGINOFFSET(XboxRaster, raster, nativeRasterOffset);
RasterLevels *levels = (RasterLevels*)natras->texture;
return levels->levels[level].data;
}
void
XboxRaster::unlock(Raster*, int32)
static void
rasterUnlock(Raster*, int32)
{
}
int32
XboxRaster::getNumLevels(Raster*)
static int32
rasterNumLevels(Raster *raster)
{
RasterLevels *levels = (RasterLevels*)this->texture;
XboxRaster *natras = PLUGINOFFSET(XboxRaster, raster, nativeRasterOffset);
RasterLevels *levels = (RasterLevels*)natras->texture;
return levels->numlevels;
}
@ -870,6 +879,10 @@ registerNativeRaster(void)
destroyNativeRaster,
copyNativeRaster);
engine[PLATFORM_XBOX].rasterNativeOffset = nativeRasterOffset;
engine[PLATFORM_XBOX].rasterCreate = rasterCreate;
engine[PLATFORM_XBOX].rasterLock = rasterLock;
engine[PLATFORM_XBOX].rasterUnlock = rasterUnlock;
engine[PLATFORM_XBOX].rasterNumLevels = rasterNumLevels;
}
Texture*