- Implemented RenderTarget in OpenGL
- Implemented dynamic shader attributes mapping in the vertex buffer in OpenGL
This commit is contained in:
parent
1d61c78f88
commit
8239306d2e
@ -5,8 +5,8 @@ using System.IO;
|
||||
using ANX.Framework.Graphics;
|
||||
using ANX.Framework.NonXNA;
|
||||
using ANX.Framework.NonXNA.RenderSystem;
|
||||
using OpenTK;
|
||||
using NLog;
|
||||
using OpenTK;
|
||||
|
||||
#region License
|
||||
|
||||
@ -62,7 +62,7 @@ namespace ANX.Framework.Windows.GL3
|
||||
/// </summary>
|
||||
public class Creator : IRenderSystemCreator
|
||||
{
|
||||
private static Logger logger = LogManager.GetCurrentClassLogger();
|
||||
private static Logger logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
#region Public
|
||||
/// <summary>
|
||||
@ -81,23 +81,23 @@ namespace ANX.Framework.Windows.GL3
|
||||
get { return 100; }
|
||||
}
|
||||
|
||||
public bool IsSupported
|
||||
{
|
||||
get
|
||||
{
|
||||
//TODO: this is just a very basic version of test for support
|
||||
return AddInSystemFactory.Instance.OperatingSystem.Platform == PlatformID.Win32NT ||
|
||||
AddInSystemFactory.Instance.OperatingSystem.Platform == PlatformID.Unix ||
|
||||
AddInSystemFactory.Instance.OperatingSystem.Platform == PlatformID.MacOSX;
|
||||
}
|
||||
}
|
||||
public bool IsSupported
|
||||
{
|
||||
get
|
||||
{
|
||||
//TODO: this is just a very basic version of test for support
|
||||
return AddInSystemFactory.Instance.OperatingSystem.Platform == PlatformID.Win32NT ||
|
||||
AddInSystemFactory.Instance.OperatingSystem.Platform == PlatformID.Unix ||
|
||||
AddInSystemFactory.Instance.OperatingSystem.Platform == PlatformID.MacOSX;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region RegisterRenderSystemCreator
|
||||
public void RegisterCreator(AddInSystemFactory factory)
|
||||
{
|
||||
logger.Debug("adding OpenGL3 RenderSystem creator to creator collection of AddInSystemFactory");
|
||||
logger.Debug("adding OpenGL3 RenderSystem creator to creator collection of AddInSystemFactory");
|
||||
factory.AddCreator(this);
|
||||
}
|
||||
#endregion
|
||||
@ -105,16 +105,16 @@ namespace ANX.Framework.Windows.GL3
|
||||
#region CreateGameHost
|
||||
public GameHost CreateGameHost(Game game)
|
||||
{
|
||||
logger.Info("creating OpenGL3 GameHost");
|
||||
AddInSystemFactory.Instance.PreventRenderSystemChange();
|
||||
return new WindowsGameHost(game);
|
||||
logger.Info("creating OpenGL3 GameHost");
|
||||
AddInSystemFactory.Instance.PreventRenderSystemChange();
|
||||
return new WindowsGameHost(game);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region CreateEffect
|
||||
public INativeEffect CreateEffect(GraphicsDevice graphics, Effect managedEffect, Stream byteCode)
|
||||
{
|
||||
AddInSystemFactory.Instance.PreventRenderSystemChange();
|
||||
AddInSystemFactory.Instance.PreventRenderSystemChange();
|
||||
|
||||
return new EffectGL3(managedEffect, byteCode);
|
||||
}
|
||||
@ -122,9 +122,9 @@ namespace ANX.Framework.Windows.GL3
|
||||
public INativeEffect CreateEffect(GraphicsDevice graphics, Effect managedEffect,
|
||||
Stream vertexShaderByteCode, Stream pixelShaderByteCode)
|
||||
{
|
||||
AddInSystemFactory.Instance.PreventRenderSystemChange();
|
||||
|
||||
return new EffectGL3(managedEffect, vertexShaderByteCode, pixelShaderByteCode);
|
||||
AddInSystemFactory.Instance.PreventRenderSystemChange();
|
||||
|
||||
return new EffectGL3(managedEffect, vertexShaderByteCode, pixelShaderByteCode);
|
||||
}
|
||||
#endregion
|
||||
|
||||
@ -132,8 +132,8 @@ namespace ANX.Framework.Windows.GL3
|
||||
INativeGraphicsDevice IRenderSystemCreator.CreateGraphicsDevice(
|
||||
PresentationParameters presentationParameters)
|
||||
{
|
||||
AddInSystemFactory.Instance.PreventRenderSystemChange();
|
||||
return new GraphicsDeviceWindowsGL3(presentationParameters);
|
||||
AddInSystemFactory.Instance.PreventRenderSystemChange();
|
||||
return new GraphicsDeviceWindowsGL3(presentationParameters);
|
||||
}
|
||||
#endregion
|
||||
|
||||
@ -150,8 +150,8 @@ namespace ANX.Framework.Windows.GL3
|
||||
public INativeTexture2D CreateTexture(GraphicsDevice graphics,
|
||||
SurfaceFormat surfaceFormat, int width, int height, int mipCount)
|
||||
{
|
||||
AddInSystemFactory.Instance.PreventRenderSystemChange();
|
||||
return new Texture2DGL3(surfaceFormat, width, height, mipCount);
|
||||
AddInSystemFactory.Instance.PreventRenderSystemChange();
|
||||
return new Texture2DGL3(surfaceFormat, width, height, mipCount);
|
||||
}
|
||||
#endregion
|
||||
|
||||
@ -168,8 +168,8 @@ namespace ANX.Framework.Windows.GL3
|
||||
public INativeBuffer CreateIndexBuffer(GraphicsDevice graphics,
|
||||
IndexElementSize size, int indexCount, BufferUsage usage)
|
||||
{
|
||||
AddInSystemFactory.Instance.PreventRenderSystemChange();
|
||||
return new IndexBufferGL3(size, indexCount, usage);
|
||||
AddInSystemFactory.Instance.PreventRenderSystemChange();
|
||||
return new IndexBufferGL3(size, indexCount, usage);
|
||||
}
|
||||
#endregion
|
||||
|
||||
@ -187,8 +187,8 @@ namespace ANX.Framework.Windows.GL3
|
||||
VertexDeclaration vertexDeclaration, int vertexCount,
|
||||
BufferUsage usage)
|
||||
{
|
||||
AddInSystemFactory.Instance.PreventRenderSystemChange();
|
||||
return new VertexBufferGL3(vertexDeclaration, vertexCount, usage);
|
||||
AddInSystemFactory.Instance.PreventRenderSystemChange();
|
||||
return new VertexBufferGL3(vertexDeclaration, vertexCount, usage);
|
||||
}
|
||||
#endregion
|
||||
|
||||
@ -199,8 +199,8 @@ namespace ANX.Framework.Windows.GL3
|
||||
/// <returns>Native Blend State.</returns>
|
||||
public INativeBlendState CreateBlendState()
|
||||
{
|
||||
AddInSystemFactory.Instance.PreventRenderSystemChange();
|
||||
return new BlendStateGL3();
|
||||
AddInSystemFactory.Instance.PreventRenderSystemChange();
|
||||
return new BlendStateGL3();
|
||||
}
|
||||
#endregion
|
||||
|
||||
@ -211,8 +211,8 @@ namespace ANX.Framework.Windows.GL3
|
||||
/// <returns>Native Rasterizer State.</returns>
|
||||
public INativeRasterizerState CreateRasterizerState()
|
||||
{
|
||||
AddInSystemFactory.Instance.PreventRenderSystemChange();
|
||||
return new RasterizerStateGL3();
|
||||
AddInSystemFactory.Instance.PreventRenderSystemChange();
|
||||
return new RasterizerStateGL3();
|
||||
}
|
||||
#endregion
|
||||
|
||||
@ -223,8 +223,8 @@ namespace ANX.Framework.Windows.GL3
|
||||
/// <returns>Native Depth Stencil State.</returns>
|
||||
public INativeDepthStencilState CreateDepthStencilState()
|
||||
{
|
||||
AddInSystemFactory.Instance.PreventRenderSystemChange();
|
||||
return new DepthStencilStateGL3();
|
||||
AddInSystemFactory.Instance.PreventRenderSystemChange();
|
||||
return new DepthStencilStateGL3();
|
||||
}
|
||||
#endregion
|
||||
|
||||
@ -235,8 +235,8 @@ namespace ANX.Framework.Windows.GL3
|
||||
/// <returns>Native Sampler State.</returns>
|
||||
public INativeSamplerState CreateSamplerState()
|
||||
{
|
||||
AddInSystemFactory.Instance.PreventRenderSystemChange();
|
||||
return new SamplerStateGL3();
|
||||
AddInSystemFactory.Instance.PreventRenderSystemChange();
|
||||
return new SamplerStateGL3();
|
||||
}
|
||||
#endregion
|
||||
|
||||
@ -248,9 +248,9 @@ namespace ANX.Framework.Windows.GL3
|
||||
/// <returns>Byte code of the shader.</returns>
|
||||
public byte[] GetShaderByteCode(PreDefinedShader type)
|
||||
{
|
||||
AddInSystemFactory.Instance.PreventRenderSystemChange();
|
||||
|
||||
if (type == PreDefinedShader.SpriteBatch)
|
||||
AddInSystemFactory.Instance.PreventRenderSystemChange();
|
||||
|
||||
if (type == PreDefinedShader.SpriteBatch)
|
||||
{
|
||||
return ShaderByteCode.SpriteBatchByteCode;
|
||||
}
|
||||
@ -286,9 +286,9 @@ namespace ANX.Framework.Windows.GL3
|
||||
/// <returns>List of graphics adapters.</returns>
|
||||
public ReadOnlyCollection<GraphicsAdapter> GetAdapterList()
|
||||
{
|
||||
AddInSystemFactory.Instance.PreventRenderSystemChange();
|
||||
|
||||
var result = new List<GraphicsAdapter>();
|
||||
AddInSystemFactory.Instance.PreventRenderSystemChange();
|
||||
|
||||
var result = new List<GraphicsAdapter>();
|
||||
foreach (DisplayDevice device in DisplayDevice.AvailableDisplays)
|
||||
{
|
||||
var displayModeCollection = new DisplayModeCollection();
|
||||
@ -347,8 +347,8 @@ namespace ANX.Framework.Windows.GL3
|
||||
DepthFormat preferredDepthFormat, int preferredMultiSampleCount,
|
||||
RenderTargetUsage usage)
|
||||
{
|
||||
AddInSystemFactory.Instance.PreventRenderSystemChange();
|
||||
return new RenderTarget2DGL3(width, height, mipMap, preferredFormat,
|
||||
AddInSystemFactory.Instance.PreventRenderSystemChange();
|
||||
return new RenderTarget2DGL3(width, height, mipMap, preferredFormat,
|
||||
preferredDepthFormat, preferredMultiSampleCount, usage);
|
||||
}
|
||||
#endregion
|
||||
|
@ -63,6 +63,16 @@ namespace ANX.Framework.Windows.GL3
|
||||
/// </summary>
|
||||
public class EffectGL3 : INativeEffect
|
||||
{
|
||||
#region ShaderAttribute (Helper struct)
|
||||
public struct ShaderAttribute
|
||||
{
|
||||
public string Name;
|
||||
public uint Location;
|
||||
public int Size;
|
||||
public ActiveAttribType Type;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Constants
|
||||
private const string FragmentSeparator = "##!fragment!##";
|
||||
#endregion
|
||||
@ -73,7 +83,13 @@ namespace ANX.Framework.Windows.GL3
|
||||
/// </summary>
|
||||
internal int programHandle;
|
||||
|
||||
private Effect managedEffect;
|
||||
private Effect managedEffect;
|
||||
|
||||
internal Dictionary<string, ShaderAttribute> ActiveAttributes
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Public
|
||||
@ -193,6 +209,8 @@ namespace ANX.Framework.Windows.GL3
|
||||
throw new InvalidDataException("Failed to link the shader program " +
|
||||
"because of: " + programError);
|
||||
}
|
||||
|
||||
GetAttributes();
|
||||
}
|
||||
#endregion
|
||||
|
||||
@ -308,6 +326,31 @@ namespace ANX.Framework.Windows.GL3
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region GetAttributes
|
||||
private void GetAttributes()
|
||||
{
|
||||
ActiveAttributes = new Dictionary<string, ShaderAttribute>();
|
||||
int attributeCount;
|
||||
GL.GetProgram(programHandle, ProgramParameter.ActiveAttributes,
|
||||
out attributeCount);
|
||||
for (int index = 0; index < attributeCount; index++)
|
||||
{
|
||||
int attributeSize;
|
||||
ActiveAttribType attributeType;
|
||||
string name = GL.GetActiveAttrib(programHandle, index,
|
||||
out attributeSize, out attributeType);
|
||||
uint attributeIndex = (uint)GL.GetAttribLocation(programHandle, name);
|
||||
ActiveAttributes.Add(name, new ShaderAttribute
|
||||
{
|
||||
Name = name,
|
||||
Location = attributeIndex,
|
||||
Size = attributeSize,
|
||||
Type = attributeType,
|
||||
});
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Apply (TODO)
|
||||
public void Apply(GraphicsDevice graphicsDevice)
|
||||
{
|
||||
|
@ -1,10 +1,11 @@
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
using ANX.Framework.Graphics;
|
||||
using ANX.Framework.NonXNA;
|
||||
using OpenTK.Graphics;
|
||||
using OpenTK.Graphics.OpenGL;
|
||||
using OpenTK.Platform;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
#region License
|
||||
|
||||
@ -64,63 +65,63 @@ namespace ANX.Framework.Windows.GL3
|
||||
private const float ColorMultiplier = 1f / 255f;
|
||||
#endregion
|
||||
|
||||
#region Interop
|
||||
[DllImport("user32.dll")]
|
||||
private static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int x, int y, int width, int height, uint uFlags);
|
||||
#region Interop
|
||||
[DllImport("user32.dll")]
|
||||
private static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int x, int y, int width, int height, uint uFlags);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
static extern bool GetWindowRect(IntPtr hWnd, out RECT lpRect);
|
||||
[DllImport("user32.dll")]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
static extern bool GetWindowRect(IntPtr hWnd, out RECT lpRect);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
static extern bool GetClientRect(IntPtr hWnd, out RECT lpRect);
|
||||
[DllImport("user32.dll")]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
static extern bool GetClientRect(IntPtr hWnd, out RECT lpRect);
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct RECT
|
||||
{
|
||||
public int Left; // x position of upper-left corner
|
||||
public int Top; // y position of upper-left corner
|
||||
public int Right; // x position of lower-right corner
|
||||
public int Bottom; // y position of lower-right corner
|
||||
}
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct RECT
|
||||
{
|
||||
public int Left; // x position of upper-left corner
|
||||
public int Top; // y position of upper-left corner
|
||||
public int Right; // x position of lower-right corner
|
||||
public int Bottom; // y position of lower-right corner
|
||||
}
|
||||
|
||||
[DllImport("libX11")]
|
||||
static extern IntPtr XCreateColormap(IntPtr display, IntPtr window, IntPtr visual, int alloc);
|
||||
[DllImport("libX11")]
|
||||
static extern IntPtr XCreateColormap(IntPtr display, IntPtr window, IntPtr visual, int alloc);
|
||||
|
||||
[DllImport("libX11", EntryPoint = "XGetVisualInfo")]
|
||||
static extern IntPtr XGetVisualInfoInternal(IntPtr display, IntPtr vinfo_mask, ref XVisualInfo template, out int nitems);
|
||||
[DllImport("libX11", EntryPoint = "XGetVisualInfo")]
|
||||
static extern IntPtr XGetVisualInfoInternal(IntPtr display, IntPtr vinfo_mask, ref XVisualInfo template, out int nitems);
|
||||
|
||||
static IntPtr XGetVisualInfo(IntPtr display, int vinfo_mask, ref XVisualInfo template, out int nitems)
|
||||
{
|
||||
return XGetVisualInfoInternal(display, (IntPtr)vinfo_mask, ref template, out nitems);
|
||||
}
|
||||
static IntPtr XGetVisualInfo(IntPtr display, int vinfo_mask, ref XVisualInfo template, out int nitems)
|
||||
{
|
||||
return XGetVisualInfoInternal(display, (IntPtr)vinfo_mask, ref template, out nitems);
|
||||
}
|
||||
|
||||
[DllImport("libX11")]
|
||||
extern static int XPending(IntPtr diplay);
|
||||
[DllImport("libX11")]
|
||||
extern static int XPending(IntPtr diplay);
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
struct XVisualInfo
|
||||
{
|
||||
public IntPtr Visual;
|
||||
public IntPtr VisualID;
|
||||
public int Screen;
|
||||
public int Depth;
|
||||
public int Class;
|
||||
public long RedMask;
|
||||
public long GreenMask;
|
||||
public long blueMask;
|
||||
public int ColormapSize;
|
||||
public int BitsPerRgb;
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
struct XVisualInfo
|
||||
{
|
||||
public IntPtr Visual;
|
||||
public IntPtr VisualID;
|
||||
public int Screen;
|
||||
public int Depth;
|
||||
public int Class;
|
||||
public long RedMask;
|
||||
public long GreenMask;
|
||||
public long blueMask;
|
||||
public int ColormapSize;
|
||||
public int BitsPerRgb;
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return String.Format("id ({0}), screen ({1}), depth ({2}), class ({3})",
|
||||
VisualID, Screen, Depth, Class);
|
||||
}
|
||||
}
|
||||
public override string ToString()
|
||||
{
|
||||
return String.Format("id ({0}), screen ({1}), depth ({2}), class ({3})",
|
||||
VisualID, Screen, Depth, Class);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Private
|
||||
/// <summary>
|
||||
@ -136,6 +137,8 @@ namespace ANX.Framework.Windows.GL3
|
||||
|
||||
internal static VertexBufferGL3[] boundVertexBuffers =
|
||||
new VertexBufferGL3[0];
|
||||
private static RenderTarget2DGL3[] boundRenderTargets =
|
||||
new RenderTarget2DGL3[0];
|
||||
internal static IndexBufferGL3 boundIndexBuffer;
|
||||
internal static EffectGL3 activeEffect;
|
||||
#endregion
|
||||
@ -214,51 +217,51 @@ namespace ANX.Framework.Windows.GL3
|
||||
break;
|
||||
}
|
||||
|
||||
GraphicsMode graphicsMode = new GraphicsMode(DatatypesMapping.SurfaceToColorFormat(presentationParameters.BackBufferFormat),
|
||||
depth,
|
||||
stencil,
|
||||
presentationParameters.MultiSampleCount // AntiAlias Samples: 2/4/8/16/32
|
||||
);
|
||||
GraphicsMode graphicsMode = new GraphicsMode(DatatypesMapping.SurfaceToColorFormat(presentationParameters.BackBufferFormat),
|
||||
depth,
|
||||
stencil,
|
||||
presentationParameters.MultiSampleCount // AntiAlias Samples: 2/4/8/16/32
|
||||
);
|
||||
|
||||
if (OpenTK.Configuration.RunningOnWindows)
|
||||
{
|
||||
nativeWindowInfo = Utilities.CreateWindowsWindowInfo(presentationParameters.DeviceWindowHandle);
|
||||
}
|
||||
else if (OpenTK.Configuration.RunningOnX11)
|
||||
{
|
||||
// Use reflection to retrieve the necessary values from Mono's Windows.Forms implementation.
|
||||
Type xplatui = Type.GetType("System.Windows.Forms.XplatUIX11, System.Windows.Forms");
|
||||
if (xplatui == null) throw new PlatformNotSupportedException(
|
||||
"System.Windows.Forms.XplatUIX11 missing. Unsupported platform or Mono runtime version, aborting.");
|
||||
if (OpenTK.Configuration.RunningOnWindows)
|
||||
{
|
||||
nativeWindowInfo = Utilities.CreateWindowsWindowInfo(presentationParameters.DeviceWindowHandle);
|
||||
}
|
||||
else if (OpenTK.Configuration.RunningOnX11)
|
||||
{
|
||||
// Use reflection to retrieve the necessary values from Mono's Windows.Forms implementation.
|
||||
Type xplatui = Type.GetType("System.Windows.Forms.XplatUIX11, System.Windows.Forms");
|
||||
if (xplatui == null) throw new PlatformNotSupportedException(
|
||||
"System.Windows.Forms.XplatUIX11 missing. Unsupported platform or Mono runtime version, aborting.");
|
||||
|
||||
// get the required handles from the X11 API.
|
||||
IntPtr display = (IntPtr)GetStaticFieldValue(xplatui, "DisplayHandle");
|
||||
IntPtr rootWindow = (IntPtr)GetStaticFieldValue(xplatui, "RootWindow");
|
||||
int screen = (int)GetStaticFieldValue(xplatui, "ScreenNo");
|
||||
// get the required handles from the X11 API.
|
||||
IntPtr display = (IntPtr)GetStaticFieldValue(xplatui, "DisplayHandle");
|
||||
IntPtr rootWindow = (IntPtr)GetStaticFieldValue(xplatui, "RootWindow");
|
||||
int screen = (int)GetStaticFieldValue(xplatui, "ScreenNo");
|
||||
|
||||
// get the XVisualInfo for this GraphicsMode
|
||||
XVisualInfo info = new XVisualInfo();
|
||||
info.VisualID = graphicsMode.Index.Value;
|
||||
int dummy;
|
||||
IntPtr infoPtr = XGetVisualInfo(display, 1 /* VisualInfoMask.ID */, ref info, out dummy);
|
||||
info = (XVisualInfo)Marshal.PtrToStructure(infoPtr, typeof(XVisualInfo));
|
||||
// get the XVisualInfo for this GraphicsMode
|
||||
XVisualInfo info = new XVisualInfo();
|
||||
info.VisualID = graphicsMode.Index.Value;
|
||||
int dummy;
|
||||
IntPtr infoPtr = XGetVisualInfo(display, 1 /* VisualInfoMask.ID */, ref info, out dummy);
|
||||
info = (XVisualInfo)Marshal.PtrToStructure(infoPtr, typeof(XVisualInfo));
|
||||
|
||||
// set the X11 colormap.
|
||||
SetStaticFieldValue(xplatui, "CustomVisual", info.Visual);
|
||||
SetStaticFieldValue(xplatui, "CustomColormap", XCreateColormap(display, rootWindow, info.Visual, 0));
|
||||
// set the X11 colormap.
|
||||
SetStaticFieldValue(xplatui, "CustomVisual", info.Visual);
|
||||
SetStaticFieldValue(xplatui, "CustomColormap", XCreateColormap(display, rootWindow, info.Visual, 0));
|
||||
|
||||
nativeWindowInfo = Utilities.CreateX11WindowInfo(display, screen, presentationParameters.DeviceWindowHandle, rootWindow, infoPtr);
|
||||
}
|
||||
else if (OpenTK.Configuration.RunningOnMacOS)
|
||||
{
|
||||
nativeWindowInfo = Utilities.CreateMacOSCarbonWindowInfo(presentationParameters.DeviceWindowHandle, false, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
nativeWindowInfo = Utilities.CreateX11WindowInfo(display, screen, presentationParameters.DeviceWindowHandle, rootWindow, infoPtr);
|
||||
}
|
||||
else if (OpenTK.Configuration.RunningOnMacOS)
|
||||
{
|
||||
nativeWindowInfo = Utilities.CreateMacOSCarbonWindowInfo(presentationParameters.DeviceWindowHandle, false, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
ResizeRenderWindow(presentationParameters);
|
||||
ResizeRenderWindow(presentationParameters);
|
||||
|
||||
nativeContext = new GraphicsContext(graphicsMode, nativeWindowInfo);
|
||||
nativeContext.MakeCurrent(nativeWindowInfo);
|
||||
@ -457,8 +460,7 @@ namespace ANX.Framework.Windows.GL3
|
||||
GL.BindBuffer(BufferTarget.ArrayBuffer,
|
||||
boundVertexBuffers[index].BufferHandle);
|
||||
ErrorHelper.Check("BindBuffer");
|
||||
boundVertexBuffers[index].MapVertexDeclaration(
|
||||
activeEffect.programHandle);
|
||||
boundVertexBuffers[index].MapVertexDeclaration(activeEffect);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
@ -476,42 +478,81 @@ namespace ANX.Framework.Windows.GL3
|
||||
}
|
||||
#endregion
|
||||
|
||||
private void ResizeRenderWindow(PresentationParameters presentationParameters)
|
||||
{
|
||||
if (OpenTK.Configuration.RunningOnWindows)
|
||||
{
|
||||
RECT windowRect;
|
||||
RECT clientRect;
|
||||
if (GetWindowRect(presentationParameters.DeviceWindowHandle, out windowRect) &&
|
||||
GetClientRect(presentationParameters.DeviceWindowHandle, out clientRect))
|
||||
{
|
||||
int width = presentationParameters.BackBufferWidth + ((windowRect.Right - windowRect.Left) - clientRect.Right);
|
||||
int height = presentationParameters.BackBufferHeight + ((windowRect.Bottom - windowRect.Top) - clientRect.Bottom);
|
||||
#region ResizeRenderWindow
|
||||
private void ResizeRenderWindow(
|
||||
PresentationParameters presentationParameters)
|
||||
{
|
||||
if (OpenTK.Configuration.RunningOnWindows)
|
||||
{
|
||||
RECT windowRect;
|
||||
RECT clientRect;
|
||||
if (GetWindowRect(presentationParameters.DeviceWindowHandle,
|
||||
out windowRect) &&
|
||||
GetClientRect(presentationParameters.DeviceWindowHandle,
|
||||
out clientRect))
|
||||
{
|
||||
int width = presentationParameters.BackBufferWidth +
|
||||
((windowRect.Right - windowRect.Left) - clientRect.Right);
|
||||
int height = presentationParameters.BackBufferHeight +
|
||||
((windowRect.Bottom - windowRect.Top) - clientRect.Bottom);
|
||||
|
||||
SetWindowPos(presentationParameters.DeviceWindowHandle, IntPtr.Zero, windowRect.Left, windowRect.Top, width, height, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
SetWindowPos(presentationParameters.DeviceWindowHandle, IntPtr.Zero,
|
||||
windowRect.Left, windowRect.Top, width, height, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
static object GetStaticFieldValue(Type type, string fieldName)
|
||||
{
|
||||
return type.GetField(fieldName,
|
||||
System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic).GetValue(null);
|
||||
}
|
||||
|
||||
static void SetStaticFieldValue(Type type, string fieldName, object value)
|
||||
{
|
||||
type.GetField(fieldName,
|
||||
System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic).SetValue(null, value);
|
||||
}
|
||||
#region GetStaticFieldValue
|
||||
static object GetStaticFieldValue(Type type, string fieldName)
|
||||
{
|
||||
return type.GetField(fieldName,
|
||||
BindingFlags.Static | BindingFlags.NonPublic).GetValue(null);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region SetStaticFieldValue
|
||||
static void SetStaticFieldValue(Type type, string fieldName, object value)
|
||||
{
|
||||
type.GetField(fieldName,
|
||||
System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic).SetValue(null, value);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region SetRenderTargets
|
||||
public void SetRenderTargets(params RenderTargetBinding[] renderTargets)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
if (renderTargets == null)
|
||||
{
|
||||
if (boundRenderTargets.Length > 0)
|
||||
{
|
||||
for (int index = 0; index < boundRenderTargets.Length; index++)
|
||||
{
|
||||
boundRenderTargets[index].Unbind();
|
||||
}
|
||||
boundRenderTargets = new RenderTarget2DGL3[0];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
boundRenderTargets = new RenderTarget2DGL3[renderTargets.Length];
|
||||
for (int index = 0; index < renderTargets.Length; index++)
|
||||
{
|
||||
RenderTarget2D renderTarget =
|
||||
renderTargets[index].RenderTarget as RenderTarget2D;
|
||||
RenderTarget2DGL3 nativeRenderTarget =
|
||||
renderTarget.NativeRenderTarget as RenderTarget2DGL3;
|
||||
boundRenderTargets[index] = nativeRenderTarget;
|
||||
|
||||
nativeRenderTarget.Bind();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region GetBackBufferData (TODO)
|
||||
public void GetBackBufferData<T>(Rectangle? rect, T[] data,
|
||||
int startIndex, int elementCount) where T : struct
|
||||
int startIndex, int elementCount) where T : struct
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
@ -521,22 +562,35 @@ namespace ANX.Framework.Windows.GL3
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void GetBackBufferData<T>(T[] data, int startIndex, int elementCount) where T : struct
|
||||
public void GetBackBufferData<T>(T[] data, int startIndex,
|
||||
int elementCount) where T : struct
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ResizeBuffers (TODO)
|
||||
public void ResizeBuffers(PresentationParameters presentationParameters)
|
||||
{
|
||||
ResizeRenderWindow(presentationParameters);
|
||||
ResizeRenderWindow(presentationParameters);
|
||||
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
#endregion
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
//TODO: implement
|
||||
}
|
||||
#region Dispose
|
||||
public void Dispose()
|
||||
{
|
||||
boundVertexBuffers = null;
|
||||
boundIndexBuffer = null;
|
||||
activeEffect = null;
|
||||
boundRenderTargets = null;
|
||||
|
||||
}
|
||||
nativeContext.Dispose();
|
||||
nativeContext = null;
|
||||
nativeWindowInfo.Dispose();
|
||||
nativeWindowInfo = null;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ using System.Runtime.InteropServices;
|
||||
// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
|
||||
// übernehmen, indem Sie "*" eingeben:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("0.5.8.0")]
|
||||
[assembly: AssemblyFileVersion("0.5.8.0")]
|
||||
[assembly: AssemblyVersion("0.5.9.0")]
|
||||
[assembly: AssemblyFileVersion("0.5.9.0")]
|
||||
|
||||
[assembly: InternalsVisibleTo("ANX.Framework.ContentPipeline")]
|
||||
|
@ -1,15 +1,142 @@
|
||||
using System;
|
||||
using ANX.Framework.NonXNA.RenderSystem;
|
||||
using ANX.Framework.Graphics;
|
||||
using ANX.Framework.NonXNA.RenderSystem;
|
||||
using OpenTK.Graphics.OpenGL;
|
||||
|
||||
namespace ANX.Framework.Windows.GL3
|
||||
{
|
||||
public class RenderTarget2DGL3 : INativeRenderTarget2D
|
||||
public class RenderTarget2DGL3 : Texture2DGL3, INativeRenderTarget2D
|
||||
{
|
||||
#region Private
|
||||
private int framebufferHandle;
|
||||
private int renderbufferHandle;
|
||||
|
||||
private bool generateMipmaps;
|
||||
#endregion
|
||||
|
||||
// TODO: usage, preferredMultiSampleCount
|
||||
#region Constructor
|
||||
public RenderTarget2DGL3(int width, int height, bool mipMap,
|
||||
SurfaceFormat preferredFormat, DepthFormat preferredDepthFormat,
|
||||
int preferredMultiSampleCount, RenderTargetUsage usage)
|
||||
{
|
||||
generateMipmaps = mipMap;
|
||||
PixelInternalFormat nativeFormat =
|
||||
DatatypesMapping.SurfaceToPixelInternalFormat(preferredFormat);
|
||||
|
||||
#region Image creation
|
||||
NativeHandle = GL.GenTexture();
|
||||
GL.BindTexture(TextureTarget.Texture2D, NativeHandle);
|
||||
GL.TexParameter(TextureTarget.Texture2D,
|
||||
TextureParameterName.TextureMagFilter, (int)All.Linear);
|
||||
GL.TexParameter(TextureTarget.Texture2D,
|
||||
TextureParameterName.TextureWrapS, (int)All.ClampToEdge);
|
||||
GL.TexParameter(TextureTarget.Texture2D,
|
||||
TextureParameterName.TextureWrapT, (int)All.ClampToEdge);
|
||||
if (generateMipmaps)
|
||||
{
|
||||
GL.TexParameter(TextureTarget.Texture2D,
|
||||
TextureParameterName.GenerateMipmap, 1);
|
||||
GL.TexParameter(TextureTarget.Texture2D,
|
||||
TextureParameterName.TextureMinFilter, (int)All.LinearMipmapLinear);
|
||||
}
|
||||
else
|
||||
{
|
||||
GL.TexParameter(TextureTarget.Texture2D,
|
||||
TextureParameterName.TextureMinFilter, (int)All.Linear);
|
||||
}
|
||||
|
||||
GL.TexImage2D(TextureTarget.Texture2D, 0, nativeFormat,
|
||||
width, height, 0, (PixelFormat)nativeFormat, PixelType.UnsignedByte,
|
||||
IntPtr.Zero);
|
||||
GL.BindTexture(TextureTarget.Texture2D, 0);
|
||||
#endregion
|
||||
|
||||
// create a renderbuffer object to store depth info
|
||||
GL.GenRenderbuffers(1, out renderbufferHandle);
|
||||
GL.BindRenderbuffer(RenderbufferTarget.Renderbuffer, renderbufferHandle);
|
||||
GL.RenderbufferStorage(RenderbufferTarget.Renderbuffer,
|
||||
DepthFormatConversion(preferredDepthFormat), width, height);
|
||||
GL.BindRenderbuffer(RenderbufferTarget.RenderbufferExt, 0);
|
||||
|
||||
// create a framebuffer object
|
||||
GL.GenFramebuffers(1, out framebufferHandle);
|
||||
GL.BindFramebuffer(FramebufferTarget.Framebuffer, framebufferHandle);
|
||||
|
||||
// attach the texture to FBO color attachment point
|
||||
GL.FramebufferTexture2D(FramebufferTarget.Framebuffer,
|
||||
FramebufferAttachment.ColorAttachment0, TextureTarget.Texture2D,
|
||||
NativeHandle, 0);
|
||||
|
||||
// attach the renderbuffer to depth attachment point
|
||||
GL.FramebufferRenderbuffer(FramebufferTarget.Framebuffer,
|
||||
FramebufferAttachment.DepthAttachment,
|
||||
RenderbufferTarget.Renderbuffer, renderbufferHandle);
|
||||
|
||||
// check FBO status
|
||||
FramebufferErrorCode status = GL.CheckFramebufferStatus(
|
||||
FramebufferTarget.Framebuffer);
|
||||
if (status != FramebufferErrorCode.FramebufferComplete)
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
"Failed to create the render target! Error=" + status);
|
||||
}
|
||||
|
||||
// switch back to window-system-provided framebuffer
|
||||
GL.BindFramebuffer(FramebufferTarget.Framebuffer, 0);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region DepthFormatConversion
|
||||
private RenderbufferStorage DepthFormatConversion(DepthFormat depthFormat)
|
||||
{
|
||||
switch(depthFormat)
|
||||
{
|
||||
default:
|
||||
case DepthFormat.None:
|
||||
// TODO
|
||||
return RenderbufferStorage.DepthComponent16;
|
||||
//return (RenderbufferStorage)All.DepthComponent;
|
||||
|
||||
case DepthFormat.Depth16:
|
||||
return RenderbufferStorage.DepthComponent16;
|
||||
|
||||
case DepthFormat.Depth24:
|
||||
return RenderbufferStorage.DepthComponent24;
|
||||
|
||||
case DepthFormat.Depth24Stencil8:
|
||||
return RenderbufferStorage.DepthComponent32;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Bind
|
||||
public void Bind()
|
||||
{
|
||||
GL.BindFramebuffer(FramebufferTarget.Framebuffer, framebufferHandle);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Unbind
|
||||
public void Unbind()
|
||||
{
|
||||
GL.BindFramebuffer(FramebufferTarget.Framebuffer, 0);
|
||||
if (generateMipmaps)
|
||||
{
|
||||
GL.BindTexture(TextureTarget.Texture2D, NativeHandle);
|
||||
GL.GenerateMipmap(GenerateMipmapTarget.Texture2D);
|
||||
GL.BindTexture(TextureTarget.Texture2D, 0);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Dispose
|
||||
public override void Dispose()
|
||||
{
|
||||
base.Dispose();
|
||||
GL.DeleteFramebuffers(1, ref framebufferHandle);
|
||||
GL.DeleteRenderbuffers(1, ref renderbufferHandle);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ namespace ANX.Framework.Windows.GL3
|
||||
#region SpriteBatchShader
|
||||
internal static byte[] SpriteBatchByteCode = new byte[]
|
||||
{
|
||||
160,
|
||||
186,
|
||||
003, 117, 110, 105, 102, 111, 114, 109, 032, 109, 097, 116, 052, 032, 077, 097, 116, 114, 105, 120,
|
||||
084, 114, 097, 110, 115, 102, 111, 114, 109, 059, 010, 097, 116, 116, 114, 105, 098, 117, 116, 101,
|
||||
032, 118, 101, 099, 052, 032, 112, 111, 115, 059, 010, 097, 116, 116, 114, 105, 098, 117, 116, 101,
|
||||
@ -67,19 +67,20 @@ namespace ANX.Framework.Windows.GL3
|
||||
114, 105, 120, 084, 114, 097, 110, 115, 102, 111, 114, 109, 042, 112, 111, 115, 059, 010, 100, 105,
|
||||
102, 102, 117, 115, 101, 084, 101, 120, 067, 111, 111, 114, 100, 061, 116, 101, 120, 059, 010, 100,
|
||||
105, 102, 102, 117, 115, 101, 067, 111, 108, 111, 114, 061, 099, 111, 108, 059, 125, 010, 035, 035,
|
||||
033, 102, 114, 097, 103, 109, 101, 110, 116, 033, 035, 035, 010, 117, 110, 105, 102, 111, 114, 109,
|
||||
032, 115, 097, 109, 112, 108, 101, 114, 050, 068, 032, 084, 101, 120, 116, 117, 114, 101, 059, 010,
|
||||
118, 097, 114, 121, 105, 110, 103, 032, 118, 101, 099, 052, 032, 100, 105, 102, 102, 117, 115, 101,
|
||||
067, 111, 108, 111, 114, 059, 010, 118, 097, 114, 121, 105, 110, 103, 032, 118, 101, 099, 050, 032,
|
||||
100, 105, 102, 102, 117, 115, 101, 084, 101, 120, 067, 111, 111, 114, 100, 059, 010, 118, 111, 105,
|
||||
100, 032, 109, 097, 105, 110, 040, 118, 111, 105, 100, 041, 123, 010, 103, 108, 095, 070, 114, 097,
|
||||
103, 067, 111, 108, 111, 114, 061, 116, 101, 120, 116, 117, 114, 101, 050, 068, 040, 084, 101, 120,
|
||||
116, 117, 114, 101, 044, 100, 105, 102, 102, 117, 115, 101, 084, 101, 120, 067, 111, 111, 114, 100,
|
||||
041, 042, 100, 105, 102, 102, 117, 115, 101, 067, 111, 108, 111, 114, 059, 125, 010, 095, 046, 094,
|
||||
078, 240, 054, 006, 106, 005, 190, 104, 250, 201, 129, 166, 050, 199, 249, 189, 159, 008, 207, 084,
|
||||
062, 171, 010, 076, 101, 119, 047, 079, 245, 134, 024, 149, 110, 166, 213, 153, 023, 179, 120, 191,
|
||||
146, 106, 047, 180, 084, 037, 088, 036, 132, 126, 030, 027, 054, 044, 236, 120, 086, 102, 211, 178,
|
||||
125
|
||||
033, 102, 114, 097, 103, 109, 101, 110, 116, 033, 035, 035, 010, 112, 114, 101, 099, 105, 115, 115,
|
||||
105, 111, 110, 032, 109, 101, 100, 105, 117, 109, 112, 032, 102, 108, 111, 097, 116, 059, 010, 117,
|
||||
110, 105, 102, 111, 114, 109, 032, 115, 097, 109, 112, 108, 101, 114, 050, 068, 032, 084, 101, 120,
|
||||
116, 117, 114, 101, 059, 010, 118, 097, 114, 121, 105, 110, 103, 032, 118, 101, 099, 052, 032, 100,
|
||||
105, 102, 102, 117, 115, 101, 067, 111, 108, 111, 114, 059, 010, 118, 097, 114, 121, 105, 110, 103,
|
||||
032, 118, 101, 099, 050, 032, 100, 105, 102, 102, 117, 115, 101, 084, 101, 120, 067, 111, 111, 114,
|
||||
100, 059, 010, 118, 111, 105, 100, 032, 109, 097, 105, 110, 040, 118, 111, 105, 100, 041, 123, 010,
|
||||
103, 108, 095, 070, 114, 097, 103, 067, 111, 108, 111, 114, 061, 116, 101, 120, 116, 117, 114, 101,
|
||||
050, 068, 040, 084, 101, 120, 116, 117, 114, 101, 044, 100, 105, 102, 102, 117, 115, 101, 084, 101,
|
||||
120, 067, 111, 111, 114, 100, 041, 042, 100, 105, 102, 102, 117, 115, 101, 067, 111, 108, 111, 114,
|
||||
059, 125, 010, 204, 002, 066, 009, 044, 094, 101, 149, 163, 197, 203, 229, 083, 172, 100, 007, 002,
|
||||
181, 147, 172, 186, 193, 103, 068, 009, 005, 065, 152, 020, 077, 034, 207, 124, 030, 210, 046, 182,
|
||||
155, 204, 156, 086, 170, 100, 065, 083, 209, 239, 206, 226, 075, 115, 157, 118, 160, 025, 101, 098,
|
||||
159, 062, 171, 094, 128, 095, 188
|
||||
};
|
||||
#endregion //SpriteBatchShader
|
||||
|
||||
|
@ -89,14 +89,18 @@ namespace ANX.Framework.Windows.GL3
|
||||
/// <summary>
|
||||
/// The OpenGL texture handle.
|
||||
/// </summary>
|
||||
internal int NativeHandle
|
||||
protected internal int NativeHandle
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
protected set;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Constructor
|
||||
internal Texture2DGL3()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a new native OpenGL texture.
|
||||
/// </summary>
|
||||
@ -165,6 +169,11 @@ namespace ANX.Framework.Windows.GL3
|
||||
"Loading mipmaps is not correctly implemented yet!");
|
||||
}
|
||||
|
||||
GL.BindTexture(TextureTarget.Texture2D, NativeHandle);
|
||||
#if DEBUG
|
||||
ErrorHelper.Check("BindTexture");
|
||||
#endif
|
||||
|
||||
GCHandle handle = GCHandle.Alloc(data, GCHandleType.Pinned);
|
||||
|
||||
// TODO: get size of first mipmap!
|
||||
@ -235,7 +244,7 @@ namespace ANX.Framework.Windows.GL3
|
||||
/// <summary>
|
||||
/// Dispose the native OpenGL texture handle.
|
||||
/// </summary>
|
||||
public void Dispose()
|
||||
public virtual void Dispose()
|
||||
{
|
||||
GL.DeleteTexture(NativeHandle);
|
||||
#if DEBUG
|
||||
|
@ -178,67 +178,54 @@ namespace ANX.Framework.Windows.GL3
|
||||
#endregion
|
||||
|
||||
#region MapVertexDeclaration
|
||||
internal void MapVertexDeclaration(int programHandle)
|
||||
{
|
||||
int attributes;
|
||||
GL.GetProgram(programHandle, ProgramParameter.ActiveAttributes,
|
||||
out attributes);
|
||||
|
||||
internal void MapVertexDeclaration(EffectGL3 effect)
|
||||
{
|
||||
VertexElement[] elements = vertexDeclaration.GetVertexElements();
|
||||
if (elements.Length != attributes)
|
||||
if (elements.Length != effect.ActiveAttributes.Count)
|
||||
{
|
||||
throw new InvalidOperationException("Mapping the VertexDeclaration " +
|
||||
"onto the glsl attributes failed because we have " +
|
||||
attributes + " Shader Attributes and " + elements.Length +
|
||||
" elements in the vertex declaration which doesn't fit!");
|
||||
effect.ActiveAttributes.Count + " Shader Attributes and " +
|
||||
elements.Length + " elements in the vertex declaration which " +
|
||||
"doesn't fit!");
|
||||
}
|
||||
|
||||
foreach (VertexElement element in elements)
|
||||
foreach (string key in effect.ActiveAttributes.Keys)
|
||||
{
|
||||
// TODO: element.UsageIndex?
|
||||
EffectGL3.ShaderAttribute attribute = effect.ActiveAttributes[key];
|
||||
GL.EnableVertexAttribArray(attribute.Location);
|
||||
VertexElement element = elements[(int)attribute.Location];
|
||||
|
||||
switch (element.VertexElementUsage)
|
||||
{
|
||||
case VertexElementUsage.Binormal:
|
||||
case VertexElementUsage.Normal:
|
||||
case VertexElementUsage.Tangent:
|
||||
case VertexElementUsage.BlendIndices:
|
||||
case VertexElementUsage.BlendWeight:
|
||||
case VertexElementUsage.Position:
|
||||
int loc = GL.GetAttribLocation(programHandle, "pos");
|
||||
ErrorHelper.Check("GetAttribLocation pos");
|
||||
GL.EnableVertexAttribArray(loc);
|
||||
ErrorHelper.Check("EnableVertexAttribArray pos");
|
||||
GL.VertexAttribPointer(loc, 3, VertexAttribPointerType.Float,
|
||||
false, vertexDeclaration.VertexStride, element.Offset);
|
||||
ErrorHelper.Check("VertexAttribPointer pos");
|
||||
GL.VertexAttribPointer((int)attribute.Location, 3,
|
||||
VertexAttribPointerType.Float, false,
|
||||
vertexDeclaration.VertexStride, element.Offset);
|
||||
break;
|
||||
|
||||
case VertexElementUsage.Color:
|
||||
int col = GL.GetAttribLocation(programHandle, "col");
|
||||
ErrorHelper.Check("GetAttribLocation col");
|
||||
GL.EnableVertexAttribArray(col);
|
||||
ErrorHelper.Check("EnableVertexAttribArray col");
|
||||
GL.VertexAttribPointer(col, 4, VertexAttribPointerType.UnsignedByte,
|
||||
true, vertexDeclaration.VertexStride, element.Offset);
|
||||
ErrorHelper.Check("VertexAttribPointer col");
|
||||
GL.VertexAttribPointer((int)attribute.Location, 4,
|
||||
VertexAttribPointerType.UnsignedByte,
|
||||
true, vertexDeclaration.VertexStride, element.Offset);
|
||||
break;
|
||||
|
||||
case VertexElementUsage.TextureCoordinate:
|
||||
int tex = GL.GetAttribLocation(programHandle, "tex");
|
||||
ErrorHelper.Check("GetAttribLocation tex");
|
||||
GL.EnableVertexAttribArray(tex);
|
||||
ErrorHelper.Check("EnableVertexAttribArray tex");
|
||||
GL.VertexAttribPointer(tex, 2, VertexAttribPointerType.Float,
|
||||
false, vertexDeclaration.VertexStride, element.Offset);
|
||||
ErrorHelper.Check("VertexAttribPointer tex");
|
||||
GL.VertexAttribPointer((int)attribute.Location, 2,
|
||||
VertexAttribPointerType.Float, false,
|
||||
vertexDeclaration.VertexStride, element.Offset);
|
||||
break;
|
||||
|
||||
// TODO
|
||||
case VertexElementUsage.Binormal:
|
||||
case VertexElementUsage.BlendIndices:
|
||||
case VertexElementUsage.BlendWeight:
|
||||
case VertexElementUsage.Depth:
|
||||
case VertexElementUsage.Fog:
|
||||
case VertexElementUsage.Normal:
|
||||
case VertexElementUsage.PointSize:
|
||||
case VertexElementUsage.Sample:
|
||||
case VertexElementUsage.Tangent:
|
||||
case VertexElementUsage.TessellateFactor:
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using ANX.Framework.NonXNA;
|
||||
|
||||
namespace RenderTarget
|
||||
{
|
||||
@ -9,7 +10,8 @@ namespace RenderTarget
|
||||
/// Der Haupteinstiegspunkt für die Anwendung.
|
||||
/// </summary>
|
||||
static void Main(string[] args)
|
||||
{
|
||||
{
|
||||
//AddInSystemFactory.Instance.PreferredRenderSystem = "OpenGL3";
|
||||
using (Game1 game = new Game1())
|
||||
{
|
||||
game.Run();
|
||||
|
@ -91,6 +91,10 @@
|
||||
<Project>{5BE49183-2F6F-4527-AC90-D816911FCF90}</Project>
|
||||
<Name>ANX.Framework.Windows.DX10</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\RenderSystems\ANX.Framework.Windows.GL3\ANX.Framework.Windows.GL3.csproj">
|
||||
<Project>{EB8258E0-6741-4DB9-B756-1EBDF67B1ED6}</Project>
|
||||
<Name>ANX.Framework.Windows.GL3</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\SoundSystems\ANX.SoundSystem.Windows.XAudio\ANX.SoundSystem.Windows.XAudio.csproj">
|
||||
<Project>{6A582788-C4D2-410C-96CD-177F75712D65}</Project>
|
||||
<Name>ANX.SoundSystem.Windows.XAudio</Name>
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using ANX.Framework.NonXNA;
|
||||
|
||||
namespace WindowsGame1
|
||||
{
|
||||
@ -10,6 +11,7 @@ namespace WindowsGame1
|
||||
/// </summary>
|
||||
static void Main(string[] args)
|
||||
{
|
||||
//AddInSystemFactory.Instance.PreferredRenderSystem = "OpenGL3";
|
||||
using (Game1 game = new Game1())
|
||||
{
|
||||
game.Run();
|
||||
|
@ -53,7 +53,7 @@ attribute vec2 tex;
|
||||
|
||||
varying vec4 diffuseColor;
|
||||
varying vec2 diffuseTexCoord;
|
||||
void main(void)
|
||||
void main( )
|
||||
{
|
||||
gl_Position = MatrixTransform * pos;
|
||||
diffuseTexCoord = tex;
|
||||
@ -66,11 +66,13 @@ void main(void)
|
||||
// Fragment Shader
|
||||
//
|
||||
|
||||
precission mediump float;
|
||||
|
||||
uniform sampler2D Texture;
|
||||
|
||||
varying vec4 diffuseColor;
|
||||
varying vec2 diffuseTexCoord;
|
||||
void main(void)
|
||||
void main( )
|
||||
{
|
||||
gl_FragColor = texture2D(Texture, diffuseTexCoord) * diffuseColor;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user