More correct, still doesn't work.
This commit is contained in:
@@ -32,6 +32,7 @@ namespace OpenRA.FileFormats.Graphics
|
|||||||
IVertexBuffer<Vertex> CreateVertexBuffer( int length );
|
IVertexBuffer<Vertex> CreateVertexBuffer( int length );
|
||||||
IIndexBuffer CreateIndexBuffer( int length );
|
IIndexBuffer CreateIndexBuffer( int length );
|
||||||
ITexture CreateTexture( Bitmap bitmap );
|
ITexture CreateTexture( Bitmap bitmap );
|
||||||
|
ITexture CreateTexture();
|
||||||
IShader CreateShader( Stream stream );
|
IShader CreateShader( Stream stream );
|
||||||
|
|
||||||
Size WindowSize { get; }
|
Size WindowSize { get; }
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ namespace OpenRA.Graphics
|
|||||||
{
|
{
|
||||||
public const int MaxPalettes = 64;
|
public const int MaxPalettes = 64;
|
||||||
int allocated = 0;
|
int allocated = 0;
|
||||||
|
ITexture texture;
|
||||||
|
|
||||||
// We need to store the Palettes themselves for the remap palettes to work
|
// We need to store the Palettes themselves for the remap palettes to work
|
||||||
// We should probably try to fix this somehow
|
// We should probably try to fix this somehow
|
||||||
@@ -31,6 +32,7 @@ namespace OpenRA.Graphics
|
|||||||
{
|
{
|
||||||
palettes = new Dictionary<string, Palette>();
|
palettes = new Dictionary<string, Palette>();
|
||||||
indices = new Dictionary<string, int>();
|
indices = new Dictionary<string, int>();
|
||||||
|
texture = Game.Renderer.Device.CreateTexture();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Palette GetPalette(string name)
|
public Palette GetPalette(string name)
|
||||||
@@ -81,17 +83,17 @@ namespace OpenRA.Graphics
|
|||||||
//foreach (var mod in paletteMods)
|
//foreach (var mod in paletteMods)
|
||||||
// mod.AdjustPalette(b);
|
// mod.AdjustPalette(b);
|
||||||
|
|
||||||
var data = new uint[256,MaxPalettes];
|
var data = new uint[MaxPalettes,256];
|
||||||
foreach (var pal in palettes)
|
foreach (var pal in palettes)
|
||||||
{
|
{
|
||||||
var j = indices[pal.Key];
|
var j = indices[pal.Key];
|
||||||
var c = pal.Value.Values;
|
var c = pal.Value.Values;
|
||||||
for (var i = 0; i < 256; i++)
|
for (var i = 0; i < 256; i++)
|
||||||
data[i,j] = c[i];
|
data[j,i] = c[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Doesn't work
|
// Doesn't work
|
||||||
Texture.SetData(data);
|
texture.SetData(data);
|
||||||
/*
|
/*
|
||||||
// Works
|
// Works
|
||||||
var foo = new Bitmap(256,MaxPalettes);
|
var foo = new Bitmap(256,MaxPalettes);
|
||||||
@@ -102,19 +104,7 @@ namespace OpenRA.Graphics
|
|||||||
|
|
||||||
Texture.SetData(foo);
|
Texture.SetData(foo);
|
||||||
*/
|
*/
|
||||||
Game.Renderer.PaletteTexture = Texture;
|
Game.Renderer.PaletteTexture = texture;
|
||||||
}
|
|
||||||
|
|
||||||
ITexture texture;
|
|
||||||
public ITexture Texture
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (texture == null)
|
|
||||||
texture = Game.Renderer.Device.CreateTexture(new Bitmap(MaxPalettes, 256));
|
|
||||||
|
|
||||||
return texture;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -283,6 +283,7 @@ namespace OpenRA.GlRenderer
|
|||||||
|
|
||||||
public IVertexBuffer<Vertex> CreateVertexBuffer(int size) { return new VertexBuffer<Vertex>(this, size); }
|
public IVertexBuffer<Vertex> CreateVertexBuffer(int size) { return new VertexBuffer<Vertex>(this, size); }
|
||||||
public IIndexBuffer CreateIndexBuffer(int size) { return new IndexBuffer(this, size); }
|
public IIndexBuffer CreateIndexBuffer(int size) { return new IndexBuffer(this, size); }
|
||||||
|
public ITexture CreateTexture() { return new Texture(this); }
|
||||||
public ITexture CreateTexture(Bitmap bitmap) { return new Texture(this, bitmap); }
|
public ITexture CreateTexture(Bitmap bitmap) { return new Texture(this, bitmap); }
|
||||||
public IShader CreateShader(Stream stream) { return new Shader(this, stream); }
|
public IShader CreateShader(Stream stream) { return new Shader(this, stream); }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,6 +21,12 @@ namespace OpenRA.GlRenderer
|
|||||||
{
|
{
|
||||||
internal int texture;
|
internal int texture;
|
||||||
|
|
||||||
|
public Texture(GraphicsDevice dev)
|
||||||
|
{
|
||||||
|
Gl.glGenTextures(1, out texture);
|
||||||
|
GraphicsDevice.CheckGlError();
|
||||||
|
}
|
||||||
|
|
||||||
public Texture(GraphicsDevice dev, Bitmap bitmap)
|
public Texture(GraphicsDevice dev, Bitmap bitmap)
|
||||||
{
|
{
|
||||||
Gl.glGenTextures(1, out texture);
|
Gl.glGenTextures(1, out texture);
|
||||||
|
|||||||
Reference in New Issue
Block a user