Add function to query maximum texture size. Also, make texture upload
functions aware of this limit.
This commit is contained in:
@@ -196,17 +196,21 @@ static bool is_power_of_2_resolution(int w, int h)
|
||||
|
||||
static bool is_over_resolution_limit(int w, int h)
|
||||
{
|
||||
if (U.glreslimit != 0)
|
||||
return (w > U.glreslimit || h > U.glreslimit);
|
||||
int reslimit = (U.glreslimit != 0)?
|
||||
min_ii(U.glreslimit, GPU_max_texture_size()) :
|
||||
GPU_max_texture_size();
|
||||
|
||||
return false;
|
||||
return (w > reslimit || h > reslimit);
|
||||
}
|
||||
|
||||
static int smaller_power_of_2_limit(int num)
|
||||
{
|
||||
int reslimit = (U.glreslimit != 0)?
|
||||
min_ii(U.glreslimit, GPU_max_texture_size()) :
|
||||
GPU_max_texture_size();
|
||||
/* take texture clamping into account */
|
||||
if (U.glreslimit != 0 && num > U.glreslimit)
|
||||
return U.glreslimit;
|
||||
if (num > reslimit)
|
||||
return reslimit;
|
||||
|
||||
return power_of_2_min_i(num);
|
||||
}
|
||||
|
||||
@@ -79,6 +79,7 @@ typedef struct GPUShaders {
|
||||
} GPUShaders;
|
||||
|
||||
static struct GPUGlobal {
|
||||
GLint maxtexsize;
|
||||
GLint maxtextures;
|
||||
GLuint currentfb;
|
||||
int glslsupport;
|
||||
@@ -107,6 +108,11 @@ void GPU_extensions_disable(void)
|
||||
GG.extdisabled = 1;
|
||||
}
|
||||
|
||||
int GPU_max_texture_size ()
|
||||
{
|
||||
return GG.maxtexsize;
|
||||
}
|
||||
|
||||
void GPU_extensions_init(void)
|
||||
{
|
||||
GLint r, g, b;
|
||||
@@ -124,6 +130,8 @@ void GPU_extensions_init(void)
|
||||
if (GLEW_ARB_multitexture)
|
||||
glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS_ARB, &GG.maxtextures);
|
||||
|
||||
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &GG.maxtexsize);
|
||||
|
||||
GG.glslsupport = 1;
|
||||
if (!GLEW_ARB_multitexture) GG.glslsupport = 0;
|
||||
if (!GLEW_ARB_vertex_shader) GG.glslsupport = 0;
|
||||
|
||||
Reference in New Issue
Block a user