Symbian^3 port

This commit is contained in:
Shinovon 2026-04-29 05:15:13 +05:00
parent 77cdaaf97e
commit 3eb71f2cc5
106 changed files with 2098 additions and 745 deletions

View file

@ -19,17 +19,11 @@ namespace rw {
namespace gl3 {
uint32 im2DVbo, im2DIbo;
#ifdef RW_GL_USE_VAOS
uint32 im2DVao;
#endif
Shader *im2dOverrideShader;
static int32 u_xform;
#define STARTINDICES 10000
#define STARTVERTICES 10000
static Shader *im2dShader;
static AttribDesc im2dattribDesc[3] = {
{ ATTRIB_POS, GL_FLOAT, GL_FALSE, 4,
@ -62,30 +56,11 @@ openIm2D(void)
const char *fs[] = { shaderDecl, header_frag_src, simple_frag_src, nil };
im2dShader = Shader::create(vs, fs);
assert(im2dShader);
glGenBuffers(1, &im2DIbo);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, im2DIbo);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, STARTINDICES*2, nil, GL_STREAM_DRAW);
glGenBuffers(1, &im2DVbo);
glBindBuffer(GL_ARRAY_BUFFER, im2DVbo);
glBufferData(GL_ARRAY_BUFFER, STARTVERTICES*sizeof(Im2DVertex), nil, GL_STREAM_DRAW);
#ifdef RW_GL_USE_VAOS
glGenVertexArrays(1, &im2DVao);
glBindVertexArray(im2DVao);
setAttribPointers(im2dattribDesc, 3);
#endif
}
void
closeIm2D(void)
{
glDeleteBuffers(1, &im2DIbo);
glDeleteBuffers(1, &im2DVbo);
#ifdef RW_GL_USE_VAOS
glDeleteVertexArrays(1, &im2DVao);
#endif
im2dShader->destroy();
im2dShader = nil;
}
@ -128,29 +103,30 @@ im2DSetXform(void)
void
im2DRenderPrimitive(PrimitiveType primType, void *vertices, int32 numVertices)
{
#ifdef RW_GL_USE_VAOS
glBindVertexArray(im2DVao);
#endif
glBindBuffer(GL_ARRAY_BUFFER, im2DVbo);
glBufferData(GL_ARRAY_BUFFER, STARTVERTICES*sizeof(Im2DVertex), nil, GL_STREAM_DRAW);
glBufferSubData(GL_ARRAY_BUFFER, 0, numVertices*sizeof(Im2DVertex), vertices);
if(im2dOverrideShader)
im2dOverrideShader->use();
else
im2dShader->use();
#ifndef RW_GL_USE_VAOS
setAttribPointers(im2dattribDesc, 3);
#endif
im2DSetXform();
flushCache();
glBindBuffer(GL_ARRAY_BUFFER, 0);
glEnableVertexAttribArray(ATTRIB_POS);
glVertexAttribPointer(ATTRIB_POS, 4, GL_FLOAT, GL_FALSE, sizeof(Im2DVertex), (uint8*)vertices + 0);
glEnableVertexAttribArray(ATTRIB_COLOR);
glVertexAttribPointer(ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(Im2DVertex), (uint8*)vertices + offsetof(Im2DVertex, r));
glEnableVertexAttribArray(ATTRIB_TEXCOORDS0);
glVertexAttribPointer(ATTRIB_TEXCOORDS0, 2, GL_FLOAT, GL_FALSE, sizeof(Im2DVertex), (uint8*)vertices + offsetof(Im2DVertex, u));
glDrawArrays(primTypeMap[primType], 0, numVertices);
#ifndef RW_GL_USE_VAOS
disableAttribPointers(im2dattribDesc, 3);
#endif
glDisableVertexAttribArray(ATTRIB_POS);
glDisableVertexAttribArray(ATTRIB_COLOR);
glDisableVertexAttribArray(ATTRIB_TEXCOORDS0);
}
void
@ -158,34 +134,31 @@ im2DRenderIndexedPrimitive(PrimitiveType primType,
void *vertices, int32 numVertices,
void *indices, int32 numIndices)
{
#ifdef RW_GL_USE_VAOS
glBindVertexArray(im2DVao);
#endif
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, im2DIbo);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, STARTINDICES*2, nil, GL_STREAM_DRAW);
glBufferSubData(GL_ELEMENT_ARRAY_BUFFER, 0, numIndices*2, indices);
glBindBuffer(GL_ARRAY_BUFFER, im2DVbo);
glBufferData(GL_ARRAY_BUFFER, STARTVERTICES*sizeof(Im2DVertex), nil, GL_STREAM_DRAW);
glBufferSubData(GL_ARRAY_BUFFER, 0, numVertices*sizeof(Im2DVertex), vertices);
if(im2dOverrideShader)
im2dOverrideShader->use();
else
im2dShader->use();
#ifndef RW_GL_USE_VAOS
setAttribPointers(im2dattribDesc, 3);
#endif
im2DSetXform();
flushCache();
glDrawElements(primTypeMap[primType], numIndices,
GL_UNSIGNED_SHORT, nil);
#ifndef RW_GL_USE_VAOS
disableAttribPointers(im2dattribDesc, 3);
#endif
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
glEnableVertexAttribArray(ATTRIB_POS);
glVertexAttribPointer(ATTRIB_POS, 4, GL_FLOAT, GL_FALSE, sizeof(Im2DVertex), (uint8*)vertices + 0);
glEnableVertexAttribArray(ATTRIB_COLOR);
glVertexAttribPointer(ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(Im2DVertex), (uint8*)vertices + offsetof(Im2DVertex, r));
glEnableVertexAttribArray(ATTRIB_TEXCOORDS0);
glVertexAttribPointer(ATTRIB_TEXCOORDS0, 2, GL_FLOAT, GL_FALSE, sizeof(Im2DVertex), (uint8*)vertices + offsetof(Im2DVertex, u));
glDrawElements(primTypeMap[primType], numIndices, GL_UNSIGNED_SHORT, indices);
glDisableVertexAttribArray(ATTRIB_POS);
glDisableVertexAttribArray(ATTRIB_COLOR);
glDisableVertexAttribArray(ATTRIB_TEXCOORDS0);
}
@ -202,10 +175,8 @@ static AttribDesc im3dattribDesc[3] = {
sizeof(Im3DVertex), offsetof(Im3DVertex, u) },
};
static uint32 im3DVbo, im3DIbo;
#ifdef RW_GL_USE_VAOS
static uint32 im3DVao;
#endif
static int32 num3DVertices; // not actually needed here
static void* currentIm3dVertices;
void
openIm3D(void)
@ -216,30 +187,12 @@ openIm3D(void)
const char *fs[] = { shaderDecl, header_frag_src, simple_frag_src, nil };
im3dShader = Shader::create(vs, fs);
assert(im3dShader);
glGenBuffers(1, &im3DIbo);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, im3DIbo);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, STARTINDICES*2, nil, GL_STREAM_DRAW);
glGenBuffers(1, &im3DVbo);
glBindBuffer(GL_ARRAY_BUFFER, im3DVbo);
glBufferData(GL_ARRAY_BUFFER, STARTVERTICES*sizeof(Im3DVertex), nil, GL_STREAM_DRAW);
#ifdef RW_GL_USE_VAOS
glGenVertexArrays(1, &im3DVao);
glBindVertexArray(im3DVao);
setAttribPointers(im3dattribDesc, 3);
#endif
currentIm3dVertices = nil;
}
void
closeIm3D(void)
{
glDeleteBuffers(1, &im3DIbo);
glDeleteBuffers(1, &im3DVbo);
#ifdef RW_GL_USE_VAOS
glDeleteVertexArrays(1, &im3DVao);
#endif
im3dShader->destroy();
im3dShader = nil;
}
@ -258,46 +211,60 @@ im3DTransform(void *vertices, int32 numVertices, Matrix *world, uint32 flags)
if((flags & im3d::VERTEXUV) == 0)
SetRenderStatePtr(TEXTURERASTER, nil);
#ifdef RW_GL_USE_VAOS
glBindVertexArray(im2DVao);
#endif
glBindBuffer(GL_ARRAY_BUFFER, im3DVbo);
glBufferData(GL_ARRAY_BUFFER, STARTVERTICES*sizeof(Im3DVertex), nil, GL_STREAM_DRAW);
glBufferSubData(GL_ARRAY_BUFFER, 0, numVertices*sizeof(Im3DVertex), vertices);
#ifndef RW_GL_USE_VAOS
setAttribPointers(im3dattribDesc, 3);
#endif
glBindBuffer(GL_ARRAY_BUFFER, 0);
currentIm3dVertices = vertices;
num3DVertices = numVertices;
}
void
im3DRenderPrimitive(PrimitiveType primType)
{
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, im3DIbo);
flushCache();
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
glEnableVertexAttribArray(ATTRIB_POS);
glVertexAttribPointer(ATTRIB_POS, 3, GL_FLOAT, GL_FALSE, sizeof(Im3DVertex), (uint8*)currentIm3dVertices + 0);
glEnableVertexAttribArray(ATTRIB_COLOR);
glVertexAttribPointer(ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(Im3DVertex), (uint8*)currentIm3dVertices + offsetof(Im3DVertex, r));
glEnableVertexAttribArray(ATTRIB_TEXCOORDS0);
glVertexAttribPointer(ATTRIB_TEXCOORDS0, 2, GL_FLOAT, GL_FALSE, sizeof(Im3DVertex), (uint8*)currentIm3dVertices + offsetof(Im3DVertex, u));
glDrawArrays(primTypeMap[primType], 0, num3DVertices);
glDisableVertexAttribArray(ATTRIB_POS);
glDisableVertexAttribArray(ATTRIB_COLOR);
glDisableVertexAttribArray(ATTRIB_TEXCOORDS0);
}
void
im3DRenderIndexedPrimitive(PrimitiveType primType, void *indices, int32 numIndices)
{
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, im3DIbo);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, STARTINDICES*2, nil, GL_STREAM_DRAW);
glBufferSubData(GL_ELEMENT_ARRAY_BUFFER, 0, numIndices*2, indices);
flushCache();
glDrawElements(primTypeMap[primType], numIndices,
GL_UNSIGNED_SHORT, nil);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
glEnableVertexAttribArray(ATTRIB_POS);
glVertexAttribPointer(ATTRIB_POS, 3, GL_FLOAT, GL_FALSE, sizeof(Im3DVertex), (uint8*)currentIm3dVertices + 0);
glEnableVertexAttribArray(ATTRIB_COLOR);
glVertexAttribPointer(ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(Im3DVertex), (uint8*)currentIm3dVertices + offsetof(Im3DVertex, r));
glEnableVertexAttribArray(ATTRIB_TEXCOORDS0);
glVertexAttribPointer(ATTRIB_TEXCOORDS0, 2, GL_FLOAT, GL_FALSE, sizeof(Im3DVertex), (uint8*)currentIm3dVertices + offsetof(Im3DVertex, u));
glDrawElements(primTypeMap[primType], numIndices, GL_UNSIGNED_SHORT, indices);
glDisableVertexAttribArray(ATTRIB_POS);
glDisableVertexAttribArray(ATTRIB_COLOR);
glDisableVertexAttribArray(ATTRIB_TEXCOORDS0);
}
void
im3DEnd(void)
{
#ifndef RW_GL_USE_VAOS
disableAttribPointers(im3dattribDesc, 3);
#endif
}
}