#DrawMeshInstanced drawing nothing

8 messages · Page 1 of 1 (latest)

soft seal
#

I pulled the example code from the website and the shaders from GitHub and I get one red square with 2 blue squares orbiting it. No other instanced squares. In searching for previous answers, I saw some say to add shader.locs[SHADER_LOC_MATRIX_MODEL] = GetShaderLocationAttrib(shader, "instanceTransform"); after the shader is loaded. When I tried that, no squares were drawn at all.

Also the shaders are loaded correctly.
Logs:

INFO: Initializing raylib 5.5
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: 3440 x 1440
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: GLAD: OpenGL extensions loaded successfully
INFO: GL: Supported extensions count: 397
INFO: GL: OpenGL device information:
INFO:     > Vendor:   NVIDIA Corporation
INFO:     > Renderer: NVIDIA GeForce RTX 3080/PCIe/SSE2
INFO:     > Version:  3.3.0 NVIDIA 570.86.16
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 - 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/onion/Repos/cell-sim/cmake-build-debug/cell_sim
INFO: VAO: [ID 2] Mesh uploaded successfully to VRAM (GPU)
INFO: FILEIO: [../data/shaders/lighting.vs] Text file loaded successfully
INFO: FILEIO: [../data/shaders/lighting.fs] Text file loaded successfully
INFO: SHADER: [ID 4] Vertex shader compiled successfully
INFO: SHADER: [ID 5] Fragment shader compiled successfully
INFO: SHADER: [ID 6] Program shader loaded successfully
INFO: TIMER: Target time per frame: 16.667 milliseconds
icy scaffold
#

Try using both the shaders and the example code from Github? The instancing example is in the examples/shaders folder on the Github. The blue cubes are drawn normally (not instanced) and the red ones would be instanced. That line you added can work in some cases... at this time probably best to use everything from Github only. Also, if you cannot make it work with source from Github then possibly confirm which OS you are working on?

#

Recently the instancing part in raylib had a small change (if I understand correctly) and most issues reported with instancing were due to people using older raylib with newer examples (like taking the example from a website and using older version of raylib). Your best bet would be to compile raylib from sources you'd download from Github and use examples that come with.

soft seal
#

I just checked, and the example on github matches the example on the website

#

Also, if you cannot make it work with source from Github then possibly confirm which OS you are working on?
It is not working on Arch Linux. My CMake directly pulls from Raylib v5.5 on GitHub

Also, the same code works correctly on my Windows laptop

icy scaffold
#

I'm sorry, I've no experience there. I think to have seen that some distros provide their own version of raylib so possibly something in that regards is giving you issues. I'm sorry I can't help in a better way but I'd just recommend trying to compile raylib youself. Or maybe you are doing that already? Also, maybe you have two versions of raylib on your system (I'm not sure if that can even happen?)...

soft seal
#

I am pulling raylib from github and using that one
cmake for reference:

cmake_minimum_required(VERSION 3.30)
project(cell_sim)

set(CMAKE_CXX_STANDARD 23)

include(FetchContent)

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3")

# Dependencies
set(RAYLIB_VERSION 5.5)

if(UNIX AND NOT APPLE)
    set(GLFW_BUILD_WAYLAND ON CACHE BOOL "" FORCE)
    set(GLFW_BUILD_X11 ON CACHE BOOL "" FORCE)
endif()

FetchContent_Declare(
        raylib
        DOWNLOAD_EXTRACT_TIMESTAMP OFF
        URL https://github.com/raysan5/raylib/archive/refs/tags/${RAYLIB_VERSION}.tar.gz
        FIND_PACKAGE_ARGS
)

FetchContent_MakeAvailable(raylib)

add_executable(${PROJECT_NAME} src/main.cpp
        src/MeshGenerator.h
        src/rlights.h)
add_subdirectory(src)

set_target_properties(${PROJECT_NAME} PROPERTIES
        RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${PROJECT_NAME})

set_property(TARGET ${PROJECT_NAME} PROPERTY VS_DEBUGGER_WORKING_DIRECTORY $<TARGET_FILE_DIR:${PROJECT_NAME}>)

file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/data DESTINATION ${CMAKE_CURRENT_BINARY_DIR})

#set(raylib_VERBOSE 1)
target_link_libraries(${PROJECT_NAME} raylib)

if (APPLE)
    target_link_libraries(${PROJECT_NAME} "-framework IOKit")
    target_link_libraries(${PROJECT_NAME} "-framework Cocoa")
    target_link_libraries(${PROJECT_NAME} "-framework OpenGL")
endif()
soft seal
#

update: doesn't happen with SDL backend, so either a problem with GLFW or the GLFW backend on Arch/wayland