Changes were made to allow compilation in Carbide C++ 2.7 and the Nokia S60v5 SDK. Important code from the OpenGL ES 1.1 backend was commented out since it prevented compilation

This commit is contained in:
Dante Leoncini 2026-05-01 07:16:02 -03:00
parent 558f1b9f32
commit 33a8324d08
48 changed files with 486 additions and 295 deletions

View file

@ -30,4 +30,5 @@ MACRO RW_GL3
SYSTEMINCLUDE /epoc32/include/stdapis/stlport SYSTEMINCLUDE /epoc32/include/stdapis/stlport
SYSTEMINCLUDE /epoc32/include/stdapis/stlport/stl SYSTEMINCLUDE /epoc32/include/stdapis/stlport/stl
MACRO RW_GLES1 MACRO RW_GLES1
MACRO S60V5
#endif #endif

View file

@ -14,7 +14,8 @@ SOURCE engine.cpp error.cpp frame.cpp geometry.cpp geoplg.cpp
SOURCEPATH ../vendor/librw/src/gl 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 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 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 SOURCEPATH ../vendor/librw/src
SOURCE hanim.cpp image.cpp light.cpp SOURCE hanim.cpp image.cpp light.cpp
SOURCEPATH ../vendor/librw/src/lodepng SOURCEPATH ../vendor/librw/src/lodepng

BIN
sis/re3.sisx Normal file

Binary file not shown.

View file

@ -84,7 +84,11 @@ public:
inline float GetTimeLeft() { return hierarchy->totalLength - currentTime; } inline float GetTimeLeft() { return hierarchy->totalLength - currentTime; }
static CAnimBlendAssociation *FromLink(CAnimBlendLink *l) { 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
} }
}; };

View file

@ -30,4 +30,4 @@ public:
void MoveMemory(bool onlyone = false); void MoveMemory(bool onlyone = false);
}; };
VALIDATE_SIZE(CAnimBlendHierarchy, 0x28); VALIDATE_SIZE(CAnimBlendHierarchy, 0x28);

View file

@ -207,4 +207,4 @@ enum AnimationId
ANIM_STD_PHONE_TALK, ANIM_STD_PHONE_TALK,
ANIM_STD_NUM ANIM_STD_NUM
}; };

View file

@ -670,4 +670,4 @@ static char StreamedNameTable[][25] =
"AUDIO\\k1_b.WAV", "AUDIO\\k1_b.WAV",
"AUDIO\\cat1.WAV" "AUDIO\\cat1.WAV"
}; };
#endif #endif

View file

@ -13,4 +13,4 @@ struct CColBox
CVector GetSize(void) { return max - min; } CVector GetSize(void) { return max - min; }
CColBox& operator=(const CColBox &other); CColBox& operator=(const CColBox &other);
}; };

View file

@ -11,4 +11,4 @@ struct CColLine
CColLine(void) { }; CColLine(void) { };
CColLine(const CVector &p0, const CVector &p1) { this->p0 = p0; this->p1 = p1; }; CColLine(const CVector &p0, const CVector &p1) { this->p0 = p0; this->p1 = p1; };
void Set(const CVector &p0, const CVector &p1); void Set(const CVector &p0, const CVector &p1);
}; };

View file

@ -34,4 +34,4 @@ struct CColModel
void GetTrianglePoint(CVector &v, int i) const; void GetTrianglePoint(CVector &v, int i) const;
CColModel& operator=(const CColModel& other); CColModel& operator=(const CColModel& other);
}; };

View file

@ -10,4 +10,4 @@ struct CColSphere
uint8 surface; uint8 surface;
uint8 piece; uint8 piece;
void Set(float radius, const CVector &center, uint8 surf = SURFACE_DEFAULT, uint8 piece = 0); void Set(float radius, const CVector &center, uint8 surf = SURFACE_DEFAULT, uint8 piece = 0);
}; };

View file

@ -65,4 +65,4 @@ struct CColTrianglePlane
void GetNormal(CVector &n) const { n = normal; } void GetNormal(CVector &n) const { n = normal; }
float CalcPoint(const CVector &v) const { return DotProduct(normal, v) - dist; }; float CalcPoint(const CVector &v) const { return DotProduct(normal, v) - dist; };
#endif #endif
}; };

