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

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

Closed
19 of 25 tasks
raysan5 opened this issue Oct 30, 2023 · 43 comments
Closed
19 of 25 tasks

Comments

@raysan5
Copy link
Owner

raysan5 commented Oct 30, 2023

Issues on multiple platforms

  • REVIEW: core_3d_camera_free. Displayed controls do not match and camera behaves strangely.

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

  • REVIEW: custom_frame_control --> Requires raylib built with SUPPORT_CUSTOM_FRAME_CONTROL.
  • REVIEW: models_loading. It seems to be buggy at selecting the model, needs some review
  • REVIEW: skybox_loading. Doesn't fill the entire window, only the bottom-left quadrant --> Probably related to HighDPI.
  • REVIEW: shader_hot_reloading, shader_spotlight. Scaling issue between the mouse and circle positions --> Probably related to HighDPI.
  • REVIEW: top_down_lights. Fully illuminated (no shadows are drawn) until light is moved

Issues on PLATFORM_WEB

  • REVIEW: models_skybox. WebGL: INVALID_VALUE: disableVertexAttribArray: index out of range _glDisableVertexAttribArray.
  • REVIEW: core_custom_frame_control --> Requires raylib built with SUPPORT_CUSTOM_FRAME_CONTROL.
  • REVIEW: core_loading_thread --> Threading support depends on the browser and security reasons.
  • REVIEW: core_window_flags --> Most window flags are intended for a window, not a canvas.
  • REVIEW: raylib_opengl_interop --> Example intended for OpenGL desktop, not OpenGL ES.
  • REVIEW: rlgl_standalone --> PLATFORM_DESKTOP exclusively
  • REVIEW: models_mesh_instancing. Not working properly on web, issues with the shader but ONLY when uploade to GitHub, it works as expected locally.

Issues on PLATFORM_DRM

  • REVIEW: Examples with 3D cameras (e.g.: models_first_person_maze, core_3d_camera_free). Camera moving uncontrollably.
  • REVIEW: Examples with visible cursors (e.g.: shapes_draw_circle_sector, shapes_draw_ring). Cursor not showing.
  • REVIEW: Examples with type inputs (e.g.: text_draw_3d, text_input_box). Can't type.
  • REVIEW: audio_module_playing. Crashing the Raspberry Pi after a few seconds.
  • REVIEW: core_custom_frame_control. Flickering and not working. --> Requires raylib built with SUPPORT_CUSTOM_FRAME_CONTROL.
  • REVIEW: core_vr_simulator. Not rendering.
  • REVIEW: models_skybox. Not rendering. --> Requires enabling HDR loading but maybe not supported by OpenGL ES.
  • REVIEW: shaders_raymarching. Not rendering. --> Shader not adapted for GLSL100.
  • REVIEW: shaders_mesh_instancing. Segmentation fault. --> Not supported by OpenGL ES.
  • REVIEW: rlgl_compute_shader. Not working. --> Not supported by OpenGL ES.
  • REVIEW: raylib_opengl_interop. Not compiling. --> Example intended for OpenGL desktop, not OpenGL ES.
  • REVIEW: rlgl_standalone. Not compiling. --> PLATFORM_DESKTOP exclusively

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

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

@raysan5
Copy link
Owner Author

raysan5 commented Oct 30, 2023

@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
Copy link

ghost commented Oct 30, 2023

Platftorm Example Status Comment
Desktop core_3d_camera_free ✔️ Fixes on #3240 and #3488.
Web models_skybox ✔️ It's working, but requires SUPPORT_FILEFORMAT_HDR to be enabled on config.h.
Web core_loading_thread 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 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 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
✔️ Fix on #3492.
DRM Examples with visible cursors:
shapes_draw_circle_sector
shapes_draw_ring
etc
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 #2952 (reply in thread).
Platftorm Example Status Comment
DRM Examples with type inputs:
text_draw_3d
text_input_box
etc
✔️ Fix on #3498.
DRM audio_module_playing 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 The only thing I could find was WARNING: FBO: [ID 1] Framebuffer has incomplete attachment.
DRM models_skybox 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 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 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
Copy link
Contributor

Bigfoot71 commented Oct 30, 2023

@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
Copy link

ghost commented Oct 31, 2023

@Bigfoot71 Maybe #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
Copy link
Contributor

Bigfoot71 commented Oct 31, 2023

@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
Copy link

ghost commented Oct 31, 2023

@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
Copy link

ghost commented Oct 31, 2023

@raysan5 Updated status table at #3487 (comment).

@SuperUserNameMan
Copy link
Contributor

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

@raysan5
Copy link
Owner Author

