Recent

Author Topic: OpenGL ES 2.0  (Read 5062 times)

meanderix

  • Jr. Member
  • **
  • Posts: 50
OpenGL ES 2.0
« on: July 15, 2012, 09:58:48 am »
Hi,

I'm thinking about porting the hello-gl2 demo from the Android NDK to learn a bit about using pixel shaders in OpenGL ES 2.0.

I found the following port of the OpenGL ES 2.0 headers in the bug tracker:
http://mantis.freepascal.org/view.php?id=15632

According to the poster it should not be a lot of work to make the necessary adjustments for Android:
Quote from: Benjamin Rosseaux
Someone can make maybe a true patch from this for FreePascal for a offical
android target support in FreePascal. And my OpenGL ES 2.0 headers (what I did originally for Nokia N900 for Maemo 5) are already in the FPC
bugtracker, which should also under Android after a single-line-change of
the OpenGL ES library path.

Is there anything in particular that I need to think about when doing this?

meanderix

  • Jr. Member
  • **
  • Posts: 50
Re: OpenGL ES 2.0
« Reply #1 on: July 16, 2012, 12:23:34 am »
Ok, I managed to port it (see attachment.) Now we have a demo that shows how to use OpenGL ES 2.0 together with JNI.

Some notes:
  • For some strange reason the compiler would name the library liblibgl2jni.so instead of libgl2jni.so. I checked the project options and everything looked fine...
  • It doesn't look like unit initialization is invoked and since the gles20 unit links dynamically, we need to manually call LoadGLESv2(). This is done in the first JNI callback, but maybe there is a better strategy?
  • There are some types in gles20.pas that are linked to native types (EGLNativePixmapType is an alias for HDC in Windows and an alias for TWindow in linux, which I think is the X11 convention. However, when I used the X11 aliases in Android, the linker complained about x11.so not being found, so I've just declared these types as integers. I don't know what would be the best convention here.)
  • Otherwise there were just some minor hick-ups with regards to string/pchar conventions for the log instructions.
« Last Edit: July 16, 2012, 12:25:19 am by meanderix »

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Re: OpenGL ES 2.0
« Reply #2 on: July 16, 2012, 02:39:45 pm »
Great, Meanderix!

I don't use Android myself, but I applaud your porting efforts. Hope somebody can give you some clarification and help improve it.

Cheers,
BigChimp
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

 

TinyPortal © 2005-2018