Amicadi
Posts: 10
Joined: Wed Sep 16, 2015 3:17 am

Minetest with OpenGL ES

Wed Sep 16, 2015 3:28 am

Since Minetest ( http://www.minetest.net/ ) works quite badly in raspberry pi (1 and 2) because it is using OpenGL instead of OpenGL ES I am trying to get Minetest running with OpenGL ES 2 in my raspberry pi2.

In order to do this, i installed these packages in the system:

Code: Select all

libegl1-mesa-dev - free implementation of the EGL API -- development files
libgegl-dev - Generic Graphics Library (development files)
libgles2-mesa-dev - free implementation of the OpenGL|ES 2.x API -- development files
libgl1-mesa-swx11-dev - free implementation of the OpenGL API -- development files
I compiled Irrlicht ogl es 1.9.0 ( at http://svn.code.sf.net/p/irrlicht/code/branches/ogl-es/ ) with the following configuration at /home/pi/irrlicht/ogl-es/include/IrrCompileConfig.h:

Code: Select all

#define _IRR_COMPILE_WITH_OPENGL_
#define _IRR_COMPILE_WITH_OGLES1_
#define _IRR_COMPILE_WITH_OGLES2_
#define _IRR_COMPILE_WITH_EGL_MANAGER_
#define _IRR_COMPILE_WITH_GLX_MANAGER_
#define _IRR_COMPILE_WITH_X11_DEVICE_
executing:

Code: Select all

make -j 4
later on I compile minetest as:

Code: Select all

cmake . -DRUN_IN_PLACE=TRUE -DENABLE_GLES=1 -DEGL_INCLUDE_DIR=/opt/vc/include/EGL -DEGL_LIBRARY=/usr/lib/arm-linux-gnueabihf/libEGL.so -DOPENGLES2_INCLUDE_DIR=/opt/vc/include/GLES2 -DOPENGLES2_LIBRARY=/usr/lib/arm-linux-gnueabihf/libGLESv2.so -DFREETYPE_INCLUDE_DIR_freetype2=/usr/include/freetype2 -DFREETYPE_INCLUDE_DIR_ft2build=/usr/include/freetype2 -DFREETYPE_LIBRARY=/usr/lib/arm-linux-gnueabihf/libfreetype.a -DIRRLICHT_SOURCE_DIR=/irrlicht/ogl-es/source/Irrlicht
make -j 4
And linking fails since at minetest/src/CMakeFiles/minetest.dir/link.txt is missing some libs/include path, so I add:

Code: Select all

-lEGL -lGLESv2 -L/opt/vc/lib
flags for /home/pi/irrlicht/ogl-es/lib/Linux/libIrrlicht.a linking and then it generates the minetest binary.

finally, in order to select ogles2 I modify minetest.conf by adding:

Code: Select all

video_driver = ogles2
CEGLManager.cpp , CIrrDeviceLinux.cpp, COGLES2ExtensionHandler.cpp and COGLES2Driver.cpp are missing some code for the chosen combination:

Code: Select all

#define _IRR_COMPILE_WITH_OGLES2_
#define _IRR_COMPILE_WITH_EGL_MANAGER_
#define _IRR_COMPILE_WITH_GLX_MANAGER_
#define _IRR_COMPILE_WITH_X11_DEVICE_
I made some modifications to these classes (The files are attached in the zip file and code is quite dirty since I have not yet get it working) following this: https://github.com/kika123/x11eglrpi/bl ... playCopy.c and this: viewtopic.php?f=63&t=6488

It seems that with these changes OpenGL ES 2Driver is initialized, or at least, I get this log:

Code: Select all

 INFO[Main]: Irrlicht: Creating X window...
 INFO[Main]: Irrlicht: Using plain X visual
 VERBOSE[Main]: Irrlicht: Visual chosen: : 33
 VERBOSE[Main]: Irrlicht: Window Location: 1,30 
 Window Dimensions 800 x 585 
 Bit depth : 16
 INFO[Main]: Irrlicht: EGL version: 1.400000
 VERBOSE[Main]: Irrlicht: CirrDeviceLinux.cpp EDT_OGLES2 - context initialized.
 VERBOSE[Main]: Irrlicht: config chosen
 VERBOSE[Main]: Irrlicht: surface created
 ERROR[Main]: Irrlicht: Creating EGL context for OpenGLESVersion: : 2
 ERROR[Main]: Irrlicht: ContextAttrib[1]: : 2
 VERBOSE[Main]: Irrlicht: EGL context created with OpenGLESVersion: : 2
 ERROR[Main]: Irrlicht: Activating Context EGL
 ERROR[Main]: Irrlicht: Activated Context EGL
 INFO[Main]: Irrlicht: Using renderer: 
 INFO[Main]: Irrlicht: 
 INFO[Main]: Irrlicht: 
 ERROR[Main]: Irrlicht: COGLES2Driver - genericDriverInit Done
 VERBOSE[Main]: Irrlicht: CirrDeviceLinux.cpp EDT_OGLES2 - Created OGLES2 Driver.
 VERBOSE[Main]: Irrlicht: CirrDeviceLinux.cpp - Created Driver.
 VERBOSE[Main]: Irrlicht: CirrDeviceLinux.cpp - Created Driver OK.
 VERBOSE[Main]: Irrlicht: CirrDeviceLinux.cpp - createInputContext.
 VERBOSE[Main]: Irrlicht: CirrDeviceLinux.cpp - createGUIAndScene.
But at minetest side the program crashes at font textures creation.

While debugging this error I realized that COGLES2ExtensionHandler::initExtensions was not doing very well, since:

Code: Select all

glGetIntegerv(GL_MAX_TEXTURE_SIZE, &val);
MaxTextureSize=static_cast<u32>(val);
was setting MaxTextureSize to zero, and this was messing with the textures creation.

So, I added more debug and find out that glGetFloatv, glGetIntegerv and glGetString function calls at initExtensions were failing :-(

Code: Select all

 Irrlicht: COGLES2ExtensionHandler::initExtensions: 
 INFO[Main]: Irrlicht: GL_AMD_compressed_3DC_texture:  false
 ....
 ....
 INFO[Main]: Irrlicht: GL_OES_blend_equation_separate:  false
 INFO[Main]: Irrlicht: GL_OES_blend_func_separate:  false
 INFO[Main]: Irrlicht: GL_OES_blend_subtract:  false
 INFO[Main]: Irrlicht: GL_OES_byte_coordinates:  false
 INFO[Main]: Irrlicht: GL_OES_compressed_ETC1_RGB8_texture:  false
 INFO[Main]: Irrlicht: GL_OES_compressed_paletted_texture:  false
 INFO[Main]: Irrlicht: GL_OES_depth24:  false
 INFO[Main]: Irrlicht: GL_OES_depth32:  false
 INFO[Main]: Irrlicht: GL_OES_depth_texture:  false
 INFO[Main]: Irrlicht: GL_OES_draw_texture:  false
 INFO[Main]: Irrlicht: GL_OES_EGL_image:  false
 INFO[Main]: Irrlicht: GL_OES_EGL_image_external:  false
 INFO[Main]: Irrlicht: GL_OES_EGL_sync:  false
 INFO[Main]: Irrlicht: GL_OES_element_index_uint:  false
 INFO[Main]: Irrlicht: GL_OES_extended_matrix_palette:  false
 INFO[Main]: Irrlicht: GL_OES_fbo_render_mipmap:  false
 INFO[Main]: Irrlicht: GL_OES_fixed_point:  false
 INFO[Main]: Irrlicht: GL_OES_fragment_precision_high:  false
 INFO[Main]: Irrlicht: GL_OES_framebuffer_object:  false
 INFO[Main]: Irrlicht: GL_OES_get_program_binary:  false
 INFO[Main]: Irrlicht: GL_OES_mapbuffer:  false
 INFO[Main]: Irrlicht: GL_OES_matrix_get:  false
 INFO[Main]: Irrlicht: GL_OES_matrix_palette:  false
 INFO[Main]: Irrlicht: GL_OES_packed_depth_stencil:  false
 INFO[Main]: Irrlicht: GL_OES_point_size_array:  false
 INFO[Main]: Irrlicht: GL_OES_point_sprite:  false
 INFO[Main]: Irrlicht: GL_OES_query_matrix:  false
 INFO[Main]: Irrlicht: GL_OES_read_format:  false
 INFO[Main]: Irrlicht: GL_OES_required_internalformat:  false
 INFO[Main]: Irrlicht: GL_OES_rgb8_rgba8:  false
 INFO[Main]: Irrlicht: GL_OES_single_precision:  false
 INFO[Main]: Irrlicht: GL_OES_standard_derivatives:  false
 INFO[Main]: Irrlicht: GL_OES_stencil1:  false
 INFO[Main]: Irrlicht: GL_OES_stencil4:  false
 INFO[Main]: Irrlicht: GL_OES_stencil8:  false
 INFO[Main]: Irrlicht: GL_OES_stencil_wrap:  false
 INFO[Main]: Irrlicht: GL_OES_surfaceless_context:  false
 INFO[Main]: Irrlicht: GL_OES_texture_3D:  false
 INFO[Main]: Irrlicht: GL_OES_texture_cube_map:  false
 INFO[Main]: Irrlicht: GL_OES_texture_env_crossbar:  false
 INFO[Main]: Irrlicht: GL_OES_texture_float:  false
 INFO[Main]: Irrlicht: GL_OES_texture_float_linear:  false
 INFO[Main]: Irrlicht: GL_OES_texture_half_float:  false
 INFO[Main]: Irrlicht: GL_OES_texture_half_float_linear:  false
 INFO[Main]: Irrlicht: GL_OES_texture_mirrored_repeat:  false
 INFO[Main]: Irrlicht: GL_OES_texture_npot:  false
 INFO[Main]: Irrlicht: GL_OES_vertex_array_object:  false
 INFO[Main]: Irrlicht: GL_OES_vertex_half_float:  false
 INFO[Main]: Irrlicht: GL_OES_vertex_type_10_10_10_2:  false
 INFO[Main]: Irrlicht: GL_QCOM_alpha_test:  false
 INFO[Main]: Irrlicht: GL_QCOM_binning_control:  false
 INFO[Main]: Irrlicht: GL_QCOM_driver_control:  false
 INFO[Main]: Irrlicht: GL_QCOM_extended_get:  false
 INFO[Main]: Irrlicht: GL_QCOM_extended_get2:  false
 INFO[Main]: Irrlicht: GL_QCOM_performance_monitor_global_mode:  false
 INFO[Main]: Irrlicht: GL_QCOM_tiled_rendering:  false
 INFO[Main]: Irrlicht: GL_QCOM_writeonly_rendering:  false
 INFO[Main]: Irrlicht: GL_SUN_multi_draw_arrays:  false
 INFO[Main]: Irrlicht: GL_VIV_shader_binary:  false
 VERBOSE[Main]: Irrlicht: COGLES2ExtensionHandler::initExtensions - GL_MAX_TEXTURE_IMAGE_UNITS = 0 
 VERBOSE[Main]: Irrlicht: COGLES2ExtensionHandler::initExtensions - GL_MAX_TEXTURE_SIZE = 0 
 VERBOSE[Main]: Irrlicht: COGLES2ExtensionHandler::initExtensions - GL_ALIASED_LINE_WIDTH_RANGE = 0.000000 
 VERBOSE[Main]: Irrlicht: COGLES2ExtensionHandler::initExtensions - GL_ALIASED_POINT_SIZE_RANGE = 0.000000
Here I got stuck. I went to Irrlicht dev channel at freenode's irc and I didn't got much help because some of the Irrlicht core developers are not active anymore... So, it looks like getting Minetest to work with Irrlicht (OpenGL ES) in Raspberry pi would require some help from this community.

Minetest Android client (with Irrlicht ogl es 1.9.0) works perfectly, and so it should work for raspberry pi

Is anybody up to take the challenge? If not... any tips on how I can continue getting Irrlicht (OpenGL ES) to work with Raspberry pi ?
Attachments
Irrlicht ogl es 1.9.0 mod files.zip
(42.95 KiB) Downloaded 97 times

User avatar
PeterO
Posts: 3638
Joined: Sun Jul 22, 2012 4:14 pm

Re: Minetest with OpenGL ES

Wed Sep 16, 2015 9:31 am

My first thought is that you don't need any of those mesa packages to use and develop openGL ES on the PI.
Having them installed is probably messing things up. But I'm not in front of a PI at the moment and can't check for sure.

PeterO
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),Aeromodelling,1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson

Amicadi
Posts: 10
Joined: Wed Sep 16, 2015 3:17 am

Re: Minetest with OpenGL ES

Wed Sep 16, 2015 10:19 am

Removing libegl1-mesa-dev, libgles2-mesa-dev and libgl1-mesa-swx11-dev will result in Irrlicht compilation error:

Code: Select all

In file included from COGLESExtensionHandler.h:14:0,
                 from COGLESExtensionHandler.cpp:10:
CEGLManager.h:15:22: fatal error: GLES/egl.h: No such file or directory
compilation terminated.
In file included from COGLESTexture.cpp:10:0:
COGLESTexture.h:21:22: fatal error: GLES/egl.h: No such file or directory
compilation terminated.
In file included from COGLESExtensionHandler.h:14:0,
                 from COGLESDriver.h:24,
                 from COGLESDriver.cpp:5:
CEGLManager.h:15:22: fatal error: GLES/egl.h: No such file or directory
Which EGL, OGLES packages should be installed providing correct headers/libs?

User avatar
PeterO
Posts: 3638
Joined: Sun Jul 22, 2012 4:14 pm

Re: Minetest with OpenGL ES

Wed Sep 16, 2015 10:27 am

They are there already ! No need to add anything. Look at the openGL ES example code in /opt/vc/
Some info here http://elinux.org/Raspberry_Pi_VideoCore_APIs

Look at hello_triangle

HTH

PeterO
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),Aeromodelling,1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson

Amicadi
Posts: 10
Joined: Wed Sep 16, 2015 3:17 am

Re: Minetest with OpenGL ES

Wed Sep 16, 2015 10:54 am

You are right, those include files are in the place (at /opt/vc/include/), but then... why compilation fails like this?

Code: Select all

g++ -Wall -pipe -fno-exceptions -fno-rtti -fstrict-aliasing -g -O0 -D_DEBUG -I../../include -Izlib -Ijpeglib -Ilibpng -I/opt/vc/include/ -I/opt/vc/include/interface/vcos/pthreads -lX11 -lEGL -lGLESv2 -I/usr/X11R6/include -DIRRLICHT_EXPORTS=1  -c -o COGLESExtensionHandler.o COGLESExtensionHandler.cpp

In file included from COGLESExtensionHandler.h:14:0,
                 from COGLESExtensionHandler.cpp:10:
CEGLManager.h:15:22: fatal error: GLES/egl.h: No such file or directory
sorry, for this question... :oops:

User avatar
PeterO
Posts: 3638
Joined: Sun Jul 22, 2012 4:14 pm

Re: Minetest with OpenGL ES

Wed Sep 16, 2015 11:05 am

The compiler error message says "GLES/egl.h: No such file or directory" which is pretty clear :roll:

The header file "egl.h" is not in the GLES directory but is in the EGL directory, so change the include statement on line 12 of CEGLManager.h to "#include <EGL/egl.h>"

You will also need to add "-L/opt/vc/lib" to the compiler switches so that the library files can be found.

PeterO
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),Aeromodelling,1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson

Amicadi
Posts: 10
Joined: Wed Sep 16, 2015 3:17 am

Re: Minetest with OpenGL ES

Wed Sep 16, 2015 12:20 pm

Yes, that did it. Also at COGLESTexture.h was needed to change the gl.h location:

Code: Select all

#if defined(_IRR_COMPILE_WITH_IPHONE_DEVICE_)
#include <OpenGLES/ES1/gl.h>
#include <OpenGLES/ES1/glext.h>
#elif defined(_IRR_ANDROID_PLATFORM_)
#include <GLES/gl.h>
#include <GLES/glext.h>
#else
//#include <GLES/egl.h>
#include <GLES/gl.h>
#include <GLES/glext.h>
#endif
As seen, for android OpenGL ES the includes are correct...

anyway, I compiled successfully Irrlicht ogl-es 1.9.0 (without the egl/gles mesa libraries).

Then I needed to re-run minetest's cmake (and make clean) so it gets correct location for libEGL.so and libGLESv2.so

Code: Select all

cmake . -DRUN_IN_PLACE=TRUE -DENABLE_GLES=1 -DEGL_INCLUDE_DIR=/opt/vc/include/EGL -DEGL_LIBRARY=/opt/vc/lib/libEGL.so -DOPENGLES2_INCLUDE_DIR=/opt/vc/include/GLES2 -DOPENGLES2_LIBRARY=/opt/vc/lib/libGLESv2.so -DFREETYPE_INCLUDE_DIR_freetype2=/usr/include/freetype2 -DFREETYPE_INCLUDE_DIR_ft2build=/usr/include/freetype2 -DFREETYPE_LIBRARY=/usr/lib/arm-linux-gnueabihf/libfreetype.a -DIRRLICHT_SOURCE_DIR=/home/pi/irrlicht/ogl-es/source/Irrlicht
After this, and changing again minetest/src/CMakeFiles/minetest.dir/link.txt, this time adding:

