1

I am attempting to make some kind of OpenGL wrapper that can be used on both PC and on Android.

My approach is to have some kind of Abstract OpenGL class with all OpenGL functions and then extend that class with a specialized one for each platform. However, there seem to be no way to do this on Android as you need a GL10 object that only can be get from functions such as onDrawFrame() and so on. You cannot save that GL10 object and use that in my Android GL class that extends Abstract OpenGL. If I try, nothing will be rendered, I have no idea why.

So are there any work around for this? If an OpenGL function are being called in Android GL class I need to have some way to do all the calls in the onDrawFrame() in the renderer class.

1
  • You need to make the abstraction in a way that all actual OpenGL calls are done in the platform-specific subclass. For example, make an abstract blit method, the PC subclass uses calls such as glBindTexture and the Android subclass uses gl.glBindTexture, with the GL10 object gl as subclass variable which you set as first thing in each onDrawFrame(). Can be done without problem, only you will have quite a bit of redundant code. Commented Jan 8, 2014 at 13:06

2 Answers 2

4

You can consider using libgdx engine if you need your OpenGL app run both on PC and Android device. That's more reasonable than creating own wrappers.

Sign up to request clarification or add additional context in comments.

2 Comments

+1 libgdx, I've used this in the past and it works great. You can also deploy it as a java applet in a web browser.
Yea, I guess that does it. I do not like how they are calling it for game engine through.
1

jPCT is another good option. Java-Based and supports PC and Android.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.