Page 1 of 1

Quad primitive?

Posted: Mon Mar 12, 2007 4:34 pm
by Eldritch
Is there any way to draw a quad primitive in 2D space in Irrlicht? The thing is that I want to use an RTT texture and overlay it over the entire screen so I can create some nice effects.

Posted: Mon Mar 12, 2007 5:02 pm
by hybrid
Of course it is. Irrlicht comes with a nice API documentation and several examples which should guide you to the correct code.

Posted: Tue Mar 13, 2007 11:15 am
by Eldritch
Found two different tutorials that incorporated two different techniques of how to draw a quad, but they were both in 3D space. I need this to be in 2D space.

Would it be possible to make a GUIImage object with color blending?

Posted: Tue Mar 13, 2007 1:58 pm
by hybrid
Please do read this:
http://irrlicht.sourceforge.net/docu/cl ... river.html
and watch for 2D methods. You'll find lots of color parameters there, too.

Posted: Tue Mar 13, 2007 7:37 pm
by bitplane
Here's a patch for IGUIImage to apply a colour/alpha change to the whole image, because of the api change it won't be committed to SVN until after 1.3 is released.

Code: Select all

Index: include/IGUIImage.h
===================================================================
--- include/IGUIImage.h	(revision 543)
+++ include/IGUIImage.h	(working copy)
@@ -28,6 +28,8 @@
 		//! sets an image
 		virtual void setImage(video::ITexture* image) = 0;
 
+		virtual void setColor(video::SColor& color) = 0;
+
 		//! sets if the image should use its alpha channel to draw itself
 		virtual void setUseAlphaChannel(bool use) = 0;
 	};
Index: source/Irrlicht/CD3D9ParallaxMapRenderer.cpp
===================================================================
--- source/Irrlicht/CD3D9ParallaxMapRenderer.cpp	(revision 543)
+++ source/Irrlicht/CD3D9ParallaxMapRenderer.cpp	(working copy)
@@ -383,7 +383,7 @@
 		services->setVertexShaderConstant(c96, 96, 1);
 
 		// set scale factor
-        f32 factor = 0.02f; // default value
+		f32 factor = 0.02f; // default value
 		if (CurrentScale != 0)
 			factor = CurrentScale;
 
Index: source/Irrlicht/CGUIImage.cpp
===================================================================
--- source/Irrlicht/CGUIImage.cpp	(revision 543)
+++ source/Irrlicht/CGUIImage.cpp	(working copy)
@@ -16,7 +16,7 @@
 
 //! constructor
 CGUIImage::CGUIImage(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect<s32> rectangle)
-: IGUIImage(environment, parent, id, rectangle), Texture(0), UseAlphaChannel(false)
+: IGUIImage(environment, parent, id, rectangle), Texture(0), UseAlphaChannel(false), Color(255,255,255,255)
 {
 	#ifdef _DEBUG
 	setDebugName("CGUIImage");
@@ -46,6 +46,11 @@
 		Texture->grab();
 }
 
+//! sets the color of the image
+void CGUIImage::setColor(video::SColor &color)
+{
+	Color = color;
+}
 
 
 //! draws the element and its children
@@ -62,7 +67,7 @@
 	if (Texture)
 		driver->draw2DImage(Texture, AbsoluteRect.UpperLeftCorner, 
 			core::rect<s32>(core::position2d<s32>(0,0), Texture->getOriginalSize()),
-			&AbsoluteClippingRect, video::SColor(255,255,255,255), UseAlphaChannel);
+			&AbsoluteClippingRect, Color, UseAlphaChannel);
 	else
 		driver->draw2DRectangle(skin->getColor(EGDC_3D_DARK_SHADOW), AbsoluteRect, &AbsoluteClippingRect);
 
Index: source/Irrlicht/CGUIImage.h
===================================================================
--- source/Irrlicht/CGUIImage.h	(revision 543)
+++ source/Irrlicht/CGUIImage.h	(working copy)
@@ -25,6 +25,9 @@
 		//! sets an image
 		virtual void setImage(video::ITexture* image);
 
+		//! sets the color of the image
+		void setColor(video::SColor &color);
+
 		//! draws the element and its children
 		virtual void draw();
 
@@ -39,7 +42,7 @@
 
 
 	private:
-
+		video::SColor Color;
 		video::ITexture* Texture;
 		bool UseAlphaChannel;
 

Posted: Tue Mar 13, 2007 8:51 pm
by Eldritch
hybrid wrote:Please do read this:
http://irrlicht.sourceforge.net/docu/cl ... river.html
and watch for 2D methods. You'll find lots of color parameters there, too.
Felt like something that should have worked, but I see nothing.. seems like the texture parameter does nothing... Also, it is not possible to set any form of blending on the drawn image. I'd need that to be able to make the effects I am looking for.

EDIT: got it to work. Seems like I had to draw the 2D image after all the regular drawing (scenemanager + guienv), which of course is logical *slap self*

But.. is there any way to setup a blending mode or something that will be used by all subsequent rendered objects?