### Basic rlights.h Usage with Raylib Example Source: https://github.com/bigfoot71/rlights/blob/master/README.md A comprehensive example showcasing the integration of rlights.h with raylib. It covers window initialization, camera setup, creating and configuring an rlights.h context, setting up lights, loading a model, and the main rendering loop. ```c #include "raylib.h" #define RLIGHTS_IMPLEMENTATION #define GLSL_VERSION 330 ///< or 120/130/etc.. 100 is default if 'PLATFORM_DESKTOP' is not defined #include "rlights.h" int main(void) { InitWindow(800, 600, "basic example"); Camera camera = { .position = (Vector3) { 2.0f, 2.0f, 2.0f }, .target = (Vector3) { 0.0f, 0.0f, 0.0f }, .up = (Vector3) { 0.0f, 1.0f, 0.0f }, .fovy = 45.0f }; RLG_Context rlgCtx = RLG_CreateContext(1); RLG_SetContext(rlgCtx); RLG_UseLight(0, true); RLG_SetLightType(0, RLG_OMNILIGHT); RLG_SetLightVec3(0, RLG_LIGHT_POSITION, camera.position); Model cube = LoadModelFromMesh(GenMeshCube(1, 1, 1)); SetTargetFPS(60); while (!WindowShouldClose()) { UpdateCamera(&camera, CAMERA_ORBITAL); RLG_SetViewPositionV(camera.position); BeginDrawing(); ClearBackground(BLACK); BeginMode3D(camera); RLG_DrawModel(cube, Vector3Zero(), 1, WHITE); EndMode3D(); EndDrawing(); } UnloadModel(cube); RLG_DestroyContext(rlgCtx); CloseWindow(); return 0; } ``` -------------------------------- ### Include rlights.h Implementation Source: https://github.com/bigfoot71/rlights/blob/master/README.md Demonstrates the standard method to include the rlights.h single-header library in a C project. Define RLIGHTS_IMPLEMENTATION before including the header to enable the implementation. ```c #define RLIGHTS_IMPLEMENTATION #include "rlights.h" ``` -------------------------------- ### RLG Skybox Management (C) Source: https://github.com/bigfoot71/rlights/blob/master/README.md Handles the loading, unloading, and drawing of skyboxes. Supports loading from standard files and HDR files, allowing for dynamic skybox environments. ```c /* Fonctions de gestion des skyboxes */ RLG_Skybox RLG_LoadSkybox(const char* skyboxFileName); RLG_Skybox RLG_LoadSkyboxHDR(const char* skyboxFileName, int size, int format); void RLG_UnloadSkybox(RLG_Skybox skybox); void RLG_DrawSkybox(RLG_Skybox skybox); ``` -------------------------------- ### RLG Context Management (C) Source: https://github.com/bigfoot71/rlights/blob/master/README.md Functions for managing the rendering context. This includes creating, destroying, setting, and retrieving the active context, which is fundamental for library operations. ```c /* Context Management */ RLG_Context RLG_CreateContext(void); void RLG_DestroyContext(RLG_Context ctx); void RLG_SetContext(RLG_Context ctx); RLG_Context RLG_GetContext(void); ``` -------------------------------- ### RLG Material Map Management (C) Source: https://github.com/bigfoot71/rlights/blob/master/README.md Handles the activation and configuration of material maps, including default maps. This allows control over how textures and materials are applied to objects. ```c /* Materials Management */ void RLG_UseMap(MaterialMapIndex mapIndex, bool active); bool RLG_IsMapUsed(MaterialMapIndex mapIndex); void RLG_UseDefaultMap(MaterialMapIndex mapIndex, bool active); void RLG_SetDefaultMap(MaterialMapIndex mapIndex, MaterialMap map); MaterialMap RLG_GetDefaultMap(MaterialMapIndex mapIndex); bool RLG_IsDefaultMapUsed(MaterialMapIndex mapIndex); ``` -------------------------------- ### rlights.h API Functions Source: https://github.com/bigfoot71/rlights/blob/master/README.md Core functions for managing the rlights.h lighting context and configuring lights within a raylib application. These functions allow for creating, setting, and manipulating light properties and view parameters. ```APIDOC RLG_Context RLG_CreateContext(int maxLights) - Creates a new lighting context with a specified maximum number of lights. - Parameters: - maxLights: The maximum number of lights the context can manage. - Returns: A pointer to the newly created RLG_Context. void RLG_SetContext(RLG_Context ctx) - Sets the global lighting context to be used for rendering. - Parameters: - ctx: The RLG_Context to set as active. void RLG_UseLight(int index, bool enabled) - Enables or disables a specific light by its index. - Parameters: - index: The index of the light to control (0 to maxLights-1). - enabled: true to enable the light, false to disable. void RLG_SetLightType(int index, int type) - Sets the type of a specific light. - Parameters: - index: The index of the light. - type: The light type (e.g., RLG_DIRECTIONAL, RLG_OMNILIGHT, RLG_SPOT). void RLG_SetLightVec3(int index, int type, Vector3 value) - Sets a Vector3 property for a specific light. - Parameters: - index: The index of the light. - type: The property type (e.g., RLG_LIGHT_POSITION, RLG_LIGHT_DIRECTION). - value: The Vector3 value to set. void RLG_SetViewPositionV(Vector3 position) - Sets the camera's view position for lighting calculations. - Parameters: - position: The camera's position as a Vector3. ``` -------------------------------- ### RLG Lighting Management (C) Source: https://github.com/bigfoot71/rlights/blob/master/README.md Provides extensive control over lights in the scene, including activation, type, color, intensity, position, and transformations. Supports setting various light properties and retrieving their values. ```c /* Lighting Management */ void RLG_UseLight(unsigned int light, bool active); bool RLG_IsLightUsed(unsigned int light); void RLG_ToggleLight(unsigned int light); void RLG_SetLightType(unsigned int light, RLG_LightType type); RLG_LightType RLG_GetLightType(unsigned int light); void RLG_SetLightValue(unsigned int light, RLG_LightProperty property, float value); void RLG_SetLightXYZ(unsigned int light, RLG_LightProperty property, float x, float y, float z); void RLG_SetLightVec3(unsigned int light, RLG_LightProperty property, Vector3 value); void RLG_SetLightColor(unsigned int light, Color color); float RLG_GetLightValue(unsigned int light, RLG_LightProperty property); Vector3 RLG_GetLightVec3(unsigned int light, RLG_LightProperty property); Color RLG_GetLightColor(unsigned int light); void RLG_LightTranslate(unsigned int light, float x, float y, float z); void RLG_LightTranslateV(unsigned int light, Vector3 v); void RLG_LightRotateX(unsigned int light, float degrees); void RLG_LightRotateY(unsigned int light, float degrees); void RLG_LightRotateZ(unsigned int light, float degrees); void RLG_LightRotate(unsigned int light, Vector3 axis, float degrees); void RLG_SetLightTarget(unsigned int light, float x, float y, float z); void RLG_SetLightTargetV(unsigned int light, Vector3 targetPosition); Vector3 RLG_GetLightTarget(unsigned int light); ``` -------------------------------- ### RLG Mesh and Model Drawing (C) Source: https://github.com/bigfoot71/rlights/blob/master/README.md Core functions for rendering meshes and models with specified materials, transformations, and tints. These are the primary drawing commands for visible objects. ```c /* Mesh/Model Drawing Functions */ void RLG_DrawMesh(Mesh mesh, Material material, Matrix transform); void RLG_DrawModel(Model model, Vector3 position, float scale, Color tint); void RLG_DrawModelEx(Model model, Vector3 position, Vector3 rotationAxis, float rotationAngle, Vector3 scale, Color tint); ``` -------------------------------- ### RLG Shadow Casting Management (C) Source: https://github.com/bigfoot71/rlights/blob/master/README.md Enables and configures shadow casting for lights, including setting shadow map resolution and bias. Also provides functions to update shadow maps and retrieve them. ```c /* Shadow Casting Management */ void RLG_EnableShadow(unsigned int light, int shadowMapResolution); void RLG_DisableShadow(unsigned int light); bool RLG_IsShadowEnabled(unsigned int light); void RLG_SetShadowBias(unsigned int light, float value); float RLG_GetShadowBias(unsigned int light); void RLG_UpdateShadowMap(unsigned int light, RLG_DrawFunc drawFunc); Texture RLG_GetShadowMap(unsigned int light); ``` -------------------------------- ### RLG View and Environment Settings (C) Source: https://github.com/bigfoot71/rlights/blob/master/README.md Functions to configure the camera's view position, ambient light color, and parallax layer properties. These settings influence the overall scene perspective and lighting. ```c /* Management of Specific Variables */ void RLG_SetViewPosition(float x, float y, float z); void RLG_SetViewPositionV(Vector3 position); Vector3 RLG_GetViewPosition(void); void RLG_SetAmbientColor(Color color); Color RLG_GetAmbientColor(void); void RLG_SetParallaxLayers(int min, int max); void RLG_GetParallaxLayers(int* min, int* max); ``` -------------------------------- ### RLG Mesh and Model Casting (C) Source: https://github.com/bigfoot71/rlights/blob/master/README.md Functions for casting meshes and models into the scene, which is typically used in conjunction with shadow mapping or other rendering techniques. Requires a shader, mesh/model, and transformation data. ```c void RLG_CastMesh(Shader shader, Mesh mesh, Matrix transform); void RLG_CastModel(Shader shader, Model model, Vector3 position, float scale); void RLG_CastModelEx(Shader shader, Model model, Vector3 position, Vector3 rotationAxis, float rotationAngle, Vector3 scale); ``` -------------------------------- ### RLG Shader Configuration (C) Source: https://github.com/bigfoot71/rlights/blob/master/README.md Allows setting custom shader code for a given shader object and retrieving shader information. This is useful for advanced visual effects and custom rendering pipelines. ```c void RLG_SetCustomShaderCode(RLG_Shader shader, const char *vsCode, const char *fsCode); const Shader* RLG_GetShader(RLG_Shader shader); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.