mirror of
https://gitlab.com/shinovon/re3-symbian.git
synced 2026-05-23 01:57:21 +03:00
Something partially working
This commit is contained in:
parent
9c3f9b9ed6
commit
52e1b18729
6 changed files with 243 additions and 274 deletions
|
|
@ -339,7 +339,9 @@ public:
|
||||||
CreateWindowL();
|
CreateWindowL();
|
||||||
iAppUi->SetOrientationL(CAknAppUiBase::EAppUiOrientationLandscape);
|
iAppUi->SetOrientationL(CAknAppUiBase::EAppUiOrientationLandscape);
|
||||||
SetExtentToWholeScreen();
|
SetExtentToWholeScreen();
|
||||||
|
#ifdef RW_GL3
|
||||||
Window().EnableAdvancedPointers();
|
Window().EnableAdvancedPointers();
|
||||||
|
#endif
|
||||||
EnableDragEvents();
|
EnableDragEvents();
|
||||||
ActivateL();
|
ActivateL();
|
||||||
|
|
||||||
|
|
@ -353,13 +355,13 @@ public:
|
||||||
RsGlobal.height = size.iHeight;
|
RsGlobal.height = size.iHeight;
|
||||||
|
|
||||||
EGLint attribs[] = {
|
EGLint attribs[] = {
|
||||||
EGL_BUFFER_SIZE, 16,
|
EGL_BUFFER_SIZE, 24,
|
||||||
EGL_DEPTH_SIZE, 16,
|
EGL_DEPTH_SIZE, 16,
|
||||||
EGL_STENCIL_SIZE, 0,
|
EGL_STENCIL_SIZE, 0,
|
||||||
|
EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
|
||||||
|
#ifdef RW_GL3
|
||||||
EGL_SAMPLES, 0,
|
EGL_SAMPLES, 0,
|
||||||
EGL_COLOR_BUFFER_TYPE, EGL_RGB_BUFFER,
|
EGL_COLOR_BUFFER_TYPE, EGL_RGB_BUFFER,
|
||||||
EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
|
|
||||||
#ifdef SYMBIAN3
|
|
||||||
EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
|
EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
|
||||||
#endif
|
#endif
|
||||||
EGL_NONE
|
EGL_NONE
|
||||||
|
|
@ -367,15 +369,19 @@ public:
|
||||||
|
|
||||||
eglDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY);
|
eglDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY);
|
||||||
eglInitialize(eglDisplay, NULL, NULL);
|
eglInitialize(eglDisplay, NULL, NULL);
|
||||||
#ifdef SYMBIAN3
|
#ifdef RW_GL3
|
||||||
eglBindAPI(EGL_OPENGL_ES_API);
|
eglBindAPI(EGL_OPENGL_ES_API);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
EGLint numConfigs;
|
EGLint numConfigs;
|
||||||
eglChooseConfig(eglDisplay, attribs, &eglConfig, 1, &numConfigs);
|
eglChooseConfig(eglDisplay, attribs, &eglConfig, 1, &numConfigs);
|
||||||
|
|
||||||
|
#ifdef RW_GL3
|
||||||
EGLint contextAttribs[ 3 ] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE };
|
EGLint contextAttribs[ 3 ] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE };
|
||||||
eglContext = eglCreateContext(eglDisplay, eglConfig, EGL_NO_CONTEXT, contextAttribs);
|
eglContext = eglCreateContext(eglDisplay, eglConfig, EGL_NO_CONTEXT, contextAttribs);
|
||||||
|
#else
|
||||||
|
eglContext = eglCreateContext(eglDisplay, eglConfig, EGL_NO_CONTEXT, NULL);
|
||||||
|
#endif
|
||||||
|
|
||||||
RWindow& window = Window();
|
RWindow& window = Window();
|
||||||
eglSurface = eglCreateWindowSurface(eglDisplay, eglConfig, &window, NULL);
|
eglSurface = eglCreateWindowSurface(eglDisplay, eglConfig, &window, NULL);
|
||||||
|
|
|
||||||
304
vendor/librw/src/gles1/gl1device.cpp
vendored
304
vendor/librw/src/gles1/gl1device.cpp
vendored
|
|
@ -25,20 +25,12 @@ GlGlobals glGlobals;
|
||||||
// terrible hack for GLES
|
// terrible hack for GLES
|
||||||
bool32 needToReadBackTextures;
|
bool32 needToReadBackTextures;
|
||||||
|
|
||||||
int32 alphaFunc;
|
|
||||||
float32 alphaRef;
|
float32 alphaRef;
|
||||||
|
|
||||||
struct UniformState
|
struct UniformState
|
||||||
{
|
{
|
||||||
float32 alphaRefLow;
|
|
||||||
float32 alphaRefHigh;
|
|
||||||
int32 pad[2];
|
|
||||||
|
|
||||||
float32 fogStart;
|
float32 fogStart;
|
||||||
float32 fogEnd;
|
float32 fogEnd;
|
||||||
float32 fogRange;
|
|
||||||
float32 fogDisable;
|
|
||||||
|
|
||||||
RGBAf fogColor;
|
RGBAf fogColor;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -48,7 +40,7 @@ struct UniformScene
|
||||||
float32 view[16];
|
float32 view[16];
|
||||||
};
|
};
|
||||||
|
|
||||||
#define MAX_LIGHTS 4
|
#define MAX_LIGHTS 8
|
||||||
|
|
||||||
struct UniformObject
|
struct UniformObject
|
||||||
{
|
{
|
||||||
|
|
@ -73,25 +65,6 @@ static UniformState uniformState;
|
||||||
static UniformScene uniformScene;
|
static UniformScene uniformScene;
|
||||||
static UniformObject uniformObject;
|
static UniformObject uniformObject;
|
||||||
|
|
||||||
#ifndef RW_GL_USE_UBOS
|
|
||||||
// State
|
|
||||||
int32 u_alphaRef;
|
|
||||||
int32 u_fogData;
|
|
||||||
int32 u_fogColor;
|
|
||||||
|
|
||||||
// Scene
|
|
||||||
int32 u_proj;
|
|
||||||
int32 u_view;
|
|
||||||
|
|
||||||
// Object
|
|
||||||
int32 u_world;
|
|
||||||
int32 u_ambLight;
|
|
||||||
int32 u_lightParams;
|
|
||||||
int32 u_lightPosition;
|
|
||||||
int32 u_lightDirection;
|
|
||||||
int32 u_lightColor;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int32 u_matColor;
|
int32 u_matColor;
|
||||||
int32 u_surfProps;
|
int32 u_surfProps;
|
||||||
|
|
||||||
|
|
@ -383,38 +356,25 @@ setDepthWrite(bool32 enable)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void setAlphaTest(bool32 enable)
|
||||||
setAlphaTest(bool32 enable)
|
|
||||||
{
|
{
|
||||||
uint32 shaderfunc;
|
|
||||||
if(rwStateCache.alphaTestEnable != enable){
|
if(rwStateCache.alphaTestEnable != enable){
|
||||||
rwStateCache.alphaTestEnable = enable;
|
rwStateCache.alphaTestEnable = enable;
|
||||||
shaderfunc = rwStateCache.alphaTestEnable ? rwStateCache.alphaFunc : ALPHAALWAYS;
|
uniformStateDirty[RWGL_ALPHAFUNC] = true;
|
||||||
if(alphaFunc != shaderfunc){
|
stateDirty = 1;
|
||||||
alphaFunc = shaderfunc;
|
|
||||||
uniformStateDirty[RWGL_ALPHAFUNC] = true;
|
|
||||||
stateDirty = 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void setAlphaTestFunction(uint32 function)
|
||||||
setAlphaTestFunction(uint32 function)
|
|
||||||
{
|
{
|
||||||
uint32 shaderfunc;
|
|
||||||
if(rwStateCache.alphaFunc != function){
|
if(rwStateCache.alphaFunc != function){
|
||||||
rwStateCache.alphaFunc = function;
|
rwStateCache.alphaFunc = function;
|
||||||
shaderfunc = rwStateCache.alphaTestEnable ? rwStateCache.alphaFunc : ALPHAALWAYS;
|
uniformStateDirty[RWGL_ALPHAFUNC] = true;
|
||||||
if(alphaFunc != shaderfunc){
|
stateDirty = 1;
|
||||||
alphaFunc = shaderfunc;
|
|
||||||
uniformStateDirty[RWGL_ALPHAFUNC] = true;
|
|
||||||
stateDirty = 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
void setVertexAlpha(bool32 enable)
|
||||||
setVertexAlpha(bool32 enable)
|
|
||||||
{
|
{
|
||||||
if(rwStateCache.vertexAlpha != enable){
|
if(rwStateCache.vertexAlpha != enable){
|
||||||
if(!rwStateCache.textureAlpha){
|
if(!rwStateCache.textureAlpha){
|
||||||
|
|
@ -548,6 +508,7 @@ setRasterStageOnly(uint32 stage, Raster *raster)
|
||||||
if(raster){
|
if(raster){
|
||||||
assert(raster->platform == PLATFORM_GLES1);
|
assert(raster->platform == PLATFORM_GLES1);
|
||||||
Gl1Raster *natras = PLUGINOFFSET(Gl1Raster, raster, nativeRasterOffset);
|
Gl1Raster *natras = PLUGINOFFSET(Gl1Raster, raster, nativeRasterOffset);
|
||||||
|
glEnable(GL_TEXTURE_2D);
|
||||||
bindTexture(natras->texid);
|
bindTexture(natras->texid);
|
||||||
|
|
||||||
rwStateCache.texstage[stage].filter = (rw::Texture::FilterMode)natras->filterMode;
|
rwStateCache.texstage[stage].filter = (rw::Texture::FilterMode)natras->filterMode;
|
||||||
|
|
@ -556,6 +517,7 @@ setRasterStageOnly(uint32 stage, Raster *raster)
|
||||||
|
|
||||||
alpha = natras->hasAlpha;
|
alpha = natras->hasAlpha;
|
||||||
}else{
|
}else{
|
||||||
|
glDisable(GL_TEXTURE_2D);
|
||||||
bindTexture(whitetex);
|
bindTexture(whitetex);
|
||||||
alpha = 0;
|
alpha = 0;
|
||||||
}
|
}
|
||||||
|
|
@ -582,6 +544,7 @@ setRasterStage(uint32 stage, Raster *raster)
|
||||||
if(raster){
|
if(raster){
|
||||||
assert(raster->platform == PLATFORM_GLES1);
|
assert(raster->platform == PLATFORM_GLES1);
|
||||||
Gl1Raster *natras = PLUGINOFFSET(Gl1Raster, raster, nativeRasterOffset);
|
Gl1Raster *natras = PLUGINOFFSET(Gl1Raster, raster, nativeRasterOffset);
|
||||||
|
glEnable(GL_TEXTURE_2D);
|
||||||
bindTexture(natras->texid);
|
bindTexture(natras->texid);
|
||||||
uint32 filter = rwStateCache.texstage[stage].filter;
|
uint32 filter = rwStateCache.texstage[stage].filter;
|
||||||
uint32 addrU = rwStateCache.texstage[stage].addressingU;
|
uint32 addrU = rwStateCache.texstage[stage].addressingU;
|
||||||
|
|
@ -607,6 +570,7 @@ setRasterStage(uint32 stage, Raster *raster)
|
||||||
}
|
}
|
||||||
alpha = natras->hasAlpha;
|
alpha = natras->hasAlpha;
|
||||||
}else{
|
}else{
|
||||||
|
glDisable(GL_TEXTURE_2D);
|
||||||
bindTexture(whitetex);
|
bindTexture(whitetex);
|
||||||
alpha = 0;
|
alpha = 0;
|
||||||
}
|
}
|
||||||
|
|
@ -884,12 +848,9 @@ static void
|
||||||
resetRenderState(void)
|
resetRenderState(void)
|
||||||
{
|
{
|
||||||
rwStateCache.alphaFunc = ALPHAGREATEREQUAL;
|
rwStateCache.alphaFunc = ALPHAGREATEREQUAL;
|
||||||
alphaFunc = 0;
|
|
||||||
alphaRef = 10.0f/255.0f;
|
alphaRef = 10.0f/255.0f;
|
||||||
uniformState.fogDisable = 1.0f;
|
|
||||||
uniformState.fogStart = 0.0f;
|
uniformState.fogStart = 0.0f;
|
||||||
uniformState.fogEnd = 0.0f;
|
uniformState.fogEnd = 0.0f;
|
||||||
uniformState.fogRange = 0.0f;
|
|
||||||
uniformState.fogColor.red = 1.0f;
|
uniformState.fogColor.red = 1.0f;
|
||||||
uniformState.fogColor.green = 1.0f;
|
uniformState.fogColor.green = 1.0f;
|
||||||
uniformState.fogColor.blue = 1.0f;
|
uniformState.fogColor.blue = 1.0f;
|
||||||
|
|
@ -943,15 +904,22 @@ resetRenderState(void)
|
||||||
for(int i = 0; i < MAXNUMSTAGES; i++){
|
for(int i = 0; i < MAXNUMSTAGES; i++){
|
||||||
setActiveTexture(i);
|
setActiveTexture(i);
|
||||||
bindTexture(whitetex);
|
bindTexture(whitetex);
|
||||||
|
glDisable(GL_TEXTURE_2D);
|
||||||
}
|
}
|
||||||
setActiveTexture(0);
|
setActiveTexture(0);
|
||||||
|
|
||||||
|
glDisable(GL_LIGHTING);
|
||||||
|
glDisable(GL_FOG);
|
||||||
|
glDisable(GL_ALPHA_TEST);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
setWorldMatrix(Matrix *mat)
|
setWorldMatrix(Matrix *mat)
|
||||||
{
|
{
|
||||||
convMatrix(&uniformObject.world, mat);
|
convMatrix(&uniformObject.world, mat);
|
||||||
// setUniform(u_world, &uniformObject.world);
|
glMatrixMode(GL_MODELVIEW);
|
||||||
|
glLoadMatrixf(uniformScene.view);
|
||||||
|
glMultMatrixf((float*)&uniformObject.world);
|
||||||
objectDirty = 1;
|
objectDirty = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -960,25 +928,27 @@ setLights(WorldLights *lightData)
|
||||||
{
|
{
|
||||||
int i, n;
|
int i, n;
|
||||||
Light *l;
|
Light *l;
|
||||||
int32 bits;
|
int32 bits = 0;
|
||||||
|
|
||||||
uniformObject.ambLight = lightData->ambient;
|
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, (GLfloat*)&lightData->ambient);
|
||||||
|
|
||||||
bits = 0;
|
|
||||||
|
|
||||||
if(lightData->numAmbients)
|
if(lightData->numAmbients)
|
||||||
bits |= VSLIGHT_AMBIENT;
|
bits |= VSLIGHT_AMBIENT;
|
||||||
|
|
||||||
n = 0;
|
n = 0;
|
||||||
|
for(i = 0; i < MAX_LIGHTS; i++)
|
||||||
|
glDisable(GL_LIGHT0 + i);
|
||||||
|
|
||||||
for(i = 0; i < lightData->numDirectionals && i < 8; i++){
|
for(i = 0; i < lightData->numDirectionals && i < 8; i++){
|
||||||
l = lightData->directionals[i];
|
l = lightData->directionals[i];
|
||||||
uniformObject.lightParams[n].type = 1.0f;
|
glEnable(GL_LIGHT0 + n);
|
||||||
uniformObject.lightColor[n] = l->color;
|
GLfloat dir[4] = { -l->getFrame()->getLTM()->at.x, -l->getFrame()->getLTM()->at.y, -l->getFrame()->getLTM()->at.z, 0.0f };
|
||||||
memcpy(&uniformObject.lightDirection[n], &l->getFrame()->getLTM()->at, sizeof(V3d));
|
glLightfv(GL_LIGHT0 + n, GL_POSITION, dir);
|
||||||
|
glLightfv(GL_LIGHT0 + n, GL_DIFFUSE, (GLfloat*)&l->color);
|
||||||
|
glLightfv(GL_LIGHT0 + n, GL_SPECULAR, (GLfloat*)&l->color);
|
||||||
bits |= VSLIGHT_DIRECT;
|
bits |= VSLIGHT_DIRECT;
|
||||||
n++;
|
n++;
|
||||||
if(n >= MAX_LIGHTS)
|
if(n >= MAX_LIGHTS) goto out;
|
||||||
goto out;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for(i = 0; i < lightData->numLocals; i++){
|
for(i = 0; i < lightData->numLocals; i++){
|
||||||
|
|
@ -986,44 +956,42 @@ setLights(WorldLights *lightData)
|
||||||
|
|
||||||
switch(l->getType()){
|
switch(l->getType()){
|
||||||
case Light::POINT:
|
case Light::POINT:
|
||||||
uniformObject.lightParams[n].type = 2.0f;
|
glEnable(GL_LIGHT0 + n);
|
||||||
uniformObject.lightParams[n].radius = l->radius;
|
{
|
||||||
uniformObject.lightColor[n] = l->color;
|
GLfloat pos[4] = { l->getFrame()->getLTM()->pos.x, l->getFrame()->getLTM()->pos.y, l->getFrame()->getLTM()->pos.z, 1.0f };
|
||||||
memcpy(&uniformObject.lightPosition[n], &l->getFrame()->getLTM()->pos, sizeof(V3d));
|
glLightfv(GL_LIGHT0 + n, GL_POSITION, pos);
|
||||||
|
glLightfv(GL_LIGHT0 + n, GL_DIFFUSE, (GLfloat*)&l->color);
|
||||||
|
glLightf(GL_LIGHT0 + n, GL_CONSTANT_ATTENUATION, 1.0f);
|
||||||
|
glLightf(GL_LIGHT0 + n, GL_LINEAR_ATTENUATION, l->radius > 0.0f ? 1.0f / l->radius : 0.0f);
|
||||||
|
}
|
||||||
bits |= VSLIGHT_POINT;
|
bits |= VSLIGHT_POINT;
|
||||||
n++;
|
n++;
|
||||||
if(n >= MAX_LIGHTS)
|
if(n >= MAX_LIGHTS) goto out;
|
||||||
goto out;
|
|
||||||
break;
|
break;
|
||||||
case Light::SPOT:
|
case Light::SPOT:
|
||||||
case Light::SOFTSPOT:
|
case Light::SOFTSPOT:
|
||||||
uniformObject.lightParams[n].type = 3.0f;
|
glEnable(GL_LIGHT0 + n);
|
||||||
uniformObject.lightParams[n].minusCosAngle = l->minusCosAngle;
|
{
|
||||||
uniformObject.lightParams[n].radius = l->radius;
|
GLfloat pos[4] = { l->getFrame()->getLTM()->pos.x, l->getFrame()->getLTM()->pos.y, l->getFrame()->getLTM()->pos.z, 1.0f };
|
||||||
uniformObject.lightColor[n] = l->color;
|
GLfloat dir[4] = { l->getFrame()->getLTM()->at.x, l->getFrame()->getLTM()->at.y, l->getFrame()->getLTM()->at.z, 0.0f };
|
||||||
memcpy(&uniformObject.lightPosition[n], &l->getFrame()->getLTM()->pos, sizeof(V3d));
|
glLightfv(GL_LIGHT0 + n, GL_POSITION, pos);
|
||||||
memcpy(&uniformObject.lightDirection[n], &l->getFrame()->getLTM()->at, sizeof(V3d));
|
glLightfv(GL_LIGHT0 + n, GL_SPOT_DIRECTION, dir);
|
||||||
// lower bound of falloff
|
glLightfv(GL_LIGHT0 + n, GL_DIFFUSE, (GLfloat*)&l->color);
|
||||||
if(l->getType() == Light::SOFTSPOT)
|
glLightf(GL_LIGHT0 + n, GL_SPOT_CUTOFF, 45.0f);
|
||||||
uniformObject.lightParams[n].hardSpot = 0.0f;
|
}
|
||||||
else
|
|
||||||
uniformObject.lightParams[n].hardSpot = 1.0f;
|
|
||||||
bits |= VSLIGHT_SPOT;
|
bits |= VSLIGHT_SPOT;
|
||||||
n++;
|
n++;
|
||||||
if(n >= MAX_LIGHTS)
|
if(n >= MAX_LIGHTS) goto out;
|
||||||
goto out;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uniformObject.lightParams[n].type = 0.0f;
|
|
||||||
|
|
||||||
// setUniform(u_ambLight, &uniformObject.ambLight);
|
|
||||||
// setUniform(u_lightParams, uniformObject.lightParams);
|
|
||||||
// setUniform(u_lightPosition, uniformObject.lightPosition);
|
|
||||||
// setUniform(u_lightDirection, uniformObject.lightDirection);
|
|
||||||
// setUniform(u_lightColor, uniformObject.lightColor);
|
|
||||||
out:
|
out:
|
||||||
|
if(n > 0 || lightData->numAmbients > 0)
|
||||||
|
glEnable(GL_LIGHTING);
|
||||||
|
else
|
||||||
|
glDisable(GL_LIGHTING);
|
||||||
|
|
||||||
objectDirty = 1;
|
objectDirty = 1;
|
||||||
return bits;
|
return bits;
|
||||||
}
|
}
|
||||||
|
|
@ -1032,7 +1000,8 @@ void
|
||||||
setProjectionMatrix(float32 *mat)
|
setProjectionMatrix(float32 *mat)
|
||||||
{
|
{
|
||||||
memcpy(&uniformScene.proj, mat, 64);
|
memcpy(&uniformScene.proj, mat, 64);
|
||||||
// setUniform(u_proj, uniformScene.proj);
|
glMatrixMode(GL_PROJECTION);
|
||||||
|
glLoadMatrixf(uniformScene.proj);
|
||||||
sceneDirty = 1;
|
sceneDirty = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1040,7 +1009,9 @@ void
|
||||||
setViewMatrix(float32 *mat)
|
setViewMatrix(float32 *mat)
|
||||||
{
|
{
|
||||||
memcpy(&uniformScene.view, mat, 64);
|
memcpy(&uniformScene.view, mat, 64);
|
||||||
// setUniform(u_view, uniformScene.view);
|
glMatrixMode(GL_MODELVIEW);
|
||||||
|
glLoadMatrixf(uniformScene.view);
|
||||||
|
glMultMatrixf((float*)&uniformObject.world);
|
||||||
sceneDirty = 1;
|
sceneDirty = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1050,14 +1021,15 @@ setMaterial(const RGBA &color, const SurfaceProperties &surfaceprops, float extr
|
||||||
{
|
{
|
||||||
rw::RGBAf col;
|
rw::RGBAf col;
|
||||||
convColor(&col, &color);
|
convColor(&col, &color);
|
||||||
// setUniform(u_matColor, &col);
|
glColor4f(col.red, col.green, col.blue, col.alpha);
|
||||||
|
|
||||||
float surfProps[4];
|
GLfloat ambient[4] = { col.red * surfaceprops.ambient, col.green * surfaceprops.ambient, col.blue * surfaceprops.ambient, col.alpha };
|
||||||
surfProps[0] = surfaceprops.ambient;
|
GLfloat diffuse[4] = { col.red * surfaceprops.diffuse, col.green * surfaceprops.diffuse, col.blue * surfaceprops.diffuse, col.alpha };
|
||||||
surfProps[1] = surfaceprops.specular;
|
GLfloat specular[4] = { surfaceprops.specular, surfaceprops.specular, surfaceprops.specular, 1.0f };
|
||||||
surfProps[2] = surfaceprops.diffuse;
|
|
||||||
surfProps[3] = extraSurfProp;
|
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, ambient);
|
||||||
// setUniform(u_surfProps, surfProps);
|
glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, diffuse);
|
||||||
|
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, specular);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
@ -1065,96 +1037,48 @@ flushCache(void)
|
||||||
{
|
{
|
||||||
flushGlRenderState();
|
flushGlRenderState();
|
||||||
|
|
||||||
#ifndef RW_GL_USE_UBOS
|
|
||||||
|
|
||||||
// what's this doing here??
|
|
||||||
uniformState.fogDisable = rwStateCache.fogEnable ? 0.0f : 1.0f;
|
|
||||||
uniformState.fogStart = rwStateCache.fogStart;
|
|
||||||
uniformState.fogEnd = rwStateCache.fogEnd;
|
|
||||||
uniformState.fogRange = 1.0f/(rwStateCache.fogStart - rwStateCache.fogEnd);
|
|
||||||
|
|
||||||
if(uniformStateDirty[RWGL_ALPHAFUNC] || uniformStateDirty[RWGL_ALPHAREF]){
|
if(uniformStateDirty[RWGL_ALPHAFUNC] || uniformStateDirty[RWGL_ALPHAREF]){
|
||||||
float alphaTest[4];
|
if (rwStateCache.alphaTestEnable) {
|
||||||
switch(alphaFunc){
|
glEnable(GL_ALPHA_TEST);
|
||||||
case ALPHAALWAYS:
|
int func = GL_ALWAYS;
|
||||||
default:
|
switch(rwStateCache.alphaFunc){
|
||||||
alphaTest[0] = -1000.0f;
|
case ALPHAALWAYS:
|
||||||
alphaTest[1] = 1000.0f;
|
func = GL_ALWAYS;
|
||||||
break;
|
break;
|
||||||
case ALPHAGREATEREQUAL:
|
case ALPHAGREATEREQUAL:
|
||||||
alphaTest[0] = alphaRef;
|
func = GL_GEQUAL;
|
||||||
alphaTest[1] = 1000.0f;
|
break;
|
||||||
break;
|
case ALPHALESS:
|
||||||
case ALPHALESS:
|
func = GL_LESS;
|
||||||
alphaTest[0] = -1000.0f;
|
break;
|
||||||
alphaTest[1] = alphaRef;
|
}
|
||||||
break;
|
glAlphaFunc(func, alphaRef);
|
||||||
|
} else {
|
||||||
|
glDisable(GL_ALPHA_TEST);
|
||||||
}
|
}
|
||||||
// setUniform(u_alphaRef, alphaTest);
|
|
||||||
uniformStateDirty[RWGL_ALPHAFUNC] = false;
|
uniformStateDirty[RWGL_ALPHAFUNC] = false;
|
||||||
uniformStateDirty[RWGL_ALPHAREF] = false;
|
uniformStateDirty[RWGL_ALPHAREF] = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(uniformStateDirty[RWGL_FOG] ||
|
if(uniformStateDirty[RWGL_FOG] ||
|
||||||
uniformStateDirty[RWGL_FOGSTART] ||
|
uniformStateDirty[RWGL_FOGSTART] ||
|
||||||
uniformStateDirty[RWGL_FOGEND]){
|
uniformStateDirty[RWGL_FOGEND] ||
|
||||||
float fogData[4] = {
|
uniformStateDirty[RWGL_FOGCOLOR]){
|
||||||
uniformState.fogStart,
|
if (rwStateCache.fogEnable) {
|
||||||
uniformState.fogEnd,
|
glEnable(GL_FOG);
|
||||||
uniformState.fogRange,
|
glFogf(GL_FOG_MODE, GL_LINEAR);
|
||||||
uniformState.fogDisable
|
glFogf(GL_FOG_START, rwStateCache.fogStart);
|
||||||
};
|
glFogf(GL_FOG_END, rwStateCache.fogEnd);
|
||||||
// setUniform(u_fogData, fogData);
|
GLfloat fcolor[4] = { uniformState.fogColor.red, uniformState.fogColor.green, uniformState.fogColor.blue, uniformState.fogColor.alpha };
|
||||||
|
glFogfv(GL_FOG_COLOR, fcolor);
|
||||||
|
} else {
|
||||||
|
glDisable(GL_FOG);
|
||||||
|
}
|
||||||
uniformStateDirty[RWGL_FOG] = false;
|
uniformStateDirty[RWGL_FOG] = false;
|
||||||
uniformStateDirty[RWGL_FOGSTART] = false;
|
uniformStateDirty[RWGL_FOGSTART] = false;
|
||||||
uniformStateDirty[RWGL_FOGEND] = false;
|
uniformStateDirty[RWGL_FOGEND] = false;
|
||||||
}
|
|
||||||
|
|
||||||
if(uniformStateDirty[RWGL_FOGCOLOR]){
|
|
||||||
// setUniform(u_fogColor, &uniformState.fogColor);
|
|
||||||
uniformStateDirty[RWGL_FOGCOLOR] = false;
|
uniformStateDirty[RWGL_FOGCOLOR] = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
|
||||||
if(objectDirty){
|
|
||||||
glBindBuffer(GL_UNIFORM_BUFFER, ubo_object);
|
|
||||||
glBufferData(GL_UNIFORM_BUFFER, sizeof(UniformObject), nil, GL_STREAM_DRAW);
|
|
||||||
glBufferData(GL_UNIFORM_BUFFER, sizeof(UniformObject), &uniformObject, GL_STREAM_DRAW);
|
|
||||||
objectDirty = 0;
|
|
||||||
}
|
|
||||||
if(sceneDirty){
|
|
||||||
glBindBuffer(GL_UNIFORM_BUFFER, ubo_scene);
|
|
||||||
glBufferData(GL_UNIFORM_BUFFER, sizeof(UniformScene), nil, GL_STREAM_DRAW);
|
|
||||||
glBufferData(GL_UNIFORM_BUFFER, sizeof(UniformScene), &uniformScene, GL_STREAM_DRAW);
|
|
||||||
sceneDirty = 0;
|
|
||||||
}
|
|
||||||
if(stateDirty){
|
|
||||||
switch(alphaFunc){
|
|
||||||
case ALPHAALWAYS:
|
|
||||||
default:
|
|
||||||
uniformState.alphaRefLow = -1000.0f;
|
|
||||||
uniformState.alphaRefHigh = 1000.0f;
|
|
||||||
break;
|
|
||||||
case ALPHAGREATEREQUAL:
|
|
||||||
uniformState.alphaRefLow = alphaRef;
|
|
||||||
uniformState.alphaRefHigh = 1000.0f;
|
|
||||||
break;
|
|
||||||
case ALPHALESS:
|
|
||||||
uniformState.alphaRefLow = -1000.0f;
|
|
||||||
uniformState.alphaRefHigh = alphaRef;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
uniformState.fogDisable = rwStateCache.fogEnable ? 0.0f : 1.0f;
|
|
||||||
uniformState.fogStart = rwStateCache.fogStart;
|
|
||||||
uniformState.fogEnd = rwStateCache.fogEnd;
|
|
||||||
uniformState.fogRange = 1.0f/(rwStateCache.fogStart - rwStateCache.fogEnd);
|
|
||||||
glBindBuffer(GL_UNIFORM_BUFFER, ubo_state);
|
|
||||||
glBufferData(GL_UNIFORM_BUFFER, sizeof(UniformState), nil, GL_STREAM_DRAW);
|
|
||||||
glBufferData(GL_UNIFORM_BUFFER, sizeof(UniformState), &uniformState, GL_STREAM_DRAW);
|
|
||||||
stateDirty = 0;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
// flushUniforms();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
@ -1427,31 +1351,6 @@ stopSymbian(void)
|
||||||
static int
|
static int
|
||||||
initOpenGL(void)
|
initOpenGL(void)
|
||||||
{
|
{
|
||||||
|
|
||||||
#ifndef RW_GL_USE_UBOS
|
|
||||||
// u_alphaRef = registerUniform("u_alphaRef", UNIFORM_VEC4);
|
|
||||||
// u_fogData = registerUniform("u_fogData", UNIFORM_VEC4);
|
|
||||||
// u_fogColor = registerUniform("u_fogColor", UNIFORM_VEC4);
|
|
||||||
// u_proj = registerUniform("u_proj", UNIFORM_MAT4);
|
|
||||||
// u_view = registerUniform("u_view", UNIFORM_MAT4);
|
|
||||||
// u_world = registerUniform("u_world", UNIFORM_MAT4);
|
|
||||||
// u_ambLight = registerUniform("u_ambLight", UNIFORM_VEC4);
|
|
||||||
// u_lightParams = registerUniform("u_lightParams", UNIFORM_VEC4, MAX_LIGHTS);
|
|
||||||
// u_lightPosition = registerUniform("u_lightPosition", UNIFORM_VEC4, MAX_LIGHTS);
|
|
||||||
// u_lightDirection = registerUniform("u_lightDirection", UNIFORM_VEC4, MAX_LIGHTS);
|
|
||||||
// u_lightColor = registerUniform("u_lightColor", UNIFORM_VEC4, MAX_LIGHTS);
|
|
||||||
// lastShaderUploaded = nil;
|
|
||||||
#else
|
|
||||||
registerBlock("Scene");
|
|
||||||
registerBlock("Object");
|
|
||||||
registerBlock("State");
|
|
||||||
#endif
|
|
||||||
// u_matColor = registerUniform("u_matColor", UNIFORM_VEC4);
|
|
||||||
// u_surfProps = registerUniform("u_surfProps", UNIFORM_VEC4);
|
|
||||||
|
|
||||||
// for im2d
|
|
||||||
// registerUniform("u_xform", UNIFORM_VEC4);
|
|
||||||
|
|
||||||
glClearColor(0.25, 0.25, 0.25, 1.0);
|
glClearColor(0.25, 0.25, 0.25, 1.0);
|
||||||
|
|
||||||
byte whitepixel[4] = {0xFF, 0xFF, 0xFF, 0xFF};
|
byte whitepixel[4] = {0xFF, 0xFF, 0xFF, 0xFF};
|
||||||
|
|
@ -1468,13 +1367,10 @@ initOpenGL(void)
|
||||||
|
|
||||||
#ifndef __SYMBIAN32__
|
#ifndef __SYMBIAN32__
|
||||||
glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &maxAnisotropy);
|
glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &maxAnisotropy);
|
||||||
|
|
||||||
if(gl3Caps.glversion >= 30){
|
|
||||||
glGenVertexArrays(1, &vao);
|
|
||||||
glBindVertexArray(vao);
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
glEnable(GL_NORMALIZE);
|
||||||
|
|
||||||
openIm2D();
|
openIm2D();
|
||||||
openIm3D();
|
openIm3D();
|
||||||
|
|
||||||
|
|
|
||||||
96
vendor/librw/src/gles1/gl1immed.cpp
vendored
96
vendor/librw/src/gles1/gl1immed.cpp
vendored
|
|
@ -41,11 +41,15 @@ static int primTypeMap[] = {
|
||||||
void
|
void
|
||||||
openIm2D(void)
|
openIm2D(void)
|
||||||
{
|
{
|
||||||
|
glGenBuffers(1, &im2DIbo);
|
||||||
|
glGenBuffers(1, &im2DVbo);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
closeIm2D(void)
|
closeIm2D(void)
|
||||||
{
|
{
|
||||||
|
glDeleteBuffers(1, &im2DIbo);
|
||||||
|
glDeleteBuffers(1, &im2DVbo);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Im2DVertex tmpprimbuf[3];
|
static Im2DVertex tmpprimbuf[3];
|
||||||
|
|
@ -76,14 +80,39 @@ im2DRenderPrimitive(PrimitiveType primType, void *vertices, int32 numVertices)
|
||||||
cam = (Camera*)engine->currentCamera;
|
cam = (Camera*)engine->currentCamera;
|
||||||
|
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, im2DVbo);
|
glBindBuffer(GL_ARRAY_BUFFER, im2DVbo);
|
||||||
glBufferData(GL_ARRAY_BUFFER, numVertices*sizeof(Im2DVertex), vertices, GL_STATIC_DRAW);
|
glBufferData(GL_ARRAY_BUFFER, numVertices*sizeof(Im2DVertex), vertices, GL_DYNAMIC_DRAW);
|
||||||
|
|
||||||
|
glEnableClientState(GL_VERTEX_ARRAY);
|
||||||
|
glVertexPointer(3, GL_FLOAT, sizeof(Im2DVertex), (void*)0);
|
||||||
|
glEnableClientState(GL_COLOR_ARRAY);
|
||||||
|
glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(Im2DVertex), (void*)offsetof(Im2DVertex, r));
|
||||||
|
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||||
|
glTexCoordPointer(2, GL_FLOAT, sizeof(Im2DVertex), (void*)offsetof(Im2DVertex, u));
|
||||||
|
|
||||||
|
glMatrixMode(GL_PROJECTION);
|
||||||
|
glPushMatrix();
|
||||||
|
glLoadIdentity();
|
||||||
|
|
||||||
|
glMatrixMode(GL_MODELVIEW);
|
||||||
|
glPushMatrix();
|
||||||
|
glLoadIdentity();
|
||||||
|
glOrthof(0.0f, (float)cam->frameBuffer->width, (float)cam->frameBuffer->height, 0.0f, -1000.0f, 1000.0f);
|
||||||
|
|
||||||
flushCache();
|
flushCache();
|
||||||
|
|
||||||
glDrawArrays(primTypeMap[primType], 0, numVertices);
|
glDrawArrays(primTypeMap[primType], 0, numVertices);
|
||||||
|
|
||||||
|
glMatrixMode(GL_PROJECTION);
|
||||||
|
glPopMatrix();
|
||||||
|
glMatrixMode(GL_MODELVIEW);
|
||||||
|
glPopMatrix();
|
||||||
|
|
||||||
|
glDisableClientState(GL_VERTEX_ARRAY);
|
||||||
|
glDisableClientState(GL_COLOR_ARRAY);
|
||||||
|
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void im2DRenderIndexedPrimitive(PrimitiveType primType,
|
||||||
im2DRenderIndexedPrimitive(PrimitiveType primType,
|
|
||||||
void *vertices, int32 numVertices,
|
void *vertices, int32 numVertices,
|
||||||
void *indices, int32 numIndices)
|
void *indices, int32 numIndices)
|
||||||
{
|
{
|
||||||
|
|
@ -91,20 +120,42 @@ im2DRenderIndexedPrimitive(PrimitiveType primType,
|
||||||
cam = (Camera*)engine->currentCamera;
|
cam = (Camera*)engine->currentCamera;
|
||||||
|
|
||||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, im2DIbo);
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, im2DIbo);
|
||||||
glBufferData(GL_ELEMENT_ARRAY_BUFFER, numIndices*2, indices, GL_STATIC_DRAW);
|
glBufferData(GL_ELEMENT_ARRAY_BUFFER, numIndices*2, indices, GL_DYNAMIC_DRAW);
|
||||||
|
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, im2DVbo);
|
glBindBuffer(GL_ARRAY_BUFFER, im2DVbo);
|
||||||
glBufferData(GL_ARRAY_BUFFER, numVertices*sizeof(Im2DVertex), vertices, GL_STATIC_DRAW);
|
glBufferData(GL_ARRAY_BUFFER, numVertices*sizeof(Im2DVertex), vertices, GL_DYNAMIC_DRAW);
|
||||||
|
|
||||||
|
glEnableClientState(GL_VERTEX_ARRAY);
|
||||||
|
glVertexPointer(3, GL_FLOAT, sizeof(Im2DVertex), (void*)0);
|
||||||
|
glEnableClientState(GL_COLOR_ARRAY);
|
||||||
|
glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(Im2DVertex), (void*)offsetof(Im2DVertex, r));
|
||||||
|
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||||
|
glTexCoordPointer(2, GL_FLOAT, sizeof(Im2DVertex), (void*)offsetof(Im2DVertex, u));
|
||||||
|
|
||||||
|
glMatrixMode(GL_PROJECTION);
|
||||||
|
glPushMatrix();
|
||||||
|
glLoadIdentity();
|
||||||
|
glOrthof(0.0f, (float)cam->frameBuffer->width, (float)cam->frameBuffer->height, 0.0f, -1000.0f, 1000.0f);
|
||||||
|
|
||||||
|
glMatrixMode(GL_MODELVIEW);
|
||||||
|
glPushMatrix();
|
||||||
|
glLoadIdentity();
|
||||||
|
|
||||||
flushCache();
|
flushCache();
|
||||||
glDrawElements(primTypeMap[primType], numIndices,
|
glDrawElements(primTypeMap[primType], numIndices, GL_UNSIGNED_SHORT, nil);
|
||||||
GL_UNSIGNED_SHORT, nil);
|
|
||||||
|
glMatrixMode(GL_PROJECTION);
|
||||||
|
glPopMatrix();
|
||||||
|
glMatrixMode(GL_MODELVIEW);
|
||||||
|
glPopMatrix();
|
||||||
|
|
||||||
|
glDisableClientState(GL_VERTEX_ARRAY);
|
||||||
|
glDisableClientState(GL_COLOR_ARRAY);
|
||||||
|
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Im3D
|
// Im3D
|
||||||
|
|
||||||
|
|
||||||
static AttribDesc im3dattribDesc[3] = {
|
static AttribDesc im3dattribDesc[3] = {
|
||||||
{ ATTRIB_POS, GL_FLOAT, GL_FALSE, 3,
|
{ ATTRIB_POS, GL_FLOAT, GL_FALSE, 3,
|
||||||
sizeof(Im3DVertex), 0 },
|
sizeof(Im3DVertex), 0 },
|
||||||
|
|
@ -152,10 +203,20 @@ im3DTransform(void *vertices, int32 numVertices, Matrix *world, uint32 flags)
|
||||||
void
|
void
|
||||||
im3DRenderPrimitive(PrimitiveType primType)
|
im3DRenderPrimitive(PrimitiveType primType)
|
||||||
{
|
{
|
||||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, im3DIbo);
|
glBindBuffer(GL_ARRAY_BUFFER, im3DVbo);
|
||||||
|
glEnableClientState(GL_VERTEX_ARRAY);
|
||||||
|
glVertexPointer(3, GL_FLOAT, sizeof(Im3DVertex), (void*)0);
|
||||||
|
glEnableClientState(GL_COLOR_ARRAY);
|
||||||
|
glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(Im3DVertex), (void*)offsetof(Im3DVertex, r));
|
||||||
|
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||||
|
glTexCoordPointer(2, GL_FLOAT, sizeof(Im3DVertex), (void*)offsetof(Im3DVertex, u));
|
||||||
|
|
||||||
flushCache();
|
flushCache();
|
||||||
glDrawArrays(primTypeMap[primType], 0, num3DVertices);
|
glDrawArrays(primTypeMap[primType], 0, num3DVertices);
|
||||||
|
|
||||||
|
glDisableClientState(GL_VERTEX_ARRAY);
|
||||||
|
glDisableClientState(GL_COLOR_ARRAY);
|
||||||
|
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
@ -164,9 +225,20 @@ im3DRenderIndexedPrimitive(PrimitiveType primType, void *indices, int32 numIndic
|
||||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, im3DIbo);
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, im3DIbo);
|
||||||
glBufferData(GL_ELEMENT_ARRAY_BUFFER, numIndices*2, indices, GL_STATIC_DRAW);
|
glBufferData(GL_ELEMENT_ARRAY_BUFFER, numIndices*2, indices, GL_STATIC_DRAW);
|
||||||
|
|
||||||
|
glBindBuffer(GL_ARRAY_BUFFER, im3DVbo);
|
||||||
|
glEnableClientState(GL_VERTEX_ARRAY);
|
||||||
|
glVertexPointer(3, GL_FLOAT, sizeof(Im3DVertex), (void*)0);
|
||||||
|
glEnableClientState(GL_COLOR_ARRAY);
|
||||||
|
glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(Im3DVertex), (void*)offsetof(Im3DVertex, r));
|
||||||
|
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||||
|
glTexCoordPointer(2, GL_FLOAT, sizeof(Im3DVertex), (void*)offsetof(Im3DVertex, u));
|
||||||
|
|
||||||
flushCache();
|
flushCache();
|
||||||
glDrawElements(primTypeMap[primType], numIndices,
|
glDrawElements(primTypeMap[primType], numIndices, GL_UNSIGNED_SHORT, nil);
|
||||||
GL_UNSIGNED_SHORT, nil);
|
|
||||||
|
glDisableClientState(GL_VERTEX_ARRAY);
|
||||||
|
glDisableClientState(GL_COLOR_ARRAY);
|
||||||
|
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
||||||
34
vendor/librw/src/gles1/gl1raster.cpp
vendored
34
vendor/librw/src/gles1/gl1raster.cpp
vendored
|
|
@ -483,24 +483,24 @@ rasterUnlock(Raster *raster, int32 level)
|
||||||
natras->backingStore->levels[level].size);
|
natras->backingStore->levels[level].size);
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
if (raster->pixels != nil && natras->format == GL_RGBA && natras->type == GL_UNSIGNED_BYTE) {
|
// if (raster->pixels != nil && natras->format == GL_RGBA && natras->type == GL_UNSIGNED_BYTE) {
|
||||||
// convert to 16-bit
|
// // convert to 16-bit
|
||||||
uint16_t* pixels16 = (uint16_t*)malloc(raster->width * raster->height * sizeof(uint16_t));
|
// uint16_t* pixels16 = (uint16_t*)malloc(raster->width * raster->height * sizeof(uint16_t));
|
||||||
uint8_t* pixels8 = (uint8_t*)raster->pixels;
|
// uint8_t* pixels8 = (uint8_t*)raster->pixels;
|
||||||
|
//
|
||||||
for (int i = 0; i < raster->width * raster->height; i++) {
|
// for (int i = 0; i < raster->width * raster->height; i++) {
|
||||||
uint8_t r = pixels8[i * 4 + 0];
|
// uint8_t r = pixels8[i * 4 + 0];
|
||||||
uint8_t g = pixels8[i * 4 + 1];
|
// uint8_t g = pixels8[i * 4 + 1];
|
||||||
uint8_t b = pixels8[i * 4 + 2];
|
// uint8_t b = pixels8[i * 4 + 2];
|
||||||
uint8_t a = pixels8[i * 4 + 3];
|
// uint8_t a = pixels8[i * 4 + 3];
|
||||||
|
//
|
||||||
pixels16[i] = ((r >> 4) << 12) | ((g >> 4) << 8) | ((b >> 4) << 4) | (a >> 4);
|
// 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);
|
// glTexImage2D(GL_TEXTURE_2D, level, GL_RGBA, raster->width, raster->height, 0, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, pixels16);
|
||||||
free(pixels16);
|
// free(pixels16);
|
||||||
} else
|
// } else
|
||||||
{
|
{
|
||||||
// glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||||
glTexImage2D(GL_TEXTURE_2D, level, natras->internalFormat,
|
glTexImage2D(GL_TEXTURE_2D, level, natras->internalFormat,
|
||||||
raster->width, raster->height,
|
raster->width, raster->height,
|
||||||
0, natras->format, natras->type, raster->pixels);
|
0, natras->format, natras->type, raster->pixels);
|
||||||
|
|
|
||||||
67
vendor/librw/src/gles1/gl1render.cpp
vendored
67
vendor/librw/src/gles1/gl1render.cpp
vendored
|
|
@ -26,46 +26,10 @@ drawInst_simple(InstanceDataHeader *header, InstanceData *inst)
|
||||||
GL_UNSIGNED_SHORT, (void*)(uintptr)inst->offset);
|
GL_UNSIGNED_SHORT, (void*)(uintptr)inst->offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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)
|
|
||||||
{
|
|
||||||
uint32 hasAlpha;
|
|
||||||
int alphafunc, alpharef, gsalpharef;
|
|
||||||
int zwrite;
|
|
||||||
hasAlpha = getAlphaBlend();
|
|
||||||
if(hasAlpha){
|
|
||||||
zwrite = rw::GetRenderState(rw::ZWRITEENABLE);
|
|
||||||
alphafunc = rw::GetRenderState(rw::ALPHATESTFUNC);
|
|
||||||
if(zwrite){
|
|
||||||
alpharef = rw::GetRenderState(rw::ALPHATESTREF);
|
|
||||||
gsalpharef = rw::GetRenderState(rw::GSALPHATESTREF);
|
|
||||||
|
|
||||||
SetRenderState(rw::ALPHATESTFUNC, rw::ALPHAGREATEREQUAL);
|
|
||||||
SetRenderState(rw::ALPHATESTREF, gsalpharef);
|
|
||||||
drawInst_simple(header, inst);
|
|
||||||
SetRenderState(rw::ALPHATESTFUNC, rw::ALPHALESS);
|
|
||||||
SetRenderState(rw::ZWRITEENABLE, 0);
|
|
||||||
drawInst_simple(header, inst);
|
|
||||||
SetRenderState(rw::ZWRITEENABLE, 1);
|
|
||||||
SetRenderState(rw::ALPHATESTFUNC, alphafunc);
|
|
||||||
SetRenderState(rw::ALPHATESTREF, alpharef);
|
|
||||||
}else{
|
|
||||||
SetRenderState(rw::ALPHATESTFUNC, rw::ALPHAALWAYS);
|
|
||||||
drawInst_simple(header, inst);
|
|
||||||
SetRenderState(rw::ALPHATESTFUNC, alphafunc);
|
|
||||||
}
|
|
||||||
}else
|
|
||||||
drawInst_simple(header, inst);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
drawInst(InstanceDataHeader *header, InstanceData *inst)
|
drawInst(InstanceDataHeader *header, InstanceData *inst)
|
||||||
{
|
{
|
||||||
// if(rw::GetRenderState(rw::GSALPHATEST))
|
drawInst_simple(header, inst);
|
||||||
// drawInst_GSemu(header, inst);
|
|
||||||
// else
|
|
||||||
drawInst_simple(header, inst);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -74,6 +38,35 @@ setupVertexInput(InstanceDataHeader *header)
|
||||||
{
|
{
|
||||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, header->ibo);
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, header->ibo);
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, header->vbo);
|
glBindBuffer(GL_ARRAY_BUFFER, header->vbo);
|
||||||
|
bool hasNormal = false;
|
||||||
|
bool hasColor = false;
|
||||||
|
bool hasTex = false;
|
||||||
|
|
||||||
|
for (int32 i = 0; i < header->numAttribs; i++) {
|
||||||
|
AttribDesc *a = &header->attribDesc[i];
|
||||||
|
if (a->index == ATTRIB_POS) {
|
||||||
|
glEnableClientState(GL_VERTEX_ARRAY);
|
||||||
|
glVertexPointer(a->size, a->type, a->stride, (void*)(uintptr)a->offset);
|
||||||
|
} else if (a->index == ATTRIB_NORMAL) {
|
||||||
|
glEnableClientState(GL_NORMAL_ARRAY);
|
||||||
|
glNormalPointer(a->type, a->stride, (void*)(uintptr)a->offset);
|
||||||
|
hasNormal = true;
|
||||||
|
} else if (a->index == ATTRIB_COLOR){
|
||||||
|
glEnableClientState(GL_COLOR_ARRAY);
|
||||||
|
glColorPointer(a->size, a->type, a->stride, (void*)(uintptr)a->offset);
|
||||||
|
hasColor = true;
|
||||||
|
} else if(a->index == ATTRIB_TEXCOORDS0){
|
||||||
|
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||||
|
glTexCoordPointer(a->size, a->type, a->stride, (void*)(uintptr)a->offset);
|
||||||
|
hasTex = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!hasNormal) glDisableClientState(GL_NORMAL_ARRAY);
|
||||||
|
if (!hasColor) {
|
||||||
|
glDisableClientState(GL_COLOR_ARRAY);
|
||||||
|
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
||||||
|
}
|
||||||
|
if(!hasTex) glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
||||||
2
vendor/librw/src/gles1/rwgles1.h
vendored
2
vendor/librw/src/gles1/rwgles1.h
vendored
|
|
@ -209,6 +209,8 @@ void *destroyNativeData(void *object, int32, int32);
|
||||||
|
|
||||||
ObjPipeline *makeDefaultPipeline(void);
|
ObjPipeline *makeDefaultPipeline(void);
|
||||||
|
|
||||||
|
void setVertexAlpha(bool32 enable);
|
||||||
|
|
||||||
// Native Texture and Raster
|
// Native Texture and Raster
|
||||||
|
|
||||||
struct Gl1Raster
|
struct Gl1Raster
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue