some random bits
This commit is contained in:
@@ -10,11 +10,10 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Drawing;
|
|
||||||
using OpenRA.FileFormats;
|
|
||||||
using OpenRA.Traits;
|
|
||||||
using OpenRA.FileFormats.Graphics;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using OpenRA.FileFormats;
|
||||||
|
using OpenRA.FileFormats.Graphics;
|
||||||
|
using OpenRA.Traits;
|
||||||
|
|
||||||
namespace OpenRA.Graphics
|
namespace OpenRA.Graphics
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -34,6 +34,30 @@ namespace OpenRA.GlRenderer
|
|||||||
SetData(bitmap);
|
SetData(bitmap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void SetData(byte[] colors, int width, int height)
|
||||||
|
{
|
||||||
|
if (!IsPowerOf2(width) || !IsPowerOf2(height))
|
||||||
|
throw new InvalidDataException("Non-power-of-two array {0}x{1}".F(width, height));
|
||||||
|
|
||||||
|
unsafe
|
||||||
|
{
|
||||||
|
fixed (byte* ptr = &colors[0])
|
||||||
|
{
|
||||||
|
IntPtr intPtr = new IntPtr((void*)ptr);
|
||||||
|
|
||||||
|
Gl.glBindTexture(Gl.GL_TEXTURE_2D, texture);
|
||||||
|
GraphicsDevice.CheckGlError();
|
||||||
|
Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_BASE_LEVEL, 0);
|
||||||
|
GraphicsDevice.CheckGlError();
|
||||||
|
Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_MAX_LEVEL, 0);
|
||||||
|
GraphicsDevice.CheckGlError();
|
||||||
|
Gl.glTexImage2D(Gl.GL_TEXTURE_2D, 0, Gl.GL_RGBA8, width, height,
|
||||||
|
0, Gl.GL_BGRA, Gl.GL_UNSIGNED_BYTE, intPtr);
|
||||||
|
GraphicsDevice.CheckGlError();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// An array of RGBA
|
// An array of RGBA
|
||||||
public void SetData(uint[,] colors)
|
public void SetData(uint[,] colors)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user