More lighting work
This commit is contained in:
parent
4b8991e45f
commit
a09e05b01a
|
@ -144,6 +144,7 @@ static void submitVertices(GLenum mode, GLsizei first, GLsizei count, GLenum typ
|
|||
// Compile
|
||||
pvr_poly_cxt_t cxt = *getPVRContext();
|
||||
cxt.list_type = activePolyList()->list_type;
|
||||
|
||||
updatePVRTextureContext(&cxt, getTexture0());
|
||||
|
||||
pvr_poly_compile(hdr, &cxt);
|
||||
|
@ -167,7 +168,7 @@ static void submitVertices(GLenum mode, GLsizei first, GLsizei count, GLenum typ
|
|||
for(GLuint i = first; i < count; ++i) {
|
||||
pvr_vertex_t* vertex = (pvr_vertex_t*) dst;
|
||||
vertex->u = vertex->v = 0.0f;
|
||||
vertex->argb = PVR_PACK_COLOR(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
vertex->argb = 0;
|
||||
vertex->oargb = 0;
|
||||
vertex->flags = PVR_CMD_VERTEX;
|
||||
|
||||
|
@ -202,9 +203,19 @@ static void submitVertices(GLenum mode, GLsizei first, GLsizei count, GLenum typ
|
|||
for(GLubyte i = 0; i < MAX_LIGHTS; ++i) {
|
||||
if(isLightEnabled(i)) {
|
||||
calculateLightingContribution(i, &vertex->x, normal, contribution);
|
||||
to_add = PVR_PACK_COLOR(contribution[0], contribution[1], contribution[2], contribution[3]);
|
||||
to_add = PVR_PACK_COLOR(contribution[3], contribution[0], contribution[1], contribution[2]);
|
||||
|
||||
/* FIXME: Add the colour to argb */
|
||||
GLubyte a = ((vertex->argb & 0xFF000000) >> 24) + ((to_add & 0xFF000000) >> 24);
|
||||
GLubyte r = ((vertex->argb & 0x00FF0000) >> 16) + ((to_add & 0x00FF0000) >> 16);
|
||||
GLubyte g = ((vertex->argb & 0x0000FF00) >> 8) + ((to_add & 0x0000FF00) >> 8);
|
||||
GLubyte b = ((vertex->argb & 0x000000FF) >> 0) + ((to_add & 0x000000FF) >> 0);
|
||||
|
||||
a = (a > 255) ? 255 : a;
|
||||
r = (r > 255) ? 255 : r;
|
||||
g = (g > 255) ? 255 : g;
|
||||
b = (b > 255) ? 255 : b;
|
||||
|
||||
vertex->argb = a << 24 | r << 16 | g << 8 | b;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -135,5 +135,6 @@ void APIENTRY glMaterialfv(GLenum face, GLenum pname, const GLfloat *params) {
|
|||
}
|
||||
|
||||
void calculateLightingContribution(const GLint light, const GLfloat* pos, const GLfloat* normal, GLfloat* colour) {
|
||||
|
||||
colour[0] = colour[3] = 0.0f;
|
||||
colour[1] = colour[2] = 0.0f;
|
||||
}
|
||||
|
|
|
@ -78,7 +78,6 @@ static int _calcPVRBlendFactor(GLenum factor) {
|
|||
case GL_ZERO:
|
||||
return PVR_BLEND_ZERO;
|
||||
case GL_SRC_ALPHA:
|
||||
case GL_SRC_COLOR:
|
||||
return PVR_BLEND_SRCALPHA;
|
||||
case GL_DST_COLOR:
|
||||
return PVR_BLEND_DESTCOLOR;
|
||||
|
@ -86,13 +85,14 @@ static int _calcPVRBlendFactor(GLenum factor) {
|
|||
return PVR_BLEND_DESTALPHA;
|
||||
case GL_ONE_MINUS_DST_COLOR:
|
||||
return PVR_BLEND_INVDESTCOLOR;
|
||||
case GL_ONE_MINUS_SRC_COLOR:
|
||||
case GL_ONE_MINUS_SRC_ALPHA:
|
||||
return PVR_BLEND_INVSRCALPHA;
|
||||
case GL_ONE_MINUS_DST_ALPHA:
|
||||
return PVR_BLEND_INVDESTALPHA;
|
||||
case GL_ONE:
|
||||
return PVR_BLEND_ONE;
|
||||
default:
|
||||
fprintf(stderr, "Invalid blend mode: %d\n", factor);
|
||||
return PVR_BLEND_ONE;
|
||||
}
|
||||
}
|
||||
|
@ -132,7 +132,7 @@ void updatePVRTextureContext(pvr_poly_cxt_t* context, TextureObject *tx1) {
|
|||
}
|
||||
|
||||
context->txr2.enable = PVR_TEXTURE_DISABLE;
|
||||
context->txr2.alpha = PVR_ALPHA_DISABLE;
|
||||
context->txr2.alpha = PVR_TXRALPHA_DISABLE;
|
||||
|
||||
if(tx1) {
|
||||
context->txr.enable = PVR_TEXTURE_ENABLE;
|
||||
|
@ -145,6 +145,7 @@ void updatePVRTextureContext(pvr_poly_cxt_t* context, TextureObject *tx1) {
|
|||
context->txr.env = tx1->env;
|
||||
context->txr.uv_flip = PVR_UVFLIP_NONE;
|
||||
context->txr.uv_clamp = tx1->uv_clamp;
|
||||
context->txr.alpha = PVR_TXRALPHA_ENABLE;
|
||||
} else {
|
||||
context->txr.enable = PVR_TEXTURE_DISABLE;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user