Code: Select all

/opt/vc/lib/libGLESv2.so /opt/vc/lib/libEGL.so -L/opt/vc/lib
flags for /home/pi/irrlicht/ogl-es/lib/Linux/libIrrlicht.a, minetest was built successfully.

Looks like GLES2 is initialized correctly (as before removing the egl/gles mesa dev packages):

Code: Select all

 INFO[Main]: Irrlicht: Creating X window...
 INFO[Main]: Irrlicht: Using plain X visual
 VERBOSE[Main]: Irrlicht: Visual chosen: : 33
 VERBOSE[Main]: Irrlicht: Window Location: 1,30
 Window Dimensions 800 x 585
 Bit depth : 16
 INFO[Main]: Irrlicht: EGL version: 1.400000
 VERBOSE[Main]: Irrlicht: CirrDeviceLinux.cpp EDT_OGLES2 - context initialized.
 VERBOSE[Main]: Irrlicht: config chosen
 VERBOSE[Main]: Irrlicht: surface created
 VERBOSE[Main]: Irrlicht: Creating EGL context for OpenGLESVersion: : 2
 VERBOSE[Main]: Irrlicht: ContextAttrib[1]: : 2
 VERBOSE[Main]: Irrlicht: EGL context created with OpenGLESVersion: : 2
 VERBOSE[Main]: Irrlicht: Activating Context EGL
 VERBOSE[Main]: Irrlicht: Activated Context EGL
 INFO[Main]: Irrlicht: Using renderer:
 INFO[Main]: Irrlicht:
 INFO[Main]: Irrlicht:
But... It gets same errors querying OpenGL ES values at COGLES2ExtensionHandler::initExtensions:

Code: Select all

Irrlicht: COGLES2ExtensionHandler::initExtensions:
 INFO[Main]: Irrlicht: GL_AMD_compressed_3DC_texture:  false
 ....
 ....
 INFO[Main]: Irrlicht: GL_OES_blend_equation_separate:  false
 INFO[Main]: Irrlicht: GL_OES_blend_func_separate:  false
 INFO[Main]: Irrlicht: GL_OES_blend_subtract:  false
 INFO[Main]: Irrlicht: GL_OES_byte_coordinates:  false
 INFO[Main]: Irrlicht: GL_OES_compressed_ETC1_RGB8_texture:  false
 INFO[Main]: Irrlicht: GL_OES_compressed_paletted_texture:  false
 INFO[Main]: Irrlicht: GL_OES_depth24:  false
 INFO[Main]: Irrlicht: GL_OES_depth32:  false
 INFO[Main]: Irrlicht: GL_OES_depth_texture:  false
 INFO[Main]: Irrlicht: GL_OES_draw_texture:  false
 INFO[Main]: Irrlicht: GL_OES_EGL_image:  false
 INFO[Main]: Irrlicht: GL_OES_EGL_image_external:  false
 INFO[Main]: Irrlicht: GL_OES_EGL_sync:  false
 INFO[Main]: Irrlicht: GL_OES_element_index_uint:  false
 INFO[Main]: Irrlicht: GL_OES_extended_matrix_palette:  false
 INFO[Main]: Irrlicht: GL_OES_fbo_render_mipmap:  false
 INFO[Main]: Irrlicht: GL_OES_fixed_point:  false
 INFO[Main]: Irrlicht: GL_OES_fragment_precision_high:  false
 INFO[Main]: Irrlicht: GL_OES_framebuffer_object:  false
 INFO[Main]: Irrlicht: GL_OES_get_program_binary:  false
 INFO[Main]: Irrlicht: GL_OES_mapbuffer:  false
 INFO[Main]: Irrlicht: GL_OES_matrix_get:  false
 INFO[Main]: Irrlicht: GL_OES_matrix_palette:  false
 INFO[Main]: Irrlicht: GL_OES_packed_depth_stencil:  false
 INFO[Main]: Irrlicht: GL_OES_point_size_array:  false
 INFO[Main]: Irrlicht: GL_OES_point_sprite:  false
 INFO[Main]: Irrlicht: GL_OES_query_matrix:  false
 INFO[Main]: Irrlicht: GL_OES_read_format:  false
 INFO[Main]: Irrlicht: GL_OES_required_internalformat:  false
 INFO[Main]: Irrlicht: GL_OES_rgb8_rgba8:  false
 INFO[Main]: Irrlicht: GL_OES_single_precision:  false
 INFO[Main]: Irrlicht: GL_OES_standard_derivatives:  false
 INFO[Main]: Irrlicht: GL_OES_stencil1:  false
 INFO[Main]: Irrlicht: GL_OES_stencil4:  false
 INFO[Main]: Irrlicht: GL_OES_stencil8:  false
 INFO[Main]: Irrlicht: GL_OES_stencil_wrap:  false
 INFO[Main]: Irrlicht: GL_OES_surfaceless_context:  false
 INFO[Main]: Irrlicht: GL_OES_texture_3D:  false
 INFO[Main]: Irrlicht: GL_OES_texture_cube_map:  false
 INFO[Main]: Irrlicht: GL_OES_texture_env_crossbar:  false
 INFO[Main]: Irrlicht: GL_OES_texture_float:  false
 INFO[Main]: Irrlicht: GL_OES_texture_float_linear:  false
 INFO[Main]: Irrlicht: GL_OES_texture_half_float:  false
 INFO[Main]: Irrlicht: GL_OES_texture_half_float_linear:  false
 INFO[Main]: Irrlicht: GL_OES_texture_mirrored_repeat:  false
 INFO[Main]: Irrlicht: GL_OES_texture_npot:  false
 INFO[Main]: Irrlicht: GL_OES_vertex_array_object:  false
 INFO[Main]: Irrlicht: GL_OES_vertex_half_float:  false
 INFO[Main]: Irrlicht: GL_OES_vertex_type_10_10_10_2:  false
 INFO[Main]: Irrlicht: GL_QCOM_alpha_test:  false
 INFO[Main]: Irrlicht: GL_QCOM_binning_control:  false
 INFO[Main]: Irrlicht: GL_QCOM_driver_control:  false
 INFO[Main]: Irrlicht: GL_QCOM_extended_get:  false
 INFO[Main]: Irrlicht: GL_QCOM_extended_get2:  false
 INFO[Main]: Irrlicht: GL_QCOM_performance_monitor_global_mode:  false
 INFO[Main]: Irrlicht: GL_QCOM_tiled_rendering:  false
 INFO[Main]: Irrlicht: GL_QCOM_writeonly_rendering:  false
 INFO[Main]: Irrlicht: GL_SUN_multi_draw_arrays:  false
 INFO[Main]: Irrlicht: GL_VIV_shader_binary:  false
 VERBOSE[Main]: Irrlicht: COGLES2ExtensionHandler::initExtensions - GL_MAX_TEXTURE_IMAGE_UNITS = 0
 VERBOSE[Main]: Irrlicht: COGLES2ExtensionHandler::initExtensions - GL_MAX_TEXTURE_SIZE = 0
 VERBOSE[Main]: Irrlicht: COGLES2ExtensionHandler::initExtensions - GL_ALIASED_LINE_WIDTH_RANGE = 0.000000
 VERBOSE[Main]: Irrlicht: COGLES2ExtensionHandler::initExtensions - GL_ALIASED_POINT_SIZE_RANGE = 0.000000

