GRAPHICS: Use NPoT textures if supported
This commit is contained in:
parent
ae4601c303
commit
e6ba906656
1 changed files with 17 additions and 4 deletions
|
@ -25,6 +25,7 @@
|
|||
#if defined(USE_OPENGL)
|
||||
|
||||
#include "graphics/opengl/texture.h"
|
||||
#include "graphics/opengl/extensions.h"
|
||||
|
||||
|
||||
namespace Graphics {
|
||||
|
@ -50,8 +51,14 @@ static const Graphics::PixelFormat getRGBAPixelFormat() {
|
|||
}
|
||||
|
||||
Texture::Texture(const Surface &srf) :
|
||||
_managedTexture(true), _width(srf.w), _height(srf.h),
|
||||
_texWidth(nextHigher2(_width)), _texHeight(nextHigher2(_height)) {
|
||||
_managedTexture(true), _width(srf.w), _height(srf.h) {
|
||||
if (Graphics::isExtensionSupported("GL_ARB_texture_non_power_of_two")) {
|
||||
_texWidth = _width;
|
||||
_texHeight = _height;
|
||||
} else {
|
||||
_texWidth = nextHigher2(_width);
|
||||
_texHeight = nextHigher2(_height);
|
||||
}
|
||||
glGenTextures(1, &_texture);
|
||||
glBindTexture(GL_TEXTURE_2D, _texture);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||
|
@ -72,8 +79,14 @@ Texture::Texture(const Surface &srf) :
|
|||
}
|
||||
|
||||
Texture::Texture(uint width, uint height) :
|
||||
_managedTexture(true), _width(width), _height(height),
|
||||
_texWidth(nextHigher2(width)), _texHeight(nextHigher2(height)) {
|
||||
_managedTexture(true), _width(width), _height(height) {
|
||||
if (Graphics::isExtensionSupported("GL_ARB_texture_non_power_of_two")) {
|
||||
_texWidth = _width;
|
||||
_texHeight = _height;
|
||||
} else {
|
||||
_texWidth = nextHigher2(_width);
|
||||
_texHeight = nextHigher2(_height);
|
||||
}
|
||||
glGenTextures(1, &_texture);
|
||||
glBindTexture(GL_TEXTURE_2D, _texture);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue