Sign in to follow this  
Skyy

OpenGL [OpenGL ES] Rendering vertices work on emulator but not on actual phone.

Recommended Posts

Hi everybody. I'm currently working on a game for Android phone using OpenGL ES. The only problem I'm currently having is the rendering of the vertices. When I render everything and run the game on emulator to emulate Android 1.5 or 1.6 platform the game works like a wonder and everything runs swell. But when I upload the game to my own phone which runs Android 1.5(HTC Hero) and the vertices don't appear on screen anymore. Any ideas what's going on? Code is roughly as follows:
                // VERTICE SETUP IN INIT
		int one = 65536;
		int half = one / 2;
		int vertices[] = {
		// FRONT
		-half, -half, half, half, -half, half,
		-half, half, half, half, half, half
		}

		ByteBuffer vbb = ByteBuffer.allocateDirect(vertices.length * 4);
		vbb.order(ByteOrder.nativeOrder());
		mVertexBuffer = vbb.asIntBuffer();
		mVertexBuffer.put(vertices);
		mVertexBuffer.position(0);



		// THE ACTUAL RENDERING
		gl.glVertexPointer(3, GL10.GL_FIXED, 0, mVertexBuffer);
		gl.glColor4f(1, 0, 0, 1);
		gl.glScalef(50, 50, 1);
		gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 0, 4);
I have tried using glDrawArrays() too and they work on the emulator too but not on the actual phone. What's going on? If it matters at all, I'm using 2D projection via GLU.gluOrtho2D() to match the world coordinates to screen coordinates. I'm pretty much lost with this one. I mean.. I'm emulating the 1.5 Android with the Android SDKs emulator and it should be the same thing as the actual device but when I upload it to my HTC Hero 1.5 it just... does not work. The program starts and all other stuff works but rendering of vertices does not work, the gl.glClear() command works fine. It clears the screen to given colour but it just does not render the vertices. Anyone got any tips what to try or what might be wrong? Cheers. [Edited by - Skyy on November 8, 2009 6:01:14 PM]

Share this post


Link to post
Share on other sites
try anything else than GL_TRIANGLE_STRIP.
Just in case, have you enabled the vtx/color-arrays?
Android's GL implementations are more of a mine-field than most phones, I've seen even basics of basics failing miserably there ...
There's usually at least one usage-path that works correctly, so try to find it. And meanwhile do post bug-reports (which may get fixed in a new firmware after a few months ...)

(Welcome to my dev-world :( )

Share this post


Link to post
Share on other sites
Haha, thank you. :) I'm enjoying the development so far, it's a bit annoying but once I nail the "one and correct" road it should be .. well, maybe not a smooth ride but some what enjoyable road. And I will do more tests based on your tip and see what happens and report back.

I have enabled the vertex and texture arrays. Currently only using vertex arrays since I haven't gone through the trouble of bringing in the sprites just yet since my phone doesn't even like the vertices so... But it's strange that it works perfectly fine on the emulator.

But yeah, going to try that out what you suggested later when I get back home.
If anyone has more tips what to do / try out, I'm open for them.

Cheers.


// Skyy

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this