OpenGL X, Y axis reference

Tutorials concerning the OpenGL® ES cross-platform API for full-function 2D and 3D graphics on the Google-Android platform.

OpenGL X, Y axis reference

Postby Sheenmue » Fri Aug 28, 2009 7:25 pm

Hi. I was making a game using Canvas and now I am porting the code to OpenGL (yeah, I know, I should have started with OpenGL :) , it was the first game I was making for Android) and everything is working but there is a problem. With OpenGL (x=0, y=0) is bottom/left while with Canvas (x=0, y=0) is top/left and y++ means the opposite in OpenGL. As the game is advanced I would have to change a lot of coordinates in Y-axis so my question is if there is a quick way to change the reference so it's the same that Canvas.

PS.: I'm using the SpriteMethodTest renderer.
Sheenmue
Freshman
Freshman
 
Posts: 2
Joined: Fri Aug 28, 2009 7:15 pm

Top

Postby Emmanuel7 » Sat Aug 29, 2009 12:56 pm

You don't have any trouble with the SpriteMethodTest ?

I've tested it last week, and for some unknown reasons, the bitmapfactory returns bitmaps with -1 height and width.

the canvas method doesn't really mind, because it doesn't use this information, but OpenGl need it to create a texture.


As for your problem, note that you don't have to change every coordinates you use.
Just make a basis transform in the renderer lib !
Emmanuel7
Senior Developer
Senior Developer
 
Posts: 164
Joined: Fri Dec 12, 2008 2:17 am
Location: Paris

Postby Sheenmue » Sat Aug 29, 2009 6:33 pm

I didn't try to compile the app, just used several classes, made some changes and I had a problem while loading the bitmaps, but it was just my fault. You have to consider this code in the loadBitmap method:


protected int loadBitmap(Context context, GL10 gl, int resourceId) {
int textureName = -1;
if (context != null && gl != null) {
..
..
..
}
return textureName;
}


If "context" or "gl" are null the method returns -1, so check those variables aren't null. I had a problem with that but as I said it was my fault.
Sheenmue
Freshman
Freshman
 
Posts: 2
Joined: Fri Aug 28, 2009 7:15 pm

Top

Return to Android 2D/3D Graphics - OpenGL Tutorials

Who is online

Users browsing this forum: No registered users and 2 guests