View file

@ -33,4 +33,4 @@ struct CompressedVector
CVector Get(void) const { return CVector(x, y, z); }; 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; }; void Set(float x, float y, float z) { this->x = x; this->y = y; this->z = z; };
#endif #endif
}; };

View file

@ -28,4 +28,4 @@ public:
bool WorkToDoForMedics(); bool WorkToDoForMedics();
}; };
extern CAccidentManager gAccidentManager; extern CAccidentManager gAccidentManager;

View file

@ -62,4 +62,4 @@ public:
static void ReportCrimeForEvent(eEventType type, intptr, bool); static void ReportCrimeForEvent(eEventType type, intptr, bool);
}; };
extern CEvent gaEvent[NUMEVENTS]; extern CEvent gaEvent[NUMEVENTS];

View file

@ -8,4 +8,4 @@ public:
bool IsInRange(CVector2D vec); bool IsInRange(CVector2D vec);
void DebugShowRange(float, int); void DebugShowRange(float, int);
CVector2D GetRandomPointInRange(); CVector2D GetRandomPointInRange();
}; };

View file

@ -69,7 +69,7 @@ myrand(void)
{ {
#ifdef USE_PS2_RAND #ifdef USE_PS2_RAND
// Use our own implementation of rand, stolen from PS2 // 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); return ((myrand_seed >> 32) & 0x7FFFFFFF);
#else #else
// or original codewarrior rand // or original codewarrior rand

View file

@ -201,4 +201,4 @@ inline DebugMenuEntry *DebugMenuAddVarBool8(const char *path, const char *name,
{ {
return DebugMenuAddVarBool8(path, name, (int8_t*)ptr, triggerFunc); return DebugMenuAddVarBool8(path, name, (int8_t*)ptr, triggerFunc);
} }
#endif #endif

View file

@ -541,4 +541,4 @@ CCompressedMatrixNotAligned::DecompressIntoFullMatrix(CMatrix &other)
other.GetUp() = CrossProduct(other.GetRight(), other.GetForward()); other.GetUp() = CrossProduct(other.GetRight(), other.GetForward());
other.GetPosition() = m_vecPos; other.GetPosition() = m_vecPos;
other.Reorthogonalise(); other.Reorthogonalise();
} }

View file

@ -174,4 +174,4 @@ CQuaternion::Set(float f1, float f2, float f3)
y = ((s1 * c2) * c3) + ((s2 * c1) * s3); y = ((s1 * c2) * c3) + ((s2 * c1) * s3);
z = ((s2 * c1) * c3) - ((s1 * c2) * s3); z = ((s2 * c1) * c3) - ((s1 * c2) * s3);
w = ((c2 * c1) * c3) + ((s2 * s1) * s3); w = ((c2 * c1) * c3) + ((s2 * s1) * s3);
} }

View file

@ -14,4 +14,4 @@ CRect::CRect(float l, float t, float r, float b)
top = t; top = t;
right = r; right = r;
bottom = b; bottom = b;
} }

View file

@ -126,4 +126,4 @@ class CMatrix;
CVector Multiply3x3(const CMatrix &mat, const CVector &vec); CVector Multiply3x3(const CMatrix &mat, const CVector &vec);
CVector Multiply3x3(const CVector &vec, const CMatrix &mat); CVector Multiply3x3(const CVector &vec, const CMatrix &mat);
CVector operator*(const CMatrix &mat, const CVector &vec); CVector operator*(const CMatrix &mat, const CVector &vec);

View file

@ -11,4 +11,4 @@ public:
public: public:
CMloModelInfo(void) : CClumpModelInfo(MITYPE_MLO) {} CMloModelInfo(void) : CClumpModelInfo(MITYPE_MLO) {}
void ConstructClump(); void ConstructClump();
}; };

View file

@ -506,4 +506,4 @@ IsFence(int16 id)
{ {
return id == MI_FENCE || return id == MI_FENCE ||
id == MI_FENCE2; id == MI_FENCE2;
} }

View file

