Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: FireMonkey application which uses OpenGL (ES?) and runs on Android/iOS?


This question is not answered. Helpful answers available: 1. Correct answers available: 1.


Permlink Replies: 9 - Last Post: Nov 26, 2014 12:57 PM Last Post By: David Patte
Joshua Smith

Posts: 5
Registered: 3/25/14
FireMonkey application which uses OpenGL (ES?) and runs on Android/iOS?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 16, 2014 10:34 AM
Hi all,

I am relatively new to both Embarcadero technologies and OpenGL.

My question is, is it possible to create a FireMonkey mobile application that runs on both Android and iOS that uses OpenGL?

I've created a simple FireMonkey HD Desktop application for Windows that uses OpenGL based off of the answer to this question on SO: http://stackoverflow.com/questions/19941859/how-to-render-an-opengl-frame-in-c-builder

But I am not sure how to make a mobile app, mainly because OpenGL requires a handle to a window and I'm not sure how that works on mobile.

Any help would be appreciated!
Thanks,
Joshua
John Frazier


Posts: 726
Registered: 2/17/00
Re: FireMonkey application which uses OpenGL (ES?) and runs on Android/iOS?
Helpful
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 16, 2014 12:03 PM   in response to: Joshua Smith in response to: Joshua Smith
Joshua Smith wrote:
Hi all,

I am relatively new to both Embarcadero technologies and OpenGL.

My question is, is it possible to create a FireMonkey mobile application that runs on both Android and iOS that uses OpenGL?

I've created a simple FireMonkey HD Desktop application for Windows that uses OpenGL based off of the answer to this question on SO: http://stackoverflow.com/questions/19941859/how-to-render-an-opengl-frame-in-c-builder

But I am not sure how to make a mobile app, mainly because OpenGL requires a handle to a window and I'm not sure how that works on mobile.

OpenGLes is what is supported on both mobile platforms when we draw all of our FireMonkey stuff. If you want to do low level OpenGL there are some examples out there; may not be C++, but should get the idea across.

http://delphi.org/2014/04/opengl-es-support-on-mobile-with-xe6/

http://www.fmxexpress.com/opengl-3d-animation-demos-for-delphi-xe5-firemonkey-on-android-and-ios/

Also dug a little more and found this nice little example for OSX

http://docwiki.embarcadero.com/CodeExamples/XE7/en/OpenGL_Multicolor_Tetrahedron_%28C%2B%2B%29

Saw this article too that may be of interest for OpenGL folks

http://docwiki.embarcadero.com/RADStudio/XE7/en/Overriding_OpenGL_Rendering_Parameters
--
John Frazier (Embarcadero Newsgroup Admin)
Joshua Smith

Posts: 5
Registered: 3/25/14
Re: FireMonkey application which uses OpenGL (ES?) and runs on Android/iOS?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 17, 2014 9:44 AM   in response to: John Frazier in response to: John Frazier
John Frazier wrote:
Joshua Smith wrote:
Hi all,

I am relatively new to both Embarcadero technologies and OpenGL.

My question is, is it possible to create a FireMonkey mobile application that runs on both Android and iOS that uses OpenGL?

I've created a simple FireMonkey HD Desktop application for Windows that uses OpenGL based off of the answer to this question on SO: http://stackoverflow.com/questions/19941859/how-to-render-an-opengl-frame-in-c-builder

But I am not sure how to make a mobile app, mainly because OpenGL requires a handle to a window and I'm not sure how that works on mobile.

OpenGLes is what is supported on both mobile platforms when we draw all of our FireMonkey stuff. If you want to do low level OpenGL there are some examples out there; may not be C++, but should get the idea across.

http://delphi.org/2014/04/opengl-es-support-on-mobile-with-xe6/

http://www.fmxexpress.com/opengl-3d-animation-demos-for-delphi-xe5-firemonkey-on-android-and-ios/

Also dug a little more and found this nice little example for OSX

http://docwiki.embarcadero.com/CodeExamples/XE7/en/OpenGL_Multicolor_Tetrahedron_%28C%2B%2B%29

Saw this article too that may be of interest for OpenGL folks

http://docwiki.embarcadero.com/RADStudio/XE7/en/Overriding_OpenGL_Rendering_Parameters
--
John Frazier (Embarcadero Newsgroup Admin)

Hi John,

Thanks for the clarification. I tried following the steps in the first link you mentioned to use OpenGL ES in a mobile 3D FireMonkey app, but it didn't work. I'm using C++ builder, so for my includes I used:
#include <FMX.Types3D.hpp>
#include <FMX.Context.GLES.hpp>
#include <Androidapi.Gles.hpp>
#include <FMX.Context.GLES.Android.hpp>
#include <FMX.Platform.Android.hpp>
#include <Androidapi.Gles2.hpp>
#include <Androidapi.JNI.OpenGL.hpp>
#include <Androidapi.Glesext.hpp>
#include <Androidapi.Gles2ext.hpp>

