Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 04-08-2010, 05:36 AM   #9 (permalink)
Johanovski
Divine avenger
 
Johanovski's Avatar
 
Join Date: Nov 2009
Location: Vic, Catalunya (Spain)
Posts: 320
Johanovski is on a distinguished road
Default

Hi Mr Jack!

I've changed something in my code to stop enabling / disabling things each time a image is drawn and I've grouped those functions at the start and finish of the renderScene method, so now I have this:

Code:
-(void)renderScene
{
	[EAGLContext setCurrentContext:context];
			
	glBindFramebufferOES(GL_FRAMEBUFFER_OES, viewFramebuffer);
	glViewport(0, 0, backingWidth, backingHeight);
			
	// Clear screen
	glClear(GL_COLOR_BUFFER_BIT);

        glEnableClientState(GL_TEXTURE_COORD_ARRAY);
			
	// Enable Texture_2D
	glEnable(GL_TEXTURE_2D);

        // Assuming OpenGL is now initialized, here goes all draw methods...
        (... draw backgrounds and all game elements here with the "renderAtPoint" method...)

	glDisable(GL_TEXTURE_2D);
	glDisableClientState(GL_TEXTURE_COORD_ARRAY);
			
	glBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderbuffer);
	[context presentRenderbuffer:GL_RENDERBUFFER_OES];
}

- (void)renderAt:(CGPoint)point texCoords:(GLfloat[])texCoords quadVertices:(GLfloat[])quadVertices{
	glPushMatrix();
	glTranslatef(point.x, point.y, 0.0f);
	glRotatef(-rotation, 0.0f, 0.0f, 1.0f);
	glScalef(scale, scale, 1.0f);

	glColor4f(colourFilter[0], colourFilter[1], colourFilter[2], colourFilter[3]);
	
	glBindTexture(GL_TEXTURE_2D, [texture name]);	
	glVertexPointer(2, GL_FLOAT, 0, quadVertices);
	glTexCoordPointer(2, GL_FLOAT, 0, texCoords);
	
        // Only enable blending if the image have transparencies
	if (!noTransparent) {
		glEnable(GL_BLEND);
	}		

	glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
	
	if (!noTransparent) {
		glDisable(GL_BLEND);
	}	

	glPopMatrix();
}
Is this what you're meaning? Sorry but I don't know much about OpenGl...
Maybe the "glPushMatrix" and the "glPopMatrix" shouldn't be called for each image?

Thanks!
Johanovski is offline   Reply With Quote
 

» Advertisements
» Online Users: 404
12 members and 392 guests
baja_yu, chemistry, Farfalo, garticle, GraffitiCircus, greeneye82, hussain1982, iconomania, SLIC, stanny, zhijianhi
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,556
Threads: 94,079
Posts: 402,739
Top Poster: BrianSlick (7,990)
Welcome to our newest member, wfarun2012
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 08:28 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.