views:

181

answers:

1

I'm developing on a Droid, version 2.1-update1. My supported GL extensions include GL_OES_point_sprite and GL_OES_point_size_array.

I am unable to get point sprites to render. The code below throws UnsupportedOperationException from GLWrapperBase at the glTexEnvi call. If I disable textures and comment out the glTexEnvi all, it throws the same exception further down, at glPointSizePointerOES().

Are point sprites properly supported in Android? Has anyone gotten them working? Or is there an issue with my code below?

// Note that gl is cast to GL11
gl.glEnable(GL11.GL_TEXTURE_2D);
gl.glEnable(GL11.GL_BLEND);
gl.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
gl.glDepthMask(false);
gl.glEnable(GL11.GL_POINT_SPRITE_OES);
gl.glTexEnvi( GL11.GL_POINT_SPRITE_OES, GL11.GL_COORD_REPLACE_OES, GL11.GL_TRUE );  
gl.glEnableClientState(GL11.GL_VERTEX_ARRAY);
gl.glVertexPointer(2, GL11.GL_SHORT, 0, .vertBuffer);
gl.glEnableClientState(GL11.GL_POINT_SIZE_ARRAY_OES);
gl.glPointSizePointerOES(GL11.GL_FLOAT, 0, pointSizeBuffer);

Thanks

+1  A: 

I got this working, here is my draw function

Initialize everything

    gl.glEnable(GL10.GL_TEXTURE);
    TextureManager.activateTexture(gl, R.drawable.water1); //Don't look for this, it's not public api, just looks upd texture id for android resource if loaded, and then activates it. it's the gl.glBindTexture() call replacement
    gl.glEnable(GL11.GL_POINT_SPRITE_OES);
    gl.glEnableClientState(GL11.GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES);
    gl.glEnableClientState(GL11.GL_POINT_SIZE_ARRAY_OES);       
    gl.glEnableClientState(GL11.GL_POINT_SPRITE_OES);
    gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);

Set the texture environment up to use point sprites

    gl.glTexEnvf(GL11.GL_POINT_SPRITE_OES, GL11.GL_COORD_REPLACE_OES, GL11.GL_TRUE);

Set up pointers to the data (First array is 2d laid out [x,y,x2,y2,...] second is 1d [s1,s2,..])

    gl.glVertexPointer(2,GL11.GL_FLOAT,0,PosData);              
    ((GL11)(gl)).glPointSizePointerOES(GL10.GL_FLOAT, 0, SizeData);

Draw

    gl.glDrawArrays(GL10.GL_POINTS,0,MAX);

Disable stuff

    gl.glDisableClientState(GL11.GL_VERTEX_ARRAY);
    gl.glDisableClientState(GL11.GL_POINT_SIZE_ARRAY_OES);
    gl.glDisableClientState(GL11.GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES);
    gl.glDisableClientState(GL11.GL_POINT_SIZE_ARRAY_OES);      
    gl.glDisable(GL10.GL_TEXTURE);

In my initializer I only have my projection setup and GL_BLEND enabled for blending. I think you would need GL_COLOR_MATERIAL if you wanted to color your sprite.

HaMMeReD