-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
1,122 additions
and
679 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#include "lights.h" | ||
|
||
#include <stddef.h> | ||
#include <stdlib.h> | ||
#include <string.h> | ||
#include <stdbool.h> | ||
|
||
#include "cglm/struct.h" | ||
|
||
cg_lights_point_t cgLightsPoints[CG_LIGHTS_POINTS_MAX]; | ||
|
||
void cgLightsInit() { | ||
cgLightsPointsClear(); | ||
} | ||
|
||
bool cgLightsIsPointSet(cg_lights_point_t point) { | ||
cg_lights_point_t defaultPoint = { | ||
(vec3s) { 0.0f, 0.0f, 0.0f }, | ||
(vec3s) { 0.0f, 0.0f, 0.0f }, | ||
0.0f, | ||
}; | ||
|
||
return memcmp(point.col.raw, defaultPoint.col.raw, sizeof(vec3s)) == 0; | ||
} | ||
|
||
void cgLightsPointsClear() { | ||
for (size_t i = 0; i < CG_LIGHTS_POINTS_MAX; i++) | ||
cgLightsPoints[i] = (cg_lights_point_t) { | ||
(vec3s) { 0.0f, 0.0f, 0.0f }, | ||
(vec3s) { 0.0f, 0.0f, 0.0f }, | ||
0.0f, | ||
}; | ||
} | ||
|
||
void cgLightsPoint(const float x, const float y, const float z, | ||
const float r, const float g, const float b, | ||
const float radius) { | ||
for (size_t i = 0; i < CG_LIGHTS_POINTS_MAX; i++) | ||
if (cgLightsIsPointSet(cgLightsPoints[i])) { | ||
cg_lights_point_t light; | ||
|
||
light.pos = (vec3s) { x, y, z }; | ||
light.col = (vec3s) { r, g, b }; | ||
light.radius = radius; | ||
|
||
cgLightsPoints[i] = light; | ||
|
||
break; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#ifndef __CG__LIGHTS_H__ | ||
#define __CG__LIGHTS_H__ | ||
|
||
#include <stdbool.h> | ||
|
||
#include "cglm/struct.h" | ||
|
||
#define CG_LIGHTS_POINTS_MAX 128 | ||
|
||
typedef struct { | ||
vec3s pos; | ||
vec3s col; | ||
float radius; | ||
} cg_lights_point_t; | ||
|
||
extern cg_lights_point_t cgLightsPoints[CG_LIGHTS_POINTS_MAX]; | ||
|
||
void cgLightsInit(); | ||
bool cgLightsIsPointSet(cg_lights_point_t); | ||
void cgLightsPointsClear(); | ||
void cgLightsPoint(const float, const float, const float, | ||
const float, const float, const float, | ||
const float); | ||
|
||
#endif // __CG__LIGHTS_H__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.