Hi everybody,
Currently, I am making a simple Irrlicht application on iPhone. My application has two windows. The first window display some objects using Irrlicht library and the second window displays an image. Since I would like to see the second windows as the background of objects (on the first windows) then I have implemented as followings:
- Place the first window in front of the second window so that we always see the first window.
- Set "backgroundColor" of first "window" and "glView" to "clearColor".
- Set the background of Irrlicht to transparent by using code:
driver->beginScene(true, true, SColor(0,0,0,0));
But when running application, I can not see the background on the second windows.
If I use OpenGL ES to draw objects directly on the first windows instead of using IrrLicht rendering, I can easily see the image on the second window.
does anybody have experience on this problem?
Any comment would be appreciated.
Thanks in advance.
PS: very sorry for my bad english
Transparent background does not work on iPhone
-
- Posts: 4
- Joined: Sat Jul 03, 2010 9:47 am
-
- Admin
- Posts: 14143
- Joined: Wed Apr 19, 2006 9:20 pm
- Location: Oldenburg(Oldb), Germany
- Contact:
Ok, in order to collect all the previous replies in one clear comment:
Transparent backgrounds are pretty OS-specific things. I'm pretty sure that none of our current device implementations support this, although I already added the 'alpha' flag in device creation for this purpose.
If you can provide some code how to get a transparent background in an iPhone app I could add this to the current device code.
Transparent backgrounds are pretty OS-specific things. I'm pretty sure that none of our current device implementations support this, although I already added the 'alpha' flag in device creation for this purpose.
If you can provide some code how to get a transparent background in an iPhone app I could add this to the current device code.
Re: Transparent background does not work on iPhone
Hi,
I have the same problem
My all code:
Obs 1: I tried use the color "255,0,0,0" and "0,0,0,0", but no success.
Obs 2: "self.containerView" is a view inside UIViewController->view. Because i will show behind a camera image and button. So i need a view for the irrlicht be in front of button and camera image.
SEE THE RESULT:
I have the same problem
My all code:
Code: Select all
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (IBAction)onStartClick:(id)sender
{
ImageTargetsViewController *vc = [[ImageTargetsViewController alloc] init];
[self presentViewController:vc animated:YES completion:nil];
}
-(void) viewWillAppear:(BOOL)a_animated
{
[super viewWillAppear:a_animated];
void *viewPtr = (__bridge_retained void*)(self.containerView);
[self.containerView setBackgroundColor:[UIColor clearColor]];
SIrrlichtCreationParameters params;
params.DriverType = video::EDT_OGLES1;
params.WindowSize = core::dimension2d<u32>(self.containerView.frame.size.width, self.containerView.frame.size.height);
params.WindowId = viewPtr;
params.Bits = 32;
m_pDevice = createDeviceEx( (const SIrrlichtCreationParameters)params ) ;
if( ! m_pDevice ) return ;
NSString* oBunPath = [ [NSBundle mainBundle] bundlePath ] ;
m_pDevice->getFileSystem()->changeWorkingDirectoryTo( [oBunPath cStringUsingEncoding:NSASCIIStringEncoding] ) ;
IVideoDriver* driver = m_pDevice->getVideoDriver() ;
ISceneManager* smgr = m_pDevice->getSceneManager() ;
IAnimatedMesh* mesh = smgr->getMesh( "Assets/sydney.md2" ) ;
if( ! mesh ) return ;
IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode( mesh );
if( node )
{
node->setMaterialFlag(EMF_LIGHTING, false);
node->setMD2Animation(scene::EMAT_STAND);
ITexture* pTex = driver->getTexture( "Assets/sydney.png" );
node->setMaterialTexture( 0, pTex );
}
smgr->addCameraSceneNode( 0, vector3df(0,30,-100), vector3df(0,5,0) ) ;
// iOS timer.
m_oDispLnk = [ [UIScreen mainScreen] displayLinkWithTarget:self selector:@selector(updateDisplay) ] ;
[ m_oDispLnk addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSRunLoopCommonModes ] ;
}
-(void) updateDisplay
{
m_pDevice->run() ;
m_pDevice->getVideoDriver()->beginScene( true, true, SColor(0,0,0,0) ) ;
m_pDevice->getSceneManager()->drawAll() ;
//m_pDevice->getGUIEnvironment()->drawAll() ;
m_pDevice->getVideoDriver()->endScene();
}
-(void) viewDidDisappear:(BOOL)a_animated
{
[super viewDidDisappear:a_animated];
if( m_oDispLnk != nil )
[ m_oDispLnk invalidate ] ;
if( m_oDispLnk != NULL )
m_pDevice->drop();
}
Obs 2: "self.containerView" is a view inside UIViewController->view. Because i will show behind a camera image and button. So i need a view for the irrlicht be in front of button and camera image.
SEE THE RESULT:
Re: Transparent background does not work on iPhone
You can try this:
Code: Select all
viewPtr.opaque = NO;
viewPtr.backgroundColor = [UIColor clearColor];
Library helping with network requests, tasks management, logger etc in desktop and mobile apps: https://github.com/GrupaPracuj/hermes
Re: Transparent background does not work on iPhone
Can anyone help us?
I have tried a new code, but no success:
I have tried a new code, but no success:
Code: Select all
self.containerView = [[UIView alloc] initWithFrame:self.view.frame];
[self.view addSubview:self.containerView];
self.containerView.backgroundColor = [UIColor clearColor];
self.containerView.opaque = NO;
self.containerView.clearsContextBeforeDrawing=YES;
void *viewPtr = (__bridge_retained void*)(self.containerView);
SIrrlichtCreationParameters params;
params.DriverType = video::EDT_OGLES1;
params.WindowSize = core::dimension2d<u32>(self.containerView.frame.size.width, self.containerView.frame.size.height);
params.WindowId = viewPtr;
params.Bits = 32;
Re: Transparent background does not work on iPhone
I can try to find a solution for this problem after sunday (+fix Irrlicht if bug related to this issue exist in an engine).
Library helping with network requests, tasks management, logger etc in desktop and mobile apps: https://github.com/GrupaPracuj/hermes