[2d in 3d] simple rectangle
[2d in 3d] simple rectangle
hello,
i have a 640x480 window.
i have a 3d scene drawed.
i want to draw a 50x60 2d-texturized-panel at the point 10,10 of this window
it will NOT be a GUI element
on this panel, i will write some text. i think the ITextSceneNode will be useful
how would you make it?
i have a 640x480 window.
i have a 3d scene drawed.
i want to draw a 50x60 2d-texturized-panel at the point 10,10 of this window
it will NOT be a GUI element
on this panel, i will write some text. i think the ITextSceneNode will be useful
how would you make it?
Get stronger confronting stronger ones
Well I would (and have) write my own gui class that uses irrlichts Draw2DImage function. And my Own bitmap font class (irrlichts font is ok but very basic).
Also don't go with 50x60. If you have to use that size make it 64x64 and use ALPHA to mask of the parts you don't want.. keep the textures pow2 for quality.
use driver->draw2Dimage(your texture, Position) and call this in your render loop as the last thing so that it is drawn on top of other things.
Also don't go with 50x60. If you have to use that size make it 64x64 and use ALPHA to mask of the parts you don't want.. keep the textures pow2 for quality.
use driver->draw2Dimage(your texture, Position) and call this in your render loop as the last thing so that it is drawn on top of other things.
If you don't tell the engine the size of your image it will just draw it 2x2. Use to set the destination size as well.
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)
There are different "draw2DImage()" functions.
The one you are looking for is this:
So obviously your "destRect" is 64x64 and your "sourceRect" is 2x2.
The one you are looking for is this:
Code: Select all
virtual void irr::video::IVideoDriver::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
) [pure virtual]
[Resolved][2d in 3d] simple rectangle
ok, works fine!
for the 2d text, i used font->draw()
for the 2d text, i used font->draw()
Get stronger confronting stronger ones
(me from above)
dude - you don't have to use 64x63 for all smaller textures - they just need to be power of 2.
2x2 IS power of 2 so you can use it as is though I would sugest 16x16 as a minimum size.
Pow of 2 also doesn't mean "square" so you can have any combination of 8,16,32,64,128,256,512,1025 etc
for example:
8 x 512 is VALID
512 x 32 is VALID
128 x 128 is VALID
64 x 256 is VALID
they are pow2
Now as for "stretching or not" using rects, that is one way - I didn't mean that though I meant to make a blank texture at a pow 2 size (64x64 for example) then place your 50x60 image in the top left of it - then use an ALPHA CHANNEL on the texture (tga,png) to remove the excess on the right and bottom - the texture size is still 64 x 64 but the visible image in game is still only 50x60 and it needs no scaling/stretching etc (so it looks good) - also be sure to turn MIP MAP CREATION OFF before loading gui / overlay textures.
HTH
dude - you don't have to use 64x63 for all smaller textures - they just need to be power of 2.
2x2 IS power of 2 so you can use it as is though I would sugest 16x16 as a minimum size.
Pow of 2 also doesn't mean "square" so you can have any combination of 8,16,32,64,128,256,512,1025 etc
for example:
8 x 512 is VALID
512 x 32 is VALID
128 x 128 is VALID
64 x 256 is VALID
they are pow2
Now as for "stretching or not" using rects, that is one way - I didn't mean that though I meant to make a blank texture at a pow 2 size (64x64 for example) then place your 50x60 image in the top left of it - then use an ALPHA CHANNEL on the texture (tga,png) to remove the excess on the right and bottom - the texture size is still 64 x 64 but the visible image in game is still only 50x60 and it needs no scaling/stretching etc (so it looks good) - also be sure to turn MIP MAP CREATION OFF before loading gui / overlay textures.
HTH
Damn typos - I meant 64 x 64 not (63) and also 1024 not 1025 (of course).
Now I also see you image is just a backdrop colour or something 2x2 so you don't mind stretching it up - if you ever use an actual detailed 50x60 image then you could do as I posted. as it is, you are happy just stretching the smaller texture up because you are not getting scaling artifcacts?
Now I also see you image is just a backdrop colour or something 2x2 so you don't mind stretching it up - if you ever use an actual detailed 50x60 image then you could do as I posted. as it is, you are happy just stretching the smaller texture up because you are not getting scaling artifcacts?
Just a precision,
i replace my 2x2 texture by a 640x480 texture, i scale it to lower sizes, and it works fine.
i think your alpha method is correct and improve performances but i don't think this will do slow down my game.
so i have some
videoDriver->draw2DImage (texture,
core::rect< s32 >(20,20,70,80),
core::rect< s32 >(0,0,640,480));
i replace my 2x2 texture by a 640x480 texture, i scale it to lower sizes, and it works fine.
i think your alpha method is correct and improve performances but i don't think this will do slow down my game.
so i have some
videoDriver->draw2DImage (texture,
core::rect< s32 >(20,20,70,80),
core::rect< s32 >(0,0,640,480));
Get stronger confronting stronger ones
no !i replace my 2x2 texture by a 640x480 texture
i understand ur confusion because of all those values and corrections and so
valid texture sizes are 2^n
so the values closest to the ones u are refering to is
256, 512, 1024
eg 2^8, 2^9, and 2^10
it is perfectly ok to use 2 different values on a texture -eg a texture sized 256*512 is OK
Regards.
Tech: win98se| 320mb ram| abitbe6| 433mhzceleron| atiRadeon7000.64mb| soundblaster125| dx9.0b | devCPP | IRR 0.12.0 |
Tech: win98se| 320mb ram| abitbe6| 433mhzceleron| atiRadeon7000.64mb| soundblaster125| dx9.0b | devCPP | IRR 0.12.0 |