Hi there,
As I'm still trying to run the CCMutableTexture ripple filter effect, I am also making a port of ripple from 1993. As far as I've tried, it compiles and run without warning or errors... but stilles, nothing shows up... the fps should be great !
The port is quiet "easy" as it is already prepared for openGLES.
Here is the snippet code,
-(void) initGL{
glPixelStorei ( GL_UNPACK_ALIGNMENT, 1 );
glClearColor ( 0.0f, 0.0f, 0.25f, 1.0f );
glShadeModel ( GL_SMOOTH );
glDisable ( GL_CULL_FACE );
// ask director the the window size
CGSize winSize = [[CCDirector sharedDirector] winSize];
image = [CCSprite node];
[image setPosition:ccp(winSize.width/2, winSize.height/2)];
//asign pixelData from loaded image
[CCTexture2D setDefaultAlphaPixelFormat:kCCTexture2DPixelFormat_RGBA8888];
ripTexture_ = [[CCTexture2DMutable alloc] initWithImage:[UIImage imageNamed:@"image.jpg"]];
ccColor4B* pixels = ripTexture_.texData;
glGenTextures ( 1, &idImg );
glEnable ( GL_TEXTURE_2D );
glBindTexture ( GL_TEXTURE_2D , idImg );
glTexImage2D ( GL_TEXTURE_2D , 0, GL_RGB, TEXTURE_WIDTH, TEXTURE_HEIGHT, 0, GL_RGB, GL_UNSIGNED_BYTE, pixels );
glTexParameteri ( GL_TEXTURE_2D , GL_TEXTURE_MAG_FILTER, GL_LINEAR );
glTexParameteri ( GL_TEXTURE_2D , GL_TEXTURE_MIN_FILTER, GL_LINEAR );
glTexParameteri ( GL_TEXTURE_2D , GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
glTexParameteri ( GL_TEXTURE_2D , GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
//free image ???
[self addChild:image];
NSLog(@"initGL end");
}
-(void) draw
{
glClear ( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
CGSize s = [[CCDirector sharedDirector] winSize];
/* glMatrixMode( GL_PROJECTION );
glLoadIdentity();
glOrthox( f2vt( -0.5f ), f2vt( gscry + 0.5f ), f2vt( -0.5f ), f2vt( gscrx + 0.5f ), f2vt( CLIP_NEAR ), f2vt( CLIP_FAR ) );
glMatrixMode( GL_MODELVIEW );
glLoadIdentity();
*/
// draw a simple line
// The default state is:
// Line Width: 1
// color: 255,255,255,255 (white, non-transparent)
// Anti-Aliased
glEnable(GL_LINE_SMOOTH);
ccDrawLine( ccp(0, 0), ccp(s.width, s.height) );
// line: color, width, aliased
// glLineWidth > 1 and GL_LINE_SMOOTH are not compatible
// GL_SMOOTH_LINE_WIDTH_RANGE = (1,1) on iPhone
glDisable(GL_LINE_SMOOTH);
glLineWidth( 5.0f );
glColor4ub(255,0,0,255);
ccDrawLine( ccp(0, s.height), ccp(s.width, 0) );
// TIP:
// If you are going to use always the same color or width, you don't
// need to call it before every draw
//
// Remember: OpenGL is a state-machine.
// draw big point in the center
glPointSize(64);
glColor4ub(0,0,255,128);
ccDrawPoint( ccp(s.width / 2, s.height / 2) );
// draw 4 small points
CGPoint points[] = { ccp(60,60), ccp(70,70), ccp(60,70), ccp(70,60) };
glPointSize(4);
glColor4ub(0,255,255,255);
ccDrawPoints( points, 4);
// restore original values
glLineWidth(1);
glColor4ub(255,255,255,255);
glPointSize(1);
[self ripple_redraw];
glFlush ( );
}
/* Draw the next frame of animation. */
-(void)ripple_redraw{
CGSize winSize = [[CCDirector sharedDirector] winSize];
glScissor ( 0, 0, winSize.width, winSize.height );
glEnable(GL_SCISSOR_TEST);
glDisable( GL_DEPTH_TEST );
glLoadIdentity();
glEnableClientState( GL_VERTEX_ARRAY );
glEnableClientState( GL_TEXTURE_COORD_ARRAY );
glVertexPointer ( 2, GL_FLOAT, sizeof( struct Ripple_VERTEX ), ripple_vertex[0][0].x );
glTexCoordPointer( 2, GL_FLOAT, sizeof( struct Ripple_VERTEX ), ripple_vertex[0][0].t );
glDrawElements ( GL_TRIANGLES, GRID_SIZE_X * GRID_SIZE_Y * 6, GL_UNSIGNED_SHORT, ripple_Indices );
glDisableClientState( GL_VERTEX_ARRAY );
glDisableClientState( GL_TEXTURE_COORD_ARRAY );
glEnable( GL_DEPTH_TEST );
glDisable(GL_SCISSOR_TEST);
[image setTexture:ripTexture_];
[image setTextureRect:CGRectMake(0, 0, ripTexture_.contentSize.width, ripTexture_.contentSize.height)];
}
full source si here (available for 4 days) :
http://demo.ovh.net/fr/e854460f75a2bdf20015f645b3f0d17f/
If anyone got time to try it.... I'm getting kind of stuck...
Thanks