raysan5 commented Oct 31, 2023

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

  • [WEB] core_loading_thread: As commented this example has been reviewed several times along the years and it's highly dependant on the start-of-the-art support for multithreading technology on web, that also kept changing. Not sure about the state at this moment, probably some security concerns are still there but I wouldn't focus more energies on it.
  • [WEB] rlgl_standalone: I think it should work with some tweak, I can review it.
  • [WEB] shaders_mesh_instancing: This is a really strange issue because locally it works but on GitHub Pages it doesn't, I vaguely remember dealing with that issue on the past and I thing the solution was somewhat related to system locale and python when compiling the example and I can't rememeber how I solved it. In any case, it probably does not worth to spend more energies on it, considering it's working for any user trying it on their systems.
  • [DRM] examples requiring visible cursor: I'm afraid the cursor is up to the user on DRM mode, due to the nature and limitations of the platform (no windowing system, no cursor). In the past there was a flag to internally create, update and draw a virtual cursor but it implied additional complexity and maintenance cost so it was finally removed to let the users manage it as desired.

Other possible issues:

  • [DESKTOP-macOS] examples not filling screen: I'm afraid this is related to RenderTexture usage, HighDPI and how different versions of macOS with retina displays handle window-creation and internal framebuffer. A related issue was reviewed recently: [core] GetRenderWidth()/GetRenderHeight() incorrect return values on retina display (HighDPI) #3367
  • [DESKTOP-macOS] models_loading: I can't find any significant issue on Windows, more info is required or we can just close it.
  • [DESKTOP-macOS] top_down_lights: Probably related to some initialization values not provided...

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
Copy link
Contributor

Bigfoot71 commented Oct 31, 2023

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 df0f7ba).

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

  • 3D .vox models cannot load on my device but can on others, see:
    [models] Crash when loading .vox model on Android with SIGSEGV error #3098

  • One thing I noticed in many 3D examples (but not all) is a Z-fighting issue, but I'm not sure if it was already present (see video).

  • I couldn't try the skybox example because my device seems to not support HDR textures, but the shaders seem to compile correctly.

Issues in video

Z-Fighting.mp4

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
Copy link

ghost commented Nov 1, 2023

@raysan5 Updated the status table (#3487 (comment)) with the comments on the other DRM examples.

@Bigfoot71
Copy link
Contributor

Bigfoot71 commented Nov 2, 2023

@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
Copy link

ghost commented Nov 2, 2023

@Bigfoot71 Related: #3260, #3261.

@Bigfoot71
Copy link
Contributor

Bigfoot71 commented Nov 2, 2023

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
Copy link

ghost commented Nov 2, 2023

@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
Copy link
Contributor

@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
Copy link
Owner Author

raysan5 commented Nov 2, 2023

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
Copy link
Contributor

Bigfoot71 commented Nov 2, 2023

@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
Copy link
Owner Author

raysan5 commented Nov 2, 2023

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
Copy link
Owner Author

raysan5 commented Nov 5, 2023

@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.

raysan5 added a commit that referenced this issue Nov 5, 2023
Example is intended for `PLATFORM_DESKTOP` only and OpenGL 3.3 Core profile.
@ghost
Copy link

ghost commented Nov 5, 2023

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! 👍

@erikyuzwa
Copy link

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
Copy link

ghost commented Dec 15, 2023

@erikyuzwa Compiled core_3d_camera_first_person from current master branch (10c8259) 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
Copy link

erikyuzwa commented Dec 15, 2023

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
Copy link

ghost commented Dec 15, 2023

@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
Copy link

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
Copy link

ghost commented Dec 15, 2023

@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
Copy link

ghost commented Dec 15, 2023

@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
Copy link

@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
Copy link

ghost commented Dec 15, 2023

@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
Copy link
Owner Author

raysan5 commented Dec 15, 2023

@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
Copy link

appreciate the followup and insight there @raysan5 🙇

@iacore
Copy link
Contributor

iacore commented Dec 25, 2023

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

@crystalthoughts
Copy link

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
Copy link
Owner Author

raysan5 commented Jan 20, 2024

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

@crystalthoughts
Copy link

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

@colesnicov
Copy link

colesnicov commented Apr 30, 2024

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
Copy link
Owner Author

raysan5 commented Apr 30, 2024

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

@colesnicov
Copy link

@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

#if defined(PLATFORM_DESKTOP) || defined(PLATFORM_DESKTOP_SDL)
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
Copy link

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

@raysan5
Copy link
Owner Author

raysan5 commented May 5, 2024

@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
Copy link

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
Copy link
Owner Author

raysan5 commented Aug 24, 2024

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

@raysan5 raysan5 closed this as completed Aug 24, 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

7 participants