Friday, March 26, 2010

Progress!

Well, after midterms and some other tough schoolwork, we've finally made some progress on DroidViz.


Most notably, the vector fields are now rendering in fullscreen. In the fluidsolver project referenced earlier, the window's bottom corner is (1,1) and the top opposite corner is (0,0). For some reason, the default window size in GLES on the android is from -1 to 1, with (0,0) directly in the center of the window. After adjusting our calculations, we now have things rendering in fullscreen.

Most importantly, the code in svn now compiles and runs. We were running this code in a separate project hosted elsewhere until we could get our stuff together. I've just spent the last few hours cleaning up the Google Code SVN, formatting code, porting stuff, etc. Things are finally current on the SVN. Feel free to check it out if you want.

Most exciting, Google has just released the NDK, revision 3. With this release, we now have access to OpenGL ES 2.0, and with that - FRAGMENT AND VERTEX SHADERS. OMFG. We'll be able to make droidViz DROP DEAD GORGEOUS. We're pretty psyched here, so we'll be spending more time on development to get this out sooner than later.

Keep it real,

-Griff

Thursday, March 11, 2010

F*** YEAH SEAKING


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