opengl es - VBO's on Android: Pointing out the correct image in texture coordinate buffers -


does know how point out given section of texture buffer array stored in hw buffer? i'm drawing triangle strip , filling square image. in texture have 2 square images next each other, texture coordinate buffer points out them out total of 16 floats.

with software buffers i'm doing access second image in texture:

texturecoordinatebuffer.position(8); gl.gltexcoordpointer(2, gl10.gl_float, 0, texturecoordinatebuffer); 

with hardware buffers assumed this:

// setup hw buffers // ... // select hw buffers gl11.glbindbuffer(gl11.gl_array_buffer,vertexcoordinatebufferindex); gl11.glvertexpointer(3, gl10.gl_float, 0, 0); gl11.glbindbuffer(gl11.gl_array_buffer, texturecoordinatebufferindex);  // point out first image in texture coordinate buffer gl11.gltexcoordpointer(2, gl11.gl_float, 0, 0); // draw // ... 

which works nicely if want point out first image in texture. access second image - assumed in last line:

// point out second image in texture coordinate buffer - doesn't work! gl11.gltexcoordpointer(2, gl11.gl_float, 0, 8); 

but renders scewed , discolored image.

anyone knows how to correctly?

you might want take @ nehe android tutorials. go in detail , show need do.

specifically, lesson looking here: http://insanitydesign.com/wp/projects/nehe-android-ports/

lesson 6

you might not binding , enabling buffers, here's snippet tutorial:

public void draw(gl10 gl) {         //bind our generated texture in case         gl.glbindtexture(gl10.gl_texture_2d, textures[0]);          //point our buffers         gl.glenableclientstate(gl10.gl_vertex_array);         gl.glenableclientstate(gl10.gl_texture_coord_array);          //set face rotation         gl.glfrontface(gl10.gl_ccw);          //enable vertex , texture state         gl.glvertexpointer(3, gl10.gl_float, 0, vertexbuffer);         gl.gltexcoordpointer(2, gl10.gl_float, 0, texturebuffer);          //draw vertices triangles, based on index buffer information         gl.gldrawelements(gl10.gl_triangles, indices.length, gl10.gl_unsigned_byte, indexbuffer);          //disable client state before leaving         gl.gldisableclientstate(gl10.gl_vertex_array);         gl.gldisableclientstate(gl10.gl_texture_coord_array);     } 

credit: insanity design - http://insanitydesign.com/

edit: see you're asking. here's more code should able then. if spritemethodtest app android: http://apps-for-android.googlecode.com/svn/trunk/spritemethodtest

you'll notice chris pruett (the developer of app) shows multitude of ways draw textures screen. below code (i believe) you're looking for.

grid.java

public void begindrawingstrips(gl10 gl, boolean usetexture) {         begindrawing(gl, usetexture);         if (!musehardwarebuffers) {             gl.glvertexpointer(3, mcoordinatetype, 0, mvertexbuffer);              if (usetexture) {                 gl.gltexcoordpointer(2, mcoordinatetype, 0, mtexcoordbuffer);             }           } else {             gl11 gl11 = (gl11)gl;             // draw using hardware buffers             gl11.glbindbuffer(gl11.gl_array_buffer, mvertbufferindex);             gl11.glvertexpointer(3, mcoordinatetype, 0, 0);              gl11.glbindbuffer(gl11.gl_array_buffer, mtexturecoordbufferindex);             gl11.gltexcoordpointer(2, mcoordinatetype, 0, 0);              gl11.glbindbuffer(gl11.gl_element_array_buffer, mindexbufferindex);         }     }      // assumes begindrawingstrips() has been called before this.     public void drawstrip(gl10 gl, boolean usetexture, int startindex, int indexcount) {         int count = indexcount;         if (startindex + indexcount >= mindexcount) {                 count = mindexcount - startindex;         }         if (!musehardwarebuffers) {             gl.gldrawelements(gl10.gl_triangles, count,                     gl10.gl_unsigned_short, mindexbuffer.position(startindex));         } else {                 gl11 gl11 = (gl11)gl;             gl11.gldrawelements(gl11.gl_triangles, count,                     gl11.gl_unsigned_short, startindex * char_size);          }     } 

specifically, you'll want @ code takes false branch of !musehardwarebuffers. suggest @ full grid.java file better representation of how because sets texture pointers , enables opengl start drawing.

on side note: suggest reading chris also: http://www.scribd.com/doc/16917369/writing-real-time-games-for-android

he goes app , found effective way of drawing textures was.


Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -