Using 2D functions to draw a scope on screen?
Using 2D functions to draw a scope on screen?
I tried a few things like draw2dImage i cant seem to get this to work I want to draw like a scoipe so it zooms in but when it zooms in I only want like a circular area to be seen though as if you are looking through a scope. I tried using ITexture or something and drawing 2D above the 3d but nothing happend. Anyone have like a example of how this is done I tried a few things but yea nothing was working :/
alpha
you need to create a bitmap of a circle. when you load up the texture set the color of the circle in the bitmap to be the colorkey so that it becomes transparent.
then smgr->drawAll() your 3d world and then
the only problem is that you need to stretch the texture to fill the screen
Code: Select all
irr::video::ITexture* scope = grr.driver->getTexture("scope.bmp");
grr.driver->makeColorKeyTexture(scope, irr::video::SColor(255,255,255,255)); //assuming the circle is white
Code: Select all
device->getVideoDriver()->draw2DImage(scope,irr::core::position2d<s32>(screenX/2,screenY/2),irr::core::rect<s32>(0,0,128,128),NULL,irr::video::SColor(255,255,255,255),true);
btw, using the code from this thread (http://irrlicht.sourceforge.net/phpBB2/ ... .php?t=633) you can stretch a 'scope' bitmap to fill the screen. i tried it out (using my derived camera class) and it seems to work well.Spartacus wrote:the scope image becomes inverted like about half way inbetween the image and the colors like swap or somthing... its just not right lol
So you didnt have a problem with the colors inverting half way in the image? Its like.... it worked with black color for like 65% of the image from the top going down but the rest inverted.. by inverted i mean like, It was showing the black color of the bitmap till it hit 65% of the height down and then it only showed the white part of the bitmap 0.o, and removed the black. Kinda werid... I also was wondering if you knew how I could apply more then 1 color to like make the scope somewhat fade to black rather then the instant change to black
the inverting could happen if you specify an incorrect size when displaying the graphic. try this codeSpartacus wrote:So you didnt have a problem with the colors inverting half way in the image? Its like.... it worked with black color for like 65% of the image from the top going down but the rest inverted.. by inverted i mean like, It was showing the black color of the bitmap till it hit 65% of the height down and then it only showed the white part of the bitmap 0.o, and removed the black. Kinda werid... I also was wondering if you knew how I could apply more then 1 color to like make the scope somewhat fade to black rather then the instant change to black
Code: Select all
irr::video::ITexture* scope = driver->addTexture(irr::core::dimension2d<s32>(800,600),"myScope"); //create empty texture which fits the screen (assume screen is 800x600)
irr::video::ITexture* scope2 = driver->getTexture("scope.bmp"); //get the bitmap of the scope, assume it's 64x64
grr.driver->makeColorKeyTexture(scope2, irr::video::SColor(255,255,255,255)); //make anything white into transparent
StretchTextureFast(scope,scope2,irr::core::rect<irr::s32>(0,0,800,600),irr::core::rect<irr::s32>(0,0,64,64)); //scale texture
......
device->getVideoDriver()->draw2DImage(scope,irr::core::position2d<s32>(0,0),irr::core::rect<s32>(0,0,800,600),NULL,irr::video::SColor(255,255,255,255),true); //draw it