@ -64,4 +64,4 @@ public:
}; };
#ifndef PED_SKIN #ifndef PED_SKIN
VALIDATE_SIZE(CPedModelInfo, 0x48); VALIDATE_SIZE(CPedModelInfo, 0x48);
#endif #endif

View file

@ -10,4 +10,4 @@ public:
void Shutdown(void) {}; void Shutdown(void) {};
RwObject *CreateInstance(void) { return nil; } RwObject *CreateInstance(void) { return nil; }
void SetClump(RpClump*) {}; void SetClump(RpClump*) {};
}; };

View file

@ -464,4 +464,4 @@ CPed::RunToReportCrime(eCrimeType crimeToReport)
m_phoneId = phoneId; m_phoneId = phoneId;
m_crimeToReportOnPhone = crimeToReport; m_crimeToReportOnPhone = crimeToReport;
return true; return true;
} }

View file

@ -149,4 +149,4 @@ CPed::Say(uint16 audio)
m_queuedSound = audio; m_queuedSound = audio;
} }
} }
} }

View file

@ -307,4 +307,4 @@ CPed::DebugRenderClosePedText()
{ {
// TODO: mobile code // TODO: mobile code
} }
#endif #endif

View file

@ -5,4 +5,4 @@ public:
static void FindZCoorForPed(CVector* pos); static void FindZCoorForPed(CVector* pos);
static CEntity* IsPositionClearOfCars(Const CVector*); static CEntity* IsPositionClearOfCars(Const CVector*);
static bool IsPositionClearForPed(CVector*); static bool IsPositionClearForPed(CVector*);
}; };

View file

@ -170,4 +170,4 @@ public:
static ePedStats GetPedStatType(char *name); static ePedStats GetPedStatType(char *name);
}; };
VALIDATE_SIZE(CPedStats, 0x34); VALIDATE_SIZE(CPedStats, 0x34);

View file

@ -24,4 +24,4 @@ public:
extern CConsole TheConsole; extern CConsole TheConsole;
void cprintf(char*, ...); void cprintf(char*, ...);

View file

@ -60,4 +60,4 @@ void RestoreAlphaTest();
#else #else
#define SetAlphaTest(a) (0) #define SetAlphaTest(a) (0)
#define RestoreAlphaTest() (0) #define RestoreAlphaTest() (0)
#endif #endif

View file

@ -70,4 +70,4 @@ ZeroSaveBuf(uint8 *&buf, uint32 length)
} while(0) } while(0)
#else #else
#define CheckSaveHeader(buf, a, b, c, d, size) SkipSaveBuf(buf, 8); #define CheckSaveHeader(buf, a, b, c, d, size) SkipSaveBuf(buf, 8);
#endif #endif

View file

@ -406,7 +406,9 @@ public:
openParams.width = RsGlobal.width; openParams.width = RsGlobal.width;
openParams.height = RsGlobal.height; openParams.height = RsGlobal.height;
openParams.windowtitle = RsGlobal.appName; #ifndef S60V5
openParams.windowtitle = RsGlobal.appName;
#endif
ControlsManager.MakeControllerActionsBlank(); ControlsManager.MakeControllerActionsBlank();
ControlsManager.InitDefaultControlConfiguration(); ControlsManager.InitDefaultControlConfiguration();

View file

@ -78,4 +78,4 @@ VALIDATE_SIZE(CBoat, 0x484);
extern float MAX_WAKE_LENGTH; extern float MAX_WAKE_LENGTH;
extern float MIN_WAKE_INTERVAL; extern float MIN_WAKE_INTERVAL;
extern float WAKE_LIFETIME; extern float WAKE_LIFETIME;

View file

@ -75,4 +75,4 @@ public:
}; };
VALIDATE_SIZE(CWeapon, 0x18); VALIDATE_SIZE(CWeapon, 0x18);
void FireOneInstantHitRound(CVector *source, CVector *target, int32 damage); void FireOneInstantHitRound(CVector *source, CVector *target, int32 damage);

View file

@ -49,4 +49,4 @@ public:
bool IsFlagSet(uint32 flag) const { return (m_Flags & flag) != 0; } bool IsFlagSet(uint32 flag) const { return (m_Flags & flag) != 0; }
}; };
VALIDATE_SIZE(CWeaponInfo, 0x54); VALIDATE_SIZE(CWeaponInfo, 0x54);

