diff --git a/.gitignore b/.gitignore index 42eb169..a2e661e 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ *.bat *.sis *.sisx +*.d ## Ignore Visual Studio temporary files, build results, and ## files generated by popular Visual Studio add-ons. diff --git a/group/librw.mmh b/group/librw.mmh index f722c30..1eba534 100644 --- a/group/librw.mmh +++ b/group/librw.mmh @@ -14,8 +14,7 @@ SOURCE engine.cpp error.cpp frame.cpp geometry.cpp geoplg.cpp SOURCEPATH ../vendor/librw/src/gl SOURCE gl3.cpp gl3device.cpp gl3immed.cpp gl3matfx.cpp gl3pipe.cpp gl3raster.cpp gl3render.cpp gl3shader.cpp gl3skin.cpp wdgl.cpp SOURCEPATH ../vendor/librw/src/gles1 -SOURCE rwgles1.cpp -//gl1.cpp gl1device.cpp gl1immed.cpp gl1pipe.cpp gl1raster.cpp gl1render.cpp +SOURCE gl1.cpp gl1device.cpp gl1immed.cpp gl1pipe.cpp gl1raster.cpp gl1render.cpp SOURCEPATH ../vendor/librw/src SOURCE hanim.cpp image.cpp light.cpp SOURCEPATH ../vendor/librw/src/lodepng diff --git a/group/re3_gles1.mmp b/group/re3_gles1.mmp index 3fdac93..690f1b2 100644 --- a/group/re3_gles1.mmp +++ b/group/re3_gles1.mmp @@ -5,4 +5,5 @@ TARGET re3.exe LIBRARY libstdcpp.lib LIBRARY libgles_cm.lib STATICLIBRARY librw_gles1.lib +ARMFPU softvfp #include "re3.mmh" \ No newline at end of file diff --git a/group/re3_gles2.mmp b/group/re3_gles2.mmp index 6a84b1e..258d08b 100644 --- a/group/re3_gles2.mmp +++ b/group/re3_gles2.mmp @@ -6,4 +6,5 @@ LIBRARY libglesv2.lib LIBRARY libegl.lib LIBRARY platformver.lib STATICLIBRARY librw_gles2.lib +ARMFPU softvfp+vfpv2 #include "re3.mmh" \ No newline at end of file diff --git a/vendor/librw/src/engine.cpp b/vendor/librw/src/engine.cpp index e559a36..d3ce4e3 100644 --- a/vendor/librw/src/engine.cpp +++ b/vendor/librw/src/engine.cpp @@ -268,13 +268,13 @@ Engine::open(EngineOpenParams *p) // Initialize device // Device and possibly OS specific! -#ifdef RW_PS2 +#if defined RW_PS2 engine->device = ps2::renderdevice; -#elif RW_GL3 +#elif defined RW_GL3 engine->device = gl3::renderdevice; -#elif RW_GLES1 - //engine->device = gles1::renderdevice; -#elif RW_D3D9 +#elif defined RW_GLES1 + engine->device = gles1::renderdevice; +#elif defined RW_D3D9 engine->device = d3d::renderdevice; #else engine->device = null::renderdevice; diff --git a/vendor/librw/src/gles1/gl1raster.cpp b/vendor/librw/src/gles1/gl1raster.cpp index 9d59424..51d1eed 100644 --- a/vendor/librw/src/gles1/gl1raster.cpp +++ b/vendor/librw/src/gles1/gl1raster.cpp @@ -132,10 +132,10 @@ rasterCreateTexture(Raster *raster) glGenTextures(1, &natras->texid); uint32 prev = bindTexture(natras->texid); - glTexImage2D(GL_TEXTURE_2D, 0, natras->internalFormat, -// raster->width, raster->height, - 1,1, - 0, natras->format, natras->type, nil); +// glTexImage2D(GL_TEXTURE_2D, 0, natras->internalFormat, +//// raster->width, raster->height, +// 1,1, +// 0, natras->format, natras->type, nil); // TODO: allocate other levels...probably natras->filterMode = 0; natras->addressU = 0; @@ -372,16 +372,12 @@ rasterLock(Raster *raster, int32 level, int32 lockMode) raster->pixels = px; if(lockMode & Raster::LOCKREAD || !(lockMode & Raster::LOCKNOFETCH)){ - if(natras->isCompressed){ - if(natras->backingStore){ - assert(level < natras->backingStore->numlevels); - assert(allocSz >= natras->backingStore->levels[level].size); - memcpy(px, natras->backingStore->levels[level].data, allocSz); - }else{ - // GLES is losing here - } + if(natras->backingStore){ + assert(level < natras->backingStore->numlevels); + assert(allocSz >= natras->backingStore->levels[level].size); + memcpy(px, natras->backingStore->levels[level].data, allocSz); } else { - // TODO + memset(px, 0, allocSz); } } @@ -440,37 +436,49 @@ rasterUnlock(Raster *raster, int32 level) raster->width, raster->height, 0, getLevelSize(raster, level), raster->pixels); - if(natras->backingStore){ - assert(level < natras->backingStore->numlevels); - memcpy(natras->backingStore->levels[level].data, raster->pixels, - natras->backingStore->levels[level].size); - } }else{ -// if (raster->pixels != nil && natras->format == GL_RGBA && natras->type == GL_UNSIGNED_BYTE) { -// // convert to 16-bit -// uint16_t* pixels16 = (uint16_t*)malloc(raster->width * raster->height * sizeof(uint16_t)); -// uint8_t* pixels8 = (uint8_t*)raster->pixels; -// -// for (int i = 0; i < raster->width * raster->height; i++) { -// uint8_t r = pixels8[i * 4 + 0]; -// uint8_t g = pixels8[i * 4 + 1]; -// uint8_t b = pixels8[i * 4 + 2]; -// uint8_t a = pixels8[i * 4 + 3]; -// -// pixels16[i] = ((r >> 4) << 12) | ((g >> 4) << 8) | ((b >> 4) << 4) | (a >> 4); -// } -// glTexImage2D(GL_TEXTURE_2D, level, GL_RGBA, raster->width, raster->height, 0, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, pixels16); -// free(pixels16); -// } else + int stride = raster->width * natras->bpp; + uint8_t* tmp = (uint8_t*)malloc(stride); + for (int y = 0; y < raster->height / 2; y++) { + uint8_t* a = (uint8_t*)raster->pixels + y * stride; + uint8_t* b = (uint8_t*)raster->pixels + (raster->height - 1 - y) * stride; + + memcpy(tmp, a, stride); + memcpy(a, b, stride); + memcpy(b, tmp, stride); + } + free(tmp); + + if (raster->pixels != nil && natras->format == GL_RGBA && natras->type == GL_UNSIGNED_BYTE) { + // convert to 16-bit + uint16_t* pixels16 = (uint16_t*)malloc(raster->width * raster->height * sizeof(uint16_t)); + uint8_t* pixels8 = (uint8_t*)raster->pixels; + + for (int i = 0; i < raster->width * raster->height; i++) { + uint8_t r = pixels8[i * 4 + 0]; + uint8_t g = pixels8[i * 4 + 1]; + uint8_t b = pixels8[i * 4 + 2]; + uint8_t a = pixels8[i * 4 + 3]; + + pixels16[i] = ((r >> 4) << 12) | ((g >> 4) << 8) | ((b >> 4) << 4) | (a >> 4); + } + glTexImage2D(GL_TEXTURE_2D, level, GL_RGBA, raster->width, raster->height, 0, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, pixels16); + free(pixels16); + } else { - glPixelStorei(GL_UNPACK_ALIGNMENT, 1); +// glPixelStorei(GL_UNPACK_ALIGNMENT, 1); glTexImage2D(GL_TEXTURE_2D, level, natras->internalFormat, raster->width, raster->height, 0, natras->format, natras->type, raster->pixels); } } -// if(level == 0 && natras->autogenMipmap) -// glGenerateMipmap(GL_TEXTURE_2D); + + if(natras->backingStore){ + assert(level < natras->backingStore->numlevels); + memcpy(natras->backingStore->levels[level].data, raster->pixels, + natras->backingStore->levels[level].size); + } + bindTexture(prev); } break; diff --git a/vendor/librw/src/gles1/rwgles1.cpp b/vendor/librw/src/gles1/rwgles1.cpp deleted file mode 100644 index e393e51..0000000 --- a/vendor/librw/src/gles1/rwgles1.cpp +++ /dev/null @@ -1,54 +0,0 @@ -#include "rwgles1.h" - -namespace rw { - -namespace gles1 { - -// --- Funciones dummy (para linkear después) --- - -inline void im2DRenderPrimitive(int, void*, int) {} -inline void im2DRenderIndexedPrimitive(int, void*, int, void*, int) {} -inline void im3DTransform(void*, int, void*, unsigned int) {} -inline void im3DRenderPrimitive(int) {} -inline void im3DRenderIndexedPrimitive(int, void*, int) {} -inline void im3DEnd(void) {} - -// --- Driver lifecycle --- -static void* -driverOpen(void* object, int32 offset, int32 size) -{ - // stub: no hace nada - return object; -} - -static void* -driverClose(void* object, int32 offset, int32 size) -{ - // stub: no hace nada - return object; -} - -// --- Raster --- -static void -registerNativeRaster(void) -{ - // stub por ahora -} - -void -registerPlatformPlugins(void) -{ - Driver::registerPlugin(PLATFORM_GLES1, 0, PLATFORM_GLES1, - driverOpen, driverClose); - registerNativeRaster(); -} - -void* -destroyNativeData(void *object, int32, int32) -{ - //freeInstanceData((Geometry*)object); - return object; -} - -} -} diff --git a/vendor/librw/src/gles1/rwgles1.h b/vendor/librw/src/gles1/rwgles1.h index f52e751..0c15375 100644 --- a/vendor/librw/src/gles1/rwgles1.h +++ b/vendor/librw/src/gles1/rwgles1.h @@ -1,28 +1,7 @@ -#pragma once - -#include -#include -#include -#include - -#include "../rwbase.h" -#include "../rwerror.h" -#include "../rwplg.h" -#include "../rwpipeline.h" -#include "../rwobjects.h" -#include "../rwengine.h" - #ifdef RW_GLES1 -#include -#include -#ifdef __SYMBIAN32__ - -#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0 -#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1 -#define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2 -#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3 - -#endif +#include +//#include +#include #endif namespace rw { @@ -30,83 +9,247 @@ namespace rw { #ifdef RW_GLES1 struct EngineOpenParams { -#ifdef __SYMBIAN32__ - void *window; // en Symbian no hay GLFW/SDL -#else - void *window; // stub igual -#endif - int width, height; + int width, height; + const char *windowtitle; }; #endif namespace gles1 { -// --- Tipos básicos que charset.cpp y otros esperan --- - -struct Im2DVertex { - float x, y, z, w; - float camZ; - float recipCamZ; - unsigned char r, g, b, a; - float u, v; - - // --- setters esperados por librw --- - - void setScreenX(float v) { x = v; } - void setScreenY(float v) { y = v; } - void setScreenZ(float v) { z = v; } - - void setCameraZ(float v) { camZ = v; } - void setRecipCameraZ(float v) { recipCamZ = v; } - - void setColor(unsigned char _r, unsigned char _g, unsigned char _b, unsigned char _a) { - r = _r; g = _g; b = _b; a = _a; - } - - void setU(float val, float recipZ) { u = val; } - void setV(float val, float recipZ) { v = val; } -}; - -struct Im3DVertex { - float x, y, z; - float u, v; - uint32 color; - - void setX(float v) { x = v; } - void setY(float v) { y = v; } - void setZ(float v) { z = v; } - - void setU(float v) { u = v; } - void setV(float v) { this->v = v; } - - void setColor(uint8 r, uint8 g, uint8 b, uint8 a) { - color = (a<<24) | (r<<16) | (g<<8) | b; - } -}; - -// --- Funciones dummy (para linkear después) --- - -inline void im2DRenderPrimitive(int, void*, int); -inline void im2DRenderIndexedPrimitive(int, void*, int, void*, int); -inline void im3DTransform(void*, int, void*, unsigned int); -inline void im3DRenderPrimitive(int); -inline void im3DRenderIndexedPrimitive(int, void*, int); -inline void im3DEnd(void); - -// --- Driver lifecycle --- -static void* -driverOpen(void* object, int32 offset, int32 size); - -static void* -driverClose(void* object, int32 offset, int32 size); - -// --- Raster --- -static void -registerNativeRaster(void); - void registerPlatformPlugins(void); +extern Device renderdevice; + +// arguments to glVertexAttribPointer basically +struct AttribDesc +{ + uint32 index; + int32 type; + bool32 normalized; + int32 size; + uint32 stride; + uint32 offset; +}; + +enum AttribIndices +{ + ATTRIB_POS = 0, + ATTRIB_NORMAL, + ATTRIB_COLOR, + ATTRIB_WEIGHTS, + ATTRIB_INDICES, + ATTRIB_TEXCOORDS0, + ATTRIB_TEXCOORDS1, +#if 0 + ATTRIB_TEXCOORDS2, + ATTRIB_TEXCOORDS3, + ATTRIB_TEXCOORDS4, + ATTRIB_TEXCOORDS5, + ATTRIB_TEXCOORDS6, + ATTRIB_TEXCOORDS7, +#endif +}; + +// default uniform indices +extern int32 u_matColor; +extern int32 u_surfProps; + +struct InstanceData +{ + uint32 numIndex; + uint32 minVert; // not used for rendering + int32 numVertices; // + Material *material; + bool32 vertexAlpha; + uint32 program; + uint32 offset; +}; + +struct InstanceDataHeader : rw::InstanceDataHeader +{ + uint32 serialNumber; + uint32 numMeshes; + uint16 *indexBuffer; + uint32 primType; + uint8 *vertexBuffer; + int32 numAttribs; + AttribDesc *attribDesc; + uint32 totalNumIndex; + uint32 totalNumVertex; + + uint32 ibo; + uint32 vbo; // or 2? + + InstanceData *inst; +}; + +#ifdef RW_GLES1 + +struct Im3DVertex +{ + V3d position; + uint8 r, g, b, a; + float32 u, v; + + void setX(float32 x) { this->position.x = x; } + void setY(float32 y) { this->position.y = y; } + void setZ(float32 z) { this->position.z = z; } + void setColor(uint8 r, uint8 g, uint8 b, uint8 a) { + this->r = r; this->g = g; this->b = b; this->a = a; } + void setU(float32 u) { this->u = u; } + void setV(float32 v) { this->v = v; } + + float getX(void) { return this->position.x; } + float getY(void) { return this->position.y; } + float getZ(void) { return this->position.z; } + RGBA getColor(void) { return makeRGBA(this->r, this->g, this->b, this->a); } + float getU(void) { return this->u; } + float getV(void) { return this->v; } +}; + +struct Im2DVertex +{ + float32 x, y, z, w; + uint8 r, g, b, a; + float32 u, v; + + void setScreenX(float32 x) { this->x = x; } + void setScreenY(float32 y) { this->y = y; } + void setScreenZ(float32 z) { this->z = z; } + // This is a bit unefficient but we have to counteract GL's divide, so multiply + void setCameraZ(float32 z) { this->w = z; } + void setRecipCameraZ(float32 recipz) { this->w = 1.0f/recipz; } + void setColor(uint8 r, uint8 g, uint8 b, uint8 a) { + this->r = r; this->g = g; this->b = b; this->a = a; } + void setU(float32 u, float recipz) { this->u = u; } + void setV(float32 v, float recipz) { this->v = v; } + + float getScreenX(void) { return this->x; } + float getScreenY(void) { return this->y; } + float getScreenZ(void) { return this->z; } + float getCameraZ(void) { return this->w; } + float getRecipCameraZ(void) { return 1.0f/this->w; } + RGBA getColor(void) { return makeRGBA(this->r, this->g, this->b, this->a); } + float getU(void) { return this->u; } + float getV(void) { return this->v; } +}; + +void setupVertexInput(InstanceDataHeader *header); +void teardownVertexInput(InstanceDataHeader *header); + +// Render state + +// Vertex shader bits +enum +{ + // These should be low so they could be used as indices + VSLIGHT_DIRECT = 1, + VSLIGHT_POINT = 2, + VSLIGHT_SPOT = 4, + VSLIGHT_MASK = 7, // all the above + // less critical + VSLIGHT_AMBIENT = 8, +}; +// per Scene +void setProjectionMatrix(float32*); +void setViewMatrix(float32*); + +// per Object +void setWorldMatrix(Matrix*); +int32 setLights(WorldLights *lightData); + +// per Mesh +void setTexture(int32 n, Texture *tex); +void setMaterial(const RGBA &color, const SurfaceProperties &surfaceprops, float extraSurfProp = 0.0f); +inline void setMaterial(uint32 flags, const RGBA &color, const SurfaceProperties &surfaceprops, float extraSurfProp = 0.0f) +{ + static RGBA white = { 255, 255, 255, 255 }; + if(flags & Geometry::MODULATE) + setMaterial(color, surfaceprops, extraSurfProp); + else + setMaterial(white, surfaceprops, extraSurfProp); +} + +void setAlphaBlend(bool32 enable); +bool32 getAlphaBlend(void); + +bool32 getAlphaTest(void); + +void bindFramebuffer(uint32 fbo); +uint32 bindTexture(uint32 texid); + +void flushCache(void); + +#endif + +class ObjPipeline : public rw::ObjPipeline +{ +public: + void init(void); + static ObjPipeline *create(void); + + void (*instanceCB)(Geometry *geo, InstanceDataHeader *header, bool32 reinstance); + void (*uninstanceCB)(Geometry *geo, InstanceDataHeader *header); + void (*renderCB)(Atomic *atomic, InstanceDataHeader *header); +}; + +void defaultInstanceCB(Geometry *geo, InstanceDataHeader *header, bool32 reinstance); +void defaultUninstanceCB(Geometry *geo, InstanceDataHeader *header); +void defaultRenderCB(Atomic *atomic, InstanceDataHeader *header); +int32 lightingCB(Atomic *atomic); + +void drawInst_simple(InstanceDataHeader *header, InstanceData *inst); +// Emulate PS2 GS alpha test FB_ONLY case: failed alpha writes to frame- but not to depth buffer +void drawInst_GSemu(InstanceDataHeader *header, InstanceData *inst); +// This one switches between the above two depending on render state; +void drawInst(InstanceDataHeader *header, InstanceData *inst); + + void *destroyNativeData(void *object, int32, int32); +ObjPipeline *makeDefaultPipeline(void); + +void setVertexAlpha(bool32 enable); + +// Native Texture and Raster + +struct Gl1Raster +{ + // arguments to glTexImage2D + int32 internalFormat; + int32 type; + int32 format; + int32 bpp; // bytes per pixel + // texture object + uint32 texid; + + bool isCompressed; + bool hasAlpha; + bool autogenMipmap; + int8 numLevels; + // cached filtermode and addressing + uint8 filterMode; + uint8 addressU; + uint8 addressV; + int32 maxAnisotropy; + + uint32 fbo; // used for camera texture only! + Raster *fboMate; // color or zbuffer raster mate of this one + RasterLevels *backingStore; // if we can't read back GPU memory but have to +}; + +// GLES can't read back textures very nicely. +// In most cases that's not an issue, but when it is, +// this has to be set before the texture is filled: +extern bool32 needToReadBackTextures; + +Texture *readNativeTexture(Stream *stream); +void writeNativeTexture(Texture *tex, Stream *stream); +uint32 getSizeNativeTexture(Texture *tex); + +extern int32 nativeRasterOffset; +void registerNativeRaster(void); +#define GETGL1RASTEREXT(raster) PLUGINOFFSET(Gl1Raster, raster, rw::gles1::nativeRasterOffset) + } } diff --git a/vendor/librw/src/gles1/rwgles1NEW.h b/vendor/librw/src/gles1/rwgles1NEW.h deleted file mode 100644 index 0c15375..0000000 --- a/vendor/librw/src/gles1/rwgles1NEW.h +++ /dev/null @@ -1,255 +0,0 @@ -#ifdef RW_GLES1 -#include -//#include -#include -#endif - -namespace rw { - -#ifdef RW_GLES1 -struct EngineOpenParams -{ - int width, height; - const char *windowtitle; -}; -#endif - -namespace gles1 { - -void registerPlatformPlugins(void); - -extern Device renderdevice; - -// arguments to glVertexAttribPointer basically -struct AttribDesc -{ - uint32 index; - int32 type; - bool32 normalized; - int32 size; - uint32 stride; - uint32 offset; -}; - -enum AttribIndices -{ - ATTRIB_POS = 0, - ATTRIB_NORMAL, - ATTRIB_COLOR, - ATTRIB_WEIGHTS, - ATTRIB_INDICES, - ATTRIB_TEXCOORDS0, - ATTRIB_TEXCOORDS1, -#if 0 - ATTRIB_TEXCOORDS2, - ATTRIB_TEXCOORDS3, - ATTRIB_TEXCOORDS4, - ATTRIB_TEXCOORDS5, - ATTRIB_TEXCOORDS6, - ATTRIB_TEXCOORDS7, -#endif -}; - -// default uniform indices -extern int32 u_matColor; -extern int32 u_surfProps; - -struct InstanceData -{ - uint32 numIndex; - uint32 minVert; // not used for rendering - int32 numVertices; // - Material *material; - bool32 vertexAlpha; - uint32 program; - uint32 offset; -}; - -struct InstanceDataHeader : rw::InstanceDataHeader -{ - uint32 serialNumber; - uint32 numMeshes; - uint16 *indexBuffer; - uint32 primType; - uint8 *vertexBuffer; - int32 numAttribs; - AttribDesc *attribDesc; - uint32 totalNumIndex; - uint32 totalNumVertex; - - uint32 ibo; - uint32 vbo; // or 2? - - InstanceData *inst; -}; - -#ifdef RW_GLES1 - -struct Im3DVertex -{ - V3d position; - uint8 r, g, b, a; - float32 u, v; - - void setX(float32 x) { this->position.x = x; } - void setY(float32 y) { this->position.y = y; } - void setZ(float32 z) { this->position.z = z; } - void setColor(uint8 r, uint8 g, uint8 b, uint8 a) { - this->r = r; this->g = g; this->b = b; this->a = a; } - void setU(float32 u) { this->u = u; } - void setV(float32 v) { this->v = v; } - - float getX(void) { return this->position.x; } - float getY(void) { return this->position.y; } - float getZ(void) { return this->position.z; } - RGBA getColor(void) { return makeRGBA(this->r, this->g, this->b, this->a); } - float getU(void) { return this->u; } - float getV(void) { return this->v; } -}; - -struct Im2DVertex -{ - float32 x, y, z, w; - uint8 r, g, b, a; - float32 u, v; - - void setScreenX(float32 x) { this->x = x; } - void setScreenY(float32 y) { this->y = y; } - void setScreenZ(float32 z) { this->z = z; } - // This is a bit unefficient but we have to counteract GL's divide, so multiply - void setCameraZ(float32 z) { this->w = z; } - void setRecipCameraZ(float32 recipz) { this->w = 1.0f/recipz; } - void setColor(uint8 r, uint8 g, uint8 b, uint8 a) { - this->r = r; this->g = g; this->b = b; this->a = a; } - void setU(float32 u, float recipz) { this->u = u; } - void setV(float32 v, float recipz) { this->v = v; } - - float getScreenX(void) { return this->x; } - float getScreenY(void) { return this->y; } - float getScreenZ(void) { return this->z; } - float getCameraZ(void) { return this->w; } - float getRecipCameraZ(void) { return 1.0f/this->w; } - RGBA getColor(void) { return makeRGBA(this->r, this->g, this->b, this->a); } - float getU(void) { return this->u; } - float getV(void) { return this->v; } -}; - -void setupVertexInput(InstanceDataHeader *header); -void teardownVertexInput(InstanceDataHeader *header); - -// Render state - -// Vertex shader bits -enum -{ - // These should be low so they could be used as indices - VSLIGHT_DIRECT = 1, - VSLIGHT_POINT = 2, - VSLIGHT_SPOT = 4, - VSLIGHT_MASK = 7, // all the above - // less critical - VSLIGHT_AMBIENT = 8, -}; -// per Scene -void setProjectionMatrix(float32*); -void setViewMatrix(float32*); - -// per Object -void setWorldMatrix(Matrix*); -int32 setLights(WorldLights *lightData); - -// per Mesh -void setTexture(int32 n, Texture *tex); -void setMaterial(const RGBA &color, const SurfaceProperties &surfaceprops, float extraSurfProp = 0.0f); -inline void setMaterial(uint32 flags, const RGBA &color, const SurfaceProperties &surfaceprops, float extraSurfProp = 0.0f) -{ - static RGBA white = { 255, 255, 255, 255 }; - if(flags & Geometry::MODULATE) - setMaterial(color, surfaceprops, extraSurfProp); - else - setMaterial(white, surfaceprops, extraSurfProp); -} - -void setAlphaBlend(bool32 enable); -bool32 getAlphaBlend(void); - -bool32 getAlphaTest(void); - -void bindFramebuffer(uint32 fbo); -uint32 bindTexture(uint32 texid); - -void flushCache(void); - -#endif - -class ObjPipeline : public rw::ObjPipeline -{ -public: - void init(void); - static ObjPipeline *create(void); - - void (*instanceCB)(Geometry *geo, InstanceDataHeader *header, bool32 reinstance); - void (*uninstanceCB)(Geometry *geo, InstanceDataHeader *header); - void (*renderCB)(Atomic *atomic, InstanceDataHeader *header); -}; - -void defaultInstanceCB(Geometry *geo, InstanceDataHeader *header, bool32 reinstance); -void defaultUninstanceCB(Geometry *geo, InstanceDataHeader *header); -void defaultRenderCB(Atomic *atomic, InstanceDataHeader *header); -int32 lightingCB(Atomic *atomic); - -void drawInst_simple(InstanceDataHeader *header, InstanceData *inst); -// Emulate PS2 GS alpha test FB_ONLY case: failed alpha writes to frame- but not to depth buffer -void drawInst_GSemu(InstanceDataHeader *header, InstanceData *inst); -// This one switches between the above two depending on render state; -void drawInst(InstanceDataHeader *header, InstanceData *inst); - - -void *destroyNativeData(void *object, int32, int32); - -ObjPipeline *makeDefaultPipeline(void); - -void setVertexAlpha(bool32 enable); - -// Native Texture and Raster - -struct Gl1Raster -{ - // arguments to glTexImage2D - int32 internalFormat; - int32 type; - int32 format; - int32 bpp; // bytes per pixel - // texture object - uint32 texid; - - bool isCompressed; - bool hasAlpha; - bool autogenMipmap; - int8 numLevels; - // cached filtermode and addressing - uint8 filterMode; - uint8 addressU; - uint8 addressV; - int32 maxAnisotropy; - - uint32 fbo; // used for camera texture only! - Raster *fboMate; // color or zbuffer raster mate of this one - RasterLevels *backingStore; // if we can't read back GPU memory but have to -}; - -// GLES can't read back textures very nicely. -// In most cases that's not an issue, but when it is, -// this has to be set before the texture is filled: -extern bool32 needToReadBackTextures; - -Texture *readNativeTexture(Stream *stream); -void writeNativeTexture(Texture *tex, Stream *stream); -uint32 getSizeNativeTexture(Texture *tex); - -extern int32 nativeRasterOffset; -void registerNativeRaster(void); -#define GETGL1RASTEREXT(raster) PLUGINOFFSET(Gl1Raster, raster, rw::gles1::nativeRasterOffset) - -} -} diff --git a/vendor/librw/src/texture.cpp b/vendor/librw/src/texture.cpp index 7ab2dee..49baa52 100644 --- a/vendor/librw/src/texture.cpp +++ b/vendor/librw/src/texture.cpp @@ -484,7 +484,7 @@ Texture::streamReadNative(Stream *stream) return gl3::readNativeTexture(stream); #ifdef RW_GLES1 if(platform == PLATFORM_GLES1){ - //return gles1::readNativeTexture(stream); + return gles1::readNativeTexture(stream); } #endif assert(0 && "unsupported platform"); @@ -506,7 +506,7 @@ Texture::streamWriteNative(Stream *stream) gl3::writeNativeTexture(this, stream); #ifdef RW_GLES1 else if(this->raster->platform == PLATFORM_GLES1){ - //gles1::writeNativeTexture(this, stream); + gles1::writeNativeTexture(this, stream); } #endif else @@ -528,7 +528,7 @@ Texture::streamGetSizeNative(void) return gl3::getSizeNativeTexture(this); #ifdef RW_GLES1 if(this->raster->platform == PLATFORM_GLES1){ - //return gles1::getSizeNativeTexture(this); + return gles1::getSizeNativeTexture(this); } #endif assert(0 && "unsupported platform");