[Scummvm-cvs-logs] SF.net SVN: scummvm:[50930] scummvm/branches/gsoc2010-opengl/backends/ graphics/opengl

vgvgf at users.sourceforge.net vgvgf at users.sourceforge.net
Fri Jul 16 06:45:47 CEST 2010


Revision: 50930
          http://scummvm.svn.sourceforge.net/scummvm/?rev=50930&view=rev
Author:   vgvgf
Date:     2010-07-16 04:45:47 +0000 (Fri, 16 Jul 2010)

Log Message:
-----------
Added basic screen drawing (only overlay working).

Modified Paths:
--------------
    scummvm/branches/gsoc2010-opengl/backends/graphics/opengl/gltexture.cpp
    scummvm/branches/gsoc2010-opengl/backends/graphics/opengl/opengl-graphics.cpp
    scummvm/branches/gsoc2010-opengl/backends/graphics/openglsdl/openglsdl-graphics.cpp

Modified: scummvm/branches/gsoc2010-opengl/backends/graphics/opengl/gltexture.cpp
===================================================================
--- scummvm/branches/gsoc2010-opengl/backends/graphics/opengl/gltexture.cpp	2010-07-16 03:35:44 UTC (rev 50929)
+++ scummvm/branches/gsoc2010-opengl/backends/graphics/opengl/gltexture.cpp	2010-07-16 04:45:47 UTC (rev 50930)
@@ -78,7 +78,8 @@
 	_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 @@
 		// 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::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::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 @@
 	};
 	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

Modified: scummvm/branches/gsoc2010-opengl/backends/graphics/opengl/opengl-graphics.cpp
===================================================================
--- scummvm/branches/gsoc2010-opengl/backends/graphics/opengl/opengl-graphics.cpp	2010-07-16 03:35:44 UTC (rev 50929)
+++ scummvm/branches/gsoc2010-opengl/backends/graphics/opengl/opengl-graphics.cpp	2010-07-16 04:45:47 UTC (rev 50930)
@@ -408,43 +408,48 @@
 // 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 @@
 	} 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,7 +497,10 @@
 
 	_gameTexture->allocBuffer(_videoMode.screenWidth, _videoMode.screenHeight);
 	_overlayTexture->allocBuffer(_videoMode.overlayWidth, _videoMode.overlayHeight);
+	_mouseTexture->allocBuffer(16, 16);
 
+	internUpdateScreen();
+
 	return true;
 }
 

Modified: scummvm/branches/gsoc2010-opengl/backends/graphics/openglsdl/openglsdl-graphics.cpp
===================================================================
--- scummvm/branches/gsoc2010-opengl/backends/graphics/openglsdl/openglsdl-graphics.cpp	2010-07-16 03:35:44 UTC (rev 50929)
+++ scummvm/branches/gsoc2010-opengl/backends/graphics/openglsdl/openglsdl-graphics.cpp	2010-07-16 04:45:47 UTC (rev 50930)
@@ -157,7 +157,9 @@
 }
 
 void OpenGLSdlGraphicsManager::internUpdateScreen() {
-	
+	OpenGLGraphicsManager::internUpdateScreen();
+
+	SDL_GL_SwapBuffers(); 
 }
 
 #endif


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list