User avatar
PeterO
Posts: 3638
Joined: Sun Jul 22, 2012 4:14 pm

Re: Minetest with OpenGL ES

Wed Sep 16, 2015 12:43 pm

Does it show ANY extensions as being supported? I don't think those extensions are supported, and since they are extensions they are optional.

If they are all needed then I might have misled you and you might do better off with the Mesa libraries if they support those extensions BUT I think they are (or at least used to be) host based so performance will be poor compared to the GPU based version. I've only ever used the native GPU openGL ES provided with the PI.

PeterO
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),Aeromodelling,1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson

Amicadi
Posts: 10
Joined: Wed Sep 16, 2015 3:17 am

Re: Minetest with OpenGL ES

Wed Sep 16, 2015 12:55 pm

No,

Code: Select all

core::stringc extensions = glGetString(GL_EXTENSIONS);
returns just empty string.

Also for this calls:

Code: Select all

GLint val=0;
glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, &val);
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &val);
glGetFloatv(GL_ALIASED_LINE_WIDTH_RANGE, DimAliasedLine);
glGetFloatv(GL_ALIASED_POINT_SIZE_RANGE, DimAliasedPoint);
is returned:

Code: Select all

VERBOSE[Main]: Irrlicht: COGLES2ExtensionHandler::initExtensions - GL_MAX_TEXTURE_IMAGE_UNITS = 0
 VERBOSE[Main]: Irrlicht: COGLES2ExtensionHandler::initExtensions - GL_MAX_TEXTURE_SIZE = 0
 VERBOSE[Main]: Irrlicht: COGLES2ExtensionHandler::initExtensions - GL_ALIASED_LINE_WIDTH_RANGE = 0.000000
 VERBOSE[Main]: Irrlicht: COGLES2ExtensionHandler::initExtensions - GL_ALIASED_POINT_SIZE_RANGE = 0.000000
