HELP!! Problim with transporent!!

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.
FLUF
Posts: 14
Joined: Fri Jan 12, 2007 11:32 pm
Contact:

HELP!! Problim with transporent!!

Post by FLUF »

I write this:

Code: Select all

int main( )
{
    config=new Config( );

    device=createDevice(video::EDT_DIRECT3D8, // ^_^'
        dimension2d<s32>(config->screen_w, config->screen_h),
        config->screen_bpp,
        config->screen_full,
        config->screen_stencil,
        config->screen_vsync);

    device->setWindowCaption(L"Cruel Track");
    driver = device->getVideoDriver( );

    ITexture *teh0=driver->getTexture("f:/1.png");
    ITexture *teh1=driver->getTexture("f:/2.png");

	while (device->run( )){
		driver->beginScene(true, true, SColor(100,0,0,0));

            driver->draw2DImage(teh0, core::position2d< s32 >(100,100), 
                core::rect< s32 >(40,40,500,500), 0, SColor(150, 25, 255, 255), true);

            driver->draw2DImage(teh1, core::position2d< s32 >(170,170), 
                core::rect< s32 >(40,40,500,500), 0, SColor(150, 255, 255, 255), true);

		driver->endScene();
	}

	return 0;
}
but it's don't work - image not transporent (appha blending don't work). Why???
Last edited by FLUF on Wed Jan 17, 2007 11:37 am, edited 1 time in total.
FLUF
Posts: 14
Joined: Fri Jan 12, 2007 11:32 pm
Contact:

Post by FLUF »

Please, HELP!! I see API reference and tutoriol. In tutorial, in "10.Shaders", you make "alpha blending" whis help Shaders function.
But I want jast 2d "alpha blending" (not full transparent). What I can do it?? Please, help.
sgt_pinky
Posts: 149
Joined: Sat Oct 14, 2006 11:20 am
Location: Melbourne, Australia

Post by sgt_pinky »

Intellectuals solve problems - geniuses prevent them. -- Einstein
#irrlicht on irc.freenode.net
FLUF
Posts: 14
Joined: Fri Jan 12, 2007 11:32 pm
Contact:

Post by FLUF »

Mrf.... V_V' I see this simple.

// draw transparent rect under cursor
core::position2d<s32> m = device->getCursorControl()->getPosition();
driver->draw2DRectangle(video::SColor(100,255,255,255),
core::rect<s32>(m.X-20, m.Y-20, m.X+20, m.Y+20));

It's RECTANGLE! But I want 2DImage!

driver->draw2DImage(teh0, core::position2d< s32 >(100,100),
core::rect< s32 >(40,40,500,500), 0, SColor(150, 25, 255, 255), true);

- not work (image not transporent)! why?! It's Bug??
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

Maybe try another draw2DImage(...) function !?!?!
There are 4 draw2DImage functions (overloaded) !!!
Mostly I'm using this one:

Code: Select all

draw2DImage  (  video::ITexture *  texture,  
  const core::rect< s32 > &  destRect,  
  const core::rect< s32 > &  sourceRect,  
  const core::rect< s32 > *  clipRect = 0,  
  video::SColor *  colors = 0,  
  bool  useAlphaChannelOfTexture = false 
 )
And have a look at the api, especially for the colors parameter !!!
It's not what you think it is... ;)
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
FLUF
Posts: 14
Joined: Fri Jan 12, 2007 11:32 pm
Contact:

cry

Post by FLUF »

I'm cry, but it's not work to v.v

Code: Select all

    ITexture *teh0=driver->getTexture("f:/1.png");
    ITexture *teh1=driver->getTexture("f:/2.png");
    
    const core::rect< s32 > destRect0 (40,40,500,500);
    const core::rect< s32 > destRect1 (90,90,500,500);
    const core::rect< s32 > sourceRect (0,0,100,100);
    const core::rect< s32 > clipRect (0, 0, 50, 50);

    video::SColor colors[4];
    colors[0]=video::SColor(100,155,155,155);
    colors[1]=video::SColor(100,155,155,155);
    colors[2]=video::SColor(100,155,155,155);
    colors[3]=video::SColor(100,155,155,155);
      
	while (device->run( )){
		driver->beginScene(true, true, SColor(100,100,100,100));

            driver->draw2DImage(teh0, destRect0, sourceRect, &clipRect, colors, true);
            driver->draw2DImage(teh1, destRect1, sourceRect, &clipRect, colors, true);

		driver->endScene();
	}
Please, sey, it's mast work or I write vrong code??
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

I think you don't have to use the colors nor the cliprect !?!?!
Try it like this:

Code: Select all

driver->draw2DImage(teh0, destRect0, sourceRect, 0, 0, true);
Also you can try to set the alpha color with:

Code: Select all

driver->makeColorKeyTexture(teh0, core::position2d<s32>(0,0));
at the position there should be a pixle with the transparent color...
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
FLUF
Posts: 14
Joined: Fri Jan 12, 2007 11:32 pm
Contact:

Post by FLUF »

No, no. I don't need full transparent. I need alpha blending.
For example, my image has to be transparent on 80% or 23% or 34.5%... u know what i mean?
What I can do it?
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

Oh, I see... ;)
And if you don't use makeColorKeyTexture(...) ???

But well then, in fact it also should work like you did it in you main post...
What about the format of the textures ???
Does png support alpha blending (or doesn't it matter at all, I don't know, sorry) ???
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
FLUF
Posts: 14
Joined: Fri Jan 12, 2007 11:32 pm
Contact:

=\

Post by FLUF »

I try mingw32 and MSVC++7.0 - not work. I try difirent formats of images - nothing =\ I see in irrlicht source (COpenGLDriver) - hm, transparent MAST work... =\ but did't work =(((
Please, if on you computer not full transparent is work (for exemple, transparent image on 23%...), PLEASE, write simple for my!
PLEASE!
fluffydim@gmail.com
harukiblue
Posts: 49
Joined: Sun Dec 10, 2006 6:23 pm

Try this

Post by harukiblue »

Code: Select all

int main( ) 
{ 
    config=new Config( ); 

    device=createDevice(video::EDT_DIRECT3D8, // ^_^' 
        dimension2d<s32>(config->screen_w, config->screen_h), 
        config->screen_bpp, 
        config->screen_full, 
        config->screen_stencil, 
        config->screen_vsync); 

    device->setWindowCaption(L"Cruel Track"); 
    driver = device->getVideoDriver( ); 

    ITexture *teh0=driver->getTexture("f:/1.png"); 
    ITexture *teh1=driver->getTexture("f:/2.png"); 

   while (device->run( )){ 
      driver->beginScene(true, true, SColor(100,0,0,0)); 

            driver->draw2DImage(teh0, core::position2d< s32 >(100,100), 
                core::rect< s32 >(40,40,500,500), 0, SColor(150, 255, 255, 255), true); 

            driver->draw2DImage(teh1, core::position2d< s32 >(170,170), 
                core::rect< s32 >(40,40,500,500), 0, SColor(150, 255, 255, 255), true); 

      driver->endScene(); 
   } 

   return 0; 
} 
I changed a little bit, But I would like to see a screen shot of your result. This may help us figure out what the problem may be. Thanks mate!
FLUF
Posts: 14
Joined: Fri Jan 12, 2007 11:32 pm
Contact:

Post by FLUF »

So, I creat new Irrlicht project (on DevCpp) and write this code (it's copypast from 'harukiblue'):

Code: Select all


#include <irrlicht.h>

using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;

IrrlichtDevice *device;
IVideoDriver *driver;

int main()
{
    device=createDevice(video::EDT_DIRECT3D9,
        dimension2d<s32>(640, 480));//, 32, true, false, false); 

    device->setWindowCaption(L"Cruel Track"); 
    driver = device->getVideoDriver( ); 

    ITexture *teh0=driver->getTexture("f:/1.png"); 
    ITexture *teh1=driver->getTexture("f:/2.png"); 

   while (device->run( )){ 
      driver->beginScene(true, true, SColor(100,0,0,0)); 

            driver->draw2DImage(teh0, core::position2d< s32 >(100,100), 
                core::rect< s32 >(0,0,80,80), 0, SColor(150, 255, 255, 255), true); 

            driver->draw2DImage(teh1, core::position2d< s32 >(110,110), 
                core::rect< s32 >(0,0,80,80), 0, SColor(150, 255, 255, 255), true); 

      driver->endScene(); 
   } 

   return 0; 
}
And what I see:
Image

And I painting in photoshop, what I want:
Image

I try Direct X 8, 9, OpenGL...
My videocard - ATI Radeon 9700 128 mb (on notebook)
OS - WinXP.

Don't undestend, why this did't work =(
harukiblue, Acki - on yore computer it's work?
If yes, plese, send my archive whis image. May be it's trable in image format or texture-load format.... ?
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Try with the last parameter being false (or just missing). You don't want the texture alpha channel.
FLUF
Posts: 14
Joined: Fri Jan 12, 2007 11:32 pm
Contact:

Post by FLUF »

V_V'
offcouse I try it! - don't work!

"You don't want the texture alpha channel."
>_<' ??!! no, I want use alpha channel!

fucked! I post question in Jan 15, 5:09 am. todey is 17, 22:50. Question is ease, but you can't give my answer! =(

PLEASE, if alpha blending work on you computer, PLEASE, write simple and send it my (fluffydim@gmail.com) or give me url on that simple.

On the guichan (http://guichan.sourceforge.net/) all work...
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

Alright, I used the same code you posted here, I only changed the graphic files:

Code: Select all

#include <irrlicht.h>
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;

IrrlichtDevice *device;
IVideoDriver *driver;

int main(){
  device=createDevice(video::EDT_DIRECT3D9,
        dimension2d<s32>(640, 480));//, 32, true, false, false);

  device->setWindowCaption(L"Cruel Track");
  driver = device->getVideoDriver( );

  ITexture *teh0=driver->getTexture("C:\\CodeBlocks\\AB-AddOn\\Media\\Irrlicht\\stones.jpg");
  ITexture *teh1=driver->getTexture("C:\\CodeBlocks\\AB-AddOn\\Media\\Irrlicht\\wall.jpg");

  while (device->run( )){
    driver->beginScene(true, true, SColor(100,0,0,0));

    driver->draw2DImage(teh0, core::position2d< s32 >(100,100), core::rect< s32 >(0,0,80,80), 0, SColor(150, 255, 255, 255), true);

    driver->draw2DImage(teh1, core::position2d< s32 >(110,110), core::rect< s32 >(0,0,80,80), 0, SColor(150, 255, 255, 255), true);

      driver->endScene();
   }
   return 0;
}
And this is the result:
Image
As you can see it's what you expected !!!
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
Post Reply