aboutsummaryrefslogtreecommitdiff
path: root/backends/graphics/opengl/gltexture.cpp
diff options
context:
space:
mode:
authorAlejandro Marzini2010-07-23 06:57:23 +0000
committerAlejandro Marzini2010-07-23 06:57:23 +0000
commitbbdb87a83151e1fdf6770523f0a90fe825e88965 (patch)
treef138be84ddd577f713151caa3c71de6742f23a62 /backends/graphics/opengl/gltexture.cpp
parentef880dd5daa205aefd425dae5dcf32e94d1f6723 (diff)
downloadscummvm-rg350-bbdb87a83151e1fdf6770523f0a90fe825e88965.tar.gz
scummvm-rg350-bbdb87a83151e1fdf6770523f0a90fe825e88965.tar.bz2
scummvm-rg350-bbdb87a83151e1fdf6770523f0a90fe825e88965.zip
OPENGL: Add basic game screen drawing. Changed Overlay PixelFormat to RGBA5551.
svn-id: r51193
Diffstat (limited to 'backends/graphics/opengl/gltexture.cpp')
-rw-r--r--backends/graphics/opengl/gltexture.cpp19
1 files changed, 15 insertions, 4 deletions
diff --git a/backends/graphics/opengl/gltexture.cpp b/backends/graphics/opengl/gltexture.cpp
index c5dc2f2507..98291edfac 100644
--- a/backends/graphics/opengl/gltexture.cpp
+++ b/backends/graphics/opengl/gltexture.cpp
@@ -104,6 +104,10 @@ void GLTexture::refresh() {
_refresh = true;
}
+void GLTexture::refreshBuffer() {
+ updateBuffer(_surface.pixels, _surface.pitch, 0, 0, _surface.w, _surface.h);
+}
+
void GLTexture::allocBuffer(GLuint w, GLuint h) {
_realWidth = w;
_realHeight = h;
@@ -133,7 +137,7 @@ 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);
+ refreshBuffer();
_refresh = false;
}
@@ -147,7 +151,7 @@ void GLTexture::updateBuffer(const void *buf, int pitch, GLuint x, GLuint y, GLu
if (buf != _surface.pixels)
memcpy(_surface.getBasePtr(x, y), buf, h * pitch);
} else {
- const byte* src = static_cast<const byte*>(buf);
+ const byte *src = static_cast<const byte *>(buf);
do {
glTexSubImage2D(GL_TEXTURE_2D, 0, x, y,
w, 1, _glFormat, _glType, src); CHECK_GL_ERROR();
@@ -159,8 +163,15 @@ void GLTexture::updateBuffer(const void *buf, int pitch, GLuint x, GLuint y, GLu
}
}
-void GLTexture::fillBuffer(byte x) {
- memset(_surface.pixels, x, _surface.h * _surface.pitch);
+void GLTexture::fillBuffer(uint32 x) {
+ if (_bytesPerPixel == 1)
+ memset(_surface.pixels, x, _surface.w * _surface.h);
+ else {
+ for (int i = 0; i < _surface.w * _surface.h; i++) {
+ memcpy(_surface.pixels, &x, _bytesPerPixel);
+ }
+ }
+
glBindTexture(GL_TEXTURE_2D, _textureName); CHECK_GL_ERROR();
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, _surface.w, _surface.h,
_glFormat, _glType, _surface.pixels); CHECK_GL_ERROR();