When I compile the project, however, it's complaining that glClearColor and GL_COLOR_BUFFER_BIT in my OnRender function is undeclared. Are there other files I should be including?
John Frazier


Posts: 726
Registered: 2/17/00
Re: FireMonkey application which uses OpenGL (ES?) and runs on Android/iOS?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 17, 2014 3:28 PM   in response to: Joshua Smith in response to: Joshua Smith
You didn't mention what version of the product you are using and your deploy target.
--
John Frazier (Embarcadero Newsgroup Admin)
Joshua Smith

Posts: 5
Registered: 3/25/14
Re: FireMonkey application which uses OpenGL (ES?) and runs on Android/iOS?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 19, 2014 5:49 AM   in response to: John Frazier in response to: John Frazier
John Frazier wrote:
You didn't mention what version of the product you are using and your deploy target.
--
John Frazier (Embarcadero Newsgroup Admin)

Sorry, I tagged the question with XE6 and by looking at the includes you can tell my target was Android :).

Joshua
Jason Stone

Posts: 3
Registered: 7/14/11
Re: FireMonkey application which uses OpenGL (ES?) and runs on Android/iOS?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 20, 2014 6:22 PM   in response to: Joshua Smith in response to: Joshua Smith
From what I can tell, Embarcadero have provided access to the OpenGL primitive API calls on Android and iOS through Delphi, but have not bothered to do so in C++ Builder.
I REALLY hope I am wrong here, but I have encountered the same problems with XE7 when I have tried to port existing C++ code which uses primitive OpenGL. There just seems to be no way to get to the basic OpenGL API functions (and lots of other necessary API activities) unless prepared to write a JNI wrapper (Android) and this just totally takes the "Rapid" out of "RAD". You're expected to rewrite all code to use the severely-restrictive FMX TContext3D, and/or stick with the pretty but oh-so-limited drag-and-drop examples.
Documentation is also lagging well behind.

If this is the case, then it is a very poor effort on Embarcadero's behalf, and another example of "Delphi-first, C++ if you're lucky".
Or to (mis-)use Abba Eban's famous quote, Borland/Embarcadero "...never miss an opportunity to miss an opportunity".

I've been a lonely advocate of C++ Builder (and its predecessors) since the early 90's, but the lack of mobile tools (until recently) have been a constant setback to its adoption in my development circles and have made it an almost impossible sell.
With XE7 and C++ Builder for Andriod/iOS I was overjoyed as I thought they had finally "got it". But it seems not.
This could be the death-knell for C++Builder for our imminent multi-platform project involving multiple companies and many developers and will cement the trajectory for all future development which follows.

Very disappointed Embarcadero.
Borja Serrano

Posts: 172
Registered: 1/10/13
Re: FireMonkey application which uses OpenGL (ES?) and runs on Android/iOS?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 21, 2014 4:23 AM   in response to: Jason Stone in response to: Jason Stone
In C++ Builder you should use directly the NDK library (NDK_PATH\platforms\android-14\arch-arm\usr\include) headers to use OpenGL functions. As they are C++, they have not been retranslated from Delphi. Those headers are directly included in the library path if you have installed the Android SDK in the IDE. Just use (for instance):

#include "GLES2\gl2.h"

Jason Stone wrote:
From what I can tell, Embarcadero have provided access to the OpenGL primitive API calls on Android and iOS through Delphi, but have not bothered to do so in C++ Builder.
I REALLY hope I am wrong here, but I have encountered the same problems with XE7 when I have tried to port existing C++ code which uses primitive OpenGL. There just seems to be no way to get to the basic OpenGL API functions (and lots of other necessary API activities) unless prepared to write a JNI wrapper (Android) and this just totally takes the "Rapid" out of "RAD". You're expected to rewrite all code to use the severely-restrictive FMX TContext3D, and/or stick with the pretty but oh-so-limited drag-and-drop examples.
Documentation is also lagging well behind.

If this is the case, then it is a very poor effort on Embarcadero's behalf, and another example of "Delphi-first, C++ if you're lucky".
Or to (mis-)use Abba Eban's famous quote, Borland/Embarcadero "...never miss an opportunity to miss an opportunity".

I've been a lonely advocate of C++ Builder (and its predecessors) since the early 90's, but the lack of mobile tools (until recently) have been a constant setback to its adoption in my development circles and have made it an almost impossible sell.
With XE7 and C++ Builder for Andriod/iOS I was overjoyed as I thought they had finally "got it". But it seems not.
This could be the death-knell for C++Builder for our imminent multi-platform project involving multiple companies and many developers and will cement the trajectory for all future development which follows.

Very disappointed Embarcadero.

--
Borja Serrano
Embarcadero Technical Support Engineer
Jason Stone