View file

@ -46,4 +46,4 @@ enum eWeaponState
WEAPONSTATE_RELOADING, WEAPONSTATE_RELOADING,
WEAPONSTATE_OUT_OF_AMMO, WEAPONSTATE_OUT_OF_AMMO,
WEAPONSTATE_MELEE_MADECONTACT WEAPONSTATE_MELEE_MADECONTACT
}; };

View file

@ -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 // We expect some attributes to always be there, use the constant buffer as fallback
if(!isPrelit){ if(!isPrelit){
dcl[i].stream = 2; 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].type = D3DDECLTYPE_D3DCOLOR;
dcl[i].method = D3DDECLMETHOD_DEFAULT; dcl[i].method = D3DDECLMETHOD_DEFAULT;
dcl[i].usage = D3DDECLUSAGE_COLOR; dcl[i].usage = D3DDECLUSAGE_COLOR;
@ -563,7 +567,11 @@ defaultInstanceCB(Geometry *geo, InstanceDataHeader *header, bool32 reinstance)
} }
if(geo->numTexCoordSets == 0){ if(geo->numTexCoordSets == 0){
dcl[i].stream = 2; 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].type = D3DDECLTYPE_FLOAT2;
dcl[i].method = D3DDECLMETHOD_DEFAULT; dcl[i].method = D3DDECLMETHOD_DEFAULT;
dcl[i].usage = D3DDECLUSAGE_TEXCOORD; dcl[i].usage = D3DDECLUSAGE_TEXCOORD;

View file

@ -273,7 +273,7 @@ Engine::open(EngineOpenParams *p)
#elif RW_GL3 #elif RW_GL3
engine->device = gl3::renderdevice; engine->device = gl3::renderdevice;
#elif RW_GLES1 #elif RW_GLES1
engine->device = gles1::renderdevice; //engine->device = gles1::renderdevice;
#elif RW_D3D9 #elif RW_D3D9
engine->device = d3d::renderdevice; engine->device = d3d::renderdevice;
#else #else

View file

@ -23,7 +23,12 @@ static AttribDesc im2dattribDesc[3] = {
{ ATTRIB_POS, GL_FLOAT, GL_FALSE, 4, { ATTRIB_POS, GL_FLOAT, GL_FALSE, 4,
sizeof(Im2DVertex), 0 }, sizeof(Im2DVertex), 0 },
{ ATTRIB_COLOR, GL_UNSIGNED_BYTE, GL_TRUE, 4, { 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, { ATTRIB_TEXCOORDS0, GL_FLOAT, GL_FALSE, 2,
sizeof(Im2DVertex), offsetof(Im2DVertex, u) }, sizeof(Im2DVertex), offsetof(Im2DVertex, u) },
}; };

54
vendor/librw/src/gles1/rwgles1.cpp vendored Normal file
View file

@ -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;
}
}
}

View file

@ -1,7 +1,28 @@
#pragma once
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include "../rwbase.h"
#include "../rwerror.h"
#include "../rwplg.h"
#include "../rwpipeline.h"
#include "../rwobjects.h"
#include "../rwengine.h"
#ifdef RW_GLES1 #ifdef RW_GLES1
#include <gles/gl.h> #include <GLES/gl.h>
//#include <gles/glext.h> #include <GLES/egl.h>
#include <gles/egl.h> #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 #endif
namespace rw { namespace rw {
@ -9,247 +30,83 @@ namespace rw {
#ifdef RW_GLES1 #ifdef RW_GLES1
struct EngineOpenParams struct EngineOpenParams
{ {
int width, height; #ifdef __SYMBIAN32__
const char *windowtitle; void *window; // en Symbian no hay GLFW/SDL
#else
void *window; // stub igual
#endif
int width, height;
}; };
#endif #endif
namespace gles1 { 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); 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); 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)
} }
} }

255
vendor/librw/src/gles1/rwgles1NEW.h vendored Normal file
View file

@ -0,0 +1,255 @@
#ifdef RW_GLES1
#include <gles/gl.h>
//#include <gles/glext.h>
#include <gles/egl.h>
#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)
}
}

