raysan5 / raylib

A simple and easy-to-use library to enjoy videogames programming
http://www.raylib.com
zlib License
21.21k stars 2.16k forks source link

[examples] Review some examples not working properly on several platforms #3487

Closed raysan5 closed 2 days ago

raysan5 commented 10 months ago

Issues on multiple platforms

Issues on PLATFORM_DESKTOP, macOS (and maybe other platforms/OSs)

Issues on PLATFORM_WEB

Issues on PLATFORM_DRM

Note that some of the issues seem related to platform/OpenGL limitations.

In any case, any help with those examples is really welcome.

raysan5 commented 10 months ago

@ubkp @michaelfiber Just opened this issue for further discussion on the examples not working properly that you reported. Actually some of them are not intended to work on the target platform while others have specific concerns.

@Bigfoot71 not sure if you tested all the examples on PLATFORM_ANDROID and you also found some issues there...

ghost commented 10 months ago
Platftorm Example Status Comment
Desktop core_3d_camera_free :heavy_check_mark: Fixes on #3240 and #3488.
Web models_skybox :heavy_check_mark: It's working, but requires SUPPORT_FILEFORMAT_HDR to be enabled on config.h.
Web core_loading_thread :x: IMHO, I don't think this example should work (at least for now) on PLATFORM_WEB. See the warning on L602-L605, which I think is warranted (check this and this). I don't think this feature is mature enough yet.

Note: There was a recent PR related to this example: #3449
Web rlgl_standalone :question: I think this should/could work. I've added the necessary lines to the Makefile.Web but for some reason it just refuses to link to the GLES2/gl2.h inside emscripten's upstream/emscripten/cache/sysroot/include.

At the moment I'm still unable to make it compile for web.
Web shaders_mesh_instancing :question: I believe the example itself is working. Compiled and uploaded it to Github at https://ubkp.github.io/shaders_mesh_instancing.html and it's working correctly.

Testing it on https://www.raylib.com/examples.html I get the errors from the screenshot on Note 1.

My best guess is that the problem could be related to the way the example gets built and/or run on raylib.com.
DRM Examples with 3D cameras:
models_first_person_maze
core_3d_camera_free
etc
:heavy_check_mark: Fix on #3492.
DRM Examples with visible cursors:
shapes_draw_circle_sector
shapes_draw_ring
etc
:x: Although the examples are working, I think that the cursor is not showing because it's not implemented for DRM (L490-L494).

Not sure how to handle it in this case. I'm assuming that in this platform the cursor would be rendered by the user on the Drawing step of the application.

References: core_input_mouse (L56) and https://github.com/raysan5/raylib/discussions/2952#discussioncomment-7172966.
Platftorm Example Status Comment
DRM Examples with type inputs:
text_draw_3d
text_input_box
etc
:heavy_check_mark: Fix on #3498.
DRM audio_module_playing :question: I have no idea why this is crashing the Raspberry Pi. All I could find was that it happens after restarting the music a few times and then trying to exit the example hitting ESC.
DRM core_vr_simulator :question: The only thing I could find was WARNING: FBO: [ID 1] Framebuffer has incomplete attachment.
DRM models_skybox :x: Got these errors: IMAGE: Data format not supported IMAGE: Failed to load image data.

Looks like the Raspberry Pi 3B doesn't support HDR, perhaps the newer ones do.
DRM shaders_raymarching :x: Issue with the fragment shader: extension GL_OES_standard_derivates unsupported in fragment shader.

Not sure if this example can run on the Raspberry Pi 3B, perhaps the newer ones can.
DRM rlgl_standalone :question: Looks like it's possible that this could be compiled. Just need to add the -L../examples/others/external/lib and -lglfw3. However, it returns an error libglfw3.a: file not recognized: file format not recognized.. Which leads me to believe that .a (file) was compiled for x86 and not ARM.

IMHO, the easiest (and safest) solution would be the user compiling/providing his own libglfw3.a for the Raspberry Pi. Would just be the case of adding that information to the source instructions (L16).

Notes

  1. Screenshot of shaders_mesh_instancing error on raylib.com/examples.html:

img

Edits

1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11. updates.

Bigfoot71 commented 10 months ago

@Bigfoot71 not sure if you tested all the examples on PLATFORM_ANDROID and you also found some issues there...

No, from memory, the few issues I had noticed last time have been fixed, and even GetMouseDelta() was implemented as a bonus. I had tried an example in each category on the site, including several from CORE.

