Plane, Sprite: Fix Bitmap flushes in draw handler
Comparing the current SceneElement classes to the earlier written documentation actually immediatelly exposed some bugs. Yay! :D
This commit is contained in:
		
							parent
							
								
									52dd1dbe2f
								
							
						
					
					
						commit
						82e2901726
					
				
					 2 changed files with 37 additions and 10 deletions
				
			
		| 
						 | 
				
			
			@ -33,6 +33,8 @@
 | 
			
		|||
#include "shader.h"
 | 
			
		||||
#include "glstate.h"
 | 
			
		||||
 | 
			
		||||
#include <sigc++/connection.h>
 | 
			
		||||
 | 
			
		||||
struct PlanePrivate
 | 
			
		||||
{
 | 
			
		||||
	Bitmap *bitmap;
 | 
			
		||||
| 
						 | 
				
			
			@ -52,6 +54,8 @@ struct PlanePrivate
 | 
			
		|||
 | 
			
		||||
	EtcTemps tmp;
 | 
			
		||||
 | 
			
		||||
	sigc::connection prepareCon;
 | 
			
		||||
 | 
			
		||||
	PlanePrivate()
 | 
			
		||||
	    : bitmap(0),
 | 
			
		||||
	      opacity(255),
 | 
			
		||||
| 
						 | 
				
			
			@ -61,7 +65,15 @@ struct PlanePrivate
 | 
			
		|||
	      ox(0), oy(0),
 | 
			
		||||
	      zoomX(1), zoomY(1),
 | 
			
		||||
	      quadSourceDirty(false)
 | 
			
		||||
	{}
 | 
			
		||||
	{
 | 
			
		||||
		prepareCon = shState->prepareDraw.connect
 | 
			
		||||
		        (sigc::mem_fun(this, &PlanePrivate::prepare));
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	~PlanePrivate()
 | 
			
		||||
	{
 | 
			
		||||
		prepareCon.disconnect();
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	void updateQuadSource()
 | 
			
		||||
	{
 | 
			
		||||
| 
						 | 
				
			
			@ -73,6 +85,18 @@ struct PlanePrivate
 | 
			
		|||
 | 
			
		||||
		quad.setTexRect(srcRect);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	void prepare()
 | 
			
		||||
	{
 | 
			
		||||
		if (quadSourceDirty)
 | 
			
		||||
		{
 | 
			
		||||
			updateQuadSource();
 | 
			
		||||
			quadSourceDirty = false;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if (bitmap)
 | 
			
		||||
			bitmap->flush();
 | 
			
		||||
	}
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
Plane::Plane(Viewport *viewport)
 | 
			
		||||
| 
						 | 
				
			
			@ -176,12 +200,6 @@ void Plane::draw()
 | 
			
		|||
	if (!p->opacity)
 | 
			
		||||
		return;
 | 
			
		||||
 | 
			
		||||
	if (p->quadSourceDirty)
 | 
			
		||||
	{
 | 
			
		||||
		p->updateQuadSource();
 | 
			
		||||
		p->quadSourceDirty = false;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	ShaderBase *base;
 | 
			
		||||
 | 
			
		||||
	if (p->color->hasEffect() || p->tone->hasEffect() || p->opacity != 255)
 | 
			
		||||
| 
						 | 
				
			
			@ -210,7 +228,6 @@ void Plane::draw()
 | 
			
		|||
 | 
			
		||||
	glState.blendMode.pushSet(p->blendType);
 | 
			
		||||
 | 
			
		||||
	p->bitmap->flush();
 | 
			
		||||
	p->bitmap->bindTex(*base);
 | 
			
		||||
	TEX::setRepeat(true);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -59,6 +59,8 @@ struct SpritePrivate
 | 
			
		|||
 | 
			
		||||
	EtcTemps tmp;
 | 
			
		||||
 | 
			
		||||
	sigc::connection prepareCon;
 | 
			
		||||
 | 
			
		||||
	SpritePrivate()
 | 
			
		||||
	    : bitmap(0),
 | 
			
		||||
	      srcRect(&tmp.rect),
 | 
			
		||||
| 
						 | 
				
			
			@ -73,11 +75,15 @@ struct SpritePrivate
 | 
			
		|||
 | 
			
		||||
	{
 | 
			
		||||
		updateSrcRectCon();
 | 
			
		||||
 | 
			
		||||
		prepareCon = shState->prepareDraw.connect
 | 
			
		||||
		        (sigc::mem_fun(this, &SpritePrivate::prepare));
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	~SpritePrivate()
 | 
			
		||||
	{
 | 
			
		||||
		srcRectCon.disconnect();
 | 
			
		||||
		prepareCon.disconnect();
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	void recomputeBushDepth()
 | 
			
		||||
| 
						 | 
				
			
			@ -112,6 +118,12 @@ struct SpritePrivate
 | 
			
		|||
		srcRectCon = srcRect->valueChanged.connect
 | 
			
		||||
				(sigc::mem_fun(this, &SpritePrivate::onSrcRectChange));
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	void prepare()
 | 
			
		||||
	{
 | 
			
		||||
		if (bitmap)
 | 
			
		||||
			bitmap->flush();
 | 
			
		||||
	}
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
Sprite::Sprite(Viewport *viewport)
 | 
			
		||||
| 
						 | 
				
			
			@ -313,8 +325,6 @@ void Sprite::draw()
 | 
			
		|||
	if (emptyFlashFlag)
 | 
			
		||||
		return;
 | 
			
		||||
 | 
			
		||||
	p->bitmap->flush();
 | 
			
		||||
 | 
			
		||||
	ShaderBase *base;
 | 
			
		||||
 | 
			
		||||
	bool renderEffect = p->color->hasEffect() ||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue