Simon Puente
Simon Puente

Reputation: 491

Can I use OpenGL GLES instead of full OpelGL on desktop?

I want to learn OpenGL to program a game in C language but I am a little confused about which library choose, the intention is to generate a C library with the game logic and using Android NDK to interface with the resources in phones.

I found an example that use GLESv2 library and this works well, I think I know that the GLES library was created because mobile devices can't use full OpenGL library.

but the real question is: Is GLES a subset of full OpelGL library in order that I can build and run my game app using GLES library on linux desktop?

Can you give me a clue if I'm going the right way with these library?

Upvotes: 2

Views: 4952

Answers (2)

Columbo
Columbo

Reputation: 6766

Is GLES a subset of full OpelGL library in order that I can build and run my game app using GLES library on linux desktop?

No, it is not. OpenGLES is a separate spec.

That said, it's very close to being a subset of OpenGL. It would be a perfectly sensible approach to have shared OpenGL code that you compile into both your Linux and Android executables. You'd have to be careful to only use functionality supported by OpenGLES and you might find you need the odd #if to account for slight differences in the APIs, but 95%+ of the code could work across both APIs.

The alternative is to use the OpenGLES API on desktop. gzh's answer implies that Linux ships with GLES which would make life easy. But if it doesn't you could look at tools like PowerVR's emulator (pvrvframe) or Mali's emulator. My only experience is using pvrvframe on Windows, which worked very well for us - performance was noticeably worse than non-emulated codepaths, but it still managed to run a demanding mobile game at playable framerates.

Upvotes: 6

gzh
gzh

Reputation: 3596

This depends on which OpenGL library you linked to your application. For OpenGL, you should link with libGL.so, but for OpenGLESv2, you should link with libGLESv2.so.

To use OpenGL:

 header file directory: /usr/include/GL
 library file: /usr/lib/libGL.so

To use OpenGLESv2:

 header file directory: /usr/include/GLES2
 library file: /usr/lib/libGLESvs.so

By the way, according to Andriod Dashboards, at present, above 60% android devices have converted to using OpenGLES v3.x. Maybe you'd better give a try to OpenGLES v3.x.

Upvotes: 3

Related Questions