mirror of
https://github.com/aharabada/glitchy-engine-beef.git
synced 2026-09-05 21:01:52 +00:00
Added extension functions for ImGui
This commit is contained in:
@@ -0,0 +1,18 @@
|
|||||||
|
using GlitchyEngine.Math;
|
||||||
|
namespace ImGui
|
||||||
|
{
|
||||||
|
extension ImGui
|
||||||
|
{
|
||||||
|
// TODO: Color-functions
|
||||||
|
|
||||||
|
public static bool ColorEdit3(char* label, ref ColorRGB col, ColorEditFlags flags = (ColorEditFlags) 0) => ColorEdit3Impl(label, *(float[3]*)&col, flags);
|
||||||
|
public static bool ColorEdit3(char* label, ref ColorRGBA col, ColorEditFlags flags = (ColorEditFlags) 0) => ColorEdit3Impl(label, *(float[3]*)&col, flags);
|
||||||
|
|
||||||
|
public static bool ColorEdit4(char* label, ref ColorRGBA col, ColorEditFlags flags = (ColorEditFlags) 0) => ColorEdit4Impl(label, *(float[4]*)&col, flags);
|
||||||
|
|
||||||
|
public static bool ColorPicker3(char* label, ref ColorRGB col, ColorEditFlags flags = (ColorEditFlags) 0) => ColorPicker3Impl(label, *(float[3]*)&col, flags);
|
||||||
|
public static bool ColorPicker3(char* label, ref ColorRGBA col, ColorEditFlags flags = (ColorEditFlags) 0) => ColorPicker3Impl(label, *(float[3]*)&col, flags);
|
||||||
|
|
||||||
|
public static bool ColorPicker4(char* label, ref ColorRGBA col, ColorEditFlags flags = (ColorEditFlags) 0, float* ref_col = null) => ColorPicker4Impl(label, *(float[4]*)&col, flags, ref_col);
|
||||||
|
}
|
||||||
|
}
|
||||||
+10
-21
@@ -53,7 +53,6 @@ namespace Sandbox
|
|||||||
|
|
||||||
Effect _effect ~ _?.ReleaseRef();
|
Effect _effect ~ _?.ReleaseRef();
|
||||||
|
|
||||||
//Buffer<ColorRGBA> _cBuffer ~ _?.ReleaseRef();
|
|
||||||
ConstantBuffer _cBuffer ~ _?.ReleaseRef();
|
ConstantBuffer _cBuffer ~ _?.ReleaseRef();
|
||||||
|
|
||||||
private Vector3 CircleCoord(float angle)
|
private Vector3 CircleCoord(float angle)
|
||||||
@@ -82,24 +81,11 @@ namespace Sandbox
|
|||||||
VertexElement(.R32G32B32_Float, "POSITION"),
|
VertexElement(.R32G32B32_Float, "POSITION"),
|
||||||
VertexElement(.R8G8B8A8_UNorm, "COLOR"),
|
VertexElement(.R8G8B8A8_UNorm, "COLOR"),
|
||||||
), _effect.VertexShader);
|
), _effect.VertexShader);
|
||||||
/*
|
|
||||||
_cBuffer = new Buffer<ColorRGBA>(Application.Get().Window.Context, .(0, .Constant, .Dynamic, .Write));
|
|
||||||
_cBuffer.Data = .White;
|
|
||||||
_cBuffer.Update();
|
|
||||||
*/
|
|
||||||
|
|
||||||
//_effect.PixelShader.Buffers.ReplaceBuffer("Constants", _cBuffer);
|
|
||||||
|
|
||||||
Buffer buffer = _effect.PixelShader.Buffers["Constants"];
|
_cBuffer = _effect.PixelShader.Buffers["Constants"] as ConstantBuffer;
|
||||||
_cBuffer = buffer as ConstantBuffer;
|
|
||||||
_cBuffer.AddRef();
|
_cBuffer.AddRef();
|
||||||
|
|
||||||
if(_cBuffer != null)
|
|
||||||
{
|
|
||||||
_cBuffer["BaseColor"].SetData(ColorRGBA.Red);
|
|
||||||
_cBuffer.Update();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create hexagon
|
// Create hexagon
|
||||||
{
|
{
|
||||||
_geometryBinding = new GeometryBinding(Application.Get().Window.Context);
|
_geometryBinding = new GeometryBinding(Application.Get().Window.Context);
|
||||||
@@ -226,7 +212,6 @@ namespace Sandbox
|
|||||||
|
|
||||||
Renderer.BeginScene(_camera);
|
Renderer.BeginScene(_camera);
|
||||||
|
|
||||||
//_cBuffer.Data = .White;
|
|
||||||
_cBuffer["BaseColor"].SetData(ColorRGBA.White);
|
_cBuffer["BaseColor"].SetData(ColorRGBA.White);
|
||||||
_cBuffer.Update();
|
_cBuffer.Update();
|
||||||
|
|
||||||
@@ -237,11 +222,9 @@ namespace Sandbox
|
|||||||
for(int y < 20)
|
for(int y < 20)
|
||||||
{
|
{
|
||||||
if((x + y) % 2 == 0)
|
if((x + y) % 2 == 0)
|
||||||
//_cBuffer.Data = .Red;
|
_cBuffer["BaseColor"].SetData(_squareColor0);
|
||||||
_cBuffer["BaseColor"].SetData(ColorRGBA.Red);
|
|
||||||
else
|
else
|
||||||
_cBuffer["BaseColor"].SetData(ColorRGBA.Blue);
|
_cBuffer["BaseColor"].SetData(_squareColor1);
|
||||||
//_cBuffer.Data = .Blue;
|
|
||||||
|
|
||||||
_cBuffer.Update();
|
_cBuffer.Update();
|
||||||
|
|
||||||
@@ -250,9 +233,11 @@ namespace Sandbox
|
|||||||
}
|
}
|
||||||
|
|
||||||
Renderer.EndScene();
|
Renderer.EndScene();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ColorRGBA _squareColor0 = ColorRGBA.CornflowerBlue;
|
||||||
|
ColorRGBA _squareColor1;
|
||||||
|
|
||||||
public override void OnEvent(Event event)
|
public override void OnEvent(Event event)
|
||||||
{
|
{
|
||||||
EventDispatcher dispatcher = scope EventDispatcher(event);
|
EventDispatcher dispatcher = scope EventDispatcher(event);
|
||||||
@@ -264,6 +249,10 @@ namespace Sandbox
|
|||||||
{
|
{
|
||||||
ImGui.Begin("Test");
|
ImGui.Begin("Test");
|
||||||
|
|
||||||
|
ImGui.ColorEdit3("Square Color", ref _squareColor0);
|
||||||
|
|
||||||
|
_squareColor1 = ColorRGBA.White - _squareColor0;
|
||||||
|
|
||||||
ImGui.End();
|
ImGui.End();
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
Reference in New Issue
Block a user