Skip to content
This repository has been archived by the owner on Feb 18, 2022. It is now read-only.

Commit

Permalink
Minor updates
Browse files Browse the repository at this point in the history
Console and input updates
  • Loading branch information
fonsp committed Dec 15, 2014
1 parent a95381f commit edcd85a
Show file tree
Hide file tree
Showing 10 changed files with 122 additions and 153 deletions.
28 changes: 0 additions & 28 deletions GraphicsEngine/Content/shaders/depth.fsh

This file was deleted.

31 changes: 0 additions & 31 deletions GraphicsEngine/Content/shaders/depth.vsh

This file was deleted.

2 changes: 1 addition & 1 deletion GraphicsEngine/Content/shaders/diffuse.vsh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ void main()
v.xyz = v.xyz - cpos;
v = gl_ModelViewMatrix * v;
dopp = dot(v.xyz, vdirL) * bL / length(v.xyz);;
if(bW > 0)
if(bW > 0.0)
{
if((effects / 1) % 2 == 1)
{
Expand Down
29 changes: 0 additions & 29 deletions GraphicsEngine/Core/Shader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -173,35 +173,6 @@ public static Shader unlitShaderCompiled
}
}

public static Shader depthShader
{
get
{
return new Shader
{
vertexShader = File.ReadAllText(@"Content/shaders/depth.vsh"),
fragmentShader = File.ReadAllText(@"Content/shaders/depth.fsh")
};
}
}

private static Shader depthShaderCompiledi;
public static Shader depthShaderCompiled
{
get
{
if(depthShaderCompiledi == null)
{
depthShaderCompiledi = depthShader;
}
if(depthShaderCompiledi.Compiled == false && RenderWindow.Instance.initialized)
{
depthShaderCompiledi.GenerateShaders();
}
return depthShaderCompiledi;
}
}

