18.09.2020
+ Textures ~ Changed 2D coordnate system to lower right as XY+
This commit is contained in:
parent
589d131246
commit
a603ecc417
26 changed files with 267 additions and 16 deletions
|
|
@ -7,12 +7,24 @@ namespace SM.OGL.Mesh
|
|||
{
|
||||
public class VBO : List<float>
|
||||
{
|
||||
public BufferUsageHint BufferUsageHint = BufferUsageHint.StaticDraw;
|
||||
public VertexAttribPointerType PointerType = VertexAttribPointerType.Float;
|
||||
public int PointerSize = 3;
|
||||
public bool Normalised = false;
|
||||
public int PointerStride = 0;
|
||||
public int PointerOffset = 0;
|
||||
public BufferUsageHint BufferUsageHint;
|
||||
public VertexAttribPointerType PointerType;
|
||||
public int PointerSize;
|
||||
public bool Normalised;
|
||||
public int PointerStride;
|
||||
public int PointerOffset;
|
||||
|
||||
public VBO(BufferUsageHint bufferUsageHint = BufferUsageHint.StaticDraw,
|
||||
VertexAttribPointerType pointerType = VertexAttribPointerType.Float, int pointerSize = 3,
|
||||
int pointerStride = 0, int pointerOffset = 0, bool normalised = false)
|
||||
{
|
||||
BufferUsageHint = bufferUsageHint;
|
||||
PointerType = pointerType;
|
||||
PointerSize = pointerSize;
|
||||
PointerStride = pointerStride;
|
||||
PointerOffset = pointerOffset;
|
||||
Normalised = normalised;
|
||||
}
|
||||
|
||||
public void Add(float x, float y) => AddRange(new[] {x,y});
|
||||
public void Add(float x, float y, float z) => AddRange(new[] {x,y,z});
|
||||
|
|
|
|||
|
|
@ -55,6 +55,7 @@
|
|||
<Compile Include="Shaders\ShaderFile.cs" />
|
||||
<Compile Include="Shaders\Uniform.cs" />
|
||||
<Compile Include="Shaders\UniformCollection.cs" />
|
||||
<Compile Include="Texture\TextureBase.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<ItemGroup>
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ namespace SM.OGL.Shaders
|
|||
throw new Exception("[Critical] No uniforms has been found.");
|
||||
|
||||
Uniforms = new UniformCollection();
|
||||
Uniforms._parentShader = this;
|
||||
for (int i = 0; i < uniformCount; i++)
|
||||
{
|
||||
string key = GL.GetActiveUniform(_id, i, out _, out _);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
using OpenTK;
|
||||
using OpenTK.Graphics;
|
||||
using OpenTK.Graphics.OpenGL4;
|
||||
using SM.OGL.Texture;
|
||||
|
||||
namespace SM.OGL.Shaders
|
||||
{
|
||||
|
|
@ -160,5 +161,14 @@ namespace SM.OGL.Shaders
|
|||
public void SetMatrix4(int count, float[] value, bool transpose = false) { GL.UniformMatrix4(Location, count, transpose, value); }
|
||||
|
||||
#endregion
|
||||
|
||||
public void SetTexture(TextureBase texture) => SetTexture(texture, Parent.NextTexture++);
|
||||
|
||||
public void SetTexture(TextureBase texture, int texturePos)
|
||||
{
|
||||
GL.ActiveTexture(TextureUnit.Texture0 + texturePos);
|
||||
GL.BindTexture(TextureTarget.Texture2D, texture);
|
||||
SetUniform1(texturePos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -6,6 +6,8 @@ namespace SM.OGL.Shaders
|
|||
{
|
||||
public class UniformCollection : Dictionary<string, Uniform>
|
||||
{
|
||||
internal int NextTexture = 0;
|
||||
|
||||
internal GenericShader _parentShader;
|
||||
|
||||
public new Uniform this[string key]
|
||||
|
|
|
|||
13
SMCode/SM.OGL/Texture/TextureBase.cs
Normal file
13
SMCode/SM.OGL/Texture/TextureBase.cs
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
using OpenTK.Graphics.OpenGL4;
|
||||
|
||||
namespace SM.OGL.Texture
|
||||
{
|
||||
public class TextureBase : GLObject
|
||||
{
|
||||
protected override bool AutoCompile { get; } = true;
|
||||
public override ObjectLabelIdentifier TypeIdentifier { get; } = ObjectLabelIdentifier.Texture;
|
||||
|
||||
public virtual TextureMinFilter Filter { get; set; }
|
||||
public virtual TextureWrapMode WrapMode { get; set; }
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue