Merged SM2D.DrawColor/DrawComplex/DrawPolygon/DrawShader/DrawTexture into DrawObject2D
This commit is contained in:
parent
beb9c19081
commit
0895c600cf
14 changed files with 320 additions and 256 deletions
|
|
@ -76,7 +76,7 @@ namespace SM.Base.Drawing
|
|||
/// <inheritdoc />
|
||||
protected override void DrawContext(ref DrawContext context)
|
||||
{
|
||||
context.ModelMaster = Transform.GetMatrix();
|
||||
context.ModelMaster *= Transform.GetMatrix();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -49,7 +49,7 @@ namespace SM.OGL
|
|||
ShadingVersion = Version.CreateGLVersion(GL.GetString(StringName.ShadingLanguageVersion));
|
||||
Extensions = GL.GetString(StringName.Extensions).Split(' ');
|
||||
|
||||
Debugging = Extensions.Contains("khr_debug");
|
||||
Debugging = Extensions.Contains("GL_KHR_debug");
|
||||
if (Debugging) GLDebugging.EnableDebugging();
|
||||
|
||||
_init = true;
|
||||
|
|
|
|||
|
|
@ -1,20 +0,0 @@
|
|||
using SM.Base.Contexts;
|
||||
using SM.Base.Drawing;
|
||||
using SM.Base.Scene;
|
||||
using SM2D.Scene;
|
||||
|
||||
namespace SM2D.Drawing
|
||||
{
|
||||
public class DrawBackgroundShader : DrawShader, IBackgroundItem
|
||||
{
|
||||
public DrawBackgroundShader(MaterialShader shader) : base(shader)
|
||||
{ }
|
||||
|
||||
protected override void DrawContext(ref DrawContext context)
|
||||
{
|
||||
Transform.Size.Set(context.WorldScale);
|
||||
|
||||
base.DrawContext(ref context);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
#region usings
|
||||
|
||||
using OpenTK.Graphics;
|
||||
using SM.Base.Contexts;
|
||||
using SM.Base.Drawing;
|
||||
using SM.Base.Scene;
|
||||
using SM2D.Scene;
|
||||
using SM2D.Types;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace SM2D.Drawing
|
||||
{
|
||||
public class DrawColor : DrawingBasis<Transformation>, I2DShowItem
|
||||
{
|
||||
public DrawColor()
|
||||
{
|
||||
}
|
||||
|
||||
public DrawColor(Color4 color)
|
||||
{
|
||||
_material.Tint = color;
|
||||
}
|
||||
|
||||
public Color4 Color
|
||||
{
|
||||
get => _material.Tint;
|
||||
set => _material.Tint = value;
|
||||
}
|
||||
|
||||
public int ZIndex { get; set; }
|
||||
|
||||
protected override void DrawContext(ref DrawContext context)
|
||||
{
|
||||
context.Shader.Draw(context);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,37 +0,0 @@
|
|||
#region usings
|
||||
|
||||
using SM.Base.Contexts;
|
||||
using SM.Base.Drawing;
|
||||
using SM.Base.Scene;
|
||||
using SM.OGL.Mesh;
|
||||
using SM2D.Scene;
|
||||
using SM2D.Types;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace SM2D.Drawing
|
||||
{
|
||||
public class DrawComplex : DrawingBasis<Transformation>, I2DShowItem
|
||||
{
|
||||
public Material Material
|
||||
{
|
||||
get => _material;
|
||||
set => _material = value;
|
||||
}
|
||||
|
||||
public GenericMesh Mesh
|
||||
{
|
||||
get => _mesh;
|
||||
set => _mesh = value;
|
||||
}
|
||||
|
||||
public int ZIndex { get; set; }
|
||||
|
||||
protected override void DrawContext(ref DrawContext context)
|
||||
{
|
||||
base.DrawContext(ref context);
|
||||
|
||||
context.Shader.Draw(context);
|
||||
}
|
||||
}
|
||||
}
|
||||
68
SMCode/SM2D/Drawing/DrawObject2D.cs
Normal file
68
SMCode/SM2D/Drawing/DrawObject2D.cs
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics;
|
||||
using SM.Base.Contexts;
|
||||
using SM.Base.Drawing;
|
||||
using SM.Base.Objects;
|
||||
using SM.Base.Textures;
|
||||
using SM2D.Object;
|
||||
using SM2D.Scene;
|
||||
using SM2D.Types;
|
||||
|
||||
namespace SM2D.Drawing
|
||||
{
|
||||
public class DrawObject2D : DrawingBasis<Transformation>, I2DShowItem
|
||||
{
|
||||
public int ZIndex { get; set; }
|
||||
|
||||
public Texture Texture
|
||||
{
|
||||
get => (Texture) _material.Texture;
|
||||
set => _material.Texture = value;
|
||||
}
|
||||
|
||||
public Color4 Color
|
||||
{
|
||||
get => _material.Tint;
|
||||
set => _material.Tint = value;
|
||||
}
|
||||
|
||||
protected override void DrawContext(ref DrawContext context)
|
||||
{
|
||||
base.DrawContext(ref context);
|
||||
context.Shader.Draw(context);
|
||||
}
|
||||
|
||||
public Material GetMaterialReference() => _material;
|
||||
public void SetMaterialReference(Material material) => _material = material;
|
||||
|
||||
public void SetShader(MaterialShader shader) => _material.CustomShader = shader;
|
||||
|
||||
public Polygon ApplyPolygon(ICollection<Vector2> vertices)
|
||||
{
|
||||
Polygon polygon = new Polygon(vertices);
|
||||
_mesh = polygon;
|
||||
return polygon;
|
||||
}
|
||||
public Polygon ApplyPolygon(ICollection<PolygonVertex> vertices)
|
||||
{
|
||||
Polygon polygon = new Polygon(vertices);
|
||||
_mesh = polygon;
|
||||
return polygon;
|
||||
}
|
||||
public void ApplyPolygon(Polygon polygon)
|
||||
{
|
||||
_mesh = polygon;
|
||||
}
|
||||
|
||||
public void ApplyMesh(Mesh mesh) => _mesh = mesh;
|
||||
|
||||
public Polygon ApplyCircle(int segments = 32)
|
||||
{
|
||||
Polygon pol = Polygon.GenerateCircle(segments);
|
||||
_mesh = pol;
|
||||
return pol;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,46 +0,0 @@
|
|||
#region usings
|
||||
|
||||
using System.Drawing;
|
||||
using OpenTK.Graphics;
|
||||
using SM.Base.Textures;
|
||||
using SM2D.Object;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace SM2D.Drawing
|
||||
{
|
||||
public class DrawPolygon : DrawColor
|
||||
{
|
||||
public DrawPolygon(Polygon polygon) : this(polygon, Color4.White)
|
||||
{
|
||||
}
|
||||
|
||||
public DrawPolygon(Polygon polygon, Bitmap map) : this(polygon, map, Color4.White)
|
||||
{
|
||||
}
|
||||
|
||||
public DrawPolygon(Polygon polygon, Color4 color) : base(color)
|
||||
{
|
||||
_mesh = polygon;
|
||||
}
|
||||
|
||||
public DrawPolygon(Polygon polygon, Bitmap map, Color4 tint) : base(tint)
|
||||
{
|
||||
_mesh = polygon;
|
||||
|
||||
_material.Texture = new Texture(map);
|
||||
}
|
||||
|
||||
public Polygon Polygon
|
||||
{
|
||||
get => (Polygon) _mesh;
|
||||
set => _mesh = value;
|
||||
}
|
||||
|
||||
public Texture Texture
|
||||
{
|
||||
get => (Texture) _material.Texture;
|
||||
set => _material.Texture = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,24 +0,0 @@
|
|||
using SM.Base.Contexts;
|
||||
using SM.Base.Drawing;
|
||||
using SM.Base.Scene;
|
||||
using SM2D.Scene;
|
||||
using SM2D.Types;
|
||||
|
||||
namespace SM2D.Drawing
|
||||
{
|
||||
public class DrawShader : DrawingBasis<Transformation>, I2DShowItem
|
||||
{
|
||||
public int ZIndex { get; set; }
|
||||
|
||||
public DrawShader(MaterialShader shader)
|
||||
{
|
||||
_material.CustomShader = shader;
|
||||
}
|
||||
|
||||
protected override void DrawContext(ref DrawContext context)
|
||||
{
|
||||
base.DrawContext(ref context);
|
||||
_material.CustomShader.Draw(context);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,56 +0,0 @@
|
|||
#region usings
|
||||
|
||||
using System.Drawing;
|
||||
using OpenTK.Graphics;
|
||||
using SM.Base.Contexts;
|
||||
using SM.Base.Textures;
|
||||
using SM.Base.Types;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace SM2D.Drawing
|
||||
{
|
||||
public class DrawTexture : DrawColor
|
||||
{
|
||||
public static float MasterScale = .25f;
|
||||
public bool ManualSize = false;
|
||||
|
||||
public float Scale = 1;
|
||||
|
||||
public DrawTexture()
|
||||
{
|
||||
}
|
||||
|
||||
protected DrawTexture(Color4 color) : base(color)
|
||||
{
|
||||
}
|
||||
|
||||
public DrawTexture(Bitmap map) : this(map, Color4.White)
|
||||
{
|
||||
}
|
||||
|
||||
public DrawTexture(Bitmap map, Color4 color) : this((Texture) map, color)
|
||||
{
|
||||
}
|
||||
|
||||
public DrawTexture(Texture texture, Color4 color)
|
||||
{
|
||||
_material.Texture = texture;
|
||||
_material.Tint = color;
|
||||
}
|
||||
|
||||
public Texture Texture
|
||||
{
|
||||
get => (Texture) _material.Texture;
|
||||
set => _material.Texture = value;
|
||||
}
|
||||
|
||||
protected override void DrawContext(ref DrawContext context)
|
||||
{
|
||||
if (!ManualSize)
|
||||
Transform.Size = new CVector2(Texture.Map.Width * MasterScale * Scale,
|
||||
Texture.Map.Height * MasterScale * Scale);
|
||||
base.DrawContext(ref context);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
<configuration>
|
||||
<dllmap os="linux" dll="opengl32.dll" target="libGL.so.1"/>
|
||||
<dllmap os="linux" dll="glu32.dll" target="libGLU.so.1"/>
|
||||
<dllmap os="linux" dll="openal32.dll" target="libopenal.so.1"/>
|
||||
<dllmap os="linux" dll="alut.dll" target="libalut.so.0"/>
|
||||
<dllmap os="linux" dll="opencl.dll" target="libOpenCL.so"/>
|
||||
<dllmap os="linux" dll="libX11" target="libX11.so.6"/>
|
||||
<dllmap os="linux" dll="libXi" target="libXi.so.6"/>
|
||||
<dllmap os="linux" dll="SDL2.dll" target="libSDL2-2.0.so.0"/>
|
||||
<dllmap os="osx" dll="opengl32.dll" target="/System/Library/Frameworks/OpenGL.framework/OpenGL"/>
|
||||
<dllmap os="osx" dll="openal32.dll" target="/System/Library/Frameworks/OpenAL.framework/OpenAL" />
|
||||
<dllmap os="osx" dll="alut.dll" target="/System/Library/Frameworks/OpenAL.framework/OpenAL" />
|
||||
<dllmap os="osx" dll="libGLES.dll" target="/System/Library/Frameworks/OpenGLES.framework/OpenGLES" />
|
||||
<dllmap os="osx" dll="libGLESv1_CM.dll" target="/System/Library/Frameworks/OpenGLES.framework/OpenGLES" />
|
||||
<dllmap os="osx" dll="libGLESv2.dll" target="/System/Library/Frameworks/OpenGLES.framework/OpenGLES" />
|
||||
<dllmap os="osx" dll="opencl.dll" target="/System/Library/Frameworks/OpenCL.framework/OpenCL"/>
|
||||
<dllmap os="osx" dll="SDL2.dll" target="libSDL2.dylib"/>
|
||||
<!-- XQuartz compatibility (X11 on Mac) -->
|
||||
<dllmap os="osx" dll="libGL.so.1" target="/usr/X11/lib/libGL.dylib"/>
|
||||
<dllmap os="osx" dll="libX11" target="/usr/X11/lib/libX11.dylib"/>
|
||||
<dllmap os="osx" dll="libXcursor.so.1" target="/usr/X11/lib/libXcursor.dylib"/>
|
||||
<dllmap os="osx" dll="libXi" target="/usr/X11/lib/libXi.dylib"/>
|
||||
<dllmap os="osx" dll="libXinerama" target="/usr/X11/lib/libXinerama.dylib"/>
|
||||
<dllmap os="osx" dll="libXrandr.so.2" target="/usr/X11/lib/libXrandr.dylib"/>
|
||||
</configuration>
|
||||
|
|
@ -41,14 +41,9 @@
|
|||
<ItemGroup>
|
||||
<Compile Include="Controls\Mouse2D.cs" />
|
||||
<Compile Include="Drawing\DrawBackground.cs" />
|
||||
<Compile Include="Drawing\DrawBackgroundShader.cs" />
|
||||
<Compile Include="Drawing\DrawColor.cs" />
|
||||
<Compile Include="Drawing\DrawComplex.cs" />
|
||||
<Compile Include="Drawing\DrawObject2D.cs" />
|
||||
<Compile Include="Drawing\DrawParticles.cs" />
|
||||
<Compile Include="Drawing\DrawPolygon.cs" />
|
||||
<Compile Include="Drawing\DrawShader.cs" />
|
||||
<Compile Include="Drawing\DrawText.cs" />
|
||||
<Compile Include="Drawing\DrawTexture.cs" />
|
||||
<Compile Include="GLWindow2D.cs" />
|
||||
<Compile Include="Object\Polygon.cs" />
|
||||
<Compile Include="Object\PolygonVertex.cs" />
|
||||
|
|
@ -73,9 +68,12 @@
|
|||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="OpenTK.dll.config" />
|
||||
<None Include="packages.config" />
|
||||
<EmbeddedResource Include="Shader\ShaderFiles\default.glsl" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="OpenTK">
|
||||
<Version>3.2.1</Version>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="OpenTK" version="3.2.1" targetFramework="net452" />
|
||||
</packages>
|
||||
Loading…
Add table
Add a link
Reference in a new issue