OpenB3D: moving to OpenGL 2.0 / GLES2.0. Need help

BlitzMax Forums/MiniB3D Module/OpenB3D: moving to OpenGL 2.0 / GLES2.0. Need help

angros47(Posted 2016) [#1]
After a lot of work, I replaced most of the fixed function pipeline with a shader based pipeline.

This version is absolutely not ready for a release, but at this point I need some volunteers to test it:

https://sourceforge.net/projects/minib3d/files/shader%20wip.zip/download

In particular, I need someone to try:
- compiling it for Android/IOS (need to set the correct headers)
- compiling it with ANGLE (to build a Direct3D version)
- compile it with EmScripten (a WebGL version)

There are still lot of features missing, and surely I forgot to change all the parts that need to be changed. But I don't have the Android SDK installed, neither the experience needed. I think, anyway, that 90% of the job to port it to programmable pipeline should be complete.


RustyKristi(Posted 2016) [#2]
Great update angros47! :) count me in for testing. So do I just overwrite the existing sources?

I know BMX-NG only has the option with Android, does it mean that you can now compile it with the Vanilla version?

thanks


angros47(Posted 2016) [#3]
You should be able to compile it like the classical version... in theory


RustyKristi(Posted 2016) [#4]
Thanks. I'm getting this camera.cpp errors. Maybe something is outdated on my other mods/libs..

C:/BlitzMax/mod/openb3d.mod/openb3dlib.mod/openb3d/src/camera.cpp: In member function 'virtual void Camera::Update()':
C:/BlitzMax/mod/openb3d.mod/openb3dlib.mod/openb3d/src/camera.cpp:458:33: error: 'glViewport' was not declared in this scope
C:/BlitzMax/mod/openb3d.mod/openb3dlib.mod/openb3d/src/camera.cpp:459:32: error: 'glScissor' was not declared in this scope
C:/BlitzMax/mod/openb3d.mod/openb3dlib.mod/openb3d/src/camera.cpp:460:36: error: 'glClearColor' was not declared in this scope
C:/BlitzMax/mod/openb3d.mod/openb3dlib.mod/openb3d/src/camera.cpp:466:11: error: 'GL_COLOR_BUFFER_BIT' was not declared in this scope
C:/BlitzMax/mod/openb3d.mod/openb3dlib.mod/openb3d/src/camera.cpp:466:31: error: 'GL_DEPTH_BUFFER_BIT' was not declared in this scope
C:/BlitzMax/mod/openb3d.mod/openb3dlib.mod/openb3d/src/camera.cpp:466:50: error: 'glClear' was not declared in this scope
C:/BlitzMax/mod/openb3d.mod/openb3dlib.mod/openb3d/src/camera.cpp:469:12: error: 'GL_COLOR_BUFFER_BIT' was not declared in this scope
C:/BlitzMax/mod/openb3d.mod/openb3dlib.mod/openb3d/src/camera.cpp:469:31: error: 'glClear' was not declared in this scope
C:/BlitzMax/mod/openb3d.mod/openb3dlib.mod/openb3d/src/camera.cpp:473:13: error: 'GL_DEPTH_BUFFER_BIT' was not declared in this scope
C:/BlitzMax/mod/openb3d.mod/openb3dlib.mod/openb3d/src/camera.cpp:473:32: error: 'glClear' was not declared in this scope
C:/BlitzMax/mod/openb3d.mod/openb3dlib.mod/openb3d/src/camera.cpp:565:17: error: 'GL_VIEWPORT' was not declared in this scope
C:/BlitzMax/mod/openb3d.mod/openb3dlib.mod/openb3d/src/camera.cpp:565:41: error: 'glGetIntegerv' was not declared in this scope
Build Error: failed to compile C:/BlitzMax/mod/openb3d.mod/openb3dlib.mod/openb3d/src/camera.cpp



angros47(Posted 2016) [#5]
Or I messed something in including headers...


RustyKristi(Posted 2016) [#6]
Great. I hope it is not related to the latest glew.mod or opengl.mod. I just did a clean blitzmax vanilla 1.5 install and have not changed any pub.mod files. I'm assuming they were both already the latest version.


markcw(Posted 2016) [#7]
I bought a Motorola Moto G today so I'll see if I can get BMax NG running on it.


markcw(Posted 2016) [#8]
Angros, I've added your GLES2 changes to the wrapper repo and it runs as OpenGL2 but I haven't got it compiling as GLES yet. This is my current error:

bmk makemods -r -l android -g armeabiv7a openb3d.openb3dsdl
...
C:/../openb3d.mod/openb3dlib.mod/openb3d/src/texture.h:15:16: fatal error: list: No such file or directory
#include <list>
^
ccoommppiillaattiioonn tteerrmmiinnaatteedd..

And yes, it actually said that! :)

This seems to be because the "Standard Template Library" is not included in the Android pre-built toolchain. So I'm currently trying to figure out what I have to do now!


angros47(Posted 2016) [#9]
I wonder if it is related to this:

https://developer.android.com/ndk/guides/standalone_toolchain.html


markcw(Posted 2016) [#10]
Thanks, I don't understand that though. I found out there's an option in $PROJECT/jni/Application.mk with "APP_STL := stlport_static" which looks like the solution but I don't know how to add this to a module, editing the file in blitzmaxng/resources/android/.. doesn't seem to work.

I just added an update so the wrapper works on Win now, this was the errors RustyKristi posted in #4 where glew or glee headers were required.


markcw(Posted 2016) [#11]
I think I'm on the right track but it's still not compiling. In openb3dsdl.bmx:
ModuleInfo "LD_OPTS: -LD:/android-ndk-r11c/sources/cxx-stl/stlport/libs/armeabi-v7a/"
or copy the .so to the mod folder and use...
ModuleInfo "LD_OPTS: -L%PWD%"

Import "-lstlport_shared"



RustyKristi(Posted 2016) [#12]
double post..


RustyKristi(Posted 2016) [#13]
Edit: I did not know there was an update for openb3d wrapper so I was trying to compile the version angros47 posted.. thanks munch! :D


RustyKristi(Posted 2016) [#14]
Did a full rebuild and getting this error instead at 90%

Compile Error: Identifier 'glpopclientattrib' not found.
[C:/BMXNG/mod/openb3d.mod/openb3d.mod/inc/TBlitz2D.bmx;9;0]
Build Error: failed to compile C:/BMXNG/mod/openb3d.mod/openb3d.mod/openb3d.bmx



markcw(Posted 2016) [#15]
I just updated it.

If you add Import Pub.OpenGL after Import Pub.Glew in openb3dlib.bmx it should compile in Bmx NG - I got the same error. Sadly any example MAVs instantly and I'm stuck there. Note that it compiles and runs fine in OS/legacy Bmx and that Glew imports OpenGL so this fix shouldn't be needed.


angros47(Posted 2016) [#16]
glpopclientattrib is not part of GLES, as far as I know


RustyKristi(Posted 2016) [#17]
Note that it compiles and runs fine in OS/legacy Bmx and that Glew imports OpenGL so this fix shouldn't be needed.



Thanks munch, using vanilla bmx since it does not do 64bit. With the 1.5 default download and for some reason I'm getting this early during build..

Building Modules
Compiling:3ds.cpp
C:/BlitzMax/mod/openb3d.mod/openb3dlib.mod/openb3d/src/3ds.cpp:1:0: error: CPU you selected does not support x86-64 instruction set
 #include "model.h"


Still trying with NG..


RustyKristi(Posted 2016) [#18]
Hey munch, This is weird but already added after Import Pub.Glew in C:\BMXNG\mod\openb3d.mod\openb3dlib.mod\openb3dlib.bmx and still the same error :/

This is already in NG and a cloned copy after reading your post..
[ 89%] Processing:openb3d.bmx
Compile Warning: In call to Function glUniformMatrix4fv:Int(location_:Int,count_:Int,transpose_:Byte,value_:Float Ptr). Argument #3 is "Int" but declaration is "Byte". 
[C:/BMXNG/mod/openb3d.mod/openb3d.mod/inc/TGLShader.bmx;179;0]

[ 90%] Processing:openb3dsdl.bmx
Compile Error: Identifier 'glpopclientattrib' not found.
[C:/BMXNG/mod/openb3d.mod/openb3d.mod/inc/TBlitz2D.bmx;9;0]
Build Error: failed to compile C:/BMXNG/mod/openb3d.mod/openb3dsdl.mod/openb3dsdl.bmx
Process complete



markcw(Posted 2016) [#19]
Sorry I haven't tested with Bmx 1.50 just OS Bmx. The sdl modules shouldn't be compiled in OS/legacy Bmx as you needs sdl.mod and it's NG only. I compile in this order openb3dlib, openb3d then b3dglgraphics but you should be able to just delete openb3dsdl and b3dglsdlgraphics mods and compile the modscope.

I think TBlitz2d needs removed from openb3dsdl.


RustyKristi(Posted 2016) [#20]
Sadly any example MAVs instantly and I'm stuck there.


Thanks ok removed all SDL modules in NG and it builds ok, so I'm getting the MAV as expected when I build some examples..

Btw, still with NG and I did report this weeks ago about the HearingPoint error on b3d sound module..

Edit: apparently, my vanilla bmx should work as the cpu arch part that I was getting was caused by wrong MinGW version (switching between NG/Vanilla on same C:/MinGW path)


RustyKristi(Posted 2016) [#21]
Hey munch, this is probably too early to point out or also driver related (SDL) and since the examples does not work yet, but I do remember Derron or Brucey mentioning the BRL.Retro stuff which will not work with Android/SDL.

https://github.com/markcwm/openb3d.mod/blob/master/openb3d.mod/openb3d.bmx#L39


angros47(Posted 2016) [#22]
I got no updates... has anyone managed to test it on Android?


RustyKristi(Posted 2016) [#23]
Hey angros47, I've been checking and testing this out recently and to date it can't even build on android with sdl..


angros47(Posted 2016) [#24]
Is SDL needed to use GLES in android?


RustyKristi(Posted 2016) [#25]
Not sure probably for Max2D and other I/O stuff. There's also mojo2 which you can refer to the port examples, as it uses gles for android build.

https://github.com/bmx-ng/mky.mod/blob/master/mojo2.mod/examples/directlight/directlight.bmx#L3-L9


angros47(Posted 2016) [#26]
Have you tried OpenB3D on Android without Max2D?


RustyKristi(Posted 2016) [#27]
Not yet. I also think that's what munch is trying to do with the below as the SDL part replaces the desktop GLMax2D part, same process with typical max2d sdl android apps.

https://github.com/markcwm/openb3d.mod/blob/52a902696bc89e86c2acef686056387a1aec4e2f/b3dglsdlgraphics.mod/b3dglsdlgraphics.bmx


markcw(Posted 2016) [#28]
I'm pretty much finished with Blitzmax and the wrapper. Sorry I just don't have the time for coding any more.


RustyKristi(Posted 2016) [#29]
wow, I'm a bit surprised but this is completely understood.

Big kudos for your work Munch, really really appreciate this awesome wrapper mod!

Thanks again. All the Best.


Cocopino(Posted 2016) [#30]
Sad to hear that Munch, thank you for all your hard work and shared code!


angros47(Posted 2016) [#31]
I got no more feed back...

Has anyone got any result on Android, or in general on any embedded system?


RustyKristi(Posted 2016) [#32]
hey angros47,

apparently, munch stopped working on the wrapper so the previous commit is the current stable. I'm not sure someone already picked this up.