[Scummvm-git-logs] scummvm master -> 26a2e738fd5cbeb46ac01a4877e65a63e6c87a76

lephilousophe noreply at scummvm.org
Sat Nov 30 22:36:37 UTC 2024


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
26a2e738fd ANDROID: Fix build after FrameBuffer class changes


Commit: 26a2e738fd5cbeb46ac01a4877e65a63e6c87a76
    https://github.com/scummvm/scummvm/commit/26a2e738fd5cbeb46ac01a4877e65a63e6c87a76
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2024-11-30T23:36:34+01:00

Commit Message:
ANDROID: Fix build after FrameBuffer class changes

Changed paths:
    backends/graphics/android/android-graphics.cpp
    backends/graphics3d/android/android-graphics3d.cpp
    backends/graphics3d/android/android-graphics3d.h
    backends/graphics3d/android/texture.cpp
    backends/graphics3d/android/texture.h
    backends/graphics3d/opengl/framebuffer.h
    graphics/opengl/texture.cpp
    graphics/opengl/texture.h


diff --git a/backends/graphics/android/android-graphics.cpp b/backends/graphics/android/android-graphics.cpp
index 33cb865dced..bf55b62d202 100644
--- a/backends/graphics/android/android-graphics.cpp
+++ b/backends/graphics/android/android-graphics.cpp
@@ -40,6 +40,7 @@
 #include "backends/platform/android/jni-android.h"
 #include "backends/graphics/android/android-graphics.h"
 #include "backends/graphics/opengl/pipelines/pipeline.h"
+#include "backends/graphics/opengl/texture.h"
 
 #include "graphics/blit.h"
 #include "graphics/managed_surface.h"
