I'm currently working on a dashboard for a robot, and part of the dashboard involves streaming video from a camera on the robot. The fastest way I can think of doing this in Irrlicht is decoding the image from the incoming packets, loading them into a IImage, locking the image and a corresponding texture, and copying the data from the image to the texture (assuming that the pixel formats are the same). I want the texture to be drawn across an entire window, but allow the window to be resized.
How could I dynamically resize the texture so that it fills the entire screen? My first idea would be using a Billboard scene node and a camera, using trial and error to move the camera until the billboard takes up the entire window, but I'd assume there's a better way to do it.
Would a solution be to get the view frustum of the camera and use the coordinates of the corner points to determine size?
Scaling Texture to Fill Display [Solved]
Scaling Texture to Fill Display [Solved]
Last edited by slavik262 on Thu Mar 04, 2010 4:58 pm, edited 1 time in total.
Maybe yopu haven't seen this on the wiki: http://www.irrlicht3d.org/wiki/index.ph ... ingAnImage
That's how to scale a picture in Irrlicht. If you don't want that I didn't understand your question.
That's how to scale a picture in Irrlicht. If you don't want that I didn't understand your question.
How does the scaling work? I'm just concerned about efficiency here since I want to run as fast as possible.
Let me rummage around in the source for a bit.
EDIT: Found it. So one of the overloads for draw2dImage can scale the image? Amusing - after looking at how CD3D9Driver does drawImage, I've found it's almost exactly the way I was doing it. I'll just check which way has better performance and go with it.
Let me rummage around in the source for a bit.
EDIT: Found it. So one of the overloads for draw2dImage can scale the image? Amusing - after looking at how CD3D9Driver does drawImage, I've found it's almost exactly the way I was doing it. I'll just check which way has better performance and go with it.
Can you post how you scaled the texture?
Which overload from the draw2DImage did the trick?
I've tried looking at the link, but can't for the life of me make it work.
Thanks!
*** EDIT ***
Lol, nevermind, I had the wrong bit of code in the wrong place, hahahaha. It now works, and in case anyone's interested, this is how I scaled a texture:
Uses the standard draw2DImage function, feeding it the desired texture, then the part of the image you want to draw (in this case, all of it), and the last part is where to draw it - from the top-left corner, to the whole size of the window.
Which overload from the draw2DImage did the trick?
I've tried looking at the link, but can't for the life of me make it work.
Thanks!
*** EDIT ***
Lol, nevermind, I had the wrong bit of code in the wrong place, hahahaha. It now works, and in case anyone's interested, this is how I scaled a texture:
Code: Select all
driver->draw2DImage( textureName,
rect<s32>( 0, 0, driver->getScreenSize().Width, driver->getScreenSize().Height ),
rect<s32>( 0, 0, billText->getSize().Width, billText->getSize().Height ) );
Last edited by jawdy on Sat Mar 06, 2010 7:40 pm, edited 1 time in total.
-
- Competition winner
- Posts: 1123
- Joined: Sun Jun 10, 2007 11:14 pm
I believe this is the function: destRect is the rectangle you want to draw it in, and it automatically scales to fit.
Code: Select all
virtual void draw2DImage (const video::ITexture *texture, const core::rect< s32 > &destRect, const core::rect< s32 > &sourceRect, const core::rect< s32 > *clipRect=0, const video::SColor *const colors=0, bool useAlphaChannelOfTexture=false)
I created a rectangular mesh, textured it with my texture, pointed a camera at it, and set the mesh close enough so that it fills the entire screen. I doubt the practicality of this if you need to do it multiple times, but since I'm making a display that will take up the entire screen, I just need to do it once.jawdy wrote:Can you post how you scaled the texture?