Posts: 3
Registered: 7/14/11
Re: FireMonkey application which uses OpenGL (ES?) and runs on Android/iOS?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Nov 5, 2014 9:33 PM   in response to: Borja Serrano in response to: Borja Serrano
Thankyou Borja, that is a big help.
I know it's a dull and time consuming job, but I trust Embarcadero can add to its documentation soon.
I hope that the new C++ Builder enhancements (including multi-platform) are generating a lot of excitement and interest in the market, but wouldn't want people to go away disappointed because it is difficult to work things out once they try to use the product for anything more than basic activities.

Nothing is ever finished until it is documented.

In the good-old-days Borland's help files used to be fantastic.
These days they are very minimal and I find myself having to search through *.h files to get more info, and it becomes a deeply unsatisfying productivity killer.
One can only glean so much from a YouTube clip... or by sending out an SOS on the forums.

But keep up the good work. C++ Builder is finally heading in the right direction again.
And if I may say (at the risk of offending the many good and dedicated Delphi people out there), I believe your growth market is all C++. Sandbagging your existing Delphi market may feed revenue and retain existing customers, but I can't see any organisation or serious developer starting a new project in single-vendor Pascal/Delphi.
Go hard with C++, before it's too late.
Just my considered opinion (admittedly as a C++ user).
Joshua Smith

Posts: 5
Registered: 3/25/14
Re: FireMonkey application which uses OpenGL (ES?) and runs on Android/iOS?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Nov 12, 2014 8:18 AM   in response to: Borja Serrano in response to: Borja Serrano
Hi Borja,

If I want to use OpenGL ES 3, what things do I need to do besides changing the ndk paths to android-18 instead of android-14 and including "GLES3\gl3.h" in my project? I made these changes but when I use try to use glGenVertextArrays() function I get this error:

[ldandroid Error] C:\Users\Public\Documents\Embarcadero\Studio\15.0\PlatformSDKs\android-ndk-r9c\toolchains\arm-linux-androideabi-4.6\prebuilt\windows\bin\arm-linux-androideabi-ld.exe: .\Android\Debug\Unit1.o: in function TForm3D1::Form3DRender(System::TObject*, Fmx::Types3d::TContext3D*):C:\Users\username\Documents\Embarcadero\Studio\Projects\OpenGL/Unit1.cpp:26: error: undefined reference to 'glGenVertexArrays'


EDIT: I should mention I am now using C++ Builder XE7

Borja Serrano wrote:
In C++ Builder you should use directly the NDK library (NDK_PATH\platforms\android-14\arch-arm\usr\include) headers to use OpenGL functions. As they are C++, they have not been retranslated from Delphi. Those headers are directly included in the library path if you have installed the Android SDK in the IDE. Just use (for instance):

#include "GLES2\gl2.h"

Jason Stone wrote:
From what I can tell, Embarcadero have provided access to the OpenGL primitive API calls on Android and iOS through Delphi, but have not bothered to do so in C++ Builder.
I REALLY hope I am wrong here, but I have encountered the same problems with XE7 when I have tried to port existing C++ code which uses primitive OpenGL. There just seems to be no way to get to the basic OpenGL API functions (and lots of other necessary API activities) unless prepared to write a JNI wrapper (Android) and this just totally takes the "Rapid" out of "RAD". You're expected to rewrite all code to use the severely-restrictive FMX TContext3D, and/or stick with the pretty but oh-so-limited drag-and-drop examples.
Documentation is also lagging well behind.

If this is the case, then it is a very poor effort on Embarcadero's behalf, and another example of "Delphi-first, C++ if you're lucky".
Or to (mis-)use Abba Eban's famous quote, Borland/Embarcadero "...never miss an opportunity to miss an opportunity".

I've been a lonely advocate of C++ Builder (and its predecessors) since the early 90's, but the lack of mobile tools (until recently) have been a constant setback to its adoption in my development circles and have made it an almost impossible sell.
With XE7 and C++ Builder for Andriod/iOS I was overjoyed as I thought they had finally "got it". But it seems not.
This could be the death-knell for C++Builder for our imminent multi-platform project involving multiple companies and many developers and will cement the trajectory for all future development which follows.

Very disappointed Embarcadero.

--
Borja Serrano
Embarcadero Technical Support Engineer

Edited by: Joshua Smith on Nov 12, 2014 8:31 AM
David Patte

Posts: 7
Registered: 1/23/98
Re: FireMonkey application which uses OpenGL (ES?) and runs on Android/iOS?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Nov 26, 2014 12:57 PM   in response to: Joshua Smith in response to: Joshua Smith
Hi Borja

Is there any sample code (even a few lines) showing how to use openGL on Android C++ as you mention above?

I'd also like to know whether openGL (as opposed to DirectX) is supported in FMX Win32 or 64?
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02