mirror of
https://github.com/isledecomp/isle-portable.git
synced 2025-09-22 11:31:57 -04:00
OpenGL: Respect max supported texture size (#518)
This commit is contained in:
parent
5e62e7e39f
commit
4983da422c
@ -42,6 +42,13 @@ void GL11_DestroyTexture(GLuint texId)
|
||||
glDeleteTextures(1, &texId);
|
||||
}
|
||||
|
||||
int GL11_GetMaxTextureSize()
|
||||
{
|
||||
GLint maxTextureSize = 0;
|
||||
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTextureSize);
|
||||
return maxTextureSize;
|
||||
}
|
||||
|
||||
GLuint GL11_UploadTextureData(void* pixels, int width, int height, bool isUi)
|
||||
{
|
||||
GLuint texId;
|
||||
|
@ -64,6 +64,7 @@ struct GLMeshCacheEntry {
|
||||
void GL11_InitState();
|
||||
void GL11_LoadExtensions();
|
||||
void GL11_DestroyTexture(GLuint texId);
|
||||
int GL11_GetMaxTextureSize();
|
||||
GLuint GL11_UploadTextureData(void* pixels, int width, int height, bool isUI);
|
||||
void GL11_UploadMesh(GLMeshCacheEntry& cache, bool hasTexture);
|
||||
void GL11_DestroyMesh(GLMeshCacheEntry& cache);
|
||||
|
@ -132,10 +132,21 @@ static Uint32 UploadTextureData(SDL_Surface* src, bool useNPOT, bool isUi)
|
||||
|
||||
SDL_Surface* finalSurface = working;
|
||||
|
||||
int newW = NextPowerOfTwo(working->w);
|
||||
int newH = NextPowerOfTwo(working->h);
|
||||
int newW = working->w;
|
||||
int newH = working->h;
|
||||
if (!useNPOT) {
|
||||
newW = NextPowerOfTwo(newW);
|
||||
newH = NextPowerOfTwo(newH);
|
||||
}
|
||||
int max = GL11_GetMaxTextureSize();
|
||||
if (newW > max) {
|
||||
newW = max;
|
||||
}
|
||||
if (newH > max) {
|
||||
newH = max;
|
||||
}
|
||||
|
||||
if (!useNPOT && (newW != working->w || newH != working->h)) {
|
||||
if (newW != working->w || newH != working->h) {
|
||||
SDL_Surface* resized = SDL_CreateSurface(newW, newH, working->format);
|
||||
if (!resized) {
|
||||
SDL_Log("SDL_CreateSurface (resize) failed: %s", SDL_GetError());
|
||||
|
Loading…
x
Reference in New Issue
Block a user