Try to match GL filtering with PVR filtering
This commit is contained in:
parent
5c190c1095
commit
e7cd91a91f
|
@ -228,7 +228,7 @@ void APIENTRY glGenerateMipmapEXT(GLenum target) {
|
|||
|
||||
/* Do the minification */
|
||||
for(sx = 0, dx = 0; sx < prevWidth; sx += 2, dx += 1) {
|
||||
for(sy = 0, sy = 0; sy < prevHeight; sy += 2, dy += 1) {
|
||||
for(sy = 0, dy = 0; sy < prevHeight; sy += 2, dy += 1) {
|
||||
GLubyte* srcTexel = &prevData[
|
||||
((sy * prevWidth) + sx) * tex->dataStride
|
||||
];
|
||||
|
|
|
@ -34,13 +34,15 @@ typedef struct {
|
|||
GLushort height;
|
||||
GLuint color; /* This is the PVR texture format */
|
||||
GLubyte env;
|
||||
GLubyte filter;
|
||||
GLushort mipmap; /* Bitmask of supplied mipmap levels */
|
||||
GLubyte mipmapCount; /* The number of mipmap levels */
|
||||
GLubyte uv_clamp;
|
||||
GLuint index;
|
||||
GLvoid *data;
|
||||
GLuint dataStride;
|
||||
|
||||
GLenum minFilter;
|
||||
GLenum magFilter;
|
||||
} TextureObject;
|
||||
|
||||
typedef struct {
|
||||
|
|
32
GL/state.c
32
GL/state.c
|
@ -126,10 +126,38 @@ void updatePVRTextureContext(pvr_poly_cxt_t* context, TextureObject *tx1) {
|
|||
context->txr2.enable = PVR_TEXTURE_DISABLE;
|
||||
context->txr2.alpha = PVR_TXRALPHA_DISABLE;
|
||||
|
||||
GLuint filter = PVR_FILTER_NEAREST;
|
||||
GLboolean enableMipmaps = GL_FALSE;
|
||||
|
||||
switch(tx1->minFilter) {
|
||||
case GL_NEAREST_MIPMAP_LINEAR:
|
||||
case GL_NEAREST_MIPMAP_NEAREST:
|
||||
case GL_LINEAR_MIPMAP_LINEAR:
|
||||
case GL_LINEAR_MIPMAP_NEAREST:
|
||||
enableMipmaps = GL_TRUE;
|
||||
break;
|
||||
}
|
||||
|
||||
if(enableMipmaps) {
|
||||
if(tx1->minFilter == GL_LINEAR_MIPMAP_NEAREST) {
|
||||
filter = PVR_FILTER_TRILINEAR1;
|
||||
} else if(tx1->minFilter == GL_LINEAR_MIPMAP_LINEAR) {
|
||||
filter = PVR_FILTER_TRILINEAR2;
|
||||
} else if(tx1->minFilter == GL_NEAREST_MIPMAP_LINEAR) {
|
||||
filter = PVR_FILTER_BILINEAR;
|
||||
} else {
|
||||
filter = PVR_FILTER_NEAREST;
|
||||
}
|
||||
} else {
|
||||
if(tx1->minFilter == GL_LINEAR && tx1->magFilter == GL_LINEAR) {
|
||||
filter = PVR_FILTER_BILINEAR;
|
||||
}
|
||||
}
|
||||
|
||||
if(tx1) {
|
||||
context->txr.enable = PVR_TEXTURE_ENABLE;
|
||||
context->txr.filter = tx1->filter;
|
||||
context->txr.mipmap = (_glIsMipmapComplete(tx1)) ? PVR_MIPMAP_ENABLE : PVR_MIPMAP_DISABLE;
|
||||
context->txr.filter = filter;
|
||||
context->txr.mipmap = (enableMipmaps) ? PVR_MIPMAP_ENABLE : PVR_MIPMAP_DISABLE;
|
||||
context->txr.mipmap_bias = PVR_MIPBIAS_NORMAL;
|
||||
context->txr.width = tx1->width;
|
||||
context->txr.height = tx1->height;
|
||||
|
|
48
GL/texture.c
48
GL/texture.c
|
@ -151,9 +151,10 @@ void APIENTRY glGenTextures(GLsizei n, GLuint *textures) {
|
|||
txr->mipmap = 0;
|
||||
txr->uv_clamp = 0;
|
||||
txr->env = PVR_TXRENV_MODULATEALPHA;
|
||||
txr->filter = PVR_FILTER_NONE;
|
||||
txr->data = NULL;
|
||||
txr->mipmapCount = 0;
|
||||
txr->minFilter = GL_NEAREST;
|
||||
txr->magFilter = GL_NEAREST;
|
||||
|
||||
*textures = id;
|
||||
|
||||
|
@ -696,30 +697,35 @@ void APIENTRY glTexParameteri(GLenum target, GLenum pname, GLint param) {
|
|||
if(target == GL_TEXTURE_2D) {
|
||||
switch(pname) {
|
||||
case GL_TEXTURE_MAG_FILTER:
|
||||
switch(param) {
|
||||
case GL_NEAREST:
|
||||
case GL_LINEAR:
|
||||
break;
|
||||
default: {
|
||||
_glKosThrowError(GL_INVALID_VALUE, __func__);
|
||||
_glKosPrintError();
|
||||
return;
|
||||
}
|
||||
}
|
||||
active->magFilter = param;
|
||||
break;
|
||||
case GL_TEXTURE_MIN_FILTER:
|
||||
switch(param) {
|
||||
case GL_LINEAR:
|
||||
active->filter = PVR_FILTER_BILINEAR;
|
||||
break;
|
||||
|
||||
case GL_NEAREST:
|
||||
active->filter = PVR_FILTER_NEAREST;
|
||||
break;
|
||||
|
||||
case GL_FILTER_NONE:
|
||||
active->filter = PVR_FILTER_NONE;
|
||||
break;
|
||||
|
||||
case GL_FILTER_BILINEAR:
|
||||
active->filter = PVR_FILTER_BILINEAR;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
case GL_LINEAR:
|
||||
case GL_NEAREST_MIPMAP_LINEAR:
|
||||
case GL_NEAREST_MIPMAP_NEAREST:
|
||||
case GL_LINEAR_MIPMAP_LINEAR:
|
||||
case GL_LINEAR_MIPMAP_NEAREST:
|
||||
break;
|
||||
default: {
|
||||
_glKosThrowError(GL_INVALID_VALUE, __func__);
|
||||
_glKosPrintError();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
active->minFilter = param;
|
||||
break;
|
||||
case GL_TEXTURE_WRAP_S:
|
||||
switch(param) {
|
||||
case GL_CLAMP:
|
||||
|
|
|
@ -124,7 +124,7 @@ void LoadGLTextures() {
|
|||
glBindTexture(GL_TEXTURE_2D, texture[0]); // 2d texture (x and y size)
|
||||
|
||||
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); // scale linearly when image bigger than texture
|
||||
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); // scale linearly when image smalled than texture
|
||||
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_LINEAR); // scale linearly when image smalled than texture
|
||||
|
||||
// 2d texture, level of detail 0 (normal), 3 components (red, green, blue), x size from image, y size from image,
|
||||
// border 0 (normal), rgb color data, unsigned byte data, and finally the data itself.
|
||||
|
|
Loading…
Reference in New Issue
Block a user