I want to use a 2d rectangle as a health bar in game. But when i try to draw a 2d rectangle it doesn't sahow up in game. Here is the code i use:
while(SPDevice->run() && Sdriver)
{
Sdriver->beginScene(true, true, video::SColor(0,100,100,100));
smgr->drawAll();
env->drawAll();
core::position2d<s32> m = SPDevice->getCursorControl()->getPosition();
Sdriver->draw2DRectangle(SColor(0,100,100,100),rect<s32>(50,50,25,25), 0);
Sdriver->draw2DImage(texture, core::position2d<s32>(m.X - 12,m.Y - 12), rect<s32>(0,0,25,25), 0, video::SColor(255,255,255,255), true);
Sdriver->endScene();
}
SPDevice->drop();
If you can help me it would be appreciated. This is probably small mistake that i made but i can't find it!
drawing 2d rectangles
-
- Posts: 8
- Joined: Fri Jul 23, 2004 2:45 am
- Location: Untied States
-
- Posts: 15
- Joined: Sun Aug 22, 2004 2:06 pm
- Location: Estonia
Re: drawing 2d rectangles
me_go_fast wrote:
Sdriver->draw2DRectangle(SColor(0,100,100,100),rect<s32>(50,50,25,25), 0);
Sdriver->draw2DImage(texture, core::position2d<s32>(m.X - 12,m.Y - 12), rect<s32>(0,0,25,25), 0, video::SColor(255,255,255,255), true);
Sdriver->endScene();
}
it seems that you replaced values inf rect<s32>. if you'll put (25,25,50,50) instead it will probably be OK.
also, as far as I remeber SColor(255, 255, 255, 255) if fully white and opaque, so that's probably good choice for testing.
greetz
I tried using just the 2D rectangle and it seems that the rectangle is showing up behind the 3d Scene....
So if I have a simple plane with some stuff on it , the rectangle shows up behind the 3D objects....
Weird????
So if I have a simple plane with some stuff on it , the rectangle shows up behind the 3D objects....
Here's my code if I change the size of the object to be towards the middle of the screen it shows me that the rectangle is behind the 3d Objects...driver->draw2DRectangle(SColor(100,255,255,255),rect<s32>(10,10,240,60),0);
Weird????
this looks like a bug to me...
smgr->drawAll();
env->drawAll();
Sdriver->draw2DRectangle(SColor(0,100,100,100),rect<s32>(50,50,25,25), 0);
take me lightly... in my program I have that minus the smgr which is what 3d?
ok so the solution seems to put the rectangle before you draw the smgr.. but doesn't env-> have to be before rectangle and after smgr?
you have all officially confused me.
smgr->drawAll();
env->drawAll();
Sdriver->draw2DRectangle(SColor(0,100,100,100),rect<s32>(50,50,25,25), 0);
take me lightly... in my program I have that minus the smgr which is what 3d?
ok so the solution seems to put the rectangle before you draw the smgr.. but doesn't env-> have to be before rectangle and after smgr?
you have all officially confused me.