Even:

Code: Select all

const core::stringc stringVer(glGetString(GL_VERSION));
returns empty string...

User avatar
PeterO
Posts: 3638
Joined: Sun Jul 22, 2012 4:14 pm

Re: Minetest with OpenGL ES

Wed Sep 16, 2015 12:59 pm

That doesn't look right ! Maybe try a simple bit of code that just calls glGetString and see what it produces.

PeterO
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),Aeromodelling,1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson

Amicadi
Posts: 10
Joined: Wed Sep 16, 2015 3:17 am

Re: Minetest with OpenGL ES

Wed Sep 16, 2015 1:03 pm

BTW, I don't think any of those extensions support is mandatory for raspberry pi client since android client is working properly built without the mesa libs... includes at android are like you pointed out. So, I think that your lead is correct ;)

Those extension are queried for setting up some stuff:

Code: Select all

       #ifdef GL_EXT_texture_filter_anisotropic
                if (FeatureAvailable[IRR_EXT_texture_filter_anisotropic])
                {
                        glGetIntegerv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &val);
                        MaxAnisotropy = static_cast<u8>(val);
                }
        #endif
        #ifdef GL_MAX_ELEMENTS_INDICES
                glGetIntegerv(GL_MAX_ELEMENTS_INDICES, &val);
                MaxIndices = val;
        #endif
                glGetIntegerv(GL_MAX_TEXTURE_SIZE, &val);
                MaxTextureSize = static_cast<u32>(val);
        #ifdef GL_EXT_texture_lod_bias 
               if (FeatureAvailable[IRR_EXT_texture_lod_bias])
                {
                        glGetFloatv(GL_MAX_TEXTURE_LOD_BIAS_EXT, &MaxTextureLODBias);
                }
        #endif

Amicadi
Posts: 10
Joined: Wed Sep 16, 2015 3:17 am

Re: Minetest with OpenGL ES

Wed Sep 16, 2015 1:53 pm

Yes, I added:

Code: Select all

GLint val=0;
char xx[255];

glGetIntegerv(GL_MAX_TEXTURE_SIZE, &val);
sprintf(xx, "\nCOGLES2ExtensionHandler::initExtensions - GL_MAX_TEXTURE_SIZE = %i \n", val);
printf(xx);
Previous and after OpenGL initialization at /opt/vc/src/hello_pi/hello_triangle/triangle.c

Output was like this:

Code: Select all

Before OGL init
COGLES2ExtensionHandler::initExtensions - GL_MAX_TEXTURE_SIZE = 0 
After OGL init
COGLES2ExtensionHandler::initExtensions - GL_MAX_TEXTURE_SIZE = 2048
So, I guess, that at Irrlicht side (even not showing any EGLERROR at eglChooseConfig, eglCreatePixmapSurface, eglCreateContext or eglMakeCurrent ) when querrying GLValues it fails due to wrong initialization.

So, I need to recheck how I initializated OGL.

If anybody is willing to recheck, at first post are the modified classes showing the changes I made. Also, this thread has info for building the whole thing :)

User avatar
PeterO
Posts: 3638
Joined: Sun Jul 22, 2012 4:14 pm

Re: Minetest with OpenGL ES

Wed Sep 16, 2015 2:01 pm

Check the initialisation code in the hello_triangle example. You need to call bcm_host_init(); before anyting else EGL or GL ES related.

PeterO
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),Aeromodelling,1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson

Amicadi
Posts: 10
Joined: Wed Sep 16, 2015 3:17 am

Re: Minetest with OpenGL ES

Wed Sep 16, 2015 2:57 pm

Added bcm_host_init(); at CEGLManager.cpp

Code: Select all

