r3d_surface_shader.odin 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /* r3d_surface_shader.odin -- R3D Surface Shader Module.
  2. *
  3. * Copyright (c) 2025-2026 Le Juez Victor
  4. *
  5. * This software is provided 'as-is', without any express or implied warranty.
  6. * For conditions of distribution and use, see accompanying LICENSE file.
  7. */
  8. package r3d
  9. import rl "vendor:raylib"
  10. when ODIN_OS == .Windows {
  11. foreign import lib {
  12. "windows/libr3d.a",
  13. "system:raylib",
  14. "system:assimp",
  15. }
  16. } else when ODIN_OS == .Linux {
  17. foreign import lib {
  18. "linux/libr3d.a",
  19. "system:raylib",
  20. "system:assimp",
  21. }
  22. } else when ODIN_OS == .Darwin {
  23. foreign import lib {
  24. "darwin/libr3d.a",
  25. "system:raylib",
  26. "system:assimp",
  27. }
  28. }
  29. SurfaceShader :: struct {}
  30. @(default_calling_convention="c", link_prefix="R3D_")
  31. foreign lib {
  32. /**
  33. * @brief Loads a surface shader from a file.
  34. *
  35. * The shader must define at least one entry point: `void vertex()` or `void fragment()`.
  36. * It can define either one or both.
  37. *
  38. * @param filePath Path to the shader source file.
  39. * @return Pointer to the loaded surface shader, or NULL on failure.
  40. */
  41. LoadSurfaceShader :: proc(filePath: cstring) -> ^SurfaceShader ---
  42. /**
  43. * @brief Loads a surface shader from a source code string in memory.
  44. *
  45. * The shader must define at least one entry point: `void vertex()` or `void fragment()`.
  46. * It can define either one or both.
  47. *
  48. * @param code Null-terminated shader source code.
  49. * @return Pointer to the loaded surface shader, or NULL on failure.
  50. */
  51. LoadSurfaceShaderFromMemory :: proc(code: cstring) -> ^SurfaceShader ---
  52. /**
  53. * @brief Unloads and destroys a surface shader.
  54. *
  55. * @param shader Surface shader to unload.
  56. */
  57. UnloadSurfaceShader :: proc(shader: ^SurfaceShader) ---
  58. /**
  59. * @brief Sets a uniform value for the current frame.
  60. *
  61. * Once a uniform is set, it remains valid for the all frames.
  62. * If an uniform is set multiple times during the same frame,
  63. * the last value defined before R3D_End() is used.
  64. *
  65. * Supported types:
  66. * bool, int, float,
  67. * ivec2, ivec3, ivec4,
  68. * vec2, vec3, vec4,
  69. * mat2, mat3, mat4
  70. *
  71. * @warning Boolean values are read as 4 bytes.
  72. *
  73. * @param shader Target surface shader.
  74. * May be NULL. In that case, the call is ignored
  75. * and a warning is logged.
  76. * @param name Name of the uniform. Must not be NULL.
  77. * @param value Pointer to the uniform value. Must not be NULL.
  78. */
  79. SetSurfaceShaderUniform :: proc(shader: ^SurfaceShader, name: cstring, value: rawptr) ---
  80. /**
  81. * @brief Sets a texture sampler for the current frame.
  82. *
  83. * Once a sampler is set, it remains valid for all frames.
  84. * If a sampler is set multiple times during the same frame,
  85. * the last value defined before R3D_End() is used.
  86. *
  87. * Supported samplers:
  88. * sampler1D, sampler2D, sampler3D, samplerCube
  89. *
  90. * @param shader Target surface shader.
  91. * May be NULL. In that case, the call is ignored
  92. * and a warning is logged.
  93. * @param name Name of the sampler uniform. Must not be NULL.
  94. * @param texture rl.Texture to bind to the sampler.
  95. */
  96. SetSurfaceShaderSampler :: proc(shader: ^SurfaceShader, name: cstring, texture: rl.Texture) ---
  97. }