public static Shader wireframeShader
{
get
Expand Down
42 changes: 18 additions & 24 deletions GraphicsEngine/GraphicsLibrary.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -116,64 +116,58 @@
<ItemGroup />
<ItemGroup>
<None Include="Content\shaders\blur.fsh">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Content\shaders\blur.vsh">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Content\shaders\collision.fsh">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Content\shaders\collision.vsh">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Content\shaders\crt.fsh">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Content\shaders\crt.vsh">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Content\shaders\depth.fsh">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Content\shaders\depth.vsh">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Content\shaders\diffuse.fsh">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Content\shaders\diffuse.vsh">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Content\shaders\dither.fsh">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Content\shaders\dither.vsh">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Content\shaders\hud.fsh">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Content\shaders\hud.vsh">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Content\shaders\ssao.fsh">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Content\shaders\ssao.vsh">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Content\shaders\unlit.fsh">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Content\shaders\unlit.vsh">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Content\shaders\wireframe.fsh">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Content\shaders\wireframe.vsh">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
Expand Down
1 change: 0 additions & 1 deletion GraphicsEngine/Hud/HudConsole.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using GraphicsLibrary.Core;
using OpenTK;
using OpenTK.Graphics;
using OpenTK.Graphics.OpenGL;
using OpenTK.Input;

namespace GraphicsLibrary.Hud
Expand Down
20 changes: 14 additions & 6 deletions GraphicsEngine/Input/InputManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ namespace GraphicsLibrary.Input
{
public static class InputManager
{
public static bool enabled = true;
private static CursorLockState _cursorLockState = CursorLockState.Free;
private static bool[] currentStates = new bool[132];
private static bool[] previousStates = new bool[132];
Expand Down Expand Up @@ -54,12 +55,12 @@ public static void HideCursor()

public static bool IsKeyDown(Key key)
{
return RenderWindow.Instance.Keyboard[key];
return enabled && RenderWindow.Instance.Keyboard[key];
}

public static bool IsKeyUp(Key key)
{
return !RenderWindow.Instance.Keyboard[key];
return enabled && !RenderWindow.Instance.Keyboard[key];
}

public static bool IsKeyToggled(Key key)
Expand All @@ -69,6 +70,10 @@ public static bool IsKeyToggled(Key key)

public static bool IsAnyKeyDown(Key key)
{
if(!enabled)
{
return false;
}
bool output = false;
for(int i = 0; i < 131; i++)
{
Expand All @@ -82,9 +87,12 @@ public static bool IsAnyKeyDown(Key key)

public static void UpdateToggleStates()
{
for(int i = 0; i < 131; i++)
if(enabled)
{
UpdateToggleState((Key)i);
for(int i = 0; i < 131; i++)
{
UpdateToggleState((Key)i);
}
}
}

Expand All @@ -109,12 +117,12 @@ public static void ClearToggleStates()

public static bool IsButtonDown(MouseButton mouseButton)
{
return RenderWindow.Instance.Mouse[mouseButton];
return enabled && RenderWindow.Instance.Mouse[mouseButton];
}

public static bool IsButtonUp(MouseButton mouseButton)
{
return !RenderWindow.Instance.Mouse[mouseButton];
return enabled && !RenderWindow.Instance.Mouse[mouseButton];
}

public static Vector2 GetMousePosition(CursorLockState cursorLockState)
Expand Down
8 changes: 1 addition & 7 deletions GraphicsEngine/RenderWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ protected override void OnUpdateFrame(FrameEventArgs e)
#endif

b = Camera.Instance.velocity.Length / c;
lf = 1f / (float)Math.Sqrt(1.0 - b * b);
lf = 1f / (float)Math.Sqrt(1.001 - b * b);

timeSinceLastUpdate = e.Time * timeMultiplier;
localTime += (float)timeSinceLastUpdate;
Expand Down Expand Up @@ -358,7 +358,6 @@ protected override void OnRenderFrame(FrameEventArgs e)

Shader.diffuseShaderCompiled.SetUniform("worldTime", worldTime);
Shader.unlitShaderCompiled.SetUniform("worldTime", worldTime);
Shader.depthShaderCompiled.SetUniform("worldTime", worldTime);
Shader.wireframeShaderCompiled.SetUniform("worldTime", worldTime);
Shader.collisionShaderCompiled.SetUniform("worldTime", worldTime);
Shader.hudShaderCompiled.SetUniform("worldTime", worldTime);
Expand All @@ -368,7 +367,6 @@ protected override void OnRenderFrame(FrameEventArgs e)

Shader.diffuseShaderCompiled.SetUniform("effects", enableDoppler, enableRelBrightness, enableRelAberration);
Shader.unlitShaderCompiled.SetUniform("effects", enableDoppler, enableRelBrightness, enableRelAberration);
Shader.depthShaderCompiled.SetUniform("effects", enableDoppler, enableRelBrightness, enableRelAberration);
Shader.wireframeShaderCompiled.SetUniform("effects", enableDoppler, enableRelBrightness, enableRelAberration);
Shader.collisionShaderCompiled.SetUniform("effects", enableDoppler, enableRelBrightness, enableRelAberration);

Expand All @@ -381,29 +379,25 @@ protected override void OnRenderFrame(FrameEventArgs e)

Shader.diffuseShaderCompiled.SetUniform("bW", b);
Shader.unlitShaderCompiled.SetUniform("bW", b);
Shader.depthShaderCompiled.SetUniform("bW", b);
Shader.wireframeShaderCompiled.SetUniform("bW", b);
Shader.collisionShaderCompiled.SetUniform("bW", b);

Vector3 vDir = smoothedVelocity.Normalized();

Shader.diffuseShaderCompiled.SetUniform("vdirW", vDir);
Shader.unlitShaderCompiled.SetUniform("vdirW", vDir);
Shader.depthShaderCompiled.SetUniform("vdirW", vDir);
Shader.wireframeShaderCompiled.SetUniform("vdirW", vDir);
Shader.collisionShaderCompiled.SetUniform("vdirW", vDir);

Shader.diffuseShaderCompiled.SetUniform("cpos", Camera.Instance.position);
Shader.unlitShaderCompiled.SetUniform("cpos", Camera.Instance.position);
Shader.depthShaderCompiled.SetUniform("cpos", Camera.Instance.position);
Shader.wireframeShaderCompiled.SetUniform("cpos", Camera.Instance.position);
Shader.collisionShaderCompiled.SetUniform("cpos", Camera.Instance.position);

Matrix4 cRot = Matrix4.CreateFromQuaternion(Camera.Instance.derivedOrientation);

Shader.diffuseShaderCompiled.SetUniform("crot", cRot);
Shader.unlitShaderCompiled.SetUniform("crot", cRot);
Shader.depthShaderCompiled.SetUniform("crot", cRot);
Shader.wireframeShaderCompiled.SetUniform("crot", cRot);
Shader.collisionShaderCompiled.SetUniform("crot", cRot);

Expand Down
Loading

0 comments on commit edcd85a

Please sign in to comment.