#elif defined(_IRR_COMPILE_WITH_X11_DEVICE_)
   bcm_host_init();
   EglWindow = (NativeWindowType)Data.OpenGLLinux.X11Window;
   Display *x_display = (Display*)Data.OpenGLLinux.X11Display;
and added -lbcm_host flag for linking libIrrlicht.a

I got exactly same output as without bcm_host_init();

Curiously at triangle example if I comment out bcm_host_init(), then:

Code: Select all

 state->surface = eglCreateWindowSurface( state->display, config, &nativewindow, NULL );
fails with EGL_NO_SURFACE, but not at Irrlicht - CEGLManager::generateSurface

Code: Select all

eglCreateGlobalImageBRCM(width, height, pixmap[4], 0, width*4, pixmap);
EglSurface = eglCreatePixmapSurface(EglDisplay, EglConfig, /**(long unsigned int)*/pixmap, 0);
It success with or without bcm_host_init() !!!... curious

Should I change eglCreatePixmapSurface to eglCreateWindowSurface ?

Original CEGLManager.cpp code for looks like this:

Code: Select all

    // Now we are able to create EGL surface.
    EglSurface = eglCreateWindowSurface(EglDisplay, EglConfig, EglWindow, 0);

    if (EGL_NO_SURFACE == EglSurface)
        EglSurface = eglCreateWindowSurface(EglDisplay, EglConfig, 0, 0);

    if (EGL_NO_SURFACE == EglSurface)
        os::Printer::log("Could not create EGL surface.");
but both at https://github.com/kika123/x11eglrpi/bl ... playCopy.c and viewtopic.php?f=63&t=6488 the Egl surface is created with eglCreatePixmapSurface... thats the reason why I changed it.

I'll try changing the code to look more like triangle example :-)

User avatar
PeterO
Posts: 3638
Joined: Sun Jul 22, 2012 4:14 pm

Re: Minetest with OpenGL ES

Wed Sep 16, 2015 3:04 pm

Amicadi wrote:I'll try changing the code to look more like triangle example :-)
That is what I would do ;)

PeterO
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),Aeromodelling,1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson

Amicadi
Posts: 10
Joined: Wed Sep 16, 2015 3:17 am

Re: Minetest with OpenGL ES

Wed Sep 16, 2015 5:28 pm

So, I made changes to previous versions of CIrrDeviceLinux.cpp and CEGLManager.cpp (which can be found in the new attached at zip file)

Unfortunatelly I get a segfault at eglCreateWindowSurface:

Code: Select all

 
 INFO[Main]: Irrlicht: Creating X window...
 INFO[Main]: Irrlicht: Using plain X visual
 VERBOSE[Main]: Irrlicht: Visual chosen: : 33
 VERBOSE[Main]: Irrlicht: Window Location: 1,30 
 Window Dimensions 800 x 585 
 Bit depth : 16
 INFO[Main]: Irrlicht: EGL version: 1.400000
 VERBOSE[Main]: Irrlicht: CirrDeviceLinux.cpp EDT_OGLES2 - context initialized.
 VERBOSE[Main]: Irrlicht: config chosen
 SEGFAULT

#0  0x76b12230 in platform_get_handle () from /opt/vc/lib/libEGL.so
#1  0x76b07e98 in eglCreateWindowSurface () from /opt/vc/lib/libEGL.so
#2  0x00978f38 in irr::video::CEGLManager::generateSurface (this=0xf6b3e8)
    at CEGLManager.cpp:276
#3  0x0095b5a8 in irr::video::COGLES2Driver::COGLES2Driver (this=0xf759c0, 
    params=..., io=0xf56af0, contextManager=0xf6b3e8, 
    __in_chrg=<optimized out>, __vtt_parm=<optimized out>)
    at COGLES2Driver.cpp:93
#4  0x009670b8 in irr::video::createOGLES2Driver (params=..., io=0xf56af0, 
    contextManager=0xf6b3e8) at COGLES2Driver.cpp:3099
#5  0x008546e4 in irr::CIrrDeviceLinux::createDriver (this=0xf56bc8)
    at CIrrDeviceLinux.cpp:638
#6  0x00852c64 in irr::CIrrDeviceLinux::CIrrDeviceLinux (this=0xf56bc8, 
    param=..., __in_chrg=<optimized out>, __vtt_parm=<optimized out>)
    at CIrrDeviceLinux.cpp:151
#7  0x008523ec in irr::createDeviceEx (params=...) at Irrlicht.cpp:95
#8  0x00450d68 in ClientLauncher::create_engine_device (this=0x7efff380, 
    log_level=4) at /home/pi/minetest/src/client/clientlauncher.cpp:561
#9  0x0044f644 in ClientLauncher::init_engine (this=0x7efff380, log_level=4)
    at /home/pi/minetest/src/client/clientlauncher.cpp:327
#10 0x0044dda0 in ClientLauncher::run (this=0x7efff380, game_params=..., 
    cmd_args=...) at /home/pi/minetest/src/client/clientlauncher.cpp:92
#11 0x00733cf0 in main (argc=1, argv=0x7efff614)
I see that at triangle.c the native window is created and configured like this:

Code: Select all