View file

@ -413,9 +413,9 @@ flipAlphaBlock5_half(uint8 *dst, uint8 *src)
dst[1] = src[1]; dst[1] = src[1];
// bits // bits
uint64 bits = *(uint64*)&src[2]; uint64 bits = *(uint64*)&src[2];
uint64 flipbits = bits & 0xFFFFFF000000; uint64 flipbits = bits & 0xFFFFFF000000ULL;
flipbits |= (bits>>12) & 0xFFF; flipbits |= (bits>>12) & 0xFFFULL;
flipbits |= (bits<<12) & 0xFFF000; flipbits |= (bits<<12) & 0xFFF000ULL;
memcpy(dst+2, &flipbits, 6); memcpy(dst+2, &flipbits, 6);
} }

View file

@ -11,6 +11,9 @@
#ifdef __SYMBIAN32__ #ifdef __SYMBIAN32__
#undef stderr #undef stderr
#define stderr stdout #define stderr stdout
#ifdef S60V5
#define OFFSET_OF(type, member) ((size_t)&(((type*)0)->member))
#endif
#endif #endif
// TODO: clean up the opengl defines // TODO: clean up the opengl defines
@ -112,16 +115,14 @@ struct LLLink
} }
}; };
#ifndef RW_GL3
#ifdef __offsetof #ifdef S60V5
#undef __offsetof #define LLLinkGetData(linkvar,type,entry) \
#endif ((type*)((char*)(linkvar) - (size_t)&(((type*)0)->entry)))
#define __offsetof(type, field) (reinterpret_cast <size_t> \ #else
(&reinterpret_cast <const volatile char &> \ #define LLLinkGetData(linkvar,type,entry) \
(static_cast<type *> (0)->field)))
#endif
#define LLLinkGetData(linkvar,type,entry) \
((type*)(((rw::uint8*)(linkvar))-offsetof(type,entry))) ((type*)(((rw::uint8*)(linkvar))-offsetof(type,entry)))
#endif
// Have to be careful since the link might be deleted. // Have to be careful since the link might be deleted.
#define FORLIST(_link, _list) \ #define FORLIST(_link, _list) \

View file

@ -483,8 +483,9 @@ Texture::streamReadNative(Stream *stream)
if(platform == PLATFORM_GL3) if(platform == PLATFORM_GL3)
return gl3::readNativeTexture(stream); return gl3::readNativeTexture(stream);
#ifdef RW_GLES1 #ifdef RW_GLES1
if(platform == PLATFORM_GLES1) if(platform == PLATFORM_GLES1){
return gles1::readNativeTexture(stream); //return gles1::readNativeTexture(stream);
}
#endif #endif
assert(0 && "unsupported platform"); assert(0 && "unsupported platform");
return nil; return nil;
@ -504,8 +505,9 @@ Texture::streamWriteNative(Stream *stream)
else if(this->raster->platform == PLATFORM_GL3) else if(this->raster->platform == PLATFORM_GL3)
gl3::writeNativeTexture(this, stream); gl3::writeNativeTexture(this, stream);
#ifdef RW_GLES1 #ifdef RW_GLES1
else if(this->raster->platform == PLATFORM_GLES1) else if(this->raster->platform == PLATFORM_GLES1){
gles1::writeNativeTexture(this, stream); //gles1::writeNativeTexture(this, stream);
}
#endif #endif
else else
assert(0 && "unsupported platform"); assert(0 && "unsupported platform");
@ -525,8 +527,9 @@ Texture::streamGetSizeNative(void)
if(this->raster->platform == PLATFORM_GL3) if(this->raster->platform == PLATFORM_GL3)
return gl3::getSizeNativeTexture(this); return gl3::getSizeNativeTexture(this);
#ifdef RW_GLES1 #ifdef RW_GLES1
if(this->raster->platform == PLATFORM_GLES1) if(this->raster->platform == PLATFORM_GLES1){
return gles1::getSizeNativeTexture(this); //return gles1::getSizeNativeTexture(this);
}
#endif #endif
assert(0 && "unsupported platform"); assert(0 && "unsupported platform");
return 0; return 0;