Minor update.
- Renamed LICENSE.md to LICENSE. - Removed Rlights.cs. It is a part of the examples now so there is no reason to keep it here.
This commit is contained in:
parent
7aea5f01ef
commit
d3babfd891
2 changed files with 0 additions and 92 deletions
17
LICENSE
Normal file
17
LICENSE
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
Copyright (C) 2020 ChrisDill
|
||||||
|
|
||||||
|
This software is provided 'as-is', without any express or implied
|
||||||
|
warranty. In no event will the authors be held liable for any damages
|
||||||
|
arising from the use of this software.
|
||||||
|
|
||||||
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
|
including commercial applications, and to alter it and redistribute it
|
||||||
|
freely, subject to the following restrictions:
|
||||||
|
|
||||||
|
1. The origin of this software must not be misrepresented; you must not
|
||||||
|
claim that you wrote the original software. If you use this software
|
||||||
|
in a product, an acknowledgment in the product documentation would be
|
||||||
|
appreciated but is not required.
|
||||||
|
2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
misrepresented as being the original software.
|
||||||
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
|
|
@ -1,92 +0,0 @@
|
||||||
|
|
||||||
namespace Raylib_cs
|
|
||||||
{
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
// Types and Structures Definition
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
public struct Light
|
|
||||||
{
|
|
||||||
public bool enabled;
|
|
||||||
public LightType type;
|
|
||||||
public Vector3 position;
|
|
||||||
public Vector3 target;
|
|
||||||
public Color color;
|
|
||||||
public int enabledLoc;
|
|
||||||
public int typeLoc;
|
|
||||||
public int posLoc;
|
|
||||||
public int targetLoc;
|
|
||||||
public int colorLoc;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Light type
|
|
||||||
public enum LightType
|
|
||||||
{
|
|
||||||
LIGHT_DIRECTIONAL,
|
|
||||||
LIGHT_POINT
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class Rlights
|
|
||||||
{
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
// Global Variables Definition
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
public const int MAX_LIGHTS = 4;
|
|
||||||
public static int lightsCount = 0; // Current amount of created lights
|
|
||||||
public const float LIGHT_DISTANCE = 3.5f;
|
|
||||||
public const float LIGHT_HEIGHT = 1.0f;
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
// Module Functions Definition
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
public static Light CreateLight(LightType type, Vector3 pos, Vector3 targ, Color color, Shader shader)
|
|
||||||
{
|
|
||||||
Light light = new Light();
|
|
||||||
|
|
||||||
if (lightsCount < MAX_LIGHTS)
|
|
||||||
{
|
|
||||||
light.enabled = true;
|
|
||||||
light.type = type;
|
|
||||||
light.position = pos;
|
|
||||||
light.target = targ;
|
|
||||||
light.color = color;
|
|
||||||
|
|
||||||
string enabledName = $"lights[{lightsCount}].enabled\0";
|
|
||||||
string typeName = $"lights[{lightsCount}].type\0";
|
|
||||||
string posName = $"lights[{lightsCount}].position\0";
|
|
||||||
string targetName = $"lights[{lightsCount}].target\0";
|
|
||||||
string colorName = $"lights[{lightsCount}].color\0";
|
|
||||||
|
|
||||||
light.enabledLoc = Raylib.GetShaderLocation(shader, enabledName);
|
|
||||||
light.typeLoc = Raylib.GetShaderLocation(shader, typeName);
|
|
||||||
light.posLoc = Raylib.GetShaderLocation(shader, posName);
|
|
||||||
light.targetLoc = Raylib.GetShaderLocation(shader, targetName);
|
|
||||||
light.colorLoc = Raylib.GetShaderLocation(shader, colorName);
|
|
||||||
|
|
||||||
UpdateLightValues(shader, light);
|
|
||||||
lightsCount++;
|
|
||||||
}
|
|
||||||
return light;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void UpdateLightValues(Shader shader, Light light)
|
|
||||||
{
|
|
||||||
// Send to shader light enabled state and type
|
|
||||||
/*Raylib.SetShaderValue(shader, light.enabledLoc, new int[] { light.enabled ? 1 : 0 }, ShaderUniformDataType.UNIFORM_INT);
|
|
||||||
Raylib.SetShaderValue(shader, light.typeLoc, new int[] { (int)light.type }, ShaderUniformDataType.UNIFORM_INT);
|
|
||||||
|
|
||||||
// Send to shader light position values
|
|
||||||
float[] position = { light.position.x, light.position.y, light.position.z };
|
|
||||||
Raylib.SetShaderValue(shader, light.posLoc, ref position, ShaderUniformDataType.UNIFORM_VEC3);
|
|
||||||
|
|
||||||
// Send to shader light target position values
|
|
||||||
float[] target = { light.target.x, light.target.y, light.target.z };
|
|
||||||
Raylib.SetShaderValue(shader, light.targetLoc, ref target, ShaderUniformDataType.UNIFORM_VEC3);
|
|
||||||
|
|
||||||
// Send to shader light color values
|
|
||||||
float[] color = { light.color.r / 255, light.color.g / 255,
|
|
||||||
light.color.b / 255, light.color.a / 255 };
|
|
||||||
Raylib.SetShaderValue(shader, light.colorLoc, ref color, ShaderUniformDataType.UNIFORM_VEC4);*/
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loading…
Reference in a new issue