Add IPostProcessWorldShader for custom effect render passes.
This commit is contained in:
@@ -442,6 +442,10 @@ namespace OpenRA.Platforms.Default
|
||||
int width, int height, int border, int format, int type, IntPtr pixels);
|
||||
public static TexImage2D glTexImage2D { get; private set; }
|
||||
|
||||
public delegate void CopyTexImage2D(int target, int level, int internalFormat,
|
||||
int x, int y, int width, int height, int border);
|
||||
public static CopyTexImage2D glCopyTexImage2D { get; private set; }
|
||||
|
||||
public delegate void GetTexImage(int target, int level,
|
||||
int format, int type, IntPtr pixels);
|
||||
public static GetTexImage glGetTexImage { get; private set; }
|
||||
@@ -607,6 +611,7 @@ namespace OpenRA.Platforms.Default
|
||||
glBindTexture = Bind<BindTexture>("glBindTexture");
|
||||
glActiveTexture = Bind<ActiveTexture>("glActiveTexture");
|
||||
glTexImage2D = Bind<TexImage2D>("glTexImage2D");
|
||||
glCopyTexImage2D = Bind<CopyTexImage2D>("glCopyTexImage2D");
|
||||
glTexParameteri = Bind<TexParameteri>("glTexParameteri");
|
||||
glTexParameterf = Bind<TexParameterf>("glTexParameterf");
|
||||
|
||||
|
||||
@@ -111,6 +111,19 @@ namespace OpenRA.Platforms.Default
|
||||
}
|
||||
}
|
||||
|
||||
public void SetDataFromReadBuffer(Rectangle rect)
|
||||
{
|
||||
VerifyThreadAffinity();
|
||||
if (!Exts.IsPowerOf2(rect.Width) || !Exts.IsPowerOf2(rect.Height))
|
||||
throw new InvalidDataException($"Non-power-of-two rectangle {rect.Width}x{rect.Height}");
|
||||
|
||||
PrepareTexture();
|
||||
|
||||
var glInternalFormat = OpenGL.Profile == GLProfile.Embedded ? OpenGL.GL_BGRA : OpenGL.GL_RGBA8;
|
||||
OpenGL.glCopyTexImage2D(OpenGL.GL_TEXTURE_2D, 0, glInternalFormat, rect.X, rect.Y, rect.Width, rect.Height, 0);
|
||||
OpenGL.CheckGLError();
|
||||
}
|
||||
|
||||
public byte[] GetData()
|
||||
{
|
||||
VerifyThreadAffinity();
|
||||
|
||||
@@ -648,6 +648,7 @@ namespace OpenRA.Platforms.Default
|
||||
readonly Func<object, object> setData2;
|
||||
readonly Action<object> setData3;
|
||||
readonly Func<object, object> setData4;
|
||||
readonly Action<object> setData5;
|
||||
readonly Action dispose;
|
||||
|
||||
public ThreadedTexture(ThreadedGraphicsContext device, ITextureInternal texture)
|
||||
@@ -663,6 +664,7 @@ namespace OpenRA.Platforms.Default
|
||||
setData2 = tuple => { setData1(tuple); return null; };
|
||||
setData3 = tuple => { var t = ((float[], int, int))tuple; texture.SetFloatData(t.Item1, t.Item2, t.Item3); };
|
||||
setData4 = tuple => { setData3(tuple); return null; };
|
||||
setData5 = rect => texture.SetDataFromReadBuffer((Rectangle)rect);
|
||||
dispose = texture.Dispose;
|
||||
}
|
||||
|
||||
@@ -725,6 +727,11 @@ namespace OpenRA.Platforms.Default
|
||||
}
|
||||
}
|
||||
|
||||
public void SetDataFromReadBuffer(Rectangle rect)
|
||||
{
|
||||
device.Post(setData5, rect);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
device.Post(dispose);
|
||||
|
||||
Reference in New Issue
Block a user