Recent

Author Topic: [SOLVED] building a native openGL app as a commandline tool  (Read 1103 times)

Key-Real

  • Full Member
  • ***
  • Posts: 202
[SOLVED] building a native openGL app as a commandline tool
« on: January 22, 2023, 10:46:09 pm »
I'm trying to create a native openGL app witch you can start from the command line.

I found all the needed units at:

lazarus/lcl/interfaces/customdrawn/android

I don't knew how to make entry point for android_main((app:Pandroid_app);

I need this app var.

I don't wanna build a library. My goal is a executable.

Ideas?
« Last Edit: January 23, 2023, 12:33:27 am by Key-Real »

KodeZwerg

  • Hero Member
  • *****
  • Posts: 2068
  • Fifty shades of code.
    • Delphi & FreePascal
Re: building a native openGL app as a commandline tool
« Reply #1 on: January 22, 2023, 11:21:05 pm »
Can you update me please, what is a commandline on android please?
« Last Edit: Tomorrow at 31:76:97 xm by KodeZwerg »

TRon

  • Hero Member
  • *****
  • Posts: 2515
Re: building a native openGL app as a commandline tool
« Reply #2 on: January 22, 2023, 11:43:44 pm »
@KodeZwerg:
Based on TS' other post that would be termux.

Key-Real

  • Full Member
  • ***
  • Posts: 202
Re: building a native openGL app as a commandline tool
« Reply #3 on: January 22, 2023, 11:46:50 pm »
begin
 writeln('Hallo');
end.

build this, and this will be a command line tool

KodeZwerg

  • Hero Member
  • *****
  • Posts: 2068
  • Fifty shades of code.
    • Delphi & FreePascal
Re: building a native openGL app as a commandline tool
« Reply #4 on: January 22, 2023, 11:50:29 pm »
@KodeZwerg:
Based on TS' other post that would be termux.
Thanks, didnt read that one so i missed the context  O:-)

begin
 writeln('Hallo');
end.

build this, and this will be a command line tool
IKR - "Grüße zurück"  :D
« Last Edit: Tomorrow at 31:76:97 xm by KodeZwerg »

Key-Real

  • Full Member
  • ***
  • Posts: 202
Re: building a native openGL app as a commandline tool
« Reply #5 on: January 22, 2023, 11:53:59 pm »
my goal is to init a openGL context whitout changing the user code.

the code should look like this:

uses myLib;
begin
 initOpenGL;
 repeat
  draw;
 until keypress;
 closeOpenGL;
end.


so myLib should handle all the init stuff.
I have this working under win/lin/osx

It looks like SDL make this somehow for Android.

You knew?

Seenkao

  • Hero Member
  • *****
  • Posts: 550
    • New ZenGL.
Re: building a native openGL app as a commandline tool
« Reply #6 on: January 23, 2023, 12:01:23 am »
Я не советую вам пробовать создать контекст из командной строки Android. Максимум, что вы можете попробовать, это использовать SDL2 для создания контекста окна. Но, это может так же не сработать.
Если вы хотите попробовать сделать это сами, то для этого надо минимум создать X-сервер и создать графическое окно. А уже после, создавать для этого окна контекст OpenGL ES.

Если вы знаете умельца, который мог бы это сделать, то советую к нему обратиться. Я не думаю, что это простой процесс.

Лучший вариант для Android - это создавать контекст OpenGL ES из java-кода.

Google translate:
I do not advise you to try to create a context from the Android command line. The most you can try is to use SDL2 to create the window context. But, that might not work either.
If you want to try it yourself, then at least you need to create an X server and create a graphical window. And after that, create an OpenGL ES context for this window.

If you know a craftsman who could do this, then I advise you to contact him. I don't think it's an easy process.

The best option for Android is to create an OpenGL ES context from java code.
Rus: Стремлюсь к созданию минимальных и достаточно быстрых приложений.

Eng: I strive to create applications that are minimal and reasonably fast.
Working on ZenGL

Key-Real

  • Full Member
  • ***
  • Posts: 202
Re: building a native openGL app as a commandline tool
« Reply #7 on: January 23, 2023, 12:17:10 am »
ok, I'm not against generating a .apk and using jni.

I would do everything needed except edit the code of the main.pas

Is there a way to hook it like this (in my library)?

