Page 1 of 1

2d images PLEASE HELP!!!!

Posted: Mon Feb 14, 2011 3:59 pm
by only1skingle
hey everyone,

I have looked at the tutorials but im lost within the code!

I am trying to make a 2d image appear on my program screen.

I am using the following code:

driver->draw2DRectangle(video::SColor(0,255,0,0),
core::rect<s32>(100,20,200,40));

but it doesn't seem to work. :(
any advice/guidance or a perfect code sample on how to put a rectangle in my program would be great.

Thanks

Posted: Mon Feb 14, 2011 4:02 pm
by Radikalizm
Are you calling this code inside your drawing loop?

Posted: Mon Feb 14, 2011 4:16 pm
by only1skingle
yes

while(device->run() && driver)
{
if (device->isWindowActive())

Posted: Mon Feb 14, 2011 4:17 pm
by Radikalizm
And where inside your drawing loop are you calling this?

Posted: Mon Feb 14, 2011 4:50 pm
by hybrid
You also have full transparency enabled. Good chances that your rectangle is completely invisible, even if it's rendered.

Posted: Mon Feb 14, 2011 5:05 pm
by only1skingle
no worries, i have now got a square placed in my window

i started messing around with the numbers in here:

core::rect<s32>(100,390,210,440));

however i am now confused as to what each number does.

As i thought maybe the (1,2 were x and y
and 3,4)); were size

but this doesn't seem to be the case.

so what do they do??

thanks

Posted: Mon Feb 14, 2011 5:08 pm
by only1skingle
its the 4 points of the rectangle...right???

Posted: Mon Feb 14, 2011 5:10 pm
by randomMesh
only1skingle wrote:no worries, i have now got a square placed in my window

i started messing around with the numbers in here:

core::rect<s32>(100,390,210,440));

however i am now confused as to what each number does.

As i thought maybe the (1,2 were x and y
and 3,4)); were size

but this doesn't seem to be the case.

so what do they do??

thanks
Position and position + size. Have a look at the constructor: irr::core::rect

So a box with width 100 and height 10 at postion 10,1 would be like

Code: Select all

irr::core::rect<irr::s32>(10, 1, 10 + 100, 1 + 10)

Posted: Mon Feb 14, 2011 5:33 pm
by only1skingle
thanks everyone for your help,
I really appreciate it :)

Posted: Tue Feb 15, 2011 6:52 am
by Bear_130278
Image