Putting a crosshair in

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
Brad8711

Putting a crosshair in

Post by Brad8711 »

Heya, i'm new to Irrlicht (and very excited to use it), and new to programming in C++,i have done a few C++ tutorials and can understand it kinda well.anyhoo, i need some help implementing a crosshair, a .bmp one. i tried a few methods but the parts of the crosshair wasn't transparent, ie the black.i'm not really sure what to do tho, there is something missing, if anyone can help i would be much obliged. :P
Guest

Post by Guest »

ok, it looks like this code can be used

Code: Select all

gui::IGUIImage *crosshair; 

    rect<s32> crosshairDimensions(position2d<s32>(640/2,480/2),dimension2d<s32>(640 * 6,480 * 6)); 
    
   crosshair=guienv->addImage(crosshairDimensions); 
    
   ITexture *tex=driver->getTexture("gui/crosshair.bmp"); 
    
   crosshair->setImage(tex); 

so if anyone has any other ideas bring them up
[/b]
Guest

Post by Guest »

i had the same question and this doesnt work for me
SARIN
Posts: 139
Joined: Fri Oct 29, 2004 3:53 am

Post by SARIN »

well, i dont no if this will work, but u could try a billboard. not sure bout the code, but u could simply set the position of the billboard like

billposx=.1*sin(camangley);
billposy=.1*cos(camanglex);
billposz=.1*cos(camangley);

yes, i no that this is very inefficient, but the way described by the guest above apparently doesnt work, and thats the first way i would have tried.
(i think the sin and cos functions are under math.h under ur compiler)
Json
Posts: 5
Joined: Thu Nov 18, 2004 12:16 pm

Post by Json »

Code: Select all

	// Load the image
	tImage = driver->getTexture("crosshair.bmp");

	// Set keycolor
	driver->makeColorKeyTexture(tImage, position2d<s32>(0,0));

	// Draw crosshair
	driver->draw2DImage(tImage, position2d<s32>(iPositionX, iPositionY), rect<s32>(0, 0, 32, 32), 0, SColor(255,255,255,255), true);
Maybe :D
Guest

Post by Guest »

and what header file do i need for that code JSON?
Handle
Posts: 19
Joined: Tue Jul 13, 2004 2:00 pm

Post by Handle »

Anonymous wrote:and what header file do i need for that code JSON?
You'll just need to include the irrlicht.h header as you must have been doing already! :wink:
Post Reply