changeset 669:46258f467c8c

* Fixed the clear screen problems. The screen is now automatically cleared every frame by the engine if there are no maps loaded. In the process I removed the setClearBackBuffer() function from the RenderBackend.
author prock@33b003aa-7bff-0310-803a-e67f0ece8222
date Mon, 08 Nov 2010 21:36:38 +0000
parents e8a799239384
children 0ac1056c8253
files demos/rpg/scripts/rpg.py demos/shooter/run.py engine/core/controller/engine.cpp engine/core/video/opengl/renderbackendopengl.cpp engine/core/video/renderbackend.cpp engine/core/video/renderbackend.h engine/core/video/sdl/renderbackendsdl.cpp engine/core/video/video.i engine/core/view/camera.cpp tools/editor/scripts/editor.py
diffstat 10 files changed, 8 insertions(+), 26 deletions(-) [+]
line wrap: on
line diff
--- a/demos/rpg/scripts/rpg.py	Mon Nov 08 20:37:31 2010 +0000
+++ b/demos/rpg/scripts/rpg.py	Mon Nov 08 21:36:38 2010 +0000
@@ -148,8 +148,6 @@
 		super(RPGApplication,self).__init__(TDS)
 		self._settings = TDS
 		
-		self.engine.getRenderBackend().setClearBackBuffer(True)
-		
 		self._gamecontroller = GameController(self, self.engine, self._settings)
 
 	def createListener(self):
--- a/demos/shooter/run.py	Mon Nov 08 20:37:31 2010 +0000
+++ b/demos/shooter/run.py	Mon Nov 08 21:36:38 2010 +0000
@@ -73,8 +73,6 @@
 		
 		self._world = world.World(self, self.engine, self._setting)
 		self._listener = ApplicationListener(self.engine, self._world)
-		
-		self.engine.getRenderBackend().setClearBackBuffer(True)
 
 	def requestQuit(self):
 		cmd = fife.Command()
--- a/engine/core/controller/engine.cpp	Mon Nov 08 20:37:31 2010 +0000
+++ b/engine/core/controller/engine.cpp	Mon Nov 08 21:36:38 2010 +0000
@@ -363,6 +363,11 @@
 		m_eventmanager->processEvents();
 		m_renderbackend->startFrame();
 		m_timemanager->update();
