diff --git a/group/common.mmh b/group/common.mmh index 08d0636..41dd5ec 100644 --- a/group/common.mmh +++ b/group/common.mmh @@ -30,4 +30,5 @@ MACRO RW_GL3 SYSTEMINCLUDE /epoc32/include/stdapis/stlport SYSTEMINCLUDE /epoc32/include/stdapis/stlport/stl MACRO RW_GLES1 +MACRO S60V5 #endif diff --git a/group/librw.mmh b/group/librw.mmh index 1eba534..f722c30 100644 --- a/group/librw.mmh +++ b/group/librw.mmh @@ -14,7 +14,8 @@ 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 gl1.cpp gl1device.cpp gl1immed.cpp gl1pipe.cpp gl1raster.cpp gl1render.cpp +SOURCE rwgles1.cpp +//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/sis/re3.sisx b/sis/re3.sisx new file mode 100644 index 0000000..a7b4584 Binary files /dev/null and b/sis/re3.sisx differ diff --git a/src/animation/AnimBlendAssociation.h b/src/animation/AnimBlendAssociation.h index 45720b6..33858e8 100644 --- a/src/animation/AnimBlendAssociation.h +++ b/src/animation/AnimBlendAssociation.h @@ -84,7 +84,11 @@ public: inline float GetTimeLeft() { return hierarchy->totalLength - currentTime; } static CAnimBlendAssociation *FromLink(CAnimBlendLink *l) { - return (CAnimBlendAssociation*)((uint8*)l - offsetof(CAnimBlendAssociation, link)); + #ifdef S60V5 + return (CAnimBlendAssociation*)((uint8*)l - OFFSET_OF(CAnimBlendAssociation, link)); + #else + return (CAnimBlendAssociation*)((uint8*)l - offsetof(CAnimBlendAssociation, link)); + #endif } }; diff --git a/src/animation/AnimBlendHierarchy.h b/src/animation/AnimBlendHierarchy.h index 40d2731..ed9d244 100644 --- a/src/animation/AnimBlendHierarchy.h +++ b/src/animation/AnimBlendHierarchy.h @@ -30,4 +30,4 @@ public: void MoveMemory(bool onlyone = false); }; -VALIDATE_SIZE(CAnimBlendHierarchy, 0x28); \ No newline at end of file +VALIDATE_SIZE(CAnimBlendHierarchy, 0x28); diff --git a/src/animation/AnimationId.h b/src/animation/AnimationId.h index baf6eb3..8e36830 100644 --- a/src/animation/AnimationId.h +++ b/src/animation/AnimationId.h @@ -207,4 +207,4 @@ enum AnimationId ANIM_STD_PHONE_TALK, ANIM_STD_NUM -}; \ No newline at end of file +}; diff --git a/src/audio/sampman.h b/src/audio/sampman.h index ad14e2b..3d10ed1 100644 --- a/src/audio/sampman.h +++ b/src/audio/sampman.h @@ -670,4 +670,4 @@ static char StreamedNameTable[][25] = "AUDIO\\k1_b.WAV", "AUDIO\\cat1.WAV" }; -#endif \ No newline at end of file +#endif diff --git a/src/collision/ColBox.h b/src/collision/ColBox.h index ac2cd67..69129b1 100644 --- a/src/collision/ColBox.h +++ b/src/collision/ColBox.h @@ -13,4 +13,4 @@ struct CColBox CVector GetSize(void) { return max - min; } CColBox& operator=(const CColBox &other); -}; \ No newline at end of file +}; diff --git a/src/collision/ColLine.h b/src/collision/ColLine.h index 21587a0..f66a48b 100644 --- a/src/collision/ColLine.h +++ b/src/collision/ColLine.h @@ -11,4 +11,4 @@ struct CColLine CColLine(void) { }; CColLine(const CVector &p0, const CVector &p1) { this->p0 = p0; this->p1 = p1; }; void Set(const CVector &p0, const CVector &p1); -}; \ No newline at end of file +}; diff --git a/src/collision/ColModel.h b/src/collision/ColModel.h index 7dcdfa4..daae720 100644 --- a/src/collision/ColModel.h +++ b/src/collision/ColModel.h @@ -34,4 +34,4 @@ struct CColModel void GetTrianglePoint(CVector &v, int i) const; CColModel& operator=(const CColModel& other); -}; \ No newline at end of file +}; diff --git a/src/collision/ColSphere.h b/src/collision/ColSphere.h index 70e2976..2608837 100644 --- a/src/collision/ColSphere.h +++ b/src/collision/ColSphere.h @@ -10,4 +10,4 @@ struct CColSphere uint8 surface; uint8 piece; void Set(float radius, const CVector ¢er, uint8 surf = SURFACE_DEFAULT, uint8 piece = 0); -}; \ No newline at end of file +}; diff --git a/src/collision/ColTriangle.h b/src/collision/ColTriangle.h index 9e918e3..5e1bc81 100644 --- a/src/collision/ColTriangle.h +++ b/src/collision/ColTriangle.h @@ -65,4 +65,4 @@ struct CColTrianglePlane void GetNormal(CVector &n) const { n = normal; } float CalcPoint(const CVector &v) const { return DotProduct(normal, v) - dist; }; #endif -}; \ No newline at end of file +}; diff --git a/src/collision/CompressedVector.h b/src/collision/CompressedVector.h index d54e49b..1a75aad 100644 --- a/src/collision/CompressedVector.h +++ b/src/collision/CompressedVector.h @@ -33,4 +33,4 @@ struct CompressedVector CVector Get(void) const { return CVector(x, y, z); }; void Set(float x, float y, float z) { this->x = x; this->y = y; this->z = z; }; #endif -}; \ No newline at end of file +}; diff --git a/src/core/Accident.h b/src/core/Accident.h index 568e114..514968f 100644 --- a/src/core/Accident.h +++ b/src/core/Accident.h @@ -28,4 +28,4 @@ public: bool WorkToDoForMedics(); }; -extern CAccidentManager gAccidentManager; \ No newline at end of file +extern CAccidentManager gAccidentManager; diff --git a/src/core/EventList.h b/src/core/EventList.h index 4ced3a8..7cc3a61 100644 --- a/src/core/EventList.h +++ b/src/core/EventList.h @@ -62,4 +62,4 @@ public: static void ReportCrimeForEvent(eEventType type, intptr, bool); }; -extern CEvent gaEvent[NUMEVENTS]; \ No newline at end of file +extern CEvent gaEvent[NUMEVENTS]; diff --git a/src/core/Range2D.h b/src/core/Range2D.h index f239e7d..bd13e56 100644 --- a/src/core/Range2D.h +++ b/src/core/Range2D.h @@ -8,4 +8,4 @@ public: bool IsInRange(CVector2D vec); void DebugShowRange(float, int); CVector2D GetRandomPointInRange(); -}; \ No newline at end of file +}; diff --git a/src/core/re3.cpp b/src/core/re3.cpp index 885a08a..c4cd2c3 100644 --- a/src/core/re3.cpp +++ b/src/core/re3.cpp @@ -69,7 +69,7 @@ myrand(void) { #ifdef USE_PS2_RAND // Use our own implementation of rand, stolen from PS2 - myrand_seed = 0x5851F42D4C957F2D * myrand_seed + 1; + myrand_seed = 0x5851F42D4C957F2DULL * myrand_seed + 1; return ((myrand_seed >> 32) & 0x7FFFFFFF); #else // or original codewarrior rand diff --git a/src/extras/debugmenu.h b/src/extras/debugmenu.h index 45b65d0..f52d75d 100644 --- a/src/extras/debugmenu.h +++ b/src/extras/debugmenu.h @@ -201,4 +201,4 @@ inline DebugMenuEntry *DebugMenuAddVarBool8(const char *path, const char *name, { return DebugMenuAddVarBool8(path, name, (int8_t*)ptr, triggerFunc); } -#endif \ No newline at end of file +#endif diff --git a/src/math/Matrix.cpp b/src/math/Matrix.cpp index b11e8a1..01c4197 100644 --- a/src/math/Matrix.cpp +++ b/src/math/Matrix.cpp @@ -541,4 +541,4 @@ CCompressedMatrixNotAligned::DecompressIntoFullMatrix(CMatrix &other) other.GetUp() = CrossProduct(other.GetRight(), other.GetForward()); other.GetPosition() = m_vecPos; other.Reorthogonalise(); -} \ No newline at end of file +} diff --git a/src/math/Quaternion.cpp b/src/math/Quaternion.cpp index b0e782e..6128f58 100644 --- a/src/math/Quaternion.cpp +++ b/src/math/Quaternion.cpp @@ -174,4 +174,4 @@ CQuaternion::Set(float f1, float f2, float f3) y = ((s1 * c2) * c3) + ((s2 * c1) * s3); z = ((s2 * c1) * c3) - ((s1 * c2) * s3); w = ((c2 * c1) * c3) + ((s2 * s1) * s3); -} \ No newline at end of file +} diff --git a/src/math/Rect.cpp b/src/math/Rect.cpp index de6320a..8b41dc2 100644 --- a/src/math/Rect.cpp +++ b/src/math/Rect.cpp @@ -14,4 +14,4 @@ CRect::CRect(float l, float t, float r, float b) top = t; right = r; bottom = b; -} \ No newline at end of file +} diff --git a/src/math/Vector.h b/src/math/Vector.h index 776bfcf..a25cd74 100644 --- a/src/math/Vector.h +++ b/src/math/Vector.h @@ -126,4 +126,4 @@ class CMatrix; CVector Multiply3x3(const CMatrix &mat, const CVector &vec); CVector Multiply3x3(const CVector &vec, const CMatrix &mat); -CVector operator*(const CMatrix &mat, const CVector &vec); \ No newline at end of file +CVector operator*(const CMatrix &mat, const CVector &vec); diff --git a/src/modelinfo/MloModelInfo.h b/src/modelinfo/MloModelInfo.h index b1ae329..f2bafc8 100644 --- a/src/modelinfo/MloModelInfo.h +++ b/src/modelinfo/MloModelInfo.h @@ -11,4 +11,4 @@ public: public: CMloModelInfo(void) : CClumpModelInfo(MITYPE_MLO) {} void ConstructClump(); -}; \ No newline at end of file +}; diff --git a/src/modelinfo/ModelIndices.h b/src/modelinfo/ModelIndices.h index c0f0192..be7389c 100644 --- a/src/modelinfo/ModelIndices.h +++ b/src/modelinfo/ModelIndices.h @@ -506,4 +506,4 @@ IsFence(int16 id) { return id == MI_FENCE || id == MI_FENCE2; -} \ No newline at end of file +} diff --git a/src/modelinfo/PedModelInfo.h b/src/modelinfo/PedModelInfo.h index 26ab3c3..b6c9d12 100644 --- a/src/modelinfo/PedModelInfo.h +++ b/src/modelinfo/PedModelInfo.h @@ -64,4 +64,4 @@ public: }; #ifndef PED_SKIN VALIDATE_SIZE(CPedModelInfo, 0x48); -#endif \ No newline at end of file +#endif diff --git a/src/modelinfo/XtraCompsModelInfo.h b/src/modelinfo/XtraCompsModelInfo.h index ab308a8..a6fe5f6 100644 --- a/src/modelinfo/XtraCompsModelInfo.h +++ b/src/modelinfo/XtraCompsModelInfo.h @@ -10,4 +10,4 @@ public: void Shutdown(void) {}; RwObject *CreateInstance(void) { return nil; } void SetClump(RpClump*) {}; -}; \ No newline at end of file +}; diff --git a/src/peds/CivilianPed.cpp b/src/peds/CivilianPed.cpp index 1c4f10f..63f8e09 100644 --- a/src/peds/CivilianPed.cpp +++ b/src/peds/CivilianPed.cpp @@ -464,4 +464,4 @@ CPed::RunToReportCrime(eCrimeType crimeToReport) m_phoneId = phoneId; m_crimeToReportOnPhone = crimeToReport; return true; -} \ No newline at end of file +} diff --git a/src/peds/PedChat.cpp b/src/peds/PedChat.cpp index 907f575..a89ab6a 100644 --- a/src/peds/PedChat.cpp +++ b/src/peds/PedChat.cpp @@ -149,4 +149,4 @@ CPed::Say(uint16 audio) m_queuedSound = audio; } } -} \ No newline at end of file +} diff --git a/src/peds/PedDebug.cpp b/src/peds/PedDebug.cpp index 1c22963..f78502d 100644 --- a/src/peds/PedDebug.cpp +++ b/src/peds/PedDebug.cpp @@ -307,4 +307,4 @@ CPed::DebugRenderClosePedText() { // TODO: mobile code } -#endif \ No newline at end of file +#endif diff --git a/src/peds/PedPlacement.h b/src/peds/PedPlacement.h index b51e2aa..66dbcc6 100644 --- a/src/peds/PedPlacement.h +++ b/src/peds/PedPlacement.h @@ -5,4 +5,4 @@ public: static void FindZCoorForPed(CVector* pos); static CEntity* IsPositionClearOfCars(Const CVector*); static bool IsPositionClearForPed(CVector*); -}; \ No newline at end of file +}; diff --git a/src/peds/PedType.h b/src/peds/PedType.h index 3e23c24..414585e 100644 --- a/src/peds/PedType.h +++ b/src/peds/PedType.h @@ -170,4 +170,4 @@ public: static ePedStats GetPedStatType(char *name); }; -VALIDATE_SIZE(CPedStats, 0x34); \ No newline at end of file +VALIDATE_SIZE(CPedStats, 0x34); diff --git a/src/renderer/Console.h b/src/renderer/Console.h index 9f22236..ee37021 100644 --- a/src/renderer/Console.h +++ b/src/renderer/Console.h @@ -24,4 +24,4 @@ public: extern CConsole TheConsole; -void cprintf(char*, ...); \ No newline at end of file +void cprintf(char*, ...); diff --git a/src/rw/RwHelper.h b/src/rw/RwHelper.h index 0e04aec..a882022 100644 --- a/src/rw/RwHelper.h +++ b/src/rw/RwHelper.h @@ -60,4 +60,4 @@ void RestoreAlphaTest(); #else #define SetAlphaTest(a) (0) #define RestoreAlphaTest() (0) -#endif \ No newline at end of file +#endif diff --git a/src/save/SaveBuf.h b/src/save/SaveBuf.h index aad2e1a..78ab6e4 100644 --- a/src/save/SaveBuf.h +++ b/src/save/SaveBuf.h @@ -70,4 +70,4 @@ ZeroSaveBuf(uint8 *&buf, uint32 length) } while(0) #else #define CheckSaveHeader(buf, a, b, c, d, size) SkipSaveBuf(buf, 8); -#endif \ No newline at end of file +#endif diff --git a/src/skel/symbian/symbian.cpp b/src/skel/symbian/symbian.cpp index 00437f2..84f0642 100644 --- a/src/skel/symbian/symbian.cpp +++ b/src/skel/symbian/symbian.cpp @@ -406,7 +406,9 @@ public: openParams.width = RsGlobal.width; openParams.height = RsGlobal.height; - openParams.windowtitle = RsGlobal.appName; + #ifndef S60V5 + openParams.windowtitle = RsGlobal.appName; + #endif ControlsManager.MakeControllerActionsBlank(); ControlsManager.InitDefaultControlConfiguration(); diff --git a/src/vehicles/Boat.h b/src/vehicles/Boat.h index 157b485..a4547ea 100644 --- a/src/vehicles/Boat.h +++ b/src/vehicles/Boat.h @@ -78,4 +78,4 @@ VALIDATE_SIZE(CBoat, 0x484); extern float MAX_WAKE_LENGTH; extern float MIN_WAKE_INTERVAL; -extern float WAKE_LIFETIME; \ No newline at end of file +extern float WAKE_LIFETIME; diff --git a/src/weapons/Weapon.h b/src/weapons/Weapon.h index c7685e0..955cf6e 100644 --- a/src/weapons/Weapon.h +++ b/src/weapons/Weapon.h @@ -75,4 +75,4 @@ public: }; VALIDATE_SIZE(CWeapon, 0x18); -void FireOneInstantHitRound(CVector *source, CVector *target, int32 damage); \ No newline at end of file +void FireOneInstantHitRound(CVector *source, CVector *target, int32 damage); diff --git a/src/weapons/WeaponInfo.h b/src/weapons/WeaponInfo.h index 96e2ecf..819de50 100644 --- a/src/weapons/WeaponInfo.h +++ b/src/weapons/WeaponInfo.h @@ -49,4 +49,4 @@ public: bool IsFlagSet(uint32 flag) const { return (m_Flags & flag) != 0; } }; -VALIDATE_SIZE(CWeaponInfo, 0x54); \ No newline at end of file +VALIDATE_SIZE(CWeaponInfo, 0x54); diff --git a/src/weapons/WeaponType.h b/src/weapons/WeaponType.h index b45740b..9878281 100644 --- a/src/weapons/WeaponType.h +++ b/src/weapons/WeaponType.h @@ -46,4 +46,4 @@ enum eWeaponState WEAPONSTATE_RELOADING, WEAPONSTATE_OUT_OF_AMMO, WEAPONSTATE_MELEE_MADECONTACT -}; \ No newline at end of file +}; diff --git a/vendor/librw/src/d3d/d3d9.cpp b/vendor/librw/src/d3d/d3d9.cpp index 851397b..1495743 100644 --- a/vendor/librw/src/d3d/d3d9.cpp +++ b/vendor/librw/src/d3d/d3d9.cpp @@ -554,7 +554,11 @@ defaultInstanceCB(Geometry *geo, InstanceDataHeader *header, bool32 reinstance) // We expect some attributes to always be there, use the constant buffer as fallback if(!isPrelit){ dcl[i].stream = 2; - dcl[i].offset = offsetof(VertexConstantData, color); + #ifdef S60V5 + dcl[i].offset = OFFSET_OF(VertexConstantData, color); + #else + dcl[i].offset = offsetof(VertexConstantData, color); + #endif dcl[i].type = D3DDECLTYPE_D3DCOLOR; dcl[i].method = D3DDECLMETHOD_DEFAULT; dcl[i].usage = D3DDECLUSAGE_COLOR; @@ -563,7 +567,11 @@ defaultInstanceCB(Geometry *geo, InstanceDataHeader *header, bool32 reinstance) } if(geo->numTexCoordSets == 0){ dcl[i].stream = 2; - dcl[i].offset = offsetof(VertexConstantData, texCoors[0]); + #ifdef S60V5 + dcl[i].offset = OFFSET_OF(VertexConstantData, texCoors); + #else + dcl[i].offset = offsetof(VertexConstantData, texCoors); + #endif dcl[i].type = D3DDECLTYPE_FLOAT2; dcl[i].method = D3DDECLMETHOD_DEFAULT; dcl[i].usage = D3DDECLUSAGE_TEXCOORD; diff --git a/vendor/librw/src/engine.cpp b/vendor/librw/src/engine.cpp index d22dc1b..e559a36 100644 --- a/vendor/librw/src/engine.cpp +++ b/vendor/librw/src/engine.cpp @@ -273,7 +273,7 @@ Engine::open(EngineOpenParams *p) #elif RW_GL3 engine->device = gl3::renderdevice; #elif RW_GLES1 - engine->device = gles1::renderdevice; + //engine->device = gles1::renderdevice; #elif RW_D3D9 engine->device = d3d::renderdevice; #else diff --git a/vendor/librw/src/gles1/gl1immed.cpp b/vendor/librw/src/gles1/gl1immed.cpp index eb4d9a0..b32c1fe 100644 --- a/vendor/librw/src/gles1/gl1immed.cpp +++ b/vendor/librw/src/gles1/gl1immed.cpp @@ -23,7 +23,12 @@ static AttribDesc im2dattribDesc[3] = { { ATTRIB_POS, GL_FLOAT, GL_FALSE, 4, sizeof(Im2DVertex), 0 }, { ATTRIB_COLOR, GL_UNSIGNED_BYTE, GL_TRUE, 4, - sizeof(Im2DVertex), offsetof(Im2DVertex, r) }, + #ifdef S60V5 + dcl[i].offset = OFFSET_OF(VertexConstantData, texCoors); + #else + dcl[i].offset = offsetof(VertexConstantData, texCoors); + #endif + { ATTRIB_TEXCOORDS0, GL_FLOAT, GL_FALSE, 2, sizeof(Im2DVertex), offsetof(Im2DVertex, u) }, }; diff --git a/vendor/librw/src/gles1/rwgles1.cpp b/vendor/librw/src/gles1/rwgles1.cpp new file mode 100644 index 0000000..e393e51 --- /dev/null +++ b/vendor/librw/src/gles1/rwgles1.cpp @@ -0,0 +1,54 @@ +#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 0c15375..f52e751 100644 --- a/vendor/librw/src/gles1/rwgles1.h +++ b/vendor/librw/src/gles1/rwgles1.h @@ -1,7 +1,28 @@ +#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 -#include +#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 #endif namespace rw { @@ -9,247 +30,83 @@ namespace rw { #ifdef RW_GLES1 struct EngineOpenParams { - int width, height; - const char *windowtitle; +#ifdef __SYMBIAN32__ + void *window; // en Symbian no hay GLFW/SDL +#else + void *window; // stub igual +#endif + int width, height; }; #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 new file mode 100644 index 0000000..0c15375 --- /dev/null +++ b/vendor/librw/src/gles1/rwgles1NEW.h @@ -0,0 +1,255 @@ +#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/image.cpp b/vendor/librw/src/image.cpp index c8cee64..b626399 100644 --- a/vendor/librw/src/image.cpp +++ b/vendor/librw/src/image.cpp @@ -413,9 +413,9 @@ flipAlphaBlock5_half(uint8 *dst, uint8 *src) dst[1] = src[1]; // bits uint64 bits = *(uint64*)&src[2]; - uint64 flipbits = bits & 0xFFFFFF000000; - flipbits |= (bits>>12) & 0xFFF; - flipbits |= (bits<<12) & 0xFFF000; + uint64 flipbits = bits & 0xFFFFFF000000ULL; + flipbits |= (bits>>12) & 0xFFFULL; + flipbits |= (bits<<12) & 0xFFF000ULL; memcpy(dst+2, &flipbits, 6); } diff --git a/vendor/librw/src/rwbase.h b/vendor/librw/src/rwbase.h index e30dabe..d4c2268 100644 --- a/vendor/librw/src/rwbase.h +++ b/vendor/librw/src/rwbase.h @@ -11,6 +11,9 @@ #ifdef __SYMBIAN32__ #undef stderr #define stderr stdout + #ifdef S60V5 + #define OFFSET_OF(type, member) ((size_t)&(((type*)0)->member)) + #endif #endif // TODO: clean up the opengl defines @@ -112,16 +115,14 @@ struct LLLink } }; -#ifndef RW_GL3 -#ifdef __offsetof -#undef __offsetof -#endif -#define __offsetof(type, field) (reinterpret_cast \ - (&reinterpret_cast \ - (static_cast (0)->field))) -#endif -#define LLLinkGetData(linkvar,type,entry) \ + +#ifdef S60V5 + #define LLLinkGetData(linkvar,type,entry) \ + ((type*)((char*)(linkvar) - (size_t)&(((type*)0)->entry))) +#else + #define LLLinkGetData(linkvar,type,entry) \ ((type*)(((rw::uint8*)(linkvar))-offsetof(type,entry))) +#endif // Have to be careful since the link might be deleted. #define FORLIST(_link, _list) \ diff --git a/vendor/librw/src/texture.cpp b/vendor/librw/src/texture.cpp index 219aa2a..7ab2dee 100644 --- a/vendor/librw/src/texture.cpp +++ b/vendor/librw/src/texture.cpp @@ -483,8 +483,9 @@ Texture::streamReadNative(Stream *stream) if(platform == PLATFORM_GL3) return gl3::readNativeTexture(stream); #ifdef RW_GLES1 - if(platform == PLATFORM_GLES1) - return gles1::readNativeTexture(stream); + if(platform == PLATFORM_GLES1){ + //return gles1::readNativeTexture(stream); + } #endif assert(0 && "unsupported platform"); return nil; @@ -504,8 +505,9 @@ Texture::streamWriteNative(Stream *stream) else if(this->raster->platform == PLATFORM_GL3) gl3::writeNativeTexture(this, stream); #ifdef RW_GLES1 - else if(this->raster->platform == PLATFORM_GLES1) - gles1::writeNativeTexture(this, stream); + else if(this->raster->platform == PLATFORM_GLES1){ + //gles1::writeNativeTexture(this, stream); + } #endif else assert(0 && "unsupported platform"); @@ -525,8 +527,9 @@ Texture::streamGetSizeNative(void) if(this->raster->platform == PLATFORM_GL3) return gl3::getSizeNativeTexture(this); #ifdef RW_GLES1 - if(this->raster->platform == PLATFORM_GLES1) - return gles1::getSizeNativeTexture(this); + if(this->raster->platform == PLATFORM_GLES1){ + //return gles1::getSizeNativeTexture(this); + } #endif assert(0 && "unsupported platform"); return 0;