Well, we finally have something interesting rendering!
We are running un-optimized fluid code (read: using floating point numbers (eew) ) on the android, and we're able to render a simple vector field. YAY!
The changes needed for Jos Stam's code were simple. Instead of using GL in immediate mode, we needed to give GL ES a vertex array and tell it how many entries within this vertex array to render.
CODE:
static void draw_velocity ( void )
{
int i, j, k;
float x, y, h;
h = 1.0f/N;
// This Disable Client State is not needed every frame. (OPTIMIZATION)
glDisableClientState( GL_COLOR_ARRAY );
glColor4f ( 1.0f, 1.0f, 1.0f, 1.0f );
glLineWidth ( 1.0f );
// An index for the vertex array
k = 0;
// Update the vert array
for ( i=1 ; i<=N ; i++ ) {
x = (i-0.5f)*h;
for ( j=1 ; j<=N ; j++ ) {
y = (j-0.5f)*h;
line_verts[k++] = x;
line_verts[k++] = y;
line_verts[k++] = x+u[IX(i,j)];
line_verts[k++] = y+v[IX(i,j)];
}
}
// Draw the new array
glVertexPointer( 2, GL_FLOAT, 0, line_verts );
glDrawArrays( GL_LINES, 0, ( N * N * 4 ) );
}
Because input will be coming from the touch screen, we need to figure out how to handle this at the NDK level, or simply pass it in to the NDK level from the Java level. Currently, we're just setting the input variables at compile time. This is producing good results.
Unfortunately, the algorithm is not stable. I blame the floating point numbers, but this remains to be seen. We'll be investigating in deeper detail later.
This code will be uploaded to SVN within a day or two (intermittent internet connection problems ahoy...)
-Griff
No comments:
Post a Comment