+
+		if (m_model->getNumMaps() == 0) {
+			m_renderbackend->clearBackBuffer();
+		}
+
 		m_model->update();
 #ifdef HAVE_OPENGL
 		if (m_settings.getLightingModel() == 1) {
--- a/engine/core/video/opengl/renderbackendopengl.cpp	Mon Nov 08 20:37:31 2010 +0000
+++ b/engine/core/video/opengl/renderbackendopengl.cpp	Mon Nov 08 21:36:38 2010 +0000
@@ -47,7 +47,6 @@
 
 		m_rgba_format = *(testsurface->format);
 		SDL_FreeSurface(testsurface);
-		m_clear = false;
 		m_lightmodel = 0;
 		m_light_enabled = false;
 		m_stencil_enabled = false;
@@ -162,9 +161,6 @@
 
 
 	void RenderBackendOpenGL::startFrame() {
-		if(m_clear) {
-			clearBackBuffer();
-		}
 	}
 
 	void RenderBackendOpenGL::endFrame() {
@@ -350,7 +346,7 @@
 		GLenum src_fact;
 		GLenum dst_fact;
 
-		switch(src) { 
+		switch(src) {
 			case 0  : src_fact = GL_ZERO; break;
 			case 1  : src_fact = GL_ONE; break;
 			case 2  : src_fact = GL_DST_COLOR; break;
@@ -363,7 +359,7 @@
 			default : src_fact = GL_DST_COLOR; break;
 		}
 
-		switch(dst) { 
+		switch(dst) {
 			case 0  : dst_fact = GL_ZERO; break;
 			case 1  : dst_fact = GL_ONE; break;
 			case 2  : dst_fact = GL_SRC_COLOR; break;
@@ -480,7 +476,7 @@
 		}
 		for(float angle=0; angle<=Mathf::twoPi(); angle+=(Mathf::twoPi()/subdivisions)){
 			glVertex2f( radius*Mathf::Cos(angle)*xstretch + p.x,
-						radius*Mathf::Sin(angle)*ystretch + p.y);  
+						radius*Mathf::Sin(angle)*ystretch + p.y);
 		}
 		glVertex2f(p.x+radius*xstretch, p.y);
 		glEnd();
--- a/engine/core/video/renderbackend.cpp	Mon Nov 08 20:37:31 2010 +0000
+++ b/engine/core/video/renderbackend.cpp	Mon Nov 08 21:36:38 2010 +0000
@@ -35,7 +35,6 @@
 
 	RenderBackend::RenderBackend(const SDL_Color& colorkey):
 		m_screen(NULL),
-		m_clear(false),
 		m_isalphaoptimized(false),
 		m_iscolorkeyenabled(false),
 		m_colorkey(colorkey) {
--- a/engine/core/video/renderbackend.h	Mon Nov 08 20:37:31 2010 +0000
+++ b/engine/core/video/renderbackend.h	Mon Nov 08 21:36:38 2010 +0000
@@ -219,14 +219,8 @@
 		 */
 		const SDL_Color& getColorKey() const;
 
-		/** Sets if the backbuffer should be cleared before rendering the next frame.
-		 * @param clear true = clear screen before next frame, false = do not clear screen
-		 */
-		void setClearBackBuffer(bool clear) { m_clear = clear; };
-
 	protected:
 		Image* m_screen;
-		bool m_clear;
 		bool m_isalphaoptimized;
 		unsigned int m_chunkingsize;
 		bool m_iscolorkeyenabled;
--- a/engine/core/video/sdl/renderbackendsdl.cpp	Mon Nov 08 20:37:31 2010 +0000
+++ b/engine/core/video/sdl/renderbackendsdl.cpp	Mon Nov 08 21:36:38 2010 +0000
@@ -42,7 +42,6 @@
 	static Logger _log(LM_VIDEO);
 
 	RenderBackendSDL::RenderBackendSDL(const SDL_Color& colorkey) : RenderBackend(colorkey) {
-		m_clear = false;
 	}
 
 
@@ -135,9 +134,6 @@
 	}
 
 	void RenderBackendSDL::startFrame() {
-		if (m_clear) {
-			clearBackBuffer();
-		}
 	}
 
 	void RenderBackendSDL::endFrame() {
--- a/engine/core/video/video.i	Mon Nov 08 20:37:31 2010 +0000
+++ b/engine/core/video/video.i	Mon Nov 08 21:36:38 2010 +0000
@@ -185,7 +185,6 @@
 		bool isColorKeyEnabled() const;
 		void setColorKey(const SDL_Color& colorkey);
 		const SDL_Color& getColorKey() const;
-		void setClearBackBuffer(bool clear);
 	};
 	
 	enum MouseCursorType {
--- a/engine/core/view/camera.cpp	Mon Nov 08 20:37:31 2010 +0000
+++ b/engine/core/view/camera.cpp	Mon Nov 08 21:36:38 2010 +0000
@@ -131,7 +131,6 @@
 			delete r_it->second;
 		}
 		m_renderers.clear();
-		m_renderbackend->setClearBackBuffer(true);
 		delete m_map_observer;
 	}
 
--- a/tools/editor/scripts/editor.py	Mon Nov 08 20:37:31 2010 +0000
+++ b/tools/editor/scripts/editor.py	Mon Nov 08 21:36:38 2010 +0000
@@ -104,8 +104,6 @@
 		ApplicationBase.__init__(self, TDS, *args, **kwargs)
 		MainWindow.__init__(self, *args, **kwargs)
 		
-		self.engine.getRenderBackend().setClearBackBuffer(True)
-		
 	def _initTools(self):
 		""" Initializes tools """
 		self._pluginmanager = plugin.PluginManager(self.getSettings())