EMT_TRANSPARENT_ALPHA_CHANNEL Problem in V0.7

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
zola
Posts: 52
Joined: Thu Jul 15, 2004 2:31 pm
Location: switzerland
Contact:

Post by zola »

@Tyn
I hope this wasn't a test :)

The problem is the following:
1 ) in Your test app insert the line guiEnv->drawAll(); (ok that's not the only problem :wink: )
2 ) You use IGUIImage if You take a look in the sources this class does only render solid textures! Most of all no alpha values are applied. I think there was a patch for this in irr 0.6 but this patch did something with the setRenderStates2DMode call in draw2DImage (which shouldn't be done imho)

This is what i think should be done:

add a flag to IGUIImage that triggers if alphablending or solid rendering should be used and use the flag in CGUIImage.cpp

IGUIImage.h

Code: Select all

// Copyright (C) 2002-2004 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in Irrlicht.h
 
#ifndef __I_GUI_IMAGE_H_INCLUDED__
#define __I_GUI_IMAGE_H_INCLUDED__

#include "IGUIElement.h"
#include "ITexture.h"
#include "SColor.h"

namespace irr
{
namespace gui
{

	//! GUI element displaying an image.
	class IGUIImage : public IGUIElement
	{
	protected:
		
		bool alphablend;
		
		video::SColor image_color;

	public:

		//! constructor
		IGUIImage(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect<s32> rectangle)
			: IGUIElement(environment, parent, id, rectangle) 
		{
			image_color=video::SColor(255,255,255,255);
			alphablend=false;
		}

		//! destructor
		~IGUIImage() {};

		//! sets an image
		virtual void setImage(video::ITexture* image) = 0;

		// set alphablending for the gui image
		virtual void setAlphaBlend(bool enable)
		{
			alphablend=enable;
		}

		// set color for the gui image
		virtual void setColor(const video::SColor& c)
		{
			image_color=c;
		}


	};


} // end namespace gui
} // end namespace irr

#endif


CGUIImage.cpp

Code: Select all

//! draws the element and its children
void CGUIImage::draw()
{
	if (!IsVisible)
		return;

	IGUISkin* skin = Environment->getSkin();
	irr::video::IVideoDriver* driver = Environment->getVideoDriver();

	core::rect<s32> rect = AbsoluteRect;

	if (Texture)
	{
		driver->draw2DImage(Texture, AbsoluteRect.UpperLeftCorner, 
			core::rect<s32>(core::position2d<s32>(0,0), Texture->getOriginalSize()),
			&AbsoluteClippingRect, image_color,alphablend);
	}
	else
	{
		// maybe this would also be a good idea then
		// driver->draw2DRectangle(image_color, AbsoluteRect, &AbsoluteClippingRect);
		driver->draw2DRectangle(skin->getColor(EGDC_3D_DARK_SHADOW), AbsoluteRect, &AbsoluteClippingRect);
	}

	IGUIElement::draw();
}
Now: using the makeColorKeyTexture method gives really bad results!
nicer would be to use real alpha mask images (TGA)

I have tested alpha-channel images with the 3 drivers and they worked with the above patch.

Cheers
zola
Posts: 52
Joined: Thu Jul 15, 2004 2:31 pm
Location: switzerland
Contact:

Post by zola »

*g* just realized this little inconcistency between the drivers:
use tyn test app with the patches in the previous post.
when rendering with OGL you can do without makeColorKey.... but DX9 need the color key creation even though You use a TGA with 32 bit pixel values?
OGL won't mind though if you make color key even if it doesn't need it ;)
Tyn
Posts: 932
Joined: Thu Nov 20, 2003 7:53 pm
Location: England
Contact:

Post by Tyn »

I remember not putting the guiEnv->drawAll() in first time I compiled but then I changed it. I wonder how I sent the wrong version?

ok, didn't know that IGUIImage didn't support transpareny. I'll try your patch tonight, bit of a pain in it not having it really, it is pretty important.
knightoflight
Posts: 199
Joined: Sun Aug 24, 2003 5:47 pm
Location: Germany

Post by knightoflight »

i found the best workaround to all the problems with V0.7 for me:
Back to V0.6 :-(
(I'ma loser baby, so why don't you kill me - BECK)
Post Reply