I will try all of them tomorrow and provide a brief report. Normally, except for some shader examples, I believe they should all be able to run without any problems.

Edit: I had already mentioned it, but unfortunately, I won't be able to try the example for the gamepad.

ghost commented 10 months ago

@Bigfoot71 Maybe https://github.com/raysan5/raylib/issues/3371 could help?

At that time I went through all examples. The ones with a comment 2 on the tables (e.g.: core_custom_logging, core_drop_files, etc) are probably the ones that could use some testing.

Bigfoot71 commented 10 months ago

@ubkp But how do you plan to make core_drop_files work on Android? Edit: Thanks for the list, it will definitely save me time if some things are already tested

ghost commented 10 months ago

@Bigfoot71 I just meant as a reference. Those were just the ones I couldn't get to work completely here. I think most of those marked with 2 are indeed not meant to run on Android.

ghost commented 10 months ago

@raysan5 Updated status table at https://github.com/raysan5/raylib/issues/3487#issuecomment-1786050159.

SuperUserNameMan commented 10 months ago

maybe SUPPORT_CUSTOM_FRAME_CONTROL could be replaced by a function to enable/disable it at runtime ?

raysan5 commented 10 months ago

@ubkp Thank you very much for the detailed table and reviews! Here my comments about some of the examples:

Other possible issues:

There are probably other example issues but I think most of them work as expected, I plan to do a full examples-test-pass for Windows and Web in the following days, if anything significant popups I will update this issue.

Bigfoot71 commented 10 months ago

Android Tests

