diff --git a/Bizware/BizHawk.Bizware.BizwareGL.OpenTK/IGL_TK.cs b/Bizware/BizHawk.Bizware.BizwareGL.OpenTK/IGL_TK.cs
index 78363a7506..b769216156 100644
--- a/Bizware/BizHawk.Bizware.BizwareGL.OpenTK/IGL_TK.cs
+++ b/Bizware/BizHawk.Bizware.BizwareGL.OpenTK/IGL_TK.cs
@@ -434,6 +434,17 @@ namespace BizHawk.Bizware.BizwareGL.Drivers.OpenTK
return ret;
}
+ public unsafe BitmapBuffer ResolveTexture2d(Texture2d tex)
+ {
+ //note - this is dangerous since it changes the bound texture. could we save it?
+ BindTexture2d(tex);
+ var bb = new BitmapBuffer(tex.IntWidth, tex.IntHeight);
+ var bmpdata = bb.LockBits();
+ GL.GetTexImage(TextureTarget.Texture2D, 0, PixelFormat.Bgra, PixelType.Byte, bmpdata.Scan0);
+ bb.UnlockBits(bmpdata);
+ return bb;
+ }
+
public Texture2d LoadTexture(string path)
{
using (var fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read))
diff --git a/Bizware/BizHawk.Bizware.BizwareGL/IGL.cs b/Bizware/BizHawk.Bizware.BizwareGL/IGL.cs
index b4946be35b..e365748a10 100644
--- a/Bizware/BizHawk.Bizware.BizwareGL/IGL.cs
+++ b/Bizware/BizHawk.Bizware.BizwareGL/IGL.cs
@@ -19,7 +19,6 @@ namespace BizHawk.Bizware.BizwareGL
///
public interface IGL : IDisposable
{
-
///
/// Clears the specified buffer parts
///
@@ -126,6 +125,11 @@ namespace BizHawk.Bizware.BizwareGL
///
void FreeTexture(IntPtr texHandle);
+ ///
+ /// resolves the texture into a new BitmapBuffer
+ ///
+ BitmapBuffer ResolveTexture2d(Texture2d texture);
+
///
/// frees the provided render target
///
@@ -134,7 +138,6 @@ namespace BizHawk.Bizware.BizwareGL
///
/// Binds this texture as the current texture2d target for parameter-specification
///
- ///
void BindTexture2d(Texture2d texture);
///
diff --git a/Bizware/BizHawk.Bizware.BizwareGL/Texture2d.cs b/Bizware/BizHawk.Bizware.BizwareGL/Texture2d.cs
index baae303336..b4cbb6093a 100644
--- a/Bizware/BizHawk.Bizware.BizwareGL/Texture2d.cs
+++ b/Bizware/BizHawk.Bizware.BizwareGL/Texture2d.cs
@@ -13,24 +13,13 @@ namespace BizHawk.Bizware.BizwareGL
///
public class Texture2d : IDisposable
{
- //not sure if I need this idea.
- //public class Maker
- //{
- // public Maker(Texture2d tex)
- // {
- // MyTexture = tex;
- // }
- // public void SetWidth(int width)
- // {
- // MyTexture.Width = width;
- // }
- // public void SetHeight(int width)
- // {
- // MyTexture.Height = height;
- // }
-
- // Texture2d MyTexture;
- //}
+ ///
+ /// resolves the texture into a new BitmapBuffer
+ ///
+ public BitmapBuffer Resolve()
+ {
+ return Owner.ResolveTexture2d(this);
+ }
public void Dispose()
{
diff --git a/Bizware/BizHawk.Bizware.Test/Program.cs b/Bizware/BizHawk.Bizware.Test/Program.cs
index 4e62cb4718..6e58e58dd5 100644
--- a/Bizware/BizHawk.Bizware.Test/Program.cs
+++ b/Bizware/BizHawk.Bizware.Test/Program.cs
@@ -59,6 +59,8 @@ namespace BizHawk.Bizware.Test
gr.End();
rt.Unbind();
+ Texture2d rttex2d = igl.LoadTexture(rt.Texture2d.Resolve());
+
//test retroarch shader
RenderTarget rt2 = igl.CreateRenderTarget(240, 240);
rt2.Bind();
@@ -68,7 +70,7 @@ namespace BizHawk.Bizware.Test
using (var stream = typeof(Program).Assembly.GetManifestResourceStream("BizHawk.Bizware.Test.TestImages.4xSoft.glsl"))
shader = new RetroShader(igl, new System.IO.StreamReader(stream).ReadToEnd());
igl.SetBlendState(igl.BlendNone);
- shader.Run(rt.Texture2d, new Size(60, 60), new Size(240, 240), true);
+ shader.Run(rttex2d, new Size(60, 60), new Size(240, 240), true);
bool running = true;
@@ -101,7 +103,7 @@ namespace BizHawk.Bizware.Test
gr.RectFill(250, 0, 16, 16);
gr.SetBlendState(igl.BlendNone);
- gr.Draw(rt.Texture2d, 0, 20);
+ gr.Draw(rttex2d, 0, 20);
gr.SetBlendState(igl.BlendNormal);
sr.RenderString(gr, 0, 0, "?? fps");