aboutsummaryrefslogtreecommitdiff
path: root/backends
diff options
context:
space:
mode:
authorAlejandro Marzini2010-07-16 04:45:47 +0000
committerAlejandro Marzini2010-07-16 04:45:47 +0000
commitcfe85d6b9f1201a6ad3a88f9e97e58af92047264 (patch)
tree3de84a911e1b7a089046577029be13c8c7fb319a /backends
parentfc8b60abda3090e01f3f147f7307bbede1e7de06 (diff)
downloadscummvm-rg350-cfe85d6b9f1201a6ad3a88f9e97e58af92047264.tar.gz
scummvm-rg350-cfe85d6b9f1201a6ad3a88f9e97e58af92047264.tar.bz2
scummvm-rg350-cfe85d6b9f1201a6ad3a88f9e97e58af92047264.zip
Added basic screen drawing (only overlay working).
svn-id: r50930
Diffstat (limited to 'backends')
-rw-r--r--backends/graphics/opengl/gltexture.cpp24
-rw-r--r--backends/graphics/opengl/opengl-graphics.cpp28
-rw-r--r--backends/graphics/openglsdl/openglsdl-graphics.cpp4
3 files changed, 31 insertions, 25 deletions
diff --git a/backends/graphics/opengl/gltexture.cpp b/backends/graphics/opengl/gltexture.cpp
index d609dd612f..eada261ca2 100644
--- a/backends/graphics/opengl/gltexture.cpp
+++ b/backends/graphics/opengl/gltexture.cpp
@@ -78,7 +78,8 @@ GLTexture::GLTexture(byte bpp, GLenum format, GLenum type)
_textureWidth(0),
_textureHeight(0) {
- refresh();
+ // Generates the texture ID for GL
+ CHECK_GL_ERROR( glGenTextures(1, &_textureName) );
// This all gets reset later in allocBuffer:
_surface.w = 0;
@@ -108,12 +109,6 @@ void GLTexture::allocBuffer(GLuint w, GLuint h) {
// Already allocated a sufficiently large buffer
return;
- nextHigher2(0);
- nextHigher2(100);
- nextHigher2(1025);
- nextHigher2(9999);
-
-
if (npot_supported) {
_textureWidth = w;
_textureHeight = h;
@@ -160,7 +155,7 @@ void GLTexture::updateBuffer(const void *buf, int pitch, GLuint x, GLuint y, GLu
void GLTexture::fillBuffer(byte x) {
byte* tmpbuf = new byte[_surface.h * _surface.w * _bytesPerPixel];
- memset(tmpbuf, 0, _surface.h * _surface.w * _bytesPerPixel);
+ memset(tmpbuf, x, _surface.h * _surface.w * _bytesPerPixel);
CHECK_GL_ERROR( glBindTexture(GL_TEXTURE_2D, _textureName) );
CHECK_GL_ERROR( glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, _surface.w, _surface.h,
_glFormat, _glType, tmpbuf) );
@@ -170,13 +165,13 @@ 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 tex_width = xdiv(_surface.w, _textureWidth);
- const GLint tex_height = xdiv(_surface.h, _textureHeight);
+ const GLint texWidth = 1;//xdiv(_surface.w, _textureWidth);
+ const GLint texHeight = 1;//xdiv(_surface.h, _textureHeight);
const GLint texcoords[] = {
0, 0,
- tex_width, 0,
- 0, tex_height,
- tex_width, tex_height,
+ texWidth, 0,
+ 0, texHeight,
+ texWidth, texHeight,
};
CHECK_GL_ERROR( glTexCoordPointer(2, GL_INT, 0, texcoords) );
@@ -188,8 +183,7 @@ void GLTexture::drawTexture(GLshort x, GLshort y, GLshort w, GLshort h) {
};
CHECK_GL_ERROR( glVertexPointer(2, GL_SHORT, 0, vertices) );
- assert(ARRAYSIZE(vertices) == ARRAYSIZE(texcoords));
- CHECK_GL_ERROR( glDrawArrays(GL_TRIANGLE_STRIP, 0, ARRAYSIZE(vertices) / 2) );
+ CHECK_GL_ERROR( glDrawArrays(GL_TRIANGLE_STRIP, 0, 4) );
}
#endif
diff --git a/backends/graphics/opengl/opengl-graphics.cpp b/backends/graphics/opengl/opengl-graphics.cpp
index 49589ead30..57a558a11b 100644
--- a/backends/graphics/opengl/opengl-graphics.cpp
+++ b/backends/graphics/opengl/opengl-graphics.cpp
@@ -408,43 +408,48 @@ void OpenGLGraphicsManager::displayMessageOnOSD(const char *msg) {
// Intern
//
-void OpenGLGraphicsManager::getGLPixelFormat(Graphics::PixelFormat pixelFormat, byte &bpp, GLenum &glFormat, GLenum &type) {
+void OpenGLGraphicsManager::getGLPixelFormat(Graphics::PixelFormat pixelFormat, byte &bpp, GLenum &glFormat, GLenum &gltype) {
if (pixelFormat == Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0)) { // RGBA8888
bpp = 4;
glFormat = GL_RGBA;
- type = GL_UNSIGNED_BYTE;
+ gltype = GL_UNSIGNED_BYTE;
} else if (pixelFormat == Graphics::PixelFormat(3, 8, 8, 8, 0, 16, 8, 0, 0)) { // RGB888
bpp = 3;
glFormat = GL_RGB;
- type = GL_UNSIGNED_BYTE;
+ gltype = GL_UNSIGNED_BYTE;
} else if (pixelFormat == Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0)) { // RGB565
bpp = 2;
glFormat = GL_RGB;
- type = GL_UNSIGNED_SHORT_5_6_5;
+ gltype = GL_UNSIGNED_SHORT_5_6_5;
} else if (pixelFormat == Graphics::PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0)) { // RGB555
bpp = 2;
glFormat = GL_RGB;
- type = GL_UNSIGNED_SHORT_5_5_5_1;
+ gltype = GL_UNSIGNED_SHORT_5_5_5_1;
} else if (pixelFormat == Graphics::PixelFormat(2, 4, 4, 4, 4, 12, 8, 4, 0)) { // RGBA4444
bpp = 2;
glFormat = GL_RGBA;
- type = GL_UNSIGNED_SHORT_4_4_4_4;
+ gltype = GL_UNSIGNED_SHORT_4_4_4_4;
} else if (pixelFormat == Graphics::PixelFormat::createFormatCLUT8()) { // CLUT8
bpp = 1;
- glFormat = GL_RGB;
- type = GL_COLOR_INDEX;
+ glFormat = GL_COLOR_INDEX;
+ gltype = GL_UNSIGNED_BYTE;
} else {
error("Not supported format");
}
}
void OpenGLGraphicsManager::internUpdateScreen() {
-
+ glClear( GL_COLOR_BUFFER_BIT );
+ _gameTexture->drawTexture(0, 0, _videoMode.hardwareWidth, _videoMode.hardwareHeight);
+ _overlayTexture->drawTexture(0, 0, _videoMode.hardwareWidth, _videoMode.hardwareHeight);
+ _mouseTexture->drawTexture(_mouseCurState.x, _mouseCurState.y, _mouseCurState.w, _mouseCurState.h);
}
bool OpenGLGraphicsManager::loadGFXMode() {
+ // Check available GL Extensions
GLTexture::initGLExtensions();
+ // Disable 3D properties
glDisable(GL_CULL_FACE);
glDisable(GL_DEPTH_TEST);
glDisable(GL_LIGHTING);
@@ -478,6 +483,8 @@ bool OpenGLGraphicsManager::loadGFXMode() {
} else
_gameTexture->refresh();
+ _overlayFormat = Graphics::PixelFormat(2, 4, 4, 4, 4, 12, 8, 4, 0);
+
if (!_overlayTexture)
_overlayTexture = new GLTexture(2, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4);
else
@@ -490,6 +497,9 @@ bool OpenGLGraphicsManager::loadGFXMode() {
_gameTexture->allocBuffer(_videoMode.screenWidth, _videoMode.screenHeight);
_overlayTexture->allocBuffer(_videoMode.overlayWidth, _videoMode.overlayHeight);
+ _mouseTexture->allocBuffer(16, 16);
+
+ internUpdateScreen();
return true;
}
diff --git a/backends/graphics/openglsdl/openglsdl-graphics.cpp b/backends/graphics/openglsdl/openglsdl-graphics.cpp
index aaa7ac7dd0..7abb4feb44 100644
--- a/backends/graphics/openglsdl/openglsdl-graphics.cpp
+++ b/backends/graphics/openglsdl/openglsdl-graphics.cpp
@@ -157,7 +157,9 @@ bool OpenGLSdlGraphicsManager::hotswapGFXMode() {
}
void OpenGLSdlGraphicsManager::internUpdateScreen() {
-
+ OpenGLGraphicsManager::internUpdateScreen();
+
+ SDL_GL_SwapBuffers();
}
#endif