I have tried almost all the examples in core, shape, textures, text, and models, as well as the 6 audio examples and some of the shader examples that seemed most relevant on Android (with https://github.com/raysan5/raylib/commit/df0f7ba61e6a89e493d8b6313001ecf6a7231e5a).

Most of the untested examples are those directly related to the keyboard, physical mouse, or gamepad.

All the tested examples were able to compile and run without any issues (except one, see below), including those using raygui.h! So, I will present the problems rather than list what works.

Issues

Issues in video

https://github.com/raysan5/raylib/assets/90587919/ec231c59-f4cb-4ae0-908f-f4b8204b935c

Finally

Everything, whether it's image generation/manipulation, shape rendering (2D/3D), model animation, gestures, fonts, sound, shaders, etc... Everything seems to work apart from the Z-fighting problem that I noticed for 3D.

Edit: Honestly, this Android test is quite successful, and the third issue doesn't even belong here, but well, we need to fill the report, lol.

ghost commented 10 months ago

@raysan5 Updated the status table (https://github.com/raysan5/raylib/issues/3487#issuecomment-1786050159) with the comments on the other DRM examples.

Bigfoot71 commented 9 months ago

@raysan5 I found how to resolve the Z-Fighting issue I mentioned earlier. (on Android)

You need to modify the floating-point precision of the default shader as follows:

#if defined(GRAPHICS_API_OPENGL_ES2)
    "#version 100                       \n"
-   "precision mediump float;           \n"     // Precision required for OpenGL ES2 (WebGL) (on some browsers)
+   "precision highp float;             \n"     // Precision required for OpenGL ES2 (WebGL) (on some browsers)
    "attribute vec3 vertexPosition;     \n"
    "attribute vec2 vertexTexCoord;     \n"
    "attribute vec4 vertexColor;        \n"
    "varying vec2 fragTexCoord;         \n"
    "varying vec4 fragColor;            \n"
#endif

However, after some research, it seems that this Z-Fighting issue, which can be resolved by modifying the floating-point precision in the shader, only occurs on certain devices (not high-end or older ones).

ghost commented 9 months ago

@Bigfoot71 Related: #3260, #3261.

Bigfoot71 commented 9 months ago

So in short, highp cause some browsers issues for compiling the shader, so the solution was to use mediump, which doesn't seem to have caused any visual issues on PLATFORM_WEB so far, but it does cause issues on some Android devices.

ghost commented 9 months ago

@Bigfoot71 Perhaps an #ifdef there could solve that for both?

#if defined(PLATFORM_WEB)
   "precision mediump float;           \n"     // Precision required for OpenGL ES2 (WebGL) (on some browsers)
#elif defined(PLATFORM_ANDROID)
   "precision highp float;             \n"
#endif
Bigfoot71 commented 9 months ago

@ubkp I thought about it, but it's not very clean, is it? Though it would certainly reconcile both issues. Perhaps it would be a good idea to at least comment the explanation, I'm in favor of it; let's see what @raysan5 thinks. He seemed inclined to remove it at the slightest issue.

raysan5 commented 9 months ago

I think this is not the best approach, many Android devices do not support highp requirement and afair, this hint only defines the minimum precision requirement, it's up to the driver to do it or not or choose a higher precission if available.

EDIT: Also note, in raylib I always priorize supporting old and low-end devices.

Bigfoot71 commented 9 months ago

@raysan5 I think we should be able to do something like this to check if the device is capable of supporting highp or not (doc):

#if defined(GL_FRAGMENT_PRECISION_HIGH)
    precision highp float;
#else
    precision mediump float;
#endif

But it's not any cleaner, anyway. So we leave it as is I guess.

This issue with mediump and Z-Fighting only occurs on certain devices and under certain conditions. I hadn't even noticed it on my device during "normal" use.

raysan5 commented 9 months ago

This issue with mediump and Z-Fighting only occurs on certain devices and under certain conditions. I hadn't even noticed it on my device during "normal" use.

@Bigfoot71 I really think it's platform/drivers-dependant and there is not a good solution to cover most use case. Better leave it as it is. In any case, advance users can change it for their needs depending on their target audience and development process.

raysan5 commented 9 months ago

@ubkp @Bigfoot71 I reviewed rlgl_standalone example, I'm afraid it is PLATFORM_DESKTOP exclusive and supporting other platforms would require some redesign. I just added a note explaining this. The examples uses GLFW to initialize the platform layer and the OpenGL 3.3 Core profile context. It could work on web with OpenGL ES 2.0 but it would need a redesign, I think it's out-of-scope for the moment for this example.

Actually, all examples in others are somewhat special and are not intended to work on all platforms or under "all scenarios".

I think we can continue with the raylib 5.0 release despite some issues with the examples, they can be reviewed in the future as required.

As a side note, today I implemented a tool to update examples open-graph metada, so examples can be shared on multiple social networks (X, Mastodon, LinkedIn, Discord...) with a fancy visual card showing each example details. I will provide more info asap.

ghost commented 9 months ago

I think we can continue with the raylib 5.0 release despite some issues with the examples, they can be reviewed in the future as required.

Agreed. I think the major problems were solved or documented. The examples issues left don't appear to be super critical.

As a side note, today I implemented a tool to update examples open-graph metada, so examples can be shared on multiple social networks (X, Mastodon, LinkedIn, Discord...) with a fancy visual card showing each example details. I will provide more info asap.

That's awesome! :+1:

erikyuzwa commented 8 months ago

Not sure if it's related, but on Desktop, the core_3d_camera_first_person.c example doesn't work with raylib5. The UI shows up but none of the 3d geography does.

ghost commented 8 months ago

@erikyuzwa Compiled core_3d_camera_first_person from current master branch (10c82595b0b239f34baf34ae0faa5bca9d5088c8) right now and it's working correctly for me on PLATFORM_DESKTOP. Tested on Linux (Ubuntu 22.04 64-bit). Screenshot:

screenshot000

Could you post the log so we can see if there's some error there?

erikyuzwa commented 8 months ago

totally believe you @ubkp - I'm using the gamejam template on VS2022. Other examples have worked ok as-is up until now. I don't see a log, but I've confirmed I'm building in debug mode.

i've even removed the raylib project in the game template, pulled down a fresh git clone of raylib and am linking to that. Same result.

ghost commented 8 months ago

@erikyuzwa All the examples should output a standard log by default on the terminal/console. Something like this:

INFO: Initializing raylib 5.1-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)
INFO: DISPLAY: Device initialized successfully
INFO:     > Display size: 1600 x 900
INFO:     > Screen size:  800 x 450
INFO:     > Render size:  800 x 450
INFO:     > Viewport offsets: 0, 0
INFO: GLAD: OpenGL extensions loaded successfully
INFO: GL: Supported extensions count: 173
INFO: GL: OpenGL device information:
INFO:     > Vendor:   Intel
INFO:     > Renderer: Mesa Intel(R) HD Graphics 3000 (SNB GT2)
INFO:     > Version:  3.3 (Core Profile) Mesa 23.0.4-0ubuntu1~22.04.1
INFO:     > GLSL:     3.30
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: ETC2/EAC compressed textures supported
INFO: PLATFORM: DESKTOP (GLFW): 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: TIMER: Target time per frame: 16.667 milliseconds
INFO: TEXTURE: [ID 2] Unloaded texture data from VRAM (GPU)
INFO: SHADER: [ID 3] Default shader unloaded successfully
INFO: TEXTURE: [ID 1] Default texture unloaded successfully
INFO: Window closed successfully

Since you're on Windows, please check if your compiler is using the -mwindows flag or -Wl,--subsystem,windows (which will hide the console on Windows). In that case, please remove that temporarily, recompile the example and try opening it on the terminal/console.

Edits: 1. editing; 2. correction.

erikyuzwa commented 8 months ago

thanks for your patience. Yes, of course it's there in that console window - my bad. (I'm used to web servers all day and scouring through and tailing log files).

