https://github.com/oblerion/lightmanager_raylib
3d light manager for raylib
https://github.com/oblerion/lightmanager_raylib
3d light raylib-c
Last synced: 17 days ago
JSON representation
3d light manager for raylib
- Host: GitHub
- URL: https://github.com/oblerion/lightmanager_raylib
- Owner: oblerion
- License: other
- Created: 2024-01-08T23:33:23.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-01-09T00:11:36.000Z (over 2 years ago)
- Last Synced: 2025-01-05T20:41:11.022Z (over 1 year ago)
- Topics: 3d, light, raylib-c
- Language: C
- Homepage:
- Size: 15.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# lightmanager_raylib
lightmanager for raylib
use edited rlight.h from shader raylib example
use shader lighting from shader raylib example
## Example
```cpp
#include "raylib.h"
#include "lightmanager.h"
int main(void)
{
// Initialization
//--------------------------------------------------------------------------------------
// float fraq = GetMonitorWidth(0)/GetMonitorHeight(0);
const int screenWidth = 1000; //GetMonitorWidth(0);
const int screenHeight = 600;//GetMonitorHeight(0);
InitWindow(screenWidth, screenHeight, "raylib [core] example - basic window");
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
Camera camera = { 0 };
camera.position = (Vector3){ 40.0f, 40.0f, 0.0f }; // Camera position
camera.target = (Vector3){ 0.0f, 0.0f, 0.0f }; // Camera looking at point
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target)
camera.fovy = 45.0f; // Camera field-of-view Y
Vector3 position = { 0.0f, 0.0f, 0.0f };
camera.projection=CAMERA_PERSPECTIVE;
Model mod = LoadModel("asset/ship_Awing_gene.glb");
float rot = 0;
LM_Init();// light manager init
LM_AddPointLight((Vector3){15,15,15},(Vector3){0,0,0},WHITE); // add light point
LM_AddPointLight((Vector3){-15,15,15},(Vector3){0,0,0},GREEN);
LM_AppliShader(&mod);// appli shader to model
while (!WindowShouldClose()) // Detect window close button or ESC key
{
BeginDrawing();
ClearBackground(BLACK);
BeginMode3D(camera);
DrawModelEx(mod,(Vector3){0,0,0},(Vector3){0,1,0},rot,(Vector3){1,1,1},WHITE);
rot = rot +5*GetFrameTime();
EndMode3D();
EndDrawing();
}
UnloadModel(mod);
LM_Unload();// unload light shader
CloseWindow(); // Close window and OpenGL
return 0;
}
```