Another restructure with code updates.
Updated RectTextrue.cs, VertexInformation.cs, and IDrawable.cs to properly pass indice information.
This commit is contained in:
parent
1a9ff8a26f
commit
519d31f2e1
20
RecrownedGTK.Tests/Graphics/Render/Shaders/ShaderTest.cs
Normal file
20
RecrownedGTK.Tests/Graphics/Render/Shaders/ShaderTest.cs
Normal file
@ -0,0 +1,20 @@
|
||||
using NUnit.Framework;
|
||||
using RecrownedGTK.Graphics.Render.Shaders;
|
||||
namespace RecrownedGTK.Tests
|
||||
{
|
||||
[TestFixture]
|
||||
public class ShaderTest
|
||||
{
|
||||
Shader currentShader;
|
||||
|
||||
public void Setup()
|
||||
{
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test()
|
||||
{
|
||||
Assert.DoesNotThrow(Shader.CreateBasicShader);
|
||||
}
|
||||
}
|
||||
}
|
19
RecrownedGTK.Tests/RecrownedGTK.Tests.csproj
Normal file
19
RecrownedGTK.Tests/RecrownedGTK.Tests.csproj
Normal file
@ -0,0 +1,19 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net48</TargetFramework>
|
||||
|
||||
<IsPackable>false</IsPackable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="nunit" Version="3.12.0" />
|
||||
<PackageReference Include="NUnit3TestAdapter" Version="3.15.1" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.4.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\RecrownedGTK\RecrownedGTK.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
@ -5,6 +5,12 @@
|
||||
},
|
||||
{
|
||||
"path": "RecrownedGTK.Tools"
|
||||
},
|
||||
{
|
||||
"path": "RecrownedGTK.Tests"
|
||||
},
|
||||
{
|
||||
"path": "RecrownedGTK.Tools.Tests"
|
||||
}
|
||||
],
|
||||
"settings": {}
|
||||
|
@ -3,10 +3,10 @@ namespace RecrownedGTK.Graphics.Render {
|
||||
public interface IDrawable
|
||||
{
|
||||
/// <summary>
|
||||
/// Fills the parameters with the information needed to draw this texture.!--
|
||||
/// Fills the parameters with the information needed to draw this texture.
|
||||
/// </summary>
|
||||
/// <param name="vertices">The vertices in pairs of 3 normalized in the order x, y, and z.</param>
|
||||
/// <param name="textureData">The texture data to be used. Can be null.</param>
|
||||
void Draw(out VertexInformation[] vertices, out TextureData textureData);
|
||||
void Draw(out VertexInformation[] vertices, out uint[] indices, out TextureData textureData);
|
||||
}
|
||||
}
|
@ -2,6 +2,7 @@ using RecrownedGTK.Types;
|
||||
using OpenTK.Graphics;
|
||||
namespace RecrownedGTK.Graphics.Render {
|
||||
public class RectTexture : Rectangle, IDrawable {
|
||||
private uint[] indices;
|
||||
private VertexInformation[] vertices;
|
||||
private TextureData textureData;
|
||||
public Color4 Color {
|
||||
@ -55,8 +56,13 @@ namespace RecrownedGTK.Graphics.Render {
|
||||
}
|
||||
public RectTexture(TextureData textureData) {
|
||||
this.textureData = textureData;
|
||||
|
||||
vertices = new VertexInformation[4];
|
||||
indices = new uint[] {0, 1, 3,
|
||||
1, 2, 3};
|
||||
}
|
||||
public void Draw(out VertexInformation[] vertices, out TextureData textureData) {
|
||||
public void Draw(out VertexInformation[] vertices, out uint[] indices, out TextureData textureData) {
|
||||
indices = this.indices;
|
||||
vertices = this.vertices;
|
||||
textureData = this.textureData;
|
||||
}
|
@ -2,7 +2,7 @@ using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using OpenTK.Graphics.OpenGL;
|
||||
namespace RecrownedGTK.Graphics.Render.Shader {
|
||||
namespace RecrownedGTK.Graphics.Render.Shaders {
|
||||
public class Shader : IDisposable {
|
||||
int handle;
|
||||
public bool IsDisposed {
|
@ -7,7 +7,7 @@ namespace RecrownedGTK.Graphics {
|
||||
public class TextureData : IDisposable {
|
||||
private bool disposed;
|
||||
int handle;
|
||||
|
||||
public readonly int width, height;
|
||||
public TextureWrapMode textureWrapModeWidth, textureWrapModeHeight;
|
||||
public Color4 borderColor;
|
||||
public TextureMinFilter textureMinFilter;
|
||||
@ -25,7 +25,8 @@ namespace RecrownedGTK.Graphics {
|
||||
height = bitmap.Height;
|
||||
}
|
||||
}
|
||||
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
GenerateTexture(textureData, width, height);
|
||||
}
|
||||
|
||||
@ -34,7 +35,8 @@ namespace RecrownedGTK.Graphics {
|
||||
textureWrapModeWidth = TextureWrapMode.ClampToBorder;
|
||||
textureMinFilter = TextureMinFilter.LinearMipmapLinear;
|
||||
textureMagFilter = TextureMagFilter.Linear;
|
||||
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
GenerateTexture(textureData, width, height);
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
using System;
|
||||
using OpenTK.Graphics.OpenGL;
|
||||
using OpenTK;
|
||||
using RecrownedGTK.Graphics.Render.Shader;
|
||||
using RecrownedGTK.Graphics.Render.Shaders;
|
||||
namespace RecrownedGTK.Graphics {
|
||||
public class VertexAttributesArrayHandle : IDisposable {
|
||||
private bool disposed;
|
||||
@ -18,7 +18,7 @@ namespace RecrownedGTK.Graphics {
|
||||
/// Creates a basic vertex attributes object handle that takes in vertices, texture coordinates, and a color.
|
||||
/// First 3 values are normalized vertex position (x, y, z), second two are texture coordinates, and last 4 are color values.
|
||||
/// </summary>
|
||||
/// <param name="shader">The shader program used. Default is the one created from <see cref="RecrownedGTK.Graphics.Render.Shader.Shader.CreateBasicShader"/>.</param>
|
||||
/// <param name="shader">The shader program used. Default is the one created from <see cref="RecrownedGTK.Graphics.Render.Shaders.Shader.CreateBasicShader"/>.</param>
|
||||
/// <param name="positionAttribName">The name of the attribute for the vertex's position in the shader. Default is "aPosition".</param>
|
||||
/// <param name="textureAttribName">The name of the attribute for the texture's coordinate. Default is "aTexture".</param>
|
||||
/// <param name="colorAttribName">The name of the attribute for color mixture. Default is "aColor".</param>
|
@ -3,7 +3,6 @@ using OpenTK.Graphics;
|
||||
namespace RecrownedGTK.Graphics {
|
||||
public struct VertexInformation {
|
||||
public Vector3 coords;
|
||||
public uint[] indices;
|
||||
public Color4 color;
|
||||
public Vector2 textureCoords;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user