Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[rcore] Desktop platform and OpenGL ES2 at the same time. Is the documentation outdated? #4648

Open
3 of 4 tasks
colesnicov opened this issue Dec 29, 2024 · 2 comments
Open
3 of 4 tasks

Comments

@colesnicov
Copy link

  • I tested it on latest raylib version from master branch
  • I checked there is no similar issue already reported
  • I checked the documentation on the wiki
  • My code has no errors or misuse of raylib

Issue description

With reference to several other issues (#1376, #4236, #1096, #215, #337, #1183), after reading them I didn't learn much.

Environment

Machine: Raspberry PI 2B
OS: Raspbian OS Lite
Protocol: Wayland
OpenGL: ES2.0
Desktop: Vivarium

Code Example

By trial and error, I managed to get raylib working on RPI as DESKTOP under OpenGL ES2, this way (in the raylib folder):

mkdir build
cd build
ccmake ..

This is what my chosen configuration looks like

                                                     Page 1 of 1
 BUILD_EXAMPLES                   OFF
 BUILD_SHARED_LIBS                ON
 CMAKE_BUILD_TYPE                 Debug
 CMAKE_INSTALL_PREFIX             /usr/local
 CUSTOMIZE_BUILD                  OFF
 ENABLE_ASAN                      OFF
 ENABLE_MSAN                      OFF
 ENABLE_UBSAN                     OFF
 GLFW_BUILD_DOCS                  OFF
 GLFW_BUILD_EXAMPLES              OFF
 GLFW_BUILD_TESTS                 OFF
 GLFW_BUILD_WAYLAND               ON
 GLFW_BUILD_X11                   OFF
 GLFW_INSTALL                     OFF
 GLFW_LIBRARY_TYPE                OBJECT
 INCLUDE_EVERYTHING               OFF
 OPENGL_VERSION                   ES 2.0
 PLATFORM                         Desktop
 USE_EXTERNAL_GLFW                IF_POSSIBLE
 WAYLAND_SCANNER_EXECUTABLE       /usr/bin/wayland-scanner
 WITH_PIC                         ON
 glfw3_DIR                        glfw3_DIR-NOTFOUND
 pthread                          /usr/lib/arm-linux-gnueabihf/libpthread.a

I have the GLFW library installed on my system, but raylib can't find it.

make -j4
sudo make install

Output:

[  4%] Generating fractional-scale-v1-client-protocol.h
[  4%] Generating xdg-shell-client-protocol.h
[  6%] Generating fractional-scale-v1-client-protocol-code.h
[  8%] Generating idle-inhibit-unstable-v1-client-protocol-code.h
[ 10%] Generating idle-inhibit-unstable-v1-client-protocol.h
[ 12%] Generating pointer-constraints-unstable-v1-client-protocol-code.h
[ 14%] Generating pointer-constraints-unstable-v1-client-protocol.h
[ 16%] Generating relative-pointer-unstable-v1-client-protocol-code.h
[ 18%] Generating relative-pointer-unstable-v1-client-protocol.h
[ 20%] Generating viewporter-client-protocol-code.h
[ 22%] Generating viewporter-client-protocol.h
[ 25%] Generating wayland-client-protocol-code.h
[ 29%] Generating xdg-activation-v1-client-protocol-code.h
[ 29%] Generating wayland-client-protocol.h
[ 31%] Generating xdg-activation-v1-client-protocol.h
[ 33%] Generating xdg-decoration-unstable-v1-client-protocol-code.h
[ 35%] Generating xdg-decoration-unstable-v1-client-protocol.h
[ 37%] Generating xdg-shell-client-protocol-code.h
[ 43%] Building C object raylib/external/glfw/src/CMakeFiles/glfw.dir/input.c.o
[ 43%] Building C object raylib/external/glfw/src/CMakeFiles/glfw.dir/context.c.o
[ 43%] Building C object raylib/external/glfw/src/CMakeFiles/glfw.dir/init.c.o
[ 45%] Building C object raylib/external/glfw/src/CMakeFiles/glfw.dir/monitor.c.o
[ 47%] Building C object raylib/external/glfw/src/CMakeFiles/glfw.dir/platform.c.o
[ 50%] Building C object raylib/external/glfw/src/CMakeFiles/glfw.dir/vulkan.c.o
[ 52%] Building C object raylib/external/glfw/src/CMakeFiles/glfw.dir/window.c.o
[ 54%] Building C object raylib/external/glfw/src/CMakeFiles/glfw.dir/egl_context.c.o
[ 56%] Building C object raylib/external/glfw/src/CMakeFiles/glfw.dir/osmesa_context.c.o
[ 58%] Building C object raylib/external/glfw/src/CMakeFiles/glfw.dir/null_init.c.o
[ 60%] Building C object raylib/external/glfw/src/CMakeFiles/glfw.dir/null_monitor.c.o
[ 62%] Building C object raylib/external/glfw/src/CMakeFiles/glfw.dir/null_window.c.o
[ 64%] Building C object raylib/external/glfw/src/CMakeFiles/glfw.dir/null_joystick.c.o
[ 66%] Building C object raylib/external/glfw/src/CMakeFiles/glfw.dir/posix_module.c.o
[ 68%] Building C object raylib/external/glfw/src/CMakeFiles/glfw.dir/posix_time.c.o
[ 70%] Building C object raylib/external/glfw/src/CMakeFiles/glfw.dir/posix_thread.c.o
[ 72%] Building C object raylib/external/glfw/src/CMakeFiles/glfw.dir/wl_init.c.o
[ 75%] Building C object raylib/external/glfw/src/CMakeFiles/glfw.dir/wl_monitor.c.o
[ 77%] Building C object raylib/external/glfw/src/CMakeFiles/glfw.dir/wl_window.c.o
[ 79%] Building C object raylib/external/glfw/src/CMakeFiles/glfw.dir/xkb_unicode.c.o
[ 81%] Building C object raylib/external/glfw/src/CMakeFiles/glfw.dir/linux_joystick.c.o
[ 83%] Building C object raylib/external/glfw/src/CMakeFiles/glfw.dir/posix_poll.c.o
[ 83%] Built target glfw
[ 87%] Building C object raylib/CMakeFiles/raylib.dir/raudio.c.o
[ 87%] Building C object raylib/CMakeFiles/raylib.dir/rcore.c.o
[ 89%] Building C object raylib/CMakeFiles/raylib.dir/rmodels.c.o
[ 91%] Building C object raylib/CMakeFiles/raylib.dir/rshapes.c.o
[ 93%] Building C object raylib/CMakeFiles/raylib.dir/rtext.c.o
[ 95%] Building C object raylib/CMakeFiles/raylib.dir/rtextures.c.o
[ 97%] Building C object raylib/CMakeFiles/raylib.dir/utils.c.o
[100%] Linking C shared library libraylib.so
[100%] Built target raylib
denis@raspberrypi:~/dev/raylib/build $ 

But I also need to verify the examples that everything actually works:

cd ../examples
make -j4

Of course, it fails again because as we know (we wrote about it here) these examples require glut to compile, which I don't have.

gcc -o others/raylib_opengl_interop others/raylib_opengl_interop.c -Wall -std=c99 -D_DEFAULT_SOURCE -Wno-missing-braces -Wunused-result -O2 -D_DEFAULT_SOURCE -I. -I/home/denis/dev/raylib/src -I/home/denis/dev/raylib/src/external  -I/usr/local/include -I/home/denis/dev/raylib/src/external/glfw/include -L. -L/home/denis/dev/raylib/src -L/home/denis/dev/raylib/src -L/usr/local/lib -lraylib -lGL -lm -lpthread -ldl -lrt -lX11 -latomic -latomic -DPLATFORM_DESKTOP -DPLATFORM_DESKTOP_GLFW
/usr/bin/ld: /tmp/ccF7fBVC.o: in function `main':
raylib_opengl_interop.c:(.text.startup+0x208): undefined reference to `glad_glGenVertexArrays'
/usr/bin/ld: raylib_opengl_interop.c:(.text.startup+0x20c): undefined reference to `glad_glBindVertexArray'
/usr/bin/ld: raylib_opengl_interop.c:(.text.startup+0x210): undefined reference to `glad_glGenBuffers'
/usr/bin/ld: raylib_opengl_interop.c:(.text.startup+0x214): undefined reference to `glad_glBindBuffer'
/usr/bin/ld: raylib_opengl_interop.c:(.text.startup+0x21c): undefined reference to `glad_glBufferData'
/usr/bin/ld: raylib_opengl_interop.c:(.text.startup+0x224): undefined reference to `glad_glVertexAttribPointer'
/usr/bin/ld: raylib_opengl_interop.c:(.text.startup+0x230): undefined reference to `glad_glUseProgram'
/usr/bin/ld: raylib_opengl_interop.c:(.text.startup+0x234): undefined reference to `glad_glEnableVertexAttribArray'
/usr/bin/ld: raylib_opengl_interop.c:(.text.startup+0x238): undefined reference to `glad_glEnable'
/usr/bin/ld: raylib_opengl_interop.c:(.text.startup+0x248): undefined reference to `glad_glUniform1f'
/usr/bin/ld: raylib_opengl_interop.c:(.text.startup+0x250): undefined reference to `glad_glUniform4fv'
/usr/bin/ld: raylib_opengl_interop.c:(.text.startup+0x254): undefined reference to `glad_glUniformMatrix4fv'
/usr/bin/ld: raylib_opengl_interop.c:(.text.startup+0x258): undefined reference to `glad_glDrawArrays'
/usr/bin/ld: raylib_opengl_interop.c:(.text.startup+0x25c): undefined reference to `glad_glDeleteBuffers'
/usr/bin/ld: raylib_opengl_interop.c:(.text.startup+0x260): undefined reference to `glad_glDeleteVertexArrays'
collect2: error: ld returned 1 exit status
make: *** [Makefile:697: others/raylib_opengl_interop] Error 1

With this, at least part of the example can be tried:

cd core
./core_basic_window

Output:

INFO: Initializing raylib 5.6-dev
INFO: Platform backend: DESKTOP (GLFW)
INFO: Supported raylib modules:
INFO:     > rcore:..... loaded (mandatory)
INFO:     > rlgl:...... loaded (mandatory)
INFO:     > rshapes:... loaded (optional)
INFO:     > rtextures:. loaded (optional)
INFO:     > rtext:..... loaded (optional)
INFO:     > rmodels:... loaded (optional)
INFO:     > raudio:.... loaded (optional)
WARNING: GLFW: Error: 65548 Description: Wayland: The platform does not provide the window position
INFO: DISPLAY: Device initialized successfully
INFO:     > Display size: 400 x 1280
INFO:     > Screen size:  800 x 450
INFO:     > Render size:  800 x 450
INFO:     > Viewport offsets: 0, 0
WARNING: GLFW: Error: 65548 Description: Wayland: The platform does not support setting the window position
INFO: GL: Supported extensions count: 59
INFO: GL: OpenGL device information:
INFO:     > Vendor:   Broadcom
INFO:     > Renderer: VC4 V3D 2.1
INFO:     > Version:  OpenGL ES 2.0 Mesa 23.2.1-1~bpo12+rpt3
INFO:     > GLSL:     OpenGL ES GLSL ES 1.0.16
INFO: GL: VAO extension detected, VAO functions loaded successfully
INFO: GL: NPOT textures extension detected, full NPOT textures supported
INFO: GL: DXT compressed textures supported
INFO: GL: ETC1 compressed textures supported
INFO: PLATFORM: DESKTOP (GLFW - Wayland): Initialized successfully
INFO: TEXTURE: [ID 1] Texture loaded successfully (1x1 | R8G8B8A8 | 1 mipmaps)
INFO: TEXTURE: [ID 1] Default texture loaded successfully
INFO: SHADER: [ID 1] Vertex shader compiled successfully
INFO: SHADER: [ID 2] Fragment shader compiled successfully
INFO: SHADER: [ID 3] Program shader loaded successfully
INFO: SHADER: [ID 3] Default shader loaded successfully
INFO: RLGL: Render batch vertex buffers loaded successfully in RAM (CPU)
INFO: RLGL: Render batch vertex buffers loaded successfully in VRAM (GPU)
INFO: RLGL: Default OpenGL state initialized successfully
INFO: TEXTURE: [ID 2] Texture loaded successfully (128x128 | GRAY_ALPHA | 1 mipmaps)
INFO: FONT: Default font loaded successfully (224 glyphs)
INFO: SYSTEM: Working Directory: /home/denis/dev/raylib/examples/core
INFO: TIMER: Target time per frame: 16.667 milliseconds

There are some errors in the report WARNING: GLFW: Error: 65548 Description: Wayland: The platform does not support setting the window position but they are related to Vivarium. The report will be sent to the appropriate departments.

IMG_20241229_161417

and also My Heard Beat cd ../models && ./models_bone_socket

IMG_20241229_161732

Works and decent FPS
60 FPS (1000/16.5=60.6) I think FPS is limited by the refresh rate of the display. On my computer it runs at 144HZ..

When I tried RAYLIB under DRM, the FPS was 4! Basically now it's the same speed I achieved with my DRM implementation without RAYLIB as it is now with raylib..

So. As I already wrote, I read some issues here and there is nothing useful. It is written everywhere that raylib cannot support both DESKTOP and OpenGL ES2 at the same time. But it can, it just needs to be updated a bit in the documentation and instructions, and maybe even cmake?

@colesnicov
Copy link
Author

Now that I think about it, the other windows open correctly. Even mine, which use GLFW installed on the system, I mentioned that raylib doesn't see the GLFW system library.

This program uses the GLFW system library and opens correctly without reporting any warnings:

IMG_20241229_164409

@Peter0x44
Copy link
Contributor

It is written everywhere that raylib cannot support both DESKTOP and OpenGL ES2 at the same time.

Where is this written?

@raysan5 raysan5 changed the title Desktop platform and OpenGL ES2 at the same time. Is the documentation outdated? [rcore] Desktop platform and OpenGL ES2 at the same time. Is the documentation outdated? Dec 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants