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 > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 02-02-2011, 12:30 AM   #1 (permalink)
Registered Member
 
Join Date: Feb 2011
Posts: 1
GlennNZ is on a distinguished road
Default Two pass render issue (OpenGL)

I'm trying to do a two pass render by rendering two textured and coloured meshes on top of each other. The textured mesh that is rendered first has no alpha and the second textured mesh has alpha values provided by a colour array (i.e. the texture itself has no alpha values).

I have this working fine on mac (not iOS) but on iPhone only the 2nd textured mesh is visible, as if none of the alpha from the colour array is being applied.

The code is as follows:
Code:
	glEnableClientState(GL_VERTEX_ARRAY);
	glEnableClientState(GL_NORMAL_ARRAY);
	glEnableClientState(GL_TEXTURE_COORD_ARRAY);
	glEnableClientState(GL_COLOR_ARRAY);

	//First pass
	glDisable(GL_BLEND);
	glBlendFunc(GL_ONE, GL_ONE);
	
	glEnable(GL_TEXTURE_2D);
	glBindTexture(GL_TEXTURE_2D, mTexture1);

	glVertexPointer(3, GL_FLOAT, 0, mVertices);
	glNormalPointer(GL_FLOAT, 0, mNormals);	
	glTexCoordPointer(2, GL_FLOAT, 0, mTexCoords);
	glColorPointer(4, GL_FLOAT, 0, mWhite);
	
	glDrawElements(GL_TRIANGLE_STRIP, mNumIndices, GL_UNSIGNED_SHORT, mIndices );

	//Second pass
	glBindTexture(GL_TEXTURE_2D, mTexture2);	
	glDepthFunc(GL_EQUAL);
	
	glEnable(GL_BLEND);
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
	
	glVertexPointer(3, GL_FLOAT, 0, mVertices);
	glNormalPointer(GL_FLOAT, 0, mNormals);	
	glTexCoordPointer(2, GL_FLOAT, 0, mTexCoords);
	glColorPointer(4, GL_FLOAT, 0, colours);
	
	glDrawElements(GL_TRIANGLE_STRIP, mNumIndices, GL_UNSIGNED_SHORT, mIndices );
	
	//Finish up
	glDisableClientState(GL_VERTEX_ARRAY);
	glDisableClientState(GL_NORMAL_ARRAY);
	glDisableClientState(GL_TEXTURE_COORD_ARRAY);	
	glDisableClientState(GL_COLOR_ARRAY);
	
	glDisable(GL_TEXTURE_2D);
	
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
	glDepthFunc(GL_LESS);
So the first mesh rendered is supposedly always being rendered, and the second mesh, which shares the vertices of the first mesh is forced to be visible because the depth testing is set to GL_EQUAL, but why doesn't the blend work?

Does anyone have any ideas?

Thanks.
GlennNZ is offline   Reply With Quote
Reply

Bookmarks

Tags
alpha, opengl, render, texture

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 367
14 members and 353 guests
7twenty7, blasterbr, Clouds, dre, EvilElf, jeroenkeij, jimmyon122, Mah6447, Morrisone, n00b, pungs, Sami Gh, stanny, toon4413
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,667
Threads: 94,121
Posts: 402,900
Top Poster: BrianSlick (7,990)
Welcome to our newest member, host number one
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 03:47 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0