Image problems
Image problems
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?
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?
-
- Posts: 271
- Joined: Sat Aug 23, 2003 5:52 pm
- Location: Hurricane Central, Florida
Re: Image problems
Hm, maybe it helps changing the texture size to a power-of-two size.
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 .
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.
Sorry about crappy loading time, freewebspace is never fast in my experience .
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.
Huh?
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:
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 [/code]
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);
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 [/code]
Tracked it down even further. I've been playing around with the image options with mixed results:
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?
Code: Select all
driver->draw2DImage(guibar, core::position2d<s32>(10,10),
core::rect<s32>(0,0,342,224), 0, true);
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?
-
- Posts: 32
- Joined: Sun Nov 23, 2003 10:23 pm
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]
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]
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.