forked from enlightenment/efl
parent
ce8bf6b723
commit
8b128c4213
|
@ -66,8 +66,15 @@ evas_gl_common_context_use(Evas_GL_Context *gc)
|
|||
if (strstr(ext, "GL_SGIS_generate_mipmap")) gc->ext.sgis_generate_mipmap = 1;
|
||||
if (strstr(ext, "GL_NV_texture_rectangle")) gc->ext.nv_texture_rectangle = 1;
|
||||
if (strstr(ext, "GL_EXT_texture_rectangle")) gc->ext.nv_texture_rectangle = 1;
|
||||
if (strstr(ext, "GL_ARB_texture_non_power_of_two")) gc->ext.arb_texture_non_power_of_two = 1;
|
||||
printf("GL EXT supported: GL_SGIS_generate_mipmap = %x\n", gc->ext.sgis_generate_mipmap);
|
||||
printf("GL EXT supported: GL_NV_texture_rectangle = %x\n", gc->ext.nv_texture_rectangle);
|
||||
printf("GL EXT supported: GL_ARB_texture_non_power_of_two = %x\n", gc->ext.arb_texture_non_power_of_two);
|
||||
// this causes at least nvidia's drivers to go into pathological pain when
|
||||
// changing textures a lot (doing video). so we wont do anything with this
|
||||
// for now, but it does work.
|
||||
gc->ext.arb_texture_non_power_of_two = 0; printf("DISABLE GL_ARB_texture_non_power_of_two\n");
|
||||
// gc->ext.nv_texture_rectangle = 0; printf("DISABLE GL_NV_texture_rectangle\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -176,7 +183,7 @@ evas_gl_common_context_font_texture_set(Evas_GL_Context *gc, Evas_GL_Font_Textur
|
|||
if (gc->font_texture != ft->texture)
|
||||
{
|
||||
gc->font_texture = ft->texture;
|
||||
gc->font_texture_not_power_of_two = ft->pool->not_power_of_two;
|
||||
gc->font_texture_rectangle = ft->pool->rectangle;
|
||||
gc->change.texture = 1;
|
||||
}
|
||||
if (!gc->change.texture) return;
|
||||
|
@ -287,7 +294,7 @@ _evas_gl_common_texture_set(Evas_GL_Context *gc)
|
|||
if (!gc->change.texture) return;
|
||||
if (gc->font_texture > 0)
|
||||
{
|
||||
if (gc->font_texture_not_power_of_two)
|
||||
if (gc->font_texture_rectangle)
|
||||
{
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
glEnable(GL_TEXTURE_RECTANGLE_NV);
|
||||
|
@ -303,7 +310,7 @@ _evas_gl_common_texture_set(Evas_GL_Context *gc)
|
|||
}
|
||||
else if (gc->texture)
|
||||
{
|
||||
if (gc->texture->not_power_of_two)
|
||||
if (gc->texture->rectangle)
|
||||
{
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
glEnable(GL_TEXTURE_RECTANGLE_NV);
|
||||
|
@ -315,7 +322,7 @@ _evas_gl_common_texture_set(Evas_GL_Context *gc)
|
|||
glEnable(GL_TEXTURE_2D);
|
||||
glBindTexture(GL_TEXTURE_2D, gc->texture->texture);
|
||||
}
|
||||
if (gc->texture->not_power_of_two)
|
||||
if (gc->texture->rectangle)
|
||||
{
|
||||
if (gc->texture->changed)
|
||||
{
|
||||
|
@ -326,7 +333,7 @@ _evas_gl_common_texture_set(Evas_GL_Context *gc)
|
|||
{
|
||||
if (gc->texture->changed)
|
||||
{
|
||||
if (gc->texture->not_power_of_two)
|
||||
if (gc->texture->rectangle)
|
||||
{
|
||||
if (gc->texture->smooth)
|
||||
{
|
||||
|
@ -343,6 +350,7 @@ _evas_gl_common_texture_set(Evas_GL_Context *gc)
|
|||
{
|
||||
if (gc->texture->smooth)
|
||||
{
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 8);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
if (gc->texture->have_mipmaps)
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
|
||||
|
|
|
@ -110,7 +110,7 @@ evas_gl_font_texture_new(Evas_GL_Context *gc, RGBA_Font_Glyph *fg)
|
|||
ft->y = ft->alloc->y;
|
||||
ft->pool = ft->alloc->pool;
|
||||
ft->texture = ft->pool->texture;
|
||||
if (ft->pool->not_power_of_two)
|
||||
if (ft->pool->rectangle)
|
||||
{
|
||||
glEnable(GL_TEXTURE_RECTANGLE_NV);
|
||||
glBindTexture(GL_TEXTURE_RECTANGLE_NV, ft->texture);
|
||||
|
@ -132,9 +132,9 @@ evas_gl_font_texture_new(Evas_GL_Context *gc, RGBA_Font_Glyph *fg)
|
|||
gc->texture = NULL;
|
||||
}
|
||||
gc->font_texture = ft->texture;
|
||||
gc->font_texture_not_power_of_two = ft->pool->not_power_of_two;
|
||||
gc->font_texture_rectangle = ft->pool->rectangle;
|
||||
gc->change.texture = 1;
|
||||
if (ft->pool->not_power_of_two)
|
||||
if (ft->pool->rectangle)
|
||||
{
|
||||
ft->tx1 = ft->x;
|
||||
ft->ty1 = ft->y;
|
||||
|
@ -263,13 +263,13 @@ _evas_gl_font_texture_pool_request(Evas_GL_Context *gc, int w, int h)
|
|||
fp->gc = gc;
|
||||
fp->w = minw;
|
||||
fp->h = minh;
|
||||
if (gc->ext.nv_texture_rectangle) fp->not_power_of_two = 1;
|
||||
if (gc->ext.nv_texture_rectangle) fp->rectangle = 1;
|
||||
|
||||
/* we dont want this mipmapped if sgis_generate_mipmap will mipmap it */
|
||||
if (gc->ext.sgis_generate_mipmap)
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP_SGIS, GL_FALSE);
|
||||
// glEnable(GL_TEXTURE_2D);
|
||||
if (fp->not_power_of_two)
|
||||
if (fp->rectangle)
|
||||
{
|
||||
glEnable(GL_TEXTURE_RECTANGLE_NV);
|
||||
glGenTextures(1, &(fp->texture));
|
||||
|
|
|
@ -176,7 +176,7 @@ evas_gl_common_image_draw(Evas_GL_Context *gc, RGBA_Draw_Context *dc, Evas_GL_Im
|
|||
(!gc->ext.sgis_generate_mipmap))
|
||||
evas_gl_common_texture_mipmaps_build(im->tex, im->im, smooth);
|
||||
|
||||
if (im->tex->not_power_of_two)
|
||||
if (im->tex->rectangle)
|
||||
{
|
||||
tx1 = sx;
|
||||
ty1 = sy;
|
||||
|
@ -205,19 +205,9 @@ evas_gl_common_image_draw(Evas_GL_Context *gc, RGBA_Draw_Context *dc, Evas_GL_Im
|
|||
evas_gl_common_context_write_buf_set(gc, GL_BACK);
|
||||
|
||||
glBegin(GL_QUADS);
|
||||
if (im->tex->not_power_of_two)
|
||||
{
|
||||
glTexCoord2d(tx1, ty1); glVertex2i(dx , dy );
|
||||
glTexCoord2d(tx2, ty1); glVertex2i(dx + dw, dy );
|
||||
glTexCoord2d(tx2, ty2); glVertex2i(dx + dw, dy + dh);
|
||||
glTexCoord2d(tx1, ty2); glVertex2i(dx , dy + dh);
|
||||
}
|
||||
else
|
||||
{
|
||||
glTexCoord2d(tx1, ty1); glVertex2f(dx , dy );
|
||||
glTexCoord2d(tx2, ty1); glVertex2f(dx + dw + 0.5, dy );
|
||||
glTexCoord2d(tx2, ty2); glVertex2f(dx + dw + 0.5, dy + dh + 0.5);
|
||||
glTexCoord2d(tx1, ty2); glVertex2f(dx , dy + dh + 0.5);
|
||||
}
|
||||
glEnd();
|
||||
}
|
||||
|
|
|
@ -13,12 +13,14 @@ evas_gl_common_texture_new(Evas_GL_Context *gc, RGBA_Image *im, int smooth)
|
|||
tex = calloc(1, sizeof(Evas_GL_Texture));
|
||||
if (!tex) return NULL;
|
||||
|
||||
if (gc->ext.nv_texture_rectangle)
|
||||
if ((gc->ext.nv_texture_rectangle) &&
|
||||
(!(gc->ext.arb_texture_non_power_of_two &&
|
||||
gc->ext.sgis_generate_mipmap)))
|
||||
{
|
||||
tex->gc = gc;
|
||||
tex->w = im->image->w;
|
||||
tex->h = im->image->h;
|
||||
tex->not_power_of_two = 1;
|
||||
tex->rectangle = 1;
|
||||
tex->tw = im->image->w;
|
||||
tex->th = im->image->h;
|
||||
tex->references = 0;
|
||||
|
@ -55,8 +57,16 @@ evas_gl_common_texture_new(Evas_GL_Context *gc, RGBA_Image *im, int smooth)
|
|||
return tex;
|
||||
}
|
||||
|
||||
if ((gc->ext.arb_texture_non_power_of_two) && (gc->ext.sgis_generate_mipmap))
|
||||
{
|
||||
tw = im->image->w;
|
||||
th = im->image->h;
|
||||
}
|
||||
else
|
||||
{
|
||||
shift = 1; while (im->image->w > shift) shift = shift << 1; tw = shift;
|
||||
shift = 1; while (im->image->h > shift) shift = shift << 1; th = shift;
|
||||
}
|
||||
tex->gc = gc;
|
||||
tex->w = tw;
|
||||
tex->h = th;
|
||||
|
@ -73,7 +83,7 @@ evas_gl_common_texture_new(Evas_GL_Context *gc, RGBA_Image *im, int smooth)
|
|||
gc->change.texture = 1;
|
||||
tex->references++;
|
||||
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 8);
|
||||
// glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 8);
|
||||
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
|
@ -145,7 +155,7 @@ evas_gl_common_texture_update(Evas_GL_Texture *tex, RGBA_Image *im, int smooth)
|
|||
int tw, th;
|
||||
GLenum pixfmt, texfmt, target;
|
||||
|
||||
if (tex->not_power_of_two)
|
||||
if (tex->rectangle)
|
||||
{
|
||||
void *data;
|
||||
|
||||
|
@ -196,16 +206,16 @@ evas_gl_common_texture_update(Evas_GL_Texture *tex, RGBA_Image *im, int smooth)
|
|||
th = tex->h;
|
||||
tex->changed = 1;
|
||||
tex->have_mipmaps = 0;
|
||||
if (tex->gc->ext.nv_texture_rectangle) glDisable(GL_TEXTURE_RECTANGLE_NV);
|
||||
// if (tex->gc->ext.nv_texture_rectangle) glDisable(GL_TEXTURE_RECTANGLE_NV);
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
if (tex->not_power_of_two)
|
||||
if (tex->rectangle)
|
||||
{
|
||||
glEnable(GL_TEXTURE_RECTANGLE_NV);
|
||||
target = GL_TEXTURE_RECTANGLE_NV;
|
||||
}
|
||||
else
|
||||
{
|
||||
glDisable(GL_TEXTURE_RECTANGLE_NV);
|
||||
// glDisable(GL_TEXTURE_RECTANGLE_NV);
|
||||
glEnable(GL_TEXTURE_2D);//
|
||||
target = GL_TEXTURE_2D;
|
||||
}
|
||||
|
@ -299,7 +309,7 @@ evas_gl_common_texture_mipmaps_build(Evas_GL_Texture *tex, RGBA_Image *im, int s
|
|||
#endif
|
||||
|
||||
if (!smooth) return;
|
||||
if (tex->not_power_of_two) return;
|
||||
if (tex->rectangle) return;
|
||||
#ifdef BUILD_MMX
|
||||
evas_common_cpu_can_do(&mmx, &sse, &sse2);
|
||||
#endif
|
||||
|
|
|
@ -65,6 +65,7 @@ struct _Evas_GL_Context
|
|||
int checked : 1;
|
||||
int sgis_generate_mipmap : 1;
|
||||
int nv_texture_rectangle : 1;
|
||||
int arb_texture_non_power_of_two : 1;
|
||||
} ext;
|
||||
|
||||
GLenum read_buf;
|
||||
|
@ -72,7 +73,7 @@ struct _Evas_GL_Context
|
|||
|
||||
Evas_GL_Texture *texture;
|
||||
GLuint font_texture;
|
||||
char font_texture_not_power_of_two : 1;
|
||||
char font_texture_rectangle : 1;
|
||||
|
||||
int max_texture_depth;
|
||||
int max_texture_size;
|
||||
|
@ -95,6 +96,7 @@ struct _Evas_GL_Texture
|
|||
char smooth : 1;
|
||||
char changed : 1;
|
||||
char have_mipmaps : 1;
|
||||
char rectangle : 1;
|
||||
char not_power_of_two : 1;
|
||||
char opt : 1;
|
||||
|
||||
|
@ -106,6 +108,7 @@ struct _Evas_GL_Image
|
|||
Evas_GL_Context *gc;
|
||||
RGBA_Image *im;
|
||||
Evas_GL_Texture *tex;
|
||||
int putcount;
|
||||
int references;
|
||||
char dirty : 1;
|
||||
char cached : 1;
|
||||
|
@ -144,7 +147,7 @@ struct _Evas_GL_Font_Texture_Pool
|
|||
int w, h;
|
||||
GLuint texture;
|
||||
int references;
|
||||
char not_power_of_two : 1;
|
||||
char rectangle : 1;
|
||||
Evas_List *allocations;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue