Draw2DImage error

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
Mercator
Posts: 16
Joined: Fri Jan 27, 2006 4:31 pm

Draw2DImage error

Post by Mercator »

I want to draw an image with varying transparency, but I get an error when I use the SColor parameter.

This compiles well:

Code: Select all

m_driver->draw2DImage(m_buf[id].img, dest, m_buf[id].src, NULL, NULL, true);
This does not:

Code: Select all

m_driver->draw2DImage(m_buf[id].img, dest, m_buf[id].src, NULL, SColor(255,255,255,255), true);

Code: Select all

error: no matching function for call to `irr::video::IVideoDriver::draw2DImage(irr::video::ITexture*&, irr::core::rect<irr::s32>&, irr::core::rect<irr::s32>&, NULL, irr::video::SColor, bool)'
s\irrlicht-1.3\include\IVideoDriver.h:481: note: candidates are: virtual void irr::video::IVideoDriver::draw2DImage(irr::video::ITexture*, const irr::core::position2d<irr::s32>&)
s\irrlicht-1.3\include\IVideoDriver.h:498: note:                 virtual void irr::video::IVideoDriver::draw2DImage(irr::video::ITexture*, const irr::core::position2d<irr::s32>&, const irr::core::rect<irr::s32>&, const irr::core::rect<irr::s32>*, irr::video::SColor, bool)
s\irrlicht-1.3\include\IVideoDriver.h:523: note:                 virtual void irr::video::IVideoDriver::draw2DImage(irr::video::ITexture*, const irr::core::position2d<irr::s32>&, const irr::core::array<irr::core::rect<irr::s32>, irr::core::irrAllocator<irr::core::rect<irr::s32> > >&, const irr::core::array<irr::s32, irr::core::irrAllocator<irr::s32> >&, irr::s32, const irr::core::rect<irr::s32>*, irr::video::SColor, bool)
s\irrlicht-1.3\include\IVideoDriver.h:535: note:                 virtual void irr::video::IVideoDriver::draw2DImage(irr::video::ITexture*, const irr::core::rect<irr::s32>&, const irr::core::rect<irr::s32>&, const irr::core::rect<irr::s32>*, irr::video::SColor*, bool)
:: === Build finished: 5 errors, 0 warnings ===

What did I do wrong?
Klasker
Posts: 230
Joined: Thu May 20, 2004 8:53 am
Contact:

Post by Klasker »

You are using the last one of the candidate methods the compiler mentioned. As you can see it does not take a video::SColor but a video::SColor*. It is a pointer to four colors, specifying the colors of each corner of the image you are drawing. So do like this:

Code: Select all

video::SColor colors[4] = {video::SColor(255,255,255,255), video::SColor(255,255,255,255), video::SColor(255,255,255,255), video::SColor(255,255,255,255)};
m_driver->draw2DImage(m_buf[id].img, dest, m_buf[id].src, NULL, &colors[0], true);
Mercator
Posts: 16
Joined: Fri Jan 27, 2006 4:31 pm

Post by Mercator »

Thank you! :D
Post Reply