On Fri, Oct 28, 2011 at 7:57 AM, Latimerius <[email protected]> wrote:
> On Thu, Oct 27, 2011 at 8:38 PM, John Davis <[email protected]> wrote:
>> That is what I kind of what I tried to do (I used GL_VERTEX_ARRAY,
>> INDEX_ARRAY was not there.):
>
> That's correct, sorry, I got distracted. GL_INDEX_ARRAY is a different thing.
>
>> Using this as a guide:
>> http://www.songho.ca/opengl/gl_vertexarray.html
>>
>> public void draw(GL10 gl) {
>> //
>> http://pyopengl.sourceforge.net/documentation/ref/gl/vertexpointer.html
>> gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
>> gl.glVertexPointer(3, GL10.GL_FLOAT, 0, mVertexBuffer);
>> gl.glDrawElements(GL10.GL_TRIANGLES, 24, GL10.GL_FIXED,
>> mIndicesBuffer); // mode, count, type, indices
>> gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);
>> }
>>
>> It did not display anything though.
>
> This looks OK overall, just try using 36 for the count argument and
> GL_UNSIGNED_BYTE/GL_UNSIGNED_SHORT for the type argument of
> glDrawElements().
>
> Also, your draw function doesn't seem to use colouring nor texturing -
> make sure you at least have a glColor() call somewhere prior to
> draw(), or a colour array, or texturing set up.
>
SOLVED:
Hello Again Latimerius,
It finally works. Its trying to look at all the docs and have to
translate them into the proper semantics. ie. docs which use glut,
docs which use pure opengl , docs in 2.0 spec, etc. One doc on 1.0
showed using a glIndexPointer which was possibly a color index.
Anyway after much trial an error I finally got it when I turned on
OpenGL debugging. It put the result of the gl calls in the LogCat
output. There I could see that it was not interpetatiing the array
correctly for the indexes.
Never the less, here is the result which works. It has the extra
benefit of adding in colors for each face.
public void draw(GL10 gl) {
gl.glVertexPointer(3, GL10.GL_FLOAT, 0, mVertexBuffer);
gl.glColorPointer(4, GL10.GL_FLOAT, 0, mColorsBuffer);
// Enable color tracking
gl.glEnable(GL10.GL_COLOR_MATERIAL);
gl.glDrawElements(GL10.GL_TRIANGLES, myoffsets.length,
GL10.GL_UNSIGNED_SHORT, mIndicesBuffer); // mode, count, type, indices
}
Thanks again for your help.
--
John F. Davis
独树一帜
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en