I have worked this out!

So for anyone who's interested:

When I removed gl.glEnableClientState(GL10.GL_COLOR_ARRAY); from the
code, it started working on the device, as well as continuing to work
on the emulator. When I put it back in we only get coloured shapes in
the emulator, and not on the device.

Does anyone know why there is this inconsistency? Is it a bug in the
sdk? Or a lack of understanding on my part?

Cheers,
Nilz.

On 26 May, 22:45, Nilz <nilz.v.pa...@gmail.com> wrote:
> Hi There!
>
> After spending the better half of this day getting my HTC Magic to
> work in developer mode, I've now found that some of my frist openGL
> coding attempts that appeared to work fine in the emulator doesn't
> work as expected on the device. I've narrowed this down to glColorf(r,
> g, b, a) not working as expected on the device itself. The provided
> OpenGL samples do work though.
>
> So for example, after modifying Cube.java from the samples to the
> below code I find that I get the expected grey square on the emulator
> but a blank white screen (background fill colour) on the device.
>
> class Cube
> {
>     public Cube()
>     {
>         int one = 0x10000;
>         int vertices[] = {
>                         -one, -one,
>                         -one, one,
>                         one, -one,
>                         one, one,
>         };
>
>         // Buffers to be passed to gl*Pointer() functions
>         // must be direct, i.e., they must be placed on the
>         // native heap where the garbage collector cannot
>         // move them.
>         //
>         // Buffers with multi-byte datatypes (e.g., short, int, float)
>         // must have their byte order set to native order
>
>         ByteBuffer vbb = ByteBuffer.allocateDirect(vertices.length*4);
>         vbb.order(ByteOrder.nativeOrder());
>         mVertexBuffer = vbb.asIntBuffer();
>         mVertexBuffer.put(vertices);
>         mVertexBuffer.position(0);
>     }
>
>     public void draw(GL10 gl)
>     {
>         gl.glFrontFace(GL10.GL_CW);
>         gl.glVertexPointer(2, gl.GL_FIXED, 0, mVertexBuffer);
>         gl.glColor4f(0.5f, 0.5f, 0.5f, 0.5f);
>         gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 0, 4);
>     }
>
>     private IntBuffer   mVertexBuffer;
>
> }
>
> I'm using the latest 1.5 SDK, and my device is the HTC Magic running
> firmware version 1.5.
>
> Can anyone explain to me why when switching from colour buffers and
> using glDrawElements to glColorf and glDrawArrays, stops shapes from
> being coloured in?
>
> Cheers,Nilz.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to