glshim updated, added latest changes by ptitSeb

This commit is contained in:
lubomyr
2015-10-27 20:55:56 +02:00
parent 0ace3293d1
commit 7ab4a4db8b
3 changed files with 64 additions and 2 deletions

View File

@@ -30,6 +30,7 @@ GLuint readhack_seq = 0;
GLuint gl_batch = 0;
GLuint gl_mergelist = 1;
int blendhack = 0;
char gl_version[50];
__attribute__((constructor))
void initialize_glshim() {
@@ -79,7 +80,7 @@ const GLubyte *glGetString(GLenum name) {
printf("**warning** glGetString(%i) called with bad init\n", name);*/
switch (name) {
case GL_VERSION:
return (GLubyte *)"1.4 glshim wrapper";
return (GLubyte *)gl_version;
case GL_EXTENSIONS:
return (const GLubyte *)(char *){
"GL_ARB_vertex_buffer_object "
@@ -122,7 +123,7 @@ const GLubyte *glGetString(GLenum name) {
// "GL_ARB_texture_cube_map "
};
case GL_VENDOR:
return (GLubyte *)"OpenPandora";
return (GLubyte *)"ptitSeb";
case GL_RENDERER:
return (GLubyte *)"GLES_CM wrapper";
case GL_SHADING_LANGUAGE_VERSION:

View File

@@ -393,6 +393,50 @@ void glTexImage2D(GLenum target, GLint level, GLint internalformat,
bound->shrink=1;
}
break;
case 9: //advertise 8192 max texture size, but >4096 are quadshrinked and >512 are shrinked, but not for empty texture
if ((width>4096) || (height>4096)) {
GLvoid *out = pixels;
pixel_quarterscale(pixels, &out, width, height, format, type);
if (out != pixels && pixels!=datab)
free(pixels);
pixels = out;
width /= 4;
height /= 4;
bound->shrink=2;
} else
if ((width>512) || (height>512)) {
GLvoid *out = pixels;
pixel_halfscale(pixels, &out, width, height, format, type);
if (out != pixels && pixels!=datab)
free(pixels);
pixels = out;
width /= 2;
height /= 2;
bound->shrink=1;
}
break;
case 10://advertise 8192 max texture size, but >2048 are quadshrinked and >512 are shrinked, but not for empty texture
if ((width>2048) || (height>2048)) {
GLvoid *out = pixels;
pixel_quarterscale(pixels, &out, width, height, format, type);
if (out != pixels && pixels!=datab)
free(pixels);
pixels = out;
width /= 4;
height /= 4;
bound->shrink=2;
} else
if ((width>512) || (height>512)) {
GLvoid *out = pixels;
pixel_halfscale(pixels, &out, width, height, format, type);
if (out != pixels && pixels!=datab)
free(pixels);
pixels = out;
width /= 2;
height /= 2;
bound->shrink=1;
}
break;
}
}
@@ -465,6 +509,8 @@ void glTexImage2D(GLenum target, GLint level, GLint internalformat,
case 7: //only > 512 /2, but not for empty texture
break;
case 8: //advertise 8192 max texture size, but >2048 are shrinked to 2048
case 9: //advertise 8192 max texture size, but >4096 are quadshrinked and >512 are shrinked, but not for empty texture (but >2048 are not supported anyway)
case 10://advertise 8192 max texture size, but >2048 are quadshrinked and >512 are shrinked, but not for empty texture (but >2048 are not supported anyway)
if((width>4096) || (height>4096)) {
width /= 4;
height /= 4;

View File

@@ -167,6 +167,7 @@ extern int texstream;
extern int copytex;
extern int nolumalpha;
extern int blendhack;
extern char gl_version[50];
bool g_recyclefbo = false;
static int g_width=0, g_height=0;
@@ -373,6 +374,14 @@ static void scan_env() {
texshrink = 8;
printf("LIBGL: Texture shink, mode 8 selected (advertise 8192 max texture size, but >2048 are shrinked to 2048)\n");
}
if (env_shrink && strcmp(env_shrink, "9") == 0) {
texshrink = 9;
printf("LIBGL: Texture shink, mode 9 selected (advertise 8192 max texture size, but >4096 are quadshrinked and > 512 are shrinked), but not for empty texture\n");
}
if (env_shrink && strcmp(env_shrink, "10") == 0) {
texshrink = 10;
printf("LIBGL: Texture shink, mode 10 selected (advertise 8192 max texture size, but >2048 are quadshrinked and > 512 are shrinked), but not for empty texture\n");
}
char *env_dump = getenv("LIBGL_TEXDUMP");
if (env_dump && strcmp(env_dump, "1") == 0) {
texdump = 1;
@@ -409,6 +418,12 @@ static void scan_env() {
env(LIBGL_BLENDHACK, blendhack, "Change Blend GL_SRC_ALPHA, GL_ONE to GL_ONE, GL_ONE");
char *env_version = getenv("LIBGL_VERSION");
if (env_version) {
printf("LIBGL: Overide version string with \"%s\" (should be in the form of \"1.x\")\n", gl_version);
}
snprintf(gl_version, 49, "%s glshim wrapper", (env_version)?env_version:"1.5");
char cwd[1024];
if (getcwd(cwd, sizeof(cwd))!= NULL)
printf("LIBGL: Current folder is:%s\n", cwd);