I have with me an iOS app for iPad which creates a few fire simulations over a png.Well,its working well exactly how we wanted it but when we are testing it on a device,we get an extra fire simulation.Heres the screen:
iPad Simulator:
iPad Device:
EDIT:
Thanks for your responses.I hoped that the response here wouldn't be strong enough so i didn't place the code previously.Apologies.
This is a snippet from my FireplacesAnimation.m which is responsible for generating the emitter
-(ParticleEmitter *)generateParticle
{
Texture *particleTexture = [[Texture alloc] initWithName:@"particle.png"];
return [[ParticleEmitter alloc] initParticleEmitterWithTexture:particleTexture
position:Vector2fMake(0, 0)
sourcePositionVariance:Vector2fMake(100, 10)
speed:5.25f
speedVariance:0.2f
particleLifeSpan:0.75f
particleLifespanVariance:0.25f
angle:90.0f
angleVariance:0
gravity:Vector2fMake(0.0f, 0.5f)
startColor:Color4fMake(1.0f, 0.0f, 0.0f, 1.0f)
startColorVariance:Color4fMake(0.2f, 0.2f, 0.2f, 1.0f)
finishColor:Color4fMake(1.0f, 1.0f, 0.3f, 0.0f)
finishColorVariance:Color4fMake(0.4f, 0.4f, 0.4f, 0.0f)
maxParticles:500
particleSize:20
particleSizeVariance:50
duration:500.0f
blendAdditive:YES];}
and i am using the following code to create the frame buffer:
(BOOL)createFramebuffer {
glGenFramebuffersOES(1, &viewFramebuffer);
glGenRenderbuffersOES(1, &viewRenderbuffer);
glBindFramebufferOES(GL_FRAMEBUFFER_OES, viewFramebuffer);
glBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderbuffer);
[context renderbufferStorage:GL_RENDERBUFFER_OES fromDrawable:(CAEAGLLayer*)self.layer];
glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, GL_RENDERBUFFER_OES, viewRenderbuffer);
glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_WIDTH_OES, &backingWidth);
glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_HEIGHT_OES, &backingHeight);
if (USE_DEPTH_BUFFER) {
glGenRenderbuffersOES(1, &depthRenderbuffer);
glBindRenderbufferOES(GL_RENDERBUFFER_OES, depthRenderbuffer);
glRenderbufferStorageOES(GL_RENDERBUFFER_OES, GL_DEPTH_COMPONENT16_OES, backingWidth, backingHeight);
glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_DEPTH_ATTACHMENT_OES, GL_RENDERBUFFER_OES, depthRenderbuffer);
}
if(glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES) != GL_FRAMEBUFFER_COMPLETE_OES) {
NSLog(@"failed to make complete framebuffer object %x", glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES));
return NO;
}
return YES;
}
aand.. drawview:
(void)drawView {
if(fireStopcount > 75){
self.alpha = 1.0;
static BOOL viewInitialized = NO;
static CFTimeInterval lastTime;
CFTimeInterval time;
time = CFAbsoluteTimeGetCurrent();
float delta = (time - lastTime);
lastTime = time;
// Replace the implementation of this method to do your own custom drawing
[explosion1 update:delta];
[explosion2 update:delta];
[explosion3 update:delta];
[EAGLContext setCurrentContext:context];
//NSLog(@"Draw Animation Fire Places View");
glBindFramebufferOES(GL_FRAMEBUFFER_OES, viewFramebuffer);
if(!viewInitialized)
{
//viewInitialized = YES;
glViewport(0, 0, backingWidth, backingHeight);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrthof(0.0f, 320.0f, 0.0f, 480.0f, -100.0f, 100.0f);
glMatrixMode(GL_MODELVIEW);
glDisable(GL_DEPTH_TEST);
glEnable(GL_TEXTURE_2D);
glEnable(GL_BLEND);
}
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glClear(GL_COLOR_BUFFER_BIT);
if(explosion1.active != YES)
{
explosion1.angle = 90.0f;
explosion1.particleSize = 20.0f;
explosion1.sourcePosition = [self firstFirePlacePoint];
explosion1.active = YES;
explosion1.duration = rand() % 2 + 1;
explosion1.sourcePositionVariance = Vector2fMake(20,20);
}
if(explosion2.active != YES)
{
explosion2.angle = 90.0f;
explosion2.sourcePosition = [self secondFirePlacePoint];
explosion2.active = YES;
explosion2.duration = rand() % 2 + 1;
explosion2.sourcePositionVariance = Vector2fMake(20,20);
}
if(explosion3.active != YES)
{
explosion3.angle = 90.0f;
explosion3.sourcePosition = [self thirdFirePlacePoint];
explosion3.active = YES;
explosion3.duration = rand() % 2 + 1;
explosion3.sourcePositionVariance = Vector2fMake(20,20);
}
[explosion1 renderParticles];
[explosion2 renderParticles];
[explosion3 renderParticles];
glBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderbuffer);
[context presentRenderbuffer:GL_RENDERBUFFER_OES];
}
else
{
fireStopcount++;
}}
Thanks for your time guys.