aboutsummaryrefslogtreecommitdiff
path: root/backends/graphics/opengl/gltexture.cpp
diff options
context:
space:
mode:
authorAlejandro Marzini2010-07-22 15:36:50 +0000
committerAlejandro Marzini2010-07-22 15:36:50 +0000
commitef880dd5daa205aefd425dae5dcf32e94d1f6723 (patch)
tree7480b67f3e88c63970b9b2dd2dba0c00f835a205 /backends/graphics/opengl/gltexture.cpp
parent0c2d90f090ab439d3b53ca6aaab5027d527716ba (diff)
downloadscummvm-rg350-ef880dd5daa205aefd425dae5dcf32e94d1f6723.tar.gz
scummvm-rg350-ef880dd5daa205aefd425dae5dcf32e94d1f6723.tar.bz2
scummvm-rg350-ef880dd5daa205aefd425dae5dcf32e94d1f6723.zip
OPENGL: Add antialiasing, hotkey: ctrl+alt+f. Fixed minor bugs.
svn-id: r51146
Diffstat (limited to 'backends/graphics/opengl/gltexture.cpp')
-rw-r--r--backends/graphics/opengl/gltexture.cpp15
1 files changed, 10 insertions, 5 deletions
diff --git a/backends/graphics/opengl/gltexture.cpp b/backends/graphics/opengl/gltexture.cpp
index bd2d67edf5..c5dc2f2507 100644
--- a/backends/graphics/opengl/gltexture.cpp
+++ b/backends/graphics/opengl/gltexture.cpp
@@ -80,7 +80,8 @@ GLTexture::GLTexture(byte bpp, GLenum format, GLenum type)
_textureHeight(0),
_realWidth(0),
_realHeight(0),
- _refresh(false) {
+ _refresh(false),
+ _filter(GL_NEAREST) {
// Generates the texture ID for GL
glGenTextures(1, &_textureName); CHECK_GL_ERROR();
@@ -122,8 +123,8 @@ void GLTexture::allocBuffer(GLuint w, GLuint h) {
// Allocate room for the texture now, but pixel data gets uploaded
// later (perhaps with multiple TexSubImage2D operations).
glBindTexture(GL_TEXTURE_2D, _textureName); CHECK_GL_ERROR();
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); CHECK_GL_ERROR();
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); CHECK_GL_ERROR();
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, _filter); CHECK_GL_ERROR();
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, _filter); CHECK_GL_ERROR();
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); CHECK_GL_ERROR();
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); CHECK_GL_ERROR();
glTexImage2D(GL_TEXTURE_2D, 0, _glFormat,
@@ -131,6 +132,8 @@ void GLTexture::allocBuffer(GLuint w, GLuint h) {
if (_surface.w != _textureWidth || _surface.h != _textureHeight)
_surface.create(_textureWidth, _textureHeight, _bytesPerPixel);
+ else if (_refresh)
+ updateBuffer(_surface.pixels, _surface.pitch, 0, 0, _surface.w, _surface.h);
_refresh = false;
}
@@ -141,13 +144,15 @@ void GLTexture::updateBuffer(const void *buf, int pitch, GLuint x, GLuint y, GLu
if (static_cast<int>(w) * _bytesPerPixel == pitch) {
glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, w, h,
_glFormat, _glType, buf); CHECK_GL_ERROR();
- memcpy(_surface.getBasePtr(x, y), buf, h * pitch);
+ if (buf != _surface.pixels)
+ memcpy(_surface.getBasePtr(x, y), buf, h * pitch);
} else {
const byte* src = static_cast<const byte*>(buf);
do {
glTexSubImage2D(GL_TEXTURE_2D, 0, x, y,
w, 1, _glFormat, _glType, src); CHECK_GL_ERROR();
- memcpy(_surface.getBasePtr(x, y), src, w * _bytesPerPixel);
+ if (buf != _surface.pixels)
+ memcpy(_surface.getBasePtr(x, y), src, w * _bytesPerPixel);
++y;
src += pitch;
} while (--h);