dst_rect.x = 0;
dst_rect.y = 0;
dst_rect.width = state->screen_width;
dst_rect.height = state->screen_height;
    
src_rect.x = 0;
src_rect.y = 0;
src_rect.width = state->screen_width << 16;
src_rect.height = state->screen_height << 16;        

dispman_display = vc_dispmanx_display_open( 0 /* LCD */);
dispman_update = vc_dispmanx_update_start( 0 );
        
dispman_element = vc_dispmanx_element_add ( dispman_update, dispman_display,
    0/*layer*/, &dst_rect, 0/*src*/,
    &src_rect, DISPMANX_PROTECTION_NONE, 0 /*alpha*/, 0/*clamp*/, 0/*transform*/);
    
nativewindow.element = dispman_element;
nativewindow.width = state->screen_width;
nativewindow.height = state->screen_height;
vc_dispmanx_update_submit_sync( dispman_update );

state->surface = eglCreateWindowSurface( state->display, config, &nativewindow, NULL );
At Irrlicht side, I create window like this:

Code: Select all

EglDisplay = XDisplay = XOpenDisplay(0);

//.....

XWindow = XCreateWindow(XDisplay,
                RootWindow(XDisplay, VisualInfo->screen),
                x, y, Width, Height, 0, VisualInfo->depth,
                InputOutput, VisualInfo->visual,
                CWBorderPixel | CWColormap | CWEventMask | CWOverrideRedirect,
                &WndAttributes);

XMapWindow ( x_display , (Window)EglWindow );
XStoreName ( x_display , (Window)EglWindow , "GL test" ); // Title will be changed later at Minetest

//..... CODE NOT AFFECTING
//..... THE XWindow PARAMETER

EglSurface = eglCreateWindowSurface(EglDisplay, EglConfig, EglWindow, 0);
Should be added something to the XWindow (as example EglWindow.element, EglWindow.width or/and EglWindow.height) or/and are those vc_dispmanx_* calls mandatory?
Attachments
Irrlicht ogl es 1.9.0 mod files_2.zip
(22.26 KiB) Downloaded 89 times

User avatar
PeterO
Posts: 3638
Joined: Sun Jul 22, 2012 4:14 pm

Re: Minetest with OpenGL ES

Wed Sep 16, 2015 5:46 pm

You shouldbn't be doing anything with X windows. X and openGLES do not work together on the PI. You need to use the code in hello_triangle.c to create the EGL surface and then work from there. You will also need to provide some means of picking up keyboard and mouse events if your application needs them.

PeterO
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),Aeromodelling,1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson

Amicadi
Posts: 10
Joined: Wed Sep 16, 2015 3:17 am

Re: Minetest with OpenGL ES

Wed Sep 16, 2015 6:27 pm

Quake 3 arena is doing fine with SDL 1.2 at Raspberry pi. I guess that would be another option, since Irrlicht can also be configured with _IRR_COMPILE_WITH_SDL_DEVICE_ instead of _IRR_COMPILE_WITH_X11_DEVICE_.

The problem is that Irrlicht is also missing some stuff with this configuration:

_IRR_COMPILE_WITH_SDL_DEVICE_
_IRR_COMPILE_WITH_EGL_MANAGER_
_IRR_COMPILE_WITH_OGLES1_ / _IRR_COMPILE_WITH_OGLES2_

But well, I could follow that way to see what happens... I can always look at quake 3 arena for raspberry pi code ( https://www.raspbian.org/RaspbianQuake3 ) which is running amazingly smooth :)

Thanks for your help, PeterO

mimi123
Posts: 583
Joined: Thu Aug 22, 2013 3:32 pm

Re: Minetest with OpenGL ES

Sat Nov 28, 2015 7:06 pm

Amicadi wrote:Quake 3 arena is doing fine with SDL 1.2 at Raspberry pi. I guess that would be another option, since Irrlicht can also be configured with _IRR_COMPILE_WITH_SDL_DEVICE_ instead of _IRR_COMPILE_WITH_X11_DEVICE_.

The problem is that Irrlicht is also missing some stuff with this configuration:

_IRR_COMPILE_WITH_SDL_DEVICE_
_IRR_COMPILE_WITH_EGL_MANAGER_
_IRR_COMPILE_WITH_OGLES1_ / _IRR_COMPILE_WITH_OGLES2_

But well, I could follow that way to see what happens... I can always look at quake 3 arena for raspberry pi code ( https://www.raspbian.org/RaspbianQuake3 ) which is running amazingly smooth :)

Thanks for your help, PeterO
It seems that you have the wrong EglDisplay and/or context.
Did you try X11EGLRPI? Set up framebuffer_depth=32 and framebuffer_ignore_alpha=1 in config.txt to try it :)

jdonald
Posts: 10
Joined: Fri Nov 03, 2017 4:36 pm

Re: Minetest with OpenGL ES

Tue Nov 21, 2017 5:25 pm

In case others come across this post since the two years it was last updated, check out the more recent Irrlicht thread. There I have posted code changes and a build procedure for linking and running Minetest with the /opt/vc libraries.

Return to “OpenGLES”

Who is online

Users browsing this forum: No registered users and 2 guests