diff --git a/backends/graphics3d/android/android-graphics3d.cpp b/backends/graphics3d/android/android-graphics3d.cpp
index 4bda2e3a73f..730801bcaf0 100644
--- a/backends/graphics3d/android/android-graphics3d.cpp
+++ b/backends/graphics3d/android/android-graphics3d.cpp
@@ -169,7 +169,9 @@ void AndroidGraphics3dManager::initSurface() {
 		// We had a frame buffer initialized, we must renew it as the game textured got renewed
 		if (_frame_buffer) {
 			delete _frame_buffer;
-			_frame_buffer = new OpenGL::FrameBuffer(_game_texture->getTextureName(),
+			_frame_buffer = new AndroidFrameBuffer(
+						_game_texture->getTextureFormat(), _game_texture->getTextureFormat(),
+						_game_texture->getTextureType(), _game_texture->getTextureName(),
 	                                        _game_texture->width(), _game_texture->height(),
 	                                        _game_texture->texWidth(), _game_texture->texHeight());
 
@@ -727,9 +729,10 @@ void AndroidGraphics3dManager::initSize(uint width, uint height,
 	delete _frame_buffer;
 
 	if (!engineSupportsArbitraryResolutions) {
-		_frame_buffer = new OpenGL::FrameBuffer(_game_texture->getTextureName(),
-		                                        _game_texture->width(), _game_texture->height(),
-		                                        _game_texture->texWidth(), _game_texture->texHeight());
+		_frame_buffer = new AndroidFrameBuffer(_game_texture->getTextureFormat(), _game_texture->getTextureFormat(),
+		                                       _game_texture->getTextureType(), _game_texture->getTextureName(),
+		                                       _game_texture->width(), _game_texture->height(),
+		                                       _game_texture->texWidth(), _game_texture->texHeight());
 		_frame_buffer->attach();
 	}
 
diff --git a/backends/graphics3d/android/android-graphics3d.h b/backends/graphics3d/android/android-graphics3d.h
index 0afe53cb583..007a8ee9279 100644
--- a/backends/graphics3d/android/android-graphics3d.h
+++ b/backends/graphics3d/android/android-graphics3d.h
@@ -26,7 +26,6 @@
 
 #include "backends/graphics/graphics.h"
 #include "backends/graphics/android/android-graphics.h"
-#include "backends/graphics3d/opengl/framebuffer.h"
 #include "backends/graphics3d/android/texture.h"
 
 #include "backends/platform/android/touchcontrols.h"
@@ -162,7 +161,7 @@ private:
 
 	// Game layer
 	GLESTexture *_game_texture;
-	OpenGL::FrameBuffer *_frame_buffer;
+	AndroidFrameBuffer *_frame_buffer;
 
 #ifdef USE_RGB_COLOR
 	// Backup of the previous pixel format to pass it back when we leave 3d
diff --git a/backends/graphics3d/android/texture.cpp b/backends/graphics3d/android/texture.cpp
index 114e0d731fb..43602362a87 100644
--- a/backends/graphics3d/android/texture.cpp
+++ b/backends/graphics3d/android/texture.cpp
@@ -50,6 +50,46 @@
 
 #include "backends/graphics3d/android/texture.h"
 
+
+AndroidFrameBuffer::AndroidFrameBuffer(GLenum glIntFormat, GLenum glFormat, GLenum glType, GLuint texture_name, uint width, uint height, uint texture_width, uint texture_height) :
+		OpenGL::FrameBuffer(glIntFormat, glFormat, glType, false) {
+	if (!OpenGLContext.framebufferObjectSupported) {
+		error("FrameBuffer Objects are not supported by the current OpenGL context");
+	}
+
+	_logicalWidth = width;
+	_logicalHeight = height;
+	_width = texture_width;
+	_height = texture_height;
+	_glTexture = texture_name;
+
+	if (_width != 0 && _height != 0) {
+		const GLfloat texWidth = (GLfloat)_logicalWidth / _width;
+		const GLfloat texHeight = (GLfloat)_logicalHeight / _height;
+
+		_texCoords[0] = 0;
+		_texCoords[1] = 0;
+
+		_texCoords[2] = texWidth;
+		_texCoords[3] = 0;
+
+		_texCoords[4] = 0;
+		_texCoords[5] = texHeight;
+
+		_texCoords[6] = texWidth;
+		_texCoords[7] = texHeight;
+	}
+
+	enableLinearFiltering(true);
+
+	init();
+}
+
+AndroidFrameBuffer::~AndroidFrameBuffer() {
+	// Prevent the texture from being deleted by the parent class
+	_glTexture = 0;
+}
+
 // Supported GL extensions
 bool GLESBaseTexture::_npot_supported = false;
 OpenGL::Shader *GLESBaseTexture::_box_shader = nullptr;
diff --git a/backends/graphics3d/android/texture.h b/backends/graphics3d/android/texture.h
index 49b9384aefd..72d42580bf9 100644
--- a/backends/graphics3d/android/texture.h
+++ b/backends/graphics3d/android/texture.h
@@ -25,6 +25,7 @@
 #define GL_GLEXT_PROTOTYPES
 #include <GLES/gl.h>
 
+#include "backends/graphics3d/opengl/framebuffer.h"
 #include "graphics/surface.h"
 #include "graphics/pixelformat.h"
 
@@ -35,6 +36,12 @@ namespace OpenGL {
 class Shader;
 }
 
+class AndroidFrameBuffer : public OpenGL::FrameBuffer {
+public:
+	AndroidFrameBuffer(GLenum glIntFormat, GLenum glFormat, GLenum glType, GLuint texture_name, uint width, uint height, uint texture_width, uint texture_height);
+	~AndroidFrameBuffer();
+};
+
 class GLESBaseTexture {
 public:
 	static void initGL();
@@ -143,6 +150,14 @@ public:
 		return _texture_name;
 	}
 
+	GLenum getTextureFormat() const {
+		return _glFormat;
+	}
+
+	GLenum getTextureType() const {
+		return _glType;
+	}
+
 	void setGameTexture() {
 		_is_game_texture = true;
 	}
diff --git a/backends/graphics3d/opengl/framebuffer.h b/backends/graphics3d/opengl/framebuffer.h
index d6baf71a935..d46e0a74cf4 100644
--- a/backends/graphics3d/opengl/framebuffer.h
+++ b/backends/graphics3d/opengl/framebuffer.h
@@ -39,10 +39,14 @@ public:
 	virtual void detach();
 
 protected:
+	FrameBuffer(GLenum glIntFormat, GLenum glFormat, GLenum glType, bool autoCreate)
+		: Texture(glIntFormat, glFormat, glType, autoCreate) {}
+
 	GLuint getFrameBufferName() const { return _frameBuffer; }
 
-private:
 	void init();
+
+private:
 	GLuint _renderBuffers[2];
 	GLuint _frameBuffer;
 };
diff --git a/graphics/opengl/texture.cpp b/graphics/opengl/texture.cpp
index 2ce9cde9cdb..bdc834a613e 100644
--- a/graphics/opengl/texture.cpp
+++ b/graphics/opengl/texture.cpp
@@ -33,12 +33,13 @@
 
 namespace OpenGL {
 
-Texture::Texture(GLenum glIntFormat, GLenum glFormat, GLenum glType)
+Texture::Texture(GLenum glIntFormat, GLenum glFormat, GLenum glType, bool autoCreate)
 	: _glIntFormat(glIntFormat), _glFormat(glFormat), _glType(glType),
 	  _width(0), _height(0), _logicalWidth(0), _logicalHeight(0),
 	  _texCoords(), _glFilter(GL_NEAREST),
 	  _glTexture(0) {
-	create();
+	if (autoCreate)
+		create();
 }
 
 Texture::~Texture() {
diff --git a/graphics/opengl/texture.h b/graphics/opengl/texture.h
index 2fb4d2d43f0..f759d90f850 100644
--- a/graphics/opengl/texture.h
+++ b/graphics/opengl/texture.h
@@ -53,7 +53,7 @@ public:
 	 * @param glFormat    The input format.
 	 * @param glType      The input type.
 	 */
-	Texture(GLenum glIntFormat, GLenum glFormat, GLenum glType);
+	Texture(GLenum glIntFormat, GLenum glFormat, GLenum glType, bool autoCreate = true);
 	~Texture();
 
 	/**
@@ -146,7 +146,8 @@ public:
 	GLuint getGLTexture() const { return _glTexture; }
 
 	static const Graphics::PixelFormat getRGBAPixelFormat();
-private:
+
+protected:
 	const GLenum _glIntFormat;
 	const GLenum _glFormat;
 	const GLenum _glType;




More information about the Scummvm-git-logs mailing list