Quad primitive?

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Eldritch
Posts: 33
Joined: Mon Feb 26, 2007 12:33 pm

Quad primitive?

Post 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.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Of course it is. Irrlicht comes with a nice API documentation and several examples which should guide you to the correct code.
Eldritch
Posts: 33
Joined: Mon Feb 26, 2007 12:33 pm

Post 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?
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post 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.
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post 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;
 
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
Eldritch
Posts: 33
Joined: Mon Feb 26, 2007 12:33 pm

Post 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?
Post Reply