Image problems

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
Tyn
Posts: 932
Joined: Thu Nov 20, 2003 7:53 pm
Location: England
Contact:

Image problems

Post by Tyn »

Hey

I'm starting to think I know less C++ than I thought. Basically I was pretty sure I knew what to do, I am adding a 2D image which I will then add my own GUI elements to and I'm having a big problem with displaying the image. The size of the image is 1024 x 180 and I've got this code to display it:

driver->draw2DImage(guibar, core::position2d<s32>(0,588),
core::rect<s32>(0,0,1024,180), 0,
video::SColor(255,255,255,255), true);

This should create a rectangle that is the right size for the image and then the top left hand corner is at 0, 588, in other words putting the GUI bar at the bottom of a 1024x768 screen right? Well, it displays only 1024 x 125 ( I think ) of the image and crops the rest. To check what it was doing I changed the left hand corner to start at 0,0 and changed the height to 500, it showed that it was tiling the image but cropping the bottom part, leaving a space and then tiling this image. Is there something wrong with my code?
[dx/x]=HUNT3R
Posts: 271
Joined: Sat Aug 23, 2003 5:52 pm
Location: Hurricane Central, Florida

Post by [dx/x]=HUNT3R »

Your code statement to display a 2D image that is 1024x180 is correct. The problem must be somewhere else...
niko
Site Admin
Posts: 1759
Joined: Fri Aug 22, 2003 4:44 am
Location: Vienna, Austria
Contact:

Re: Image problems

Post by niko »

Hm, maybe it helps changing the texture size to a power-of-two size.
Guest

Post by Guest »

I thought the code was right, guess it's my inexperience with game engines that's showing through right now. I changed it to the power of two size ( something I should have known being that I've done textures for games before ) and updated all the code but it did the same thing. Here's a pic of what is happening ( without the 3D scene for clarity )



Sorry about crappy loading time, freewebspace is never fast in my experience :D.

I've extended the box so it tiles and the white space is what it is cropping ( white being the background colour currently ) and the blue bar being the window bar of the program. As you can see it is cropping the bottom part, or making it transparent, leaving the space where it should be and then tiling it over again.
Guest

Post by Guest »

Oops, forgot image.

Image
Tyn
Posts: 932
Joined: Thu Nov 20, 2003 7:53 pm
Location: England
Contact:

Huh?

Post by Tyn »

Well, I had a play around with my code. I added the 3D world and got my bar to draw over the world in the correct position. I found the problem, what was happening was I had a line of code to tell the program where to find the alpha channel in the image, like in the example, and it worked to an extent. It worked fine for the top half, but for some reason in the bottom half it didn't filter the colour and made the whole bottom half semi-transpararent When I removed the code it made the whole image semi-transparent, which was strange. A couple of things I need to understand I think:

How do I adjust transparancy of an image? I thought it was the first figure in this line of code:

Code: Select all

video::SColor(255,255,255,255), true);
But it doesn't seem to do anything.

Why would an alpha channel only effect half an image? It can't be the format I am using, I have used BMP, TGA and JPEG all of which have the same effect. I have adjusted the size of the image to conform with the power of two effect, is there something else I should know but am ignorant of?

Methinks understanding how a graphics engine works will be harder than the project I wish to do :lol:[/code]
Tyn
Posts: 932
Joined: Thu Nov 20, 2003 7:53 pm
Location: England
Contact:

Post by Tyn »

Tracked it down even further. I've been playing around with the image options with mixed results:

Code: Select all

				driver->draw2DImage(guibar, core::position2d<s32>(10,10),	
				core::rect<s32>(0,0,342,224), 0, true);
Is the code I am using at the moment, it creates strange errors.

Right, so there are two things in this code which puzzle me:

core::rect<s32>(0,0,342,224), 0, true)

What is the number in bold type representing? I didn't find any mention of it in the API.

The bool in italics I know of, it is the alpha channel active bool. Defaulted to False, but if the mysterious 0 doesn't exist then it creates compile errors, however the 0 can exist without the true, in fact it creates the weird colour difference I was originally having problems with. So what the hell is it, what does it do and why is it messing my my image?
Harry_Mystic
Posts: 32
Joined: Sun Nov 23, 2003 10:23 pm

Post by Harry_Mystic »

Hi

here is the link to the documentation of draw2DImage
http://irrlicht.sourceforge.net/docu/cl ... r.html#a22
The bold 0 is (from the docu):
"clipRect: Pointer to rectangle on the screen where the image is clipped to. This pointer can be NULL. Then the image is not clipped"
When you use the last parameter (useAlphaChannelOfTexture = true) you need to put another value SColor between "bold 0" and "true" like in your first version.
Hope this helps

Cheers
[/url]
Guest

Post by Guest »

OK, so it isn't the Clip identifier that is causing the problem, and I have already identified the alpha colour earlier in my code but I tried doing it there as well but it did nothing. Thanx for trying, dunno what the problem is :? I'll leave it for now and see if anyone else has the same problem in the future.
Arudil
Posts: 27
Joined: Sun Sep 28, 2003 7:59 am
Location: Germany
Contact:

Post by Arudil »

i didn't read all, because it's late, and it's weekend, and english remember me at school.. did you do what niko said? i solved a problem with niko's tip.
Tyn
Posts: 932
Joined: Thu Nov 20, 2003 7:53 pm
Location: England
Contact:

Post by Tyn »

Yeah I did, made no difference unfortunatly :(
Post Reply