New batching structure base files.
This commit is contained in:
parent
7512f66cdb
commit
171c27ab80
@ -1,14 +1,15 @@
|
||||
using System;
|
||||
namespace RecrownedGTK.Graphics.Render {
|
||||
public class TextureBatch {
|
||||
public class Batch {
|
||||
private bool begun;
|
||||
public TextureBatch() {
|
||||
//TODO Finish batch.
|
||||
public Batch() {
|
||||
//TODO: Finish this class.
|
||||
}
|
||||
public void Begin() {
|
||||
if (begun) throw new InvalidOperationException("This batch has already been started.");
|
||||
begun = true;
|
||||
}
|
||||
|
||||
public void End() {
|
||||
if (!begun) throw new InvalidOperationException("The batch has not begun.");
|
||||
begun = false;
|
@ -1,34 +1,11 @@
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
|
||||
namespace RecrownedGTK.Graphics {
|
||||
public class Texture : IRectangleDrawable {
|
||||
//TODO Complete a basic texture capable of being rendered by a batch.
|
||||
byte[] textureData;
|
||||
public byte[] ColorData {
|
||||
get {
|
||||
return textureData;
|
||||
}
|
||||
}
|
||||
public class Texture : IDrawable {
|
||||
public Texture() {
|
||||
|
||||
}
|
||||
|
||||
public Texture(byte[] textureData) {
|
||||
this.textureData = textureData;
|
||||
}
|
||||
|
||||
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[]));
|
||||
}
|
||||
}
|
||||
|
||||
public void Draw(out float[] vertices, out float[] indices, out TextureData textureData) {
|
||||
throw new System.NotImplementedException();
|
||||
//TODO: Implement this.
|
||||
}
|
||||
}
|
||||
}
|
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