aboutsummaryrefslogtreecommitdiff
path: root/backends
diff options
context:
space:
mode:
authorAlejandro Marzini2010-07-18 05:32:44 +0000
committerAlejandro Marzini2010-07-18 05:32:44 +0000
commit03d66c401214ecc02021b00d42ade314c16e0201 (patch)
tree81dc4e22b60a241098a2c30766892f363c275c48 /backends
parent492569a7a20d17cfac5fedf1eec1876e53a2767c (diff)
downloadscummvm-rg350-03d66c401214ecc02021b00d42ade314c16e0201.tar.gz
scummvm-rg350-03d66c401214ecc02021b00d42ade314c16e0201.tar.bz2
scummvm-rg350-03d66c401214ecc02021b00d42ade314c16e0201.zip
Fixed rect size when drawing npot textures. Added OpenGL attr for SDL.
svn-id: r50979
Diffstat (limited to 'backends')
-rw-r--r--backends/graphics/opengl/gltexture.cpp16
-rw-r--r--backends/graphics/openglsdl/openglsdl-graphics.cpp7
2 files changed, 15 insertions, 8 deletions
diff --git a/backends/graphics/opengl/gltexture.cpp b/backends/graphics/opengl/gltexture.cpp
index 0803c74f9a..70833c4098 100644
--- a/backends/graphics/opengl/gltexture.cpp
+++ b/backends/graphics/opengl/gltexture.cpp
@@ -36,10 +36,10 @@
// Supported GL extensions
static bool npot_supported = false;
-static inline GLint xdiv(int numerator, int denominator) {
+/*static inline GLint xdiv(int numerator, int denominator) {
assert(numerator < (1 << 16));
return (numerator << 16) / denominator;
-}
+}*/
static GLuint nextHigher2(GLuint v) {
if (v == 0)
@@ -61,6 +61,7 @@ void GLTexture::initGLExtensions() {
const char* ext_string =
reinterpret_cast<const char*>(glGetString(GL_EXTENSIONS));
+ CHECK_GL_ERROR(0);
Common::StringTokenizer tokenizer(ext_string, " ");
while (!tokenizer.empty()) {
Common::String token = tokenizer.nextToken();
@@ -128,8 +129,7 @@ void GLTexture::allocBuffer(GLuint w, GLuint h) {
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,
- _textureWidth, _textureHeight,
- 0, _glFormat, _glType, NULL) );
+ _textureWidth, _textureHeight, 0, _glFormat, _glType, NULL) );
}
void GLTexture::updateBuffer(const void *buf, int pitch, GLuint x, GLuint y, GLuint w, GLuint h) {
@@ -165,15 +165,15 @@ void GLTexture::fillBuffer(byte x) {
void GLTexture::drawTexture(GLshort x, GLshort y, GLshort w, GLshort h) {
CHECK_GL_ERROR( glBindTexture(GL_TEXTURE_2D, _textureName) );
- const GLint texWidth = 1;//xdiv(_surface.w, _textureWidth);
- const GLint texHeight = 1;//xdiv(_surface.h, _textureHeight);
- const GLint texcoords[] = {
+ const GLfloat texWidth = (GLfloat)_surface.w / _textureWidth;//xdiv(_surface.w, _textureWidth);
+ const GLfloat texHeight = (GLfloat)_surface.h / _textureHeight;//xdiv(_surface.h, _textureHeight);
+ const GLfloat texcoords[] = {
0, 0,
texWidth, 0,
0, texHeight,
texWidth, texHeight,
};
- CHECK_GL_ERROR( glTexCoordPointer(2, GL_INT, 0, texcoords) );
+ CHECK_GL_ERROR( glTexCoordPointer(2, GL_FLOAT, 0, texcoords) );
const GLshort vertices[] = {
x, y,
diff --git a/backends/graphics/openglsdl/openglsdl-graphics.cpp b/backends/graphics/openglsdl/openglsdl-graphics.cpp
index 98e67d2e78..99468b1447 100644
--- a/backends/graphics/openglsdl/openglsdl-graphics.cpp
+++ b/backends/graphics/openglsdl/openglsdl-graphics.cpp
@@ -127,6 +127,13 @@ bool OpenGLSdlGraphicsManager::loadGFXMode() {
_videoMode.hardwareWidth = _videoMode.screenWidth * _videoMode.scaleFactor;
_videoMode.hardwareHeight = _videoMode.screenHeight * _videoMode.scaleFactor;
+ // Setup OpenGL attributes for SDL
+ SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
+ SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
+ SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
+ SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16);
+ SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
+
_hwscreen = SDL_SetVideoMode(_videoMode.hardwareWidth, _videoMode.hardwareHeight, 32,
_videoMode.fullscreen ? (SDL_FULLSCREEN | SDL_OPENGL) : SDL_OPENGL
);