If you'd prefer me moving this to a new issue I'm fine with that too

Here's what I'm seeing:


INFO: Initializing raylib 5.1-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)
INFO: DISPLAY: Device initialized successfully
INFO:     > Display size: 1920 x 1080
INFO:     > Screen size:  1280 x 720
INFO:     > Render size:  1280 x 720
INFO:     > Viewport offsets: 0, 0
INFO: GLAD: OpenGL extensions loaded successfully
INFO: GL: Supported extensions count: 400
INFO: GL: OpenGL device information:
INFO:     > Vendor:   NVIDIA Corporation
INFO:     > Renderer: NVIDIA GeForce RTX 2070 SUPER/PCIe/SSE2
INFO:     > Version:  3.3.0 NVIDIA 546.33
INFO:     > GLSL:     3.30 NVIDIA via Cg compiler
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: ETC2/EAC compressed textures supported
INFO: PLATFORM: DESKTOP (GLFW): 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: TIMER: Target time per frame: 16.667 milliseconds
INFO: TEXTURE: [ID 3] Texture loaded successfully (1280x720 | R8G8B8A8 | 1 mipmaps)
INFO: TEXTURE: [ID 1] Depth renderbuffer loaded successfully (32 bits)
INFO: FBO: [ID 1] Framebuffer object created successfully
INFO: TIMER: Target time per frame: 16.667 milliseconds
INFO: FBO: [ID 1] Unloaded framebuffer from VRAM (GPU)
INFO: TEXTURE: [ID 2] Unloaded texture data from VRAM (GPU)
INFO: SHADER: [ID 3] Default shader unloaded successfully
INFO: TEXTURE: [ID 1] Default texture unloaded successfully
INFO: Window closed successfully```
ghost commented 8 months ago

@erikyuzwa Yeah, probably a better idea to open a new issue regarding this one. Thanks for the log. There's something there I don't recall seeing before. On this section:

INFO: TEXTURE: [ID 2] Texture loaded successfully (128x128 | GRAY_ALPHA | 1 mipmaps)
INFO: FONT: Default font loaded successfully (224 glyphs)
INFO: TIMER: Target time per frame: 16.667 milliseconds
INFO: TEXTURE: [ID 3] Texture loaded successfully (1280x720 | R8G8B8A8 | 1 mipmaps)
INFO: TEXTURE: [ID 1] Depth renderbuffer loaded successfully (32 bits)
INFO: FBO: [ID 1] Framebuffer object created successfully
INFO: TIMER: Target time per frame: 16.667 milliseconds

Not sure why it's doing this:

INFO: TEXTURE: [ID 3] Texture loaded successfully (1280x720 | R8G8B8A8 | 1 mipmaps)
INFO: TEXTURE: [ID 1] Depth renderbuffer loaded successfully (32 bits)
INFO: FBO: [ID 1] Framebuffer object created successfully
INFO: TIMER: Target time per frame: 16.667 milliseconds

Are you using the stock examples/core/core_3d_camera_first_person.c example without modifications?

Edit: typo, editing.

ghost commented 8 months ago

@erikyuzwa You mentioned you're using the gamejam template, right? By any chance are you testing using this structure? If so, please test using just this (exactly as is) instead.

erikyuzwa commented 8 months ago

@ubkp - that worked! Thanks so much. Not sure why the same code dropped into the rendering in the game template didn't but I'll leave that until I work more with textures - thank you SO much and apologies for polluting the OG issue with this.

Here's the log just in case it helps. I will also go through the source to see if I can pipe the log to a file (for eventual testers).

INFO: Initializing raylib 5.1-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)
INFO: DISPLAY: Device initialized successfully
INFO:     > Display size: 1920 x 1080
INFO:     > Screen size:  800 x 450
INFO:     > Render size:  800 x 450
INFO:     > Viewport offsets: 0, 0
INFO: GLAD: OpenGL extensions loaded successfully
INFO: GL: Supported extensions count: 400
INFO: GL: OpenGL device information:
INFO:     > Vendor:   NVIDIA Corporation
INFO:     > Renderer: NVIDIA GeForce RTX 2070 SUPER/PCIe/SSE2
INFO:     > Version:  3.3.0 NVIDIA 546.33
INFO:     > GLSL:     3.30 NVIDIA via Cg compiler
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: ETC2/EAC compressed textures supported
INFO: PLATFORM: DESKTOP (GLFW): 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: TIMER: Target time per frame: 16.667 milliseconds
INFO: TEXTURE: [ID 2] Unloaded texture data from VRAM (GPU)
INFO: SHADER: [ID 3] Default shader unloaded successfully
INFO: TEXTURE: [ID 1] Default texture unloaded successfully
INFO: Window closed successfully
ghost commented 8 months ago

@erikyuzwa No problem, glad it worked. :)

I think the problem was that the gamejam template basic structure, for some reason, opts to render to a texture (L79-L82, L124-L130) and them render that texture to screen (L133-L141).

Most of the examples use a far simpler method of just rendering things directly to screen (e.g.: L144-L196), which is probably what I would recommend using while you're getting used to raylib.

Regarding the log, on Linux it's usually just a matter of piping the log to a file (e.g.: ./core_3d_camera_first_person > LOG). Windows probably have something similar to that, although I don't know the syntax.

Edit: typo.

raysan5 commented 8 months ago

@ubkp @erikyuzwa the gamejam template actually belongs to a previous gamejam that required a 32x32 pixels game and it included code to scale that game x4, so I kept the RenderTexture for convenience, also useful to deal with fixed game sizes/screen-ratios that need to be scaled to screen later on.

About the log output to file, afair, in Windows CMD, core_3d_camera_first_person > mylog.txt should work. But you also have SetTraceLogCallback(TraceLogCallback callback) to output the log messages wherever you want.

erikyuzwa commented 8 months ago

appreciate the followup and insight there @raysan5 🙇

iacore commented 8 months ago

I found a bug, where rlgl_standalone doesn't link GLFW with cmake -D BUILD_SHARED_LIBS=ON.

crystalthoughts commented 7 months ago

The compute shader example doesn't seem to do anything now . I tried both an Odin port and building the VS2022 example. Black screen with GUI but nothing else

raysan5 commented 7 months ago

@crystalthoughts Note that compute shader example requires recompiling raylib for OpenGL 4.3.

crystalthoughts commented 7 months ago

Thanks Ray I'll give it a go (soonish) and report back if there's still an issue

colesnicov commented 3 months ago

On RPI 2B core_basic_window looks good but others...:

denis@raspberrypi:~/dev/raylib-5.0/examples $ make PLATFORM=PLATFORM_DRM
gcc -o others/raylib_opengl_interop others/raylib_opengl_interop.c -Wall -std=c99 -D_DEFAULT_SOURCE -Wno-missing-braces -Wunused-result -O2 -std=gnu99 -DEGL_NO_X11 -I. -I../src -I../src/external -I/usr/local/include -I/usr/include/libdrm -I../src/external/glfw/include -L. -L../src -L../src -lraylib -lGLESv2 -lEGL -lpthread -lrt -lm -lgbm -ldrm -ldl -latomic -DPLATFORM_DRM
others/raylib_opengl_interop.c: In function ‘main’:
others/raylib_opengl_interop.c:94:5: error: unknown type name ‘GLuint’
   94 |     GLuint vao = 0;
      |     ^~~~~~
others/raylib_opengl_interop.c:95:5: error: unknown type name ‘GLuint’
   95 |     GLuint vbo = 0;
      |     ^~~~~~
others/raylib_opengl_interop.c:96:5: warning: implicit declaration of function ‘glGenVertexArrays’ [-Wimplicit-function-declaration]
   96 |     glGenVertexArrays(1, &vao);
      |     ^~~~~~~~~~~~~~~~~
others/raylib_opengl_interop.c:97:5: warning: implicit declaration of function ‘glBindVertexArray’; did you mean ‘rlLoadVertexArray’? [-Wimplicit-function-declaration]
   97 |     glBindVertexArray(vao);
      |     ^~~~~~~~~~~~~~~~~
      |     rlLoadVertexArray
others/raylib_opengl_interop.c:98:9: warning: implicit declaration of function ‘glGenBuffers’ [-Wimplicit-function-declaration]
   98 |         glGenBuffers(1, &vbo);
      |         ^~~~~~~~~~~~
others/raylib_opengl_interop.c:99:9: warning: implicit declaration of function ‘glBindBuffer’ [-Wimplicit-function-declaration]
   99 |         glBindBuffer(GL_ARRAY_BUFFER, vbo);
      |         ^~~~~~~~~~~~
others/raylib_opengl_interop.c:99:22: error: ‘GL_ARRAY_BUFFER’ undeclared (first use in this function)
   99 |         glBindBuffer(GL_ARRAY_BUFFER, vbo);
      |                      ^~~~~~~~~~~~~~~
others/raylib_opengl_interop.c:99:22: note: each undeclared identifier is reported only once for each function it appears in
others/raylib_opengl_interop.c:100:9: warning: implicit declaration of function ‘glBufferData’ [-Wimplicit-function-declaration]
  100 |         glBufferData(GL_ARRAY_BUFFER, MAX_PARTICLES*sizeof(Particle), particles, GL_STATIC_DRAW);
      |         ^~~~~~~~~~~~
others/raylib_opengl_interop.c:100:82: error: ‘GL_STATIC_DRAW’ undeclared (first use in this function); did you mean ‘RL_STATIC_DRAW’?
  100 |         glBufferData(GL_ARRAY_BUFFER, MAX_PARTICLES*sizeof(Particle), particles, GL_STATIC_DRAW);
      |                                                                                  ^~~~~~~~~~~~~~
      |                                                                                  RL_STATIC_DRAW
others/raylib_opengl_interop.c:102:9: warning: implicit declaration of function ‘glVertexAttribPointer’ [-Wimplicit-function-declaration]
  102 |         glVertexAttribPointer(shader.locs[SHADER_LOC_VERTEX_POSITION], 3, GL_FLOAT, GL_FALSE, 0, 0);
      |         ^~~~~~~~~~~~~~~~~~~~~
others/raylib_opengl_interop.c:102:75: error: ‘GL_FLOAT’ undeclared (first use in this function); did you mean ‘RL_FLOAT’?
  102 |         glVertexAttribPointer(shader.locs[SHADER_LOC_VERTEX_POSITION], 3, GL_FLOAT, GL_FALSE, 0, 0);
      |                                                                           ^~~~~~~~
      |                                                                           RL_FLOAT
others/raylib_opengl_interop.c:102:85: error: ‘GL_FALSE’ undeclared (first use in this function)
  102 |         glVertexAttribPointer(shader.locs[SHADER_LOC_VERTEX_POSITION], 3, GL_FLOAT, GL_FALSE, 0, 0);
      |                                                                                     ^~~~~~~~
others/raylib_opengl_interop.c:103:9: warning: implicit declaration of function ‘glEnableVertexAttribArray’; did you mean ‘rlEnableVertexAttribute’? [-Wimplicit-function-declaration]
  103 |         glEnableVertexAttribArray(0);
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~
      |         rlEnableVertexAttribute
others/raylib_opengl_interop.c:109:5: warning: implicit declaration of function ‘glEnable’ [-Wimplicit-function-declaration]
  109 |     glEnable(GL_PROGRAM_POINT_SIZE);
      |     ^~~~~~~~
others/raylib_opengl_interop.c:109:14: error: ‘GL_PROGRAM_POINT_SIZE’ undeclared (first use in this function)
  109 |     glEnable(GL_PROGRAM_POINT_SIZE);
      |              ^~~~~~~~~~~~~~~~~~~~~
others/raylib_opengl_interop.c:130:13: warning: implicit declaration of function ‘glUseProgram’ [-Wimplicit-function-declaration]
  130 |             glUseProgram(shader.id);
      |             ^~~~~~~~~~~~
others/raylib_opengl_interop.c:132:17: warning: implicit declaration of function ‘glUniform1f’ [-Wimplicit-function-declaration]
  132 |                 glUniform1f(currentTimeLoc, GetTime());
      |                 ^~~~~~~~~~~
others/raylib_opengl_interop.c:135:17: warning: implicit declaration of function ‘glUniform4fv’ [-Wimplicit-function-declaration]
  135 |                 glUniform4fv(colorLoc, 1, (float *)&color);
      |                 ^~~~~~~~~~~~
others/raylib_opengl_interop.c:140:17: warning: implicit declaration of function ‘glUniformMatrix4fv’ [-Wimplicit-function-declaration]
  140 |                 glUniformMatrix4fv(shader.locs[SHADER_LOC_MATRIX_MVP], 1, false, MatrixToFloat(modelViewProjection));
      |                 ^~~~~~~~~~~~~~~~~~
others/raylib_opengl_interop.c:143:21: warning: implicit declaration of function ‘glDrawArrays’ [-Wimplicit-function-declaration]
  143 |                     glDrawArrays(GL_POINTS, 0, MAX_PARTICLES);
      |                     ^~~~~~~~~~~~
others/raylib_opengl_interop.c:143:34: error: ‘GL_POINTS’ undeclared (first use in this function)
  143 |                     glDrawArrays(GL_POINTS, 0, MAX_PARTICLES);
      |                                  ^~~~~~~~~
others/raylib_opengl_interop.c:157:5: warning: implicit declaration of function ‘glDeleteBuffers’ [-Wimplicit-function-declaration]
  157 |     glDeleteBuffers(1, &vbo);
      |     ^~~~~~~~~~~~~~~
others/raylib_opengl_interop.c:158:5: warning: implicit declaration of function ‘glDeleteVertexArrays’; did you mean ‘rlDrawVertexArray’? [-Wimplicit-function-declaration]
  158 |     glDeleteVertexArrays(1, &vao);
      |     ^~~~~~~~~~~~~~~~~~~~
      |     rlDrawVertexArray
make: *** [Makefile:612: others/raylib_opengl_interop] Error 1
raysan5 commented 3 months ago

@colesnicov this is a special example to illustrate raylib interoperatibility with OpenGL, it requires including OpenGL libraries.

colesnicov commented 3 months ago

@colesnicov this is a special example to illustrate raylib interoperatibility with OpenGL, it requires including OpenGL libraries.

I want to try to run the rest of the examples. Here I tried to fix https://github.com/raysan5/raylib/blob/master/examples/others/raylib_opengl_interop.c

I changed the code on the line https://github.com/raysan5/raylib/blob/f1007554a0a8145060797c0aa8169bdaf2c1c6b8/examples/others/raylib_opengl_interop.c#L29 as follows: #if defined(PLATFORM_DESKTOP) || defined(PLATFORM_DESKTOP_SDL) || defined(PLATFORM_DRM)

Heres the log:

denis@raspberrypi:~/dev/raylib/examples $ make PLATFORM=PLATFORM_DRM
gcc -o others/raylib_opengl_interop others/raylib_opengl_interop.c -Wall -std=c99 -D_DEFAULT_SOURCE -Wno-missing-braces -Wunused-result -O2 -std=gnu99 -DEGL_NO_X11 -I. -I../src -I../src/external -I/usr/local/include -I/usr/include/libdrm -I../src/external/glfw/include -L. -L../src -L../src -lraylib -lGLESv2 -lEGL -lpthread -lrt -lm -lgbm -ldrm -ldl -latomic -DPLATFORM_DRM
/usr/bin/ld: /tmp/ccbgpmF5.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:616: others/raylib_opengl_interop] Error 1

you have glad.h in the external folder but you're missing glad.c and I'm not sure how to proceed here. Where should I take it? I don't know much about it, then.

colesnicov commented 3 months ago

I found this https://gen.glad.sh/, and I'm a deer for it :D .

raysan5 commented 3 months ago

@colesnicov Just note that I'm planning to remove glad from raylib dependencies and just load required extensions manually. It would reduce initialization times and memory required... as well as an external dependency.

colesnicov commented 3 months ago

Most of the example after adjusting the size, I made it global:

find . -type f -name "*.c" -print0 | xargs -0 sed -i -e 's/screenHeight = 450/screenHeight =
1280/g'

and

find . -type f -name "*.c" -print0 | xargs -0 sed -i -e 's/screenWidth = 800/screenWidth = 400
g'

from folder examples work without problems.

This applies to RayGUI as well.

raysan5 commented 2 days ago

I'm closing this issue, examples issues would be opened per individual examples when required.