New batching structure base files.
This commit is contained in:
parent
7512f66cdb
commit
171c27ab80
@ -1,14 +1,15 @@
|
|||||||
using System;
|
using System;
|
||||||
namespace RecrownedGTK.Graphics.Render {
|
namespace RecrownedGTK.Graphics.Render {
|
||||||
public class TextureBatch {
|
public class Batch {
|
||||||
private bool begun;
|
private bool begun;
|
||||||
public TextureBatch() {
|
public Batch() {
|
||||||
//TODO Finish batch.
|
//TODO: Finish this class.
|
||||||
}
|
}
|
||||||
public void Begin() {
|
public void Begin() {
|
||||||
if (begun) throw new InvalidOperationException("This batch has already been started.");
|
if (begun) throw new InvalidOperationException("This batch has already been started.");
|
||||||
begun = true;
|
begun = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void End() {
|
public void End() {
|
||||||
if (!begun) throw new InvalidOperationException("The batch has not begun.");
|
if (!begun) throw new InvalidOperationException("The batch has not begun.");
|
||||||
begun = false;
|
begun = false;
|
@ -1,34 +1,11 @@
|
|||||||
using System.Drawing;
|
|
||||||
using System.IO;
|
|
||||||
|
|
||||||
namespace RecrownedGTK.Graphics {
|
namespace RecrownedGTK.Graphics {
|
||||||
public class Texture : IRectangleDrawable {
|
public class Texture : IDrawable {
|
||||||
//TODO Complete a basic texture capable of being rendered by a batch.
|
|
||||||
byte[] textureData;
|
|
||||||
public byte[] ColorData {
|
|
||||||
get {
|
|
||||||
return textureData;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public Texture() {
|
public Texture() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
public void Draw(out float[] vertices, out float[] indices, out TextureData textureData) {
|
||||||
public Texture(byte[] textureData) {
|
throw new System.NotImplementedException();
|
||||||
this.textureData = textureData;
|
//TODO: Implement this.
|
||||||
}
|
|
||||||
|
|
||||||
public Texture(string path) {
|
|
||||||
LoadFromPNG(path);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void LoadFromPNG(string path) {
|
|
||||||
using (FileStream file = new FileStream(path, FileMode.Open)) {
|
|
||||||
using (Bitmap bitmap = new Bitmap(file)) {
|
|
||||||
ImageConverter converter = new ImageConverter();
|
|
||||||
textureData = (byte[]) converter.ConvertTo(bitmap, typeof(byte[]));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
35
RecrownedGTK/Graphics/TextureData.cs
Normal file
35
RecrownedGTK/Graphics/TextureData.cs
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
using System.Drawing;
|
||||||
|
using System.IO;
|
||||||
|
using OpenTK.Graphics.OpenGL;
|
||||||
|
namespace RecrownedGTK.Graphics {
|
||||||
|
public class TextureData {
|
||||||
|
int handle;
|
||||||
|
byte[] textureData;
|
||||||
|
public byte[] ColorData {
|
||||||
|
get {
|
||||||
|
return textureData;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public TextureData(string path) {
|
||||||
|
LoadFromPNG(path);
|
||||||
|
}
|
||||||
|
public TextureData() {
|
||||||
|
//TODO: Finish this class.
|
||||||
|
}
|
||||||
|
public TextureData(byte[] textureData, int width, int height, int mipmap = 0) {
|
||||||
|
this.textureData = textureData;
|
||||||
|
GL.TexImage2D(TextureTarget.Texture2D, mipmap, PixelInternalFormat.Rgba, width, height, 0, PixelFormat.Rgba, PixelType.UnsignedByte, textureData);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void LoadFromPNG(string path) {
|
||||||
|
using (FileStream file = new FileStream(path, FileMode.Open)) {
|
||||||
|
using (Bitmap bitmap = new Bitmap(file)) {
|
||||||
|
ImageConverter converter = new ImageConverter();
|
||||||
|
textureData = (byte[]) converter.ConvertTo(bitmap, typeof(byte[]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user