Thread: [Agate-svn-commit] SF.net SVN: agate:[923] branches/agate3d-3.2
Status: Alpha
Brought to you by:
kanato
|
From: <ka...@us...> - 2009-04-28 01:08:39
|
Revision: 923
http://agate.svn.sourceforge.net/agate/?rev=923&view=rev
Author: kanato
Date: 2009-04-28 01:08:32 +0000 (Tue, 28 Apr 2009)
Log Message:
-----------
Initial commit of merging agate-3d branch.
Modified Paths:
--------------
branches/agate3d-3.2/AgateLib/AgateException.cs
branches/agate3d-3.2/AgateLib/DisplayLib/Display.cs
branches/agate3d-3.2/AgateLib/DisplayLib/PixelBuffer.cs
branches/agate3d-3.2/AgateLib/Drivers/IDesktopDriver.cs
branches/agate3d-3.2/AgateLib/Geometry/Builders/Cube.cs
branches/agate3d-3.2/AgateLib/Geometry/Color.cs
branches/agate3d-3.2/AgateLib/Geometry/Rectangle.cs
branches/agate3d-3.2/AgateLib/Geometry/RectangleF.cs
branches/agate3d-3.2/AgateLib/Geometry/Vector3.cs
branches/agate3d-3.2/AgateLib/ImplementationBase/DisplayImpl.cs
branches/agate3d-3.2/AgateLib/ImplementationBase/IDisplayCaps.cs
branches/agate3d-3.2/AgateLib/InputLib/Mouse.cs
branches/agate3d-3.2/AgateLib/Resources/AgateResourceCollection.cs
branches/agate3d-3.2/AgateLib/Resources/AgateResourceException.cs
branches/agate3d-3.2/AgateLib/Resources/AgateResourceLoader.cs
branches/agate3d-3.2/Build/monodevelop.sh
branches/agate3d-3.2/Drivers/AgateDrawing/Drawing_Display.cs
branches/agate3d-3.2/Drivers/AgateLib.WinForms/Icons.Designer.cs
branches/agate3d-3.2/Drivers/AgateMDX/DrawBuffer.cs
branches/agate3d-3.2/Drivers/AgateMDX/MDX1_Display.cs
branches/agate3d-3.2/Drivers/AgateOTK/GL_Display.cs
branches/agate3d-3.2/Drivers/AgateOTK/GL_GameWindow.cs
branches/agate3d-3.2/Drivers/AgateOTK/GL_Surface.cs
branches/agate3d-3.2/Drivers/AgateOTK/OpenTK.Utilities.dll
branches/agate3d-3.2/Drivers/AgateOTK/OpenTK.dll
branches/agate3d-3.2/Drivers/AgateOTK/OpenTK.xml
branches/agate3d-3.2/Drivers/AgateOTK/Otk_Reporter.cs
branches/agate3d-3.2/Drivers/AgateSDL/Reporter.cs
Added Paths:
-----------
branches/agate3d-3.2/AgateLib/DisplayLib/PrimitiveType.cs
branches/agate3d-3.2/AgateLib/DisplayLib/Shaders/
branches/agate3d-3.2/AgateLib/DisplayLib/Shaders/PixelShader.cs
branches/agate3d-3.2/AgateLib/DisplayLib/Shaders/ShaderCompiler.cs
branches/agate3d-3.2/AgateLib/DisplayLib/Shaders/ShaderLanguage.cs
branches/agate3d-3.2/AgateLib/DisplayLib/Shaders/ShaderProgram.cs
branches/agate3d-3.2/AgateLib/DisplayLib/Shaders/VertexShader.cs
branches/agate3d-3.2/AgateLib/DisplayLib/VertexBuffer.cs
branches/agate3d-3.2/AgateLib/Geometry/Builders/
branches/agate3d-3.2/AgateLib/Geometry/Builders/Terrain.cs
branches/agate3d-3.2/AgateLib/Geometry/Matrix4.cs
branches/agate3d-3.2/AgateLib/Geometry/Vector4.cs
branches/agate3d-3.2/AgateLib/ImplementationBase/ShaderCompilerImpl.cs
branches/agate3d-3.2/AgateLib/ImplementationBase/VertexBufferImpl.cs
branches/agate3d-3.2/AgateLib/Meshes/
branches/agate3d-3.2/AgateLib/Meshes/Loaders/
branches/agate3d-3.2/AgateLib/Meshes/Loaders/Obj/
branches/agate3d-3.2/AgateLib/Meshes/Loaders/Obj/OBJFileRepresentation.cs
branches/agate3d-3.2/AgateLib/Meshes/Loaders/Obj/Parser.cs
branches/agate3d-3.2/AgateLib/Meshes/Loaders/Obj/TokenTypes.cs
branches/agate3d-3.2/Drivers/AgateMDX/MDX1_VertexBuffer.cs
branches/agate3d-3.2/Drivers/AgateOTK/ArbShader.cs
branches/agate3d-3.2/Drivers/AgateOTK/GL_VertexBuffer.cs
branches/agate3d-3.2/Drivers/AgateOTK/GlslFragmentProgram.cs
branches/agate3d-3.2/Drivers/AgateOTK/GlslShader.cs
branches/agate3d-3.2/Drivers/AgateOTK/GlslShaderCompiler.cs
branches/agate3d-3.2/Drivers/AgateOTK/GlslVertexProgram.cs
branches/agate3d-3.2/Drivers/AgateOTK/OtkShader.cs
branches/agate3d-3.2/Tests/Display3D/
branches/agate3d-3.2/Tests/Display3D/Glsl.cs
branches/agate3d-3.2/Tests/Display3D/Matrices.cs
branches/agate3d-3.2/Tests/Display3D/Test3d.cs
Removed Paths:
-------------
branches/agate3d-3.2/AgateLib/DisplayLib/Shaders/PixelShader.cs
branches/agate3d-3.2/AgateLib/DisplayLib/Shaders/ShaderCompiler.cs
branches/agate3d-3.2/AgateLib/DisplayLib/Shaders/ShaderLanguage.cs
branches/agate3d-3.2/AgateLib/DisplayLib/Shaders/ShaderProgram.cs
branches/agate3d-3.2/AgateLib/DisplayLib/Shaders/VertexShader.cs
branches/agate3d-3.2/AgateLib/Meshes/Loaders/
branches/agate3d-3.2/AgateLib/Meshes/Loaders/Obj/OBJFileRepresentation.cs
branches/agate3d-3.2/AgateLib/Meshes/Loaders/Obj/Parser.cs
branches/agate3d-3.2/AgateLib/Meshes/Loaders/Obj/TokenTypes.cs
Property Changed:
----------------
branches/agate3d-3.2/
branches/agate3d-3.2/AgateLib/
branches/agate3d-3.2/AgateLib/AgateSetup.cs
branches/agate3d-3.2/AgateLib/AudioLib/
branches/agate3d-3.2/AgateLib/AudioLib/Audio.cs
branches/agate3d-3.2/AgateLib/BitmapFont/FontMetrics.cs
branches/agate3d-3.2/AgateLib/BitmapFont/GlyphMetrics.cs
branches/agate3d-3.2/AgateLib/Core.cs
branches/agate3d-3.2/AgateLib/DisplayLib/
branches/agate3d-3.2/AgateLib/DisplayLib/Display.cs
branches/agate3d-3.2/AgateLib/DisplayLib/StringTransformer.cs
branches/agate3d-3.2/AgateLib/Drivers/AgateDriverReporter.cs
branches/agate3d-3.2/AgateLib/Drivers/IDesktopDriver.cs
branches/agate3d-3.2/AgateLib/ImplementationBase/
branches/agate3d-3.2/AgateLib/ImplementationBase/AudioImpl.cs
branches/agate3d-3.2/AgateLib/InputLib/
branches/agate3d-3.2/AgateLib/Resources/AgateResourceCollection.cs
branches/agate3d-3.2/AgateLib/Resources/AgateResourceLoader.cs
branches/agate3d-3.2/AgateLib/Resources/BitmapFontResource.cs
branches/agate3d-3.2/AgateLib/Timing.cs
branches/agate3d-3.2/AgateLib/Utility/Platform.cs
branches/agate3d-3.2/Build/monodevelop.sh
branches/agate3d-3.2/Drivers/
branches/agate3d-3.2/Drivers/AgateDrawing/Drawing_Reporter.cs
branches/agate3d-3.2/Drivers/AgateLib.WinForms/
branches/agate3d-3.2/Drivers/AgateSDL/
branches/agate3d-3.2/Drivers/AgateSDL/Audio/SDL_Audio.cs
branches/agate3d-3.2/Drivers/AgateSDL/Audio/SDL_Music.cs
branches/agate3d-3.2/Drivers/AgateSDL/Audio/SDL_SoundBuffer.cs
branches/agate3d-3.2/Drivers/AgateSDL/Audio/SDL_SoundBufferSession.cs
branches/agate3d-3.2/Drivers/AgateSDL/Reporter.cs
branches/agate3d-3.2/Examples/BallBuster.Net/OpenTK.dll.config
branches/agate3d-3.2/Tools/FontCreator/SaveFont.Designer.cs
branches/agate3d-3.2/Tools/FontCreator/SaveFont.cs
branches/agate3d-3.2/Tools/FontCreator/SaveFont.resx
branches/agate3d-3.2/Tools/FontCreator/frmFontCreator.Designer.cs
branches/agate3d-3.2/Tools/FontCreator/frmFontCreator.cs
branches/agate3d-3.2/Tools/FontCreator/frmFontCreator.resx
branches/agate3d-3.2/Tools/PackedSpriteCreator/SpriteEditor.Designer.cs
branches/agate3d-3.2/Tools/PackedSpriteCreator/SpriteEditor.cs
branches/agate3d-3.2/Tools/PackedSpriteCreator/SpriteEditor.resx
branches/agate3d-3.2/Tools/PackedSpriteCreator/SpritePacker.cs
Property changes on: branches/agate3d-3.2
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/agate-3d:659
/branches/build:424-517
/branches/font:778-916
/branches/merge-tests:806-810
/branches/registrar:595-599
/branches/sprites:463-513
+ /branches/agate-3d:629-702,840-864
/branches/build:424-517
/branches/font:778-916
/branches/merge-tests:806-810
/branches/registrar:595-599
/branches/sprites:463-513
Property changes on: branches/agate3d-3.2/AgateLib
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/agate-3d/AgateLib:659
/branches/build/AgateLib:447-517
/branches/font/AgateLib:778-916
/branches/merge-tests/AgateLib:806-810
/branches/registrar/AgateLib:595-599
/branches/sprites/AgateLib:463-513
+ /branches/agate-3d/AgateLib:629-702,840-864
/branches/build/AgateLib:447-517
/branches/font/AgateLib:778-916
/branches/merge-tests/AgateLib:806-810
/branches/registrar/AgateLib:595-599
/branches/sprites/AgateLib:463-513
Modified: branches/agate3d-3.2/AgateLib/AgateException.cs
===================================================================
--- branches/agate3d-3.2/AgateLib/AgateException.cs 2009-04-27 05:52:15 UTC (rev 922)
+++ branches/agate3d-3.2/AgateLib/AgateException.cs 2009-04-28 01:08:32 UTC (rev 923)
@@ -46,10 +46,21 @@
/// <summary>
/// Constructs an AgateException.
/// </summary>
- public AgateException(string message, Exception inner) : base(message, inner) { }
+ public AgateException(Exception inner, string message) : base(message, inner) { }
/// <summary>
+ /// Constructs an AgateException, calling string.Format on the arguments.
+ /// </summary>
+ public AgateException(string format, params object[] args)
+ : base(string.Format(format, args)) { }
+ /// <summary>
/// Constructs an AgateException.
/// </summary>
+ public AgateException(Exception inner, string format, params object[] args)
+ : base(string.Format(format, args), inner) { }
+
+ /// <summary>
+ /// Deserializes an AgateException.
+ /// </summary>
protected AgateException(
System.Runtime.Serialization.SerializationInfo info,
System.Runtime.Serialization.StreamingContext context)
@@ -93,4 +104,4 @@
System.Runtime.Serialization.StreamingContext context)
: base(info, context) { }
}
-}
+}
\ No newline at end of file
Property changes on: branches/agate3d-3.2/AgateLib/AgateSetup.cs
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/agate-3d/AgateLib/AgateSetup.cs:659
/branches/build/AgateLib/AgateSetup.cs:501-517
/branches/font/AgateLib/AgateSetup.cs:778-916
/branches/merge-tests/AgateLib/AgateSetup.cs:806-810
/branches/registrar/AgateLib/AgateSetup.cs:595-599
/branches/sprites/AgateLib/AgateSetup.cs:463-513
+ /branches/agate-3d/AgateLib/AgateSetup.cs:629-702,840-864
/branches/build/AgateLib/AgateSetup.cs:501-517
/branches/font/AgateLib/AgateSetup.cs:778-916
/branches/merge-tests/AgateLib/AgateSetup.cs:806-810
/branches/registrar/AgateLib/AgateSetup.cs:595-599
/branches/sprites/AgateLib/AgateSetup.cs:463-513
Property changes on: branches/agate3d-3.2/AgateLib/AudioLib
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/agate-3d/AgateLib/AudioLib:659
/branches/font/AgateLib/AudioLib:778-916
/branches/merge-tests/AgateLib/AudioLib:806-810
/branches/registrar/AgateLib/AudioLib:595-599
/branches/sprites/AgateLib/AudioLib:463-513
+ /branches/agate-3d/AgateLib/AudioLib:629-702,840-864
/branches/font/AgateLib/AudioLib:778-916
/branches/merge-tests/AgateLib/AudioLib:806-810
/branches/registrar/AgateLib/AudioLib:595-599
/branches/sprites/AgateLib/AudioLib:463-513
Property changes on: branches/agate3d-3.2/AgateLib/AudioLib/Audio.cs
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/agate-3d/AgateLib/AudioLib/Audio.cs:659
/branches/build/AgateLib/AudioLib/Audio.cs:501-517
/branches/font/AgateLib/AudioLib/Audio.cs:778-916
/branches/merge-tests/AgateLib/AudioLib/Audio.cs:806-810
/branches/registrar/AgateLib/AudioLib/Audio.cs:595-599
/branches/sprites/AgateLib/AudioLib/Audio.cs:463-513
+ /branches/agate-3d/AgateLib/AudioLib/Audio.cs:629-702,840-864
/branches/build/AgateLib/AudioLib/Audio.cs:501-517
/branches/font/AgateLib/AudioLib/Audio.cs:778-916
/branches/merge-tests/AgateLib/AudioLib/Audio.cs:806-810
/branches/registrar/AgateLib/AudioLib/Audio.cs:595-599
/branches/sprites/AgateLib/AudioLib/Audio.cs:463-513
Property changes on: branches/agate3d-3.2/AgateLib/BitmapFont/FontMetrics.cs
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/agate-3d/AgateLib/BitmapFont/FontMetrics.cs:659
/branches/font/AgateLib/BitmapFont/FontMetrics.cs:778-916
/branches/merge-tests/AgateLib/BitmapFont/FontMetrics.cs:806-810
+ /branches/agate-3d/AgateLib/BitmapFont/FontMetrics.cs:629-702,840-864
/branches/font/AgateLib/BitmapFont/FontMetrics.cs:778-916
/branches/merge-tests/AgateLib/BitmapFont/FontMetrics.cs:806-810
Property changes on: branches/agate3d-3.2/AgateLib/BitmapFont/GlyphMetrics.cs
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/agate-3d/AgateLib/BitmapFont/GlyphMetrics.cs:659
/branches/build/AgateLib/Resources/GlyphMetrics.cs:447-517
/branches/font/AgateLib/BitmapFont/GlyphMetrics.cs:778-916
/branches/merge-tests/AgateLib/BitmapFont/GlyphMetrics.cs:806-810
/branches/registrar/AgateLib/Resources/GlyphMetrics.cs:595-599
/branches/sprites/AgateLib/Resources/GlyphMetrics.cs:463-513
+ /branches/agate-3d/AgateLib/BitmapFont/GlyphMetrics.cs:629-702,840-864
/branches/build/AgateLib/Resources/GlyphMetrics.cs:447-517
/branches/font/AgateLib/BitmapFont/GlyphMetrics.cs:778-916
/branches/merge-tests/AgateLib/BitmapFont/GlyphMetrics.cs:806-810
/branches/registrar/AgateLib/Resources/GlyphMetrics.cs:595-599
/branches/sprites/AgateLib/Resources/GlyphMetrics.cs:463-513
Property changes on: branches/agate3d-3.2/AgateLib/Core.cs
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/agate-3d/AgateLib/Core.cs:659
/branches/build/AgateLib/Core.cs:501-517
/branches/font/AgateLib/Core.cs:778-916
/branches/merge-tests/AgateLib/Core.cs:806-810
/branches/registrar/AgateLib/Core.cs:595-599
/branches/sprites/AgateLib/Core.cs:463-513
+ /branches/agate-3d/AgateLib/Core.cs:629-702,840-864
/branches/build/AgateLib/Core.cs:501-517
/branches/font/AgateLib/Core.cs:778-916
/branches/merge-tests/AgateLib/Core.cs:806-810
/branches/registrar/AgateLib/Core.cs:595-599
/branches/sprites/AgateLib/Core.cs:463-513
Property changes on: branches/agate3d-3.2/AgateLib/DisplayLib
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/agate-3d/AgateLib/DisplayLib:659
/branches/font/AgateLib/DisplayLib:778-916
/branches/merge-tests/AgateLib/DisplayLib:806-810
/branches/registrar/AgateLib/DisplayLib:595-599
/branches/sprites/AgateLib/DisplayLib:463-513
+ /branches/agate-3d/AgateLib/DisplayLib:629-702,840-864
/branches/font/AgateLib/DisplayLib:778-916
/branches/merge-tests/AgateLib/DisplayLib:806-810
/branches/registrar/AgateLib/DisplayLib:595-599
/branches/sprites/AgateLib/DisplayLib:463-513
Modified: branches/agate3d-3.2/AgateLib/DisplayLib/Display.cs
===================================================================
--- branches/agate3d-3.2/AgateLib/DisplayLib/Display.cs 2009-04-27 05:52:15 UTC (rev 922)
+++ branches/agate3d-3.2/AgateLib/DisplayLib/Display.cs 2009-04-28 01:08:32 UTC (rev 923)
@@ -91,7 +91,11 @@
impl.Initialize();
mSurfacePacker = new SurfacePacker();
+ }
+ private static ShaderCompilerImpl CreateShaderCompiler()
+ {
+ return impl.CreateShaderCompiler();
}
/// <summary>
/// Disposes of the Display.
@@ -125,6 +129,12 @@
}
}
+ public static Shaders.ShaderProgram Shader
+ {
+ get { return impl.Shader; }
+ set { impl.Shader = value; }
+ }
+
/// <summary>
/// Delegate type for functions which are called when Display.Dispose is called
/// at the end of execution of the program.
@@ -522,9 +532,31 @@
{
if (pts.Length % 2 == 1)
throw new ArgumentException("pts argument is not an even number of points!");
-
impl.DrawLineSegments(pts, color);
}
+
+ #region --- Matrix Settings ---
+
+ public static Matrix4 MatrixProjection
+ {
+ get { return impl.MatrixProjection; }
+ set { impl.MatrixProjection = value; }
+ }
+ public static Matrix4 MatrixView
+ {
+ get { return impl.MatrixView; }
+ set { impl.MatrixView = value; }
+ }
+ public static Matrix4 MatrixWorld
+ {
+ get { return impl.MatrixWorld; }
+ set { impl.MatrixWorld = value; }
+ }
+
+
+ #endregion
+
+
/// <summary>
/// Draws the outline of a rectangle.
/// </summary>
@@ -661,6 +693,4 @@
}
}
-
-
}
Property changes on: branches/agate3d-3.2/AgateLib/DisplayLib/Display.cs
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/agate-3d/AgateLib/DisplayLib/Display.cs:659
/branches/build/AgateLib/DisplayLib/Display.cs:501-517
/branches/font/AgateLib/DisplayLib/Display.cs:778-916
/branches/merge-tests/AgateLib/DisplayLib/Display.cs:806-810
/branches/registrar/AgateLib/DisplayLib/Display.cs:595-599
/branches/sprites/AgateLib/DisplayLib/Display.cs:463-513
+ /branches/agate-3d/AgateLib/DisplayLib/Display.cs:629-702,840-864
/branches/build/AgateLib/DisplayLib/Display.cs:501-517
/branches/font/AgateLib/DisplayLib/Display.cs:778-916
/branches/merge-tests/AgateLib/DisplayLib/Display.cs:806-810
/branches/registrar/AgateLib/DisplayLib/Display.cs:595-599
/branches/sprites/AgateLib/DisplayLib/Display.cs:463-513
Modified: branches/agate3d-3.2/AgateLib/DisplayLib/PixelBuffer.cs
===================================================================
--- branches/agate3d-3.2/AgateLib/DisplayLib/PixelBuffer.cs 2009-04-27 05:52:15 UTC (rev 922)
+++ branches/agate3d-3.2/AgateLib/DisplayLib/PixelBuffer.cs 2009-04-28 01:08:32 UTC (rev 923)
@@ -30,7 +30,7 @@
/// construct or modify surface data programmatically.
/// </summary>
[Serializable]
- public sealed class PixelBuffer
+ public sealed class PixelBuffer : ICloneable
{
#region --- Private Data ---
@@ -174,6 +174,14 @@
{
this.CopyFrom(buffer, srcRect, new Point(0, 0), false);
}
+ /// <summary>
+ /// Returns a deep copy of the PixelBuffer object.
+ /// </summary>
+ /// <returns></returns>
+ public PixelBuffer Clone()
+ {
+ return new PixelBuffer(this, new Rectangle(0, 0, Width, Height));
+ }
/// <summary>
/// Loads image data from a file and returns a PixelBuffer.
@@ -985,8 +993,106 @@
}
#endregion
+ #region --- ICloneable Members ---
+ object ICloneable.Clone()
+ {
+ return Clone();
+ }
+ #endregion
+ #region --- Normal Map conversion routines ---
+
+ /// <summary>
+ /// Creates a normal map by interpreting the pixel data in the passed buffer
+ /// as a height map.
+ /// </summary>
+ /// <param name="buffer"></param>
+ /// <returns></returns>
+ public static PixelBuffer NormalMapFromHeightMap(PixelBuffer buffer)
+ {
+ return NormalMapFromHeightMap(buffer, 1.0f);
+ }
+ /// <summary>
+ /// Creates a normal map by interpreting the pixel data in the passed buffer
+ /// as a height map.
+ /// </summary>
+ /// <param name="buffer"></param>
+ /// <param name="normalStr">The weight for the x-y components of the normals in
+ /// the normal map. Smaller values make the normal map more subtle.
+ /// Values in the range 0.5f to 3.0f are reasonable.</param>
+ /// <returns></returns>
+ public static PixelBuffer NormalMapFromHeightMap(PixelBuffer buffer, float normalStr)
+ {
+ int[,] heights = new int[buffer.Width, buffer.Height];
+
+ for (int j = 0; j < buffer.Height; j++)
+ {
+ for (int i = 0; i < buffer.Width; i++)
+ {
+ heights[i, j] = (int)(buffer.GetPixel(i, j).Intensity * short.MaxValue);
+ }
+ }
+
+ PixelBuffer retval = new PixelBuffer(buffer.PixelFormat, buffer.Size);
+ int[,] square = new int[3, 3];
+
+ for (int j = 0; j < retval.Height; j++)
+ {
+ for (int i = 0; i < retval.Width; i++)
+ {
+ GetSquare(square, heights, i, j);
+
+ // sobel operator:
+ int diffx = square[0, 0] - square[2, 0] +
+ 2 * (square[0, 1] - square[2, 1]) +
+ square[0, 2] - square[2, 0];
+
+ int diffy = square[0, 0] + 2 * square[1, 0] + square[0, 2] +
+ -square[0, 2] - 2 * square[1, 2] - square[2, 2];
+
+ Vector3 vec = new Vector3(diffx / (float)short.MaxValue, diffy / (float)short.MaxValue, 0);
+ vec *= normalStr;
+ vec.Z = 1;
+
+ vec = vec.Normalize();
+ vec = vec / 2;
+ vec.X += 0.5f; vec.Y += 0.5f; vec.Z += 0.5f;
+ Color clr = Color.FromArgb((int)(vec.X * 255),
+ (int)(vec.Y * 255),
+ (int)(vec.Z * 255));
+
+ retval.SetPixel(i, j, clr);
+ }
+ }
+
+ return retval;
+ }
+
+ private static void GetSquare(int[,] square, int[,] heights, int x, int y)
+ {
+ for (int j = -1; j <= 1; j++)
+ {
+ for (int i = -1; i <= 1; i++)
+ {
+ int val = GetValueWrap(heights, x + i, y + j);
+
+ square[i + 1, j + 1] = val;
+ }
+ }
+ }
+
+ private static int GetValueWrap(int[,] heights, int x, int y)
+ {
+ if (x < 0) x += heights.GetUpperBound(0) + 1;
+ if (y < 0) y += heights.GetUpperBound(1) + 1;
+ if (x > heights.GetUpperBound(0)) x -= heights.GetUpperBound(0) + 1;
+ if (y > heights.GetUpperBound(1)) y -= heights.GetUpperBound(1) + 1;
+
+ return heights[x, y];
+ }
+
+ #endregion
}
}
Added: branches/agate3d-3.2/AgateLib/DisplayLib/PrimitiveType.cs
===================================================================
--- branches/agate3d-3.2/AgateLib/DisplayLib/PrimitiveType.cs (rev 0)
+++ branches/agate3d-3.2/AgateLib/DisplayLib/PrimitiveType.cs 2009-04-28 01:08:32 UTC (rev 923)
@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace AgateLib.DisplayLib
+{
+ public enum PrimitiveType
+ {
+ TriangleList,
+ TriangleFan,
+ TriangleStrip,
+ }
+}
Deleted: branches/agate3d-3.2/AgateLib/DisplayLib/Shaders/PixelShader.cs
===================================================================
--- branches/agate-3d/AgateLib/DisplayLib/Shaders/PixelShader.cs 2009-04-15 04:44:43 UTC (rev 864)
+++ branches/agate3d-3.2/AgateLib/DisplayLib/Shaders/PixelShader.cs 2009-04-28 01:08:32 UTC (rev 923)
@@ -1,16 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-
-namespace AgateLib.DisplayLib.Shaders
-{
- public abstract class PixelShader
- {
- public virtual ShaderLanguage Language
- {
- get { return ShaderLanguage.Unknown; }
- }
- public string Source { get; protected set; }
- }
-}
Copied: branches/agate3d-3.2/AgateLib/DisplayLib/Shaders/PixelShader.cs (from rev 864, branches/agate-3d/AgateLib/DisplayLib/Shaders/PixelShader.cs)
===================================================================
--- branches/agate3d-3.2/AgateLib/DisplayLib/Shaders/PixelShader.cs (rev 0)
+++ branches/agate3d-3.2/AgateLib/DisplayLib/Shaders/PixelShader.cs 2009-04-28 01:08:32 UTC (rev 923)
@@ -0,0 +1,16 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace AgateLib.DisplayLib.Shaders
+{
+ public abstract class PixelShader
+ {
+ public virtual ShaderLanguage Language
+ {
+ get { return ShaderLanguage.Unknown; }
+ }
+ public string Source { get; protected set; }
+ }
+}
Deleted: branches/agate3d-3.2/AgateLib/DisplayLib/Shaders/ShaderCompiler.cs
===================================================================
--- branches/agate-3d/AgateLib/DisplayLib/Shaders/ShaderCompiler.cs 2009-04-15 04:44:43 UTC (rev 864)
+++ branches/agate3d-3.2/AgateLib/DisplayLib/Shaders/ShaderCompiler.cs 2009-04-28 01:08:32 UTC (rev 923)
@@ -1,36 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using AgateLib.ImplementationBase;
-
-namespace AgateLib.DisplayLib.Shaders
-{
- public static class ShaderCompiler
- {
- static ShaderCompilerImpl impl;
-
- internal static void Initialize(AgateLib.ImplementationBase.ShaderCompilerImpl shaderCompilerImpl)
- {
- impl = shaderCompilerImpl;
-
- Display.DisposeDisplay += new Display.DisposeDisplayHandler(Display_DisposeDisplay);
- }
-
- static void Display_DisposeDisplay()
- {
- impl = null;
- }
-
- internal static void Disable()
- {
- impl = null;
- }
-
- public static ShaderProgram CompileShader(ShaderLanguage language, string vertexShaderSource, string pixelShaderSource)
- {
- return impl.CompileShader(language, vertexShaderSource, pixelShaderSource);
- }
-
- }
-}
Copied: branches/agate3d-3.2/AgateLib/DisplayLib/Shaders/ShaderCompiler.cs (from rev 864, branches/agate-3d/AgateLib/DisplayLib/Shaders/ShaderCompiler.cs)
===================================================================
--- branches/agate3d-3.2/AgateLib/DisplayLib/Shaders/ShaderCompiler.cs (rev 0)
+++ branches/agate3d-3.2/AgateLib/DisplayLib/Shaders/ShaderCompiler.cs 2009-04-28 01:08:32 UTC (rev 923)
@@ -0,0 +1,36 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using AgateLib.ImplementationBase;
+
+namespace AgateLib.DisplayLib.Shaders
+{
+ public static class ShaderCompiler
+ {
+ static ShaderCompilerImpl impl;
+
+ internal static void Initialize(AgateLib.ImplementationBase.ShaderCompilerImpl shaderCompilerImpl)
+ {
+ impl = shaderCompilerImpl;
+
+ Display.DisposeDisplay += new Display.DisposeDisplayHandler(Display_DisposeDisplay);
+ }
+
+ static void Display_DisposeDisplay()
+ {
+ impl = null;
+ }
+
+ internal static void Disable()
+ {
+ impl = null;
+ }
+
+ public static ShaderProgram CompileShader(ShaderLanguage language, string vertexShaderSource, string pixelShaderSource)
+ {
+ return impl.CompileShader(language, vertexShaderSource, pixelShaderSource);
+ }
+
+ }
+}
Deleted: branches/agate3d-3.2/AgateLib/DisplayLib/Shaders/ShaderLanguage.cs
===================================================================
--- branches/agate-3d/AgateLib/DisplayLib/Shaders/ShaderLanguage.cs 2009-04-15 04:44:43 UTC (rev 864)
+++ branches/agate3d-3.2/AgateLib/DisplayLib/Shaders/ShaderLanguage.cs 2009-04-28 01:08:32 UTC (rev 923)
@@ -1,17 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-
-namespace AgateLib.DisplayLib.Shaders
-{
- public enum ShaderLanguage
- {
- Unknown,
-
- Glsl,
- // Hlsl,
- // Cg,
-
- }
-}
Copied: branches/agate3d-3.2/AgateLib/DisplayLib/Shaders/ShaderLanguage.cs (from rev 864, branches/agate-3d/AgateLib/DisplayLib/Shaders/ShaderLanguage.cs)
===================================================================
--- branches/agate3d-3.2/AgateLib/DisplayLib/Shaders/ShaderLanguage.cs (rev 0)
+++ branches/agate3d-3.2/AgateLib/DisplayLib/Shaders/ShaderLanguage.cs 2009-04-28 01:08:32 UTC (rev 923)
@@ -0,0 +1,17 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace AgateLib.DisplayLib.Shaders
+{
+ public enum ShaderLanguage
+ {
+ Unknown,
+
+ Glsl,
+ // Hlsl,
+ // Cg,
+
+ }
+}
Deleted: branches/agate3d-3.2/AgateLib/DisplayLib/Shaders/ShaderProgram.cs
===================================================================
--- branches/agate-3d/AgateLib/DisplayLib/Shaders/ShaderProgram.cs 2009-04-15 04:44:43 UTC (rev 864)
+++ branches/agate3d-3.2/AgateLib/DisplayLib/Shaders/ShaderProgram.cs 2009-04-28 01:08:32 UTC (rev 923)
@@ -1,37 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using AgateLib.Geometry;
-
-namespace AgateLib.DisplayLib.Shaders
-{
- public abstract class ShaderProgram
- {
- public abstract PixelShader PixelShader { get; }
- public abstract VertexShader VertexShader { get; }
-
- public abstract void SetUniform(string name, params float[] v);
- public abstract void SetUniform(string name, params int[] v);
- public abstract void SetUniform(string name, Matrix4 matrix);
-
- public void SetUniform(string name, Vector2 v)
- {
- SetUniform(name, v.X, v.Y);
- }
- public void SetUniform(string name, Vector3 v)
- {
- SetUniform(name, v.X, v.Y, v.Z);
- }
- public void SetUniform(string name, Vector4 v)
- {
- SetUniform(name, v.X, v.Y, v.Z, v.W);
- }
- public void SetUniform(string name, Color color)
- {
- SetUniform(name, color.R / 255.0f, color.G / 255.0f, color.B / 255.0f, color.A / 255.0f);
- }
-
- public VertexLayout VertexDefinition { get; set; }
- }
-}
Copied: branches/agate3d-3.2/AgateLib/DisplayLib/Shaders/ShaderProgram.cs (from rev 864, branches/agate-3d/AgateLib/DisplayLib/Shaders/ShaderProgram.cs)
===================================================================
--- branches/agate3d-3.2/AgateLib/DisplayLib/Shaders/ShaderProgram.cs (rev 0)
+++ branches/agate3d-3.2/AgateLib/DisplayLib/Shaders/ShaderProgram.cs 2009-04-28 01:08:32 UTC (rev 923)
@@ -0,0 +1,37 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using AgateLib.Geometry;
+
+namespace AgateLib.DisplayLib.Shaders
+{
+ public abstract class ShaderProgram
+ {
+ public abstract PixelShader PixelShader { get; }
+ public abstract VertexShader VertexShader { get; }
+
+ public abstract void SetUniform(string name, params float[] v);
+ public abstract void SetUniform(string name, params int[] v);
+ public abstract void SetUniform(string name, Matrix4 matrix);
+
+ public void SetUniform(string name, Vector2 v)
+ {
+ SetUniform(name, v.X, v.Y);
+ }
+ public void SetUniform(string name, Vector3 v)
+ {
+ SetUniform(name, v.X, v.Y, v.Z);
+ }
+ public void SetUniform(string name, Vector4 v)
+ {
+ SetUniform(name, v.X, v.Y, v.Z, v.W);
+ }
+ public void SetUniform(string name, Color color)
+ {
+ SetUniform(name, color.R / 255.0f, color.G / 255.0f, color.B / 255.0f, color.A / 255.0f);
+ }
+
+ public VertexLayout VertexDefinition { get; set; }
+ }
+}
Deleted: branches/agate3d-3.2/AgateLib/DisplayLib/Shaders/VertexShader.cs
===================================================================
--- branches/agate-3d/AgateLib/DisplayLib/Shaders/VertexShader.cs 2009-04-15 04:44:43 UTC (rev 864)
+++ branches/agate3d-3.2/AgateLib/DisplayLib/Shaders/VertexShader.cs 2009-04-28 01:08:32 UTC (rev 923)
@@ -1,16 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-
-namespace AgateLib.DisplayLib.Shaders
-{
- public abstract class VertexShader
- {
- public virtual ShaderLanguage Language
- {
- get { return ShaderLanguage.Unknown; }
- }
- public string Source { get; protected set; }
- }
-}
Copied: branches/agate3d-3.2/AgateLib/DisplayLib/Shaders/VertexShader.cs (from rev 864, branches/agate-3d/AgateLib/Disp...
[truncated message content] |
|
From: <ka...@us...> - 2009-04-28 01:26:59
|
Revision: 924
http://agate.svn.sourceforge.net/agate/?rev=924&view=rev
Author: kanato
Date: 2009-04-28 01:26:55 +0000 (Tue, 28 Apr 2009)
Log Message:
-----------
Add missing shaders and make 3D tests work.
Modified Paths:
--------------
branches/agate3d-3.2/Drivers/AgateOTK/GL_Surface.cs
branches/agate3d-3.2/Tests/Display3D/Glsl.cs
branches/agate3d-3.2/Tests/Display3D/Matrices.cs
branches/agate3d-3.2/Tests/Display3D/Test3d.cs
Added Paths:
-----------
branches/agate3d-3.2/Tests/Data/bg-bricks-heightmap.png
branches/agate3d-3.2/Tests/Data/shaders/
branches/agate3d-3.2/Tests/Data/shaders/BumpMap_fragment.txt
branches/agate3d-3.2/Tests/Data/shaders/BumpMap_vertex.txt
branches/agate3d-3.2/Tests/Data/shaders/PerPixelLighting_fragment.txt
branches/agate3d-3.2/Tests/Data/shaders/PerPixelLighting_vertex.txt
Modified: branches/agate3d-3.2/Drivers/AgateOTK/GL_Surface.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateOTK/GL_Surface.cs 2009-04-28 01:08:32 UTC (rev 923)
+++ branches/agate3d-3.2/Drivers/AgateOTK/GL_Surface.cs 2009-04-28 01:26:55 UTC (rev 924)
@@ -167,7 +167,6 @@
public override void Dispose()
{
ReleaseTextureRef();
-
}
public override void Draw(SurfaceState state)
Added: branches/agate3d-3.2/Tests/Data/bg-bricks-heightmap.png
===================================================================
(Binary files differ)
Property changes on: branches/agate3d-3.2/Tests/Data/bg-bricks-heightmap.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: branches/agate3d-3.2/Tests/Data/shaders/BumpMap_fragment.txt
===================================================================
--- branches/agate3d-3.2/Tests/Data/shaders/BumpMap_fragment.txt (rev 0)
+++ branches/agate3d-3.2/Tests/Data/shaders/BumpMap_fragment.txt 2009-04-28 01:26:55 UTC (rev 924)
@@ -0,0 +1,46 @@
+varying vec4 diffuse,ambientGlobal, ambient;
+varying vec3 normal,lightDir,halfVector;
+varying float dist;
+uniform sampler2D texture0;
+uniform sampler2D texture1;
+
+void main()
+{
+ vec3 n,halfV,viewV,ldir;
+ float NdotL,NdotHV;
+ vec4 color = ambientGlobal;
+ float att;
+
+ /* a fragment shader can't write a varying variable, hence we need
+ a new variable to store the normalized interpolated normal */
+ n = normalize(normal);
+
+ // calculate the bumpmap properties
+ vec4 bumpcolor = texture2D(texture1,gl_TexCoord[0].st);
+ bumpcolor = bumpcolor * 2.0 - 1.0;
+ n = normalize(bumpcolor.rgb);
+ //n = vec3(0.707,0,0.707);
+
+ /* compute the dot product between normal and normalized lightdir */
+ NdotL = max(dot(n,normalize(lightDir)),0.0);
+
+ if (NdotL > 0.0) {
+ att = 1.0 / (gl_LightSource[0].constantAttenuation +
+ gl_LightSource[0].linearAttenuation * dist +
+ gl_LightSource[0].quadraticAttenuation * dist * dist);
+
+ color += att * (diffuse * NdotL + ambient);
+
+ halfV = normalize(halfVector);
+ NdotHV = max(dot(n,halfV),0.0);
+ color += att * gl_FrontMaterial.specular * gl_LightSource[0].specular *
+ pow(NdotHV,gl_FrontMaterial.shininess);
+ }
+
+ vec4 texcolor = texture2D(texture0,gl_TexCoord[0].st);
+
+ color.rgb *= texcolor.rgb;
+
+ gl_FragColor = color;
+}
+
Added: branches/agate3d-3.2/Tests/Data/shaders/BumpMap_vertex.txt
===================================================================
--- branches/agate3d-3.2/Tests/Data/shaders/BumpMap_vertex.txt (rev 0)
+++ branches/agate3d-3.2/Tests/Data/shaders/BumpMap_vertex.txt 2009-04-28 01:26:55 UTC (rev 924)
@@ -0,0 +1,43 @@
+
+attribute vec3 tangent; //The inverse tangent to the geometry
+attribute vec3 bitangent; //The inverse binormal to the geometry
+
+varying vec4 diffuse,ambientGlobal,ambient;
+varying vec3 normal,lightDir,halfVector;
+varying float dist;
+
+void main()
+{
+ vec3 aux;
+
+ normal = normalize(gl_Normal);
+
+ // Building the matrix Eye Space -> Tangent Space
+ vec3 n = normalize (gl_NormalMatrix * gl_Normal);
+ vec3 t = normalize (gl_NormalMatrix * tangent);
+ vec3 b = normalize (gl_NormalMatrix * bitangent);
+
+ vec4 evPos = gl_ModelViewMatrix * gl_Vertex;
+ vec3 lightVec = vec3(gl_LightSource[0].position.xyz - evPos.xyz);
+
+ vec3 v;
+ v.x = dot(lightVec, t);
+ v.y = dot(lightVec, b);
+ v.z = dot(lightVec, n);
+ lightDir = normalize(v);
+
+ dist = length(lightVec);
+
+ halfVector = normalize(gl_LightSource[0].halfVector.xyz);
+
+ /* Compute the diffuse, ambient and globalAmbient terms */
+ diffuse = gl_FrontMaterial.diffuse * gl_LightSource[0].diffuse;
+
+ /* The ambient terms have been separated since one of them */
+ /* suffers attenuation */
+ ambient = gl_FrontMaterial.ambient * gl_LightSource[0].ambient;
+ ambientGlobal = gl_LightModel.ambient * gl_FrontMaterial.ambient;
+
+ gl_Position = ftransform();
+ gl_TexCoord[0] = gl_MultiTexCoord0;
+}
Added: branches/agate3d-3.2/Tests/Data/shaders/PerPixelLighting_fragment.txt
===================================================================
--- branches/agate3d-3.2/Tests/Data/shaders/PerPixelLighting_fragment.txt (rev 0)
+++ branches/agate3d-3.2/Tests/Data/shaders/PerPixelLighting_fragment.txt 2009-04-28 01:26:55 UTC (rev 924)
@@ -0,0 +1,40 @@
+varying vec4 diffuse,ambientGlobal, ambient;
+varying vec3 normal,lightDir,halfVector;
+varying float dist;
+uniform sampler2D texture0;
+
+
+void main()
+{
+ vec3 n,halfV,viewV,ldir;
+ float NdotL,NdotHV;
+ vec4 color = ambientGlobal;
+ float att;
+
+ /* a fragment shader can't write a varying variable, hence we need
+ a new variable to store the normalized interpolated normal */
+ n = normalize(normal);
+
+ /* compute the dot product between normal and normalized lightdir */
+ NdotL = max(dot(n,normalize(lightDir)),0.0);
+
+ if (NdotL > 0.0) {
+ att = 1.0 / (gl_LightSource[0].constantAttenuation +
+ gl_LightSource[0].linearAttenuation * dist +
+ gl_LightSource[0].quadraticAttenuation * dist * dist);
+
+ color += att * (diffuse * NdotL + ambient);
+
+ halfV = normalize(halfVector);
+ NdotHV = max(dot(n,halfV),0.0);
+ color += att * gl_FrontMaterial.specular * gl_LightSource[0].specular *
+ pow(NdotHV,gl_FrontMaterial.shininess);
+ }
+
+ vec4 texcolor = texture2D(texture0,gl_TexCoord[0].st);
+
+ color.rgb *= texcolor.rgb;
+
+ gl_FragColor = color;
+}
+
Added: branches/agate3d-3.2/Tests/Data/shaders/PerPixelLighting_vertex.txt
===================================================================
--- branches/agate3d-3.2/Tests/Data/shaders/PerPixelLighting_vertex.txt (rev 0)
+++ branches/agate3d-3.2/Tests/Data/shaders/PerPixelLighting_vertex.txt 2009-04-28 01:26:55 UTC (rev 924)
@@ -0,0 +1,31 @@
+varying vec4 diffuse,ambientGlobal,ambient;
+varying vec3 normal,lightDir,halfVector;
+varying float dist;
+
+void main()
+{
+ vec4 ecPos;
+ vec3 aux;
+
+ normal = normalize(gl_NormalMatrix * gl_Normal);
+
+ /* these are the new lines of code to compute the light's direction */
+ ecPos = gl_ModelViewMatrix * gl_Vertex;
+ aux = vec3(gl_LightSource[0].position-ecPos);
+ lightDir = normalize(aux);
+ dist = length(aux);
+
+ halfVector = normalize(gl_LightSource[0].halfVector.xyz);
+
+ /* Compute the diffuse, ambient and globalAmbient terms */
+ diffuse = gl_FrontMaterial.diffuse * gl_LightSource[0].diffuse;
+
+ /* The ambient terms have been separated since one of them */
+ /* suffers attenuation */
+ ambient = gl_FrontMaterial.ambient * gl_LightSource[0].ambient;
+ ambientGlobal = gl_LightModel.ambient * gl_FrontMaterial.ambient;
+
+
+ gl_Position = ftransform();
+ gl_TexCoord[0] = gl_MultiTexCoord0;
+}
Modified: branches/agate3d-3.2/Tests/Display3D/Glsl.cs
===================================================================
--- branches/agate3d-3.2/Tests/Display3D/Glsl.cs 2009-04-28 01:08:32 UTC (rev 923)
+++ branches/agate3d-3.2/Tests/Display3D/Glsl.cs 2009-04-28 01:26:55 UTC (rev 924)
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
+using System.IO;
using System.Linq;
using System.Text;
using AgateLib;
@@ -10,19 +11,29 @@
using AgateLib.Geometry;
using AgateLib.InputLib;
-namespace Glsl
+namespace Tests.Display3D.Glsl
{
- public class Glsl
+ public class Glsl: IAgateTest
{
- /// <summary>
- /// The main entry point for the application.
- /// </summary>
- [STAThread]
- static void Main(string[] args)
+ #region IAgateTest Members
+
+ public string Name
{
- new Glsl().Run(args);
+ get { return "Glsl"; }
}
+ public string Category
+ {
+ get { return "Display 3D"; }
+ }
+
+ void IAgateTest.Main(string[] args)
+ {
+ Run(args);
+ }
+
+ #endregion
+
bool rotating = false;
const float velocity = 0.04f;
const float mousevelocity = 0.004f;
@@ -46,11 +57,6 @@
}
private void Run(string[] args)
{
- // These two lines are used by AgateLib tests to locate
- // driver plugins and images.
- AgateLib.AgateFileProvider.Assemblies.AddPath("../Drivers");
- AgateLib.AgateFileProvider.Images.AddPath("../../../Tests/TestImages");
-
using (AgateSetup setup = new AgateSetup(args))
{
setup.Initialize(true, false, false);
@@ -93,12 +99,12 @@
PixelBuffer.NormalMapFromHeightMap(height.ReadPixels(), 2.0f));
buffer.Textures[1].SaveTo("normal.png");
- ShaderProgram shader = null;
//var shader = ShaderCompiler.CompileShader(ShaderLanguage.Glsl,
// Shaders.PerPixelLighting_vertex, Shaders.PerPixelLighting_fragment);
+ var shader = ShaderCompiler.CompileShader(ShaderLanguage.Glsl,
+ File.ReadAllText("Data/shaders/BumpMap_vertex.txt"),
+ File.ReadAllText("Data/shaders/BumpMap_fragment.txt"));
//var shader = ShaderCompiler.CompileShader(ShaderLanguage.Glsl,
- // Shaders.BumpMap_vertex, Shaders.BumpMap_fragment);
- //var shader = ShaderCompiler.CompileShader(ShaderLanguage.Glsl,
// Shaders.BumpMap_vertex, Shaders.PerPixelLighting_fragment);
resetmouse();
Modified: branches/agate3d-3.2/Tests/Display3D/Matrices.cs
===================================================================
--- branches/agate3d-3.2/Tests/Display3D/Matrices.cs 2009-04-28 01:08:32 UTC (rev 923)
+++ branches/agate3d-3.2/Tests/Display3D/Matrices.cs 2009-04-28 01:26:55 UTC (rev 924)
@@ -8,19 +8,28 @@
using AgateLib.Geometry.Builders;
using AgateLib.InputLib;
-namespace TestMatrices
+namespace Tests.Display3D.TestMatrices
{
- public class Matrices
+ public class Matrices : IAgateTest
{
- /// <summary>
- /// The main entry point for the application.
- /// </summary>
- [STAThread]
- static void Main(string[] args)
+ #region IAgateTest Members
+
+ public string Name
{
- new Matrices().Run(args);
+ get { return "Matrices"; }
}
+ public string Category
+ {
+ get { return "Display 3D"; }
+ }
+
+ void IAgateTest.Main(string[] args)
+ {
+ Run(args);
+ }
+
+ #endregion
static int matrixIndex = 1;
static int move, turn;
Modified: branches/agate3d-3.2/Tests/Display3D/Test3d.cs
===================================================================
--- branches/agate3d-3.2/Tests/Display3D/Test3d.cs 2009-04-28 01:08:32 UTC (rev 923)
+++ branches/agate3d-3.2/Tests/Display3D/Test3d.cs 2009-04-28 01:26:55 UTC (rev 924)
@@ -9,15 +9,34 @@
using AgateLib.DisplayLib;
using AgateLib.InputLib;
-namespace Test3D
+namespace Tests.Display3D.Test3D
{
- class Test3d
+ class Test3d : IAgateTest
{
- static int matrixIndex = 1;
- static int move, turn;
+ #region IAgateTest Members
- static void Main(string[] args)
+ public string Name
{
+ get { return "Test 3D"; }
+ }
+
+ public string Category
+ {
+ get { return "Display 3D"; }
+ }
+
+ void IAgateTest.Main(string[] args)
+ {
+ Run(args);
+ }
+
+ #endregion
+
+ int matrixIndex = 1;
+ int move, turn;
+
+ void Run(string[] args)
+ {
System.IO.FileStream fs = new System.IO.FileStream(@"c:\cube.obj", System.IO.FileMode.Open, System.IO.FileAccess.Read);
AgateLib.Meshes.Loaders.Obj.OBJFileRepresentation objRep = new AgateLib.Meshes.Loaders.Obj.OBJFileRepresentation(fs);
@@ -150,19 +169,19 @@
}
}
- private static Vector3 CalculateLookDirection(float facingAngle)
+ private Vector3 CalculateLookDirection(float facingAngle)
{
return new Vector3(Math.Cos(facingAngle), Math.Sin(facingAngle), 0);
}
- private static Vector3 CalculateLookTarget(Vector3 position, float facingAngle)
+ private Vector3 CalculateLookTarget(Vector3 position, float facingAngle)
{
Vector3 lookTarget = position;
lookTarget += new Vector3(Math.Cos(facingAngle), Math.Sin(facingAngle), 0);
return lookTarget;
}
- static void Keyboard_KeyUp(InputEventArgs e)
+ void Keyboard_KeyUp(InputEventArgs e)
{
if (e.KeyCode == KeyCode.Up || e.KeyCode == KeyCode.Down)
move = 0;
@@ -170,7 +189,7 @@
turn = 0;
}
- static void Keyboard_KeyDown(AgateLib.InputLib.InputEventArgs e)
+ void Keyboard_KeyDown(AgateLib.InputLib.InputEventArgs e)
{
if (e.KeyCode == AgateLib.InputLib.KeyCode.Space)
matrixIndex++;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ka...@us...> - 2009-04-28 08:25:22
|
Revision: 925
http://agate.svn.sourceforge.net/agate/?rev=925&view=rev
Author: kanato
Date: 2009-04-28 08:25:11 +0000 (Tue, 28 Apr 2009)
Log Message:
-----------
Switch to using vertex structures with VertexLayout information.
Modified Paths:
--------------
branches/agate3d-3.2/AgateLib/DisplayLib/Shaders/ShaderProgram.cs
branches/agate3d-3.2/AgateLib/DisplayLib/VertexBuffer.cs
branches/agate3d-3.2/AgateLib/Geometry/Builders/Cube.cs
branches/agate3d-3.2/AgateLib/Geometry/Builders/Terrain.cs
branches/agate3d-3.2/AgateLib/ImplementationBase/DisplayImpl.cs
branches/agate3d-3.2/AgateLib/ImplementationBase/VertexBufferImpl.cs
branches/agate3d-3.2/Drivers/AgateOTK/GL_Display.cs
branches/agate3d-3.2/Drivers/AgateOTK/GL_VertexBuffer.cs
branches/agate3d-3.2/Tests/Display3D/Glsl.cs
branches/agate3d-3.2/Tests/Display3D/Matrices.cs
branches/agate3d-3.2/Tests/Display3D/Test3d.cs
Added Paths:
-----------
branches/agate3d-3.2/AgateLib/DisplayLib/IndexBuffer.cs
branches/agate3d-3.2/AgateLib/Geometry/VertexTypes/
branches/agate3d-3.2/AgateLib/Geometry/VertexTypes/PositionTextureNTB.cs
branches/agate3d-3.2/AgateLib/Geometry/VertexTypes/PositionTextureNormal.cs
branches/agate3d-3.2/AgateLib/Geometry/VertexTypes/VertexLayout.cs
branches/agate3d-3.2/AgateLib/ImplementationBase/IndexBufferImpl.cs
branches/agate3d-3.2/Drivers/AgateOTK/GL_IndexBuffer.cs
Added: branches/agate3d-3.2/AgateLib/DisplayLib/IndexBuffer.cs
===================================================================
--- branches/agate3d-3.2/AgateLib/DisplayLib/IndexBuffer.cs (rev 0)
+++ branches/agate3d-3.2/AgateLib/DisplayLib/IndexBuffer.cs 2009-04-28 08:25:11 UTC (rev 925)
@@ -0,0 +1,43 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using AgateLib.ImplementationBase;
+
+namespace AgateLib.DisplayLib
+{
+ public class IndexBuffer
+ {
+ IndexBufferImpl impl;
+
+ public IndexBuffer(IndexBufferType type, int size)
+ {
+ impl = Display.Impl.CreateIndexBuffer(type, size);
+ }
+
+ public void WriteIndices(short[] indices)
+ {
+ impl.WriteIndices(indices);
+ }
+ public void WriteIndices(int[] indices)
+ {
+ impl.WriteIndices(indices);
+ }
+
+ public int Count
+ {
+ get { return impl.Count; }
+ }
+
+ public IndexBufferImpl Impl
+ {
+ get { return impl; }
+ }
+ }
+
+ public enum IndexBufferType
+ {
+ Int16,
+ Int32,
+ }
+}
Modified: branches/agate3d-3.2/AgateLib/DisplayLib/Shaders/ShaderProgram.cs
===================================================================
--- branches/agate3d-3.2/AgateLib/DisplayLib/Shaders/ShaderProgram.cs 2009-04-28 01:26:55 UTC (rev 924)
+++ branches/agate3d-3.2/AgateLib/DisplayLib/Shaders/ShaderProgram.cs 2009-04-28 08:25:11 UTC (rev 925)
@@ -3,6 +3,7 @@
using System.Linq;
using System.Text;
using AgateLib.Geometry;
+using AgateLib.Geometry.VertexTypes;
namespace AgateLib.DisplayLib.Shaders
{
Modified: branches/agate3d-3.2/AgateLib/DisplayLib/VertexBuffer.cs
===================================================================
--- branches/agate3d-3.2/AgateLib/DisplayLib/VertexBuffer.cs 2009-04-28 01:26:55 UTC (rev 924)
+++ branches/agate3d-3.2/AgateLib/DisplayLib/VertexBuffer.cs 2009-04-28 08:25:11 UTC (rev 925)
@@ -4,6 +4,7 @@
using System.Text;
using AgateLib.ImplementationBase;
using AgateLib.Geometry;
+using AgateLib.Geometry.VertexTypes;
namespace AgateLib.DisplayLib
{
@@ -17,6 +18,7 @@
throw new ArgumentNullException(
"The supplied VertexLayout must not be null. " +
"You may wish to use one of the static members of VertexLayout.");
+
if (layout.Count == 0)
throw new ArgumentException(
"The supplied VertexLayout has no items in it. You must supply a valid layout.");
@@ -24,50 +26,41 @@
impl = Display.Impl.CreateVertexBuffer(layout, vertexCount);
}
- public void WriteVertexData(Vector3[] data)
+ public void WriteVertexData<T>(T[] data)
{
- impl.WriteVertexData(data);
+ impl.Write(data);
}
- public void WriteTextureCoords(Vector2[] texCoords)
+ public void Draw()
{
- impl.WriteTextureCoords(texCoords);
+ impl.Draw(0, VertexCount);
}
- public void WriteNormalData(Vector3[] data)
+ public void Draw(int start, int count)
{
- impl.WriteNormalData(data);
+ impl.Draw(start, count);
}
- public void WriteIndices(short[] indices)
+ /// <summary>
+ /// Draws the vertices using the indexes in the index buffer.
+ /// </summary>
+ /// <param name="indexbuffer"></param>
+ public void DrawIndexed(IndexBuffer indexbuffer)
{
- impl.WriteIndices(indices);
- impl.Indexed = true;
+ impl.DrawIndexed(indexbuffer, 0, indexbuffer.Count);
}
- public void WriteAttributeData(string attributeName, Vector3[] data)
+ /// <summary>
+ /// Draws the vertices using the specified set of indexes in the index buffer.
+ /// </summary>
+ /// <param name="indexbuffer"></param>
+ /// <param name="start"></param>
+ /// <param name="count"></param>
+ public void DrawIndexed(IndexBuffer indexbuffer, int start, int count)
{
- impl.WriteAttributeData(attributeName, data);
+ impl.DrawIndexed(indexbuffer, start, count);
}
- public bool Indexed
- {
- get { return impl.Indexed; }
- set { impl.Indexed = value; }
- }
- public void Draw()
- {
- impl.Draw();
- }
- public void Draw(int start, int count)
- {
- impl.Draw(start, count);
- }
-
public int VertexCount
{
get { return impl.VertexCount; }
}
- public int IndexCount
- {
- get { return impl.IndexCount; }
- }
public PrimitiveType PrimitiveType
{
get { return impl.PrimitiveType; }
@@ -77,7 +70,6 @@
{
get { return impl.Textures; }
}
-
}
public class TextureList
@@ -111,221 +103,4 @@
}
}
- public class VertexLayout : IList<VertexMember>
- {
- List<VertexMember> items = new List<VertexMember>();
-
- int VertexSize
- {
- get
- {
- return this.Sum(x => x.ItemSize);
- }
- }
-
- public static VertexLayout PositionNormalTexture
- {
- get
- {
- return new VertexLayout
- {
- new VertexMember(VertexMemberType.Float3, VertexMemberUsage.Position),
- new VertexMember(VertexMemberType.Float3, VertexMemberUsage.Normal),
- new VertexMember(VertexMemberType.Float2, VertexMemberUsage.Texture),
- };
- }
- }
- public static VertexLayout PositionNormalTangentBitangentTexture
- {
- get
- {
- return new VertexLayout
- {
- new VertexMember(VertexMemberType.Float3, VertexMemberUsage.Position),
- new VertexMember(VertexMemberType.Float3, VertexMemberUsage.Normal),
- new VertexMember(VertexMemberType.Float3, VertexMemberUsage.Tangent),
- new VertexMember(VertexMemberType.Float3, VertexMemberUsage.Bitangent),
- new VertexMember(VertexMemberType.Float2, VertexMemberUsage.Texture),
- };
- }
- }
- public VertexLayout PositionNormal
- {
- get
- {
- return new VertexLayout
- {
- new VertexMember(VertexMemberType.Float3, VertexMemberUsage.Position),
- new VertexMember(VertexMemberType.Float3, VertexMemberUsage.Normal),
- };
- }
- }
- public VertexLayout PositionTexture
- {
- get
- {
- return new VertexLayout
- {
- new VertexMember(VertexMemberType.Float3, VertexMemberUsage.Position),
- new VertexMember(VertexMemberType.Float2, VertexMemberUsage.Texture),
- };
- }
- }
-
- #region --- IList<VertexMember> Members ---
-
- int IList<VertexMember>.IndexOf(VertexMember item)
- {
- return items.IndexOf(item);
- }
- void IList<VertexMember>.Insert(int index, VertexMember item)
- {
- items.Insert(index, item);
- }
- public void RemoveAt(int index)
- {
- items.RemoveAt(index);
- }
- public VertexMember this[int index]
- {
- get { return items[index]; }
- set { items[index] = value; }
- }
-
- #endregion
- #region --- ICollection<VertexMember> Members ---
-
- public void Add(VertexMember item)
- {
- items.Add(item);
- }
- public void Clear()
- {
- items.Clear();
- }
- bool ICollection<VertexMember>.Contains(VertexMember item)
- {
- return items.Contains(item);
- }
- public void CopyTo(VertexMember[] array, int arrayIndex)
- {
- items.CopyTo(array, arrayIndex);
- }
-
- public int Count
- {
- get { return items.Count; }
- }
-
- bool ICollection<VertexMember>.IsReadOnly
- {
- get { return false; }
- }
-
- bool ICollection<VertexMember>.Remove(VertexMember item)
- {
- return items.Remove(item);
- }
-
- #endregion
- #region --- IEnumerable<VertexMember> Members ---
-
- IEnumerator<VertexMember> IEnumerable<VertexMember>.GetEnumerator()
- {
- return items.GetEnumerator();
- }
-
- #endregion
- #region --- IEnumerable Members ---
-
- System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
- {
- return items.GetEnumerator();
- }
-
- #endregion
-
- public bool Contains(VertexMemberUsage vertexMemberUsage)
- {
- return items.Any(x => x.Usage == vertexMemberUsage);
- }
- public bool Contains(string attributeName)
- {
- return items.Any(x => x.Usage == VertexMemberUsage.Attribute && x.AttributeString == attributeName);
- }
- }
-
- public class VertexMember
- {
- VertexMemberUsage mDef;
- string mAttributeString;
-
- public VertexMember(VertexMemberType type, VertexMemberUsage def)
- {
- if (def == VertexMemberUsage.Attribute)
- throw new AgateException("Use the (VertexMemberType, string) overload instead.");
-
- MemberType = type;
- Usage = def;
- }
-
- public VertexMember(VertexMemberType type, string attributeName)
- {
- MemberType = type;
- Usage = VertexMemberUsage.Attribute;
- AttributeString = attributeName;
- }
-
- public VertexMemberType MemberType { get; private set; }
- public VertexMemberUsage Usage
- {
- get { return mDef; }
- private set
- {
- mDef = value;
-
- if (mDef != VertexMemberUsage.Attribute)
- mAttributeString = null;
- }
- }
- public string AttributeString
- {
- get { return mAttributeString; }
- private set
- {
- mAttributeString = value;
- mDef = VertexMemberUsage.Attribute;
- }
- }
-
- public int ItemSize
- {
- get
- {
- return 1;
- }
- }
- }
-
- public enum VertexMemberType
- {
- Float1,
- Float2,
- Float3,
- Float4,
- }
-
- public enum VertexMemberUsage
- {
- Position,
- Normal,
- Tangent,
- Bitangent,
- Color,
- Texture,
- Texture1,
- Texture2,
- Texture3,
- Attribute,
- }
}
Modified: branches/agate3d-3.2/AgateLib/Geometry/Builders/Cube.cs
===================================================================
--- branches/agate3d-3.2/AgateLib/Geometry/Builders/Cube.cs 2009-04-28 01:26:55 UTC (rev 924)
+++ branches/agate3d-3.2/AgateLib/Geometry/Builders/Cube.cs 2009-04-28 08:25:11 UTC (rev 925)
@@ -2,57 +2,68 @@
using System.Collections.Generic;
using System.Text;
using AgateLib.DisplayLib;
+using AgateLib.Geometry.VertexTypes;
namespace AgateLib.Geometry.Builders
{
public class CubeBuilder
{
+ VertexBuffer mVertices = null;
+ IndexBuffer mIndices = null;
+
public CubeBuilder()
{
Length = 1;
- VertexType = VertexLayout.PositionNormalTexture;
+ VertexType = VertexTypes.PositionTextureNTB.VertexLayout;
}
+ public VertexBuffer VertexBuffer
+ {
+ get { return mVertices; }
+ }
+ public IndexBuffer IndexBuffer
+ {
+ get { return mIndices; }
+ }
+
public float Length { get; set; }
public Vector3 Location { get; set; }
+
bool GenerateTextureCoords
{
- get { return VertexType.Contains(VertexMemberUsage.Texture); }
+ get { return VertexType.ContainsElement(VertexElement.Texture); }
}
bool GenerateNormals
{
- get { return VertexType.Contains(VertexMemberUsage.Normal); }
+ get { return VertexType.ContainsElement(VertexElement.Normal); }
}
bool GenerateTangent
{
- get { return VertexType.Contains(VertexMemberUsage.Tangent); }
+ get { return VertexType.ContainsElement(VertexElement.Tangent); }
}
bool GenerateBitangent
{
- get { return VertexType.Contains(VertexMemberUsage.Bitangent); }
+ get { return VertexType.ContainsElement(VertexElement.Bitangent); }
}
-
public VertexLayout VertexType { get; set; }
- public VertexBuffer CreateVertexBuffer()
+ public void CreateVertexBuffer()
{
- VertexBuffer retval = new VertexBuffer(VertexType, 24);
+ PositionTextureNTB[] vertices = new PositionTextureNTB[24];
- retval.PrimitiveType = PrimitiveType.TriangleList;
- retval.WriteVertexData(GetVertexData());
- retval.WriteIndices(GetIndexData());
+ mVertices = new VertexBuffer(VertexType, 24);
+ mIndices = new IndexBuffer(IndexBufferType.Int16, 36);
- if (GenerateTextureCoords)
- retval.WriteTextureCoords(GetTextureCoords());
- if (GenerateNormals)
- retval.WriteNormalData(GetNormals());
- if (GenerateTangent)
- retval.WriteAttributeData("tangent", GetTangent());
- if (GenerateBitangent)
- retval.WriteAttributeData("bitangent", GetBitangent());
+ mVertices.PrimitiveType = PrimitiveType.TriangleList;
- return retval;
+ GenerateVertexData(vertices);
+ GenerateNormalData(vertices);
+ GenerateTexCoordData(vertices);
+
+ mVertices.WriteVertexData(vertices);
+ mIndices.WriteIndices(GetIndexData());
+
}
@@ -130,77 +141,67 @@
return retval;
}
- private Vector3[] GetNormals()
+ private void GenerateNormalData(PositionTextureNTB[] vertices)
{
- Vector3[] retval = new Vector3[24];
-
int i = 0;
float length = Length / 2.0f;
for (int sign = -1; sign <= 1; sign += 2)
{
- retval[i++] = new Vector3(0, 0, sign);
- retval[i++] = new Vector3(0, 0, sign);
- retval[i++] = new Vector3(0, 0, sign);
- retval[i++] = new Vector3(0, 0, sign);
+ vertices[i++].Normal = new Vector3(0, 0, sign);
+ vertices[i++].Normal = new Vector3(0, 0, sign);
+ vertices[i++].Normal = new Vector3(0, 0, sign);
+ vertices[i++].Normal = new Vector3(0, 0, sign);
- retval[i++] = new Vector3(0, sign, 0);
- retval[i++] = new Vector3(0, sign, 0);
- retval[i++] = new Vector3(0, sign, 0);
- retval[i++] = new Vector3(0, sign, 0);
+ vertices[i++].Normal = new Vector3(0, sign, 0);
+ vertices[i++].Normal = new Vector3(0, sign, 0);
+ vertices[i++].Normal = new Vector3(0, sign, 0);
+ vertices[i++].Normal = new Vector3(0, sign, 0);
- retval[i++] = new Vector3(sign, 0, 0);
- retval[i++] = new Vector3(sign, 0, 0);
- retval[i++] = new Vector3(sign, 0, 0);
- retval[i++] = new Vector3(sign, 0, 0);
+ vertices[i++].Normal = new Vector3(sign, 0, 0);
+ vertices[i++].Normal = new Vector3(sign, 0, 0);
+ vertices[i++].Normal = new Vector3(sign, 0, 0);
+ vertices[i++].Normal = new Vector3(sign, 0, 0);
}
-
- return retval;
}
- protected virtual Vector3[] GetVertexData()
+
+
+ private void GenerateVertexData(PositionTextureNTB[] vertices)
{
- Vector3[] retval = new Vector3[24];
-
int i = 0;
float length = Length / 2.0f;
for (int sign = -1; sign <= 1; sign += 2)
{
- retval[i++] = new Vector3(length, length, sign * length);
- retval[i++] = new Vector3(length, -length, sign * length);
- retval[i++] = new Vector3(-length, length, sign * length);
- retval[i++] = new Vector3(-length, -length, sign * length);
+ vertices[i++].Position = new Vector3(length, length, sign * length);
+ vertices[i++].Position = new Vector3(length, -length, sign * length);
+ vertices[i++].Position = new Vector3(-length, length, sign * length);
+ vertices[i++].Position = new Vector3(-length, -length, sign * length);
- retval[i++] = new Vector3(length, sign * length, length);
- retval[i++] = new Vector3(length, sign * length, -length);
- retval[i++] = new Vector3(-length, sign * length, length);
- retval[i++] = new Vector3(-length, sign * length, -length);
+ vertices[i++].Position = new Vector3(length, sign * length, length);
+ vertices[i++].Position = new Vector3(length, sign * length, -length);
+ vertices[i++].Position = new Vector3(-length, sign * length, length);
+ vertices[i++].Position = new Vector3(-length, sign * length, -length);
- retval[i++] = new Vector3(sign * length, length, length);
- retval[i++] = new Vector3(sign * length, length, -length);
- retval[i++] = new Vector3(sign * length, -length, length);
- retval[i++] = new Vector3(sign * length, -length, -length);
+ vertices[i++].Position = new Vector3(sign * length, length, length);
+ vertices[i++].Position = new Vector3(sign * length, length, -length);
+ vertices[i++].Position = new Vector3(sign * length, -length, length);
+ vertices[i++].Position = new Vector3(sign * length, -length, -length);
}
- for (i = 0; i < retval.Length; i++)
- retval[i] += Location;
-
- return retval;
+ for (i = 0; i < vertices.Length; i++)
+ vertices[i].Position += Location;
}
- protected virtual Vector2[] GetTextureCoords()
+ private void GenerateTexCoordData(PositionTextureNTB[] vertices)
{
- Vector2[] retval = new Vector2[24];
-
int i = 0;
for (int face = 0; face < 6; face++)
{
- retval[i++] = new Vector2(0, 0);
- retval[i++] = new Vector2(0, 1);
- retval[i++] = new Vector2(1, 0);
- retval[i++] = new Vector2(1, 1);
+ vertices[i++].Texture = new Vector2(0, 0);
+ vertices[i++].Texture = new Vector2(0, 1);
+ vertices[i++].Texture = new Vector2(1, 0);
+ vertices[i++].Texture = new Vector2(1, 1);
}
-
- return retval;
}
}
}
\ No newline at end of file
Modified: branches/agate3d-3.2/AgateLib/Geometry/Builders/Terrain.cs
===================================================================
--- branches/agate3d-3.2/AgateLib/Geometry/Builders/Terrain.cs 2009-04-28 01:26:55 UTC (rev 924)
+++ branches/agate3d-3.2/AgateLib/Geometry/Builders/Terrain.cs 2009-04-28 08:25:11 UTC (rev 925)
@@ -3,6 +3,7 @@
using System.Linq;
using System.Text;
using AgateLib.DisplayLib;
+using AgateLib.Geometry.VertexTypes;
namespace AgateLib.Geometry.Builders
{
@@ -17,7 +18,7 @@
Height = 1;
MaxPeak = 1;
- VertexType = VertexLayout.PositionNormalTexture;
+ VertexType = PositionTextureNormal.VertexLayout;
}
/// <summary>
@@ -61,9 +62,9 @@
VertexBuffer retval = new VertexBuffer(VertexType, vertices.Length);
retval.WriteVertexData(vertices);
- retval.WriteTextureCoords(texture);
- retval.WriteNormalData(normal);
- retval.WriteIndices(indices);
+ //retval.WriteTextureCoords(texture);
+ //retval.WriteNormalData(normal);
+ //retval.WriteIndices(indices);
return retval;
}
Added: branches/agate3d-3.2/AgateLib/Geometry/VertexTypes/PositionTextureNTB.cs
===================================================================
--- branches/agate3d-3.2/AgateLib/Geometry/VertexTypes/PositionTextureNTB.cs (rev 0)
+++ branches/agate3d-3.2/AgateLib/Geometry/VertexTypes/PositionTextureNTB.cs 2009-04-28 08:25:11 UTC (rev 925)
@@ -0,0 +1,33 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Runtime.InteropServices;
+using System.Text;
+
+namespace AgateLib.Geometry.VertexTypes
+{
+ [StructLayout(LayoutKind.Sequential, Pack = 1)]
+ public struct PositionTextureNTB
+ {
+ public Vector3 Position;
+ public Vector2 Texture;
+ public Vector3 Normal;
+ public Vector3 Tangent;
+ public Vector3 Bitangent;
+
+ public static VertexLayout VertexLayout
+ {
+ get
+ {
+ return new VertexLayout
+ {
+ new VertexElementDesc(VertexElementDataType.Float3, VertexElement.Position),
+ new VertexElementDesc(VertexElementDataType.Float2, VertexElement.Texture),
+ new VertexElementDesc(VertexElementDataType.Float3, VertexElement.Normal),
+ new VertexElementDesc(VertexElementDataType.Float3, VertexElement.Tangent),
+ new VertexElementDesc(VertexElementDataType.Float3, VertexElement.Bitangent),
+ };
+ }
+ }
+ }
+}
Added: branches/agate3d-3.2/AgateLib/Geometry/VertexTypes/PositionTextureNormal.cs
===================================================================
--- branches/agate3d-3.2/AgateLib/Geometry/VertexTypes/PositionTextureNormal.cs (rev 0)
+++ branches/agate3d-3.2/AgateLib/Geometry/VertexTypes/PositionTextureNormal.cs 2009-04-28 08:25:11 UTC (rev 925)
@@ -0,0 +1,29 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Runtime.InteropServices;
+using System.Text;
+
+namespace AgateLib.Geometry.VertexTypes
+{
+ [StructLayout(LayoutKind.Sequential, Pack = 1)]
+ public class PositionTextureNormal
+ {
+ public Vector3 Position;
+ public Vector2 Texture;
+ public Vector3 Normal;
+
+ public static VertexLayout VertexLayout
+ {
+ get
+ {
+ return new VertexLayout
+ {
+ new VertexElementDesc(VertexElementDataType.Float3, VertexElement.Position),
+ new VertexElementDesc(VertexElementDataType.Float2, VertexElement.Texture),
+ new VertexElementDesc(VertexElementDataType.Float3, VertexElement.Normal),
+ };
+ }
+ }
+ }
+}
Added: branches/agate3d-3.2/AgateLib/Geometry/VertexTypes/VertexLayout.cs
===================================================================
--- branches/agate3d-3.2/AgateLib/Geometry/VertexTypes/VertexLayout.cs (rev 0)
+++ branches/agate3d-3.2/AgateLib/Geometry/VertexTypes/VertexLayout.cs 2009-04-28 08:25:11 UTC (rev 925)
@@ -0,0 +1,254 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace AgateLib.Geometry.VertexTypes
+{
+ public class VertexLayout : IList<VertexElementDesc>
+ {
+ List<VertexElementDesc> items = new List<VertexElementDesc>();
+
+ public int VertexSize
+ {
+ get
+ {
+ return this.Sum(x => x.ItemSize);
+ }
+ }
+
+ public VertexElementDesc GetElement(VertexElement element)
+ {
+ for (int i = 0; i < Count; i++)
+ {
+ if (this[i].ElementType == element)
+ return this[i];
+ }
+
+ throw new AgateException("Element {0} not found.", element);
+ }
+
+ public bool ContainsElement(VertexElement element)
+ {
+ return items.Any(x => x.ElementType == element);
+ }
+ public bool ContainsElement(string attributeName)
+ {
+ return items.Any(x => x.ElementType == VertexElement.Attribute && x.AttributeString == attributeName);
+ }
+ public int ElementByteIndex(VertexElement element)
+ {
+ int size = 0;
+
+ for (int i = 0; i < Count; i++)
+ {
+ if (this[i].ElementType == element)
+ return size;
+
+ size += this[i].ItemSize;
+ }
+
+ throw new AgateException("Could not find the element {0} in the vertex layout.", element);
+ }
+ public int ElementByteIndex(string attributeName)
+ {
+
+ int size = 0;
+
+ for (int i = 0; i < Count; i++)
+ {
+ if (this[i].ElementType == VertexElement.Attribute &&
+ this[i].AttributeString == attributeName)
+ {
+ return size;
+ }
+
+ size += SizeOf(this[i].DataType);
+ }
+
+ throw new AgateException("Could not find the attribute {0} in the vertex layout.", attributeName);
+ }
+
+ public static int SizeOf(VertexElementDataType vertexElementType)
+ {
+ switch (vertexElementType)
+ {
+ case VertexElementDataType.Float1: return 1 * sizeof(float);
+ case VertexElementDataType.Float2: return 2 * sizeof(float);
+ case VertexElementDataType.Float3: return 3 * sizeof(float);
+ case VertexElementDataType.Float4: return 4 * sizeof(float);
+
+ default: throw new NotImplementedException();
+ }
+ }
+
+ /*
+
+ public VertexLayout PositionNormal
+ {
+ get
+ {
+ return new VertexLayout
+ {
+ new VertexMember(VertexMemberType.Float3, VertexMemberUsage.Position),
+ new VertexMember(VertexMemberType.Float3, VertexMemberUsage.Normal),
+ };
+ }
+ }
+ public VertexLayout PositionTexture
+ {
+ get
+ {
+ return new VertexLayout
+ {
+ new VertexMember(VertexMemberType.Float3, VertexMemberUsage.Position),
+ new VertexMember(VertexMemberType.Float2, VertexMemberUsage.Texture),
+ };
+ }
+ }
+ */
+
+ #region --- IList<VertexMember> Members ---
+
+ int IList<VertexElementDesc>.IndexOf(VertexElementDesc item)
+ {
+ return items.IndexOf(item);
+ }
+ void IList<VertexElementDesc>.Insert(int index, VertexElementDesc item)
+ {
+ items.Insert(index, item);
+ }
+ public void RemoveAt(int index)
+ {
+ items.RemoveAt(index);
+ }
+ public VertexElementDesc this[int index]
+ {
+ get { return items[index]; }
+ set { items[index] = value; }
+ }
+
+ #endregion
+ #region --- ICollection<VertexMember> Members ---
+
+ public void Add(VertexElementDesc item)
+ {
+ items.Add(item);
+ }
+ public void Clear()
+ {
+ items.Clear();
+ }
+ bool ICollection<VertexElementDesc>.Contains(VertexElementDesc item)
+ {
+ return items.Contains(item);
+ }
+ public void CopyTo(VertexElementDesc[] array, int arrayIndex)
+ {
+ items.CopyTo(array, arrayIndex);
+ }
+
+ public int Count
+ {
+ get { return items.Count; }
+ }
+
+ bool ICollection<VertexElementDesc>.IsReadOnly
+ {
+ get { return false; }
+ }
+
+ bool ICollection<VertexElementDesc>.Remove(VertexElementDesc item)
+ {
+ return items.Remove(item);
+ }
+
+ #endregion
+ #region --- IEnumerable<VertexMember> Members ---
+
+ IEnumerator<VertexElementDesc> IEnumerable<VertexElementDesc>.GetEnumerator()
+ {
+ return items.GetEnumerator();
+ }
+
+ #endregion
+ #region --- IEnumerable Members ---
+
+ System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
+ {
+ return items.GetEnumerator();
+ }
+
+ #endregion
+
+ }
+ public class VertexElementDesc
+ {
+ VertexElement mDef;
+ string mAttributeString;
+
+ public VertexElementDesc(VertexElementDataType type, VertexElement def)
+ {
+ if (def == VertexElement.Attribute)
+ throw new AgateException("Use the (VertexMemberType, string) overload instead.");
+
+ DataType = type;
+ ElementType = def;
+ }
+ public VertexElementDesc(VertexElementDataType type, string attributeName)
+ {
+ DataType = type;
+ ElementType = VertexElement.Attribute;
+ AttributeString = attributeName;
+ }
+
+ public VertexElementDataType DataType { get; private set; }
+ public VertexElement ElementType
+ {
+ get { return mDef; }
+ private set
+ {
+ mDef = value;
+
+ if (mDef != VertexElement.Attribute)
+ mAttributeString = null;
+ }
+ }
+
+ public string AttributeString
+ {
+ get { return mAttributeString; }
+ private set
+ {
+ mAttributeString = value;
+ mDef = VertexElement.Attribute;
+ }
+ }
+
+ public int ItemSize
+ {
+ get { return VertexLayout.SizeOf(DataType); }
+ }
+ }
+
+ public enum VertexElementDataType
+ {
+ Float1,
+ Float2,
+ Float3,
+ Float4,
+ }
+ public enum VertexElement
+ {
+ Position,
+ Normal,
+ Tangent,
+ Bitangent,
+ Color,
+ Texture,
+ Texture1,
+ Texture2,
+ Texture3,
+ Attribute,
+ }
+}
Modified: branches/agate3d-3.2/AgateLib/ImplementationBase/DisplayImpl.cs
===================================================================
--- branches/agate3d-3.2/AgateLib/ImplementationBase/DisplayImpl.cs 2009-04-28 01:26:55 UTC (rev 924)
+++ branches/agate3d-3.2/AgateLib/ImplementationBase/DisplayImpl.cs 2009-04-28 08:25:11 UTC (rev 925)
@@ -596,11 +596,17 @@
protected internal abstract void HideCursor();
- protected internal virtual VertexBufferImpl CreateVertexBuffer(VertexLayout layout, int vertexCount)
+ protected internal virtual VertexBufferImpl CreateVertexBuffer(
+ Geometry.VertexTypes.VertexLayout layout, int vertexCount)
{
throw new AgateException("Cannot create a vertex buffer with a driver that does not support 3D.");
}
+ protected internal virtual IndexBufferImpl CreateIndexBuffer(IndexBufferType type, int size)
+ {
+ throw new AgateException("Cannot create an index buffer with a driver that does not support 3D.");
+ }
+
public virtual Matrix4 MatrixProjection
{
get { throw new AgateException("3D is not supported."); }
@@ -644,5 +650,6 @@
ShaderCompiler.Disable();
}
+
}
}
Added: branches/agate3d-3.2/AgateLib/ImplementationBase/IndexBufferImpl.cs
===================================================================
--- branches/agate3d-3.2/AgateLib/ImplementationBase/IndexBufferImpl.cs (rev 0)
+++ branches/agate3d-3.2/AgateLib/ImplementationBase/IndexBufferImpl.cs 2009-04-28 08:25:11 UTC (rev 925)
@@ -0,0 +1,18 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using AgateLib.DisplayLib;
+
+namespace AgateLib.ImplementationBase
+{
+ public abstract class IndexBufferImpl
+ {
+ public abstract void WriteIndices(short[] indices);
+ public abstract void WriteIndices(int[] indices);
+
+ public abstract int Count { get; }
+
+ public abstract IndexBufferType IndexType { get; }
+ }
+}
Modified: branches/agate3d-3.2/AgateLib/ImplementationBase/VertexBufferImpl.cs
===================================================================
--- branches/agate3d-3.2/AgateLib/ImplementationBase/VertexBufferImpl.cs 2009-04-28 01:26:55 UTC (rev 924)
+++ branches/agate3d-3.2/AgateLib/ImplementationBase/VertexBufferImpl.cs 2009-04-28 08:25:11 UTC (rev 925)
@@ -13,27 +13,14 @@
Textures = new TextureList();
}
- public abstract void WriteVertexData(Vector3[] data);
- public abstract void WriteTextureCoords(Vector2[] texCoords);
- public abstract void WriteNormalData(Vector3[] data);
- public abstract void WriteIndices(short[] indices);
- public abstract void WriteAttributeData(string attributeName, Vector3[] data);
+ public abstract void Write<T>(T[] vertices);
public abstract int VertexCount { get; }
- public abstract int IndexCount { get; }
- public virtual bool Indexed { get; set; }
-
public virtual PrimitiveType PrimitiveType { get; set; }
public TextureList Textures { get; set; }
- public virtual void Draw()
- {
- Draw(0, Indexed ? IndexCount : VertexCount);
- }
public abstract void Draw(int start, int count);
-
-
-
+ public abstract void DrawIndexed(IndexBuffer indexbuffer, int start, int count);
}
}
Modified: branches/agate3d-3.2/Drivers/AgateOTK/GL_Display.cs
===================================================================
--- branches/agate3d-3...
[truncated message content] |
|
From: <ka...@us...> - 2009-05-01 07:34:25
|
Revision: 930
http://agate.svn.sourceforge.net/agate/?rev=930&view=rev
Author: kanato
Date: 2009-05-01 07:34:20 +0000 (Fri, 01 May 2009)
Log Message:
-----------
Update AgateMDX with vertex/index buffer support. Not working right yet.
Modified Paths:
--------------
branches/agate3d-3.2/AgateLib/DisplayLib/IndexBuffer.cs
branches/agate3d-3.2/Drivers/AgateMDX/D3DDevice.cs
branches/agate3d-3.2/Drivers/AgateMDX/MDX1_Display.cs
branches/agate3d-3.2/Drivers/AgateMDX/MDX1_Surface.cs
branches/agate3d-3.2/Drivers/AgateMDX/MDX1_VertexBuffer.cs
branches/agate3d-3.2/Drivers/AgateOTK/GL_IndexBuffer.cs
branches/agate3d-3.2/Tests/Display3D/Matrices.cs
Added Paths:
-----------
branches/agate3d-3.2/Drivers/AgateMDX/MDX1_IndexBuffer.cs
Modified: branches/agate3d-3.2/AgateLib/DisplayLib/IndexBuffer.cs
===================================================================
--- branches/agate3d-3.2/AgateLib/DisplayLib/IndexBuffer.cs 2009-05-01 02:16:20 UTC (rev 929)
+++ branches/agate3d-3.2/AgateLib/DisplayLib/IndexBuffer.cs 2009-05-01 07:34:20 UTC (rev 930)
@@ -17,13 +17,63 @@
public void WriteIndices(short[] indices)
{
+ if (impl.IndexType == IndexBufferType.Int32)
+ {
+ WriteIndices(ConvertToInt32(indices));
+ return;
+ }
+
impl.WriteIndices(indices);
}
public void WriteIndices(int[] indices)
{
+ if (impl.IndexType == IndexBufferType.Int16)
+ {
+ WriteIndices(ConvertToInt16(indices));
+ return;
+ }
+
impl.WriteIndices(indices);
}
+ private short[] ConvertToInt16(int[] indices)
+ {
+ short[] retval = new short[indices.Length];
+
+ int i = 0;
+
+ try
+ {
+ checked
+ {
+ for (i = 0; i < retval.Length; i++)
+ {
+ retval[i] = (short)indices[i];
+ }
+ }
+ }
+ catch (OverflowException ex)
+ {
+ throw new AgateLib.AgateException(ex, string.Format(
+ "A 16 bit index buffer cannot contain values greater than {0}, " +
+ "but there is a value of {1} at index {2}.",
+ short.MaxValue, indices[i], i));
+ }
+
+ return retval;
+ }
+ private int[] ConvertToInt32(short[] indices)
+ {
+ int[] retval = new int[indices.Length];
+
+ for (int i = 0; i < retval.Length; i++)
+ {
+ retval[i] = (short)indices[i];
+ }
+
+ return retval;
+ }
+
public int Count
{
get { return impl.Count; }
Modified: branches/agate3d-3.2/Drivers/AgateMDX/D3DDevice.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateMDX/D3DDevice.cs 2009-05-01 02:16:20 UTC (rev 929)
+++ branches/agate3d-3.2/Drivers/AgateMDX/D3DDevice.cs 2009-05-01 07:34:20 UTC (rev 930)
@@ -32,7 +32,7 @@
public class D3DDevice : IDisposable
{
private Device mDevice;
- private Texture mLastTexture;
+ private Texture[] mLastTexture = new Texture[8];
private MDX1_IRenderTarget mRenderTarget;
private DrawBuffer mDrawBuffer;
@@ -46,6 +46,7 @@
private int mMaxLightsUsed = 0;
+
//VertexBuffer mSurfaceVB;
//const int NumVertices = 1000;
//int mSurfaceVBPointer = 0;
@@ -256,13 +257,16 @@
public void SetDeviceStateTexture(Texture texture)
{
-
- if (texture == mLastTexture)
+ SetDeviceStateTexture(texture, 0);
+ }
+ public void SetDeviceStateTexture(Texture texture, int index)
+ {
+ if (texture == mLastTexture[index])
return;
- mDevice.SetTexture(0, texture);
+ mDevice.SetTexture(index, texture);
- mLastTexture = texture;
+ mLastTexture[index] = texture;
if (texture != null)
{
@@ -349,7 +353,7 @@
mDevice.RenderState.AmbientMaterialSource = ColorSource.Color1;
mDevice.RenderState.AmbientColor = lights.Ambient.ToArgb();
-
+
//Material mat = new Material();
//mat.Diffuse = System.Drawing.Color.White;
Modified: branches/agate3d-3.2/Drivers/AgateMDX/MDX1_Display.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateMDX/MDX1_Display.cs 2009-05-01 02:16:20 UTC (rev 929)
+++ branches/agate3d-3.2/Drivers/AgateMDX/MDX1_Display.cs 2009-05-01 07:34:20 UTC (rev 930)
@@ -53,6 +53,10 @@
private bool mVSync = true;
+ private bool mHasDepth , mHasStencil;
+ private float mDepthClear = 0;
+ private int mStencilClear = 0;
+
#endregion
#region --- Creation / Destruction ---
@@ -96,20 +100,55 @@
if (caps.DeviceCaps.SupportsPureDevice)
flags |= Direct3D.CreateFlags.PureDevice;
- Device device = new Device
- (0, dtype, window.RenderTarget.TopLevelControl.Handle,
- flags, present);
+ Device device = new Device(0, dtype,
+ window.RenderTarget.TopLevelControl.Handle,
+ flags, present);
+ try
+ {
+ DepthFormat f = (DepthFormat)device.DepthStencilSurface.Description.Format;
+ SetHaveDepthStencil(f);
+ }
+ catch
+ {
+ mHasDepth = false;
+ mHasStencil = false;
+ }
+
device.DeviceLost += new EventHandler(mDevice_DeviceLost);
device.DeviceReset += new EventHandler(mDevice_DeviceReset);
mDevice = new D3DDevice(device);
+
// create primitive objects
mLine = new Direct3D.Line(device);
- //CreateSurfaceVB();
+ }
+ private void SetHaveDepthStencil(DepthFormat depthFormat)
+ {
+ switch (depthFormat)
+ {
+ case DepthFormat.D24X4S4:
+ case DepthFormat.D24S8:
+ case DepthFormat.D15S1:
+ mHasStencil = true;
+ mHasDepth = true;
+ break;
+
+ case DepthFormat.D24X8:
+ case DepthFormat.D32:
+ case DepthFormat.D16:
+ mHasStencil = false;
+ mHasDepth = true;
+ break;
+
+ default:
+ mHasDepth = false;
+ mHasStencil = false;
+ break;
+ }
}
public override void Dispose()
@@ -195,15 +234,6 @@
#region --- Creation of objects ---
- //public override DisplayWindowImpl CreateDisplayWindow(string title, int clientWidth, int clientHeight,
- // string iconFile, bool startFullScreen, bool allowResize)
- //{
- // return new MDX1_DisplayWindow(title, clientWidth, clientHeight, iconFile, startFullScreen, allowResize);
- //}
- //public override DisplayWindowImpl CreateDisplayWindow(System.Windows.Forms.Control renderTarget)
- //{
- // return new MDX1_DisplayWindow(renderTarget);
- //}
public override DisplayWindowImpl CreateDisplayWindow(CreateWindowParams windowParams)
{
return new MDX1_DisplayWindow(windowParams);
@@ -252,12 +282,10 @@
while (mClipRects.Count > 0)
PopClipRect();
-
mRenderTarget.EndRender();
}
-
#endregion
#region --- Clip Rect stuff ---
@@ -295,6 +323,9 @@
mDevice.Device.Viewport = view;
mCurrentClipRect = newClipRect;
+
+ mDevice.Device.RenderState.StencilEnable = false;
+ mDevice.Device.RenderState.ZBufferEnable = false;
SetOrthoProjection(newClipRect);
}
@@ -307,9 +338,7 @@
{
if (mClipRects.Count == 0)
{
-#if DEBUG
throw new Exception("You have popped the cliprect too many times.");
-#endif
}
else
{
@@ -323,11 +352,23 @@
#endregion
#region --- Methods for drawing to the back buffer ---
+ ClearFlags ClearFlags
+ {
+ get
+ {
+ ClearFlags retval = ClearFlags.Target;
+
+ if (mHasDepth) retval |= ClearFlags.ZBuffer;
+ if (mHasStencil) retval |= ClearFlags.Stencil;
+
+ return retval;
+ }
+ }
public override void Clear(Color color)
{
mDevice.DrawBuffer.Flush();
- mDevice.Clear(ClearFlags.Target, color.ToArgb(), 1.0f, 0);
+ mDevice.Clear(ClearFlags, color.ToArgb(), mDepthClear, mStencilClear);
}
public override void Clear(Color color, Rectangle rect)
{
@@ -336,7 +377,7 @@
System.Drawing.Rectangle[] rects = new System.Drawing.Rectangle[1];
rects[0] = Interop.Convert(rect);
- mDevice.Clear(ClearFlags.Target, color.ToArgb(), 1.0f, 0, rects);
+ mDevice.Clear(ClearFlags, color.ToArgb(), mDepthClear, mStencilClear, rects);
}
@@ -504,22 +545,12 @@
private PresentParameters CreateFullScreenPresentParameters(MDX1_DisplayWindow displayWindow,
int width, int height, int bpp)
{
- PresentParameters present = new PresentParameters();
+ PresentParameters present = CreateBasePresentParams(displayWindow);
- present.AutoDepthStencilFormat = DepthFormat.Unknown;
- present.EnableAutoDepthStencil = false;
- present.DeviceWindowHandle = displayWindow.RenderTarget.Handle;
- present.BackBufferWidth = width;
- present.BackBufferHeight = height;
present.SwapEffect = SwapEffect.Flip;
present.Windowed = false;
present.PresentFlag = PresentFlag.None;
- if (VSync)
- present.PresentationInterval = PresentInterval.Default;
- else
- present.PresentationInterval = PresentInterval.Immediate;
-
SelectBestDisplayMode(present, bpp);
return present;
@@ -528,16 +559,23 @@
private PresentParameters CreateWindowedPresentParameters(MDX1_DisplayWindow displayWindow,
int width, int height)
{
+ PresentParameters present = CreateBasePresentParams(displayWindow);
+
+ return present;
+ }
+
+ private PresentParameters CreateBasePresentParams(MDX1_DisplayWindow displayWindow)
+ {
PresentParameters present = new PresentParameters();
present.BackBufferCount = 1;
- present.AutoDepthStencilFormat = DepthFormat.Unknown;
- present.EnableAutoDepthStencil = false;
+ present.AutoDepthStencilFormat = GetDepthFormat(Format.A8R8G8B8);
+ present.EnableAutoDepthStencil = true;
present.DeviceWindowHandle = displayWindow.RenderTarget.Handle;
- present.BackBufferWidth = width;
- present.BackBufferHeight = height;
+ present.BackBufferWidth = displayWindow.Width;
+ present.BackBufferHeight = displayWindow.Height;
present.BackBufferFormat = Format.Unknown;
- present.SwapEffect = SwapEffect.Copy;
+ present.SwapEffect = SwapEffect.Discard;
present.Windowed = true;
present.PresentFlag = PresentFlag.LockableBackBuffer;
@@ -548,6 +586,52 @@
return present;
}
+ private DepthFormat GetDepthFormat(Format backbufferFormat)
+ {
+ DepthFormat[] formats = new DepthFormat[]
+ {
+ DepthFormat.D24S8,
+ DepthFormat.D24X4S4,
+ DepthFormat.D24X8,
+ DepthFormat.D15S1,
+ DepthFormat.D32,
+ DepthFormat.D16,
+ };
+
+ var adapter = Manager.Adapters.Default.Adapter;
+ Format deviceFormat = GetDeviceFormat(backbufferFormat);
+
+ foreach (var f in formats)
+ {
+ if (Manager.CheckDeviceFormat(adapter, DeviceType.Hardware, deviceFormat,
+ Usage.DepthStencil, ResourceType.Surface, f) == false)
+ {
+ continue;
+ }
+ if (Manager.CheckDepthStencilMatch(adapter, DeviceType.Hardware,
+ deviceFormat, backbufferFormat, f) == false)
+ {
+ continue;
+ }
+
+ return f;
+ }
+
+ return DepthFormat.Unknown;
+ }
+ private Format GetDeviceFormat(Format backbufferFormat)
+ {
+ switch (backbufferFormat)
+ {
+ case Format.A8R8G8B8: return Format.X8R8G8B8;
+ case Format.A8B8G8R8: return Format.X8B8G8R8;
+ case Format.A1R5G5B5: return Format.X1R5G5B5;
+
+ default:
+ return backbufferFormat;
+ }
+ }
+
public override ScreenMode[] EnumScreenModes()
{
List<ScreenMode> modes = new List<ScreenMode>();
@@ -839,11 +923,15 @@
Matrix4 world = Matrix4.Identity;
Matrix4 view = Matrix4.Identity;
- // TODO: Fix this
- protected override VertexBufferImpl CreateVertexBuffer(VertexLayout layout, int vertexCount)
+ protected override VertexBufferImpl CreateVertexBuffer(
+ AgateLib.Geometry.VertexTypes.VertexLayout layout, int vertexCount)
{
- return new MDX1_VertexBuffer(this);
+ return new MDX1_VertexBuffer(this, layout, vertexCount);
}
+ protected override IndexBufferImpl CreateIndexBuffer(IndexBufferType type, int size)
+ {
+ return new MDX1_IndexBuffer(this, type, size);
+ }
private Matrix TransformAgateMatrix(Matrix4 value)
{
Added: branches/agate3d-3.2/Drivers/AgateMDX/MDX1_IndexBuffer.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateMDX/MDX1_IndexBuffer.cs (rev 0)
+++ branches/agate3d-3.2/Drivers/AgateMDX/MDX1_IndexBuffer.cs 2009-05-01 07:34:20 UTC (rev 930)
@@ -0,0 +1,62 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using AgateLib.DisplayLib;
+using AgateLib.ImplementationBase;
+using Direct3D = Microsoft.DirectX.Direct3D;
+
+namespace AgateMDX
+{
+ class MDX1_IndexBuffer : IndexBufferImpl
+ {
+ MDX1_Display mDisplay;
+ IndexBufferType mType;
+ int mCount;
+ Direct3D.IndexBuffer mBuffer;
+
+ public MDX1_IndexBuffer(MDX1_Display disp, IndexBufferType type, int count)
+ {
+ mDisplay = disp;
+ mType = type;
+ mCount = count;
+
+ CreateIndexBuffer();
+ }
+
+ private void CreateIndexBuffer()
+ {
+ int indexSize = 2;
+
+ if (IndexType == IndexBufferType.Int32)
+ indexSize = 4;
+
+ mBuffer = new Microsoft.DirectX.Direct3D.IndexBuffer(
+ mDisplay.D3D_Device.Device,
+ mCount * indexSize,
+ Microsoft.DirectX.Direct3D.Usage.WriteOnly,
+ Microsoft.DirectX.Direct3D.Pool.Managed,
+ IndexType == IndexBufferType.Int16);
+ }
+
+ public override int Count
+ {
+ get { return mCount; }
+ }
+
+ public override AgateLib.DisplayLib.IndexBufferType IndexType
+ {
+ get { return mType; }
+ }
+
+ public override void WriteIndices(int[] indices)
+ {
+ mBuffer.SetData(indices, 0, Microsoft.DirectX.Direct3D.LockFlags.Discard);
+ }
+
+ public override void WriteIndices(short[] indices)
+ {
+ mBuffer.SetData(indices, 0, Microsoft.DirectX.Direct3D.LockFlags.Discard);
+ }
+ }
+}
Modified: branches/agate3d-3.2/Drivers/AgateMDX/MDX1_Surface.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateMDX/MDX1_Surface.cs 2009-05-01 02:16:20 UTC (rev 929)
+++ branches/agate3d-3.2/Drivers/AgateMDX/MDX1_Surface.cs 2009-05-01 07:34:20 UTC (rev 930)
@@ -65,6 +65,11 @@
#endregion
+ public Texture D3dTexture
+ {
+ get { return mTexture.Value; }
+ }
+
#region --- TextureCoordinates structure ---
struct TextureCoordinates
Modified: branches/agate3d-3.2/Drivers/AgateMDX/MDX1_VertexBuffer.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateMDX/MDX1_VertexBuffer.cs 2009-05-01 02:16:20 UTC (rev 929)
+++ branches/agate3d-3.2/Drivers/AgateMDX/MDX1_VertexBuffer.cs 2009-05-01 07:34:20 UTC (rev 930)
@@ -2,7 +2,9 @@
using System.Collections.Generic;
using System.Text;
using AgateLib;
+using AgateLib.DisplayLib;
using AgateLib.Geometry;
+using AgateLib.Geometry.VertexTypes;
using AgateLib.ImplementationBase;
using Direct3D = Microsoft.DirectX.Direct3D;
@@ -11,50 +13,209 @@
class MDX1_VertexBuffer : VertexBufferImpl
{
MDX1_Display mDisplay;
+ Direct3D.VertexBuffer mBuffer;
+ Direct3D.VertexDeclaration mDeclaration;
+ Direct3D.VertexFormats mFormats;
+ int mCount;
- public MDX1_VertexBuffer(MDX1_Display display)
+ public MDX1_VertexBuffer(MDX1_Display display, VertexLayout layout, int vertexCount)
{
mDisplay = display;
+ mCount = vertexCount;
+
+ mDeclaration = CreateVertexDeclaration(layout);
+ mFormats = CreateVertexFormats(layout);
+
+ mBuffer = new Microsoft.DirectX.Direct3D.VertexBuffer(
+ mDisplay.D3D_Device.Device,
+ vertexCount * layout.VertexSize,
+ Microsoft.DirectX.Direct3D.Usage.WriteOnly,
+ mFormats,
+ Direct3D.Pool.Managed);
}
+ private Direct3D.VertexFormats CreateVertexFormats(VertexLayout layout)
+ {
+ Direct3D.VertexFormats retval = Microsoft.DirectX.Direct3D.VertexFormats.None;
- public override void WriteNormalData(Vector3[] data)
- {
- throw new NotImplementedException();
+ foreach (var element in layout)
+ {
+ switch (element.ElementType)
+ {
+ case VertexElement.Position:
+ retval |= Microsoft.DirectX.Direct3D.VertexFormats.Position;
+ break;
+
+ case VertexElement.Texture:
+ retval |= Microsoft.DirectX.Direct3D.VertexFormats.Texture0;
+ break;
+
+ case VertexElement.Texture1:
+ retval |= Microsoft.DirectX.Direct3D.VertexFormats.Texture1;
+ break;
+
+ case VertexElement.Texture2:
+ retval |= Microsoft.DirectX.Direct3D.VertexFormats.Texture2;
+ break;
+
+ case VertexElement.Texture3:
+ retval |= Microsoft.DirectX.Direct3D.VertexFormats.Texture3;
+ break;
+
+ case VertexElement.Color:
+ retval |= Microsoft.DirectX.Direct3D.VertexFormats.Diffuse;
+ break;
+ }
+ }
+
+ return retval;
}
- public override void WriteTextureCoords(Vector2[] texCoords)
+ private Direct3D.VertexDeclaration CreateVertexDeclaration(VertexLayout layout)
{
- throw new NotImplementedException();
+ List<Direct3D.VertexElement> formats = new List<Microsoft.DirectX.Direct3D.VertexElement>();
+
+ for (int i = 0; i < layout.Count; i++)
+ {
+ var element = layout[i];
+ short loc = 0;
+ int size;
+
+ Direct3D.VertexElement d3d_element = ConvertElement(element, out size);
+ d3d_element.Offset = loc;
+ loc += (short)size;
+ }
+
+ formats.Add(Direct3D.VertexElement.VertexDeclarationEnd);
+
+ return new Direct3D.VertexDeclaration(
+ mDisplay.D3D_Device.Device, formats.ToArray());
}
- public override void WriteVertexData(Vector3[] data)
+ private Direct3D.VertexElement ConvertElement(VertexElementDesc element, out int size)
{
- throw new NotImplementedException();
+ Direct3D.DeclarationType declType;
+ Direct3D.DeclarationMethod declMethod = Microsoft.DirectX.Direct3D.DeclarationMethod.Default;
+ Direct3D.DeclarationUsage declUsage;
+
+ switch(element.DataType)
+ {
+ case VertexElementDataType.Float1:
+ declType = Microsoft.DirectX.Direct3D.DeclarationType.Float1;
+ break;
+ case VertexElementDataType.Float2:
+ declType = Microsoft.DirectX.Direct3D.DeclarationType.Float2;
+ break;
+ case VertexElementDataType.Float3:
+ declType = Microsoft.DirectX.Direct3D.DeclarationType.Float3;
+ break;
+ case VertexElementDataType.Float4:
+ declType = Microsoft.DirectX.Direct3D.DeclarationType.Float4;
+ break;
+ default:
+ throw new NotImplementedException(
+ element.DataType.ToString() + " not implemented.");
+ }
+
+ size = VertexLayout.SizeOf(element.DataType);
+
+ switch(element.ElementType)
+ {
+ case VertexElement.Position:
+ declUsage = Microsoft.DirectX.Direct3D.DeclarationUsage.Position;
+ break;
+ case VertexElement.Texture:
+ declUsage = Microsoft.DirectX.Direct3D.DeclarationUsage.TextureCoordinate;
+ break;
+ case VertexElement.Normal:
+ declUsage = Microsoft.DirectX.Direct3D.DeclarationUsage.Normal;
+ break;
+ case VertexElement.Tangent:
+ declUsage = Microsoft.DirectX.Direct3D.DeclarationUsage.Tangent;
+ break;
+ case VertexElement.Color:
+ declUsage = Microsoft.DirectX.Direct3D.DeclarationUsage.Color;
+ break;
+ case VertexElement.Bitangent:
+ declUsage = Microsoft.DirectX.Direct3D.DeclarationUsage.BiNormal;
+ break;
+ default:
+ throw new NotImplementedException(
+ element.ElementType.ToString() + " not implemented.");
+ }
+
+ return new Direct3D.VertexElement(0, 0, declType, declMethod, declUsage, 0);
}
- public override void WriteIndices(short[] indices)
+
+ private Direct3D.PrimitiveType GetPrimitiveType(ref int vertexCount)
{
- throw new NotImplementedException();
+ switch (this.PrimitiveType)
+ {
+ case PrimitiveType.TriangleFan:
+ vertexCount = vertexCount - 2;
+ return Microsoft.DirectX.Direct3D.PrimitiveType.TriangleFan;
+ case PrimitiveType.TriangleList:
+ vertexCount /= 3;
+ return Microsoft.DirectX.Direct3D.PrimitiveType.TriangleList;
+ case PrimitiveType.TriangleStrip:
+ vertexCount = vertexCount - 2;
+ return Microsoft.DirectX.Direct3D.PrimitiveType.TriangleStrip;
+ default:
+ throw new NotImplementedException(this.PrimitiveType.ToString() + " not implemented.");
+ }
}
- public override void Draw(int vertexStart, int vertexCount)
+ public override void Draw(int start, int count)
{
- throw new NotImplementedException();
+ int primitiveCount = count;
+
+ // after calling GetPrimitiveType, primitiveCount is the number of primitives
+ // instead of the number of vertices.
+ Direct3D.PrimitiveType primType = GetPrimitiveType(ref primitiveCount);
+
+ SetTextures();
+
+ mDisplay.D3D_Device.Device.SetStreamSource(0, mBuffer, 0);
+ mDisplay.D3D_Device.Device.VertexDeclaration = mDeclaration;
+ mDisplay.D3D_Device.Device.DrawPrimitives(primType, start, primitiveCount);
}
+ public override void DrawIndexed(IndexBuffer indexbuffer, int start, int count)
+ {
+ int primitiveCount = count;
- public override int IndexCount
+ // after calling GetPrimitiveType, count is the number of primitives
+ // instead of the number of vertices.
+ Direct3D.PrimitiveType primType = GetPrimitiveType(ref primitiveCount);
+
+ SetTextures();
+
+ mDisplay.D3D_Device.Device.SetStreamSource(0, mBuffer, 0);
+ mDisplay.D3D_Device.Device.VertexDeclaration = mDeclaration;
+ mDisplay.D3D_Device.Device.DrawIndexedPrimitives(primType, start, 0, count, 0, primitiveCount);
+ }
+
+ private void SetTextures()
{
- get { return 0; }
+ for (int i = 0; i < Textures.Count; i++)
+ {
+ if (Textures[i] == null)
+ mDisplay.D3D_Device.SetDeviceStateTexture(null, i);
+ else
+ {
+ MDX1_Surface surf = (MDX1_Surface)Textures[i].Impl;
+
+ mDisplay.D3D_Device.SetDeviceStateTexture(surf.D3dTexture, i);
+ }
+ }
}
public override int VertexCount
{
- get { return 0; }
+ get { return mCount; }
}
-
- public override void WriteAttributeData(string attributeName, Vector3[] data)
+ public override void Write<T>(T[] vertices)
{
- throw new NotImplementedException();
+ mBuffer.SetData(vertices, 0, Microsoft.DirectX.Direct3D.LockFlags.Discard);
}
}
}
Modified: branches/agate3d-3.2/Drivers/AgateOTK/GL_IndexBuffer.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateOTK/GL_IndexBuffer.cs 2009-05-01 02:16:20 UTC (rev 929)
+++ branches/agate3d-3.2/Drivers/AgateOTK/GL_IndexBuffer.cs 2009-05-01 07:34:20 UTC (rev 930)
@@ -46,33 +46,6 @@
GL.BindBuffer(BufferTarget.ElementArrayBuffer, mBufferID);
}
- private short[] ConvertToInt16(int[] indices)
- {
- short[] retval = new short[indices.Length];
-
- int i = 0;
-
- try
- {
- checked
- {
- for (i = 0; i < retval.Length; i++)
- {
- retval[i] = (short)indices[i];
- }
- }
- }
- catch (OverflowException ex)
- {
- throw new AgateLib.AgateException(ex, string.Format(
- "A 16 bit index buffer cannot contain values greater than {0}, " +
- "but there is a value of {1} at index {2}.",
- short.MaxValue, indices[i], i));
- }
-
- return retval;
- }
-
unsafe public override void WriteIndices(int[] indices)
{
if (indices.Length != Count)
@@ -80,10 +53,8 @@
"The size of the passed array must match the size of the index buffer.");
if (mType == IndexBufferType.Int16)
- {
- WriteIndices(ConvertToInt16(indices));
- return;
- }
+ throw new ArgumentException(
+ "Cannot write 32-bit data to a 16-bit buffer.");
Bind();
Modified: branches/agate3d-3.2/Tests/Display3D/Matrices.cs
===================================================================
--- branches/agate3d-3.2/Tests/Display3D/Matrices.cs 2009-05-01 02:16:20 UTC (rev 929)
+++ branches/agate3d-3.2/Tests/Display3D/Matrices.cs 2009-05-01 07:34:20 UTC (rev 930)
@@ -30,6 +30,7 @@
}
#endregion
+
static int matrixIndex = 1;
static int move, turn;
@@ -58,6 +59,7 @@
cube.Location = new Vector3(cube.Length / 2, cube.Length / 2, 0);
cube.CreateVertexBuffer();
+ IndexBuffer indices = cube.IndexBuffer;
VertexBuffer b = cube.VertexBuffer;
b.Textures[0] = surf;
@@ -111,7 +113,7 @@
break;
case 1:
- myproj = Matrix4.Projection(45, wind.Width / (float)wind.Height, 1f, 1000);
+ myproj = Matrix4.Projection(45, wind.Width / (float)wind.Height, 1f, 1000f);
myview = Matrix4.LookAt(position, lookTarget,
new Vector3(0, 0, 1));
@@ -136,7 +138,7 @@
Display.MatrixWorld = Matrix4.Translation(0, 0, 0);
m[0].Position = position;
- m.DoLighting();
+ //m.DoLighting();
// draw a weird checkerboard
for (int x = 0; x < 8; x += 2)
@@ -152,7 +154,7 @@
Display.DrawRect(new Rectangle(0, 0, 8, 8), Color.Black);
- b.Draw();
+ b.DrawIndexed(indices);
Display.EndFrame();
Core.KeepAlive();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ka...@us...> - 2009-05-01 07:55:12
|
Revision: 931
http://agate.svn.sourceforge.net/agate/?rev=931&view=rev
Author: kanato
Date: 2009-05-01 07:55:09 +0000 (Fri, 01 May 2009)
Log Message:
-----------
Update vertex buffer so local state info is updated correctly.
Modified Paths:
--------------
branches/agate3d-3.2/Drivers/AgateMDX/MDX1_Display.cs
branches/agate3d-3.2/Drivers/AgateMDX/MDX1_IndexBuffer.cs
branches/agate3d-3.2/Drivers/AgateMDX/MDX1_VertexBuffer.cs
branches/agate3d-3.2/Tests/Display3D/Matrices.cs
Modified: branches/agate3d-3.2/Drivers/AgateMDX/MDX1_Display.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateMDX/MDX1_Display.cs 2009-05-01 07:34:20 UTC (rev 930)
+++ branches/agate3d-3.2/Drivers/AgateMDX/MDX1_Display.cs 2009-05-01 07:55:09 UTC (rev 931)
@@ -120,7 +120,10 @@
mDevice = new D3DDevice(device);
-
+
+ mDevice.Device.RenderState.StencilEnable = false;
+ mDevice.Device.RenderState.ZBufferEnable = false;
+
// create primitive objects
mLine = new Direct3D.Line(device);
@@ -324,9 +327,6 @@
mDevice.Device.Viewport = view;
mCurrentClipRect = newClipRect;
- mDevice.Device.RenderState.StencilEnable = false;
- mDevice.Device.RenderState.ZBufferEnable = false;
-
SetOrthoProjection(newClipRect);
}
public override void PushClipRect(Rectangle newClipRect)
Modified: branches/agate3d-3.2/Drivers/AgateMDX/MDX1_IndexBuffer.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateMDX/MDX1_IndexBuffer.cs 2009-05-01 07:34:20 UTC (rev 930)
+++ branches/agate3d-3.2/Drivers/AgateMDX/MDX1_IndexBuffer.cs 2009-05-01 07:55:09 UTC (rev 931)
@@ -24,6 +24,11 @@
CreateIndexBuffer();
}
+ public Direct3D.IndexBuffer DeviceIndexBuffer
+ {
+ get { return mBuffer; }
+ }
+
private void CreateIndexBuffer()
{
int indexSize = 2;
Modified: branches/agate3d-3.2/Drivers/AgateMDX/MDX1_VertexBuffer.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateMDX/MDX1_VertexBuffer.cs 2009-05-01 07:34:20 UTC (rev 930)
+++ branches/agate3d-3.2/Drivers/AgateMDX/MDX1_VertexBuffer.cs 2009-05-01 07:55:09 UTC (rev 931)
@@ -173,14 +173,16 @@
SetTextures();
+
mDisplay.D3D_Device.Device.SetStreamSource(0, mBuffer, 0);
mDisplay.D3D_Device.Device.VertexDeclaration = mDeclaration;
mDisplay.D3D_Device.Device.DrawPrimitives(primType, start, primitiveCount);
}
- public override void DrawIndexed(IndexBuffer indexbuffer, int start, int count)
+ public override void DrawIndexed(IndexBuffer _indexbuffer, int start, int count)
{
int primitiveCount = count;
+ MDX1_IndexBuffer indexbuffer = _indexbuffer.Impl as MDX1_IndexBuffer;
// after calling GetPrimitiveType, count is the number of primitives
// instead of the number of vertices.
@@ -188,9 +190,12 @@
SetTextures();
+ mDisplay.D3D_Device.Device.Indices = indexbuffer.DeviceIndexBuffer;
mDisplay.D3D_Device.Device.SetStreamSource(0, mBuffer, 0);
+ mDisplay.D3D_Device.VertexFormat = mFormats;
mDisplay.D3D_Device.Device.VertexDeclaration = mDeclaration;
- mDisplay.D3D_Device.Device.DrawIndexedPrimitives(primType, start, 0, count, 0, primitiveCount);
+ mDisplay.D3D_Device.Device.DrawIndexedPrimitives(primType, 0, 0, count, start, primitiveCount);
+
}
private void SetTextures()
Modified: branches/agate3d-3.2/Tests/Display3D/Matrices.cs
===================================================================
--- branches/agate3d-3.2/Tests/Display3D/Matrices.cs 2009-05-01 07:34:20 UTC (rev 930)
+++ branches/agate3d-3.2/Tests/Display3D/Matrices.cs 2009-05-01 07:55:09 UTC (rev 931)
@@ -153,13 +153,10 @@
}
Display.DrawRect(new Rectangle(0, 0, 8, 8), Color.Black);
-
b.DrawIndexed(indices);
Display.EndFrame();
Core.KeepAlive();
-
-
}
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ka...@us...> - 2009-05-07 04:18:19
|
Revision: 958
http://agate.svn.sourceforge.net/agate/?rev=958&view=rev
Author: kanato
Date: 2009-05-07 04:17:58 +0000 (Thu, 07 May 2009)
Log Message:
-----------
Introduce HLSL classes.
Modified Paths:
--------------
branches/agate3d-3.2/AgateLib/DisplayLib/Shaders/ShaderLanguage.cs
branches/agate3d-3.2/AgateLib/ImplementationBase/DisplayImpl.cs
branches/agate3d-3.2/Drivers/AgateMDX/DrawBuffer.cs
branches/agate3d-3.2/Drivers/AgateMDX/MDX1_Display.cs
branches/agate3d-3.2/Drivers/AgateOTK/GL_Display.cs
branches/agate3d-3.2/Tests/Display3D/Glsl.cs
Added Paths:
-----------
branches/agate3d-3.2/Drivers/AgateMDX/HlslCompiler.cs
branches/agate3d-3.2/Drivers/AgateMDX/HlslShaderProgram.cs
branches/agate3d-3.2/Tests/Data/shaders/glsl/
branches/agate3d-3.2/Tests/Data/shaders/glsl/BumpMap_fragment.txt
branches/agate3d-3.2/Tests/Data/shaders/glsl/BumpMap_vertex.txt
branches/agate3d-3.2/Tests/Data/shaders/glsl/PerPixelLighting_fragment.txt
branches/agate3d-3.2/Tests/Data/shaders/glsl/PerPixelLighting_vertex.txt
branches/agate3d-3.2/Tests/Data/shaders/hlsl/
branches/agate3d-3.2/Tests/Data/shaders/hlsl/PerPixelLighting_fragment.txt
branches/agate3d-3.2/Tests/Data/shaders/hlsl/PerPixelLighting_vertex.txt
branches/agate3d-3.2/Tests/Display3D/Hlsl.cs
Removed Paths:
-------------
branches/agate3d-3.2/Tests/Data/shaders/BumpMap_fragment.txt
branches/agate3d-3.2/Tests/Data/shaders/BumpMap_vertex.txt
branches/agate3d-3.2/Tests/Data/shaders/PerPixelLighting_fragment.txt
branches/agate3d-3.2/Tests/Data/shaders/PerPixelLighting_vertex.txt
Modified: branches/agate3d-3.2/AgateLib/DisplayLib/Shaders/ShaderLanguage.cs
===================================================================
--- branches/agate3d-3.2/AgateLib/DisplayLib/Shaders/ShaderLanguage.cs 2009-05-07 02:02:28 UTC (rev 957)
+++ branches/agate3d-3.2/AgateLib/DisplayLib/Shaders/ShaderLanguage.cs 2009-05-07 04:17:58 UTC (rev 958)
@@ -10,7 +10,7 @@
Unknown,
Glsl,
- // Hlsl,
+ Hlsl,
// Cg,
}
Modified: branches/agate3d-3.2/AgateLib/ImplementationBase/DisplayImpl.cs
===================================================================
--- branches/agate3d-3.2/AgateLib/ImplementationBase/DisplayImpl.cs 2009-05-07 02:02:28 UTC (rev 957)
+++ branches/agate3d-3.2/AgateLib/ImplementationBase/DisplayImpl.cs 2009-05-07 04:17:58 UTC (rev 958)
@@ -650,6 +650,5 @@
ShaderCompiler.Disable();
}
-
}
}
Modified: branches/agate3d-3.2/Drivers/AgateMDX/DrawBuffer.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateMDX/DrawBuffer.cs 2009-05-07 02:02:28 UTC (rev 957)
+++ branches/agate3d-3.2/Drivers/AgateMDX/DrawBuffer.cs 2009-05-07 04:17:58 UTC (rev 958)
@@ -46,7 +46,6 @@
Texture mTexture;
bool mAlphaBlend;
-
public DrawBuffer(D3DDevice device)
{
mDevice = device;
Added: branches/agate3d-3.2/Drivers/AgateMDX/HlslCompiler.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateMDX/HlslCompiler.cs (rev 0)
+++ branches/agate3d-3.2/Drivers/AgateMDX/HlslCompiler.cs 2009-05-07 04:17:58 UTC (rev 958)
@@ -0,0 +1,26 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using AgateLib.DisplayLib.Shaders;
+using AgateLib.ImplementationBase;
+
+namespace AgateMDX
+{
+ class HlslCompiler : ShaderCompilerImpl
+ {
+ MDX1_Display mDisplay;
+
+ public HlslCompiler(MDX1_Display display)
+ {
+ mDisplay = display;
+ }
+
+ public override ShaderProgram CompileShader(ShaderLanguage language, string vertexShaderSource, string pixelShaderSource)
+ {
+ throw new NotImplementedException();
+
+ //return new HlslShaderProgram();
+ }
+ }
+}
Added: branches/agate3d-3.2/Drivers/AgateMDX/HlslShaderProgram.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateMDX/HlslShaderProgram.cs (rev 0)
+++ branches/agate3d-3.2/Drivers/AgateMDX/HlslShaderProgram.cs 2009-05-07 04:17:58 UTC (rev 958)
@@ -0,0 +1,43 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using AgateLib.DisplayLib.Shaders;
+
+namespace AgateMDX
+{
+ class HlslShaderProgram : ShaderProgram
+ {
+ public override PixelShader PixelShader
+ {
+ get { throw new NotImplementedException(); }
+ }
+
+ public override void SetUniform(string name, AgateLib.Geometry.Matrix4 matrix)
+ {
+ throw new NotImplementedException();
+ }
+
+ public override void SetUniform(string name, params int[] v)
+ {
+ throw new NotImplementedException();
+ }
+
+ public override void SetUniform(string name, params float[] v)
+ {
+ throw new NotImplementedException();
+ }
+
+ public override VertexShader VertexShader
+ {
+ get { throw new NotImplementedException(); }
+ }
+ }
+
+ class HlslPixelShader : PixelShader
+ {
+ }
+
+ class HlslVertexShader : VertexShader
+ { }
+}
Modified: branches/agate3d-3.2/Drivers/AgateMDX/MDX1_Display.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateMDX/MDX1_Display.cs 2009-05-07 02:02:28 UTC (rev 957)
+++ branches/agate3d-3.2/Drivers/AgateMDX/MDX1_Display.cs 2009-05-07 04:17:58 UTC (rev 958)
@@ -121,6 +121,7 @@
mDevice = new D3DDevice(device);
+ InitializeShaders();
}
@@ -239,6 +240,10 @@
{
return BitmapFontUtil.ConstructFromOSFont(bitmapOptions);
}
+ protected override ShaderCompilerImpl CreateShaderCompiler()
+ {
+ return new HlslCompiler(this);
+ }
#endregion
@@ -882,12 +887,12 @@
}
bool IDisplayCaps.SupportsShaders
{
- get { return false; }
+ get { return true; }
}
AgateLib.DisplayLib.Shaders.ShaderLanguage IDisplayCaps.ShaderLanguage
{
- get { return AgateLib.DisplayLib.Shaders.ShaderLanguage.Unknown; }
+ get { return AgateLib.DisplayLib.Shaders.ShaderLanguage.Hlsl; }
}
#endregion
Modified: branches/agate3d-3.2/Drivers/AgateOTK/GL_Display.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateOTK/GL_Display.cs 2009-05-07 02:02:28 UTC (rev 957)
+++ branches/agate3d-3.2/Drivers/AgateOTK/GL_Display.cs 2009-05-07 04:17:58 UTC (rev 958)
@@ -428,8 +428,7 @@
mSupportsShaders = true;
}
- if (mSupportsShaders)
- InitializeShaders();
+ InitializeShaders();
glInitialized = true;
Deleted: branches/agate3d-3.2/Tests/Data/shaders/BumpMap_fragment.txt
===================================================================
--- branches/agate3d-3.2/Tests/Data/shaders/BumpMap_fragment.txt 2009-05-07 02:02:28 UTC (rev 957)
+++ branches/agate3d-3.2/Tests/Data/shaders/BumpMap_fragment.txt 2009-05-07 04:17:58 UTC (rev 958)
@@ -1,46 +0,0 @@
-varying vec4 diffuse,ambientGlobal, ambient;
-varying vec3 normal,lightDir,halfVector;
-varying float dist;
-uniform sampler2D texture0;
-uniform sampler2D texture1;
-
-void main()
-{
- vec3 n,halfV,viewV,ldir;
- float NdotL,NdotHV;
- vec4 color = ambientGlobal;
- float att;
-
- /* a fragment shader can't write a varying variable, hence we need
- a new variable to store the normalized interpolated normal */
- n = normalize(normal);
-
- // calculate the bumpmap properties
- vec4 bumpcolor = texture2D(texture1,gl_TexCoord[0].st);
- bumpcolor = bumpcolor * 2.0 - 1.0;
- n = normalize(bumpcolor.rgb);
- //n = vec3(0.707,0,0.707);
-
- /* compute the dot product between normal and normalized lightdir */
- NdotL = max(dot(n,normalize(lightDir)),0.0);
-
- if (NdotL > 0.0) {
- att = 1.0 / (gl_LightSource[0].constantAttenuation +
- gl_LightSource[0].linearAttenuation * dist +
- gl_LightSource[0].quadraticAttenuation * dist * dist);
-
- color += att * (diffuse * NdotL + ambient);
-
- halfV = normalize(halfVector);
- NdotHV = max(dot(n,halfV),0.0);
- color += att * gl_FrontMaterial.specular * gl_LightSource[0].specular *
- pow(NdotHV,gl_FrontMaterial.shininess);
- }
-
- vec4 texcolor = texture2D(texture0,gl_TexCoord[0].st);
-
- color.rgb *= texcolor.rgb;
-
- gl_FragColor = color;
-}
-
Deleted: branches/agate3d-3.2/Tests/Data/shaders/BumpMap_vertex.txt
===================================================================
--- branches/agate3d-3.2/Tests/Data/shaders/BumpMap_vertex.txt 2009-05-07 02:02:28 UTC (rev 957)
+++ branches/agate3d-3.2/Tests/Data/shaders/BumpMap_vertex.txt 2009-05-07 04:17:58 UTC (rev 958)
@@ -1,43 +0,0 @@
-
-attribute vec3 tangent; //The inverse tangent to the geometry
-attribute vec3 bitangent; //The inverse binormal to the geometry
-
-varying vec4 diffuse,ambientGlobal,ambient;
-varying vec3 normal,lightDir,halfVector;
-varying float dist;
-
-void main()
-{
- vec3 aux;
-
- normal = normalize(gl_Normal);
-
- // Building the matrix Eye Space -> Tangent Space
- vec3 n = normalize (gl_NormalMatrix * gl_Normal);
- vec3 t = normalize (gl_NormalMatrix * tangent);
- vec3 b = normalize (gl_NormalMatrix * bitangent);
-
- vec4 evPos = gl_ModelViewMatrix * gl_Vertex;
- vec3 lightVec = vec3(gl_LightSource[0].position.xyz - evPos.xyz);
-
- vec3 v;
- v.x = dot(lightVec, t);
- v.y = dot(lightVec, b);
- v.z = dot(lightVec, n);
- lightDir = normalize(v);
-
- dist = length(lightVec);
-
- halfVector = normalize(gl_LightSource[0].halfVector.xyz);
-
- /* Compute the diffuse, ambient and globalAmbient terms */
- diffuse = gl_FrontMaterial.diffuse * gl_LightSource[0].diffuse;
-
- /* The ambient terms have been separated since one of them */
- /* suffers attenuation */
- ambient = gl_FrontMaterial.ambient * gl_LightSource[0].ambient;
- ambientGlobal = gl_LightModel.ambient * gl_FrontMaterial.ambient;
-
- gl_Position = ftransform();
- gl_TexCoord[0] = gl_MultiTexCoord0;
-}
Deleted: branches/agate3d-3.2/Tests/Data/shaders/PerPixelLighting_fragment.txt
===================================================================
--- branches/agate3d-3.2/Tests/Data/shaders/PerPixelLighting_fragment.txt 2009-05-07 02:02:28 UTC (rev 957)
+++ branches/agate3d-3.2/Tests/Data/shaders/PerPixelLighting_fragment.txt 2009-05-07 04:17:58 UTC (rev 958)
@@ -1,40 +0,0 @@
-varying vec4 diffuse,ambientGlobal, ambient;
-varying vec3 normal,lightDir,halfVector;
-varying float dist;
-uniform sampler2D texture0;
-
-
-void main()
-{
- vec3 n,halfV,viewV,ldir;
- float NdotL,NdotHV;
- vec4 color = ambientGlobal;
- float att;
-
- /* a fragment shader can't write a varying variable, hence we need
- a new variable to store the normalized interpolated normal */
- n = normalize(normal);
-
- /* compute the dot product between normal and normalized lightdir */
- NdotL = max(dot(n,normalize(lightDir)),0.0);
-
- if (NdotL > 0.0) {
- att = 1.0 / (gl_LightSource[0].constantAttenuation +
- gl_LightSource[0].linearAttenuation * dist +
- gl_LightSource[0].quadraticAttenuation * dist * dist);
-
- color += att * (diffuse * NdotL + ambient);
-
- halfV = normalize(halfVector);
- NdotHV = max(dot(n,halfV),0.0);
- color += att * gl_FrontMaterial.specular * gl_LightSource[0].specular *
- pow(NdotHV,gl_FrontMaterial.shininess);
- }
-
- vec4 texcolor = texture2D(texture0,gl_TexCoord[0].st);
-
- color.rgb *= texcolor.rgb;
-
- gl_FragColor = color;
-}
-
Deleted: branches/agate3d-3.2/Tests/Data/shaders/PerPixelLighting_vertex.txt
===================================================================
--- branches/agate3d-3.2/Tests/Data/shaders/PerPixelLighting_vertex.txt 2009-05-07 02:02:28 UTC (rev 957)
+++ branches/agate3d-3.2/Tests/Data/shaders/PerPixelLighting_vertex.txt 2009-05-07 04:17:58 UTC (rev 958)
@@ -1,31 +0,0 @@
-varying vec4 diffuse,ambientGlobal,ambient;
-varying vec3 normal,lightDir,halfVector;
-varying float dist;
-
-void main()
-{
- vec4 ecPos;
- vec3 aux;
-
- normal = normalize(gl_NormalMatrix * gl_Normal);
-
- /* these are the new lines of code to compute the light's direction */
- ecPos = gl_ModelViewMatrix * gl_Vertex;
- aux = vec3(gl_LightSource[0].position-ecPos);
- lightDir = normalize(aux);
- dist = length(aux);
-
- halfVector = normalize(gl_LightSource[0].halfVector.xyz);
-
- /* Compute the diffuse, ambient and globalAmbient terms */
- diffuse = gl_FrontMaterial.diffuse * gl_LightSource[0].diffuse;
-
- /* The ambient terms have been separated since one of them */
- /* suffers attenuation */
- ambient = gl_FrontMaterial.ambient * gl_LightSource[0].ambient;
- ambientGlobal = gl_LightModel.ambient * gl_FrontMaterial.ambient;
-
-
- gl_Position = ftransform();
- gl_TexCoord[0] = gl_MultiTexCoord0;
-}
Copied: branches/agate3d-3.2/Tests/Data/shaders/glsl/BumpMap_fragment.txt (from rev 924, branches/agate3d-3.2/Tests/Data/shaders/BumpMap_fragment.txt)
===================================================================
--- branches/agate3d-3.2/Tests/Data/shaders/glsl/BumpMap_fragment.txt (rev 0)
+++ branches/agate3d-3.2/Tests/Data/shaders/glsl/BumpMap_fragment.txt 2009-05-07 04:17:58 UTC (rev 958)
@@ -0,0 +1,46 @@
+varying vec4 diffuse,ambientGlobal, ambient;
+varying vec3 normal,lightDir,halfVector;
+varying float dist;
+uniform sampler2D texture0;
+uniform sampler2D texture1;
+
+void main()
+{
+ vec3 n,halfV,viewV,ldir;
+ float NdotL,NdotHV;
+ vec4 color = ambientGlobal;
+ float att;
+
+ /* a fragment shader can't write a varying variable, hence we need
+ a new variable to store the normalized interpolated normal */
+ n = normalize(normal);
+
+ // calculate the bumpmap properties
+ vec4 bumpcolor = texture2D(texture1,gl_TexCoord[0].st);
+ bumpcolor = bumpcolor * 2.0 - 1.0;
+ n = normalize(bumpcolor.rgb);
+ //n = vec3(0.707,0,0.707);
+
+ /* compute the dot product between normal and normalized lightdir */
+ NdotL = max(dot(n,normalize(lightDir)),0.0);
+
+ if (NdotL > 0.0) {
+ att = 1.0 / (gl_LightSource[0].constantAttenuation +
+ gl_LightSource[0].linearAttenuation * dist +
+ gl_LightSource[0].quadraticAttenuation * dist * dist);
+
+ color += att * (diffuse * NdotL + ambient);
+
+ halfV = normalize(halfVector);
+ NdotHV = max(dot(n,halfV),0.0);
+ color += att * gl_FrontMaterial.specular * gl_LightSource[0].specular *
+ pow(NdotHV,gl_FrontMaterial.shininess);
+ }
+
+ vec4 texcolor = texture2D(texture0,gl_TexCoord[0].st);
+
+ color.rgb *= texcolor.rgb;
+
+ gl_FragColor = color;
+}
+
Copied: branches/agate3d-3.2/Tests/Data/shaders/glsl/BumpMap_vertex.txt (from rev 924, branches/agate3d-3.2/Tests/Data/shaders/BumpMap_vertex.txt)
===================================================================
--- branches/agate3d-3.2/Tests/Data/shaders/glsl/BumpMap_vertex.txt (rev 0)
+++ branches/agate3d-3.2/Tests/Data/shaders/glsl/BumpMap_vertex.txt 2009-05-07 04:17:58 UTC (rev 958)
@@ -0,0 +1,43 @@
+
+attribute vec3 tangent; //The inverse tangent to the geometry
+attribute vec3 bitangent; //The inverse binormal to the geometry
+
+varying vec4 diffuse,ambientGlobal,ambient;
+varying vec3 normal,lightDir,halfVector;
+varying float dist;
+
+void main()
+{
+ vec3 aux;
+
+ normal = normalize(gl_Normal);
+
+ // Building the matrix Eye Space -> Tangent Space
+ vec3 n = normalize (gl_NormalMatrix * gl_Normal);
+ vec3 t = normalize (gl_NormalMatrix * tangent);
+ vec3 b = normalize (gl_NormalMatrix * bitangent);
+
+ vec4 evPos = gl_ModelViewMatrix * gl_Vertex;
+ vec3 lightVec = vec3(gl_LightSource[0].position.xyz - evPos.xyz);
+
+ vec3 v;
+ v.x = dot(lightVec, t);
+ v.y = dot(lightVec, b);
+ v.z = dot(lightVec, n);
+ lightDir = normalize(v);
+
+ dist = length(lightVec);
+
+ halfVector = normalize(gl_LightSource[0].halfVector.xyz);
+
+ /* Compute the diffuse, ambient and globalAmbient terms */
+ diffuse = gl_FrontMaterial.diffuse * gl_LightSource[0].diffuse;
+
+ /* The ambient terms have been separated since one of them */
+ /* suffers attenuation */
+ ambient = gl_FrontMaterial.ambient * gl_LightSource[0].ambient;
+ ambientGlobal = gl_LightModel.ambient * gl_FrontMaterial.ambient;
+
+ gl_Position = ftransform();
+ gl_TexCoord[0] = gl_MultiTexCoord0;
+}
Copied: branches/agate3d-3.2/Tests/Data/shaders/glsl/PerPixelLighting_fragment.txt (from rev 924, branches/agate3d-3.2/Tests/Data/shaders/PerPixelLighting_fragment.txt)
===================================================================
--- branches/agate3d-3.2/Tests/Data/shaders/glsl/PerPixelLighting_fragment.txt (rev 0)
+++ branches/agate3d-3.2/Tests/Data/shaders/glsl/PerPixelLighting_fragment.txt 2009-05-07 04:17:58 UTC (rev 958)
@@ -0,0 +1,40 @@
+varying vec4 diffuse,ambientGlobal, ambient;
+varying vec3 normal,lightDir,halfVector;
+varying float dist;
+uniform sampler2D texture0;
+
+
+void main()
+{
+ vec3 n,halfV,viewV,ldir;
+ float NdotL,NdotHV;
+ vec4 color = ambientGlobal;
+ float att;
+
+ /* a fragment shader can't write a varying variable, hence we need
+ a new variable to store the normalized interpolated normal */
+ n = normalize(normal);
+
+ /* compute the dot product between normal and normalized lightdir */
+ NdotL = max(dot(n,normalize(lightDir)),0.0);
+
+ if (NdotL > 0.0) {
+ att = 1.0 / (gl_LightSource[0].constantAttenuation +
+ gl_LightSource[0].linearAttenuation * dist +
+ gl_LightSource[0].quadraticAttenuation * dist * dist);
+
+ color += att * (diffuse * NdotL + ambient);
+
+ halfV = normalize(halfVector);
+ NdotHV = max(dot(n,halfV),0.0);
+ color += att * gl_FrontMaterial.specular * gl_LightSource[0].specular *
+ pow(NdotHV,gl_FrontMaterial.shininess);
+ }
+
+ vec4 texcolor = texture2D(texture0,gl_TexCoord[0].st);
+
+ color.rgb *= texcolor.rgb;
+
+ gl_FragColor = color;
+}
+
Copied: branches/agate3d-3.2/Tests/Data/shaders/glsl/PerPixelLighting_vertex.txt (from rev 924, branches/agate3d-3.2/Tests/Data/shaders/PerPixelLighting_vertex.txt)
===================================================================
--- branches/agate3d-3.2/Tests/Data/shaders/glsl/PerPixelLighting_vertex.txt (rev 0)
+++ branches/agate3d-3.2/Tests/Data/shaders/glsl/PerPixelLighting_vertex.txt 2009-05-07 04:17:58 UTC (rev 958)
@@ -0,0 +1,31 @@
+varying vec4 diffuse,ambientGlobal,ambient;
+varying vec3 normal,lightDir,halfVector;
+varying float dist;
+
+void main()
+{
+ vec4 ecPos;
+ vec3 aux;
+
+ normal = normalize(gl_NormalMatrix * gl_Normal);
+
+ /* these are the new lines of code to compute the light's direction */
+ ecPos = gl_ModelViewMatrix * gl_Vertex;
+ aux = vec3(gl_LightSource[0].position-ecPos);
+ lightDir = normalize(aux);
+ dist = length(aux);
+
+ halfVector = normalize(gl_LightSource[0].halfVector.xyz);
+
+ /* Compute the diffuse, ambient and globalAmbient terms */
+ diffuse = gl_FrontMaterial.diffuse * gl_LightSource[0].diffuse;
+
+ /* The ambient terms have been separated since one of them */
+ /* suffers attenuation */
+ ambient = gl_FrontMaterial.ambient * gl_LightSource[0].ambient;
+ ambientGlobal = gl_LightModel.ambient * gl_FrontMaterial.ambient;
+
+
+ gl_Position = ftransform();
+ gl_TexCoord[0] = gl_MultiTexCoord0;
+}
Copied: branches/agate3d-3.2/Tests/Data/shaders/hlsl/PerPixelLighting_fragment.txt (from rev 924, branches/agate3d-3.2/Tests/Data/shaders/PerPixelLighting_fragment.txt)
===================================================================
--- branches/agate3d-3.2/Tests/Data/shaders/hlsl/PerPixelLighting_fragment.txt (rev 0)
+++ branches/agate3d-3.2/Tests/Data/shaders/hlsl/PerPixelLighting_fragment.txt 2009-05-07 04:17:58 UTC (rev 958)
@@ -0,0 +1,40 @@
+varying vec4 diffuse,ambientGlobal, ambient;
+varying vec3 normal,lightDir,halfVector;
+varying float dist;
+uniform sampler2D texture0;
+
+
+void main()
+{
+ vec3 n,halfV,viewV,ldir;
+ float NdotL,NdotHV;
+ vec4 color = ambientGlobal;
+ float att;
+
+ /* a fragment shader can't write a varying variable, hence we need
+ a new variable to store the normalized interpolated normal */
+ n = normalize(normal);
+
+ /* compute the dot product between normal and normalized lightdir */
+ NdotL = max(dot(n,normalize(lightDir)),0.0);
+
+ if (NdotL > 0.0) {
+ att = 1.0 / (gl_LightSource[0].constantAttenuation +
+ gl_LightSource[0].linearAttenuation * dist +
+ gl_LightSource[0].quadraticAttenuation * dist * dist);
+
+ color += att * (diffuse * NdotL + ambient);
+
+ halfV = normalize(halfVector);
+ NdotHV = max(dot(n,halfV),0.0);
+ color += att * gl_FrontMaterial.specular * gl_LightSource[0].specular *
+ pow(NdotHV,gl_FrontMaterial.shininess);
+ }
+
+ vec4 texcolor = texture2D(texture0,gl_TexCoord[0].st);
+
+ color.rgb *= texcolor.rgb;
+
+ gl_FragColor = color;
+}
+
Copied: branches/agate3d-3.2/Tests/Data/shaders/hlsl/PerPixelLighting_vertex.txt (from rev 924, branches/agate3d-3.2/Tests/Data/shaders/PerPixelLighting_vertex.txt)
===================================================================
--- branches/agate3d-3.2/Tests/Data/shaders/hlsl/PerPixelLighting_vertex.txt (rev 0)
+++ branches/agate3d-3.2/Tests/Data/shaders/hlsl/PerPixelLighting_vertex.txt 2009-05-07 04:17:58 UTC (rev 958)
@@ -0,0 +1,31 @@
+varying vec4 diffuse,ambientGlobal,ambient;
+varying vec3 normal,lightDir,halfVector;
+varying float dist;
+
+void main()
+{
+ vec4 ecPos;
+ vec3 aux;
+
+ normal = normalize(gl_NormalMatrix * gl_Normal);
+
+ /* these are the new lines of code to compute the light's direction */
+ ecPos = gl_ModelViewMatrix * gl_Vertex;
+ aux = vec3(gl_LightSource[0].position-ecPos);
+ lightDir = normalize(aux);
+ dist = length(aux);
+
+ halfVector = normalize(gl_LightSource[0].halfVector.xyz);
+
+ /* Compute the diffuse, ambient and globalAmbient terms */
+ diffuse = gl_FrontMaterial.diffuse * gl_LightSource[0].diffuse;
+
+ /* The ambient terms have been separated since one of them */
+ /* suffers attenuation */
+ ambient = gl_FrontMaterial.ambient * gl_LightSource[0].ambient;
+ ambientGlobal = gl_LightModel.ambient * gl_FrontMaterial.ambient;
+
+
+ gl_Position = ftransform();
+ gl_TexCoord[0] = gl_MultiTexCoord0;
+}
Modified: branches/agate3d-3.2/Tests/Display3D/Glsl.cs
===================================================================
--- branches/agate3d-3.2/Tests/Display3D/Glsl.cs 2009-05-07 02:02:28 UTC (rev 957)
+++ branches/agate3d-3.2/Tests/Display3D/Glsl.cs 2009-05-07 04:17:58 UTC (rev 958)
@@ -19,7 +19,7 @@
public string Name
{
- get { return "Glsl"; }
+ get { return "Glsl (OpenGL only)"; }
}
public string Category
@@ -85,13 +85,9 @@
double frequency = 2 * Math.PI / 5;
const float size = 25;
- //var shader = ShaderCompiler.CompileShader(ShaderLanguage.Glsl,
- // Shaders.PerPixelLighting_vertex, Shaders.PerPixelLighting_fragment);
var shader = ShaderCompiler.CompileShader(ShaderLanguage.Glsl,
- File.ReadAllText("Data/shaders/BumpMap_vertex.txt"),
- File.ReadAllText("Data/shaders/BumpMap_fragment.txt"));
- //var shader = ShaderCompiler.CompileShader(ShaderLanguage.Glsl,
- // Shaders.BumpMap_vertex, Shaders.PerPixelLighting_fragment);
+ File.ReadAllText("Data/shaders/glsl/BumpMap_vertex.txt"),
+ File.ReadAllText("Data/shaders/glsl/BumpMap_fragment.txt"));
//HeightMapTerrain b = new HeightMapTerrain(height.ReadPixels());
//b.Width = size;
Copied: branches/agate3d-3.2/Tests/Display3D/Hlsl.cs (from rev 925, branches/agate3d-3.2/Tests/Display3D/Glsl.cs)
===================================================================
--- branches/agate3d-3.2/Tests/Display3D/Hlsl.cs (rev 0)
+++ branches/agate3d-3.2/Tests/Display3D/Hlsl.cs 2009-05-07 04:17:58 UTC (rev 958)
@@ -0,0 +1,186 @@
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.IO;
+using System.Linq;
+using System.Text;
+using AgateLib;
+using AgateLib.Geometry.Builders;
+using AgateLib.DisplayLib;
+using AgateLib.DisplayLib.Shaders;
+using AgateLib.Geometry;
+using AgateLib.InputLib;
+
+namespace Tests.Display3D.Glsl
+{
+ public class Hlsl: IAgateTest
+ {
+ #region IAgateTest Members
+
+ public string Name
+ {
+ get { return "Hlsl (Direct3D only)"; }
+ }
+
+ public string Category
+ {
+ get { return "Display 3D"; }
+ }
+
+ void IAgateTest.Main(string[] args)
+ {
+ Run(args);
+ }
+
+ #endregion
+
+ bool rotating = false;
+ const float velocity = 0.04f;
+ const float mousevelocity = 0.004f;
+ float theta = (float)Math.PI / 2;
+ float phi = (float)-Math.PI / 2;
+ Vector3 eye = new Vector3(0, 70, 20);
+ Vector3 up = new Vector3(0, 0, 1);
+ DisplayWindow wind;
+
+ Vector3 lookDir
+ {
+ get { return Vector3.FromPolar(1, theta, phi); }
+ }
+ Vector2 centerPoint
+ {
+ get { return new Vector2(wind.Width / 2, wind.Height / 2); }
+ }
+ void resetmouse()
+ {
+ Mouse.Position = new Point(wind.Width / 2, wind.Height / 2);
+ }
+ private void Run(string[] args)
+ {
+ using (AgateSetup setup = new AgateSetup(args))
+ {
+ setup.Initialize(true, false, false);
+ if (setup.WasCanceled)
+ return;
+
+ wind = DisplayWindow.CreateWindowed("GLSL", 800, 600);
+ Mouse.MouseDown += new InputEventHandler(Mouse_MouseDown);
+
+ FontSurface font = new FontSurface("Arial", 14.0f);
+
+ Surface texture = new Surface("bg-bricks.png");
+ Surface height = new Surface("bg-bricks-heightmap.png");
+ //Surface height = new Surface("jellybean.png");
+
+ LightManager m = new LightManager();
+ m.AddPointLight(new Vector3(0, 0, 0), Color.White);
+ m.Enabled = true;
+ m.Ambient = Color.FromArgb(0, 255, 0);
+ m[0].AttenuationConstant = 0.0001f;
+ m[0].AttenuationLinear = 0.004f;
+ m[0].AttenuationQuadratic = 0.0001f;
+ m[0].Range = 200;
+
+ double time = 0;
+ double frequency = 2 * Math.PI / 5;
+ const float size = 25;
+
+ var shader = ShaderCompiler.CompileShader(ShaderLanguage.Glsl,
+ File.ReadAllText("Data/shaders/glsl/BumpMap_vertex.txt"),
+ File.ReadAllText("Data/shaders/glsl/BumpMap_fragment.txt"));
+
+ //HeightMapTerrain b = new HeightMapTerrain(height.ReadPixels());
+ //b.Width = size;
+ //b.Height = size;
+ //b.MaxPeak = 1;
+ CubeBuilder b = new CubeBuilder();
+ //b.VertexType = VertexLayout.PositionNormalTangentBitangentTexture;
+ b.Length = size;
+ b.CreateVertexBuffer();
+
+ IndexBuffer index = b.IndexBuffer;
+ VertexBuffer buffer = b.VertexBuffer;
+ buffer.Textures[0] = texture;
+ buffer.Textures[1] = new Surface(
+ PixelBuffer.NormalMapFromHeightMap(height.ReadPixels(), 2.0f));
+ buffer.Textures[1].SaveTo("normal.png");
+
+
+ resetmouse();
+ Mouse.Hide();
+
+ while (wind.IsClosed == false)
+ {
+ if (Core.IsActive)
+ {
+ Vector3 move = lookDir * velocity * Display.DeltaTime;
+ Vector3 strafe = Vector3.CrossProduct(move, up).Normalize() * velocity * Display.DeltaTime;
+ Vector3 fly = new Vector3(0, 0, velocity * Display.DeltaTime);
+
+ if (Keyboard.Keys[KeyCode.W]) eye += move;
+ else if (Keyboard.Keys[KeyCode.S]) eye -= move;
+
+ if (Keyboard.Keys[KeyCode.A]) eye -= strafe;
+ else if (Keyboard.Keys[KeyCode.D]) eye += strafe;
+
+ if (Keyboard.Keys[KeyCode.Q]) eye += fly;
+ else if (Keyboard.Keys[KeyCode.E]) eye -= fly;
+
+ if (Keyboard.Keys[KeyCode.Escape])
+ return;
+
+ Vector2 mouseDiff = new Vector2(Mouse.X, Mouse.Y) - centerPoint;
+
+ theta += mouseDiff.Y * mousevelocity;
+ phi -= mouseDiff.X * mousevelocity;
+ resetmouse();
+
+ if (phi < -Math.PI) phi += (float)(Math.PI * 2);
+ if (phi > Math.PI) phi -= (float)(Math.PI * 2);
+ if (theta < 0) theta = 0;
+ if (theta > Math.PI) theta = (float)Math.PI;
+ }
+
+ if (rotating)
+ {
+ time += Display.DeltaTime / 1000.0;
+ }
+
+ Display.BeginFrame();
+ Display.Clear(Color.Gray);
+
+ Display.Shader = shader;
+
+ Display.MatrixProjection = Matrix4.Projection(45f, wind.Width / (float)wind.Height, 1.0f, 1000f);
+ Display.MatrixWorld = Matrix4.Identity;
+ Display.MatrixView = Matrix4.Identity;
+
+ Display.MatrixView = Matrix4.LookAt(eye, eye + lookDir, up);
+
+ m[0].Position = eye;
+ m.DoLighting();
+
+ Display.MatrixWorld =
+ Matrix4.Translation(-size / 2, -size / 2, 0) * Matrix4.RotateZ((float)(frequency * time));
+
+ buffer.DrawIndexed(index);
+
+ Debug.Print("x, y, z = {0}", eye.ToString());
+ Debug.Print("angle = {0}", phi * 180 / Math.PI);
+
+ Display.EndFrame();
+ Core.KeepAlive();
+ }
+ }
+ }
+
+ void Mouse_MouseDown(InputEventArgs e)
+ {
+ if (e.MouseButtons == Mouse.MouseButtons.Secondary)
+ {
+ rotating = !rotating;
+ }
+ }
+
+ }
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ka...@us...> - 2009-05-07 15:53:17
|
Revision: 960
http://agate.svn.sourceforge.net/agate/?rev=960&view=rev
Author: kanato
Date: 2009-05-07 15:53:01 +0000 (Thu, 07 May 2009)
Log Message:
-----------
Initial implementation of compiling HLSL vertex and pixel shaders.
Modified Paths:
--------------
branches/agate3d-3.2/AgateLib/DisplayLib/Shaders/ShaderCompiler.cs
branches/agate3d-3.2/AgateLib/DisplayLib/Shaders/ShaderProgram.cs
branches/agate3d-3.2/AgateLib/ImplementationBase/ShaderCompilerImpl.cs
branches/agate3d-3.2/Drivers/AgateMDX/HlslCompiler.cs
branches/agate3d-3.2/Drivers/AgateMDX/HlslShaderProgram.cs
branches/agate3d-3.2/Tests/Display3D/Hlsl.cs
Added Paths:
-----------
branches/agate3d-3.2/AgateLib/DisplayLib/Shaders/Effect.cs
branches/agate3d-3.2/AgateLib/DisplayLib/Shaders/Technique.cs
branches/agate3d-3.2/Tests/Data/shaders/hlsl/PerPixelLighting_pixel.txt
branches/agate3d-3.2/Tests/Data/shaders/hlsl/PerPixelLighting_vertex.txt
Removed Paths:
-------------
branches/agate3d-3.2/Tests/Data/shaders/hlsl/PerPixelLighting_fragment.txt
branches/agate3d-3.2/Tests/Data/shaders/hlsl/PerPixelLighting_vertex.txt
Added: branches/agate3d-3.2/AgateLib/DisplayLib/Shaders/Effect.cs
===================================================================
--- branches/agate3d-3.2/AgateLib/DisplayLib/Shaders/Effect.cs (rev 0)
+++ branches/agate3d-3.2/AgateLib/DisplayLib/Shaders/Effect.cs 2009-05-07 15:53:01 UTC (rev 960)
@@ -0,0 +1,11 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace AgateLib.DisplayLib.Shaders
+{
+ public class Effect
+ {
+ }
+}
Modified: branches/agate3d-3.2/AgateLib/DisplayLib/Shaders/ShaderCompiler.cs
===================================================================
--- branches/agate3d-3.2/AgateLib/DisplayLib/Shaders/ShaderCompiler.cs 2009-05-07 13:19:02 UTC (rev 959)
+++ branches/agate3d-3.2/AgateLib/DisplayLib/Shaders/ShaderCompiler.cs 2009-05-07 15:53:01 UTC (rev 960)
@@ -27,6 +27,10 @@
impl = null;
}
+ public static ShaderProgram CompileEffect(ShaderLanguage language, string effectSource)
+ {
+ return impl.CompileEffect(language, effectSource);
+ }
public static ShaderProgram CompileShader(ShaderLanguage language, string vertexShaderSource, string pixelShaderSource)
{
return impl.CompileShader(language, vertexShaderSource, pixelShaderSource);
Modified: branches/agate3d-3.2/AgateLib/DisplayLib/Shaders/ShaderProgram.cs
===================================================================
--- branches/agate3d-3.2/AgateLib/DisplayLib/Shaders/ShaderProgram.cs 2009-05-07 13:19:02 UTC (rev 959)
+++ branches/agate3d-3.2/AgateLib/DisplayLib/Shaders/ShaderProgram.cs 2009-05-07 15:53:01 UTC (rev 960)
@@ -34,5 +34,9 @@
}
public VertexLayout VertexDefinition { get; set; }
+
+ public abstract void Render(RenderHandler handler, object obj);
}
+
+ public delegate void RenderHandler(object obj);
}
Added: branches/agate3d-3.2/AgateLib/DisplayLib/Shaders/Technique.cs
===================================================================
--- branches/agate3d-3.2/AgateLib/DisplayLib/Shaders/Technique.cs (rev 0)
+++ branches/agate3d-3.2/AgateLib/DisplayLib/Shaders/Technique.cs 2009-05-07 15:53:01 UTC (rev 960)
@@ -0,0 +1,11 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace AgateLib.DisplayLib.Shaders
+{
+ public class Technique
+ {
+ }
+}
Modified: branches/agate3d-3.2/AgateLib/ImplementationBase/ShaderCompilerImpl.cs
===================================================================
--- branches/agate3d-3.2/AgateLib/ImplementationBase/ShaderCompilerImpl.cs 2009-05-07 13:19:02 UTC (rev 959)
+++ branches/agate3d-3.2/AgateLib/ImplementationBase/ShaderCompilerImpl.cs 2009-05-07 15:53:01 UTC (rev 960)
@@ -9,5 +9,6 @@
public abstract class ShaderCompilerImpl
{
public abstract ShaderProgram CompileShader(ShaderLanguage language, string vertexShaderSource, string pixelShaderSource);
+ public abstract ShaderProgram CompileEffect(ShaderLanguage language, string effectSource);
}
}
Modified: branches/agate3d-3.2/Drivers/AgateMDX/HlslCompiler.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateMDX/HlslCompiler.cs 2009-05-07 13:19:02 UTC (rev 959)
+++ branches/agate3d-3.2/Drivers/AgateMDX/HlslCompiler.cs 2009-05-07 15:53:01 UTC (rev 960)
@@ -4,6 +4,7 @@
using System.Text;
using AgateLib.DisplayLib.Shaders;
using AgateLib.ImplementationBase;
+using Direct3D = Microsoft.DirectX.Direct3D;
namespace AgateMDX
{
@@ -16,8 +17,27 @@
mDisplay = display;
}
+ public override ShaderProgram CompileEffect(ShaderLanguage language, string effectSource)
+ {
+ Direct3D.Effect effect = Direct3D.Effect.FromString(mDisplay.D3D_Device.Device,
+ effectSource, null, null, Direct3D.ShaderFlags.None, null);
+
+ return new HlslShaderProgram(effect);
+ }
public override ShaderProgram CompileShader(ShaderLanguage language, string vertexShaderSource, string pixelShaderSource)
{
+ var vertexShaderStream = Direct3D.ShaderLoader.CompileShader(
+ vertexShaderSource, "main", null, "vs_1_1", Direct3D.ShaderFlags.None);
+
+
+ var vertexShader = new Direct3D.VertexShader(mDisplay.D3D_Device.Device, vertexShaderStream);
+
+
+ var pixelShaderStream = Direct3D.ShaderLoader.CompileShader(
+ pixelShaderSource, "main", null, "ps_1_1", Direct3D.ShaderFlags.None);
+
+ var pixelShader = new Direct3D.PixelShader(mDisplay.D3D_Device.Device, pixelShaderStream);
+
throw new NotImplementedException();
//return new HlslShaderProgram();
Modified: branches/agate3d-3.2/Drivers/AgateMDX/HlslShaderProgram.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateMDX/HlslShaderProgram.cs 2009-05-07 13:19:02 UTC (rev 959)
+++ branches/agate3d-3.2/Drivers/AgateMDX/HlslShaderProgram.cs 2009-05-07 15:53:01 UTC (rev 960)
@@ -3,11 +3,18 @@
using System.Linq;
using System.Text;
using AgateLib.DisplayLib.Shaders;
+using Direct3D = Microsoft.DirectX.Direct3D;
namespace AgateMDX
{
class HlslShaderProgram : ShaderProgram
{
+ Direct3D.Effect mEffect;
+
+ public HlslShaderProgram(Direct3D.Effect effect)
+ {
+ mEffect = effect;
+ }
public override PixelShader PixelShader
{
get { throw new NotImplementedException(); }
@@ -32,6 +39,20 @@
{
get { throw new NotImplementedException(); }
}
+
+ public override void Render(RenderHandler handler, object obj)
+ {
+ int passcount = mEffect.Begin(Microsoft.DirectX.Direct3D.FX.None);
+
+ for (int i = 0; i < passcount; i++)
+ {
+ mEffect.BeginPass(i);
+ handler(obj);
+ mEffect.EndPass();
+ }
+
+ mEffect.End();
+ }
}
class HlslPixelShader : PixelShader
Deleted: branches/agate3d-3.2/Tests/Data/shaders/hlsl/PerPixelLighting_fragment.txt
===================================================================
--- branches/agate3d-3.2/Tests/Data/shaders/hlsl/PerPixelLighting_fragment.txt 2009-05-07 13:19:02 UTC (rev 959)
+++ branches/agate3d-3.2/Tests/Data/shaders/hlsl/PerPixelLighting_fragment.txt 2009-05-07 15:53:01 UTC (rev 960)
@@ -1,40 +0,0 @@
-varying vec4 diffuse,ambientGlobal, ambient;
-varying vec3 normal,lightDir,halfVector;
-varying float dist;
-uniform sampler2D texture0;
-
-
-void main()
-{
- vec3 n,halfV,viewV,ldir;
- float NdotL,NdotHV;
- vec4 color = ambientGlobal;
- float att;
-
- /* a fragment shader can't write a varying variable, hence we need
- a new variable to store the normalized interpolated normal */
- n = normalize(normal);
-
- /* compute the dot product between normal and normalized lightdir */
- NdotL = max(dot(n,normalize(lightDir)),0.0);
-
- if (NdotL > 0.0) {
- att = 1.0 / (gl_LightSource[0].constantAttenuation +
- gl_LightSource[0].linearAttenuation * dist +
- gl_LightSource[0].quadraticAttenuation * dist * dist);
-
- color += att * (diffuse * NdotL + ambient);
-
- halfV = normalize(halfVector);
- NdotHV = max(dot(n,halfV),0.0);
- color += att * gl_FrontMaterial.specular * gl_LightSource[0].specular *
- pow(NdotHV,gl_FrontMaterial.shininess);
- }
-
- vec4 texcolor = texture2D(texture0,gl_TexCoord[0].st);
-
- color.rgb *= texcolor.rgb;
-
- gl_FragColor = color;
-}
-
Added: branches/agate3d-3.2/Tests/Data/shaders/hlsl/PerPixelLighting_pixel.txt
===================================================================
(Binary files differ)
Property changes on: branches/agate3d-3.2/Tests/Data/shaders/hlsl/PerPixelLighting_pixel.txt
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Deleted: branches/agate3d-3.2/Tests/Data/shaders/hlsl/PerPixelLighting_vertex.txt
===================================================================
--- branches/agate3d-3.2/Tests/Data/shaders/hlsl/PerPixelLighting_vertex.txt 2009-05-07 13:19:02 UTC (rev 959)
+++ branches/agate3d-3.2/Tests/Data/shaders/hlsl/PerPixelLighting_vertex.txt 2009-05-07 15:53:01 UTC (rev 960)
@@ -1,31 +0,0 @@
-varying vec4 diffuse,ambientGlobal,ambient;
-varying vec3 normal,lightDir,halfVector;
-varying float dist;
-
-void main()
-{
- vec4 ecPos;
- vec3 aux;
-
- normal = normalize(gl_NormalMatrix * gl_Normal);
-
- /* these are the new lines of code to compute the light's direction */
- ecPos = gl_ModelViewMatrix * gl_Vertex;
- aux = vec3(gl_LightSource[0].position-ecPos);
- lightDir = normalize(aux);
- dist = length(aux);
-
- halfVector = normalize(gl_LightSource[0].halfVector.xyz);
-
- /* Compute the diffuse, ambient and globalAmbient terms */
- diffuse = gl_FrontMaterial.diffuse * gl_LightSource[0].diffuse;
-
- /* The ambient terms have been separated since one of them */
- /* suffers attenuation */
- ambient = gl_FrontMaterial.ambient * gl_LightSource[0].ambient;
- ambientGlobal = gl_LightModel.ambient * gl_FrontMaterial.ambient;
-
-
- gl_Position = ftransform();
- gl_TexCoord[0] = gl_MultiTexCoord0;
-}
Copied: branches/agate3d-3.2/Tests/Data/shaders/hlsl/PerPixelLighting_vertex.txt (from rev 958, branches/agate3d-3.2/Tests/Data/shaders/hlsl/PerPixelLighting_fragment.txt)
===================================================================
--- branches/agate3d-3.2/Tests/Data/shaders/hlsl/PerPixelLighting_vertex.txt (rev 0)
+++ branches/agate3d-3.2/Tests/Data/shaders/hlsl/PerPixelLighting_vertex.txt 2009-05-07 15:53:01 UTC (rev 960)
@@ -0,0 +1,31 @@
+float4x4 worldViewProj;
+
+struct VS_INPUT
+{
+ float3 position : POSITION;
+ float4 color0 : COLOR0;
+ float2 texcoord0 : TEXCOORD0;
+};
+
+struct VS_OUTPUT
+{
+ float4 hposition : POSITION;
+ float4 color0 : COLOR0;
+ float2 texcoord0 : TEXCOORD0;
+};
+
+VS_OUTPUT main( VS_INPUT IN )
+{
+ VS_OUTPUT OUT;
+
+ float4 v = float4( IN.position.x,
+ IN.position.y,
+ IN.position.z,
+ 1.0f );
+
+ OUT.hposition = mul( v, worldViewProj );
+ OUT.color0 = IN.color0;
+ OUT.texcoord0 = IN.texcoord0;
+
+ return OUT;
+}
Modified: branches/agate3d-3.2/Tests/Display3D/Hlsl.cs
===================================================================
--- branches/agate3d-3.2/Tests/Display3D/Hlsl.cs 2009-05-07 13:19:02 UTC (rev 959)
+++ branches/agate3d-3.2/Tests/Display3D/Hlsl.cs 2009-05-07 15:53:01 UTC (rev 960)
@@ -86,8 +86,8 @@
const float size = 25;
var shader = ShaderCompiler.CompileShader(ShaderLanguage.Glsl,
- File.ReadAllText("Data/shaders/glsl/BumpMap_vertex.txt"),
- File.ReadAllText("Data/shaders/glsl/BumpMap_fragment.txt"));
+ File.ReadAllText("Data/shaders/hlsl/PerPixelLighting_vertex.txt"),
+ File.ReadAllText("Data/shaders/hlsl/PerPixelLighting_pixel.txt"));
//HeightMapTerrain b = new HeightMapTerrain(height.ReadPixels());
//b.Width = size;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ka...@us...> - 2009-05-09 22:07:15
|
Revision: 962
http://agate.svn.sourceforge.net/agate/?rev=962&view=rev
Author: kanato
Date: 2009-05-09 22:06:59 +0000 (Sat, 09 May 2009)
Log Message:
-----------
Implement driver preference option when AgateLib is initialized.
Modified Paths:
--------------
branches/agate3d-3.2/AgateLib/AgateApplication.cs
branches/agate3d-3.2/AgateLib/AgateSetup.cs
branches/agate3d-3.2/AgateLib/AppInitParameters.cs
branches/agate3d-3.2/AgateLib/Drivers/IUserSetSystems.cs
branches/agate3d-3.2/AgateLib/Drivers/Registrar.cs
branches/agate3d-3.2/Drivers/AgateLib.WinForms/SetSystemsForm.Designer.cs
branches/agate3d-3.2/Drivers/AgateLib.WinForms/SetSystemsForm.cs
branches/agate3d-3.2/Tests/Display3D/Glsl.cs
branches/agate3d-3.2/Tests/Display3D/Hlsl.cs
branches/agate3d-3.2/Tests/frmLauncher.cs
Modified: branches/agate3d-3.2/AgateLib/AgateApplication.cs
===================================================================
--- branches/agate3d-3.2/AgateLib/AgateApplication.cs 2009-05-07 17:07:44 UTC (rev 961)
+++ branches/agate3d-3.2/AgateLib/AgateApplication.cs 2009-05-09 22:06:59 UTC (rev 962)
@@ -49,7 +49,7 @@
double totalSplashTime = 0;
bool splashFadeDone = false;
- #region --- Run Methods ---
+ #region --- Run Method ---
/// <summary>
/// Runs the application.
@@ -68,6 +68,10 @@
{
using (AgateSetup setup = new AgateSetup(args))
{
+ setup.PreferredDisplay = InitParams.PreferredDisplay;
+ setup.PreferredAudio = InitParams.PreferredAudio;
+ setup.PreferredInput = InitParams.PreferredInput;
+
setup.Initialize(
InitParams.InitializeDisplay,
InitParams.InitializeAudio,
Modified: branches/agate3d-3.2/AgateLib/AgateSetup.cs
===================================================================
--- branches/agate3d-3.2/AgateLib/AgateSetup.cs 2009-05-07 17:07:44 UTC (rev 961)
+++ branches/agate3d-3.2/AgateLib/AgateSetup.cs 2009-05-09 22:06:59 UTC (rev 962)
@@ -66,10 +66,29 @@
private bool mUseAudio = true;
private bool mUseInput = true;
+ private DisplayTypeID mPreferredDisplay = DisplayTypeID.AutoSelect;
+ private AudioTypeID mPreferredAudio = AudioTypeID.AutoSelect;
+ private InputTypeID mPreferredInput = InputTypeID.AutoSelect;
+
private DisplayTypeID mSelectDisplay = DisplayTypeID.AutoSelect;
private AudioTypeID mSelectAudio = AudioTypeID.AutoSelect;
private InputTypeID mSelectInput = InputTypeID.AutoSelect;
+ public DisplayTypeID PreferredDisplay
+ {
+ get { return mPreferredDisplay; }
+ set { mPreferredDisplay = value; }
+ }
+ public AudioTypeID PreferredAudio
+ {
+ get { return mPreferredAudio; }
+ set { mPreferredAudio = value; }
+ }
+ public InputTypeID PreferredInput
+ {
+ get { return mPreferredInput; }
+ set { mPreferredInput = value; }
+ }
/// <summary>
/// Constructs a Setup object.
@@ -280,8 +299,10 @@
return;
mWasCanceled = !Registrar.UserSelectDrivers(mUseDisplay, mUseAudio, mUseInput,
- out mSelectDisplay, out mSelectAudio, out mSelectInput);
+ mPreferredDisplay, mPreferredAudio, mPreferredInput ,
+ out mSelectDisplay, out mSelectAudio, out mSelectInput);
+
mAlreadyAsked = true;
}
Modified: branches/agate3d-3.2/AgateLib/AppInitParameters.cs
===================================================================
--- branches/agate3d-3.2/AgateLib/AppInitParameters.cs 2009-05-07 17:07:44 UTC (rev 961)
+++ branches/agate3d-3.2/AgateLib/AppInitParameters.cs 2009-05-09 22:06:59 UTC (rev 962)
@@ -23,5 +23,10 @@
public bool InitializeDisplay { get; set; }
public bool InitializeAudio { get; set; }
public bool InitializeJoysticks { get; set; }
+
+ public Drivers.DisplayTypeID PreferredDisplay { get; set; }
+ public Drivers.AudioTypeID PreferredAudio { get; set; }
+ public Drivers.InputTypeID PreferredInput { get; set; }
+
}
}
Modified: branches/agate3d-3.2/AgateLib/Drivers/IUserSetSystems.cs
===================================================================
--- branches/agate3d-3.2/AgateLib/Drivers/IUserSetSystems.cs 2009-05-07 17:07:44 UTC (rev 961)
+++ branches/agate3d-3.2/AgateLib/Drivers/IUserSetSystems.cs 2009-05-09 22:06:59 UTC (rev 962)
@@ -82,8 +82,7 @@
/// <param name="chooseDisplay"></param>
/// <param name="chooseAudio"></param>
/// <param name="chooseInput"></param>
- void SetChoices(bool chooseDisplay, bool chooseAudio, bool chooseInput);
-
-
+ void SetChoices(bool chooseDisplay, bool chooseAudio, bool chooseInput,
+ DisplayTypeID preferredDisplay, AudioTypeID preferredAudio, InputTypeID preferredInput);
}
}
Modified: branches/agate3d-3.2/AgateLib/Drivers/Registrar.cs
===================================================================
--- branches/agate3d-3.2/AgateLib/Drivers/Registrar.cs 2009-05-07 17:07:44 UTC (rev 961)
+++ branches/agate3d-3.2/AgateLib/Drivers/Registrar.cs 2009-05-09 22:06:59 UTC (rev 962)
@@ -19,6 +19,7 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
+using System.Linq;
using System.Reflection;
using System.Text;
@@ -45,10 +46,31 @@
private static IDesktopDriver mDesktop;
private static readonly string[] KnownNativeLibraries = new string[]
- {
- "SDL.dll",
- };
+ {
+ "SDL.dll",
+ };
+
+ static bool Contains(this List<AgateDriverInfo> list, DisplayTypeID type)
+ {
+ return list.Any(
+ x => comparator(x, DriverType.Display, (int)type));
+ }
+ static bool Contains(this List<AgateDriverInfo> list, AudioTypeID type)
+ {
+ return list.Any(
+ x => comparator(x, DriverType.Audio, (int)type));
+ }
+ static bool Contains(this List<AgateDriverInfo> list, InputTypeID type)
+ {
+ return list.Any(
+ x => comparator(x, DriverType.Input, (int)type));
+ }
+ static bool comparator(AgateDriverInfo info, DriverType driverType, int type)
+ {
+ return info.DriverType == driverType && info.DriverTypeID == type;
+ }
+
static Registrar()
{
}
@@ -199,20 +221,21 @@
/// <param name="selectedInput"></param>
/// <returns></returns>
internal static bool UserSelectDrivers(bool chooseDisplay, bool chooseAudio, bool chooseInput,
+ DisplayTypeID preferredDisplay, AudioTypeID preferredAudio, InputTypeID preferredInput,
out DisplayTypeID selectedDisplay, out AudioTypeID selectedAudio, out InputTypeID selectedInput)
{
if (mDesktop == null)
{
CreateDesktopDriver();
+
if (mDesktop == null)
SelectBestDrivers(chooseDisplay, chooseAudio, chooseInput,
+ preferredDisplay, preferredAudio, preferredInput,
out selectedDisplay, out selectedAudio, out selectedInput);
}
IUserSetSystems frm = mDesktop.CreateUserSetSystems();
- frm.SetChoices(chooseDisplay, chooseAudio, chooseInput);
-
// set default values.
selectedDisplay = DisplayTypeID.AutoSelect;
selectedAudio = AudioTypeID.AutoSelect;
@@ -231,6 +254,10 @@
frm.AddInputType(info);
}
+ frm.SetChoices(chooseDisplay, chooseAudio, chooseInput,
+ preferredDisplay, preferredAudio, preferredInput);
+
+ // run the dialog asking user which drivers to use.
if (frm.RunDialog() == SetSystemsDialogResult.Cancel)
{
return false;
@@ -245,17 +272,27 @@
}
private static void SelectBestDrivers(bool chooseDisplay, bool chooseAudio, bool chooseInput,
+ DisplayTypeID preferredDisplay, AudioTypeID preferredAudio, InputTypeID preferredInput,
out DisplayTypeID selectedDisplay, out AudioTypeID selectedAudio, out InputTypeID selectedInput)
{
+ // initial return values if a driver isn't selected.
selectedDisplay = DisplayTypeID.AutoSelect;
selectedAudio = AudioTypeID.AutoSelect;
selectedInput = InputTypeID.AutoSelect;
- if (displayDrivers.Count > 0)
+ if (preferredDisplay != DisplayTypeID.AutoSelect && displayDrivers.Contains(preferredDisplay))
+ selectedDisplay = preferredDisplay;
+ else if (displayDrivers.Count > 0)
selectedDisplay = (DisplayTypeID)displayDrivers[0].DriverTypeID;
- if (audioDrivers.Count > 0)
+
+ if (preferredAudio != AudioTypeID.AutoSelect && audioDrivers.Contains(preferredAudio))
+ selectedAudio = preferredAudio;
+ else if (audioDrivers.Count > 0)
selectedAudio = (AudioTypeID)audioDrivers[0].DriverTypeID;
- if (inputDrivers.Count > 0)
+
+ if (preferredInput != InputTypeID.AutoSelect && inputDrivers.Contains(preferredInput))
+ selectedInput = preferredInput;
+ else if (inputDrivers.Count > 0)
selectedInput = (InputTypeID)inputDrivers[0].DriverTypeID;
}
@@ -409,5 +446,6 @@
get { return inputDrivers; }
}
+
}
}
Modified: branches/agate3d-3.2/Drivers/AgateLib.WinForms/SetSystemsForm.Designer.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateLib.WinForms/SetSystemsForm.Designer.cs 2009-05-07 17:07:44 UTC (rev 961)
+++ branches/agate3d-3.2/Drivers/AgateLib.WinForms/SetSystemsForm.Designer.cs 2009-05-09 22:06:59 UTC (rev 962)
@@ -163,7 +163,6 @@
this.MaximizeBox = false;
this.Name = "SetSystemsForm";
this.Text = "Select Drivers";
- this.Load += new System.EventHandler(this.frmSetSystems_Load);
this.ResumeLayout(false);
}
Modified: branches/agate3d-3.2/Drivers/AgateLib.WinForms/SetSystemsForm.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateLib.WinForms/SetSystemsForm.cs 2009-05-07 17:07:44 UTC (rev 961)
+++ branches/agate3d-3.2/Drivers/AgateLib.WinForms/SetSystemsForm.cs 2009-05-09 22:06:59 UTC (rev 962)
@@ -71,19 +71,7 @@
Icon = FormUtil.AgateLibIcon;
}
- /// <summary>
- /// Constructs the form. Specifies whether display, audio and input
- /// should be allowed to be chosen.
- /// </summary>
- /// <param name="chooseDisplay"></param>
- /// <param name="chooseAudio"></param>
- /// <param name="chooseInput"></param>
- public SetSystemsForm(bool chooseDisplay, bool chooseAudio, bool chooseInput)
- {
- InitializeComponent();
- }
-
/// <summary>
/// Adds.
/// </summary>
@@ -130,22 +118,59 @@
}
}
- private void frmSetSystems_Load(object sender, EventArgs e)
- {
- SelectFirst(displayList);
- SelectFirst(audioList);
- SelectFirst(inputList);
- }
-
private void SelectFirst(ComboBox theComboBox)
{
if (theComboBox.Items.Count > 0)
theComboBox.SelectedIndex = 0;
}
+ private void SelectItem(ComboBox theComboBox, int driverTypeID)
+ {
+ for (int i = 0; i < theComboBox.Items.Count; i++)
+ {
+ AgateDriverInfo item = (AgateDriverInfo)theComboBox.Items[i];
+
+ if (item.DriverTypeID == driverTypeID)
+ {
+ theComboBox.SelectedIndex = i;
+ return;
+ }
+ }
+
+ SelectFirst(theComboBox);
+ }
+
#region IUserSetSystems Members
+ public void SetChoices(bool chooseDisplay, bool chooseAudio, bool chooseInput,
+ DisplayTypeID preferredDisplay, AudioTypeID preferredAudio, InputTypeID preferredInput)
+ {
+ mChooseDisplay = chooseDisplay;
+ mChooseAudio = chooseAudio;
+ mChooseInput = chooseInput;
+ displayList.Enabled = mChooseDisplay;
+ audioList.Enabled = mChooseAudio;
+ inputList.Enabled = mChooseInput;
+
+ if (preferredDisplay != DisplayTypeID.AutoSelect)
+ SelectItem(displayList, (int)preferredDisplay);
+ else
+ SelectFirst(displayList);
+
+ if (preferredAudio != AudioTypeID.AutoSelect)
+ SelectItem(audioList, (int)preferredAudio);
+ else
+ SelectFirst(audioList);
+
+ if (preferredInput != InputTypeID.AutoSelect)
+ SelectItem(inputList, (int)preferredInput);
+ else
+ SelectFirst(inputList);
+ }
+
+
+
public SetSystemsDialogResult RunDialog()
{
if (displayList.Items.Count == 0 && mChooseDisplay)
@@ -164,20 +189,7 @@
}
}
- public void SetChoices(bool chooseDisplay, bool chooseAudio, bool chooseInput)
- {
- mChooseDisplay = chooseDisplay;
- mChooseAudio = chooseAudio;
- mChooseInput = chooseInput;
-
- displayList.Enabled = mChooseDisplay;
- audioList.Enabled = mChooseAudio;
- inputList.Enabled = mChooseInput;
- }
-
-
#endregion
-
}
}
\ No newline at end of file
Modified: branches/agate3d-3.2/Tests/Display3D/Glsl.cs
===================================================================
--- branches/agate3d-3.2/Tests/Display3D/Glsl.cs 2009-05-07 17:07:44 UTC (rev 961)
+++ branches/agate3d-3.2/Tests/Display3D/Glsl.cs 2009-05-09 22:06:59 UTC (rev 962)
@@ -59,6 +59,7 @@
{
using (AgateSetup setup = new AgateSetup(args))
{
+ setup.PreferredDisplay = AgateLib.Drivers.DisplayTypeID.OpenGL;
setup.Initialize(true, false, false);
if (setup.WasCanceled)
return;
Modified: branches/agate3d-3.2/Tests/Display3D/Hlsl.cs
===================================================================
--- branches/agate3d-3.2/Tests/Display3D/Hlsl.cs 2009-05-07 17:07:44 UTC (rev 961)
+++ branches/agate3d-3.2/Tests/Display3D/Hlsl.cs 2009-05-09 22:06:59 UTC (rev 962)
@@ -59,11 +59,12 @@
{
using (AgateSetup setup = new AgateSetup(args))
{
+ setup.PreferredDisplay = AgateLib.Drivers.DisplayTypeID.Direct3D_MDX_1_1;
setup.Initialize(true, false, false);
if (setup.WasCanceled)
return;
- wind = DisplayWindow.CreateWindowed("GLSL", 800, 600);
+ wind = DisplayWindow.CreateWindowed("HLSL", 800, 600);
Mouse.MouseDown += new InputEventHandler(Mouse_MouseDown);
FontSurface font = new FontSurface("Arial", 14.0f);
Modified: branches/agate3d-3.2/Tests/frmLauncher.cs
===================================================================
--- branches/agate3d-3.2/Tests/frmLauncher.cs 2009-05-07 17:07:44 UTC (rev 961)
+++ branches/agate3d-3.2/Tests/frmLauncher.cs 2009-05-09 22:06:59 UTC (rev 962)
@@ -116,6 +116,7 @@
finally
{
this.Show();
+ Cursor.Show();
this.TopMost = true;
this.TopMost = false;
this.Activate();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ka...@us...> - 2009-05-10 04:13:32
|
Revision: 963
http://agate.svn.sourceforge.net/agate/?rev=963&view=rev
Author: kanato
Date: 2009-05-10 04:13:22 +0000 (Sun, 10 May 2009)
Log Message:
-----------
HLSL compiler working now.
Modified Paths:
--------------
branches/agate3d-3.2/Drivers/AgateMDX/HlslCompiler.cs
branches/agate3d-3.2/Drivers/AgateMDX/HlslShaderProgram.cs
branches/agate3d-3.2/Drivers/AgateMDX/MDX1_Display.cs
branches/agate3d-3.2/Drivers/AgateMDX/MDX1_VertexBuffer.cs
branches/agate3d-3.2/Tests/Data/shaders/hlsl/PerPixelLighting_pixel.txt
branches/agate3d-3.2/Tests/Data/shaders/hlsl/PerPixelLighting_vertex.txt
Modified: branches/agate3d-3.2/Drivers/AgateMDX/HlslCompiler.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateMDX/HlslCompiler.cs 2009-05-09 22:06:59 UTC (rev 962)
+++ branches/agate3d-3.2/Drivers/AgateMDX/HlslCompiler.cs 2009-05-10 04:13:22 UTC (rev 963)
@@ -19,11 +19,15 @@
public override ShaderProgram CompileEffect(ShaderLanguage language, string effectSource)
{
- Direct3D.Effect effect = Direct3D.Effect.FromString(mDisplay.D3D_Device.Device,
- effectSource, null, null, Direct3D.ShaderFlags.None, null);
+ throw new NotImplementedException();
+ }
+ //public override ShaderProgram CompileEffect(ShaderLanguage language, string effectSource)
+ //{
+ // Direct3D.Effect effect = Direct3D.Effect.FromString(mDisplay.D3D_Device.Device,
+ // effectSource, null, null, Direct3D.ShaderFlags.None, null);
- return new HlslShaderProgram(effect);
- }
+ // return new HlslShaderProgram(effect);
+ //}
public override ShaderProgram CompileShader(ShaderLanguage language, string vertexShaderSource, string pixelShaderSource)
{
var vertexShaderStream = Direct3D.ShaderLoader.CompileShader(
@@ -38,9 +42,7 @@
var pixelShader = new Direct3D.PixelShader(mDisplay.D3D_Device.Device, pixelShaderStream);
- throw new NotImplementedException();
-
- //return new HlslShaderProgram();
+ return new HlslShaderProgram(vertexShader, pixelShader);
}
}
}
Modified: branches/agate3d-3.2/Drivers/AgateMDX/HlslShaderProgram.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateMDX/HlslShaderProgram.cs 2009-05-09 22:06:59 UTC (rev 962)
+++ branches/agate3d-3.2/Drivers/AgateMDX/HlslShaderProgram.cs 2009-05-10 04:13:22 UTC (rev 963)
@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
+using AgateLib.DisplayLib;
using AgateLib.DisplayLib.Shaders;
using Direct3D = Microsoft.DirectX.Direct3D;
@@ -9,11 +10,16 @@
{
class HlslShaderProgram : ShaderProgram
{
- Direct3D.Effect mEffect;
+ Direct3D.VertexShader mVertexShader;
+ Direct3D.PixelShader mPixelShader;
+ MDX1_Display mDisplay;
- public HlslShaderProgram(Direct3D.Effect effect)
+ public HlslShaderProgram(Direct3D.VertexShader vert, Direct3D.PixelShader pix)
{
- mEffect = effect;
+ mDisplay = (MDX1_Display)Display.Impl;
+
+ mVertexShader = vert;
+ mPixelShader = pix;
}
public override PixelShader PixelShader
{
@@ -22,17 +28,17 @@
public override void SetUniform(string name, AgateLib.Geometry.Matrix4 matrix)
{
- throw new NotImplementedException();
+
}
public override void SetUniform(string name, params int[] v)
{
- throw new NotImplementedException();
+
}
public override void SetUniform(string name, params float[] v)
{
- throw new NotImplementedException();
+
}
public override VertexShader VertexShader
@@ -40,18 +46,31 @@
get { throw new NotImplementedException(); }
}
+ public Direct3D.VertexShader HlslVertexShader
+ {
+ get { return mVertexShader; }
+ }
+ public Direct3D.PixelShader HlslPixelShader
+ {
+ get { return mPixelShader; }
+ }
+
public override void Render(RenderHandler handler, object obj)
{
- int passcount = mEffect.Begin(Microsoft.DirectX.Direct3D.FX.None);
+ mDisplay.D3D_Device.Device.VertexShader = mVertexShader;
+ mDisplay.D3D_Device.Device.PixelShader = mPixelShader;
- for (int i = 0; i < passcount; i++)
- {
- mEffect.BeginPass(i);
- handler(obj);
- mEffect.EndPass();
- }
+ handler(obj);
+ //int passcount = mEffect.Begin(Microsoft.DirectX.Direct3D.FX.None);
- mEffect.End();
+ //for (int i = 0; i < passcount; i++)
+ //{
+ // mEffect.BeginPass(i);
+ // handler(obj);
+ // mEffect.EndPass();
+ //}
+
+ //mEffect.End();
}
}
Modified: branches/agate3d-3.2/Drivers/AgateMDX/MDX1_Display.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateMDX/MDX1_Display.cs 2009-05-09 22:06:59 UTC (rev 962)
+++ branches/agate3d-3.2/Drivers/AgateMDX/MDX1_Display.cs 2009-05-10 04:13:22 UTC (rev 963)
@@ -792,12 +792,10 @@
{
mDevice.DrawBuffer.Flush();
}
-
public override void SetOrthoProjection(Rectangle region)
{
mDevice.SetOrthoProjection(region);
}
-
public override void DoLighting(LightManager lights)
{
FlushDrawBuffer();
@@ -996,6 +994,26 @@
return TransformAgateMatrix(MatrixProjection * MatrixView * MatrixWorld);
}
+ HlslShaderProgram mShader;
+
+ public override AgateLib.DisplayLib.Shaders.ShaderProgram Shader
+ {
+ get
+ {
+ return mShader;
+ }
+ set
+ {
+ if (mShader == value)
+ return;
+
+ mShader = (HlslShaderProgram) value;
+
+ mDevice.Device.VertexShader = mShader.HlslVertexShader;
+ mDevice.Device.PixelShader = mShader.HlslPixelShader;
+
+ }
+ }
#endregion
#region --- IPlatformServices Members ---
Modified: branches/agate3d-3.2/Drivers/AgateMDX/MDX1_VertexBuffer.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateMDX/MDX1_VertexBuffer.cs 2009-05-09 22:06:59 UTC (rev 962)
+++ branches/agate3d-3.2/Drivers/AgateMDX/MDX1_VertexBuffer.cs 2009-05-10 04:13:22 UTC (rev 963)
@@ -44,6 +44,10 @@
Direct3D.Pool.Managed);
}
+ public override VertexLayout VertexLayout
+ {
+ get { return mLayout; }
+ }
private Direct3D.VertexFormats CreateVertexFormats(VertexLayout layout)
{
Direct3D.VertexFormats retval = Microsoft.DirectX.Direct3D.VertexFormats.None;
Modified: branches/agate3d-3.2/Tests/Data/shaders/hlsl/PerPixelLighting_pixel.txt
===================================================================
(Binary files differ)
Modified: branches/agate3d-3.2/Tests/Data/shaders/hlsl/PerPixelLighting_vertex.txt
===================================================================
--- branches/agate3d-3.2/Tests/Data/shaders/hlsl/PerPixelLighting_vertex.txt 2009-05-09 22:06:59 UTC (rev 962)
+++ branches/agate3d-3.2/Tests/Data/shaders/hlsl/PerPixelLighting_vertex.txt 2009-05-10 04:13:22 UTC (rev 963)
@@ -3,14 +3,15 @@
struct VS_INPUT
{
float3 position : POSITION;
- float4 color0 : COLOR0;
float2 texcoord0 : TEXCOORD0;
+ float3 normal : NORMAL;
+ float3 tangent : TANGENT;
+ float3 bitangent : BINORMAL;
};
-
+
struct VS_OUTPUT
{
float4 hposition : POSITION;
- float4 color0 : COLOR0;
float2 texcoord0 : TEXCOORD0;
};
@@ -24,7 +25,6 @@
1.0f );
OUT.hposition = mul( v, worldViewProj );
- OUT.color0 = IN.color0;
OUT.texcoord0 = IN.texcoord0;
return OUT;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ka...@us...> - 2009-05-11 06:04:22
|
Revision: 972
http://agate.svn.sourceforge.net/agate/?rev=972&view=rev
Author: kanato
Date: 2009-05-11 06:04:11 +0000 (Mon, 11 May 2009)
Log Message:
-----------
Initial commit of AgateSDX.
Modified Paths:
--------------
branches/agate3d-3.2/Build/AgateLib-Windows.xml
Added Paths:
-----------
branches/agate3d-3.2/Build/Projects/AgateSDX.proj.xml
branches/agate3d-3.2/Drivers/AgateSDX/
branches/agate3d-3.2/Drivers/AgateSDX/D3DDevice.cs
branches/agate3d-3.2/Drivers/AgateSDX/DrawBuffer.cs
branches/agate3d-3.2/Drivers/AgateSDX/HlslCompiler.cs
branches/agate3d-3.2/Drivers/AgateSDX/HlslShaderProgram.cs
branches/agate3d-3.2/Drivers/AgateSDX/PositionColorNormalTexture.cs
branches/agate3d-3.2/Drivers/AgateSDX/Properties/
branches/agate3d-3.2/Drivers/AgateSDX/Properties/AssemblyInfo.cs
branches/agate3d-3.2/Drivers/AgateSDX/Reporter.cs
branches/agate3d-3.2/Drivers/AgateSDX/SDX_Display.cs
branches/agate3d-3.2/Drivers/AgateSDX/SDX_DisplayWindow.cs
branches/agate3d-3.2/Drivers/AgateSDX/SDX_IRenderTarget.cs
branches/agate3d-3.2/Drivers/AgateSDX/SDX_IndexBuffer.cs
branches/agate3d-3.2/Drivers/AgateSDX/SDX_Surface.cs
branches/agate3d-3.2/Drivers/AgateSDX/SDX_VertexBuffer.cs
branches/agate3d-3.2/Drivers/AgateSDX/frmFullScreen.Designer.cs
branches/agate3d-3.2/Drivers/AgateSDX/frmFullScreen.cs
branches/agate3d-3.2/Drivers/AgateSDX/frmFullScreen.resx
Modified: branches/agate3d-3.2/Build/AgateLib-Windows.xml
===================================================================
--- branches/agate3d-3.2/Build/AgateLib-Windows.xml 2009-05-11 05:59:26 UTC (rev 971)
+++ branches/agate3d-3.2/Build/AgateLib-Windows.xml 2009-05-11 06:04:11 UTC (rev 972)
@@ -26,6 +26,7 @@
<?include file="Projects/AgateSDL.proj.xml" ?>
<?include file="Projects/AgateFMOD.proj.xml" ?>
<?include file="Projects/AgateMDX.proj.xml" ?>
+ <?include file="Projects/AgateSDX.proj.xml" ?>
<?include file="Projects/Tests.proj.xml" ?>
</Solution>
Added: branches/agate3d-3.2/Build/Projects/AgateSDX.proj.xml
===================================================================
--- branches/agate3d-3.2/Build/Projects/AgateSDX.proj.xml (rev 0)
+++ branches/agate3d-3.2/Build/Projects/AgateSDX.proj.xml 2009-05-11 06:04:11 UTC (rev 972)
@@ -0,0 +1,30 @@
+<Project name="AgateSDX" path="../Drivers/AgateSDX" language="C#" type="Library" frameworkVersion="v3_5">
+ <Configuration name="Debug">
+ <Options>
+ <OutputPath>../../Binaries/Debug/Drivers</OutputPath>
+ <AllowUnsafe>true</AllowUnsafe>
+ </Options>
+ </Configuration>
+
+ <Configuration name="Release">
+ <Options>
+ <OutputPath>../../Binaries/Release/Drivers</OutputPath>
+ <AllowUnsafe>true</AllowUnsafe>
+ </Options>
+ </Configuration>
+
+ <Reference name="AgateLib"/>
+ <Reference name="AgateLib.WinForms"/>
+ <Reference name="SlimDX"/>
+ <Reference name="System"/>
+ <Reference name="System.Core"/>
+ <Reference name="System.Data"/>
+ <Reference name="System.Drawing"/>
+ <Reference name="System.Windows.Forms"/>
+ <Reference name="System.Xml"/>
+
+ <Files>
+ <Match path="." pattern="*.cs" recurse="true"/>
+ <Match pattern="*.resx" recurse="true"/>
+ </Files>
+</Project>
Property changes on: branches/agate3d-3.2/Drivers/AgateSDX
___________________________________________________________________
Added: svn:ignore
+ [Bb]in
obj
[Dd]ebug
[Rr]elease
*.user
*.aps
*.eto
Copied: branches/agate3d-3.2/Drivers/AgateSDX/D3DDevice.cs (from rev 930, branches/agate3d-3.2/Drivers/AgateMDX/D3DDevice.cs)
===================================================================
--- branches/agate3d-3.2/Drivers/AgateSDX/D3DDevice.cs (rev 0)
+++ branches/agate3d-3.2/Drivers/AgateSDX/D3DDevice.cs 2009-05-11 06:04:11 UTC (rev 972)
@@ -0,0 +1,398 @@
+// The contents of this file are subject to the Mozilla Public License
+// Version 1.1 (the "License"); you may not use this file except in
+// compliance with the License. You may obtain a copy of the License at
+// http://www.mozilla.org/MPL/
+//
+// Software distributed under the License is distributed on an "AS IS"
+// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+// License for the specific language governing rights and limitations
+// under the License.
+//
+// The Original Code is AgateLib.
+//
+// The Initial Developer of the Original Code is Erik Ylvisaker.
+// Portions created by Erik Ylvisaker are Copyright (C) 2006-2009.
+// All Rights Reserved.
+//
+// Contributor(s): Erik Ylvisaker
+//
+using System;
+using System.Collections.Generic;
+using System.Text;
+using Direct3D = SlimDX.Direct3D9;
+using SlimDX.Direct3D9;
+using SlimDX;
+
+using AgateLib.DisplayLib;
+using AgateLib.Geometry;
+using AgateLib.WinForms;
+
+namespace AgateMDX
+{
+ public class D3DDevice : IDisposable
+ {
+ private Device mDevice;
+ private Texture[] mLastTexture = new Texture[8];
+ private SDX_IRenderTarget mRenderTarget;
+ private DrawBuffer mDrawBuffer;
+
+ private VertexFormat mVertexFormat;
+ private bool mAlphaBlend;
+ private TextureArgument mAlphaArgument1;
+ private TextureArgument mAlphaArgument2;
+ private TextureOperation mAlphaOperation;
+
+ private Matrix mWorld2D;
+
+ private int mMaxLightsUsed = 0;
+
+
+ //VertexBuffer mSurfaceVB;
+ //const int NumVertices = 1000;
+ //int mSurfaceVBPointer = 0;
+
+ //readonly int SurfaceVBSize = NumVertices * CustomVertex.TransformedColoredTextured.StrideSize;
+
+ public D3DDevice(Device device)
+ {
+ mDevice = device;
+ mWorld2D = Matrix.Identity;
+
+ //mDevice.DeviceLost += new EventHandler(mDevice_DeviceLost);
+ mDrawBuffer = new DrawBuffer(this);
+ }
+
+ ~D3DDevice()
+ {
+ Dispose(false);
+ }
+
+
+ void mDevice_DeviceLost(object sender, EventArgs e)
+ {
+ // set weird values which will indicate that the device's
+ // render states need to be set.
+ mAlphaBlend = false;
+ mVertexFormat = VertexFormat.None;
+ mAlphaArgument1 = TextureArgument.Temp;
+ mAlphaArgument2 = TextureArgument.Temp;
+ mAlphaOperation = TextureOperation.Add;
+ }
+
+ public void Dispose()
+ {
+ Dispose(true);
+ }
+ private void Dispose(bool disposing)
+ {
+ if (disposing)
+ GC.SuppressFinalize(this);
+
+ if (mDevice != null)
+ {
+ mDevice.Dispose();
+ mDevice = null;
+ }
+ //if (mSurfaceVB != null)
+ //{
+ // mSurfaceVB.Dispose();
+ // mSurfaceVB = null;
+ //}
+ }
+
+ //private void CreateSurfaceVB()
+ //{
+ // //mSurfaceVB = new VertexBuffer(mDevice, SurfaceVBSize,
+ // // Usage.WriteOnly | Usage.Dynamic, CustomVertex.TransformedColoredTextured.Format,
+ // // Pool.Default);
+ //}
+ public Device Device
+ {
+ get { return mDevice; }
+ }
+
+ InterpolationMode lastInterpolation;
+
+ public InterpolationMode Interpolation
+ {
+ get { return lastInterpolation; }
+ set
+ {
+ if (value == lastInterpolation)
+ return;
+
+ DrawBuffer.Flush();
+
+ switch (value)
+ {
+ case InterpolationMode.Default:
+ case InterpolationMode.Nicest:
+ mDevice.SetSamplerState(0, SamplerState.MinFilter, TextureFilter.Anisotropic);
+ mDevice.SetSamplerState(0, SamplerState.MagFilter, TextureFilter.Anisotropic);
+ break;
+
+ case InterpolationMode.Fastest:
+ mDevice.SetSamplerState(0, SamplerState.MinFilter, TextureFilter.Point);
+ mDevice.SetSamplerState(0, SamplerState.MagFilter, TextureFilter.Point);
+ break;
+ }
+
+ lastInterpolation = value;
+ }
+ }
+
+ public SDX_IRenderTarget RenderTarget
+ {
+ get { return mRenderTarget; }
+ set { mRenderTarget = value; }
+ }
+ public DrawBuffer DrawBuffer
+ {
+ get { return mDrawBuffer; }
+ }
+ public VertexFormat VertexFormat
+ {
+ get { return mVertexFormat; }
+ set
+ {
+ if (mVertexFormat != value)
+ {
+ mVertexFormat = value;
+ mDevice.VertexFormat = value;
+ }
+ }
+ }
+ public bool AlphaBlend
+ {
+ get { return mAlphaBlend; }
+ set
+ {
+ if (value != mAlphaBlend)
+ {
+ mAlphaBlend = value;
+ mDevice.SetRenderState(RenderState.AlphaBlendEnable, value);
+ }
+ }
+ }
+ public TextureArgument AlphaArgument1
+ {
+ get { return mAlphaArgument1; }
+ set
+ {
+ if (value != mAlphaArgument1)
+ {
+ mAlphaArgument1 = value;
+ mDevice.SetTextureStageState(0, TextureStage.AlphaArg1, value);
+ }
+
+ }
+ }
+ public TextureArgument AlphaArgument2
+ {
+ get { return mAlphaArgument2; }
+ set
+ {
+ if (value != mAlphaArgument2)
+ {
+ mAlphaArgument2 = value;
+ mDevice.SetTextureStageState(0, TextureStage.AlphaArg2, value);
+ }
+ }
+ }
+ public TextureOperation AlphaOperation
+ {
+ get { return mAlphaOperation; }
+ set
+ {
+ if (value != mAlphaOperation)
+ {
+ mAlphaOperation = value;
+ mDevice.SetTextureStageState(0, TextureStage.AlphaOperation, value);
+ }
+ }
+ }
+ public void Set2DDrawState()
+ {
+ mDevice.SetRenderState(RenderState.SourceBlend, Blend.SourceAlpha);
+ mDevice.SetRenderState(RenderState.DestinationBlend, Blend.InverseSourceAlpha);
+
+ mDevice.SetSamplerState(0, SamplerState.AddressU, TextureAddress.Clamp);
+ mDevice.SetSamplerState(0, SamplerState.AddressV, TextureAddress.Clamp);
+
+ mDevice.SetSamplerState(0, SamplerState.MagFilter, TextureFilter.Anisotropic);
+ mDevice.SetSamplerState(0, SamplerState.MinFilter, TextureFilter.Anisotropic);
+
+ SetView2D();
+ }
+
+
+ public void SetOrthoProjection(Rectangle region)
+ {
+ Matrix orthoProj = Matrix.OrthoOffCenterRH(
+ region.Left, region.Right, region.Bottom, region.Top, -1, 1);
+
+ mDevice.SetTransform(TransformState.Projection, orthoProj);
+ }
+
+ public void SetView2D()
+ {
+ Matrix world = mWorld2D;
+ //Matrix orthoProj = Matrix.OrthoRH(RenderTarget.Width, -RenderTarget.Height, -1, 1);
+ SetOrthoProjection(new Rectangle(0, 0, RenderTarget.Width, RenderTarget.Height));
+
+ mDevice.SetRenderState(RenderState.CullMode, Cull.None);
+ mDevice.SetRenderState(RenderState.Lighting, false);
+
+ mDevice.SetTransform(TransformState.World, world);
+ mDevice.SetTransform(TransformState.View, Matrix.Identity);
+ }
+ public void SetFontRenderState()
+ {
+ mLastTexture = null;
+ mVertexFormat = VertexFormat.PointSize;
+ }
+
+ public void SetDeviceStateTexture(Texture texture)
+ {
+ SetDeviceStateTexture(texture, 0);
+ }
+ public void SetDeviceStateTexture(Texture texture, int index)
+ {
+ if (texture == mLastTexture[index])
+ return;
+
+ mDevice.SetTexture(index, texture);
+
+ mLastTexture[index] = texture;
+
+ if (texture != null)
+ {
+ AlphaArgument1 = TextureArgument.Texture;
+ AlphaArgument2 = TextureArgument.Diffuse;
+ AlphaOperation = TextureOperation.Modulate;
+ }
+ }
+
+ public void SetOrigin(float x, float y, float z)
+ {
+ Matrix world = Matrix.Translation(x, y, z) * mWorld2D;
+
+ mDevice.SetTransform(TransformState.World, world);
+ }
+
+ public Size MaxSurfaceSize
+ {
+ get
+ {
+ Size retval = new Size(
+ mDevice.Capabilities.MaxTextureWidth, mDevice.Capabilities.MaxTextureHeight);
+
+ return retval;
+ }
+ }
+
+ public void Clear(ClearFlags flags, int color, float zdepth, int stencil)
+ {
+ mDevice.Clear(flags, color, zdepth, stencil);
+ }
+
+ public void Clear(ClearFlags flags, int color, float zdepth, int stencil, System.Drawing.Rectangle[] rects)
+ {
+ mDevice.Clear(flags, color, zdepth, stencil, rects);
+ }
+
+ //public void WriteToSurfaceVBAndRender
+ // (PrimitiveType primitiveType, int primCount, CustomVertex.TransformedColoredTextured[] verts)
+ //{
+ // GraphicsStream stm;
+
+ // if (mSurfaceVBPointer + verts.Length < NumVertices)
+ // {
+ // stm = mSurfaceVB.Lock(mSurfaceVBPointer,
+ // CustomVertex.TransformedColoredTextured.StrideSize * verts.Length,
+ // LockFlags.NoOverwrite);
+
+ // }
+ // else
+ // {
+ // mSurfaceVBPointer = 0;
+
+ // stm = mSurfaceVB.Lock(mSurfaceVBPointer,
+ // CustomVertex.TransformedColoredTextured.StrideSize * verts.Length,
+ // LockFlags.Discard);
+ // }
+
+ // stm.Write(verts);
+
+ // mSurfaceVB.Unlock();
+
+ // mDevice.SetStreamSource(0, mSurfaceVB, 0);
+ // mDevice.VertexFormat = CustomVertex.TransformedColoredTextured.Format;
+ // mDevice.DrawPrimitives(primitiveType, mSurfaceVBPointer, primCount);
+
+ // mSurfaceVBPointer += verts.Length;
+ //}
+
+
+
+ internal void DoLighting(LightManager lights)
+ {
+ if (lights.Enabled == false)
+ {
+ mDevice.SetRenderState(RenderState.Lighting, false);
+ return;
+ }
+
+ mDevice.SetRenderState(RenderState.Lighting, true);
+ mDevice.SetRenderState(RenderState.DiffuseMaterialSource, ColorSource.Color1);
+ mDevice.SetRenderState(RenderState.AmbientMaterialSource, ColorSource.Color1);
+
+ mDevice.SetRenderState(RenderState.Ambient, lights.Ambient.ToArgb());
+
+ //Material mat = new Material();
+ //mat.Diffuse = System.Drawing.Color.White;
+
+ //mDevice.Material = mat;
+ //Direct3D.Light light = new SlimDX.Direct3D9.Light();
+
+ //for (int i = 0; i < mMaxLightsUsed || i < lights.Count; i++)
+ //{
+ // if (i >= lights.Count)
+ // {
+ // mDevice.SetLight(i, Direct3D.Ligh
+ // mDevice.SetLight(i, [i].Enabled = false;
+ // mDevice.Lights[i].Update();
+
+ // continue;
+ // }
+ // if (lights[i].Enabled == false)
+ // {
+ // mDevice.Lights[i].Enabled = false;
+ // mDevice.Lights[i].Update();
+
+ // continue;
+ // }
+
+ // mDevice.Lights[i].Type = LightType.Point;
+
+ // mDevice.Lights[i].Attenuation0 = lights[i].AttenuationConstant;
+ // mDevice.Lights[i].Attenuation1 = lights[i].AttenuationLinear;
+ // mDevice.Lights[i].Attenuation2 = lights[i].AttenuationQuadratic;
+
+ // mDevice.Lights[i].Diffuse = Interop.Convert(lights[i].Diffuse);
+ // mDevice.Lights[i].Ambient = Interop.Convert(lights[i].Ambient);
+ // //mDevice.Lights[i].Specular = (System.Drawing.Color)lights[i].Specular;
+
+ // mDevice.Lights[i].Position = new SlimDX.Vector3(
+ // lights[i].Position.X, lights[i].Position.Y, lights[i].Position.Z);
+
+ // mDevice.Lights[i].Range = lights[i].Range;
+
+ // mDevice.Lights[i].Enabled = true;
+ // mDevice.Lights[i].Update();
+ //}
+
+ mMaxLightsUsed = lights.Count;
+ }
+ }
+}
\ No newline at end of file
Copied: branches/agate3d-3.2/Drivers/AgateSDX/DrawBuffer.cs (from rev 958, branches/agate3d-3.2/Drivers/AgateMDX/DrawBuffer.cs)
===================================================================
--- branches/agate3d-3.2/Drivers/AgateSDX/DrawBuffer.cs (rev 0)
+++ branches/agate3d-3.2/Drivers/AgateSDX/DrawBuffer.cs 2009-05-11 06:04:11 UTC (rev 972)
@@ -0,0 +1,119 @@
+// The contents of this file are subject to the Mozilla Public License
+// Version 1.1 (the "License"); you may not use this file except in
+// compliance with the License. You may obtain a copy of the License at
+// http://www.mozilla.org/MPL/
+//
+// Software distributed under the License is distributed on an "AS IS"
+// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+// License for the specific language governing rights and limitations
+// under the License.
+//
+// The Original Code is AgateLib.
+//
+// The Initial Developer of the Original Code is Erik Ylvisaker.
+// Portions created by Erik Ylvisaker are Copyright (C) 2006-2009.
+// All Rights Reserved.
+//
+// Contributor(s): Erik Ylvisaker
+//
+using System;
+using System.Collections.Generic;
+using System.Runtime.InteropServices;
+using System.Text;
+using SlimDX;
+using SlimDX.Direct3D9;
+using Direct3D = SlimDX.Direct3D9;
+using AgateLib.DisplayLib;
+
+namespace AgateMDX
+{
+ /// <summary>
+ /// Perhaps at some point this should be converted to use a vertex buffer
+ /// instead of a vertex array.
+ /// </summary>
+ public class DrawBuffer
+ {
+ const int vertPageSize = 1000;
+ int pages = 1;
+
+ D3DDevice mDevice;
+
+ PositionColorNormalTexture[] mVerts;
+ short[] mIndices;
+
+ int mVertPointer = 0;
+ int mIndexPointer = 0;
+
+ Texture mTexture;
+ bool mAlphaBlend;
+
+ public DrawBuffer(D3DDevice device)
+ {
+ mDevice = device;
+
+ AllocateVerts();
+ }
+
+ private void AllocateVerts()
+ {
+ mVerts = new PositionColorNormalTexture[vertPageSize * pages];
+ mIndices = new short[vertPageSize / 2 * 3 * pages];
+ }
+ public void CacheDrawIndexedTriangles(PositionColorNormalTexture[] verts, short[] indices,
+ Texture texture, bool alphaBlend)
+ {
+ if (mTexture != texture || mAlphaBlend != alphaBlend)
+ {
+ Flush();
+
+ mTexture = texture;
+ mAlphaBlend = alphaBlend;
+ }
+
+ // increase the number of vertex pages if we don't have enough space.
+ while (mVertPointer + verts.Length > mVerts.Length)
+ {
+ Flush();
+
+ // this is an arbitrary cap on the size of the vertex array.
+ if (pages < 32)
+ pages++;
+
+ AllocateVerts();
+ }
+
+ verts.CopyTo(mVerts, mVertPointer);
+
+ for (int i = 0; i < indices.Length; i++)
+ mIndices[i + mIndexPointer] = (short)(indices[i] + mVertPointer);
+
+ mVertPointer += verts.Length;
+ mIndexPointer += indices.Length;
+
+ }
+
+ public void Flush()
+ {
+ if (mVertPointer == 0)
+ return;
+
+ mDevice.SetDeviceStateTexture(mTexture);
+ mDevice.AlphaBlend = mAlphaBlend;
+ mDevice.VertexFormat = PositionColorNormalTexture.Format;
+
+ try
+ {
+ mDevice.Device.DrawIndexedUserPrimitives
+ (Direct3D.PrimitiveType.TriangleList, 0, mVertPointer,
+ mIndexPointer / 3, mIndices, Format.Index16, mVerts,
+ Marshal.SizeOf(typeof(PositionColorNormalTexture)));
+ }
+ catch { }
+
+ mVertPointer = 0;
+ mIndexPointer = 0;
+
+ }
+
+ }
+}
Copied: branches/agate3d-3.2/Drivers/AgateSDX/HlslCompiler.cs (from rev 963, branches/agate3d-3.2/Drivers/AgateMDX/HlslCompiler.cs)
===================================================================
--- branches/agate3d-3.2/Drivers/AgateSDX/HlslCompiler.cs (rev 0)
+++ branches/agate3d-3.2/Drivers/AgateSDX/HlslCompiler.cs 2009-05-11 06:04:11 UTC (rev 972)
@@ -0,0 +1,50 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using AgateLib.DisplayLib.Shaders;
+using AgateLib.ImplementationBase;
+using Direct3D = SlimDX.Direct3D9;
+
+namespace AgateMDX
+{
+ class HlslCompiler : ShaderCompilerImpl
+ {
+ SDX_Display mDisplay;
+
+ public HlslCompiler(SDX_Display display)
+ {
+ mDisplay = display;
+ }
+
+ public override ShaderProgram CompileEffect(ShaderLanguage language, string effectSource)
+ {
+ throw new NotImplementedException();
+ }
+ //public override ShaderProgram CompileEffect(ShaderLanguage language, string effectSource)
+ //{
+ // Direct3D.Effect effect = Direct3D.Effect.FromString(mDisplay.D3D_Device.Device,
+ // effectSource, null, null, Direct3D.ShaderFlags.None, null);
+
+ // return new HlslShaderProgram(effect);
+ //}
+ public override ShaderProgram CompileShader(ShaderLanguage language, string vertexShaderSource, string pixelShaderSource)
+ {
+ throw new NotImplementedException();
+
+ //var vertexShaderStream = Direct3D.ShaderLoader.CompileShader(
+ // vertexShaderSource, "main", null, "vs_1_1", Direct3D.ShaderFlags.None);
+
+
+ //var vertexShader = new Direct3D.VertexShader(mDisplay.D3D_Device.Device, vertexShaderStream);
+
+
+ //var pixelShaderStream = Direct3D.ShaderLoader.CompileShader(
+ // pixelShaderSource, "main", null, "ps_1_1", Direct3D.ShaderFlags.None);
+
+ //var pixelShader = new Direct3D.PixelShader(mDisplay.D3D_Device.Device, pixelShaderStream);
+
+ //return new HlslShaderProgram(vertexShader, pixelShader);
+ }
+ }
+}
Copied: branches/agate3d-3.2/Drivers/AgateSDX/HlslShaderProgram.cs (from rev 963, branches/agate3d-3.2/Drivers/AgateMDX/HlslShaderProgram.cs)
===================================================================
--- branches/agate3d-3.2/Drivers/AgateSDX/HlslShaderProgram.cs (rev 0)
+++ branches/agate3d-3.2/Drivers/AgateSDX/HlslShaderProgram.cs 2009-05-11 06:04:11 UTC (rev 972)
@@ -0,0 +1,83 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using AgateLib.DisplayLib;
+using AgateLib.DisplayLib.Shaders;
+using Direct3D = SlimDX.Direct3D9;
+
+namespace AgateMDX
+{
+ class HlslShaderProgram : ShaderProgram
+ {
+ Direct3D.VertexShader mVertexShader;
+ Direct3D.PixelShader mPixelShader;
+ SDX_Display mDisplay;
+
+ public HlslShaderProgram(Direct3D.VertexShader vert, Direct3D.PixelShader pix)
+ {
+ mDisplay = (SDX_Display)Display.Impl;
+
+ mVertexShader = vert;
+ mPixelShader = pix;
+ }
+ public override PixelShader PixelShader
+ {
+ get { throw new NotImplementedException(); }
+ }
+
+ public override void SetUniform(string name, AgateLib.Geometry.Matrix4 matrix)
+ {
+
+ }
+
+ public override void SetUniform(string name, params int[] v)
+ {
+
+ }
+
+ public override void SetUniform(string name, params float[] v)
+ {
+
+ }
+
+ public override VertexShader VertexShader
+ {
+ get { throw new NotImplementedException(); }
+ }
+
+ public Direct3D.VertexShader HlslVertexShader
+ {
+ get { return mVertexShader; }
+ }
+ public Direct3D.PixelShader HlslPixelShader
+ {
+ get { return mPixelShader; }
+ }
+
+ public override void Render(RenderHandler handler, object obj)
+ {
+ mDisplay.D3D_Device.Device.VertexShader = mVertexShader;
+ mDisplay.D3D_Device.Device.PixelShader = mPixelShader;
+
+ handler(obj);
+ //int passcount = mEffect.Begin(SlimDX.Direct3D9.FX.None);
+
+ //for (int i = 0; i < passcount; i++)
+ //{
+ // mEffect.BeginPass(i);
+ // handler(obj);
+ // mEffect.EndPass();
+ //}
+
+ //mEffect.End();
+ }
+ }
+
+ class HlslPixelShader : PixelShader
+ {
+ }
+
+ class HlslVertexShader : VertexShader
+ { }
+}
Copied: branches/agate3d-3.2/Drivers/AgateSDX/PositionColorNormalTexture.cs (from rev 922, branches/agate3d-3.2/Drivers/AgateMDX/PositionColorNormalTexture.cs)
===================================================================
--- branches/agate3d-3.2/Drivers/AgateSDX/PositionColorNormalTexture.cs (rev 0)
+++ branches/agate3d-3.2/Drivers/AgateSDX/PositionColorNormalTexture.cs 2009-05-11 06:04:11 UTC (rev 972)
@@ -0,0 +1,89 @@
+// The contents of this file are subject to the Mozilla Public License
+// Version 1.1 (the "License"); you may not use this file except in
+// compliance with the License. You may obtain a copy of the License at
+// http://www.mozilla.org/MPL/
+//
+// Software distributed under the License is distributed on an "AS IS"
+// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+// License for the specific language governing rights and limitations
+// under the License.
+//
+// The Original Code is AgateLib.
+//
+// The Initial Developer of the Original Code is Erik Ylvisaker.
+// Portions created by Erik Ylvisaker are Copyright (C) 2006-2009.
+// All Rights Reserved.
+//
+// Contributor(s): Erik Ylvisaker
+//
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Runtime.InteropServices;
+using SlimDX;
+using SlimDX.Direct3D9;
+
+namespace AgateMDX
+{
+ [StructLayout(LayoutKind.Sequential)]
+ public struct PositionColorNormalTexture
+ {
+ public float X, Y, Z;
+ public float nx, ny, nz;
+ public int Color;
+ public float Tu, Tv;
+
+ public static VertexFormat Format =
+ VertexFormat.PositionNormal | VertexFormat.Diffuse | VertexFormat.Texture1;
+
+ public PositionColorNormalTexture(float x, float y, float z, int color, float tu, float tv,
+ float nx, float ny, float nz)
+ {
+ X = x;
+ Y = y;
+ Z = z;
+ Color = color;
+ Tu = tu;
+ Tv = tv;
+ this.nx = nx;
+ this.ny = ny;
+ this.nz = nz;
+ }
+
+ public override string ToString()
+ {
+ return string.Format("X: {0} Y: {1} Z: {2} Color: {3} Tu: {4}, Tv: {5}",
+ X, Y, Z, Color, Tu, Tv);
+ }
+ }
+
+ [StructLayout(LayoutKind.Sequential)]
+ public struct PositionColored
+ {
+ public float x, y, z;
+ public int Color;
+
+ public Vector3 Position
+ {
+ get { return new Vector3(x, y, z); }
+ set
+ {
+ x = value.X;
+ y = value.Y;
+ z = value.Z;
+ }
+ }
+ public PositionColored(float x, float y, float z, AgateLib.Geometry.Color clr)
+ : this(x, y, z, clr.ToArgb())
+ { }
+ public PositionColored(float x, float y, float z, int clr)
+ {
+ this.x = x;
+ this.y = y;
+ this.z = z;
+ this.Color = clr;
+ }
+ public static VertexFormat Format =
+ VertexFormat.Position | VertexFormat.Diffuse;
+ }
+}
Added: branches/agate3d-3.2/Drivers/AgateSDX/Properties/AssemblyInfo.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateSDX/Properties/AssemblyInfo.cs (rev 0)
+++ branches/agate3d-3.2/Drivers/AgateSDX/Properties/AssemblyInfo.cs 2009-05-11 06:04:11 UTC (rev 972)
@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("AgateSDX")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("AgateSDX")]
+[assembly: AssemblyCopyright("Copyright © 2009")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("04704349-3b13-4991-97c6-c5e78fe93806")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
Copied: branches/agate3d-3.2/Drivers/AgateSDX/Reporter.cs (from rev 922, branches/agate3d-3.2/Drivers/AgateMDX/Reporter.cs)
===================================================================
--- branches/agate3d-3.2/Drivers/AgateSDX/Reporter.cs (rev 0)
+++ branches/agate3d-3.2/Drivers/AgateSDX/Reporter.cs 2009-05-11 06:04:11 UTC (rev 972)
@@ -0,0 +1,49 @@
+// The contents of this file are subject to the Mozilla Public License
+// Version 1.1 (the "License"); you may not use this file except in
+// compliance with the License. You may obtain a copy of the License at
+// http://www.mozilla.org/MPL/
+//
+// Software distributed under the License is distributed on an "AS IS"
+// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+// License for the specific language governing rights and limitations
+// under the License.
+//
+// The Original Code is AgateLib.
+//
+// The Initial Developer of the Original Code is Erik Ylvisaker.
+// Portions created by Erik Ylvisaker are Copyright (C) 2006-2009.
+// All Rights Reserved.
+//
+// Contributor(s): Erik Ylvisaker
+//
+using System;
+using System.Collections.Generic;
+using System.Text;
+using AgateLib.Drivers;
+
+namespace AgateMDX
+{
+ class Reporter : AgateDriverReporter
+ {
+ public override IEnumerable<AgateDriverInfo> ReportDrivers()
+ {
+ yield return new AgateDriverInfo(
+ DisplayTypeID.Direct3D9_SDX,
+ typeof(SDX_Display),
+ "SlimDX - Direct3D 9",
+ 500);
+
+ //yield return new AgateDriverInfo(
+ // AudioTypeID.DirectSound,
+ // typeof(MDX1_Audio),
+ // "Managed DirectX 1.1 - DirectSound",
+ // 100);
+
+ //yield return new AgateDriverInfo(
+ // InputTypeID.DirectInput,
+ // typeof(MDX1_Input),
+ // "Managed DirectX 1.1 - DirectInput",
+ // 100);
+ }
+ }
+}
Copied: branches/agate3d-3.2/Drivers/AgateSDX/SDX_Display.cs (from rev 963, branches/agate3d-3.2/Drivers/AgateMDX/MDX1_Display.cs)
===================================================================
--- branches/agate3d-3.2/Drivers/AgateSDX/SDX_Display.cs (rev 0)
+++ branches/agate3d-3.2/Drivers/AgateSDX/SDX_Display.cs 2009-05-11 06:04:11 UTC (rev 972)
@@ -0,0 +1,1064 @@
+// The contents of this file are subject to the Mozilla Public License
+// Version 1.1 (the "License"); you may not use this file except in
+// compliance with the License. You may obtain a copy of the License at
+// http://www.mozilla.org/MPL/
+//
+// Software distributed under the License is distributed on an "AS IS"
+// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+// License for the specific language governing rights and limitations
+// under the License.
+//
+// The Original Code is AgateLib.
+//
+// The Initial Developer of the Original Code is Erik Ylvisaker.
+// Portions created by Erik Ylvisaker are Copyright (C) 2006-2009.
+// All Rights Reserved.
+//
+// Contributor(s): Erik Ylvisaker
+//
+using System;
+using System.Collections.Generic;
+using System.Text;
+using Direct3D = SlimDX.Direct3D9;
+using SlimDX.Direct3D9;
+using SlimDX;
+
+using AgateLib.BitmapFont;
+using AgateLib.DisplayLib;
+using AgateLib.Drivers;
+using AgateLib.Geometry;
+using AgateLib.ImplementationBase;
+using AgateLib.WinForms;
+
+using Vector2 = SlimDX.Vector2;
+using Im...
[truncated message content] |
|
From: <ka...@us...> - 2009-05-11 06:56:14
|
Revision: 975
http://agate.svn.sourceforge.net/agate/?rev=975&view=rev
Author: kanato
Date: 2009-05-11 06:56:04 +0000 (Mon, 11 May 2009)
Log Message:
-----------
Move Push/pop clip rect implementations to DisplayLib/Display.cs.
Modified Paths:
--------------
branches/agate3d-3.2/AgateLib/AgateApplication.cs
branches/agate3d-3.2/AgateLib/DisplayLib/Display.cs
branches/agate3d-3.2/AgateLib/ImplementationBase/DisplayImpl.cs
branches/agate3d-3.2/Drivers/AgateDrawing/Drawing_Display.cs
branches/agate3d-3.2/Drivers/AgateMDX/MDX1_Display.cs
branches/agate3d-3.2/Drivers/AgateOTK/GL_Display.cs
branches/agate3d-3.2/Drivers/AgateSDX/SDX_Display.cs
Modified: branches/agate3d-3.2/AgateLib/AgateApplication.cs
===================================================================
--- branches/agate3d-3.2/AgateLib/AgateApplication.cs 2009-05-11 06:30:52 UTC (rev 974)
+++ branches/agate3d-3.2/AgateLib/AgateApplication.cs 2009-05-11 06:56:04 UTC (rev 975)
@@ -237,7 +237,7 @@
Surface powered = InternalResources.Data.PoweredBy;
Size size = powered.SurfaceSize;
- int left = (int)(totalSplashTime * size.Width - size.Width);
+ int left = (int)(totalSplashTime * size.Width - size.Width)+1;
Rectangle gradientRect = new Rectangle(left, MainWindow.Height - size.Height,
size.Width, size.Height);
Modified: branches/agate3d-3.2/AgateLib/DisplayLib/Display.cs
===================================================================
--- branches/agate3d-3.2/AgateLib/DisplayLib/Display.cs 2009-05-11 06:30:52 UTC (rev 974)
+++ branches/agate3d-3.2/AgateLib/DisplayLib/Display.cs 2009-05-11 06:56:04 UTC (rev 975)
@@ -61,7 +61,9 @@
private static DisplayImpl impl;
private static DisplayWindow mCurrentWindow;
private static SurfacePacker mSurfacePacker;
-
+ private static Rectangle mCurrentClipRect;
+ private static Stack<Rectangle> mClipRects = new Stack<Rectangle>();
+
/// <summary>
/// Gets the object which handles all of the actual calls to Display functions.
/// This may be cast to a surface object in whatever rendering library
@@ -318,15 +320,24 @@
/// <param name="newClipRect"></param>
public static void PushClipRect(Rectangle newClipRect)
{
- impl.PushClipRect(newClipRect);
+ mClipRects.Push(mCurrentClipRect);
+ SetClipRect(newClipRect);
}
/// <summary>
/// Pops the clip rect and restores the previous clip rect.
/// </summary>
public static void PopClipRect()
{
- impl.PopClipRect();
+ if (mClipRects.Count == 0)
+ {
+ throw new Exception("You have popped the cliprect too many times.");
+ }
+ else
+ {
+ SetClipRect(mClipRects.Pop());
+ }
}
+
/// <summary>
/// Returns the maximum size a surface object can be.
/// </summary>
Modified: branches/agate3d-3.2/AgateLib/ImplementationBase/DisplayImpl.cs
===================================================================
--- branches/agate3d-3.2/AgateLib/ImplementationBase/DisplayImpl.cs 2009-05-11 06:30:52 UTC (rev 974)
+++ branches/agate3d-3.2/AgateLib/ImplementationBase/DisplayImpl.cs 2009-05-11 06:56:04 UTC (rev 975)
@@ -321,22 +321,13 @@
/// </summary>
public abstract Size MaxSurfaceSize { get; }
- #region --- Clip Rect stuff ---
+ #region --- SetClipRect ---
/// <summary>
/// Set the current clipping rect.
/// </summary>
/// <param name="newClipRect"></param>
public abstract void SetClipRect(Rectangle newClipRect);
- /// <summary>
- /// Pushes a clip rect onto the clip rect stack.
- /// </summary>
- /// <param name="newClipRect"></param>
- public abstract void PushClipRect(Rectangle newClipRect);
- /// <summary>
- /// Pops the clip rect and restores the previous clip rect.
- /// </summary>
- public abstract void PopClipRect();
#endregion
#region --- Direct modification of the back buffer ---
Modified: branches/agate3d-3.2/Drivers/AgateDrawing/Drawing_Display.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateDrawing/Drawing_Display.cs 2009-05-11 06:30:52 UTC (rev 974)
+++ branches/agate3d-3.2/Drivers/AgateDrawing/Drawing_Display.cs 2009-05-11 06:56:04 UTC (rev 975)
@@ -42,9 +42,6 @@
private bool mInFrame = false;
- private Stack<Geometry.Rectangle> mClipRects = new Stack<Geometry.Rectangle>();
- private Geometry.Rectangle mCurrentClipRect;
-
#endregion
#region --- Events and Event Handlers ---
@@ -207,9 +204,6 @@
mGraphics.Dispose();
mGraphics = null;
- while (mClipRects.Count > 0)
- PopClipRect();
-
Drawing_IRenderTarget renderTarget = RenderTarget.Impl as Drawing_IRenderTarget;
renderTarget.EndRender();
@@ -220,24 +214,9 @@
public override void SetClipRect(Geometry.Rectangle newClipRect)
{
mGraphics.SetClip(Interop.Convert(newClipRect));
- mCurrentClipRect = newClipRect;
}
- public override void PushClipRect(Geometry.Rectangle newClipRect)
- {
- mClipRects.Push(mCurrentClipRect);
- SetClipRect(newClipRect);
- }
- public override void PopClipRect()
- {
-#if DEBUG
- if (mClipRects.Count == 0)
- throw new Exception("The cliprect has been popped too many times.");
-#endif
- SetClipRect(mClipRects.Pop());
- }
-
#endregion
protected override void ProcessEvents()
Modified: branches/agate3d-3.2/Drivers/AgateMDX/MDX1_Display.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateMDX/MDX1_Display.cs 2009-05-11 06:30:52 UTC (rev 974)
+++ branches/agate3d-3.2/Drivers/AgateMDX/MDX1_Display.cs 2009-05-11 06:56:04 UTC (rev 975)
@@ -261,12 +261,7 @@
protected override void OnEndFrame()
{
mDevice.DrawBuffer.Flush();
-
- while (mClipRects.Count > 0)
- PopClipRect();
-
mRenderTarget.EndRender();
-
}
#endregion
@@ -305,30 +300,12 @@
view.Height = newClipRect.Height;
mDevice.Device.Viewport = view;
- mCurrentClipRect = newClipRect;
SetOrthoProjection(newClipRect);
}
- public override void PushClipRect(Rectangle newClipRect)
- {
- mClipRects.Push(mCurrentClipRect);
- SetClipRect(newClipRect);
- }
- public override void PopClipRect()
- {
- if (mClipRects.Count == 0)
- {
- throw new Exception("You have popped the cliprect too many times.");
- }
- else
- {
- SetClipRect(mClipRects.Pop());
- }
- }
+
- private Stack<Rectangle> mClipRects = new Stack<Rectangle>();
- private Rectangle mCurrentClipRect;
-
+
#endregion
#region --- Methods for drawing to the back buffer ---
Modified: branches/agate3d-3.2/Drivers/AgateOTK/GL_Display.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateOTK/GL_Display.cs 2009-05-11 06:30:52 UTC (rev 974)
+++ branches/agate3d-3.2/Drivers/AgateOTK/GL_Display.cs 2009-05-11 06:56:04 UTC (rev 975)
@@ -173,20 +173,6 @@
mCurrentClip = newClipRect;
}
- public override void PushClipRect(Rectangle newClipRect)
- {
- mClipRects.Push(mCurrentClip);
-
- SetClipRect(newClipRect);
- }
-
- public override void PopClipRect()
- {
- SetClipRect(mClipRects.Peek());
-
- mClipRects.Pop();
- }
-
public override void FlushDrawBuffer()
{
mState.DrawBuffer.Flush();
Modified: branches/agate3d-3.2/Drivers/AgateSDX/SDX_Display.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateSDX/SDX_Display.cs 2009-05-11 06:30:52 UTC (rev 974)
+++ branches/agate3d-3.2/Drivers/AgateSDX/SDX_Display.cs 2009-05-11 06:56:04 UTC (rev 975)
@@ -269,12 +269,7 @@
protected override void OnEndFrame()
{
mDevice.DrawBuffer.Flush();
-
- while (mClipRects.Count > 0)
- PopClipRect();
-
mRenderTarget.EndRender();
-
}
#endregion
@@ -311,28 +306,19 @@
view.Y = newClipRect.Y;
view.Width = newClipRect.Width;
view.Height = newClipRect.Height;
+ view.MinZ = 0;
+ view.MaxZ = 1;
- //mDevice.Device.Viewport = view;
+ if (view.Width == 0 || view.Height == 0)
+ {
+ throw new AgateLib.AgateException("Cannot set a cliprect with a width / height of zero.");
+ }
+
+ mDevice.Device.Viewport = view;
mCurrentClipRect = newClipRect;
SetOrthoProjection(newClipRect);
}
- public override void PushClipRect(Rectangle newClipRect)
- {
- mClipRects.Push(mCurrentClipRect);
- SetClipRect(newClipRect);
- }
- public override void PopClipRect()
- {
- if (mClipRects.Count == 0)
- {
- throw new Exception("You have popped the cliprect too many times.");
- }
- else
- {
- SetClipRect(mClipRects.Pop());
- }
- }
private Stack<Rectangle> mClipRects = new Stack<Rectangle>();
private Rectangle mCurrentClipRect;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ka...@us...> - 2009-05-13 05:35:46
|
Revision: 981
http://agate.svn.sourceforge.net/agate/?rev=981&view=rev
Author: kanato
Date: 2009-05-13 05:35:39 +0000 (Wed, 13 May 2009)
Log Message:
-----------
Eliminate use of normals in AgateSDX for drawing surfaces.
Move PositionColor and PositionTextureColor structures to AgateLib/Geometry/VertexTypes.
Modified Paths:
--------------
branches/agate3d-3.2/AgateLib/DisplayLib/Display.cs
branches/agate3d-3.2/AgateLib/DisplayLib/Light.cs
branches/agate3d-3.2/AgateLib/DisplayLib/LightManager.cs
branches/agate3d-3.2/AgateLib/DisplayLib/Surface.cs
branches/agate3d-3.2/AgateLib/Drivers/TypeID.cs
branches/agate3d-3.2/AgateLib/Geometry/VertexTypes/VertexLayout.cs
branches/agate3d-3.2/Drivers/AgateOTK/GL_Surface.cs
branches/agate3d-3.2/Drivers/AgateSDX/AgateSDX.csproj
branches/agate3d-3.2/Drivers/AgateSDX/D3DDevice.cs
branches/agate3d-3.2/Drivers/AgateSDX/DrawBuffer.cs
branches/agate3d-3.2/Drivers/AgateSDX/SDX_Display.cs
branches/agate3d-3.2/Drivers/AgateSDX/SDX_Surface.cs
branches/agate3d-3.2/Drivers/AgateSDX/SDX_VertexBuffer.cs
branches/agate3d-3.2/Tests/DisplayTests/PixelBufferTest/PixelBufferTest.cs
branches/agate3d-3.2/Tests/DisplayTests/TileTester/TileTester.cs
branches/agate3d-3.2/Tests/DisplayTests/TileTester/frmTileTester.Designer.cs
branches/agate3d-3.2/Tests/DisplayTests/TileTester/frmTileTester.cs
Added Paths:
-----------
branches/agate3d-3.2/AgateLib/Geometry/VertexTypes/PositionColor.cs
branches/agate3d-3.2/AgateLib/Geometry/VertexTypes/PositionTextureColor.cs
branches/agate3d-3.2/Drivers/AgateSDX/VertexFormats.cs
Removed Paths:
-------------
branches/agate3d-3.2/Drivers/AgateSDX/PositionColorNormalTexture.cs
Modified: branches/agate3d-3.2/AgateLib/DisplayLib/Display.cs
===================================================================
--- branches/agate3d-3.2/AgateLib/DisplayLib/Display.cs 2009-05-11 15:22:15 UTC (rev 980)
+++ branches/agate3d-3.2/AgateLib/DisplayLib/Display.cs 2009-05-13 05:35:39 UTC (rev 981)
@@ -276,6 +276,7 @@
throw new AgateException("The current window has been closed, and a new render target has not been set. A render target must be set to continue rendering.");
impl.BeginFrame();
+ mCurrentClipRect = new Rectangle(0, 0, RenderTarget.Width, RenderTarget.Height);
}
/// <summary>
/// EndFrame must be called at the end of each frame.
@@ -330,7 +331,7 @@
{
if (mClipRects.Count == 0)
{
- throw new Exception("You have popped the cliprect too many times.");
+ throw new AgateException("You have popped the cliprect too many times.");
}
else
{
Modified: branches/agate3d-3.2/AgateLib/DisplayLib/Light.cs
===================================================================
--- branches/agate3d-3.2/AgateLib/DisplayLib/Light.cs 2009-05-11 15:22:15 UTC (rev 980)
+++ branches/agate3d-3.2/AgateLib/DisplayLib/Light.cs 2009-05-13 05:35:39 UTC (rev 981)
@@ -27,6 +27,7 @@
/// Class which represents a single light source.
/// Only point light sources are supported at the moment.
/// </summary>
+ [Obsolete("Use shaders to accomplish lighting instead.")]
public class Light
{
private bool mEnabled = true;
Modified: branches/agate3d-3.2/AgateLib/DisplayLib/LightManager.cs
===================================================================
--- branches/agate3d-3.2/AgateLib/DisplayLib/LightManager.cs 2009-05-11 15:22:15 UTC (rev 980)
+++ branches/agate3d-3.2/AgateLib/DisplayLib/LightManager.cs 2009-05-13 05:35:39 UTC (rev 981)
@@ -27,6 +27,7 @@
/// The LightManager class keeps a list of Light objects which can be used
/// to setup the lighting in the rendering API.
/// </summary>
+ [Obsolete("Use shaders to accomplish lighting instead.")]
public class LightManager : IList<Light>
{
List<Light> mLights = new List<Light>();
Modified: branches/agate3d-3.2/AgateLib/DisplayLib/Surface.cs
===================================================================
--- branches/agate3d-3.2/AgateLib/DisplayLib/Surface.cs 2009-05-11 15:22:15 UTC (rev 980)
+++ branches/agate3d-3.2/AgateLib/DisplayLib/Surface.cs 2009-05-13 05:35:39 UTC (rev 981)
@@ -256,6 +256,7 @@
/// </para>
/// </remarks>
///
+ [Obsolete("Use shaders for lighting effects.")]
public int TesselateFactor
{
get { return impl.TesselateFactor; }
Modified: branches/agate3d-3.2/AgateLib/Drivers/TypeID.cs
===================================================================
--- branches/agate3d-3.2/AgateLib/Drivers/TypeID.cs 2009-05-11 15:22:15 UTC (rev 980)
+++ branches/agate3d-3.2/AgateLib/Drivers/TypeID.cs 2009-05-13 05:35:39 UTC (rev 981)
@@ -101,10 +101,9 @@
/// </summary>
DirectSound = 0x100,
/// <summary>
- /// Implementation using XNA Studio
- /// (what will this be called), anyway?)
+ /// Implementation using XAudio2, the new replacement for DirectSound.
/// </summary>
- XAct = 0x110,
+ XAudio2 = 0x110,
/// <summary>
/// Implementation using the cross-platform OpenAL library.
Added: branches/agate3d-3.2/AgateLib/Geometry/VertexTypes/PositionColor.cs
===================================================================
--- branches/agate3d-3.2/AgateLib/Geometry/VertexTypes/PositionColor.cs (rev 0)
+++ branches/agate3d-3.2/AgateLib/Geometry/VertexTypes/PositionColor.cs 2009-05-13 05:35:39 UTC (rev 981)
@@ -0,0 +1,37 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Runtime.InteropServices;
+using System.Text;
+
+namespace AgateLib.Geometry.VertexTypes
+{
+ [StructLayout(LayoutKind.Sequential)]
+ public struct PositionColor
+ {
+ public Vector3 Position;
+ public int Color;
+
+ public PositionColor(float x, float y, float z, Color color)
+ : this(x, y, z, color.ToArgb())
+ { }
+ public PositionColor(float x, float y, float z, int color)
+ {
+ Position = new Vector3(x, y, z);
+ this.Color = color;
+ }
+
+
+ public static VertexLayout VertexLayout
+ {
+ get
+ {
+ return new VertexLayout
+ {
+ new VertexElementDesc(VertexElementDataType.Float3, VertexElement.Position),
+ new VertexElementDesc(VertexElementDataType.Int, VertexElement.DiffuseColor),
+ };
+ }
+ }
+ }
+}
Added: branches/agate3d-3.2/AgateLib/Geometry/VertexTypes/PositionTextureColor.cs
===================================================================
--- branches/agate3d-3.2/AgateLib/Geometry/VertexTypes/PositionTextureColor.cs (rev 0)
+++ branches/agate3d-3.2/AgateLib/Geometry/VertexTypes/PositionTextureColor.cs 2009-05-13 05:35:39 UTC (rev 981)
@@ -0,0 +1,50 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Runtime.InteropServices;
+using System.Text;
+
+namespace AgateLib.Geometry.VertexTypes
+{
+ [StructLayout(LayoutKind.Sequential)]
+ public struct PositionTextureColor
+ {
+ public Vector3 Position;
+ public Vector2 TexCoord;
+ public int Color;
+
+ public PositionTextureColor(float x, float y, float z, Color color, float tu, float tv)
+ : this(x, y, z, color.ToArgb(), tu, tv)
+ { }
+ public PositionTextureColor(float x, float y, float z, int color, float tu, float tv)
+ {
+ Position = new Vector3(x, y, z);
+ TexCoord = new Vector2(tu, tv);
+ this.Color = color;
+ }
+
+ public float X { get { return Position.X; } set { Position.X = value; } }
+ public float Y { get { return Position.Y; } set { Position.Y = value; } }
+ public float Z { get { return Position.Z; } set { Position.Z = value; } }
+
+ public override string ToString()
+ {
+ return string.Format("X: {0} Y: {1} Z: {2} Color: {3} Tu: {4}, Tv: {5}",
+ Position.X, Position.Y, Position.Z, Color, TexCoord.X, TexCoord.Y);
+ }
+
+ public static VertexLayout VertexLayout
+ {
+ get
+ {
+ return new VertexLayout
+ {
+ new VertexElementDesc(VertexElementDataType.Float3, VertexElement.Position),
+ new VertexElementDesc(VertexElementDataType.Float2, VertexElement.Texture),
+ new VertexElementDesc(VertexElementDataType.Int, VertexElement.DiffuseColor),
+ };
+ }
+ }
+ }
+
+}
Modified: branches/agate3d-3.2/AgateLib/Geometry/VertexTypes/VertexLayout.cs
===================================================================
--- branches/agate3d-3.2/AgateLib/Geometry/VertexTypes/VertexLayout.cs 2009-05-11 15:22:15 UTC (rev 980)
+++ branches/agate3d-3.2/AgateLib/Geometry/VertexTypes/VertexLayout.cs 2009-05-13 05:35:39 UTC (rev 981)
@@ -55,6 +55,7 @@
case VertexElementDataType.Float2: return 2 * sizeof(float);
case VertexElementDataType.Float3: return 3 * sizeof(float);
case VertexElementDataType.Float4: return 4 * sizeof(float);
+ case VertexElementDataType.Int: return sizeof(int);
default: throw new NotImplementedException();
}
@@ -196,6 +197,7 @@
Float2,
Float3,
Float4,
+ Int,
}
public enum VertexElement
{
@@ -203,7 +205,7 @@
Normal,
Tangent,
Bitangent,
- Color,
+ DiffuseColor,
Texture,
Texture1,
Texture2,
Modified: branches/agate3d-3.2/Drivers/AgateOTK/GL_Surface.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateOTK/GL_Surface.cs 2009-05-11 15:22:15 UTC (rev 980)
+++ branches/agate3d-3.2/Drivers/AgateOTK/GL_Surface.cs 2009-05-13 05:35:39 UTC (rev 981)
@@ -157,7 +157,14 @@
int[] array = new int[1];
array[0] = mTextureID;
- GL.DeleteTextures(1, array);
+ try
+ {
+ GL.DeleteTextures(1, array);
+ }
+ catch (GraphicsContextMissingException)
+ {
+ System.Diagnostics.Debug.Print("Caught missing graphics context exception. Fix this someday.");
+ }
mTextureIDs.Remove(mTextureID);
}
Modified: branches/agate3d-3.2/Drivers/AgateSDX/AgateSDX.csproj
===================================================================
--- branches/agate3d-3.2/Drivers/AgateSDX/AgateSDX.csproj 2009-05-11 15:22:15 UTC (rev 980)
+++ branches/agate3d-3.2/Drivers/AgateSDX/AgateSDX.csproj 2009-05-13 05:35:39 UTC (rev 981)
@@ -90,9 +90,8 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\AgateLib\AgateLib.csproj">
+ <Project>{5E0F3C6E-5116-40FE-9F9C-3ECC3CBA9152}</Project>
<Name>AgateLib</Name>
- <Project>{C9CD5A49-13B1-4B31-8EB4-5EDBF6C3811D}</Project>
- <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
</ProjectReference>
<ProjectReference Include="..\AgateLib.WinForms\AgateLib.WinForms.csproj">
<Name>AgateLib.WinForms</Name>
@@ -122,7 +121,7 @@
</Compile>
<Compile Include="SDX_Input.cs" />
<Compile Include="SDX_Audio.cs" />
- <Compile Include="PositionColorNormalTexture.cs">
+ <Compile Include="VertexFormats.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Reporter.cs">
Modified: branches/agate3d-3.2/Drivers/AgateSDX/D3DDevice.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateSDX/D3DDevice.cs 2009-05-11 15:22:15 UTC (rev 980)
+++ branches/agate3d-3.2/Drivers/AgateSDX/D3DDevice.cs 2009-05-13 05:35:39 UTC (rev 981)
@@ -25,6 +25,7 @@
using AgateLib.DisplayLib;
using AgateLib.Geometry;
+using AgateLib.Geometry.VertexTypes;
using AgateLib.WinForms;
namespace AgateSDX
@@ -46,6 +47,7 @@
private int mMaxLightsUsed = 0;
+ private VertexDeclaration mSurfaceDecl;
//VertexBuffer mSurfaceVB;
//const int NumVertices = 1000;
@@ -60,6 +62,10 @@
//mDevice.DeviceLost += new EventHandler(mDevice_DeviceLost);
mDrawBuffer = new DrawBuffer(this);
+
+ mSurfaceDecl = SDX_VertexBuffer.CreateVertexDeclaration(
+ device, PositionTextureColor.VertexLayout);
+
}
~D3DDevice()
@@ -67,7 +73,10 @@
Dispose(false);
}
-
+ public void SetVertexDeclarationForSurfaces()
+ {
+ mDevice.VertexDeclaration = mSurfaceDecl;
+ }
void mDevice_DeviceLost(object sender, EventArgs e)
{
// set weird values which will indicate that the device's
Modified: branches/agate3d-3.2/Drivers/AgateSDX/DrawBuffer.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateSDX/DrawBuffer.cs 2009-05-11 15:22:15 UTC (rev 980)
+++ branches/agate3d-3.2/Drivers/AgateSDX/DrawBuffer.cs 2009-05-13 05:35:39 UTC (rev 981)
@@ -24,6 +24,7 @@
using SlimDX.Direct3D9;
using Direct3D = SlimDX.Direct3D9;
using AgateLib.DisplayLib;
+using AgateLib.Geometry.VertexTypes;
namespace AgateSDX
{
@@ -38,7 +39,7 @@
D3DDevice mDevice;
- PositionColorNormalTexture[] mVerts;
+ PositionTextureColor[] mVerts;
short[] mIndices;
int mVertPointer = 0;
@@ -56,10 +57,10 @@
private void AllocateVerts()
{
- mVerts = new PositionColorNormalTexture[vertPageSize * pages];
+ mVerts = new PositionTextureColor[vertPageSize * pages];
mIndices = new short[vertPageSize / 2 * 3 * pages];
}
- public void CacheDrawIndexedTriangles(PositionColorNormalTexture[] verts, short[] indices,
+ public void CacheDrawIndexedTriangles(PositionTextureColor[] verts, short[] indices,
Texture texture, bool alphaBlend)
{
if (mTexture != texture || mAlphaBlend != alphaBlend)
@@ -99,14 +100,14 @@
mDevice.SetDeviceStateTexture(mTexture);
mDevice.AlphaBlend = mAlphaBlend;
- mDevice.VertexFormat = PositionColorNormalTexture.Format;
+ mDevice.SetVertexDeclarationForSurfaces();
try
{
mDevice.Device.DrawIndexedUserPrimitives
(Direct3D.PrimitiveType.TriangleList, 0, mVertPointer,
mIndexPointer / 3, mIndices, Format.Index16, mVerts,
- Marshal.SizeOf(typeof(PositionColorNormalTexture)));
+ Marshal.SizeOf(typeof(PositionTextureColor)));
}
catch { }
Deleted: branches/agate3d-3.2/Drivers/AgateSDX/PositionColorNormalTexture.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateSDX/PositionColorNormalTexture.cs 2009-05-11 15:22:15 UTC (rev 980)
+++ branches/agate3d-3.2/Drivers/AgateSDX/PositionColorNormalTexture.cs 2009-05-13 05:35:39 UTC (rev 981)
@@ -1,89 +0,0 @@
-// The contents of this file are subject to the Mozilla Public License
-// Version 1.1 (the "License"); you may not use this file except in
-// compliance with the License. You may obtain a copy of the License at
-// http://www.mozilla.org/MPL/
-//
-// Software distributed under the License is distributed on an "AS IS"
-// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
-// License for the specific language governing rights and limitations
-// under the License.
-//
-// The Original Code is AgateLib.
-//
-// The Initial Developer of the Original Code is Erik Ylvisaker.
-// Portions created by Erik Ylvisaker are Copyright (C) 2006-2009.
-// All Rights Reserved.
-//
-// Contributor(s): Erik Ylvisaker
-//
-using System;
-using System.Collections.Generic;
-using System.Text;
-using System.Runtime.InteropServices;
-using SlimDX;
-using SlimDX.Direct3D9;
-
-namespace AgateSDX
-{
- [StructLayout(LayoutKind.Sequential)]
- public struct PositionColorNormalTexture
- {
- public float X, Y, Z;
- public float nx, ny, nz;
- public int Color;
- public float Tu, Tv;
-
- public static VertexFormat Format =
- VertexFormat.PositionNormal | VertexFormat.Diffuse | VertexFormat.Texture1;
-
- public PositionColorNormalTexture(float x, float y, float z, int color, float tu, float tv,
- float nx, float ny, float nz)
- {
- X = x;
- Y = y;
- Z = z;
- Color = color;
- Tu = tu;
- Tv = tv;
- this.nx = nx;
- this.ny = ny;
- this.nz = nz;
- }
-
- public override string ToString()
- {
- return string.Format("X: {0} Y: {1} Z: {2} Color: {3} Tu: {4}, Tv: {5}",
- X, Y, Z, Color, Tu, Tv);
- }
- }
-
- [StructLayout(LayoutKind.Sequential)]
- public struct PositionColored
- {
- public float x, y, z;
- public int Color;
-
- public Vector3 Position
- {
- get { return new Vector3(x, y, z); }
- set
- {
- x = value.X;
- y = value.Y;
- z = value.Z;
- }
- }
- public PositionColored(float x, float y, float z, AgateLib.Geometry.Color clr)
- : this(x, y, z, clr.ToArgb())
- { }
- public PositionColored(float x, float y, float z, int clr)
- {
- this.x = x;
- this.y = y;
- this.z = z;
- this.Color = clr;
- }
- public static VertexFormat Format =
- VertexFormat.Position | VertexFormat.Diffuse;
- }
-}
Modified: branches/agate3d-3.2/Drivers/AgateSDX/SDX_Display.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateSDX/SDX_Display.cs 2009-05-11 15:22:15 UTC (rev 980)
+++ branches/agate3d-3.2/Drivers/AgateSDX/SDX_Display.cs 2009-05-13 05:35:39 UTC (rev 981)
@@ -27,6 +27,7 @@
using AgateLib.DisplayLib;
using AgateLib.Drivers;
using AgateLib.Geometry;
+using AgateLib.Geometry.VertexTypes;
using AgateLib.ImplementationBase;
using AgateLib.WinForms;
@@ -47,8 +48,8 @@
private bool mInitialized = false;
// variables for drawing primitives
- PositionColored[] mLines = new PositionColored[5];
- PositionColored[] mFillRectVerts = new PositionColored[6];
+ PositionColor[] mLines = new PositionColor[5];
+ PositionColor[] mFillRectVerts = new PositionColor[6];
private bool mVSync = true;
@@ -57,8 +58,15 @@
private float mDepthClear = 1.0f;
private int mStencilClear = 0;
+ VertexDeclaration mPosColorDecl;
+
#endregion
+ public VertexDeclaration SurfaceDeclaration
+ {
+ get { return mPosColorDecl; }
+ }
+
public DisplayMode DisplayMode
{
get
@@ -131,6 +139,7 @@
InitializeShaders();
+ mPosColorDecl = SDX_VertexBuffer.CreateVertexDeclaration(device, PositionColor.VertexLayout);
}
private void SetHaveDepthStencil(Format depthFormat)
@@ -375,10 +384,10 @@
{
mDevice.DrawBuffer.Flush();
- mLines[0] = new PositionColored(a.X, a.Y, 0, color.ToArgb());
- mLines[1] = new PositionColored(b.X, b.Y, 0, color.ToArgb());
+ mLines[0] = new PositionColor(a.X, a.Y, 0, color.ToArgb());
+ mLines[1] = new PositionColor(b.X, b.Y, 0, color.ToArgb());
- mDevice.VertexFormat = PositionColored.Format;
+ mDevice.Device.VertexDeclaration = mPosColorDecl;
mDevice.Device.DrawUserPrimitives(SlimDX.Direct3D9.PrimitiveType.LineList, 1, mLines);
}
public override void DrawLines(Point[] pt, Color color)
@@ -386,14 +395,14 @@
mDevice.DrawBuffer.Flush();
if (pt.Length > mLines.Length)
- mLines = new PositionColored[pt.Length];
+ mLines = new PositionColor[pt.Length];
for (int i = 0; i < pt.Length; i++)
{
- mLines[i] = new PositionColored(pt[i].X, pt[i].Y, 0, color.ToArgb());
+ mLines[i] = new PositionColor(pt[i].X, pt[i].Y, 0, color.ToArgb());
}
- mDevice.VertexFormat = PositionColored.Format;
+ mDevice.Device.VertexDeclaration = mPosColorDecl;
mDevice.Device.DrawUserPrimitives(Direct3D.PrimitiveType.LineList, pt.Length / 2, mLines);
}
public override void DrawRect(Rectangle rect, Color color)
@@ -406,13 +415,13 @@
int c = color.ToArgb();
- mLines[0] = new PositionColored(rect.X, rect.Y, 0, c);
- mLines[1] = new PositionColored(rect.Right, rect.Y, 0, c);
- mLines[2] = new PositionColored(rect.Right, rect.Bottom, 0, c);
- mLines[3] = new PositionColored(rect.X, rect.Bottom, 0, c);
- mLines[4] = new PositionColored(rect.X, rect.Y, 0, c);
-
- mDevice.VertexFormat = PositionColored.Format;
+ mLines[0] = new PositionColor(rect.X, rect.Y, 0, c);
+ mLines[1] = new PositionColor(rect.Right, rect.Y, 0, c);
+ mLines[2] = new PositionColor(rect.Right, rect.Bottom, 0, c);
+ mLines[3] = new PositionColor(rect.X, rect.Bottom, 0, c);
+ mLines[4] = new PositionColor(rect.X, rect.Y, 0, c);
+
+ mDevice.Device.VertexDeclaration = mPosColorDecl;
mDevice.Device.DrawUserPrimitives(Direct3D.PrimitiveType.LineStrip, 4, mLines);
}
@@ -431,18 +440,18 @@
public override void FillRect(RectangleF rect, Gradient color)
{
// defining our screen sized quad, note the Z value of 1f to place it in the background
- mFillRectVerts[0].Position = new SlimDX.Vector3(rect.Left, rect.Top, 0f);
+ mFillRectVerts[0].Position = new AgateLib.Geometry.Vector3(rect.Left, rect.Top, 0f);
mFillRectVerts[0].Color = color.TopLeft.ToArgb();
- mFillRectVerts[1].Position = new SlimDX.Vector3(rect.Right, rect.Top, 0f);
+ mFillRectVerts[1].Position = new AgateLib.Geometry.Vector3(rect.Right, rect.Top, 0f);
mFillRectVerts[1].Color = color.TopRight.ToArgb();
- mFillRectVerts[2].Position = new SlimDX.Vector3(rect.Left, rect.Bottom, 0f);
+ mFillRectVerts[2].Position = new AgateLib.Geometry.Vector3(rect.Left, rect.Bottom, 0f);
mFillRectVerts[2].Color = color.BottomLeft.ToArgb();
mFillRectVerts[3] = mFillRectVerts[1];
- mFillRectVerts[4].Position = new SlimDX.Vector3(rect.Right, rect.Bottom, 0f);
+ mFillRectVerts[4].Position = new AgateLib.Geometry.Vector3(rect.Right, rect.Bottom, 0f);
mFillRectVerts[4].Color = color.BottomRight.ToArgb();
mFillRectVerts[5] = mFillRectVerts[2];
@@ -454,7 +463,7 @@
mDevice.SetDeviceStateTexture(null);
mDevice.AlphaArgument1 = TextureArgument.Diffuse;
- mDevice.VertexFormat = PositionColored.Format;
+ mDevice.Device.VertexDeclaration = mPosColorDecl;
mDevice.Device.DrawUserPrimitives(Direct3D.PrimitiveType.TriangleList, 2, mFillRectVerts);
mDevice.AlphaArgument1 = TextureArgument.Texture;
}
Modified: branches/agate3d-3.2/Drivers/AgateSDX/SDX_Surface.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateSDX/SDX_Surface.cs 2009-05-11 15:22:15 UTC (rev 980)
+++ branches/agate3d-3.2/Drivers/AgateSDX/SDX_Surface.cs 2009-05-13 05:35:39 UTC (rev 981)
@@ -22,23 +22,24 @@
using System.Runtime.InteropServices;
using System.Text;
-using SlimDX.Direct3D9;
using SlimDX;
+using SlimDX.Direct3D9;
+using Direct3D = SlimDX.Direct3D9;
using AgateLib.DisplayLib;
using AgateLib.Geometry;
+using AgateLib.Geometry.VertexTypes;
using AgateLib.ImplementationBase;
using AgateLib.Utility;
using AgateLib.WinForms;
using Drawing = System.Drawing;
using ImageFileFormat = AgateLib.DisplayLib.ImageFileFormat;
-using Direct3D = SlimDX.Direct3D9;
using Surface = AgateLib.DisplayLib.Surface;
+using Vector2 = AgateLib.Geometry.Vector2;
namespace AgateSDX
{
-
public class SDX_Surface : SurfaceImpl, SDX_IRenderTarget
{
#region --- Private Variables ---
@@ -57,10 +58,10 @@
float mRotationCos = 1.0f;
float mRotationSin = 0.0f;
- PositionColorNormalTexture[] mVerts = new PositionColorNormalTexture[4];
+ PositionTextureColor[] mVerts = new PositionTextureColor[4];
short[] mIndices = new short[] { 0, 2, 1, 1, 2, 3 };
- PositionColorNormalTexture[] mExtraVerts = new PositionColorNormalTexture[4];
+ PositionTextureColor[] mExtraVerts = new PositionTextureColor[4];
short[] mExtraIndices = new short[] { 0, 2, 1, 1, 2, 3 };
#endregion
@@ -378,7 +379,7 @@
}
}
- private void SetVertsTextureCoordinates(PositionColorNormalTexture[] verts, int startIndex,
+ private void SetVertsTextureCoordinates(PositionTextureColor[] verts, int startIndex,
Rectangle srcRect)
{
TextureCoordinates texCoords = GetTextureCoordinates(srcRect);
@@ -386,20 +387,13 @@
SetVertsTextureCoordinates(verts, startIndex, texCoords);
}
- private void SetVertsTextureCoordinates(PositionColorNormalTexture[] verts, int startIndex,
+ private void SetVertsTextureCoordinates(PositionTextureColor[] verts, int startIndex,
TextureCoordinates texCoords)
{
- verts[startIndex].Tu = texCoords.Left;
- verts[startIndex].Tv = texCoords.Top;
-
- verts[startIndex + 1].Tu = texCoords.Right;
- verts[startIndex + 1].Tv = texCoords.Top;
-
- verts[startIndex + 2].Tu = texCoords.Left;
- verts[startIndex + 2].Tv = texCoords.Bottom;
-
- verts[startIndex + 3].Tu = texCoords.Right;
- verts[startIndex + 3].Tv = texCoords.Bottom;
+ verts[startIndex].TexCoord = new Vector2(texCoords.Left, texCoords.Top);
+ verts[startIndex + 1].TexCoord = new Vector2(texCoords.Right, texCoords.Top);
+ verts[startIndex + 2].TexCoord = new Vector2(texCoords.Left, texCoords.Bottom);
+ verts[startIndex + 3].TexCoord = new Vector2(texCoords.Right, texCoords.Bottom);
}
private TextureCoordinates GetTextureCoordinates(Rectangle srcRect)
@@ -429,14 +423,14 @@
return texCoords;
}
- private void SetVertsColor(Gradient ColorGradient, PositionColorNormalTexture[] verts, int startIndex, int count)
+ private void SetVertsColor(Gradient ColorGradient, PositionTextureColor[] verts, int startIndex, int count)
{
verts[startIndex].Color = ColorGradient.TopLeft.ToArgb();
verts[startIndex + 1].Color = ColorGradient.TopRight.ToArgb();
verts[startIndex + 2].Color = ColorGradient.BottomLeft.ToArgb();
verts[startIndex + 3].Color = ColorGradient.BottomRight.ToArgb();
}
- private void SetVertsColor(Gradient ColorGradient, PositionColorNormalTexture[] verts, int startIndex, int count,
+ private void SetVertsColor(Gradient ColorGradient, PositionTextureColor[] verts, int startIndex, int count,
double x, double y, double width, double height)
{
verts[startIndex].Color = ColorGradient.Interpolate(x, y).ToArgb();
@@ -445,7 +439,7 @@
verts[startIndex + 3].Color = ColorGradient.Interpolate(x + width, y + height).ToArgb();
}
- private void SetVertsPosition(PositionColorNormalTexture[] verts, int index,
+ private void SetVertsPosition(PositionTextureColor[] verts, int index,
RectangleF dest, float rotationCenterX, float rotationCenterY,
OriginAlignment DisplayAlignment,
float mRotationCos, float mRotationSin)
@@ -455,7 +449,6 @@
float destWidth = dest.Width;
float destHeight = dest.Height;
-
mCenterPoint = Origin.CalcF(DisplayAlignment, dest.Size);
destX += rotationCenterX - mCenterPoint.X;
@@ -489,12 +482,6 @@
verts[index + 3].Y = -mRotationSin * (-rotationCenterX + destWidth) +
mRotationCos * (-rotationCenterY + destHeight) + destY;
- for (int i = 0; i < 4; i++)
- {
- verts[index + i].nx = 0;
- verts[index + i].ny = 0;
- verts[index + i].nz = -1;
- }
}
Modified: branches/agate3d-3.2/Drivers/AgateSDX/SDX_VertexBuffer.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateSDX/SDX_VertexBuffer.cs 2009-05-11 15:22:15 UTC (rev 980)
+++ branches/agate3d-3.2/Drivers/AgateSDX/SDX_VertexBuffer.cs 2009-05-13 05:35:39 UTC (rev 981)
@@ -15,25 +15,18 @@
SDX_Display mDisplay;
Direct3D.VertexBuffer mBuffer;
Direct3D.VertexDeclaration mDeclaration;
- Direct3D.VertexFormat mFormats;
int mCount;
object data;
VertexLayout mLayout;
- static StringBuilder b;
-
public SDX_VertexBuffer(SDX_Display display, VertexLayout layout, int vertexCount)
{
mDisplay = display;
mCount = vertexCount;
- b = new StringBuilder();
+ mDeclaration = CreateVertexDeclaration(mDisplay.D3D_Device.Device, layout);
+ Direct3D.VertexFormat mFormats = CreateVertexFormat(layout);
- mDeclaration = CreateVertexDeclaration(layout);
- mFormats = CreateVertexFormat(layout);
-
- System.Diagnostics.Debug.WriteLine(b.ToString());
-
mLayout = layout;
mBuffer = new SlimDX.Direct3D9.VertexBuffer(
@@ -76,7 +69,7 @@
retval |= SlimDX.Direct3D9.VertexFormat.Texture3;
break;
- case VertexElement.Color:
+ case VertexElement.DiffuseColor:
retval |= SlimDX.Direct3D9.VertexFormat.Diffuse;
break;
}
@@ -84,7 +77,7 @@
return retval;
}
- private Direct3D.VertexDeclaration CreateVertexDeclaration(VertexLayout layout)
+ public static Direct3D.VertexDeclaration CreateVertexDeclaration(Direct3D.Device d3dDevice, VertexLayout layout)
{
List<Direct3D.VertexElement> formats = new List<Direct3D.VertexElement>();
short loc = 0;
@@ -100,10 +93,9 @@
formats.Add(Direct3D.VertexElement.VertexDeclarationEnd);
- return new Direct3D.VertexDeclaration(
- mDisplay.D3D_Device.Device, formats.ToArray());
+ return new Direct3D.VertexDeclaration(d3dDevice, formats.ToArray());
}
- private Direct3D.VertexElement ConvertElement(VertexElementDesc element, ref short loc)
+ private static Direct3D.VertexElement ConvertElement(VertexElementDesc element, ref short loc)
{
Direct3D.DeclarationMethod declMethod = SlimDX.Direct3D9.DeclarationMethod.Default;
Direct3D.DeclarationUsage declUsage;
@@ -125,6 +117,9 @@
case VertexElementDataType.Float4:
declType = SlimDX.Direct3D9.DeclarationType.Float4;
break;
+ case VertexElementDataType.Int:
+ declType = SlimDX.Direct3D9.DeclarationType.Color;
+ break;
default:
throw new NotImplementedException(
element.DataType.ToString() + " not implemented.");
@@ -144,7 +139,7 @@
case VertexElement.Tangent:
declUsage = SlimDX.Direct3D9.DeclarationUsage.Tangent;
break;
- case VertexElement.Color:
+ case VertexElement.DiffuseColor:
declUsage = SlimDX.Direct3D9.DeclarationUsage.Color;
break;
case VertexElement.Bitangent:
@@ -155,8 +150,6 @@
element.ElementType.ToString() + " not implemented.");
}
- b.AppendFormat("{0} {1} {2} {3}\n", declType, declUsage, loc, size);
-
loc += (short)size;
return new Direct3D.VertexElement(0, (short)(loc - size), declType, declMethod, declUsage, 0);
Copied: branches/agate3d-3.2/Drivers/AgateSDX/VertexFormats.cs (from rev 979, branches/agate3d-3.2/Drivers/AgateSDX/PositionColorNormalTexture.cs)
===================================================================
--- branches/agate3d-3.2/Drivers/AgateSDX/VertexFormats.cs (rev 0)
+++ branches/agate3d-3.2/Drivers/AgateSDX/VertexFormats.cs 2009-05-13 05:35:39 UTC (rev 981)
@@ -0,0 +1,90 @@
+// The contents of this file are subject to the Mozilla Public License
+// Version 1.1 (the "License"); you may not use this file except in
+// compliance with the License. You may obtain a copy of the License at
+// http://www.mozilla.org/MPL/
+//
+// Software distributed under the License is distributed on an "AS IS"
+// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+// License for the ...
[truncated message content] |
|
From: <ka...@us...> - 2009-05-18 07:42:47
|
Revision: 986
http://agate.svn.sourceforge.net/agate/?rev=986&view=rev
Author: kanato
Date: 2009-05-18 07:42:41 +0000 (Mon, 18 May 2009)
Log Message:
-----------
Implement Display.FillEllipse and Display.FillPolygon.
Modified Paths:
--------------
branches/agate3d-3.2/AgateLib/DisplayLib/Display.cs
branches/agate3d-3.2/AgateLib/ImplementationBase/DisplayImpl.cs
branches/agate3d-3.2/Drivers/AgateDrawing/Drawing_Display.cs
branches/agate3d-3.2/Drivers/AgateMDX/MDX1_Display.cs
branches/agate3d-3.2/Drivers/AgateOTK/GL_Display.cs
branches/agate3d-3.2/Drivers/AgateSDX/SDX_Display.cs
branches/agate3d-3.2/Tests/DisplayTests/BasicDrawing/BasicDrawing.cs
branches/agate3d-3.2/Tests/DisplayTests/BasicDrawing/DrawingTester.Designer.cs
branches/agate3d-3.2/Tests/DisplayTests/BasicDrawing/DrawingTester.cs
Modified: branches/agate3d-3.2/AgateLib/DisplayLib/Display.cs
===================================================================
--- branches/agate3d-3.2/AgateLib/DisplayLib/Display.cs 2009-05-17 19:11:31 UTC (rev 985)
+++ branches/agate3d-3.2/AgateLib/DisplayLib/Display.cs 2009-05-18 07:42:41 UTC (rev 986)
@@ -476,6 +476,27 @@
{
impl.SetOrthoProjection(region);
}
+
+ #region --- Matrix Settings ---
+
+ public static Matrix4 MatrixProjection
+ {
+ get { return impl.MatrixProjection; }
+ set { impl.MatrixProjection = value; }
+ }
+ public static Matrix4 MatrixView
+ {
+ get { return impl.MatrixView; }
+ set { impl.MatrixView = value; }
+ }
+ public static Matrix4 MatrixWorld
+ {
+ get { return impl.MatrixWorld; }
+ set { impl.MatrixWorld = value; }
+ }
+
+
+ #endregion
#region --- Drawing Functions ---
/// <summary>
@@ -497,7 +518,7 @@
/// <param name="color"></param>
public static void DrawLine(int x1, int y1, int x2, int y2, Color color)
{
- impl.DrawLine(x1, y1, x2, y2, color);
+ impl.DrawLine(new Point(x1, y1), new Point(x2, y2), color);
}
/// <summary>
/// Draws a line between the two points specified.
@@ -532,29 +553,6 @@
throw new ArgumentException("pts argument is not an even number of points!");
impl.DrawLineSegments(pts, color);
}
-
- #region --- Matrix Settings ---
-
- public static Matrix4 MatrixProjection
- {
- get { return impl.MatrixProjection; }
- set { impl.MatrixProjection = value; }
- }
- public static Matrix4 MatrixView
- {
- get { return impl.MatrixView; }
- set { impl.MatrixView = value; }
- }
- public static Matrix4 MatrixWorld
- {
- get { return impl.MatrixWorld; }
- set { impl.MatrixWorld = value; }
- }
-
-
- #endregion
-
-
/// <summary>
/// Draws the outline of a rectangle.
/// </summary>
@@ -585,7 +583,35 @@
{
impl.DrawRect(new Rectangle(x, y, width, height), color);
}
+
/// <summary>
+ /// Draws a filled ellipse inscribed in the specified rectangle.
+ /// </summary>
+ /// <param name="rect"></param>
+ /// <param name="color"></param>
+ public static void FillEllipse(Rectangle rect, Color color)
+ {
+ impl.FillEllipse((RectangleF)rect, color);
+ }
+ /// <summary>
+ /// Draws a filled ellipse inscribed in the specified rectangle.
+ /// </summary>
+ /// <param name="rect"></param>
+ /// <param name="color"></param>
+ public static void FillEllipse(RectangleF rect, Color color)
+ {
+ impl.FillEllipse(rect, color);
+ }
+ /// <summary>
+ /// Draws a filled polygon. The last point will be connected to the first point.
+ /// </summary>
+ /// <param name="pts"></param>
+ /// <param name="color"></param>
+ public static void FillPolygon(PointF[] pts, Color color)
+ {
+ impl.FillPolygon(pts, color);
+ }
+ /// <summary>
/// Draws a filled rectangle.
/// </summary>
/// <param name="rect"></param>
Modified: branches/agate3d-3.2/AgateLib/ImplementationBase/DisplayImpl.cs
===================================================================
--- branches/agate3d-3.2/AgateLib/ImplementationBase/DisplayImpl.cs 2009-05-17 19:11:31 UTC (rev 985)
+++ branches/agate3d-3.2/AgateLib/ImplementationBase/DisplayImpl.cs 2009-05-18 07:42:41 UTC (rev 986)
@@ -375,7 +375,7 @@
// we will take the circumference as being the number of points to draw
// on the ellipse.
- Point[] pts = new Point[(int)Math.Ceiling(circumference)];
+ Point[] pts = new Point[(int)Math.Ceiling(circumference * 2)];
double step = 2 * Math.PI / (pts.Length - 1);
for (int i = 0; i < pts.Length; i++)
@@ -387,16 +387,37 @@
DrawLines(pts, color);
}
+
+ public virtual void FillEllipse(RectangleF rect, Color color)
+ {
+ PointF center = new PointF(rect.Left + rect.Width / 2,
+ rect.Top + rect.Height / 2);
+
+ double radiusX = rect.Width / 2;
+ double radiusY = rect.Height / 2;
+ double h = Math.Pow(radiusX - radiusY, 2) / Math.Pow(radiusX + radiusY, 2);
+
+ //Ramanujan's second approximation to the circumference of an ellipse.
+ double circumference =
+ Math.PI * (radiusX + radiusY) * (1 + 3 * h / (10 + Math.Sqrt(4 - 3 * h)));
+
+ // we will take the circumference as being the number of points to draw
+ // on the ellipse.
+ PointF[] pts = new PointF[(int)Math.Ceiling(circumference * 2)];
+ double step = 2 * Math.PI / (pts.Length - 1);
+
+ for (int i = 0; i < pts.Length; i++)
+ {
+ pts[i] = new PointF((float)(center.X + radiusX * Math.Cos(step * i) + 0.5),
+ (float)(center.Y + radiusY * Math.Sin(step * i) + 0.5));
+ }
+
+ FillPolygon(pts, color);
+ }
+
+ public abstract void FillPolygon(PointF[] pts, Color color);
+
/// <summary>
- /// Draws a line between the two specified end-points.
- /// </summary>
- /// <param name="x1"></param>
- /// <param name="y1"></param>
- /// <param name="x2"></param>
- /// <param name="y2"></param>
- /// <param name="color"></param>
- public abstract void DrawLine(int x1, int y1, int x2, int y2, Color color);
- /// <summary>
/// Draws a line between the two specified endpoints.
/// </summary>
/// <param name="a"></param>
@@ -641,5 +662,6 @@
ShaderCompiler.Disable();
}
+
}
}
Modified: branches/agate3d-3.2/Drivers/AgateDrawing/Drawing_Display.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateDrawing/Drawing_Display.cs 2009-05-17 19:11:31 UTC (rev 985)
+++ branches/agate3d-3.2/Drivers/AgateDrawing/Drawing_Display.cs 2009-05-18 07:42:41 UTC (rev 986)
@@ -137,12 +137,6 @@
new SolidBrush(Interop.Convert(color)), Interop.Convert(dest_rect));
}
- public override void DrawLine(int x1, int y1, int x2, int y2, Geometry.Color color)
- {
- CheckInFrame("DrawLine");
-
- mGraphics.DrawLine(new Pen(Interop.Convert(color)), x1, y1, x2, y2);
- }
public override void DrawLine(Geometry.Point a, Geometry.Point b, Geometry.Color color)
{
CheckInFrame("DrawLine");
@@ -192,6 +186,20 @@
FillRect(rect, color.AverageColor);
}
+ public override void FillPolygon(Geometry.PointF[] pts, Geometry.Color color)
+ {
+ SolidBrush b = new SolidBrush(Interop.Convert(color));
+
+ PointF[] p = new PointF[pts.Length];
+ for (int i = 0; i < pts.Length; i++)
+ p[i] = Interop.Convert(pts[i]);
+
+ mGraphics.FillPolygon(b, p);
+
+ b.Dispose();
+ }
+
+
#endregion
#region --- Begin/End Frame and DeltaTime ---
Modified: branches/agate3d-3.2/Drivers/AgateMDX/MDX1_Display.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateMDX/MDX1_Display.cs 2009-05-17 19:11:31 UTC (rev 985)
+++ branches/agate3d-3.2/Drivers/AgateMDX/MDX1_Display.cs 2009-05-18 07:42:41 UTC (rev 986)
@@ -350,10 +350,6 @@
}
- public override void DrawLine(int x1, int y1, int x2, int y2, Color color)
- {
- DrawLine(new Point(x1, y1), new Point(x2, y2), color);
- }
public override void DrawLine(Point a, Point b, Color color)
{
mDevice.DrawBuffer.Flush();
@@ -442,9 +438,12 @@
mDevice.AlphaArgument1 = TextureArgument.TextureColor;
}
+ public override void FillPolygon(PointF[] pts, Color color)
+ {
+ throw new NotImplementedException();
+ }
-
#endregion
#region --- Display Mode changing stuff ---
Modified: branches/agate3d-3.2/Drivers/AgateOTK/GL_Display.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateOTK/GL_Display.cs 2009-05-17 19:11:31 UTC (rev 985)
+++ branches/agate3d-3.2/Drivers/AgateOTK/GL_Display.cs 2009-05-18 07:42:41 UTC (rev 986)
@@ -259,28 +259,20 @@
DrawRect(dest, Color.FromArgb(255, color));
}
-
- public override void DrawLine(int x1, int y1, int x2, int y2, Color color)
+ public override void DrawLine(Point a, Point b, Color color)
{
mState.DrawBuffer.Flush();
-
mState.SetGLColor(color);
GL.Disable(EnableCap.Texture2D);
GL.Begin(BeginMode.Lines);
- GL.Vertex2(x1, y1 + 0.5);
- GL.Vertex2(x2, y2 + 0.5);
+ GL.Vertex2(a.X, a.Y);
+ GL.Vertex2(b.X, b.Y);
GL.End();
GL.Enable(EnableCap.Texture2D);
}
- public override void DrawLine(Point a, Point b, Color color)
- {
- mState.DrawBuffer.Flush();
- DrawLine(a.X, a.Y, b.X, b.Y, color);
- }
-
public override void DrawRect(Rectangle rect, Color color)
{
DrawRect(new RectangleF(rect.X, rect.Y, rect.Width, rect.Height), color);
@@ -358,6 +350,24 @@
GL.Enable(EnableCap.Texture2D);
}
+ public override void FillPolygon(PointF[] pts, Color color)
+ {
+ mState.DrawBuffer.Flush();
+
+ GL.Disable(EnableCap.Texture2D);
+
+ mState.SetGLColor(color);
+
+ GL.Begin(BeginMode.TriangleFan);
+ for (int i = 0; i < pts.Length; i++)
+ {
+ GL.Vertex3(pts[i].X, pts[i].Y, 0);
+ }
+ GL.End(); // Done Drawing The Quad
+
+ GL.Enable(EnableCap.Texture2D);
+ }
+
public override bool VSync
{
get { return mVSync; }
Modified: branches/agate3d-3.2/Drivers/AgateSDX/SDX_Display.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateSDX/SDX_Display.cs 2009-05-17 19:11:31 UTC (rev 985)
+++ branches/agate3d-3.2/Drivers/AgateSDX/SDX_Display.cs 2009-05-18 07:42:41 UTC (rev 986)
@@ -376,10 +376,6 @@
}
- public override void DrawLine(int x1, int y1, int x2, int y2, Color color)
- {
- DrawLine(new Point(x1, y1), new Point(x2, y2), color);
- }
public override void DrawLine(Point a, Point b, Color color)
{
mDevice.DrawBuffer.Flush();
@@ -403,7 +399,7 @@
}
mDevice.Device.VertexDeclaration = mPosColorDecl;
- mDevice.Device.DrawUserPrimitives(Direct3D.PrimitiveType.LineList, pt.Length / 2, mLines);
+ mDevice.Device.DrawUserPrimitives(Direct3D.PrimitiveType.LineStrip, pt.Length - 1, mLines);
}
public override void DrawRect(Rectangle rect, Color color)
{
@@ -425,6 +421,32 @@
mDevice.Device.DrawUserPrimitives(Direct3D.PrimitiveType.LineStrip, 4, mLines);
}
+ PositionColor[] polygonVerts = new PositionColor[10];
+
+ public override void FillPolygon(PointF[] pts, Color color)
+ {
+ if (polygonVerts.Length < pts.Length)
+ polygonVerts = new PositionColor[pts.Length];
+
+ int clr = color.ToArgb();
+
+ for (int i = 0; i < pts.Length; i++)
+ {
+ polygonVerts[i].Position = new AgateLib.Geometry.Vector3(pts[i].X, pts[i].Y, 0);
+ polygonVerts[i].Color = clr;
+ }
+
+ mDevice.DrawBuffer.Flush();
+
+ mDevice.AlphaBlend = true;
+
+ mDevice.SetDeviceStateTexture(null);
+ mDevice.AlphaArgument1 = TextureArgument.Diffuse;
+
+ mDevice.Device.VertexDeclaration = mPosColorDecl;
+ mDevice.Device.DrawUserPrimitives(Direct3D.PrimitiveType.TriangleFan, pts.Length - 2, polygonVerts);
+ mDevice.AlphaArgument1 = TextureArgument.Texture;
+ }
public override void FillRect(Rectangle rect, Color color)
{
FillRect((RectangleF)rect, new Gradient(color));
@@ -439,7 +461,6 @@
}
public override void FillRect(RectangleF rect, Gradient color)
{
- // defining our screen sized quad, note the Z value of 1f to place it in the background
mFillRectVerts[0].Position = new AgateLib.Geometry.Vector3(rect.Left, rect.Top, 0f);
mFillRectVerts[0].Color = color.TopLeft.ToArgb();
Modified: branches/agate3d-3.2/Tests/DisplayTests/BasicDrawing/BasicDrawing.cs
===================================================================
--- branches/agate3d-3.2/Tests/DisplayTests/BasicDrawing/BasicDrawing.cs 2009-05-17 19:11:31 UTC (rev 985)
+++ branches/agate3d-3.2/Tests/DisplayTests/BasicDrawing/BasicDrawing.cs 2009-05-18 07:42:41 UTC (rev 986)
@@ -14,6 +14,7 @@
enum ShapeType
{
FillRect,
+ FillEllipse,
DrawRect,
DrawEllipse,
DrawLine,
@@ -54,6 +55,13 @@
case ShapeType.FillRect:
Display.FillRect(Rect, Color);
break;
+
+ case ShapeType.FillEllipse:
+ Display.FillEllipse(Rect, Color);
+ break;
+
+ default:
+ throw new NotImplementedException();
}
}
}
@@ -92,6 +100,7 @@
frm.btnDrawRect.Click += new EventHandler(btnDrawRect_Click);
frm.btnFillRect.Click += new EventHandler(btnFillRect_Click);
frm.btnDrawCircle.Click += new EventHandler(btnDrawCircle_Click);
+ frm.btnFillCircle.Click += new EventHandler(btnFillCircle_Click);
frm.Show();
// This creates the window that we will be drawing in.
@@ -129,6 +138,11 @@
}
}
+ void btnFillCircle_Click(object sender, EventArgs e)
+ {
+ shapes.Add(new Shape(ShapeType.FillEllipse, Color.FromArgb(frm.SelectedColor.ToArgb()), RandomRect()));
+ }
+
static void btnDrawCircle_Click(object sender, EventArgs e)
{
shapes.Add(new Shape(ShapeType.DrawEllipse, Color.FromArgb(frm.SelectedColor.ToArgb()), RandomRect()));
Modified: branches/agate3d-3.2/Tests/DisplayTests/BasicDrawing/DrawingTester.Designer.cs
===================================================================
--- branches/agate3d-3.2/Tests/DisplayTests/BasicDrawing/DrawingTester.Designer.cs 2009-05-17 19:11:31 UTC (rev 985)
+++ branches/agate3d-3.2/Tests/DisplayTests/BasicDrawing/DrawingTester.Designer.cs 2009-05-18 07:42:41 UTC (rev 986)
@@ -41,6 +41,7 @@
this.label1 = new System.Windows.Forms.Label();
this.nudAlpha = new System.Windows.Forms.NumericUpDown();
this.btnDrawCircle = new System.Windows.Forms.Button();
+ this.btnFillCircle = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.nudAlpha)).BeginInit();
this.SuspendLayout();
//
@@ -51,7 +52,7 @@
| System.Windows.Forms.AnchorStyles.Right)));
this.panel1.Location = new System.Drawing.Point(93, 12);
this.panel1.Name = "panel1";
- this.panel1.Size = new System.Drawing.Size(187, 193);
+ this.panel1.Size = new System.Drawing.Size(226, 238);
this.panel1.TabIndex = 0;
//
// btnDrawLine
@@ -96,7 +97,7 @@
// btnClear
//
this.btnClear.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
- this.btnClear.Location = new System.Drawing.Point(12, 182);
+ this.btnClear.Location = new System.Drawing.Point(12, 227);
this.btnClear.Name = "btnClear";
this.btnClear.Size = new System.Drawing.Size(75, 23);
this.btnClear.TabIndex = 4;
@@ -144,11 +145,22 @@
this.btnDrawCircle.Text = "Draw Circle";
this.btnDrawCircle.UseVisualStyleBackColor = true;
//
+ // btnFillCircle
+ //
+ this.btnFillCircle.Location = new System.Drawing.Point(12, 182);
+ this.btnFillCircle.Name = "btnFillCircle";
+ this.btnFillCircle.Size = new System.Drawing.Size(75, 23);
+ this.btnFillCircle.TabIndex = 8;
+ this.btnFillCircle.Text = "Fill Circle";
+ this.btnFillCircle.UseVisualStyleBackColor = true;
+ this.btnFillCircle.Click += new System.EventHandler(this.btnFillCircle_Click);
+ //
// DrawingTester
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(292, 217);
+ this.ClientSize = new System.Drawing.Size(331, 262);
+ this.Controls.Add(this.btnFillCircle);
this.Controls.Add(this.btnDrawCircle);
this.Controls.Add(this.nudAlpha);
this.Controls.Add(this.label1);
@@ -179,6 +191,7 @@
private System.Windows.Forms.Label label1;
private System.Windows.Forms.NumericUpDown nudAlpha;
public System.Windows.Forms.Button btnDrawCircle;
+ public System.Windows.Forms.Button btnFillCircle;
}
}
\ No newline at end of file
Modified: branches/agate3d-3.2/Tests/DisplayTests/BasicDrawing/DrawingTester.cs
===================================================================
--- branches/agate3d-3.2/Tests/DisplayTests/BasicDrawing/DrawingTester.cs 2009-05-17 19:11:31 UTC (rev 985)
+++ branches/agate3d-3.2/Tests/DisplayTests/BasicDrawing/DrawingTester.cs 2009-05-18 07:42:41 UTC (rev 986)
@@ -33,5 +33,10 @@
}
}
+ private void btnFillCircle_Click(object sender, EventArgs e)
+ {
+
+ }
+
}
}
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ka...@us...> - 2009-05-20 03:33:35
|
Revision: 994
http://agate.svn.sourceforge.net/agate/?rev=994&view=rev
Author: kanato
Date: 2009-05-20 03:33:19 +0000 (Wed, 20 May 2009)
Log Message:
-----------
Add in RenderStateAdapter and refactor VSync to go through the render states.
Modified Paths:
--------------
branches/agate3d-3.2/AgateLib/DisplayLib/Display.cs
branches/agate3d-3.2/AgateLib/ImplementationBase/DisplayImpl.cs
branches/agate3d-3.2/Drivers/AgateDrawing/Drawing_Display.cs
branches/agate3d-3.2/Drivers/AgateMDX/MDX1_Display.cs
branches/agate3d-3.2/Drivers/AgateOTK/GL_Display.cs
branches/agate3d-3.2/Drivers/AgateOTK/GL_DisplayControl.cs
branches/agate3d-3.2/Drivers/AgateOTK/GL_GameWindow.cs
branches/agate3d-3.2/Drivers/AgateSDX/SDX_Display.cs
branches/agate3d-3.2/Tests/CoreTests/Performance/Performance.cs
branches/agate3d-3.2/Tests/DisplayTests/LightingTest/LightingTest.cs
branches/agate3d-3.2/Tests/DisplayTests/SpriteTester/frmSpriteTester.cs
branches/agate3d-3.2/Tests/DisplayTests/TileTester/TileTester.cs
branches/agate3d-3.2/Tests/DisplayTests/TileTester/frmTileTester.cs
branches/agate3d-3.2/Tests/Fonts/Fonts.cs
Added Paths:
-----------
branches/agate3d-3.2/AgateLib/DisplayLib/RenderStateAdapter.cs
Modified: branches/agate3d-3.2/AgateLib/DisplayLib/Display.cs
===================================================================
--- branches/agate3d-3.2/AgateLib/DisplayLib/Display.cs 2009-05-19 16:13:29 UTC (rev 993)
+++ branches/agate3d-3.2/AgateLib/DisplayLib/Display.cs 2009-05-20 03:33:19 UTC (rev 994)
@@ -63,7 +63,8 @@
private static SurfacePacker mSurfacePacker;
private static Rectangle mCurrentClipRect;
private static Stack<Rectangle> mClipRects = new Stack<Rectangle>();
-
+ private static RenderStateAdapter mRenderState = new RenderStateAdapter();
+
/// <summary>
/// Gets the object which handles all of the actual calls to Display functions.
/// This may be cast to a surface object in whatever rendering library
@@ -95,6 +96,11 @@
mSurfacePacker = new SurfacePacker();
}
+ public static RenderStateAdapter RenderState
+ {
+ get { return mRenderState; }
+ }
+
private static ShaderCompilerImpl CreateShaderCompiler()
{
return impl.CreateShaderCompiler();
@@ -406,22 +412,11 @@
/// Gets or sets the VSync flag. If VSync is off, tearing might occur.
/// If VSync is on, the framerate will be capped at the monitor's refresh rate.
/// </summary>
+ [Obsolete("Use Display.RenderState.WaitForVerticalBlank instead.", true)]
public static bool VSync
{
- get
- {
- if (impl == null)
- throw new AgateException("Display has not been initialized.");
-
- return impl.VSync;
- }
- set
- {
- if (impl == null)
- throw new AgateException("Display has not been initialized.");
-
- impl.VSync = value;
- }
+ get { return RenderState.WaitForVerticalBlank; }
+ set { RenderState.WaitForVerticalBlank = value; }
}
/// <summary>
@@ -686,11 +681,13 @@
/// <summary>
/// Turns lighting functions off.
/// </summary>
+ [Obsolete("Use shaders instead.")]
public static void DisableLighting()
{
DoLighting(LightManager.Empty);
}
+
internal static void DoLighting(LightManager lights)
{
impl.DoLighting(lights);
Added: branches/agate3d-3.2/AgateLib/DisplayLib/RenderStateAdapter.cs
===================================================================
--- branches/agate3d-3.2/AgateLib/DisplayLib/RenderStateAdapter.cs (rev 0)
+++ branches/agate3d-3.2/AgateLib/DisplayLib/RenderStateAdapter.cs 2009-05-20 03:33:19 UTC (rev 994)
@@ -0,0 +1,111 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace AgateLib.DisplayLib
+{
+ public sealed class RenderStateAdapter
+ {
+ void CheckDisplayInitialized()
+ {
+ if (Display.Impl == null)
+ throw new AgateException("Display has not been initialized.");
+ }
+
+ public bool WaitForVerticalBlank
+ {
+ get
+ {
+ CheckDisplayInitialized();
+ return Display.Impl.GetRenderState(RenderStateBool.WaitForVerticalBlank);
+ }
+ set
+ {
+ CheckDisplayInitialized();
+ Display.Impl.SetRenderState(RenderStateBool.WaitForVerticalBlank, value);
+ }
+ }
+
+ public bool AlphaBlend
+ {
+ get
+ {
+ CheckDisplayInitialized();
+ return Display.Impl.GetRenderState(RenderStateBool.AlphaBlend);
+ }
+ set
+ {
+ CheckDisplayInitialized();
+ Display.Impl.SetRenderState(RenderStateBool.AlphaBlend, value);
+ }
+ }
+
+
+ public bool ZBufferTest
+ {
+ get
+ {
+ CheckDisplayInitialized();
+ return Display.Impl.GetRenderState(RenderStateBool.ZBufferTest);
+ }
+ set
+ {
+ CheckDisplayInitialized();
+ Display.Impl.SetRenderState(RenderStateBool.ZBufferTest, value);
+ }
+ }
+ public bool ZBufferWrite
+ {
+ get
+ {
+ CheckDisplayInitialized();
+ return Display.Impl.GetRenderState(RenderStateBool.ZBufferWrite);
+ }
+ set
+ {
+ CheckDisplayInitialized();
+ Display.Impl.SetRenderState(RenderStateBool.ZBufferWrite, value);
+ }
+ }
+ public bool StencilBufferTest
+ {
+ get
+ {
+ CheckDisplayInitialized();
+ return Display.Impl.GetRenderState(RenderStateBool.StencilBufferTest);
+ }
+ set
+ {
+ CheckDisplayInitialized();
+ Display.Impl.SetRenderState(RenderStateBool.StencilBufferTest, value);
+ }
+ }
+ public bool StencilBufferWrite
+ {
+ get
+ {
+ CheckDisplayInitialized();
+ return Display.Impl.GetRenderState(RenderStateBool.StencilBufferWrite);
+ }
+ set
+ {
+ CheckDisplayInitialized();
+ Display.Impl.SetRenderState(RenderStateBool.StencilBufferWrite, value);
+ }
+ }
+ }
+
+ public enum RenderStateBool
+ {
+ WaitForVerticalBlank,
+
+ AlphaBlend,
+
+ ZBufferTest,
+ ZBufferWrite,
+
+ StencilBufferTest,
+ StencilBufferWrite,
+ }
+}
Modified: branches/agate3d-3.2/AgateLib/ImplementationBase/DisplayImpl.cs
===================================================================
--- branches/agate3d-3.2/AgateLib/ImplementationBase/DisplayImpl.cs 2009-05-19 16:13:29 UTC (rev 993)
+++ branches/agate3d-3.2/AgateLib/ImplementationBase/DisplayImpl.cs 2009-05-20 03:33:19 UTC (rev 994)
@@ -409,7 +409,7 @@
for (int i = 0; i < pts.Length; i++)
{
pts[i] = new PointF((float)(center.X + radiusX * Math.Cos(step * i) + 0.5),
- (float)(center.Y + radiusY * Math.Sin(step * i) + 0.5));
+ (float)(center.Y + radiusY * Math.Sin(step * i) + 0.5));
}
FillPolygon(pts, color);
@@ -525,17 +525,6 @@
}
/// <summary>
- /// Gets or sets VSync flag.
- /// There is no need to call base.VSync if overriding this member.
- /// </summary>
- public virtual bool VSync
- {
- get { return true; }
- set { }
- }
-
-
- /// <summary>
/// Enumerates a list of screen modes.
/// </summary>
/// <returns></returns>
@@ -663,5 +652,8 @@
}
+
+ protected internal abstract bool GetRenderState(RenderStateBool renderStateBool);
+ protected internal abstract void SetRenderState(RenderStateBool renderStateBool, bool value);
}
}
Modified: branches/agate3d-3.2/Drivers/AgateDrawing/Drawing_Display.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateDrawing/Drawing_Display.cs 2009-05-19 16:13:29 UTC (rev 993)
+++ branches/agate3d-3.2/Drivers/AgateDrawing/Drawing_Display.cs 2009-05-20 03:33:19 UTC (rev 994)
@@ -375,6 +375,33 @@
}
#endregion
+
+
+ protected override bool GetRenderState(RenderStateBool renderStateBool)
+ {
+ switch (renderStateBool)
+ {
+ // vsync is not supported, but shouldn't throw an error.
+ case RenderStateBool.WaitForVerticalBlank: return false;
+ default:
+ throw new NotSupportedException(string.Format(
+ "The specified render state, {0}, is not supported by this driver."));
+ }
+ }
+
+ protected override void SetRenderState(RenderStateBool renderStateBool, bool value)
+ {
+ switch (renderStateBool)
+ {
+ case RenderStateBool.WaitForVerticalBlank:
+ // vsync is not supported, but shouldn't throw an error.
+ break;
+
+ default:
+ throw new NotSupportedException(string.Format(
+ "The specified render state, {0}, is not supported by this driver."));
+ }
+ }
}
Modified: branches/agate3d-3.2/Drivers/AgateMDX/MDX1_Display.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateMDX/MDX1_Display.cs 2009-05-19 16:13:29 UTC (rev 993)
+++ branches/agate3d-3.2/Drivers/AgateMDX/MDX1_Display.cs 2009-05-20 03:33:19 UTC (rev 994)
@@ -540,7 +540,7 @@
if (present.AutoDepthStencilFormat == DepthFormat.Unknown)
present.EnableAutoDepthStencil = false;
- if (VSync)
+ if (GetRenderState(RenderStateBool.WaitForVerticalBlank))
present.PresentationInterval = PresentInterval.Default;
else
present.PresentationInterval = PresentInterval.Immediate;
@@ -711,19 +711,7 @@
if (VSyncChanged != null)
VSyncChanged(this, EventArgs.Empty);
}
- public override bool VSync
- {
- get
- {
- return mVSync;
- }
- set
- {
- mVSync = value;
- OnVSyncChanged();
- }
- }
public override Size MaxSurfaceSize
{
get { return mDevice.MaxSurfaceSize; }
@@ -1004,5 +992,32 @@
}
#endregion
+
+
+ protected override bool GetRenderState(RenderStateBool renderStateBool)
+ {
+ switch (renderStateBool)
+ {
+ case RenderStateBool.WaitForVerticalBlank: return mVSync;
+ default:
+ throw new NotSupportedException(string.Format(
+ "The specified render state, {0}, is not supported by this driver."));
+ }
+ }
+
+ protected override void SetRenderState(RenderStateBool renderStateBool, bool value)
+ {
+ switch (renderStateBool)
+ {
+ case RenderStateBool.WaitForVerticalBlank:
+ mVSync = value;
+ OnVSyncChanged();
+ break;
+
+ default:
+ throw new NotSupportedException(string.Format(
+ "The specified render state, {0}, is not supported by this driver."));
+ }
+ }
}
}
\ No newline at end of file
Modified: branches/agate3d-3.2/Drivers/AgateOTK/GL_Display.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateOTK/GL_Display.cs 2009-05-19 16:13:29 UTC (rev 993)
+++ branches/agate3d-3.2/Drivers/AgateOTK/GL_Display.cs 2009-05-20 03:33:19 UTC (rev 994)
@@ -368,12 +368,6 @@
GL.Enable(EnableCap.Texture2D);
}
- public override bool VSync
- {
- get { return mVSync; }
- set { mVSync = value; }
- }
-
public override void Initialize()
{
mState = new GLState();
@@ -752,5 +746,30 @@
#endregion
#endregion
+
+ protected override bool GetRenderState(RenderStateBool renderStateBool)
+ {
+ switch (renderStateBool)
+ {
+ case RenderStateBool.WaitForVerticalBlank: return mVSync;
+ default:
+ throw new NotSupportedException(string.Format(
+ "The specified render state, {0}, is not supported by this driver."));
+ }
+ }
+
+ protected override void SetRenderState(RenderStateBool renderStateBool, bool value)
+ {
+ switch (renderStateBool)
+ {
+ case RenderStateBool.WaitForVerticalBlank:
+ mVSync = value;
+ break;
+
+ default:
+ throw new NotSupportedException(string.Format(
+ "The specified render state, {0}, is not supported by this driver."));
+ }
+ }
}
}
\ No newline at end of file
Modified: branches/agate3d-3.2/Drivers/AgateOTK/GL_DisplayControl.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateOTK/GL_DisplayControl.cs 2009-05-19 16:13:29 UTC (rev 993)
+++ branches/agate3d-3.2/Drivers/AgateOTK/GL_DisplayControl.cs 2009-05-20 03:33:19 UTC (rev 994)
@@ -425,8 +425,8 @@
public override void EndRender()
{
- if (mContext.VSync != mDisplay.VSync)
- mContext.VSync = mDisplay.VSync;
+ if (mContext.VSync != Display.RenderState.WaitForVerticalBlank)
+ mContext.VSync = Display.RenderState.WaitForVerticalBlank;
mContext.SwapBuffers();
}
Modified: branches/agate3d-3.2/Drivers/AgateOTK/GL_GameWindow.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateOTK/GL_GameWindow.cs 2009-05-19 16:13:29 UTC (rev 993)
+++ branches/agate3d-3.2/Drivers/AgateOTK/GL_GameWindow.cs 2009-05-20 03:33:19 UTC (rev 994)
@@ -431,8 +431,8 @@
public override void BeginRender()
{
- if (mWindow.Context.VSync != mDisplay.VSync)
- mWindow.Context.VSync = mDisplay.VSync;
+ if (mWindow.Context.VSync != Display.RenderState.WaitForVerticalBlank)
+ mWindow.Context.VSync = Display.RenderState.WaitForVerticalBlank;
MakeCurrent();
Modified: branches/agate3d-3.2/Drivers/AgateSDX/SDX_Display.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateSDX/SDX_Display.cs 2009-05-19 16:13:29 UTC (rev 993)
+++ branches/agate3d-3.2/Drivers/AgateSDX/SDX_Display.cs 2009-05-20 03:33:19 UTC (rev 994)
@@ -588,7 +588,7 @@
if (present.AutoDepthStencilFormat == Format.Unknown)
present.EnableAutoDepthStencil = false;
- if (VSync)
+ if (GetRenderState(RenderStateBool.WaitForVerticalBlank))
present.PresentationInterval = PresentInterval.Default;
else
present.PresentationInterval = PresentInterval.Immediate;
@@ -779,25 +779,6 @@
System.Windows.Forms.Application.DoEvents();
}
- internal event EventHandler VSyncChanged;
- private void OnVSyncChanged()
- {
- if (VSyncChanged != null)
- VSyncChanged(this, EventArgs.Empty);
- }
- public override bool VSync
- {
- get
- {
- return mVSync;
- }
- set
- {
- mVSync = value;
-
- OnVSyncChanged();
- }
- }
public override Size MaxSurfaceSize
{
get { return mDevice.MaxSurfaceSize; }
@@ -1082,5 +1063,39 @@
}
#endregion
+
+ [Obsolete("The necessity of this needs to be verified.")]
+ internal event EventHandler VSyncChanged;
+ private void OnVSyncChanged()
+ {
+ if (VSyncChanged != null)
+ VSyncChanged(this, EventArgs.Empty);
+ }
+
+ protected override bool GetRenderState(RenderStateBool renderStateBool)
+ {
+ switch (renderStateBool)
+ {
+ case RenderStateBool.WaitForVerticalBlank: return mVSync;
+ default:
+ throw new NotSupportedException(string.Format(
+ "The specified render state, {0}, is not supported by this driver."));
+ }
+ }
+
+ protected override void SetRenderState(RenderStateBool renderStateBool, bool value)
+ {
+ switch (renderStateBool)
+ {
+ case RenderStateBool.WaitForVerticalBlank:
+ mVSync = value;
+ OnVSyncChanged();
+ break;
+
+ default:
+ throw new NotSupportedException(string.Format(
+ "The specified render state, {0}, is not supported by this driver."));
+ }
+ }
}
}
\ No newline at end of file
Modified: branches/agate3d-3.2/Tests/CoreTests/Performance/Performance.cs
===================================================================
--- branches/agate3d-3.2/Tests/CoreTests/Performance/Performance.cs 2009-05-19 16:13:29 UTC (rev 993)
+++ branches/agate3d-3.2/Tests/CoreTests/Performance/Performance.cs 2009-05-20 03:33:19 UTC (rev 994)
@@ -65,7 +65,7 @@
double fps;
Display.Initialize((DisplayTypeID)info.DriverTypeID);
- Display.VSync = false;
+ Display.RenderState.WaitForVerticalBlank = false;
DisplayWindow wind = DisplayWindow.CreateWindowed("Performance Test", 300, 300);
font = new FontSurface("Arial", 11);
Modified: branches/agate3d-3.2/Tests/DisplayTests/LightingTest/LightingTest.cs
===================================================================
--- branches/agate3d-3.2/Tests/DisplayTests/LightingTest/LightingTest.cs 2009-05-19 16:13:29 UTC (rev 993)
+++ branches/agate3d-3.2/Tests/DisplayTests/LightingTest/LightingTest.cs 2009-05-20 03:33:19 UTC (rev 994)
@@ -45,7 +45,7 @@
lights.AddPointLight(new Vector3(0, 0, -1), Color.White);
lights.AddPointLight(new Vector3(0, 0, -1), Color.Yellow);
- Display.VSync = false;
+ Display.RenderState.WaitForVerticalBlank = false;
//lights[0].Ambient = Color.White;
lights[1].AttenuationConstant = 0.01f;
Modified: branches/agate3d-3.2/Tests/DisplayTests/SpriteTester/frmSpriteTester.cs
===================================================================
--- branches/agate3d-3.2/Tests/DisplayTests/SpriteTester/frmSpriteTester.cs 2009-05-19 16:13:29 UTC (rev 993)
+++ branches/agate3d-3.2/Tests/DisplayTests/SpriteTester/frmSpriteTester.cs 2009-05-20 03:33:19 UTC (rev 994)
@@ -338,7 +338,7 @@
private void chkVSync_CheckedChanged(object sender, EventArgs e)
{
- Display.VSync = chkVSync.Checked;
+ Display.RenderState.WaitForVerticalBlank = chkVSync.Checked;
}
}
Modified: branches/agate3d-3.2/Tests/DisplayTests/TileTester/TileTester.cs
===================================================================
--- branches/agate3d-3.2/Tests/DisplayTests/TileTester/TileTester.cs 2009-05-19 16:13:29 UTC (rev 993)
+++ branches/agate3d-3.2/Tests/DisplayTests/TileTester/TileTester.cs 2009-05-20 03:33:19 UTC (rev 994)
@@ -34,7 +34,7 @@
tile = new Surface("bg-bricks.png");
- Display.VSync = true;
+ Display.RenderState.WaitForVerticalBlank = true;
while (frm.IsDisposed == false)
{
Display.BeginFrame();
Modified: branches/agate3d-3.2/Tests/DisplayTests/TileTester/frmTileTester.cs
===================================================================
--- branches/agate3d-3.2/Tests/DisplayTests/TileTester/frmTileTester.cs 2009-05-19 16:13:29 UTC (rev 993)
+++ branches/agate3d-3.2/Tests/DisplayTests/TileTester/frmTileTester.cs 2009-05-20 03:33:19 UTC (rev 994)
@@ -18,7 +18,7 @@
CreateControl();
DisplayWindow wind = DisplayWindow.CreateFromControl(agateRenderTarget1);
- chkVSync.Checked = Display.VSync;
+ chkVSync.Checked = Display.RenderState.WaitForVerticalBlank;
}
public bool ScrollX
@@ -40,7 +40,7 @@
}
private void chkVSync_CheckedChanged(object sender, EventArgs e)
{
- Display.VSync = chkVSync.Checked;
+ Display.RenderState.WaitForVerticalBlank = chkVSync.Checked;
}
}
}
\ No newline at end of file
Modified: branches/agate3d-3.2/Tests/Fonts/Fonts.cs
===================================================================
--- branches/agate3d-3.2/Tests/Fonts/Fonts.cs 2009-05-19 16:13:29 UTC (rev 993)
+++ branches/agate3d-3.2/Tests/Fonts/Fonts.cs 2009-05-20 03:33:19 UTC (rev 994)
@@ -135,7 +135,7 @@
}
else if (Keyboard.Keys[KeyCode.F2])
{
- Display.VSync = !Display.VSync;
+ Display.RenderState.WaitForVerticalBlank = !Display.RenderState.WaitForVerticalBlank;
Keyboard.ReleaseKey(KeyCode.F2);
}
else if (Keyboard.Keys[KeyCode.Escape])
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ka...@us...> - 2009-05-20 03:37:29
|
Revision: 995
http://agate.svn.sourceforge.net/agate/?rev=995&view=rev
Author: kanato
Date: 2009-05-20 03:37:24 +0000 (Wed, 20 May 2009)
Log Message:
-----------
Deprecate the DoLighting in DisplayImpl.
Modified Paths:
--------------
branches/agate3d-3.2/AgateLib/ImplementationBase/DisplayImpl.cs
branches/agate3d-3.2/Drivers/AgateDrawing/Drawing_Display.cs
Modified: branches/agate3d-3.2/AgateLib/ImplementationBase/DisplayImpl.cs
===================================================================
--- branches/agate3d-3.2/AgateLib/ImplementationBase/DisplayImpl.cs 2009-05-20 03:33:19 UTC (rev 994)
+++ branches/agate3d-3.2/AgateLib/ImplementationBase/DisplayImpl.cs 2009-05-20 03:37:24 UTC (rev 995)
@@ -553,7 +553,11 @@
/// Gets all the light settings from the LightManager.
/// </summary>
/// <param name="lights"></param>
- public abstract void DoLighting(LightManager lights);
+ [Obsolete()]
+ public virtual void DoLighting(LightManager lights)
+ {
+ throw new NotImplementedException("DoLighting is not implemented, and also deprecated.");
+ }
/// <summary>
/// Processes pending events.
Modified: branches/agate3d-3.2/Drivers/AgateDrawing/Drawing_Display.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateDrawing/Drawing_Display.cs 2009-05-20 03:33:19 UTC (rev 994)
+++ branches/agate3d-3.2/Drivers/AgateDrawing/Drawing_Display.cs 2009-05-20 03:37:24 UTC (rev 995)
@@ -250,10 +250,6 @@
{
throw new AgateException("SetOrthoProjection is not implemented in AgateDrawing.dll.");
}
- public override void DoLighting(LightManager lights)
- {
- throw new AgateException("Lighting is not supported by AgateDrawing. Use a 3D accelerated driver such as AgateOTK or AgateMDX for lighting support.");
- }
protected override void SavePixelBuffer(PixelBuffer pixelBuffer, string filename, ImageFileFormat format)
{
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ka...@us...> - 2009-05-20 04:04:28
|
Revision: 997
http://agate.svn.sourceforge.net/agate/?rev=997&view=rev
Author: kanato
Date: 2009-05-20 04:04:18 +0000 (Wed, 20 May 2009)
Log Message:
-----------
Add RenderStates test.
Add support for ZBufferTest in SDX.
Modified Paths:
--------------
branches/agate3d-3.2/AgateLib/DisplayLib/RenderStateAdapter.cs
branches/agate3d-3.2/Drivers/AgateSDX/D3DDevice.cs
branches/agate3d-3.2/Drivers/AgateSDX/SDX_Display.cs
Added Paths:
-----------
branches/agate3d-3.2/Tests/DisplayTests/RenderStates/
branches/agate3d-3.2/Tests/DisplayTests/RenderStates/RenderStates.cs
branches/agate3d-3.2/Tests/DisplayTests/RenderStates/frmRenderStateTest.Designer.cs
branches/agate3d-3.2/Tests/DisplayTests/RenderStates/frmRenderStateTest.cs
branches/agate3d-3.2/Tests/DisplayTests/RenderStates/frmRenderStateTest.resx
Modified: branches/agate3d-3.2/AgateLib/DisplayLib/RenderStateAdapter.cs
===================================================================
--- branches/agate3d-3.2/AgateLib/DisplayLib/RenderStateAdapter.cs 2009-05-20 03:43:15 UTC (rev 996)
+++ branches/agate3d-3.2/AgateLib/DisplayLib/RenderStateAdapter.cs 2009-05-20 04:04:18 UTC (rev 997)
@@ -41,7 +41,6 @@
}
}
-
public bool ZBufferTest
{
get
Modified: branches/agate3d-3.2/Drivers/AgateSDX/D3DDevice.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateSDX/D3DDevice.cs 2009-05-20 03:43:15 UTC (rev 996)
+++ branches/agate3d-3.2/Drivers/AgateSDX/D3DDevice.cs 2009-05-20 04:04:18 UTC (rev 997)
@@ -102,19 +102,8 @@
mDevice.Dispose();
mDevice = null;
}
- //if (mSurfaceVB != null)
- //{
- // mSurfaceVB.Dispose();
- // mSurfaceVB = null;
- //}
}
- //private void CreateSurfaceVB()
- //{
- // //mSurfaceVB = new VertexBuffer(mDevice, SurfaceVBSize,
- // // Usage.WriteOnly | Usage.Dynamic, CustomVertex.TransformedColoredTextured.Format,
- // // Pool.Default);
- //}
public Device Device
{
get { return mDevice; }
Modified: branches/agate3d-3.2/Drivers/AgateSDX/SDX_Display.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateSDX/SDX_Display.cs 2009-05-20 03:43:15 UTC (rev 996)
+++ branches/agate3d-3.2/Drivers/AgateSDX/SDX_Display.cs 2009-05-20 04:04:18 UTC (rev 997)
@@ -1078,6 +1078,7 @@
switch (renderStateBool)
{
case RenderStateBool.WaitForVerticalBlank: return mVSync;
+ case RenderStateBool.ZBufferTest: return mDevice.Device.GetRenderState<bool>(RenderState.ZEnable);
default:
throw new NotSupportedException(string.Format(
"The specified render state, {0}, is not supported by this driver."));
@@ -1093,6 +1094,10 @@
OnVSyncChanged();
break;
+ case RenderStateBool.ZBufferTest:
+ mDevice.Device.SetRenderState(RenderState.ZEnable, value);
+ return;
+
default:
throw new NotSupportedException(string.Format(
"The specified render state, {0}, is not supported by this driver."));
Added: branches/agate3d-3.2/Tests/DisplayTests/RenderStates/RenderStates.cs
===================================================================
--- branches/agate3d-3.2/Tests/DisplayTests/RenderStates/RenderStates.cs (rev 0)
+++ branches/agate3d-3.2/Tests/DisplayTests/RenderStates/RenderStates.cs 2009-05-20 04:04:18 UTC (rev 997)
@@ -0,0 +1,54 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using AgateLib;
+
+namespace Tests.DisplayTests.RenderStates
+{
+ class RenderStates : IAgateTest
+ {
+
+ #region IAgateTest Members
+
+ public string Name
+ {
+ get { return "Render States"; }
+ }
+
+ public string Category
+ {
+ get { return "Display"; }
+ }
+
+ public void Main(string[] args)
+ {
+ using (AgateSetup setup = new AgateSetup(args))
+ {
+ setup.Initialize(true, false, false);
+ if (setup.WasCanceled)
+ return;
+
+ frmRenderStateTest frm = new frmRenderStateTest();
+ frm.Show();
+
+ int count = 0;
+
+ while (frm.Visible)
+ {
+ frm.UpdateFrame();
+
+ count++;
+ if (count > 60)
+ frm.Text = string.Format("Render States - {0:0.00} FPS", AgateLib.DisplayLib.Display.FramesPerSecond);
+
+ Core.KeepAlive();
+
+
+ }
+ }
+ }
+
+ #endregion
+ }
+}
Added: branches/agate3d-3.2/Tests/DisplayTests/RenderStates/frmRenderStateTest.Designer.cs
===================================================================
--- branches/agate3d-3.2/Tests/DisplayTests/RenderStates/frmRenderStateTest.Designer.cs (rev 0)
+++ branches/agate3d-3.2/Tests/DisplayTests/RenderStates/frmRenderStateTest.Designer.cs 2009-05-20 04:04:18 UTC (rev 997)
@@ -0,0 +1,94 @@
+namespace Tests.DisplayTests.RenderStates
+{
+ partial class frmRenderStateTest
+ {
+ /// <summary>
+ /// Required designer variable.
+ /// </summary>
+ private System.ComponentModel.IContainer components = null;
+
+ /// <summary>
+ /// Clean up any resources being used.
+ /// </summary>
+ /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ /// <summary>
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ /// </summary>
+ private void InitializeComponent()
+ {
+ this.agateRenderTarget1 = new AgateLib.WinForms.AgateRenderTarget();
+ this.propertyGrid1 = new System.Windows.Forms.PropertyGrid();
+ this.splitContainer1 = new System.Windows.Forms.SplitContainer();
+ this.splitContainer1.Panel1.SuspendLayout();
+ this.splitContainer1.Panel2.SuspendLayout();
+ this.splitContainer1.SuspendLayout();
+ this.SuspendLayout();
+ //
+ // agateRenderTarget1
+ //
+ this.agateRenderTarget1.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.agateRenderTarget1.Location = new System.Drawing.Point(0, 0);
+ this.agateRenderTarget1.Name = "agateRenderTarget1";
+ this.agateRenderTarget1.Size = new System.Drawing.Size(238, 374);
+ this.agateRenderTarget1.TabIndex = 0;
+ //
+ // propertyGrid1
+ //
+ this.propertyGrid1.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.propertyGrid1.Location = new System.Drawing.Point(0, 0);
+ this.propertyGrid1.Name = "propertyGrid1";
+ this.propertyGrid1.Size = new System.Drawing.Size(362, 374);
+ this.propertyGrid1.TabIndex = 1;
+ //
+ // splitContainer1
+ //
+ this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.splitContainer1.FixedPanel = System.Windows.Forms.FixedPanel.Panel2;
+ this.splitContainer1.Location = new System.Drawing.Point(0, 0);
+ this.splitContainer1.Name = "splitContainer1";
+ //
+ // splitContainer1.Panel1
+ //
+ this.splitContainer1.Panel1.Controls.Add(this.agateRenderTarget1);
+ //
+ // splitContainer1.Panel2
+ //
+ this.splitContainer1.Panel2.Controls.Add(this.propertyGrid1);
+ this.splitContainer1.Size = new System.Drawing.Size(604, 374);
+ this.splitContainer1.SplitterDistance = 238;
+ this.splitContainer1.TabIndex = 2;
+ //
+ // frmRenderStateTest
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(604, 374);
+ this.Controls.Add(this.splitContainer1);
+ this.Name = "frmRenderStateTest";
+ this.Text = "frmRenderStateTest";
+ this.splitContainer1.Panel1.ResumeLayout(false);
+ this.splitContainer1.Panel2.ResumeLayout(false);
+ this.splitContainer1.ResumeLayout(false);
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private AgateLib.WinForms.AgateRenderTarget agateRenderTarget1;
+ private System.Windows.Forms.PropertyGrid propertyGrid1;
+ private System.Windows.Forms.SplitContainer splitContainer1;
+ }
+}
\ No newline at end of file
Added: branches/agate3d-3.2/Tests/DisplayTests/RenderStates/frmRenderStateTest.cs
===================================================================
--- branches/agate3d-3.2/Tests/DisplayTests/RenderStates/frmRenderStateTest.cs (rev 0)
+++ branches/agate3d-3.2/Tests/DisplayTests/RenderStates/frmRenderStateTest.cs 2009-05-20 04:04:18 UTC (rev 997)
@@ -0,0 +1,33 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Windows.Forms;
+using AgateLib.DisplayLib;
+
+namespace Tests.DisplayTests.RenderStates
+{
+ public partial class frmRenderStateTest : Form
+ {
+ DisplayWindow wind;
+
+ public frmRenderStateTest()
+ {
+ InitializeComponent();
+
+ wind = DisplayWindow.CreateFromControl(agateRenderTarget1);
+
+ propertyGrid1.SelectedObject = Display.RenderState;
+ }
+
+ internal void UpdateFrame()
+ {
+ Display.BeginFrame();
+ Display.Clear(AgateLib.Geometry.Color.Green);
+ Display.EndFrame();
+ }
+ }
+}
Added: branches/agate3d-3.2/Tests/DisplayTests/RenderStates/frmRenderStateTest.resx
===================================================================
--- branches/agate3d-3.2/Tests/DisplayTests/RenderStates/frmRenderStateTest.resx (rev 0)
+++ branches/agate3d-3.2/Tests/DisplayTests/RenderStates/frmRenderStateTest.resx 2009-05-20 04:04:18 UTC (rev 997)
@@ -0,0 +1,120 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+ <!--
+ Microsoft ResX Schema
+
+ Version 2.0
+
+ The primary goals of this format is to allow a simple XML format
+ that is mostly human readable. The generation and parsing of the
+ various data types are done through the TypeConverter classes
+ associated with the data types.
+
+ Example:
+
+ ... ado.net/XML headers & schema ...
+ <resheader name="resmimetype">text/microsoft-resx</resheader>
+ <resheader name="version">2.0</resheader>
+ <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+ <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+ <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
+ <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+ <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+ <value>[base64 mime encoded serialized .NET Framework object]</value>
+ </data>
+ <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+ <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
+ <comment>This is a comment</comment>
+ </data>
+
+ There are any number of "resheader" rows that contain simple
+ name/value pairs.
+
+ Each data row contains a name, and value. The row also contains a
+ type or mimetype. Type corresponds to a .NET class that support
+ text/value conversion through the TypeConverter architecture.
+ Classes that don't support this are serialized and stored with the
+ mimetype set.
+
+ The mimetype is used for serialized objects, and tells the
+ ResXResourceReader how to depersist the object. This is currently not
+ extensible. For a given mimetype the value must be set accordingly:
+
+ Note - application/x-microsoft.net.object.binary.base64 is the format
+ that the ResXResourceWriter will generate, however the reader can
+ read any of the formats listed below.
+
+ mimetype: application/x-microsoft.net.object.binary.base64
+ value : The object must be serialized with
+ : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.soap.base64
+ value : The object must be serialized with
+ : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.bytearray.base64
+ value : The object must be serialized into a byte array
+ : using a System.ComponentModel.TypeConverter
+ : and then encoded with base64 encoding.
+ -->
+ <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+ <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
+ <xsd:element name="root" msdata:IsDataSet="true">
+ <xsd:complexType>
+ <xsd:choice maxOccurs="unbounded">
+ <xsd:element name="metadata">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" />
+ </xsd:sequence>
+ <xsd:attribute name="name" use="required" type="xsd:string" />
+ <xsd:attribute name="type" type="xsd:string" />
+ <xsd:attribute name="mimetype" type="xsd:string" />
+ <xsd:attribute ref="xml:space" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="assembly">
+ <xsd:complexType>
+ <xsd:attribute name="alias" type="xsd:string" />
+ <xsd:attribute name="name" type="xsd:string" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="data">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
+ <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+ <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+ <xsd:attribute ref="xml:space" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="resheader">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" />
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:choice>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:schema>
+ <resheader name="resmimetype">
+ <value>text/microsoft-resx</value>
+ </resheader>
+ <resheader name="version">
+ <value>2.0</value>
+ </resheader>
+ <resheader name="reader">
+ <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+ <resheader name="writer">
+ <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+</root>
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ka...@us...> - 2009-05-20 04:10:50
|
Revision: 998
http://agate.svn.sourceforge.net/agate/?rev=998&view=rev
Author: kanato
Date: 2009-05-20 04:10:44 +0000 (Wed, 20 May 2009)
Log Message:
-----------
Remove StencilBufferWrite.
Modified Paths:
--------------
branches/agate3d-3.2/AgateLib/DisplayLib/RenderStateAdapter.cs
branches/agate3d-3.2/Drivers/AgateSDX/SDX_Display.cs
branches/agate3d-3.2/Tests/DisplayTests/RenderStates/frmRenderStateTest.Designer.cs
Modified: branches/agate3d-3.2/AgateLib/DisplayLib/RenderStateAdapter.cs
===================================================================
--- branches/agate3d-3.2/AgateLib/DisplayLib/RenderStateAdapter.cs 2009-05-20 04:04:18 UTC (rev 997)
+++ branches/agate3d-3.2/AgateLib/DisplayLib/RenderStateAdapter.cs 2009-05-20 04:10:44 UTC (rev 998)
@@ -80,19 +80,6 @@
Display.Impl.SetRenderState(RenderStateBool.StencilBufferTest, value);
}
}
- public bool StencilBufferWrite
- {
- get
- {
- CheckDisplayInitialized();
- return Display.Impl.GetRenderState(RenderStateBool.StencilBufferWrite);
- }
- set
- {
- CheckDisplayInitialized();
- Display.Impl.SetRenderState(RenderStateBool.StencilBufferWrite, value);
- }
- }
}
public enum RenderStateBool
@@ -105,6 +92,5 @@
ZBufferWrite,
StencilBufferTest,
- StencilBufferWrite,
}
}
Modified: branches/agate3d-3.2/Drivers/AgateSDX/SDX_Display.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateSDX/SDX_Display.cs 2009-05-20 04:04:18 UTC (rev 997)
+++ branches/agate3d-3.2/Drivers/AgateSDX/SDX_Display.cs 2009-05-20 04:10:44 UTC (rev 998)
@@ -1079,6 +1079,8 @@
{
case RenderStateBool.WaitForVerticalBlank: return mVSync;
case RenderStateBool.ZBufferTest: return mDevice.Device.GetRenderState<bool>(RenderState.ZEnable);
+ case RenderStateBool.StencilBufferTest: return mDevice.Device.GetRenderState<bool>(RenderState.StencilEnable);
+
default:
throw new NotSupportedException(string.Format(
"The specified render state, {0}, is not supported by this driver."));
@@ -1098,6 +1100,10 @@
mDevice.Device.SetRenderState(RenderState.ZEnable, value);
return;
+ case RenderStateBool.StencilBufferTest:
+ mDevice.Device.SetRenderState(RenderState.StencilEnable, value);
+ return;
+
default:
throw new NotSupportedException(string.Format(
"The specified render state, {0}, is not supported by this driver."));
Modified: branches/agate3d-3.2/Tests/DisplayTests/RenderStates/frmRenderStateTest.Designer.cs
===================================================================
--- branches/agate3d-3.2/Tests/DisplayTests/RenderStates/frmRenderStateTest.Designer.cs 2009-05-20 04:04:18 UTC (rev 997)
+++ branches/agate3d-3.2/Tests/DisplayTests/RenderStates/frmRenderStateTest.Designer.cs 2009-05-20 04:10:44 UTC (rev 998)
@@ -77,7 +77,7 @@
this.ClientSize = new System.Drawing.Size(604, 374);
this.Controls.Add(this.splitContainer1);
this.Name = "frmRenderStateTest";
- this.Text = "frmRenderStateTest";
+ this.Text = "Render States";
this.splitContainer1.Panel1.ResumeLayout(false);
this.splitContainer1.Panel2.ResumeLayout(false);
this.splitContainer1.ResumeLayout(false);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ka...@us...> - 2009-08-24 18:06:33
|
Revision: 1021
http://agate.svn.sourceforge.net/agate/?rev=1021&view=rev
Author: kanato
Date: 2009-08-24 18:06:22 +0000 (Mon, 24 Aug 2009)
Log Message:
-----------
Implement initial Effect structures in SDX.
Modified Paths:
--------------
branches/agate3d-3.2/AgateLib/DisplayLib/Display.cs
branches/agate3d-3.2/AgateLib/DisplayLib/Shaders/Effect.cs
branches/agate3d-3.2/AgateLib/DisplayLib/Shaders/ShaderCompiler.cs
branches/agate3d-3.2/AgateLib/DisplayLib/Shaders/ShaderProgram.cs
branches/agate3d-3.2/AgateLib/ImplementationBase/DisplayImpl.cs
branches/agate3d-3.2/AgateLib/ImplementationBase/ShaderCompilerImpl.cs
branches/agate3d-3.2/Drivers/AgateMDX/MDX1_Display.cs
branches/agate3d-3.2/Drivers/AgateOTK/ArbShader.cs
branches/agate3d-3.2/Drivers/AgateOTK/ArbShaderCompiler.cs
branches/agate3d-3.2/Drivers/AgateOTK/GL_Display.cs
branches/agate3d-3.2/Drivers/AgateOTK/GL_VertexBuffer.cs
branches/agate3d-3.2/Drivers/AgateOTK/GlslFragmentProgram.cs
branches/agate3d-3.2/Drivers/AgateOTK/GlslShader.cs
branches/agate3d-3.2/Drivers/AgateOTK/GlslShaderCompiler.cs
branches/agate3d-3.2/Drivers/AgateOTK/GlslVertexProgram.cs
branches/agate3d-3.2/Drivers/AgateOTK/OtkShader.cs
branches/agate3d-3.2/Drivers/AgateSDX/AgateSDX.csproj
branches/agate3d-3.2/Drivers/AgateSDX/HlslCompiler.cs
branches/agate3d-3.2/Drivers/AgateSDX/SDX_Display.cs
branches/agate3d-3.2/Drivers/AgateSDX/SDX_Surface.cs
branches/agate3d-3.2/Tests/Display3D/Hlsl.cs
Added Paths:
-----------
branches/agate3d-3.2/Drivers/AgateSDX/EffectParameter.cs
branches/agate3d-3.2/Drivers/AgateSDX/HlslEffect.cs
branches/agate3d-3.2/Drivers/AgateSDX/SDX_Effect.cs
branches/agate3d-3.2/Tests/Data/shaders/hlsl/PerPixelLighting.fx
Removed Paths:
-------------
branches/agate3d-3.2/AgateLib/DisplayLib/Shaders/PixelShader.cs
branches/agate3d-3.2/AgateLib/DisplayLib/Shaders/VertexShader.cs
branches/agate3d-3.2/Drivers/AgateMDX/HlslCompiler.cs
branches/agate3d-3.2/Drivers/AgateMDX/HlslShaderProgram.cs
branches/agate3d-3.2/Drivers/AgateSDX/HlslShaderProgram.cs
branches/agate3d-3.2/Tests/Data/shaders/hlsl/PerPixelLighting_pixel.txt
branches/agate3d-3.2/Tests/Data/shaders/hlsl/PerPixelLighting_vertex.txt
branches/agate3d-3.2/Tests/Display3D/Glsl.cs
branches/agate3d-3.2/Tests/Display3D/Matrices.cs
branches/agate3d-3.2/Tests/Display3D/Test3d.cs
Modified: branches/agate3d-3.2/AgateLib/DisplayLib/Display.cs
===================================================================
--- branches/agate3d-3.2/AgateLib/DisplayLib/Display.cs 2009-08-24 18:05:34 UTC (rev 1020)
+++ branches/agate3d-3.2/AgateLib/DisplayLib/Display.cs 2009-08-24 18:06:22 UTC (rev 1021)
@@ -137,10 +137,10 @@
}
}
- public static Shaders.ShaderProgram Shader
+ public static Shaders.Effect Effect
{
- get { return impl.Shader; }
- set { impl.Shader = value; }
+ get { return impl.Effect; }
+ set { impl.Effect = value; }
}
/// <summary>
@@ -472,26 +472,6 @@
impl.SetOrthoProjection(region);
}
- #region --- Matrix Settings ---
-
- public static Matrix4 MatrixProjection
- {
- get { return impl.MatrixProjection; }
- set { impl.MatrixProjection = value; }
- }
- public static Matrix4 MatrixView
- {
- get { return impl.MatrixView; }
- set { impl.MatrixView = value; }
- }
- public static Matrix4 MatrixWorld
- {
- get { return impl.MatrixWorld; }
- set { impl.MatrixWorld = value; }
- }
-
-
- #endregion
#region --- Drawing Functions ---
/// <summary>
@@ -687,7 +667,7 @@
DoLighting(LightManager.Empty);
}
-
+ [Obsolete("Use shaders instead.")]
internal static void DoLighting(LightManager lights)
{
impl.DoLighting(lights);
Modified: branches/agate3d-3.2/AgateLib/DisplayLib/Shaders/Effect.cs
===================================================================
--- branches/agate3d-3.2/AgateLib/DisplayLib/Shaders/Effect.cs 2009-08-24 18:05:34 UTC (rev 1020)
+++ branches/agate3d-3.2/AgateLib/DisplayLib/Shaders/Effect.cs 2009-08-24 18:06:22 UTC (rev 1021)
@@ -2,10 +2,47 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
+using AgateLib.Geometry;
+using AgateLib.Geometry.VertexTypes;
namespace AgateLib.DisplayLib.Shaders
{
- public class Effect
+ public abstract class Effect
{
+ public abstract string Technique { get; set; }
+
+ public abstract int Passes { get; }
+
+ public abstract void Begin();
+ public abstract void BeginPass(int passIndex);
+ public abstract void EndPass();
+ public abstract void End();
+
+ public abstract void SetUniform(string name, params float[] v);
+ public abstract void SetUniform(string name, params int[] v);
+ public abstract void SetUniform(string name, Matrix4 matrix);
+
+ public void SetUniform(string name, Vector2 v)
+ {
+ SetUniform(name, v.X, v.Y);
+ }
+ public void SetUniform(string name, Vector3 v)
+ {
+ SetUniform(name, v.X, v.Y, v.Z);
+ }
+ public void SetUniform(string name, Vector4 v)
+ {
+ SetUniform(name, v.X, v.Y, v.Z, v.W);
+ }
+ public void SetUniform(string name, Color color)
+ {
+ SetUniform(name, color.R / 255.0f, color.G / 255.0f, color.B / 255.0f, color.A / 255.0f);
+ }
+
+ public VertexLayout VertexDefinition { get; set; }
+
+ public abstract void Render<T>(RenderHandler<T> handler, T obj);
}
+
+ public delegate void RenderHandler<T>(T obj);
}
Deleted: branches/agate3d-3.2/AgateLib/DisplayLib/Shaders/PixelShader.cs
===================================================================
--- branches/agate3d-3.2/AgateLib/DisplayLib/Shaders/PixelShader.cs 2009-08-24 18:05:34 UTC (rev 1020)
+++ branches/agate3d-3.2/AgateLib/DisplayLib/Shaders/PixelShader.cs 2009-08-24 18:06:22 UTC (rev 1021)
@@ -1,16 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-
-namespace AgateLib.DisplayLib.Shaders
-{
- public abstract class PixelShader
- {
- public virtual ShaderLanguage Language
- {
- get { return ShaderLanguage.Unknown; }
- }
- public string Source { get; protected set; }
- }
-}
Modified: branches/agate3d-3.2/AgateLib/DisplayLib/Shaders/ShaderCompiler.cs
===================================================================
--- branches/agate3d-3.2/AgateLib/DisplayLib/Shaders/ShaderCompiler.cs 2009-08-24 18:05:34 UTC (rev 1020)
+++ branches/agate3d-3.2/AgateLib/DisplayLib/Shaders/ShaderCompiler.cs 2009-08-24 18:06:22 UTC (rev 1021)
@@ -27,14 +27,9 @@
impl = null;
}
- public static ShaderProgram CompileEffect(ShaderLanguage language, string effectSource)
+ public static Effect CompileEffect(ShaderLanguage language, string effectSource)
{
return impl.CompileEffect(language, effectSource);
}
- public static ShaderProgram CompileShader(ShaderLanguage language, string vertexShaderSource, string pixelShaderSource)
- {
- return impl.CompileShader(language, vertexShaderSource, pixelShaderSource);
- }
-
}
}
Modified: branches/agate3d-3.2/AgateLib/DisplayLib/Shaders/ShaderProgram.cs
===================================================================
--- branches/agate3d-3.2/AgateLib/DisplayLib/Shaders/ShaderProgram.cs 2009-08-24 18:05:34 UTC (rev 1020)
+++ branches/agate3d-3.2/AgateLib/DisplayLib/Shaders/ShaderProgram.cs 2009-08-24 18:06:22 UTC (rev 1021)
@@ -7,6 +7,7 @@
namespace AgateLib.DisplayLib.Shaders
{
+ /*
public abstract class ShaderProgram
{
public abstract PixelShader PixelShader { get; }
@@ -39,4 +40,5 @@
}
public delegate void RenderHandler(object obj);
+ * */
}
Deleted: branches/agate3d-3.2/AgateLib/DisplayLib/Shaders/VertexShader.cs
===================================================================
--- branches/agate3d-3.2/AgateLib/DisplayLib/Shaders/VertexShader.cs 2009-08-24 18:05:34 UTC (rev 1020)
+++ branches/agate3d-3.2/AgateLib/DisplayLib/Shaders/VertexShader.cs 2009-08-24 18:06:22 UTC (rev 1021)
@@ -1,16 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-
-namespace AgateLib.DisplayLib.Shaders
-{
- public abstract class VertexShader
- {
- public virtual ShaderLanguage Language
- {
- get { return ShaderLanguage.Unknown; }
- }
- public string Source { get; protected set; }
- }
-}
Modified: branches/agate3d-3.2/AgateLib/ImplementationBase/DisplayImpl.cs
===================================================================
--- branches/agate3d-3.2/AgateLib/ImplementationBase/DisplayImpl.cs 2009-08-24 18:05:34 UTC (rev 1020)
+++ branches/agate3d-3.2/AgateLib/ImplementationBase/DisplayImpl.cs 2009-08-24 18:06:22 UTC (rev 1021)
@@ -638,7 +638,7 @@
throw new NotSupportedException("The current driver does not support shaders.");
}
- public virtual ShaderProgram Shader
+ public virtual Effect Effect
{
get { throw new NotSupportedException("The current driver does not support shaders."); }
set { throw new NotSupportedException("The current driver does not support shaders."); }
Modified: branches/agate3d-3.2/AgateLib/ImplementationBase/ShaderCompilerImpl.cs
===================================================================
--- branches/agate3d-3.2/AgateLib/ImplementationBase/ShaderCompilerImpl.cs 2009-08-24 18:05:34 UTC (rev 1020)
+++ branches/agate3d-3.2/AgateLib/ImplementationBase/ShaderCompilerImpl.cs 2009-08-24 18:06:22 UTC (rev 1021)
@@ -8,7 +8,6 @@
{
public abstract class ShaderCompilerImpl
{
- public abstract ShaderProgram CompileShader(ShaderLanguage language, string vertexShaderSource, string pixelShaderSource);
- public abstract ShaderProgram CompileEffect(ShaderLanguage language, string effectSource);
+ public abstract Effect CompileEffect(ShaderLanguage language, string effectSource);
}
}
Deleted: branches/agate3d-3.2/Drivers/AgateMDX/HlslCompiler.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateMDX/HlslCompiler.cs 2009-08-24 18:05:34 UTC (rev 1020)
+++ branches/agate3d-3.2/Drivers/AgateMDX/HlslCompiler.cs 2009-08-24 18:06:22 UTC (rev 1021)
@@ -1,48 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using AgateLib.DisplayLib.Shaders;
-using AgateLib.ImplementationBase;
-using Direct3D = Microsoft.DirectX.Direct3D;
-
-namespace AgateMDX
-{
- class HlslCompiler : ShaderCompilerImpl
- {
- MDX1_Display mDisplay;
-
- public HlslCompiler(MDX1_Display display)
- {
- mDisplay = display;
- }
-
- public override ShaderProgram CompileEffect(ShaderLanguage language, string effectSource)
- {
- throw new NotImplementedException();
- }
- //public override ShaderProgram CompileEffect(ShaderLanguage language, string effectSource)
- //{
- // Direct3D.Effect effect = Direct3D.Effect.FromString(mDisplay.D3D_Device.Device,
- // effectSource, null, null, Direct3D.ShaderFlags.None, null);
-
- // return new HlslShaderProgram(effect);
- //}
- public override ShaderProgram CompileShader(ShaderLanguage language, string vertexShaderSource, string pixelShaderSource)
- {
- var vertexShaderStream = Direct3D.ShaderLoader.CompileShader(
- vertexShaderSource, "main", null, "vs_1_1", Direct3D.ShaderFlags.None);
-
-
- var vertexShader = new Direct3D.VertexShader(mDisplay.D3D_Device.Device, vertexShaderStream);
-
-
- var pixelShaderStream = Direct3D.ShaderLoader.CompileShader(
- pixelShaderSource, "main", null, "ps_1_1", Direct3D.ShaderFlags.None);
-
- var pixelShader = new Direct3D.PixelShader(mDisplay.D3D_Device.Device, pixelShaderStream);
-
- return new HlslShaderProgram(vertexShader, pixelShader);
- }
- }
-}
Deleted: branches/agate3d-3.2/Drivers/AgateMDX/HlslShaderProgram.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateMDX/HlslShaderProgram.cs 2009-08-24 18:05:34 UTC (rev 1020)
+++ branches/agate3d-3.2/Drivers/AgateMDX/HlslShaderProgram.cs 2009-08-24 18:06:22 UTC (rev 1021)
@@ -1,83 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using AgateLib.DisplayLib;
-using AgateLib.DisplayLib.Shaders;
-using Direct3D = Microsoft.DirectX.Direct3D;
-
-namespace AgateMDX
-{
- class HlslShaderProgram : ShaderProgram
- {
- Direct3D.VertexShader mVertexShader;
- Direct3D.PixelShader mPixelShader;
- MDX1_Display mDisplay;
-
- public HlslShaderProgram(Direct3D.VertexShader vert, Direct3D.PixelShader pix)
- {
- mDisplay = (MDX1_Display)Display.Impl;
-
- mVertexShader = vert;
- mPixelShader = pix;
- }
- public override PixelShader PixelShader
- {
- get { throw new NotImplementedException(); }
- }
-
- public override void SetUniform(string name, AgateLib.Geometry.Matrix4 matrix)
- {
-
- }
-
- public override void SetUniform(string name, params int[] v)
- {
-
- }
-
- public override void SetUniform(string name, params float[] v)
- {
-
- }
-
- public override VertexShader VertexShader
- {
- get { throw new NotImplementedException(); }
- }
-
- public Direct3D.VertexShader HlslVertexShader
- {
- get { return mVertexShader; }
- }
- public Direct3D.PixelShader HlslPixelShader
- {
- get { return mPixelShader; }
- }
-
- public override void Render(RenderHandler handler, object obj)
- {
- mDisplay.D3D_Device.Device.VertexShader = mVertexShader;
- mDisplay.D3D_Device.Device.PixelShader = mPixelShader;
-
- handler(obj);
- //int passcount = mEffect.Begin(Microsoft.DirectX.Direct3D.FX.None);
-
- //for (int i = 0; i < passcount; i++)
- //{
- // mEffect.BeginPass(i);
- // handler(obj);
- // mEffect.EndPass();
- //}
-
- //mEffect.End();
- }
- }
-
- class HlslPixelShader : PixelShader
- {
- }
-
- class HlslVertexShader : VertexShader
- { }
-}
Modified: branches/agate3d-3.2/Drivers/AgateMDX/MDX1_Display.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateMDX/MDX1_Display.cs 2009-08-24 18:05:34 UTC (rev 1020)
+++ branches/agate3d-3.2/Drivers/AgateMDX/MDX1_Display.cs 2009-08-24 18:06:22 UTC (rev 1021)
@@ -240,10 +240,6 @@
{
return BitmapFontUtil.ConstructFromOSFont(bitmapOptions);
}
- protected override ShaderCompilerImpl CreateShaderCompiler()
- {
- return new HlslCompiler(this);
- }
#endregion
@@ -958,26 +954,6 @@
return TransformAgateMatrix(MatrixProjection * MatrixView * MatrixWorld);
}
- HlslShaderProgram mShader;
-
- public override AgateLib.DisplayLib.Shaders.ShaderProgram Shader
- {
- get
- {
- return mShader;
- }
- set
- {
- if (mShader == value)
- return;
-
- mShader = (HlslShaderProgram) value;
-
- mDevice.Device.VertexShader = mShader.HlslVertexShader;
- mDevice.Device.PixelShader = mShader.HlslPixelShader;
-
- }
- }
#endregion
#region --- IPlatformServices Members ---
Modified: branches/agate3d-3.2/Drivers/AgateOTK/ArbShader.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateOTK/ArbShader.cs 2009-08-24 18:05:34 UTC (rev 1020)
+++ branches/agate3d-3.2/Drivers/AgateOTK/ArbShader.cs 2009-08-24 18:06:22 UTC (rev 1021)
@@ -22,11 +22,11 @@
GlslVertexProgram vertex;
GlslFragmentProgram pixel;
- public override PixelShader PixelShader
+ public GlslFragmentProgram PixelShader
{
get { return pixel; }
}
- public override VertexShader VertexShader
+ public GlslVertexProgram VertexShader
{
get { return vertex; }
}
@@ -44,20 +44,20 @@
return GL.Arb.GetUniformLocation(programHandle, name);
}
- public override void SetUniform(string name, params float[] v)
+ public void SetUniform(string name, params float[] v)
{
int loc = GetUniformLocation(name);
}
- public override void SetUniform(string name, params int[] v)
+ public void SetUniform(string name, params int[] v)
{
}
- public override void SetUniform(string name, AgateLib.Geometry.Matrix4 matrix)
+ public void SetUniform(string name, AgateLib.Geometry.Matrix4 matrix)
{
}
- public override void Render(RenderHandler handler, object obj)
+ public void Render<T>(RenderHandler<T> handler, T obj)
{
throw new NotImplementedException();
}
Modified: branches/agate3d-3.2/Drivers/AgateOTK/ArbShaderCompiler.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateOTK/ArbShaderCompiler.cs 2009-08-24 18:05:34 UTC (rev 1020)
+++ branches/agate3d-3.2/Drivers/AgateOTK/ArbShaderCompiler.cs 2009-08-24 18:06:22 UTC (rev 1021)
@@ -14,7 +14,7 @@
{
}
- public override ShaderProgram CompileShader(ShaderLanguage language, string vertexShaderSource, string pixelShaderSource)
+ public OtkShader CompileShader(ShaderLanguage language, string vertexShaderSource, string pixelShaderSource)
{
if (language != ShaderLanguage.Glsl)
throw new NotSupportedException("AgateOTK can only compile and use GLSL shaders.");
@@ -25,7 +25,7 @@
return LinkPrograms(vert, frag);
}
- private ShaderProgram LinkPrograms(GlslVertexProgram vert, GlslFragmentProgram frag)
+ private OtkShader LinkPrograms(GlslVertexProgram vert, GlslFragmentProgram frag)
{
int program = GL.Arb.CreateProgramObject();
@@ -67,7 +67,7 @@
return shaderHandle;
}
- public override ShaderProgram CompileEffect(ShaderLanguage language, string effectSource)
+ public override Effect CompileEffect(ShaderLanguage language, string effectSource)
{
throw new NotImplementedException();
}
Modified: branches/agate3d-3.2/Drivers/AgateOTK/GL_Display.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateOTK/GL_Display.cs 2009-08-24 18:05:34 UTC (rev 1020)
+++ branches/agate3d-3.2/Drivers/AgateOTK/GL_Display.cs 2009-08-24 18:06:22 UTC (rev 1021)
@@ -427,7 +427,7 @@
OtkShader mCurrentShader;
- public override AgateLib.DisplayLib.Shaders.ShaderProgram Shader
+ public OtkShader Shader
{
get
{
Modified: branches/agate3d-3.2/Drivers/AgateOTK/GL_VertexBuffer.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateOTK/GL_VertexBuffer.cs 2009-08-24 18:05:34 UTC (rev 1020)
+++ branches/agate3d-3.2/Drivers/AgateOTK/GL_VertexBuffer.cs 2009-08-24 18:06:22 UTC (rev 1021)
@@ -89,6 +89,7 @@
private void SetAttributes()
{
+ /*
GlslShader shader = Display.Shader as GlslShader;
if (shader == null)
return;
@@ -106,7 +107,9 @@
GL.VertexAttribPointer(shaderAttribIndex, size,
mAttributeBuffers[i].Type,
false, 0, IntPtr.Zero);
- }
+ }*/
+ throw new NotImplementedException();
+
}
private void SetClientStates()
@@ -155,6 +158,7 @@
(IntPtr)mLayout.ElementByteIndex(VertexElement.Texture));
}
+ /*
GlslShader shader = Display.Shader as GlslShader;
if (Textures.ActiveTextures > 1)
@@ -191,6 +195,8 @@
{
GL.BindTexture(TextureTarget.Texture2D, ((GL_Surface)Textures[0].Impl).GLTextureID);
}
+ * */
+ throw new NotImplementedException();
}
private BeginMode SelectBeginMode()
Modified: branches/agate3d-3.2/Drivers/AgateOTK/GlslFragmentProgram.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateOTK/GlslFragmentProgram.cs 2009-08-24 18:05:34 UTC (rev 1020)
+++ branches/agate3d-3.2/Drivers/AgateOTK/GlslFragmentProgram.cs 2009-08-24 18:06:22 UTC (rev 1021)
@@ -6,7 +6,7 @@
namespace AgateOTK
{
- class GlslFragmentProgram : PixelShader
+ class GlslFragmentProgram
{
int index;
@@ -16,7 +16,7 @@
this.Source = source;
}
-
+ public string Source { get; private set; }
public int ShaderHandle
{
get { return index; }
Modified: branches/agate3d-3.2/Drivers/AgateOTK/GlslShader.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateOTK/GlslShader.cs 2009-08-24 18:05:34 UTC (rev 1020)
+++ branches/agate3d-3.2/Drivers/AgateOTK/GlslShader.cs 2009-08-24 18:06:22 UTC (rev 1021)
@@ -139,11 +139,11 @@
}
}
- public override PixelShader PixelShader
+ public GlslFragmentProgram PixelShader
{
get { return pixel; }
}
- public override VertexShader VertexShader
+ public GlslVertexProgram VertexShader
{
get { return vertex; }
}
@@ -178,7 +178,7 @@
throw new AgateLib.AgateException("Could not find uniform {0} in the GLSL program.", name);
}
- public override void SetUniform(string name, params float[] v)
+ public void SetUniform(string name, params float[] v)
{
int loc = GetUniformLocation(name);
@@ -205,7 +205,7 @@
throw new AgateLib.AgateException("Too many parameters to SetUniform.");
}
}
- public override void SetUniform(string name, params int[] v)
+ public void SetUniform(string name, params int[] v)
{
int loc = GetUniformLocation(name);
@@ -233,7 +233,7 @@
}
}
- public override void SetUniform(string name, AgateLib.Geometry.Matrix4 matrix)
+ public void SetUniform(string name, AgateLib.Geometry.Matrix4 matrix)
{
int loc = GetUniformLocation(name);
@@ -244,7 +244,7 @@
}
- public override void Render(RenderHandler handler, object obj)
+ public void Render<T>(RenderHandler<T> handler, T obj)
{
throw new NotImplementedException();
}
Modified: branches/agate3d-3.2/Drivers/AgateOTK/GlslShaderCompiler.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateOTK/GlslShaderCompiler.cs 2009-08-24 18:05:34 UTC (rev 1020)
+++ branches/agate3d-3.2/Drivers/AgateOTK/GlslShaderCompiler.cs 2009-08-24 18:06:22 UTC (rev 1021)
@@ -14,7 +14,7 @@
{
}
- public override ShaderProgram CompileShader(ShaderLanguage language, string vertexShaderSource, string pixelShaderSource)
+ public OtkShader CompileShader(ShaderLanguage language, string vertexShaderSource, string pixelShaderSource)
{
if (language != ShaderLanguage.Glsl)
throw new NotSupportedException("AgateOTK can only compile and use GLSL shaders.");
@@ -25,7 +25,7 @@
return LinkPrograms(vert, frag);
}
- private ShaderProgram LinkPrograms(GlslVertexProgram vert, GlslFragmentProgram frag)
+ private OtkShader LinkPrograms(GlslVertexProgram vert, GlslFragmentProgram frag)
{
int program = GL.CreateProgram();
@@ -84,7 +84,7 @@
return shaderHandle;
}
- public override ShaderProgram CompileEffect(ShaderLanguage language, string effectSource)
+ public override Effect CompileEffect(ShaderLanguage language, string effectSource)
{
throw new NotImplementedException();
}
Modified: branches/agate3d-3.2/Drivers/AgateOTK/GlslVertexProgram.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateOTK/GlslVertexProgram.cs 2009-08-24 18:05:34 UTC (rev 1020)
+++ branches/agate3d-3.2/Drivers/AgateOTK/GlslVertexProgram.cs 2009-08-24 18:06:22 UTC (rev 1021)
@@ -6,7 +6,7 @@
namespace AgateOTK
{
- class GlslVertexProgram : VertexShader
+ class GlslVertexProgram
{
int index;
@@ -20,5 +20,6 @@
{
get { return index; }
}
+ public string Source { get; private set; }
}
}
Modified: branches/agate3d-3.2/Drivers/AgateOTK/OtkShader.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateOTK/OtkShader.cs 2009-08-24 18:05:34 UTC (rev 1020)
+++ branches/agate3d-3.2/Drivers/AgateOTK/OtkShader.cs 2009-08-24 18:06:22 UTC (rev 1021)
@@ -6,7 +6,7 @@
namespace AgateOTK
{
- public abstract class OtkShader : ShaderProgram
+ public abstract class OtkShader
{
public abstract int Handle { get; }
}
Modified: branches/agate3d-3.2/Drivers/AgateSDX/AgateSDX.csproj
===================================================================
--- branches/agate3d-3.2/Drivers/AgateSDX/AgateSDX.csproj 2009-08-24 18:05:34 UTC (rev 1020)
+++ branches/agate3d-3.2/Drivers/AgateSDX/AgateSDX.csproj 2009-08-24 18:06:22 UTC (rev 1021)
@@ -106,6 +106,7 @@
<Compile Include="DrawBuffer.cs">
<SubType>Code</SubType>
</Compile>
+ <Compile Include="EffectParameter.cs" />
<Compile Include="frmFullScreen.cs">
<SubType>Form</SubType>
</Compile>
@@ -116,9 +117,10 @@
<Compile Include="HlslCompiler.cs">
<SubType>Code</SubType>
</Compile>
- <Compile Include="HlslShaderProgram.cs">
+ <Compile Include="HlslEffect.cs">
<SubType>Code</SubType>
</Compile>
+ <Compile Include="SDX_Effect.cs" />
<Compile Include="SDX_Input.cs" />
<Compile Include="SDX_Audio.cs" />
<Compile Include="VertexFormats.cs">
Added: branches/agate3d-3.2/Drivers/AgateSDX/EffectParameter.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateSDX/EffectParameter.cs (rev 0)
+++ branches/agate3d-3.2/Drivers/AgateSDX/EffectParameter.cs 2009-08-24 18:06:22 UTC (rev 1021)
@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using Direct3D = SlimDX.Direct3D9;
+
+namespace AgateSDX
+{
+ class EffectParameter
+ {
+ public string Name { get; set; }
+ public Direct3D.EffectHandle Handle { get; set; }
+ }
+}
Modified: branches/agate3d-3.2/Drivers/AgateSDX/HlslCompiler.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateSDX/HlslCompiler.cs 2009-08-24 18:05:34 UTC (rev 1020)
+++ branches/agate3d-3.2/Drivers/AgateSDX/HlslCompiler.cs 2009-08-24 18:06:22 UTC (rev 1021)
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using System.IO;
using System.Linq;
using System.Text;
using AgateLib.DisplayLib.Shaders;
@@ -17,34 +18,19 @@
mDisplay = display;
}
- public override ShaderProgram CompileEffect(ShaderLanguage language, string effectSource)
+ public override Effect CompileEffect(ShaderLanguage language, string effectSource)
{
- throw new NotImplementedException();
- }
- //public override ShaderProgram CompileEffect(ShaderLanguage language, string effectSource)
- //{
- // Direct3D.Effect effect = Direct3D.Effect.FromString(mDisplay.D3D_Device.Device,
- // effectSource, null, null, Direct3D.ShaderFlags.None, null);
+ string tempFile = Path.GetTempFileName();
- // return new HlslShaderProgram(effect);
- //}
- public override ShaderProgram CompileShader(ShaderLanguage language, string vertexShaderSource, string pixelShaderSource)
- {
- throw new NotImplementedException();
+ using (var stream = new StreamWriter(tempFile))
+ {
+ stream.WriteLine(effectSource);
+ }
- //var vertexShaderStream = Direct3D.ShaderLoader.CompileShader(
- // vertexShaderSource, "main", null, "vs_1_1", Direct3D.ShaderFlags.None);
+ var effect = Direct3D.Effect.FromFile(mDisplay.D3D_Device.Device,
+ tempFile, SlimDX.Direct3D9.ShaderFlags.Debug);
-
- //var vertexShader = new Direct3D.VertexShader(mDisplay.D3D_Device.Device, vertexShaderStream);
-
-
- //var pixelShaderStream = Direct3D.ShaderLoader.CompileShader(
- // pixelShaderSource, "main", null, "ps_1_1", Direct3D.ShaderFlags.None);
-
- //var pixelShader = new Direct3D.PixelShader(mDisplay.D3D_Device.Device, pixelShaderStream);
-
- //return new HlslShaderProgram(vertexShader, pixelShader);
+ return new HlslEffect(effect);
}
}
}
Copied: branches/agate3d-3.2/Drivers/AgateSDX/HlslEffect.cs (from rev 979, branches/agate3d-3.2/Drivers/AgateSDX/HlslShaderProgram.cs)
===================================================================
--- branches/agate3d-3.2/Drivers/AgateSDX/HlslEffect.cs (rev 0)
+++ branches/agate3d-3.2/Drivers/AgateSDX/HlslEffect.cs 2009-08-24 18:06:22 UTC (rev 1021)
@@ -0,0 +1,107 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using AgateLib.DisplayLib;
+using AgateLib.DisplayLib.Shaders;
+using Direct3D = SlimDX.Direct3D9;
+
+namespace AgateSDX
+{
+ class HlslEffect : Effect
+ {
+ SDX_Display mDisplay;
+ Direct3D.Effect mEffect;
+ Dictionary<string, EffectParameter> mParams = new Dictionary<string, EffectParameter>();
+
+ public HlslEffect(Direct3D.Effect effect)
+ {
+ mDisplay = (SDX_Display)Display.Impl;
+ mEffect = effect;
+ }
+
+ private EffectParameter GetParameter(string name)
+ {
+ if (mParams.ContainsKey(name))
+ return mParams[name];
+
+ var param = mEffect.GetParameter(null, name);
+ EffectParameter p = new EffectParameter();
+ p.Name = name;
+ p.Handle = param;
+
+ mParams[name] = p;
+
+ return p;
+ }
+
+ public override void SetUniform(string name, AgateLib.Geometry.Matrix4 matrix)
+ {
+ var param = GetParameter(name);
+
+ mEffect.SetValue<SlimDX.Matrix>(param.Handle, mDisplay.TransformAgateMatrix(matrix));
+ }
+
+ public override void SetUniform(string name, params int[] v)
+ {
+ var param = GetParameter(name);
+
+ }
+
+ public override void SetUniform(string name, params float[] v)
+ {
+
+ }
+
+ public override void Render<T>(RenderHandler<T> handler, T obj)
+ {
+ int passcount = mEffect.Begin(SlimDX.Direct3D9.FX.None);
+
+ for (int i = 0; i < passcount; i++)
+ {
+ mEffect.BeginPass(i);
+ handler(obj);
+ mEffect.EndPass();
+ }
+
+ mEffect.End();
+ }
+
+ public override string Technique
+ {
+ get
+ {
+ throw new NotImplementedException();
+ }
+ set
+ {
+ throw new NotImplementedException();
+ }
+ }
+
+ public override int Passes
+ {
+ get { throw new NotImplementedException(); }
+ }
+
+ public override void Begin()
+ {
+ throw new NotImplementedException();
+ }
+
+ public override void BeginPass(int passIndex)
+ {
+ throw new NotImplementedException();
+ }
+
+ public override void EndPass()
+ {
+ throw new NotImplementedException();
+ }
+
+ public override void End()
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
Deleted: branches/agate3d-3.2/Drivers/AgateSDX/HlslShaderProgram.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateSDX/HlslShaderProgram.cs 2009-08-24 18:05:34 UTC (rev 1020)
+++ branches/agate3d-3.2/Drivers/AgateSDX/HlslShaderProgram.cs 2009-08-24 18:06:22 ...
[truncated message content] |
|
From: <ka...@us...> - 2009-08-29 00:59:29
|
Revision: 1024
http://agate.svn.sourceforge.net/agate/?rev=1024&view=rev
Author: kanato
Date: 2009-08-29 00:59:21 +0000 (Sat, 29 Aug 2009)
Log Message:
-----------
Remove IDIisplayCaps.Supports3D
Modified Paths:
--------------
branches/agate3d-3.2/AgateLib/ImplementationBase/IDisplayCaps.cs
branches/agate3d-3.2/Drivers/AgateDrawing/Drawing_Display.cs
branches/agate3d-3.2/Drivers/AgateMDX/MDX1_Display.cs
branches/agate3d-3.2/Drivers/AgateOTK/GL_Display.cs
branches/agate3d-3.2/Drivers/AgateSDX/SDX_Display.cs
Modified: branches/agate3d-3.2/AgateLib/ImplementationBase/IDisplayCaps.cs
===================================================================
--- branches/agate3d-3.2/AgateLib/ImplementationBase/IDisplayCaps.cs 2009-08-29 00:51:23 UTC (rev 1023)
+++ branches/agate3d-3.2/AgateLib/ImplementationBase/IDisplayCaps.cs 2009-08-29 00:59:21 UTC (rev 1024)
@@ -77,10 +77,6 @@
/// </summary>
bool IsHardwareAccelerated { get; }
/// <summary>
- /// Indicates whether or not 3D drawing is supported.
- /// </summary>
- bool Supports3D { get; }
- /// <summary>
/// Indicates whether or not vertex/pixel shaders are supported.
/// </summary>
bool SupportsShaders { get; }
Modified: branches/agate3d-3.2/Drivers/AgateDrawing/Drawing_Display.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateDrawing/Drawing_Display.cs 2009-08-29 00:51:23 UTC (rev 1023)
+++ branches/agate3d-3.2/Drivers/AgateDrawing/Drawing_Display.cs 2009-08-29 00:59:21 UTC (rev 1024)
@@ -323,11 +323,6 @@
{
get { return false; }
}
-
- bool IDisplayCaps.Supports3D
- {
- get { return false; }
- }
bool IDisplayCaps.SupportsFullScreen
{
get { return false; }
Modified: branches/agate3d-3.2/Drivers/AgateMDX/MDX1_Display.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateMDX/MDX1_Display.cs 2009-08-29 00:51:23 UTC (rev 1023)
+++ branches/agate3d-3.2/Drivers/AgateMDX/MDX1_Display.cs 2009-08-29 00:59:21 UTC (rev 1024)
@@ -830,10 +830,6 @@
{
get { return true; }
}
- bool IDisplayCaps.Supports3D
- {
- get { return true; }
- }
bool IDisplayCaps.SupportsFullScreen
{
Modified: branches/agate3d-3.2/Drivers/AgateOTK/GL_Display.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateOTK/GL_Display.cs 2009-08-29 00:51:23 UTC (rev 1023)
+++ branches/agate3d-3.2/Drivers/AgateOTK/GL_Display.cs 2009-08-29 00:59:21 UTC (rev 1024)
@@ -592,10 +592,6 @@
{
get { return true; }
}
- bool IDisplayCaps.Supports3D
- {
- get { return true; }
- }
bool IDisplayCaps.SupportsFullScreen
{
get { return true; }
Modified: branches/agate3d-3.2/Drivers/AgateSDX/SDX_Display.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateSDX/SDX_Display.cs 2009-08-29 00:51:23 UTC (rev 1023)
+++ branches/agate3d-3.2/Drivers/AgateSDX/SDX_Display.cs 2009-08-29 00:59:21 UTC (rev 1024)
@@ -906,10 +906,6 @@
{
get { return true; }
}
- bool IDisplayCaps.Supports3D
- {
- get { return true; }
- }
bool IDisplayCaps.SupportsFullScreen
{
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ka...@us...> - 2009-08-29 01:20:17
|
Revision: 1025
http://agate.svn.sourceforge.net/agate/?rev=1025&view=rev
Author: kanato
Date: 2009-08-29 01:20:09 +0000 (Sat, 29 Aug 2009)
Log Message:
-----------
Add HLSL compiler error reporting.
Modified Paths:
--------------
branches/agate3d-3.2/Drivers/AgateSDX/HlslCompiler.cs
Added Paths:
-----------
branches/agate3d-3.2/AgateLib/DisplayLib/Shaders/AgateShaderCompileError.cs
Added: branches/agate3d-3.2/AgateLib/DisplayLib/Shaders/AgateShaderCompileError.cs
===================================================================
--- branches/agate3d-3.2/AgateLib/DisplayLib/Shaders/AgateShaderCompileError.cs (rev 0)
+++ branches/agate3d-3.2/AgateLib/DisplayLib/Shaders/AgateShaderCompileError.cs 2009-08-29 01:20:09 UTC (rev 1025)
@@ -0,0 +1,26 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace AgateLib.DisplayLib.Shaders
+{
+ [global::System.Serializable]
+ public class AgateShaderCompilerException : Exception
+ {
+ //
+ // For guidelines regarding the creation of new exception types, see
+ // http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconerrorraisinghandlingguidelines.asp
+ // and
+ // http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dncscol/html/csharp07192001.asp
+ //
+
+ public AgateShaderCompilerException() { }
+ public AgateShaderCompilerException(string message) : base(message) { }
+ public AgateShaderCompilerException(string message, Exception inner) : base(message, inner) { }
+ protected AgateShaderCompilerException(
+ System.Runtime.Serialization.SerializationInfo info,
+ System.Runtime.Serialization.StreamingContext context)
+ : base(info, context) { }
+ }
+}
Modified: branches/agate3d-3.2/Drivers/AgateSDX/HlslCompiler.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateSDX/HlslCompiler.cs 2009-08-29 00:59:21 UTC (rev 1024)
+++ branches/agate3d-3.2/Drivers/AgateSDX/HlslCompiler.cs 2009-08-29 01:20:09 UTC (rev 1025)
@@ -27,10 +27,20 @@
stream.WriteLine(effectSource);
}
- var effect = Direct3D.Effect.FromFile(mDisplay.D3D_Device.Device,
- tempFile, SlimDX.Direct3D9.ShaderFlags.Debug);
+ string compilationErrors = "";
- return new HlslEffect(effect);
+ try
+ {
+ var effect = Direct3D.Effect.FromFile(mDisplay.D3D_Device.Device,
+ tempFile, null, null, null, SlimDX.Direct3D9.ShaderFlags.Debug, null, out compilationErrors);
+
+ return new HlslEffect(effect);
+ }
+ catch (Direct3D.Direct3D9Exception e)
+ {
+ throw new AgateShaderCompilerException(compilationErrors, e);
+ }
+
}
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ka...@us...> - 2009-08-29 01:29:22
|
Revision: 1026
http://agate.svn.sourceforge.net/agate/?rev=1026&view=rev
Author: kanato
Date: 2009-08-29 01:29:10 +0000 (Sat, 29 Aug 2009)
Log Message:
-----------
Some refactoring of the Effect class.
Modified Paths:
--------------
branches/agate3d-3.2/AgateLib/DisplayLib/Shaders/Effect.cs
branches/agate3d-3.2/Drivers/AgateSDX/HlslEffect.cs
branches/agate3d-3.2/Tests/Data/shaders/hlsl/PerPixelLighting.fx
branches/agate3d-3.2/Tests/Display3D/Hlsl.cs
Modified: branches/agate3d-3.2/AgateLib/DisplayLib/Shaders/Effect.cs
===================================================================
--- branches/agate3d-3.2/AgateLib/DisplayLib/Shaders/Effect.cs 2009-08-29 01:20:09 UTC (rev 1025)
+++ branches/agate3d-3.2/AgateLib/DisplayLib/Shaders/Effect.cs 2009-08-29 01:29:10 UTC (rev 1026)
@@ -18,28 +18,28 @@
public abstract void EndPass();
public abstract void End();
- public abstract void SetUniform(string name, params float[] v);
- public abstract void SetUniform(string name, params int[] v);
- public abstract void SetUniform(string name, Matrix4 matrix);
+ public abstract void SetVariable(string name, params float[] v);
+ public abstract void SetVariable(string name, params int[] v);
+ public abstract void SetVariable(string name, Matrix4 matrix);
- public void SetUniform(string name, Vector2 v)
+ public void SetVariable(string name, Vector2 v)
{
- SetUniform(name, v.X, v.Y);
+ SetVariable(name, v.X, v.Y);
}
- public void SetUniform(string name, Vector3 v)
+ public void SetVariable(string name, Vector3 v)
{
- SetUniform(name, v.X, v.Y, v.Z);
+ SetVariable(name, v.X, v.Y, v.Z);
}
- public void SetUniform(string name, Vector4 v)
+ public void SetVariable(string name, Vector4 v)
{
- SetUniform(name, v.X, v.Y, v.Z, v.W);
+ SetVariable(name, v.X, v.Y, v.Z, v.W);
}
- public void SetUniform(string name, Color color)
+ public void SetVariable(string name, Color color)
{
- SetUniform(name, color.R / 255.0f, color.G / 255.0f, color.B / 255.0f, color.A / 255.0f);
+ SetVariable(name, color.R / 255.0f, color.G / 255.0f, color.B / 255.0f, color.A / 255.0f);
}
- public VertexLayout VertexDefinition { get; set; }
+ //public VertexLayout VertexDefinition { get; set; }
public abstract void Render<T>(RenderHandler<T> handler, T obj);
}
Modified: branches/agate3d-3.2/Drivers/AgateSDX/HlslEffect.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateSDX/HlslEffect.cs 2009-08-29 01:20:09 UTC (rev 1025)
+++ branches/agate3d-3.2/Drivers/AgateSDX/HlslEffect.cs 2009-08-29 01:29:10 UTC (rev 1026)
@@ -4,6 +4,7 @@
using System.Text;
using AgateLib.DisplayLib;
using AgateLib.DisplayLib.Shaders;
+using AgateLib.Geometry;
using Direct3D = SlimDX.Direct3D9;
namespace AgateSDX
@@ -35,22 +36,19 @@
return p;
}
- public override void SetUniform(string name, AgateLib.Geometry.Matrix4 matrix)
+ public override void SetVariable(string name, Matrix4 matrix)
{
- var param = GetParameter(name);
-
mEffect.SetValue(name, mDisplay.TransformAgateMatrix(matrix));
}
- public override void SetUniform(string name, params int[] v)
+ public override void SetVariable(string name, params int[] v)
{
- var param = GetParameter(name);
-
+ mEffect.SetValue(name, v);
}
- public override void SetUniform(string name, params float[] v)
+ public override void SetVariable(string name, params float[] v)
{
-
+ mEffect.SetValue(name, v);
}
public override void Render<T>(RenderHandler<T> handler, T obj)
Modified: branches/agate3d-3.2/Tests/Data/shaders/hlsl/PerPixelLighting.fx
===================================================================
(Binary files differ)
Modified: branches/agate3d-3.2/Tests/Display3D/Hlsl.cs
===================================================================
--- branches/agate3d-3.2/Tests/Display3D/Hlsl.cs 2009-08-29 01:20:09 UTC (rev 1025)
+++ branches/agate3d-3.2/Tests/Display3D/Hlsl.cs 2009-08-29 01:29:10 UTC (rev 1026)
@@ -73,15 +73,6 @@
Surface height = new Surface("bg-bricks-heightmap.png");
//Surface height = new Surface("jellybean.png");
- LightManager m = new LightManager();
- m.AddPointLight(new Vector3(0, 0, 0), Color.White);
- m.Enabled = true;
- m.Ambient = Color.FromArgb(0, 255, 0);
- m[0].AttenuationConstant = 0.0001f;
- m[0].AttenuationLinear = 0.004f;
- m[0].AttenuationQuadratic = 0.0001f;
- m[0].Range = 200;
-
double time = 0;
double frequency = 2 * Math.PI / 5;
const float size = 25;
@@ -149,14 +140,13 @@
Display.Clear(Color.Gray);
Matrix4 proj = Matrix4.Projection(45f, wind.Width / (float)wind.Height, 1.0f, 1000f); // projection
+ Matrix4 view = Matrix4.LookAt(eye, eye + lookDir, up);
- m[0].Position = eye;
- m.DoLighting();
-
// world transformation
- proj *= Matrix4.Translation(-size / 2, -size / 2, 0) * Matrix4.RotateZ((float)(frequency * time));
+ Matrix4 world = Matrix4.Translation(-size / 2, -size / 2, 0) * Matrix4.RotateZ((float)(frequency * time));
+ Matrix4 composite = proj * view * world;
- shader.SetUniform("worldViewProj", proj);
+ shader.SetVariable("worldViewProj", composite);
shader.Render(x => x.DrawIndexed(index), buffer);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ka...@us...> - 2009-08-29 03:27:02
|
Revision: 1027
http://agate.svn.sourceforge.net/agate/?rev=1027&view=rev
Author: kanato
Date: 2009-08-29 03:26:47 +0000 (Sat, 29 Aug 2009)
Log Message:
-----------
Rename Matrix4 to Matrix4x4.
Modified Paths:
--------------
branches/agate3d-3.2/AgateLib/DisplayLib/Display.cs
branches/agate3d-3.2/AgateLib/DisplayLib/Shaders/Effect.cs
branches/agate3d-3.2/AgateLib/ImplementationBase/DisplayImpl.cs
branches/agate3d-3.2/Drivers/AgateMDX/MDX1_Display.cs
branches/agate3d-3.2/Drivers/AgateOTK/ArbShader.cs
branches/agate3d-3.2/Drivers/AgateOTK/GL_Display.cs
branches/agate3d-3.2/Drivers/AgateOTK/GlslShader.cs
branches/agate3d-3.2/Drivers/AgateSDX/HlslEffect.cs
branches/agate3d-3.2/Drivers/AgateSDX/SDX_Display.cs
Added Paths:
-----------
branches/agate3d-3.2/AgateLib/Geometry/Matrix4x4.cs
Removed Paths:
-------------
branches/agate3d-3.2/AgateLib/Geometry/Matrix4.cs
Modified: branches/agate3d-3.2/AgateLib/DisplayLib/Display.cs
===================================================================
--- branches/agate3d-3.2/AgateLib/DisplayLib/Display.cs 2009-08-29 01:29:10 UTC (rev 1026)
+++ branches/agate3d-3.2/AgateLib/DisplayLib/Display.cs 2009-08-29 03:26:47 UTC (rev 1027)
@@ -452,6 +452,11 @@
{
SetOrthoProjection(Rectangle.FromLTRB(left, top, right, bottom));
}
+ public static Matrix4x4 GetOrthoProjection()
+ {
+ return Matrix4x4.Ortho(RectangleF.FromLTRB(0, 0, RenderTarget.Width, RenderTarget.Height), -1, 1);
+ }
+
/// <summary>
/// Sets the orthogonal projection for rendering. This allows redefinition of the
/// coordinates used to address pixels in the window.
Modified: branches/agate3d-3.2/AgateLib/DisplayLib/Shaders/Effect.cs
===================================================================
--- branches/agate3d-3.2/AgateLib/DisplayLib/Shaders/Effect.cs 2009-08-29 01:29:10 UTC (rev 1026)
+++ branches/agate3d-3.2/AgateLib/DisplayLib/Shaders/Effect.cs 2009-08-29 03:26:47 UTC (rev 1027)
@@ -20,7 +20,7 @@
public abstract void SetVariable(string name, params float[] v);
public abstract void SetVariable(string name, params int[] v);
- public abstract void SetVariable(string name, Matrix4 matrix);
+ public abstract void SetVariable(string name, Matrix4x4 matrix);
public void SetVariable(string name, Vector2 v)
{
Deleted: branches/agate3d-3.2/AgateLib/Geometry/Matrix4.cs
===================================================================
--- branches/agate3d-3.2/AgateLib/Geometry/Matrix4.cs 2009-08-29 01:29:10 UTC (rev 1026)
+++ branches/agate3d-3.2/AgateLib/Geometry/Matrix4.cs 2009-08-29 03:26:47 UTC (rev 1027)
@@ -1,264 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace AgateLib.Geometry
-{
- public struct Matrix4
- {
- float m11, m12, m13, m14;
- float m21, m22, m23, m24;
- float m31, m32, m33, m34;
- float m41, m42, m43, m44;
-
- public static readonly Matrix4 Identity = new Matrix4(
- 1, 0, 0, 0,
- 0, 1, 0, 0,
- 0, 0, 1, 0,
- 0, 0, 0, 1);
- public static Matrix4 Translation(double x, double y, double z)
- {
- return Translation((float)x, (float)y, (float)z);
- }
- public static Matrix4 Translation(float x, float y, float z)
- {
- return new Matrix4(
- 1, 0, 0, x,
- 0, 1, 0, y,
- 0, 0, 1, z,
- 0, 0, 0, 1);
- }
- public static Matrix4 Translation(Vector3 vec)
- {
- return Translation(vec.X, vec.Y, vec.Z);
- }
-
- public static Matrix4 Scale(float x, float y, float z)
- {
- return new Matrix4(
- x, 0, 0, 0,
- 0, y, 0, 0,
- 0, 0, z, 0,
- 0, 0, 0, 1);
- }
- //public static Matrix4 RotateXDegrees(float angle)
- //{
- // return RotateX(angle * (float)(Math.PI / 180.0));
- //}
- public static Matrix4 RotateX(float angle)
- {
- float cos = (float)Math.Cos(angle);
- float sin = (float)Math.Sin(angle);
-
- return new Matrix4(
- 1, 0, 0, 0,
- 0, cos, -sin, 0,
- 0, sin, cos, 0,
- 0, 0, 0, 1);
- }
- public static Matrix4 RotateY(float angle)
- {
- float cos = (float)Math.Cos(angle);
- float sin = (float)Math.Sin(angle);
-
- return new Matrix4(
- cos, 0, sin, 0,
- 0, 1, 0, 0,
- -sin, 0, cos, 0,
- 0, 0, 0, 1);
- }
- public static Matrix4 RotateZ(float angle)
- {
- float cos = (float)Math.Cos(angle);
- float sin = (float)Math.Sin(angle);
-
- return new Matrix4(
- cos, -sin, 0, 0,
- sin, cos, 0, 0,
- 0, 0, 1, 0,
- 0, 0, 0, 1);
- }
- public static Matrix4 LookAt(Vector3 eye, Vector3 target, Vector3 up)
- {
- // equation from
- // http://pyopengl.sourceforge.net/documentation/manual/gluLookAt.3G.xml
-
- Vector3 f = (target - eye);
-
- f /= f.Magnitude;
- up /= up.Magnitude;
-
- Vector3 s = f.CrossProduct(up);
- s /= s.Magnitude;
-
- Vector3 u = s.CrossProduct(f);
-
- return new Matrix4(
- s.X, s.Y, s.Z, -s.DotProduct(eye),
- u.X, u.Y, u.Z, -u.DotProduct(eye),
- -f.X, -f.Y, -f.Z, f.DotProduct(eye),
- 0, 0, 0, 1);
- }
- /// <summary>
- /// Creates a projection matrix for perspective corrected views.
- /// </summary>
- /// <param name="fieldOfViewY">The vertical field of view in degrees.</param>
- /// <param name="aspect">The aspect ratio of the view port.</param>
- /// <param name="zNear">The z value of the near clipping plane.</param>
- /// <param name="zFar">The z value of the far clipping plane.</param>
- /// <returns></returns>
- public static Matrix4 Projection(float fieldOfViewY, float aspect, float zNear, float zFar)
- {
- if (zFar == zNear)
- throw new ArgumentException("zFar and zNear must not be the same.");
-
- // equation from
- // http://pyopengl.sourceforge.net/documentation/manual/gluPerspective.3G.xml
-
- float fovInRad = (float)(Math.PI * fieldOfViewY / 180.0);
- float cot = (float)(1.0 / Math.Tan(fovInRad / 2));
- float zDiff = zFar - zNear;
-
- return new Matrix4(
- cot / aspect, 0, 0, 0,
- 0, cot, 0, 0,
- 0, 0, -(zFar + zNear) / zDiff, -2 * zFar * zNear / zDiff,
- 0, 0, -1, 0);
- }
- public static Matrix4 Ortho(RectangleF r, float zNear, float zFar)
- {
- // equation from
- // http://pyopengl.sourceforge.net/documentation/manual/glOrtho.3G.xml
-
- return new Matrix4(
- 2 / r.Width, 0, 0, -(r.Right + r.Left) / r.Width,
- 0, -2 / r.Height, 0, (r.Top + r.Bottom) / r.Height,
- 0, 0, -2 / (zFar - zNear), -(zFar + zNear) / (zFar - zNear),
- 0, 0, 0, 1);
- }
-
- public Matrix4(float a11, float a12, float a13, float a14,
- float a21, float a22, float a23, float a24,
- float a31, float a32, float a33, float a34,
- float a41, float a42, float a43, float a44)
- {
- m11 = a11; m12 = a12; m13 = a13; m14 = a14;
- m21 = a21; m22 = a22; m23 = a23; m24 = a24;
- m31 = a31; m32 = a32; m33 = a33; m34 = a34;
- m41 = a41; m42 = a42; m43 = a43; m44 = a44;
- }
-
- public float this[int row, int col]
- {
- get
- {
- if (col < 0 || col > 3) throw new ArgumentOutOfRangeException("col");
-
- switch (row)
- {
- case 0: return Select(col, m11, m12, m13, m14);
- case 1: return Select(col, m21, m22, m23, m24);
- case 2: return Select(col, m31, m32, m33, m34);
- case 3: return Select(col, m41, m42, m43, m44);
- default: throw new ArgumentOutOfRangeException("row");
- }
- }
- set
- {
- if (col < 0 || col > 3) throw new ArgumentOutOfRangeException("col");
-
- switch (row)
- {
- case 0:
- Set(col, value, ref m11, ref m12, ref m13, ref m14);
- break;
- case 1:
- Set(col, value, ref m21, ref m22, ref m23, ref m24);
- break;
- case 2:
- Set(col, value, ref m31, ref m32, ref m33, ref m34);
- break;
- case 3:
- Set(col, value, ref m41, ref m42, ref m43, ref m44);
- break;
- default:
- throw new ArgumentOutOfRangeException("row");
- }
- }
-
- }
-
- private void Set(int index, float value, ref float v1, ref float v2, ref float v3, ref float v4)
- {
- switch (index)
- {
- case 0: v1 = value; break;
- case 1: v2 = value; break;
- case 2: v3 = value; break;
- case 3: v4 = value; break;
- default:
- throw new ArgumentOutOfRangeException("index");
- }
- }
-
- private float Select(int index, float v1, float v2, float v3, float v4)
- {
- switch (index)
- {
- case 0: return v1;
- case 1: return v2;
- case 2: return v3;
- case 3: return v4;
- default:
- throw new ArgumentOutOfRangeException("index");
- }
- }
-
- public Matrix4 Transpose()
- {
- return new Matrix4(
- m11, m21, m31, m41,
- m12, m22, m32, m42,
- m13, m23, m33, m43,
- m14, m24, m34, m44);
- }
-
- private Matrix4 Mult(Matrix4 m)
- {
- Matrix4 retval = new Matrix4();
-
- for (int row = 0; row < 4; row++)
- {
- for (int col = 0; col < 4; col++)
- {
- for (int inner = 0; inner < 4; inner++)
- {
- retval[row, col] +=
- this[row, inner] * m[inner, col];
- }
- }
- }
-
- return retval;
- }
-
- public static Matrix4 operator *(Matrix4 left, Matrix4 right)
- {
- return left.Mult(right);
- }
- public static Vector4 operator *(Matrix4 left, Vector4 right)
- {
- Vector4 retval = new Vector4();
-
- for (int row = 0; row < 4; row++)
- {
- for (int col = 0; col < 4; col++)
- {
- retval[row] += left[row, col] * right[col];
- }
- }
-
- return retval;
- }
- }
-}
Copied: branches/agate3d-3.2/AgateLib/Geometry/Matrix4x4.cs (from rev 923, branches/agate3d-3.2/AgateLib/Geometry/Matrix4.cs)
===================================================================
--- branches/agate3d-3.2/AgateLib/Geometry/Matrix4x4.cs (rev 0)
+++ branches/agate3d-3.2/AgateLib/Geometry/Matrix4x4.cs 2009-08-29 03:26:47 UTC (rev 1027)
@@ -0,0 +1,264 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace AgateLib.Geometry
+{
+ public struct Matrix4x4
+ {
+ float m11, m12, m13, m14;
+ float m21, m22, m23, m24;
+ float m31, m32, m33, m34;
+ float m41, m42, m43, m44;
+
+ public static readonly Matrix4x4 Identity = new Matrix4x4(
+ 1, 0, 0, 0,
+ 0, 1, 0, 0,
+ 0, 0, 1, 0,
+ 0, 0, 0, 1);
+ public static Matrix4x4 Translation(double x, double y, double z)
+ {
+ return Translation((float)x, (float)y, (float)z);
+ }
+ public static Matrix4x4 Translation(float x, float y, float z)
+ {
+ return new Matrix4x4(
+ 1, 0, 0, x,
+ 0, 1, 0, y,
+ 0, 0, 1, z,
+ 0, 0, 0, 1);
+ }
+ public static Matrix4x4 Translation(Vector3 vec)
+ {
+ return Translation(vec.X, vec.Y, vec.Z);
+ }
+
+ public static Matrix4x4 Scale(float x, float y, float z)
+ {
+ return new Matrix4x4(
+ x, 0, 0, 0,
+ 0, y, 0, 0,
+ 0, 0, z, 0,
+ 0, 0, 0, 1);
+ }
+ //public static Matrix4 RotateXDegrees(float angle)
+ //{
+ // return RotateX(angle * (float)(Math.PI / 180.0));
+ //}
+ public static Matrix4x4 RotateX(float angle)
+ {
+ float cos = (float)Math.Cos(angle);
+ float sin = (float)Math.Sin(angle);
+
+ return new Matrix4x4(
+ 1, 0, 0, 0,
+ 0, cos, -sin, 0,
+ 0, sin, cos, 0,
+ 0, 0, 0, 1);
+ }
+ public static Matrix4x4 RotateY(float angle)
+ {
+ float cos = (float)Math.Cos(angle);
+ float sin = (float)Math.Sin(angle);
+
+ return new Matrix4x4(
+ cos, 0, sin, 0,
+ 0, 1, 0, 0,
+ -sin, 0, cos, 0,
+ 0, 0, 0, 1);
+ }
+ public static Matrix4x4 RotateZ(float angle)
+ {
+ float cos = (float)Math.Cos(angle);
+ float sin = (float)Math.Sin(angle);
+
+ return new Matrix4x4(
+ cos, -sin, 0, 0,
+ sin, cos, 0, 0,
+ 0, 0, 1, 0,
+ 0, 0, 0, 1);
+ }
+ public static Matrix4x4 LookAt(Vector3 eye, Vector3 target, Vector3 up)
+ {
+ // equation from
+ // http://pyopengl.sourceforge.net/documentation/manual/gluLookAt.3G.xml
+
+ Vector3 f = (target - eye);
+
+ f /= f.Magnitude;
+ up /= up.Magnitude;
+
+ Vector3 s = f.CrossProduct(up);
+ s /= s.Magnitude;
+
+ Vector3 u = s.CrossProduct(f);
+
+ return new Matrix4x4(
+ s.X, s.Y, s.Z, -s.DotProduct(eye),
+ u.X, u.Y, u.Z, -u.DotProduct(eye),
+ -f.X, -f.Y, -f.Z, f.DotProduct(eye),
+ 0, 0, 0, 1);
+ }
+ /// <summary>
+ /// Creates a projection matrix for perspective corrected views.
+ /// </summary>
+ /// <param name="fieldOfViewY">The vertical field of view in degrees.</param>
+ /// <param name="aspect">The aspect ratio of the view port.</param>
+ /// <param name="zNear">The z value of the near clipping plane.</param>
+ /// <param name="zFar">The z value of the far clipping plane.</param>
+ /// <returns></returns>
+ public static Matrix4x4 Projection(float fieldOfViewY, float aspect, float zNear, float zFar)
+ {
+ if (zFar == zNear)
+ throw new ArgumentException("zFar and zNear must not be the same.");
+
+ // equation from
+ // http://pyopengl.sourceforge.net/documentation/manual/gluPerspective.3G.xml
+
+ float fovInRad = (float)(Math.PI * fieldOfViewY / 180.0);
+ float cot = (float)(1.0 / Math.Tan(fovInRad / 2));
+ float zDiff = zFar - zNear;
+
+ return new Matrix4x4(
+ cot / aspect, 0, 0, 0,
+ 0, cot, 0, 0,
+ 0, 0, -(zFar + zNear) / zDiff, -2 * zFar * zNear / zDiff,
+ 0, 0, -1, 0);
+ }
+ public static Matrix4x4 Ortho(RectangleF r, float zNear, float zFar)
+ {
+ // equation from
+ // http://pyopengl.sourceforge.net/documentation/manual/glOrtho.3G.xml
+
+ return new Matrix4x4(
+ 2 / r.Width, 0, 0, -(r.Right + r.Left) / r.Width,
+ 0, -2 / r.Height, 0, (r.Top + r.Bottom) / r.Height,
+ 0, 0, -2 / (zFar - zNear), -(zFar + zNear) / (zFar - zNear),
+ 0, 0, 0, 1);
+ }
+
+ public Matrix4x4(float a11, float a12, float a13, float a14,
+ float a21, float a22, float a23, float a24,
+ float a31, float a32, float a33, float a34,
+ float a41, float a42, float a43, float a44)
+ {
+ m11 = a11; m12 = a12; m13 = a13; m14 = a14;
+ m21 = a21; m22 = a22; m23 = a23; m24 = a24;
+ m31 = a31; m32 = a32; m33 = a33; m34 = a34;
+ m41 = a41; m42 = a42; m43 = a43; m44 = a44;
+ }
+
+ public float this[int row, int col]
+ {
+ get
+ {
+ if (col < 0 || col > 3) throw new ArgumentOutOfRangeException("col");
+
+ switch (row)
+ {
+ case 0: return Select(col, m11, m12, m13, m14);
+ case 1: return Select(col, m21, m22, m23, m24);
+ case 2: return Select(col, m31, m32, m33, m34);
+ case 3: return Select(col, m41, m42, m43, m44);
+ default: throw new ArgumentOutOfRangeException("row");
+ }
+ }
+ set
+ {
+ if (col < 0 || col > 3) throw new ArgumentOutOfRangeException("col");
+
+ switch (row)
+ {
+ case 0:
+ Set(col, value, ref m11, ref m12, ref m13, ref m14);
+ break;
+ case 1:
+ Set(col, value, ref m21, ref m22, ref m23, ref m24);
+ break;
+ case 2:
+ Set(col, value, ref m31, ref m32, ref m33, ref m34);
+ break;
+ case 3:
+ Set(col, value, ref m41, ref m42, ref m43, ref m44);
+ break;
+ default:
+ throw new ArgumentOutOfRangeException("row");
+ }
+ }
+
+ }
+
+ private void Set(int index, float value, ref float v1, ref float v2, ref float v3, ref float v4)
+ {
+ switch (index)
+ {
+ case 0: v1 = value; break;
+ case 1: v2 = value; break;
+ case 2: v3 = value; break;
+ case 3: v4 = value; break;
+ default:
+ throw new ArgumentOutOfRangeException("index");
+ }
+ }
+
+ private float Select(int index, float v1, float v2, float v3, float v4)
+ {
+ switch (index)
+ {
+ case 0: return v1;
+ case 1: return v2;
+ case 2: return v3;
+ case 3: return v4;
+ default:
+ throw new ArgumentOutOfRangeException("index");
+ }
+ }
+
+ public Matrix4x4 Transpose()
+ {
+ return new Matrix4x4(
+ m11, m21, m31, m41,
+ m12, m22, m32, m42,
+ m13, m23, m33, m43,
+ m14, m24, m34, m44);
+ }
+
+ private Matrix4x4 Mult(Matrix4x4 m)
+ {
+ Matrix4x4 retval = new Matrix4x4();
+
+ for (int row = 0; row < 4; row++)
+ {
+ for (int col = 0; col < 4; col++)
+ {
+ for (int inner = 0; inner < 4; inner++)
+ {
+ retval[row, col] +=
+ this[row, inner] * m[inner, col];
+ }
+ }
+ }
+
+ return retval;
+ }
+
+ public static Matrix4x4 operator *(Matrix4x4 left, Matrix4x4 right)
+ {
+ return left.Mult(right);
+ }
+ public static Vector4 operator *(Matrix4x4 left, Vector4 right)
+ {
+ Vector4 retval = new Vector4();
+
+ for (int row = 0; row < 4; row++)
+ {
+ for (int col = 0; col < 4; col++)
+ {
+ retval[row] += left[row, col] * right[col];
+ }
+ }
+
+ return retval;
+ }
+ }
+}
Modified: branches/agate3d-3.2/AgateLib/ImplementationBase/DisplayImpl.cs
===================================================================
--- branches/agate3d-3.2/AgateLib/ImplementationBase/DisplayImpl.cs 2009-08-29 01:29:10 UTC (rev 1026)
+++ branches/agate3d-3.2/AgateLib/ImplementationBase/DisplayImpl.cs 2009-08-29 03:26:47 UTC (rev 1027)
@@ -612,17 +612,17 @@
throw new AgateException("Cannot create an index buffer with a driver that does not support 3D.");
}
- public virtual Matrix4 MatrixProjection
+ public virtual Matrix4x4 MatrixProjection
{
get { throw new AgateException("3D is not supported."); }
set { throw new AgateException("3D is not supported."); }
}
- public virtual Matrix4 MatrixView
+ public virtual Matrix4x4 MatrixView
{
get { throw new AgateException("3D is not supported."); }
set { throw new AgateException("3D is not supported."); }
}
- public virtual Matrix4 MatrixWorld
+ public virtual Matrix4x4 MatrixWorld
{
get { throw new AgateException("3D is not supported."); }
set { throw new AgateException("3D is not supported."); }
Modified: branches/agate3d-3.2/Drivers/AgateMDX/MDX1_Display.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateMDX/MDX1_Display.cs 2009-08-29 01:29:10 UTC (rev 1026)
+++ branches/agate3d-3.2/Drivers/AgateMDX/MDX1_Display.cs 2009-08-29 03:26:47 UTC (rev 1027)
@@ -858,9 +858,9 @@
#region --- 3D stuff ---
- Matrix4 projection = Matrix4.Identity;
- Matrix4 world = Matrix4.Identity;
- Matrix4 view = Matrix4.Identity;
+ Matrix4x4 projection = Matrix4x4.Identity;
+ Matrix4x4 world = Matrix4x4.Identity;
+ Matrix4x4 view = Matrix4x4.Identity;
protected override VertexBufferImpl CreateVertexBuffer(
AgateLib.Geometry.VertexTypes.VertexLayout layout, int vertexCount)
@@ -872,7 +872,7 @@
return new MDX1_IndexBuffer(this, type, size);
}
- private Matrix TransformAgateMatrix(Matrix4 value)
+ private Matrix TransformAgateMatrix(Matrix4x4 value)
{
Matrix retval = new Matrix();
@@ -898,7 +898,7 @@
return retval;
}
- public override Matrix4 MatrixProjection
+ public override Matrix4x4 MatrixProjection
{
get
{
@@ -906,7 +906,7 @@
}
set
{
- //value = Matrix4.Projection(45, 800 / 600f, 1f, 1000f);
+ //value = Matrix4x4.Projection(45, 800 / 600f, 1f, 1000f);
var x = Microsoft.DirectX.Matrix.PerspectiveFovRH(
(float)(45 * Math.PI / 180), 800 / 600f, 1f, 1000f);
@@ -916,7 +916,7 @@
}
}
- public override Matrix4 MatrixView
+ public override Matrix4x4 MatrixView
{
get
{
@@ -930,7 +930,7 @@
TransformAgateMatrix(value));
}
}
- public override Matrix4 MatrixWorld
+ public override Matrix4x4 MatrixWorld
{
get
{
Modified: branches/agate3d-3.2/Drivers/AgateOTK/ArbShader.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateOTK/ArbShader.cs 2009-08-29 01:29:10 UTC (rev 1026)
+++ branches/agate3d-3.2/Drivers/AgateOTK/ArbShader.cs 2009-08-29 03:26:47 UTC (rev 1027)
@@ -53,7 +53,7 @@
{
}
- public void SetUniform(string name, AgateLib.Geometry.Matrix4 matrix)
+ public void SetUniform(string name, AgateLib.Geometry.Matrix4x4 matrix)
{
}
Modified: branches/agate3d-3.2/Drivers/AgateOTK/GL_Display.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateOTK/GL_Display.cs 2009-08-29 01:29:10 UTC (rev 1026)
+++ branches/agate3d-3.2/Drivers/AgateOTK/GL_Display.cs 2009-08-29 03:26:47 UTC (rev 1027)
@@ -185,11 +185,11 @@
Glu.Ortho2D(region.Left, region.Right, region.Bottom, region.Top);
}
- Matrix4 projection = Matrix4.Identity;
- Matrix4 world = Matrix4.Identity;
- Matrix4 view = Matrix4.Identity;
+ Matrix4x4 projection = Matrix4x4.Identity;
+ Matrix4x4 world = Matrix4x4.Identity;
+ Matrix4x4 view = Matrix4x4.Identity;
- public override Matrix4 MatrixProjection
+ public override Matrix4x4 MatrixProjection
{
get { return projection; }
set
@@ -198,7 +198,7 @@
SetProjection();
}
}
- public override Matrix4 MatrixView
+ public override Matrix4x4 MatrixView
{
get { return view; }
set
@@ -207,7 +207,7 @@
SetModelview();
}
}
- public override Matrix4 MatrixWorld
+ public override Matrix4x4 MatrixWorld
{
get { return world; }
set
@@ -234,7 +234,7 @@
GL.LoadMatrix(ref otkProjection);
}
- private OpenTK.Math.Matrix4 ConvertAgateMatrix(Matrix4 matrix, bool invertY)
+ private OpenTK.Math.Matrix4 ConvertAgateMatrix(Matrix4x4 matrix, bool invertY)
{
int sign = invertY ? -1 : 1;
Modified: branches/agate3d-3.2/Drivers/AgateOTK/GlslShader.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateOTK/GlslShader.cs 2009-08-29 01:29:10 UTC (rev 1026)
+++ branches/agate3d-3.2/Drivers/AgateOTK/GlslShader.cs 2009-08-29 03:26:47 UTC (rev 1027)
@@ -233,7 +233,7 @@
}
}
- public void SetUniform(string name, AgateLib.Geometry.Matrix4 matrix)
+ public void SetUniform(string name, AgateLib.Geometry.Matrix4x4 matrix)
{
int loc = GetUniformLocation(name);
Modified: branches/agate3d-3.2/Drivers/AgateSDX/HlslEffect.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateSDX/HlslEffect.cs 2009-08-29 01:29:10 UTC (rev 1026)
+++ branches/agate3d-3.2/Drivers/AgateSDX/HlslEffect.cs 2009-08-29 03:26:47 UTC (rev 1027)
@@ -36,16 +36,14 @@
return p;
}
- public override void SetVariable(string name, Matrix4 matrix)
+ public override void SetVariable(string name, Matrix4x4 matrix)
{
mEffect.SetValue(name, mDisplay.TransformAgateMatrix(matrix));
}
-
public override void SetVariable(string name, params int[] v)
{
mEffect.SetValue(name, v);
}
-
public override void SetVariable(string name, params float[] v)
{
mEffect.SetValue(name, v);
@@ -73,7 +71,7 @@
}
set
{
- throw new NotImplementedException();
+ mEffect.Technique = value;
}
}
@@ -84,22 +82,22 @@
public override void Begin()
{
- throw new NotImplementedException();
+ mEffect.Begin();
}
public override void BeginPass(int passIndex)
{
- throw new NotImplementedException();
+ mEffect.BeginPass(passIndex);
}
public override void EndPass()
{
- throw new NotImplementedException();
+ mEffect.EndPass();
}
public override void End()
{
- throw new NotImplementedException();
+ mEffect.End();
}
}
}
Modified: branches/agate3d-3.2/Drivers/AgateSDX/SDX_Display.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateSDX/SDX_Display.cs 2009-08-29 01:29:10 UTC (rev 1026)
+++ branches/agate3d-3.2/Drivers/AgateSDX/SDX_Display.cs 2009-08-29 03:26:47 UTC (rev 1027)
@@ -934,9 +934,9 @@
#region --- 3D stuff ---
- Matrix4 projection = Matrix4.Identity;
- Matrix4 world = Matrix4.Identity;
- Matrix4 view = Matrix4.Identity;
+ Matrix4x4 projection = Matrix4x4.Identity;
+ Matrix4x4 world = Matrix4x4.Identity;
+ Matrix4x4 view = Matrix4x4.Identity;
protected override VertexBufferImpl CreateVertexBuffer(
AgateLib.Geometry.VertexTypes.VertexLayout layout, int vertexCount)
@@ -948,7 +948,7 @@
return new SDX_IndexBuffer(this, type, size);
}
- internal Matrix TransformAgateMatrix(Matrix4 value)
+ internal Matrix TransformAgateMatrix(Matrix4x4 value)
{
Matrix retval = new Matrix();
@@ -974,7 +974,7 @@
return retval;
}
- public override Matrix4 MatrixProjection
+ public override Matrix4x4 MatrixProjection
{
get
{
@@ -992,7 +992,7 @@
}
}
- public override Matrix4 MatrixView
+ public override Matrix4x4 MatrixView
{
get
{
@@ -1006,7 +1006,7 @@
TransformAgateMatrix(value));
}
}
- public override Matrix4 MatrixWorld
+ public override Matrix4x4 MatrixWorld
{
get
{
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ka...@us...> - 2009-08-29 04:27:01
|
Revision: 1028
http://agate.svn.sourceforge.net/agate/?rev=1028&view=rev
Author: kanato
Date: 2009-08-29 04:26:54 +0000 (Sat, 29 Aug 2009)
Log Message:
-----------
Shaders working with 2D drawing.
Modified Paths:
--------------
branches/agate3d-3.2/AgateLib/DisplayLib/Shaders/Effect.cs
branches/agate3d-3.2/Drivers/AgateSDX/DrawBuffer.cs
branches/agate3d-3.2/Drivers/AgateSDX/HlslEffect.cs
branches/agate3d-3.2/Drivers/AgateSDX/SDX_Display.cs
Modified: branches/agate3d-3.2/AgateLib/DisplayLib/Shaders/Effect.cs
===================================================================
--- branches/agate3d-3.2/AgateLib/DisplayLib/Shaders/Effect.cs 2009-08-29 03:26:47 UTC (rev 1027)
+++ branches/agate3d-3.2/AgateLib/DisplayLib/Shaders/Effect.cs 2009-08-29 04:26:54 UTC (rev 1028)
@@ -18,6 +18,7 @@
public abstract void EndPass();
public abstract void End();
+ public abstract void SetTexture(EffectTexture tex, string variableName);
public abstract void SetVariable(string name, params float[] v);
public abstract void SetVariable(string name, params int[] v);
public abstract void SetVariable(string name, Matrix4x4 matrix);
@@ -44,5 +45,13 @@
public abstract void Render<T>(RenderHandler<T> handler, T obj);
}
+ public enum EffectTexture
+ {
+ Texture0,
+ Texture1,
+ Texture2,
+ Texture3,
+ }
+
public delegate void RenderHandler<T>(T obj);
}
Modified: branches/agate3d-3.2/Drivers/AgateSDX/DrawBuffer.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateSDX/DrawBuffer.cs 2009-08-29 03:26:47 UTC (rev 1027)
+++ branches/agate3d-3.2/Drivers/AgateSDX/DrawBuffer.cs 2009-08-29 04:26:54 UTC (rev 1028)
@@ -102,6 +102,26 @@
mDevice.AlphaBlend = mAlphaBlend;
mDevice.SetVertexDeclarationForSurfaces();
+ SDX_Display display = (SDX_Display)Display.Impl;
+
+ if (display.Effect != null)
+ {
+ HlslEffect fx = (HlslEffect)display.Effect;
+
+ fx.SetTexture(AgateLib.DisplayLib.Shaders.EffectTexture.Texture0, mTexture);
+
+ fx.InternalRender<object>(DoDraw, null);
+ }
+ else
+ DoDraw(null);
+
+ mVertPointer = 0;
+ mIndexPointer = 0;
+
+ }
+
+ private void DoDraw(object ignored)
+ {
try
{
mDevice.Device.DrawIndexedUserPrimitives
@@ -110,10 +130,6 @@
Marshal.SizeOf(typeof(PositionTextureColor)));
}
catch { }
-
- mVertPointer = 0;
- mIndexPointer = 0;
-
}
}
Modified: branches/agate3d-3.2/Drivers/AgateSDX/HlslEffect.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateSDX/HlslEffect.cs 2009-08-29 03:26:47 UTC (rev 1027)
+++ branches/agate3d-3.2/Drivers/AgateSDX/HlslEffect.cs 2009-08-29 04:26:54 UTC (rev 1028)
@@ -14,6 +14,7 @@
SDX_Display mDisplay;
Direct3D.Effect mEffect;
Dictionary<string, EffectParameter> mParams = new Dictionary<string, EffectParameter>();
+ Dictionary<EffectTexture, string> mTextures = new Dictionary<EffectTexture, string>();
public HlslEffect(Direct3D.Effect effect)
{
@@ -51,18 +52,36 @@
public override void Render<T>(RenderHandler<T> handler, T obj)
{
+ mDisplay.Effect = this;
+
int passcount = mEffect.Begin(SlimDX.Direct3D9.FX.None);
for (int i = 0; i < passcount; i++)
{
mEffect.BeginPass(i);
handler(obj);
+
+ Display.FlushDrawBuffer();
mEffect.EndPass();
}
mEffect.End();
}
+ public void InternalRender<T>(RenderHandler<T> handler, T obj)
+ {
+ mDisplay.Effect = this;
+ int passcount = mEffect.Begin(SlimDX.Direct3D9.FX.None);
+
+ for (int i = 0; i < passcount; i++)
+ {
+ mEffect.BeginPass(i);
+ handler(obj);
+ mEffect.EndPass();
+ }
+
+ mEffect.End();
+ }
public override string Technique
{
get
@@ -82,6 +101,8 @@
public override void Begin()
{
+ mDisplay.Effect = this;
+
mEffect.Begin();
}
@@ -92,12 +113,31 @@
public override void EndPass()
{
+ Display.FlushDrawBuffer();
mEffect.EndPass();
}
public override void End()
{
mEffect.End();
+
+ mDisplay.Effect = null;
}
+
+ public override void SetTexture(EffectTexture tex, string variableName)
+ {
+ if (string.IsNullOrEmpty(variableName))
+ {
+ mTextures.Remove(tex);
+ }
+ else
+ mTextures[tex] = variableName;
+ }
+ public void SetTexture(EffectTexture tex, Direct3D.Texture surf)
+ {
+ string varName = mTextures[tex];
+
+ mEffect.SetTexture(varName, surf);
+ }
}
}
Modified: branches/agate3d-3.2/Drivers/AgateSDX/SDX_Display.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateSDX/SDX_Display.cs 2009-08-29 03:26:47 UTC (rev 1027)
+++ branches/agate3d-3.2/Drivers/AgateSDX/SDX_Display.cs 2009-08-29 04:26:54 UTC (rev 1028)
@@ -774,6 +774,20 @@
#endregion
+ HlslEffect mCurrentEffect;
+
+ public override AgateLib.DisplayLib.Shaders.Effect Effect
+ {
+ get
+ {
+ return mCurrentEffect;
+ }
+ set
+ {
+ mCurrentEffect = (HlslEffect)value;
+ }
+ }
+
protected override void ProcessEvents()
{
System.Windows.Forms.Application.DoEvents();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ka...@us...> - 2009-08-30 01:03:26
|
Revision: 1031
http://agate.svn.sourceforge.net/agate/?rev=1031&view=rev
Author: kanato
Date: 2009-08-30 01:03:13 +0000 (Sun, 30 Aug 2009)
Log Message:
-----------
Refactor Display Caps stuff.
Modified Paths:
--------------
branches/agate3d-3.2/AgateLib/DisplayLib/Display.cs
branches/agate3d-3.2/AgateLib/DisplayLib/Shaders/ShaderLanguage.cs
branches/agate3d-3.2/AgateLib/ImplementationBase/DisplayImpl.cs
branches/agate3d-3.2/Drivers/AgateDrawing/Drawing_Display.cs
branches/agate3d-3.2/Drivers/AgateOTK/GL_Display.cs
branches/agate3d-3.2/Drivers/AgateSDX/SDX_Display.cs
Added Paths:
-----------
branches/agate3d-3.2/AgateLib/DisplayLib/DisplayCapsInfo.cs
Modified: branches/agate3d-3.2/AgateLib/DisplayLib/Display.cs
===================================================================
--- branches/agate3d-3.2/AgateLib/DisplayLib/Display.cs 2009-08-29 16:59:07 UTC (rev 1030)
+++ branches/agate3d-3.2/AgateLib/DisplayLib/Display.cs 2009-08-30 01:03:13 UTC (rev 1031)
@@ -658,7 +658,7 @@
/// <summary>
/// Gets the capabilities of the Display object.
/// </summary>
- public static IDisplayCaps Caps
+ public static DisplayCapsInfo Caps
{
get { return impl.Caps; }
}
Added: branches/agate3d-3.2/AgateLib/DisplayLib/DisplayCapsInfo.cs
===================================================================
--- branches/agate3d-3.2/AgateLib/DisplayLib/DisplayCapsInfo.cs (rev 0)
+++ branches/agate3d-3.2/AgateLib/DisplayLib/DisplayCapsInfo.cs 2009-08-30 01:03:13 UTC (rev 1031)
@@ -0,0 +1,176 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace AgateLib.DisplayLib
+{
+ public class DisplayCapsInfo
+ {
+ /// <summary>
+ /// Indicates whether or not full screen windows can be created.
+ /// </summary>
+ public bool SupportsFullScreen
+ {
+ get { return Display.Impl.Supports(DisplayBoolCaps.FullScreen); }
+ }
+ /// <summary>
+ /// Indicates whether or not the screen resolution can be changed.
+ /// If the Display driver supports full screen but not mode switching,
+ /// then a DisplayWindow which is created with as a full screen window
+ /// cannot change resolutions after it is initially set.
+ /// </summary>
+ public bool SupportsFullScreenModeSwitching
+ {
+ get { return Display.Impl.Supports(DisplayBoolCaps.FullScreenModeSwitching); }
+ }
+ /// <summary>
+ /// Indicates whether setting Surface.SetScale has any visible effect.
+ /// </summary>
+ public bool SupportsScaling
+ {
+ get { return Display.Impl.Supports(DisplayBoolCaps.Scaling); }
+ }
+ /// <summary>
+ /// Indicates whether setting Surface.RotationAngle has any visible effect.
+ /// </summary>
+ public bool SupportsRotation
+ {
+ get { return Display.Impl.Supports(DisplayBoolCaps.Rotation); }
+ }
+ /// <summary>
+ /// Indicates whether setting Surface.Color has any visible effect.
+ /// </summary>
+ public bool SupportsColor
+ {
+ get { return Display.Impl.Supports(DisplayBoolCaps.Color); }
+ }
+ /// <summary>
+ /// Indicates whether Surface gradients are supported. If not, then setting Surface.ColorGradient
+ /// color of a surface is the same as setting the Surface.Color with the average of the
+ /// gradient colors.
+ /// </summary>
+ public bool SupportsGradient
+ {
+ get { return Display.Impl.Supports(DisplayBoolCaps.Gradient); }
+ }
+ /// <summary>
+ /// Indicates whether setting Surface.Alpha has any visible effect.
+ /// </summary>
+ public bool SupportsSurfaceAlpha
+ {
+ get { return Display.Impl.Supports(DisplayBoolCaps.SurfaceAlpha); }
+ }
+ /// <summary>
+ /// Indicates whether the alpha channel in surface pixels is used.
+ /// </summary>
+ public bool SupportsPixelAlpha
+ {
+ get { return Display.Impl.Supports(DisplayBoolCaps.PixelAlpha); }
+ }
+ /// <summary>
+ /// Indicates whether or not lighting is supported.
+ /// </summary>
+ [Obsolete]
+ public bool SupportsLighting
+ {
+ get { return Display.Impl.Supports(DisplayBoolCaps.Lighting); }
+ }
+ /// <summary>
+ /// Indicates the maximum number of lights which can be used.
+ /// </summary>
+ [Obsolete]
+ public int MaxLights
+ {
+ get { return 8; }
+ }
+ /// <summary>
+ /// Indicates whether there is hardware acceleration available for 2D and 3D drawing.
+ /// </summary>
+ public bool IsHardwareAccelerated
+ {
+ get { return Display.Impl.Supports(DisplayBoolCaps.IsHardwareAccelerated); }
+ }
+ /// <summary>
+ /// Indicates whether or not vertex/pixel shaders are supported.
+ /// </summary>
+ public bool SupportsShaders
+ {
+ get { return Display.Impl.Supports(DisplayBoolCaps.Shaders); }
+ }
+ /// <summary>
+ /// Indicates which shader language is supported.
+ /// </summary>
+ public AgateLib.DisplayLib.Shaders.ShaderLanguage ShaderLanguage
+ {
+ get { return AgateLib.DisplayLib.Shaders.ShaderLanguage.Hlsl; }
+ }
+ /// <summary>
+ /// Indicates whether the driver can create a bitmap font from an operating
+ /// system font.
+ /// </summary>
+ public bool CanCreateBitmapFont
+ {
+ get { return Display.Impl.Supports(DisplayBoolCaps.CanCreateBitmapFont); }
+ }
+ }
+
+ public enum DisplayBoolCaps
+ {
+ /// <summary>
+ /// Indicates whether or not full screen windows can be created.
+ /// </summary>
+ FullScreen,
+ /// <summary>
+ /// Indicates whether or not the screen resolution can be changed.
+ /// If the Display driver supports full screen but not mode switching,
+ /// then a DisplayWindow which is created with as a full screen window
+ /// cannot change resolutions after it is initially set.
+ /// </summary>
+ FullScreenModeSwitching,
+ /// <summary>
+ /// Indicates whether setting Surface.SetScale has any visible effect.
+ /// </summary>
+ Scaling,
+ /// <summary>
+ /// Indicates whether setting Surface.RotationAngle has any visible effect.
+ /// </summary>
+ Rotation,
+ /// <summary>
+ /// Indicates whether setting Surface.Color has any visible effect.
+ /// </summary>
+ Color,
+ /// <summary>
+ /// Indicates whether Surface gradients are supported. If not, then setting Surface.ColorGradient
+ /// color of a surface is the same as setting the Surface.Color with the average of the
+ /// gradient colors.
+ /// </summary>
+ Gradient,
+ /// <summary>
+ /// Indicates whether setting Surface.Alpha has any visible effect.
+ /// </summary>
+ SurfaceAlpha,
+ /// <summary>
+ /// Indicates whether the alpha channel in surface pixels is used.
+ /// </summary>
+ PixelAlpha,
+ /// <summary>
+ /// Indicates whether or not lighting is supported.
+ /// </summary>
+ [Obsolete]
+ Lighting,
+ /// <summary>
+ /// Indicates whether there is hardware acceleration available for 2D and 3D drawing.
+ /// </summary>
+ IsHardwareAccelerated,
+ /// <summary>
+ /// Indicates whether or not vertex/pixel shaders are supported.
+ /// </summary>
+ Shaders,
+ /// <summary>
+ /// Indicates whether the driver can create a bitmap font from an operating
+ /// system font.
+ /// </summary>
+ CanCreateBitmapFont,
+ }
+}
Modified: branches/agate3d-3.2/AgateLib/DisplayLib/Shaders/ShaderLanguage.cs
===================================================================
--- branches/agate3d-3.2/AgateLib/DisplayLib/Shaders/ShaderLanguage.cs 2009-08-29 16:59:07 UTC (rev 1030)
+++ branches/agate3d-3.2/AgateLib/DisplayLib/Shaders/ShaderLanguage.cs 2009-08-30 01:03:13 UTC (rev 1031)
@@ -7,7 +7,7 @@
{
public enum ShaderLanguage
{
- Unknown,
+ None,
Glsl,
Hlsl,
Modified: branches/agate3d-3.2/AgateLib/ImplementationBase/DisplayImpl.cs
===================================================================
--- branches/agate3d-3.2/AgateLib/ImplementationBase/DisplayImpl.cs 2009-08-29 16:59:07 UTC (rev 1030)
+++ branches/agate3d-3.2/AgateLib/ImplementationBase/DisplayImpl.cs 2009-08-30 01:03:13 UTC (rev 1031)
@@ -34,10 +34,14 @@
public abstract class DisplayImpl : DriverImplBase
{
private double mAlphaThreshold = 5.0 / 255.0;
+ private DisplayLib.DisplayCapsInfo mCapsInfo = new DisplayCapsInfo();
private IRenderTarget mRenderTarget;
+ public abstract bool Supports(DisplayBoolCaps caps);
+ public abstract IEnumerable<DisplayLib.Shaders.ShaderLanguage> SupportedShaderLanguages { get; }
+
/// <summary>
/// Gets or sets the current render target.
/// </summary>
@@ -547,7 +551,10 @@
/// <summary>
/// Gets the capabilities of the Display object.
/// </summary>
- public abstract IDisplayCaps Caps { get; }
+ public DisplayCapsInfo Caps
+ {
+ get { return mCapsInfo; }
+ }
/// <summary>
/// Gets all the light settings from the LightManager.
Modified: branches/agate3d-3.2/Drivers/AgateDrawing/Drawing_Display.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateDrawing/Drawing_Display.cs 2009-08-29 16:59:07 UTC (rev 1030)
+++ branches/agate3d-3.2/Drivers/AgateDrawing/Drawing_Display.cs 2009-08-30 01:03:13 UTC (rev 1031)
@@ -33,7 +33,7 @@
{
using WinForms;
- public class Drawing_Display : DisplayImpl, IDisplayCaps, IPlatformServices
+ public class Drawing_Display : DisplayImpl, IPlatformServices
{
#region --- Private variables ---
@@ -256,11 +256,6 @@
WinForms.FormUtil.SavePixelBuffer(pixelBuffer, filename, format);
}
- public override IDisplayCaps Caps
- {
- get { return this; }
- }
-
protected override void HideCursor()
{
System.Windows.Forms.Cursor.Hide();
@@ -272,71 +267,31 @@
#region --- IDisplayCaps Members ---
- bool IDisplayCaps.SupportsScaling
+ public override bool Supports(DisplayBoolCaps caps)
{
- get { return true; }
- }
+ switch (caps)
+ {
+ case DisplayBoolCaps.Scaling: return true;
+ case DisplayBoolCaps.Rotation: return true;
+ case DisplayBoolCaps.Color: return true;
+ case DisplayBoolCaps.Gradient: return false;
+ case DisplayBoolCaps.SurfaceAlpha: return true;
+ case DisplayBoolCaps.PixelAlpha: return true;
+ case DisplayBoolCaps.IsHardwareAccelerated: return false;
+ case DisplayBoolCaps.FullScreen: return false;
+ case DisplayBoolCaps.FullScreenModeSwitching: return false;
+ case DisplayBoolCaps.Shaders: return false;
+ case DisplayBoolCaps.CanCreateBitmapFont: return true;
+ }
- bool IDisplayCaps.SupportsRotation
- {
- get { return true; }
+ return false;
}
- bool IDisplayCaps.SupportsColor
+ public override IEnumerable<AgateLib.DisplayLib.Shaders.ShaderLanguage> SupportedShaderLanguages
{
- get { return true; }
+ get { yield return AgateLib.DisplayLib.Shaders.ShaderLanguage.None; }
}
- bool IDisplayCaps.SupportsGradient
- {
- get { return false; }
- }
- bool IDisplayCaps.SupportsSurfaceAlpha
- {
- get { return true; }
- }
- bool IDisplayCaps.SupportsPixelAlpha
- {
- get { return true; }
- }
-
- bool IDisplayCaps.SupportsShaders
- {
- get { return false; }
- }
-
- AgateLib.DisplayLib.Shaders.ShaderLanguage IDisplayCaps.ShaderLanguage
- {
- get { return AgateLib.DisplayLib.Shaders.ShaderLanguage.Unknown; }
- }
- bool IDisplayCaps.SupportsLighting
- {
- get { return false; }
- }
-
- int IDisplayCaps.MaxLights
- {
- get { return 0; }
- }
-
- bool IDisplayCaps.IsHardwareAccelerated
- {
- get { return false; }
- }
- bool IDisplayCaps.SupportsFullScreen
- {
- get { return false; }
- }
- bool IDisplayCaps.SupportsFullScreenModeSwitching
- {
- get { return false; }
- }
-
- bool IDisplayCaps.CanCreateBitmapFont
- {
- get { return true; }
- }
-
#endregion
#region IPlatformServices Members
Modified: branches/agate3d-3.2/Drivers/AgateOTK/GL_Display.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateOTK/GL_Display.cs 2009-08-29 16:59:07 UTC (rev 1030)
+++ branches/agate3d-3.2/Drivers/AgateOTK/GL_Display.cs 2009-08-30 01:03:13 UTC (rev 1031)
@@ -33,7 +33,7 @@
namespace AgateOTK
{
- public sealed class GL_Display : DisplayImpl, IDisplayCaps, AgateLib.PlatformSpecific.IPlatformServices
+ public sealed class GL_Display : DisplayImpl, AgateLib.PlatformSpecific.IPlatformServices
{
GL_IRenderTarget mRenderTarget;
GLState mState;
@@ -555,11 +555,6 @@
AgateLib.WinForms.FormUtil.SavePixelBuffer(pixelBuffer, filename, format);
}
- public override IDisplayCaps Caps
- {
- get { return this; }
- }
-
protected override void HideCursor()
{
System.Windows.Forms.Cursor.Hide();
@@ -583,79 +578,32 @@
#region --- IDisplayCaps Members ---
- bool IDisplayCaps.SupportsScaling
+ public override bool Supports(DisplayBoolCaps caps)
{
- get { return true; }
- }
-
- bool IDisplayCaps.SupportsRotation
- {
- get { return true; }
- }
- bool IDisplayCaps.SupportsFullScreen
- {
- get { return true; }
- }
- bool IDisplayCaps.SupportsFullScreenModeSwitching
- {
- get { return true; }
- }
-
- bool IDisplayCaps.SupportsColor
- {
- get { return true; }
- }
- bool IDisplayCaps.SupportsGradient
- {
- get { return true; }
- }
- bool IDisplayCaps.SupportsSurfaceAlpha
- {
- get { return true; }
- }
-
- bool IDisplayCaps.SupportsShaders
- {
- get
+ switch (caps)
{
- return mSupportsShaders;
+ case DisplayBoolCaps.Scaling: return true;
+ case DisplayBoolCaps.Rotation: return true;
+ case DisplayBoolCaps.Color: return true;
+ case DisplayBoolCaps.Gradient: return true;
+ case DisplayBoolCaps.SurfaceAlpha: return true;
+ case DisplayBoolCaps.PixelAlpha: return true;
+ case DisplayBoolCaps.IsHardwareAccelerated: return true;
+ case DisplayBoolCaps.FullScreen: return true;
+ case DisplayBoolCaps.FullScreenModeSwitching: return true;
+ case DisplayBoolCaps.Shaders: return false;
+ case DisplayBoolCaps.CanCreateBitmapFont: return true;
}
- }
- bool IDisplayCaps.SupportsPixelAlpha
- {
- get { return true; }
- }
- bool IDisplayCaps.SupportsLighting
- {
- get { return true; }
+ return false;
}
- int IDisplayCaps.MaxLights
+ public override IEnumerable<AgateLib.DisplayLib.Shaders.ShaderLanguage> SupportedShaderLanguages
{
- get
- {
- int[] max = new int[1];
- GL.GetInteger(GetPName.MaxLights, max);
-
- return max[0];
- }
+ get { yield return AgateLib.DisplayLib.Shaders.ShaderLanguage.Glsl; }
}
- bool IDisplayCaps.IsHardwareAccelerated
- {
- get { return true; }
- }
- AgateLib.DisplayLib.Shaders.ShaderLanguage IDisplayCaps.ShaderLanguage
- {
- get { return AgateLib.DisplayLib.Shaders.ShaderLanguage.Glsl; }
- }
- bool IDisplayCaps.CanCreateBitmapFont
- {
- get { return true; }
- }
-
#endregion
#region --- IPlatformServices Members ---
Modified: branches/agate3d-3.2/Drivers/AgateSDX/SDX_Display.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateSDX/SDX_Display.cs 2009-08-29 16:59:07 UTC (rev 1030)
+++ branches/agate3d-3.2/Drivers/AgateSDX/SDX_Display.cs 2009-08-30 01:03:13 UTC (rev 1031)
@@ -36,7 +36,7 @@
namespace AgateSDX
{
- public class SDX_Display : DisplayImpl, IDisplayCaps, AgateLib.PlatformSpecific.IPlatformServices
+ public class SDX_Display : DisplayImpl, AgateLib.PlatformSpecific.IPlatformServices
{
#region --- Private Variables ---
@@ -857,11 +857,6 @@
FormUtil.SavePixelBuffer(pixelBuffer, filename, format);
}
- public override IDisplayCaps Caps
- {
- get { return this; }
- }
-
protected override void HideCursor()
{
System.Windows.Forms.Cursor.Hide();
@@ -873,77 +868,31 @@
#region --- IDisplayCaps Members ---
- bool IDisplayCaps.SupportsScaling
+ public override bool Supports(DisplayBoolCaps caps)
{
- get { return true; }
- }
-
- bool IDisplayCaps.SupportsRotation
- {
- get { return true; }
- }
-
- bool IDisplayCaps.SupportsColor
- {
- get { return true; }
- }
- bool IDisplayCaps.SupportsGradient
- {
- get { return true; }
- }
- bool IDisplayCaps.SupportsSurfaceAlpha
- {
- get { return true; }
- }
-
- bool IDisplayCaps.SupportsPixelAlpha
- {
- get { return true; }
- }
-
- bool IDisplayCaps.SupportsLighting
- {
- get { return true; }
- }
-
- int IDisplayCaps.MaxLights
- {
- get
+ switch (caps)
{
- Capabilities c = mDirect3Dobject.Adapters[0].GetCaps(DeviceType.Hardware);
-
- return c.MaxActiveLights;
+ case DisplayBoolCaps.Scaling: return true;
+ case DisplayBoolCaps.Rotation: return true;
+ case DisplayBoolCaps.Color: return true;
+ case DisplayBoolCaps.Gradient: return true;
+ case DisplayBoolCaps.SurfaceAlpha: return true;
+ case DisplayBoolCaps.PixelAlpha: return true;
+ case DisplayBoolCaps.IsHardwareAccelerated: return true;
+ case DisplayBoolCaps.FullScreen: return true;
+ case DisplayBoolCaps.FullScreenModeSwitching: return true;
+ case DisplayBoolCaps.Shaders: return true;
+ case DisplayBoolCaps.CanCreateBitmapFont: return true;
}
- }
- bool IDisplayCaps.IsHardwareAccelerated
- {
- get { return true; }
+ return false;
}
- bool IDisplayCaps.SupportsFullScreen
+ public override IEnumerable<AgateLib.DisplayLib.Shaders.ShaderLanguage> SupportedShaderLanguages
{
- get { return true; }
+ get { yield return AgateLib.DisplayLib.Shaders.ShaderLanguage.Hlsl; }
}
- bool IDisplayCaps.SupportsFullScreenModeSwitching
- {
- get { return true; }
- }
- bool IDisplayCaps.SupportsShaders
- {
- get { return true; }
- }
- AgateLib.DisplayLib.Shaders.ShaderLanguage IDisplayCaps.ShaderLanguage
- {
- get { return AgateLib.DisplayLib.Shaders.ShaderLanguage.Hlsl; }
- }
-
- bool IDisplayCaps.CanCreateBitmapFont
- {
- get { return true; }
- }
-
#endregion
#region --- 3D stuff ---
@@ -1099,5 +1048,6 @@
"The specified render state, {0}, is not supported by this driver."));
}
}
+
}
}
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|