Using texture as background image , IOS env

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
gil.hadas
Posts: 7
Joined: Tue Feb 11, 2014 10:56 am

Using texture as background image , IOS env

Post by gil.hadas »

I am developing IOS application that use the camera picture.
I want to use it as a background image, what is the best way to do it?
All my attempt to load it as not PO2 with addTexture failed.
this code that did work was by converting to PO2:
core::stringc filename(cfilename); //fname is the file from which IImage will be created

IImage *tempImg = driver->createImage(ECF_A8R8G8B8,core::dimension2d<u32>(1024,1024));
IImage *image = driver->createImageFromFile(filename);

image->copyToScaling(tempImg); //I scale the image to 512x512 in this way


if(!driver->findTexture(filename))
m_pTexture = driver->addTexture(filename, tempImg);
else
m_pTexture = driver->getTexture(filename);

any Idea?
Gil
vivekSivamRP
Posts: 66
Joined: Sat Sep 29, 2012 11:58 am

Re: Using texture as background image , IOS env

Post by vivekSivamRP »

use 2d planes.
Last edited by vivekSivamRP on Tue Feb 11, 2014 4:48 pm, edited 1 time in total.
vivekSivamRP
Posts: 66
Joined: Sat Sep 29, 2012 11:58 am

Re: Using texture as background image , IOS env

Post by vivekSivamRP »

Use 2d planes, it's easy with irrlicth's in built functions,

for ex,

Code: Select all

 
IMesh* twoDMesh = smgr->getGeometryCreator()->createPlaneMesh(tileSize);  // creats 2d plane Mesh
IMeshSceneNode* node = smgr->addMeshSceneNode(twoDMesh); // get sceneNode for mesh
node->setScale(vector3df(1.0));   // fix your scale
node->setMaterialTexture(0,YourBG); /// Finally set ur camera's picture to the node
 
Place the node as your wish.
gil.hadas
Posts: 7
Joined: Tue Feb 11, 2014 10:56 am

Re: Using texture as background image , IOS env

Post by gil.hadas »

Thanks for your quick answer,
I tried this code on the Hello world sample but still I don't see the texture.
can you send mea sample code that works for you?
Thanks
vivekSivamRP
Posts: 66
Joined: Sat Sep 29, 2012 11:58 am

Re: Using texture as background image , IOS env

Post by vivekSivamRP »

that's the sample code. it's not possible to load nonPowerOf_2_texture in ios. you convert the texture to power of 2 and set the texture to the 2d plane, then scale the 2d plane as you desired. It's similar to loading nonPowerOf_2_texture.
gil.hadas
Posts: 7
Joined: Tue Feb 11, 2014 10:56 am

Re: Using texture as background image , IOS env

Post by gil.hadas »

Thanks, I'll try to crop and scale the texture.
Maybe I can change irrlicht code not to clear the background image of the view.
gil.hadas
Posts: 7
Joined: Tue Feb 11, 2014 10:56 am

Re: Using texture as background image , IOS env

Post by gil.hadas »

I Found a solution, in displayInitialize of CIrrDeviceiOS I added
view.layer.opaque = NO;
and in COGLES1Driver::beginScene
I use backbuffer flag as follow :
if (backBuffer)
{
const f32 inv = 1.0f / 255.0f;
glClearColor(color.getRed() * inv, color.getGreen() * inv,
color.getBlue() * inv, color.getAlpha() * inv);

mask |= GL_COLOR_BUFFER_BIT;
}
else
{
mask |= GL_COLOR_BUFFER_BIT;
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);

}
that did the job.
Post Reply