TRon

  • Hero Member
  • *****
  • Posts: 2515
Re: building a native openGL app as a commandline tool
« Reply #8 on: January 23, 2023, 12:21:58 am »
@Key-Real:
If indeed you are expecting that to be realized with termux then termux is a better friend than FPC. Meaning that people already did these things for termux with C. Ergo that would be a better source for information (and try replicate that with FPC).

Could be there is someone around here that has experience with termux/FPC/GL but I doubt it.

Key-Real

  • Full Member
  • ***
  • Posts: 202
Re: building a native openGL app as a commandline tool
« Reply #9 on: January 23, 2023, 12:27:58 am »
termux is only a shell for me, I compile there.

I would likely create a .apk. There is, as I see now, no way around it.

my problem is, the android_main (the entrypoint) have to be called out of a library.

is it possible to hook this to leave the program code as it is and do all the init stuff in my unit?

Key-Real

  • Full Member
  • ***
  • Posts: 202
Re: building a native openGL app as a commandline tool
« Reply #10 on: January 23, 2023, 12:33:10 am »
But this is another topic now. I start another thread on that and mark this thread a solved.

Seenkao

  • Hero Member
  • *****
  • Posts: 550
    • New ZenGL.
Re: building a native openGL app as a commandline tool
« Reply #11 on: January 23, 2023, 12:38:53 am »
ok, I'm not against generating a .apk and using jni.

I would do everything needed except edit the code of the main.pas

Is there a way to hook it like this (in my library)?
Посмотри как это реализовал Andru в библиотеке ZenGL. Там есть недочёт, не сделан таймер для java-кода. А руки у меня пока не дошли исправить этот недочёт.
Можешь посмотреть здесь ещё. Там подобная идея.
Но всё это создавалось на компьютерах. На FPC компилировались *.so библиотеки и записывались в загрузку самого приложения.

customdrawn - должен содержать пример нативного исполнения. Но, нативное исполнение не доведено до ума, потому все используют нативные вызовы из java-кода.

Google translate:
See how Andru implemented it in the library ZenGL. There is a flaw, there is no timer for java code. And my hands have not yet reached to correct this defect.
You can see more here. There is a similar idea.
But all this was created on computers. On FPC, *.so libraries were compiled and written into the load of the application itself.

customdrawn - should contain an example of native execution. But, native execution is not brought to mind, because everyone uses native calls from java code.
Rus: Стремлюсь к созданию минимальных и достаточно быстрых приложений.

Eng: I strive to create applications that are minimal and reasonably fast.
Working on ZenGL

TRon

  • Hero Member
  • *****
  • Posts: 2515
Re: building a native openGL app as a commandline tool
« Reply #12 on: January 23, 2023, 12:45:37 am »
is it possible to hook this to leave the program code as it is and do all the init stuff in my unit?
Sorry but this subject is really out of my comfort-zone so I would have no idea.

I did see a video of someone compiling a opengl program in termux with c++ but as far as I am able to tell that is just Linux (termux) talking.

The only other reference i am aware of is https://arm-software.github.io/opengl-es-sdk-for-android/tutorials.html but that seems to-do exactly that what you do not wish to do: create a java startup, build your app as a shared library and let java call your main setup routine.
« Last Edit: January 23, 2023, 12:47:12 am by TRon »

Key-Real

  • Full Member
  • ***
  • Posts: 202
Re: [SOLVED] building a native openGL app as a commandline tool
« Reply #13 on: January 23, 2023, 11:19:58 am »
[CONCLUSION]

it is not possible. You have to build an .apk

Seenkao

  • Hero Member
  • *****
  • Posts: 550
    • New ZenGL.
Re: [SOLVED] building a native openGL app as a commandline tool
« Reply #14 on: January 23, 2023, 11:53:44 am »
[CONCLUSION]

it is not possible. You have to build an .apk
Да, но он может быть создан без java-кода! Я делал. Но это почти бессмысленно. Описал в соседнем топике.

Google translate:
Yes, but it can be created without java code! I did. But it's almost pointless. Described in the next topic.
Rus: Стремлюсь к созданию минимальных и достаточно быстрых приложений.

Eng: I strive to create applications that are minimal and reasonably fast.
Working on ZenGL

 

TinyPortal © 2005-2018