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 "shader.h"
 | 
				
			||||||
#include "glstate.h"
 | 
					#include "glstate.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <sigc++/connection.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct PlanePrivate
 | 
					struct PlanePrivate
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	Bitmap *bitmap;
 | 
						Bitmap *bitmap;
 | 
				
			||||||
| 
						 | 
					@ -52,6 +54,8 @@ struct PlanePrivate
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	EtcTemps tmp;
 | 
						EtcTemps tmp;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						sigc::connection prepareCon;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	PlanePrivate()
 | 
						PlanePrivate()
 | 
				
			||||||
	    : bitmap(0),
 | 
						    : bitmap(0),
 | 
				
			||||||
	      opacity(255),
 | 
						      opacity(255),
 | 
				
			||||||
| 
						 | 
					@ -61,7 +65,15 @@ struct PlanePrivate
 | 
				
			||||||
	      ox(0), oy(0),
 | 
						      ox(0), oy(0),
 | 
				
			||||||
	      zoomX(1), zoomY(1),
 | 
						      zoomX(1), zoomY(1),
 | 
				
			||||||
	      quadSourceDirty(false)
 | 
						      quadSourceDirty(false)
 | 
				
			||||||
	{}
 | 
						{
 | 
				
			||||||
 | 
							prepareCon = shState->prepareDraw.connect
 | 
				
			||||||
 | 
							        (sigc::mem_fun(this, &PlanePrivate::prepare));
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						~PlanePrivate()
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							prepareCon.disconnect();
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	void updateQuadSource()
 | 
						void updateQuadSource()
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
| 
						 | 
					@ -73,6 +85,18 @@ struct PlanePrivate
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		quad.setTexRect(srcRect);
 | 
							quad.setTexRect(srcRect);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						void prepare()
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							if (quadSourceDirty)
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								updateQuadSource();
 | 
				
			||||||
 | 
								quadSourceDirty = false;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if (bitmap)
 | 
				
			||||||
 | 
								bitmap->flush();
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Plane::Plane(Viewport *viewport)
 | 
					Plane::Plane(Viewport *viewport)
 | 
				
			||||||
| 
						 | 
					@ -176,12 +200,6 @@ void Plane::draw()
 | 
				
			||||||
	if (!p->opacity)
 | 
						if (!p->opacity)
 | 
				
			||||||
		return;
 | 
							return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (p->quadSourceDirty)
 | 
					 | 
				
			||||||
	{
 | 
					 | 
				
			||||||
		p->updateQuadSource();
 | 
					 | 
				
			||||||
		p->quadSourceDirty = false;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	ShaderBase *base;
 | 
						ShaderBase *base;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (p->color->hasEffect() || p->tone->hasEffect() || p->opacity != 255)
 | 
						if (p->color->hasEffect() || p->tone->hasEffect() || p->opacity != 255)
 | 
				
			||||||
| 
						 | 
					@ -210,7 +228,6 @@ void Plane::draw()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	glState.blendMode.pushSet(p->blendType);
 | 
						glState.blendMode.pushSet(p->blendType);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	p->bitmap->flush();
 | 
					 | 
				
			||||||
	p->bitmap->bindTex(*base);
 | 
						p->bitmap->bindTex(*base);
 | 
				
			||||||
	TEX::setRepeat(true);
 | 
						TEX::setRepeat(true);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -59,6 +59,8 @@ struct SpritePrivate
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	EtcTemps tmp;
 | 
						EtcTemps tmp;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						sigc::connection prepareCon;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	SpritePrivate()
 | 
						SpritePrivate()
 | 
				
			||||||
	    : bitmap(0),
 | 
						    : bitmap(0),
 | 
				
			||||||
	      srcRect(&tmp.rect),
 | 
						      srcRect(&tmp.rect),
 | 
				
			||||||
| 
						 | 
					@ -73,11 +75,15 @@ struct SpritePrivate
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		updateSrcRectCon();
 | 
							updateSrcRectCon();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							prepareCon = shState->prepareDraw.connect
 | 
				
			||||||
 | 
							        (sigc::mem_fun(this, &SpritePrivate::prepare));
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	~SpritePrivate()
 | 
						~SpritePrivate()
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		srcRectCon.disconnect();
 | 
							srcRectCon.disconnect();
 | 
				
			||||||
 | 
							prepareCon.disconnect();
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	void recomputeBushDepth()
 | 
						void recomputeBushDepth()
 | 
				
			||||||
| 
						 | 
					@ -112,6 +118,12 @@ struct SpritePrivate
 | 
				
			||||||
		srcRectCon = srcRect->valueChanged.connect
 | 
							srcRectCon = srcRect->valueChanged.connect
 | 
				
			||||||
				(sigc::mem_fun(this, &SpritePrivate::onSrcRectChange));
 | 
									(sigc::mem_fun(this, &SpritePrivate::onSrcRectChange));
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						void prepare()
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							if (bitmap)
 | 
				
			||||||
 | 
								bitmap->flush();
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Sprite::Sprite(Viewport *viewport)
 | 
					Sprite::Sprite(Viewport *viewport)
 | 
				
			||||||
| 
						 | 
					@ -313,8 +325,6 @@ void Sprite::draw()
 | 
				
			||||||
	if (emptyFlashFlag)
 | 
						if (emptyFlashFlag)
 | 
				
			||||||
		return;
 | 
							return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	p->bitmap->flush();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	ShaderBase *base;
 | 
						ShaderBase *base;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	bool renderEffect = p->color->hasEffect() ||
 | 
						bool renderEffect = p->color->hasEffect() ||
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue