agate-svn-commit Mailing List for AgateLib (Page 21)
Status: Alpha
Brought to you by:
kanato
You can subscribe to this list here.
2009 |
Jan
|
Feb
|
Mar
|
Apr
(86) |
May
(77) |
Jun
|
Jul
(1) |
Aug
(31) |
Sep
(12) |
Oct
(31) |
Nov
(53) |
Dec
(39) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2010 |
Jan
(53) |
Feb
(14) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(2) |
Sep
|
Oct
|
Nov
(7) |
Dec
(13) |
2011 |
Jan
(17) |
Feb
(5) |
Mar
(1) |
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
(10) |
Nov
(21) |
Dec
|
2012 |
Jan
(6) |
Feb
(14) |
Mar
(5) |
Apr
(4) |
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2013 |
Jan
(1) |
Feb
(8) |
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
|
Aug
(2) |
Sep
(1) |
Oct
(5) |
Nov
(9) |
Dec
(5) |
2014 |
Jan
(3) |
Feb
(2) |
Mar
(4) |
Apr
(3) |
May
|
Jun
(5) |
Jul
(33) |
Aug
(69) |
Sep
(35) |
Oct
(4) |
Nov
(1) |
Dec
|
From: <ka...@us...> - 2009-08-31 05:29:11
|
Revision: 1037 http://agate.svn.sourceforge.net/agate/?rev=1037&view=rev Author: kanato Date: 2009-08-31 05:29:04 +0000 (Mon, 31 Aug 2009) Log Message: ----------- Delete AgateMDX. Modified Paths: -------------- trunk/Build/AgateLib-Windows.xml trunk/Drivers/AgateSDX/AgateSDX.csproj Removed Paths: ------------- trunk/Build/Projects/AgateMDX.proj.xml trunk/Drivers/AgateMDX/ Modified: trunk/Build/AgateLib-Windows.xml =================================================================== --- trunk/Build/AgateLib-Windows.xml 2009-08-31 05:26:45 UTC (rev 1036) +++ trunk/Build/AgateLib-Windows.xml 2009-08-31 05:29:04 UTC (rev 1037) @@ -25,7 +25,6 @@ <?include file="Projects/AgateOTK.proj.xml" ?> <?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" ?> Deleted: trunk/Build/Projects/AgateMDX.proj.xml =================================================================== --- trunk/Build/Projects/AgateMDX.proj.xml 2009-08-31 05:26:45 UTC (rev 1036) +++ trunk/Build/Projects/AgateMDX.proj.xml 2009-08-31 05:29:04 UTC (rev 1037) @@ -1,35 +0,0 @@ -<Project name="AgateMDX" path="../Drivers/AgateMDX" 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="Microsoft.DirectX"/> - <Reference name="Microsoft.DirectX.AudioVideoPlayback"/> - <Reference name="Microsoft.DirectX.Direct3D"/> - <Reference name="Microsoft.DirectX.Direct3DX"/> - <Reference name="Microsoft.DirectX.DirectInput"/> - <Reference name="Microsoft.DirectX.DirectSound"/> - <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> Modified: trunk/Drivers/AgateSDX/AgateSDX.csproj =================================================================== --- trunk/Drivers/AgateSDX/AgateSDX.csproj 2009-08-31 05:26:45 UTC (rev 1036) +++ trunk/Drivers/AgateSDX/AgateSDX.csproj 2009-08-31 05:29:04 UTC (rev 1037) @@ -3,7 +3,7 @@ <ProjectType>Local</ProjectType> <ProductVersion>9.0.30729</ProductVersion> <SchemaVersion>2.0</SchemaVersion> - <ProjectGuid>{E5DEDA0F-18A1-4C64-8343-06B04C7C4C56}</ProjectGuid> + <ProjectGuid>{BC71081A-124D-4675-9ECE-92450189EC75}</ProjectGuid> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <ApplicationIcon> @@ -91,12 +91,12 @@ <ItemGroup> <ProjectReference Include="..\..\AgateLib\AgateLib.csproj"> <Name>AgateLib</Name> - <Project>{4514ED3F-E5BC-4748-8ABF-87C184DF8489}</Project> + <Project>{CCAE9D71-50DF-4B75-91AE-D9552A9A8353}</Project> <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package> </ProjectReference> <ProjectReference Include="..\AgateLib.WinForms\AgateLib.WinForms.csproj"> <Name>AgateLib.WinForms</Name> - <Project>{A25F0712-B26B-460A-8E37-314D5D1B5959}</Project> + <Project>{B874EDC7-C67D-4C45-A2B7-A41FDD898A02}</Project> <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package> </ProjectReference> </ItemGroup> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ka...@us...> - 2009-08-31 05:26:57
|
Revision: 1036 http://agate.svn.sourceforge.net/agate/?rev=1036&view=rev Author: kanato Date: 2009-08-31 05:26:45 +0000 (Mon, 31 Aug 2009) Log Message: ----------- Fix surface construction in SDX. Modified Paths: -------------- trunk/Drivers/AgateSDX/SDX_Surface.cs Modified: trunk/Drivers/AgateSDX/SDX_Surface.cs =================================================================== --- trunk/Drivers/AgateSDX/SDX_Surface.cs 2009-08-31 05:13:07 UTC (rev 1035) +++ trunk/Drivers/AgateSDX/SDX_Surface.cs 2009-08-31 05:26:45 UTC (rev 1036) @@ -223,13 +223,13 @@ } mTexture = new Ref<Texture>(Texture.FromStream(mDevice.Device, - st, 0, 0, 1, Usage.None, + stream, 0, 0, 1, Usage.None, format, Pool.Managed, Filter.None, Filter.None, 0x00000000)); mTextureSize = new Size(mTexture.Value.GetSurfaceLevel(0).Description.Width, mTexture.Value.GetSurfaceLevel(0).Description.Height); - //bitmap.Dispose(); + stream.Dispose(); } public void LoadFromFile() { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ka...@us...> - 2009-08-31 05:13:17
|
Revision: 1035 http://agate.svn.sourceforge.net/agate/?rev=1035&view=rev Author: kanato Date: 2009-08-31 05:13:07 +0000 (Mon, 31 Aug 2009) Log Message: ----------- Merge 3D branch into trunk. Modified Paths: -------------- trunk/AgateLib/AgateApplication.cs trunk/AgateLib/AgateException.cs trunk/AgateLib/AgateSetup.cs trunk/AgateLib/AppInitParameters.cs trunk/AgateLib/DisplayLib/Display.cs trunk/AgateLib/DisplayLib/Light.cs trunk/AgateLib/DisplayLib/LightManager.cs trunk/AgateLib/DisplayLib/PixelBuffer.cs trunk/AgateLib/DisplayLib/Surface.cs trunk/AgateLib/Drivers/AgateDriverInfo.cs trunk/AgateLib/Drivers/IDesktopDriver.cs trunk/AgateLib/Drivers/IUserSetSystems.cs trunk/AgateLib/Drivers/Registrar.cs trunk/AgateLib/Drivers/TypeID.cs trunk/AgateLib/Geometry/Color.cs trunk/AgateLib/Geometry/Rectangle.cs trunk/AgateLib/Geometry/RectangleF.cs trunk/AgateLib/Geometry/Vector3.cs trunk/AgateLib/ImplementationBase/DisplayImpl.cs trunk/AgateLib/ImplementationBase/IDisplayCaps.cs trunk/AgateLib/ImplementationBase/SurfaceImpl.cs trunk/AgateLib/InputLib/Mouse.cs trunk/AgateLib/Resources/AgateResourceCollection.cs trunk/AgateLib/Resources/AgateResourceException.cs trunk/AgateLib/Resources/AgateResourceLoader.cs trunk/Build/AgateLib-Windows.xml trunk/Build/monodevelop.sh trunk/Drivers/AgateDrawing/Drawing_Display.cs trunk/Drivers/AgateLib.WinForms/Icons.Designer.cs trunk/Drivers/AgateLib.WinForms/SetSystemsForm.Designer.cs trunk/Drivers/AgateLib.WinForms/SetSystemsForm.cs trunk/Drivers/AgateMDX/D3DDevice.cs trunk/Drivers/AgateMDX/DrawBuffer.cs trunk/Drivers/AgateMDX/MDX1_Display.cs trunk/Drivers/AgateMDX/MDX1_Surface.cs trunk/Drivers/AgateOTK/GL_Display.cs trunk/Drivers/AgateOTK/GL_DisplayControl.cs trunk/Drivers/AgateOTK/GL_GameWindow.cs trunk/Drivers/AgateOTK/GL_Surface.cs trunk/Drivers/AgateOTK/OpenTK.Utilities.dll trunk/Drivers/AgateOTK/OpenTK.dll trunk/Drivers/AgateOTK/OpenTK.xml trunk/Drivers/AgateOTK/Otk_Reporter.cs trunk/Drivers/AgateSDL/Reporter.cs trunk/Tests/AudioTests/AudioPlayer/AudioPlayer.cs trunk/Tests/CoreTests/Performance/Performance.cs trunk/Tests/DisplayTests/BasicDrawing/BasicDrawing.cs trunk/Tests/DisplayTests/BasicDrawing/DrawingTester.Designer.cs trunk/Tests/DisplayTests/BasicDrawing/DrawingTester.cs trunk/Tests/DisplayTests/PixelBufferTest/PixelBufferTest.cs trunk/Tests/DisplayTests/SpriteTester/frmSpriteTester.cs trunk/Tests/DisplayTests/TileTester/TileTester.cs trunk/Tests/DisplayTests/TileTester/frmTileTester.Designer.cs trunk/Tests/DisplayTests/TileTester/frmTileTester.cs trunk/Tests/Fonts/Fonts.cs trunk/Tests/Launcher.cs trunk/Tests/frmLauncher.cs Added Paths: ----------- trunk/AgateLib/DisplayLib/DisplayCapsInfo.cs trunk/AgateLib/DisplayLib/IndexBuffer.cs trunk/AgateLib/DisplayLib/PrimitiveType.cs trunk/AgateLib/DisplayLib/RenderStateAdapter.cs trunk/AgateLib/DisplayLib/Shaders/ trunk/AgateLib/DisplayLib/Shaders/AgateShaderCompileError.cs trunk/AgateLib/DisplayLib/Shaders/Effect.cs trunk/AgateLib/DisplayLib/Shaders/ShaderCompiler.cs trunk/AgateLib/DisplayLib/Shaders/ShaderLanguage.cs trunk/AgateLib/DisplayLib/Shaders/ShaderProgram.cs trunk/AgateLib/DisplayLib/Shaders/Technique.cs trunk/AgateLib/DisplayLib/Shaders/UniformState.cs trunk/AgateLib/DisplayLib/VertexBuffer.cs trunk/AgateLib/Geometry/Builders/ trunk/AgateLib/Geometry/Builders/Cube.cs trunk/AgateLib/Geometry/Builders/Terrain.cs trunk/AgateLib/Geometry/Matrix4x4.cs trunk/AgateLib/Geometry/Vector4.cs trunk/AgateLib/Geometry/VertexTypes/ trunk/AgateLib/Geometry/VertexTypes/PositionColor.cs trunk/AgateLib/Geometry/VertexTypes/PositionTextureColor.cs trunk/AgateLib/Geometry/VertexTypes/PositionTextureNTB.cs trunk/AgateLib/Geometry/VertexTypes/PositionTextureNormal.cs trunk/AgateLib/Geometry/VertexTypes/VertexLayout.cs trunk/AgateLib/ImplementationBase/IndexBufferImpl.cs trunk/AgateLib/ImplementationBase/ShaderCompilerImpl.cs trunk/AgateLib/ImplementationBase/VertexBufferImpl.cs trunk/AgateLib/Meshes/ trunk/AgateLib/Meshes/Loaders/ trunk/AgateLib/Meshes/Loaders/OBJFileRepresentation.cs trunk/AgateLib/Meshes/Loaders/Obj/ trunk/AgateLib/Meshes/Loaders/Obj/OBJFileRepresentation.cs trunk/AgateLib/Meshes/Loaders/Obj/Parser.cs trunk/AgateLib/Meshes/Loaders/Obj/TokenTypes.cs trunk/Build/Projects/AgateSDX.proj.xml trunk/Drivers/AgateMDX/MDX1_IndexBuffer.cs trunk/Drivers/AgateMDX/MDX1_VertexBuffer.cs trunk/Drivers/AgateOTK/ArbShader.cs trunk/Drivers/AgateOTK/ArbShaderCompiler.cs trunk/Drivers/AgateOTK/GL_IndexBuffer.cs trunk/Drivers/AgateOTK/GL_VertexBuffer.cs trunk/Drivers/AgateOTK/GlslFragmentProgram.cs trunk/Drivers/AgateOTK/GlslShader.cs trunk/Drivers/AgateOTK/GlslShaderCompiler.cs trunk/Drivers/AgateOTK/GlslVertexProgram.cs trunk/Drivers/AgateOTK/OtkShader.cs trunk/Drivers/AgateSDX/ trunk/Drivers/AgateSDX/AgateSDX.csproj trunk/Drivers/AgateSDX/D3DDevice.cs trunk/Drivers/AgateSDX/DrawBuffer.cs trunk/Drivers/AgateSDX/EffectParameter.cs trunk/Drivers/AgateSDX/HlslCompiler.cs trunk/Drivers/AgateSDX/HlslEffect.cs trunk/Drivers/AgateSDX/Properties/ trunk/Drivers/AgateSDX/Properties/AssemblyInfo.cs trunk/Drivers/AgateSDX/Reporter.cs trunk/Drivers/AgateSDX/SDX_Audio.cs trunk/Drivers/AgateSDX/SDX_Display.cs trunk/Drivers/AgateSDX/SDX_DisplayWindow.cs trunk/Drivers/AgateSDX/SDX_Effect.cs trunk/Drivers/AgateSDX/SDX_IRenderTarget.cs trunk/Drivers/AgateSDX/SDX_IndexBuffer.cs trunk/Drivers/AgateSDX/SDX_Input.cs trunk/Drivers/AgateSDX/SDX_Surface.cs trunk/Drivers/AgateSDX/SDX_VertexBuffer.cs trunk/Drivers/AgateSDX/VertexFormats.cs trunk/Drivers/AgateSDX/frmFullScreen.Designer.cs trunk/Drivers/AgateSDX/frmFullScreen.cs trunk/Drivers/AgateSDX/frmFullScreen.resx trunk/Tests/Data/bg-bricks-heightmap.png trunk/Tests/Data/shaders/ trunk/Tests/Data/shaders/glsl/ trunk/Tests/Data/shaders/glsl/BumpMap_fragment.txt trunk/Tests/Data/shaders/glsl/BumpMap_vertex.txt trunk/Tests/Data/shaders/glsl/PerPixelLighting_fragment.txt trunk/Tests/Data/shaders/glsl/PerPixelLighting_vertex.txt trunk/Tests/Data/shaders/hlsl/ trunk/Tests/Data/shaders/hlsl/Lighting.fx trunk/Tests/Data/shaders/hlsl/PerPixelLighting.fx trunk/Tests/DisplayTests/RenderStates/ trunk/Tests/DisplayTests/RenderStates/RenderStates.cs trunk/Tests/DisplayTests/RenderStates/frmRenderStateTest.Designer.cs trunk/Tests/DisplayTests/RenderStates/frmRenderStateTest.cs trunk/Tests/DisplayTests/RenderStates/frmRenderStateTest.resx trunk/Tests/Shaders/ trunk/Tests/Shaders/Hlsl.cs trunk/Tests/Shaders/LightingTest/ trunk/Tests/Shaders/LightingTest/LightingTest.cs trunk/Tests/Shaders/LightingTest/LightingTestForm.Designer.cs trunk/Tests/Shaders/LightingTest/LightingTestForm.cs trunk/Tests/Shaders/LightingTest/LightingTestForm.resx Removed Paths: ------------- trunk/AgateLib/DisplayLib/Shaders/AgateShaderCompileError.cs trunk/AgateLib/DisplayLib/Shaders/Effect.cs trunk/AgateLib/DisplayLib/Shaders/ShaderCompiler.cs trunk/AgateLib/DisplayLib/Shaders/ShaderLanguage.cs trunk/AgateLib/DisplayLib/Shaders/ShaderProgram.cs trunk/AgateLib/DisplayLib/Shaders/Technique.cs trunk/AgateLib/DisplayLib/Shaders/UniformState.cs trunk/AgateLib/Geometry/Builders/Cube.cs trunk/AgateLib/Geometry/Builders/Terrain.cs trunk/AgateLib/Geometry/VertexTypes/PositionColor.cs trunk/AgateLib/Geometry/VertexTypes/PositionTextureColor.cs trunk/AgateLib/Geometry/VertexTypes/PositionTextureNTB.cs trunk/AgateLib/Geometry/VertexTypes/PositionTextureNormal.cs trunk/AgateLib/Geometry/VertexTypes/VertexLayout.cs trunk/AgateLib/Meshes/Loaders/ trunk/AgateLib/Meshes/Loaders/OBJFileRepresentation.cs trunk/AgateLib/Meshes/Loaders/Obj/ trunk/AgateLib/Meshes/Loaders/Obj/OBJFileRepresentation.cs trunk/AgateLib/Meshes/Loaders/Obj/Parser.cs trunk/AgateLib/Meshes/Loaders/Obj/TokenTypes.cs trunk/Drivers/AgateSDX/AgateSDX.csproj trunk/Drivers/AgateSDX/D3DDevice.cs trunk/Drivers/AgateSDX/DrawBuffer.cs trunk/Drivers/AgateSDX/EffectParameter.cs trunk/Drivers/AgateSDX/HlslCompiler.cs trunk/Drivers/AgateSDX/HlslEffect.cs trunk/Drivers/AgateSDX/Properties/ trunk/Drivers/AgateSDX/Properties/AssemblyInfo.cs trunk/Drivers/AgateSDX/Reporter.cs trunk/Drivers/AgateSDX/SDX_Audio.cs trunk/Drivers/AgateSDX/SDX_Display.cs trunk/Drivers/AgateSDX/SDX_DisplayWindow.cs trunk/Drivers/AgateSDX/SDX_Effect.cs trunk/Drivers/AgateSDX/SDX_IRenderTarget.cs trunk/Drivers/AgateSDX/SDX_IndexBuffer.cs trunk/Drivers/AgateSDX/SDX_Input.cs trunk/Drivers/AgateSDX/SDX_Surface.cs trunk/Drivers/AgateSDX/SDX_VertexBuffer.cs trunk/Drivers/AgateSDX/VertexFormats.cs trunk/Drivers/AgateSDX/frmFullScreen.Designer.cs trunk/Drivers/AgateSDX/frmFullScreen.cs trunk/Drivers/AgateSDX/frmFullScreen.resx trunk/Tests/Data/shaders/glsl/ trunk/Tests/Data/shaders/glsl/BumpMap_fragment.txt trunk/Tests/Data/shaders/glsl/BumpMap_vertex.txt trunk/Tests/Data/shaders/glsl/PerPixelLighting_fragment.txt trunk/Tests/Data/shaders/glsl/PerPixelLighting_vertex.txt trunk/Tests/Data/shaders/hlsl/ trunk/Tests/Data/shaders/hlsl/Lighting.fx trunk/Tests/Data/shaders/hlsl/PerPixelLighting.fx trunk/Tests/DisplayTests/LightingTest/ trunk/Tests/DisplayTests/RenderStates/RenderStates.cs trunk/Tests/DisplayTests/RenderStates/frmRenderStateTest.Designer.cs trunk/Tests/DisplayTests/RenderStates/frmRenderStateTest.cs trunk/Tests/DisplayTests/RenderStates/frmRenderStateTest.resx trunk/Tests/Shaders/Hlsl.cs trunk/Tests/Shaders/LightingTest/ trunk/Tests/Shaders/LightingTest/LightingTest.cs trunk/Tests/Shaders/LightingTest/LightingTestForm.Designer.cs trunk/Tests/Shaders/LightingTest/LightingTestForm.cs trunk/Tests/Shaders/LightingTest/LightingTestForm.resx Property Changed: ---------------- trunk/ trunk/AgateLib/ trunk/AgateLib/AgateFileProvider.cs trunk/AgateLib/AgateSetup.cs trunk/AgateLib/AudioLib/ trunk/AgateLib/AudioLib/Audio.cs trunk/AgateLib/BitmapFont/FontMetrics.cs trunk/AgateLib/BitmapFont/GlyphMetrics.cs trunk/AgateLib/Core.cs trunk/AgateLib/DisplayLib/ trunk/AgateLib/DisplayLib/Display.cs trunk/AgateLib/DisplayLib/StringTransformer.cs trunk/AgateLib/Drivers/AgateDriverReporter.cs trunk/AgateLib/Drivers/IDesktopDriver.cs trunk/AgateLib/ImplementationBase/ trunk/AgateLib/ImplementationBase/AudioImpl.cs trunk/AgateLib/InputLib/ trunk/AgateLib/Resources/AgateResourceCollection.cs trunk/AgateLib/Resources/AgateResourceLoader.cs trunk/AgateLib/Resources/BitmapFontResource.cs trunk/AgateLib/Sprites/Sprite.cs trunk/AgateLib/Sprites/SpriteFrame.cs trunk/AgateLib/Timing.cs trunk/AgateLib/Utility/Platform.cs trunk/Build/monodevelop.sh trunk/Drivers/ trunk/Drivers/AgateDrawing/Drawing_Reporter.cs trunk/Drivers/AgateLib.WinForms/ trunk/Drivers/AgateSDL/ trunk/Drivers/AgateSDL/Audio/SDL_Audio.cs trunk/Drivers/AgateSDL/Audio/SDL_Music.cs trunk/Drivers/AgateSDL/Audio/SDL_SoundBuffer.cs trunk/Drivers/AgateSDL/Audio/SDL_SoundBufferSession.cs trunk/Drivers/AgateSDL/Input/SDL_Input.cs trunk/Drivers/AgateSDL/Reporter.cs trunk/Examples/BallBuster.Net/OpenTK.dll.config trunk/Tests/CoreTests/ trunk/Tests/DisplayTests/SurfaceTester/SurfaceTester.cs trunk/Tests/DisplayTests/TestPacker/TestPacker.cs trunk/Tests/DisplayTests/TestPacker/frmTestPacker.Designer.cs trunk/Tests/DisplayTests/TestPacker/frmTestPacker.cs trunk/Tests/DisplayTests/TestPacker/frmTestPacker.resx trunk/Tests/DisplayTests/TileTester/TileTester.cs trunk/Tests/DisplayTests/TileTester/frmTileTester.Designer.cs trunk/Tests/DisplayTests/TileTester/frmTileTester.cs trunk/Tests/DisplayTests/TileTester/frmTileTester.resx trunk/Tests/InputTests/Input/ trunk/Tests/InputTests/Input/InputTester.cs trunk/Tests/InputTests/Input/frmInputTester.Designer.cs trunk/Tests/InputTests/Input/frmInputTester.cs trunk/Tests/InputTests/InputState/ trunk/Tests/InputTests/InputState/InputStateTester.cs trunk/Tools/FontCreator/CreateFont.Designer.cs trunk/Tools/FontCreator/CreateFont.cs trunk/Tools/FontCreator/CreateFont.resx trunk/Tools/FontCreator/EditGlyphs.Designer.cs trunk/Tools/FontCreator/EditGlyphs.cs trunk/Tools/FontCreator/EditGlyphs.resx trunk/Tools/FontCreator/SaveFont.Designer.cs trunk/Tools/FontCreator/SaveFont.cs trunk/Tools/FontCreator/SaveFont.resx trunk/Tools/FontCreator/frmFontCreator.Designer.cs trunk/Tools/FontCreator/frmFontCreator.cs trunk/Tools/FontCreator/frmFontCreator.resx trunk/Tools/PackedSpriteCreator/SpriteEditor.Designer.cs trunk/Tools/PackedSpriteCreator/SpriteEditor.cs trunk/Tools/PackedSpriteCreator/SpriteEditor.resx trunk/Tools/PackedSpriteCreator/SpritePacker.cs Property changes on: trunk ___________________________________________________________________ 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/agate3d-3.2:923-1034 /branches/build:424-517 /branches/font:778-916 /branches/merge-tests:806-810 /branches/registrar:595-599 /branches/sprites:463-513 Property changes on: trunk/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/agate3d-3.2/AgateLib:923-1034 /branches/build/AgateLib:447-448,501-517 /branches/font/AgateLib:778-916 /branches/merge-tests/AgateLib:806-810 /branches/registrar/AgateLib:595-599 /branches/sprites/AgateLib:463-513 Modified: trunk/AgateLib/AgateApplication.cs =================================================================== --- trunk/AgateLib/AgateApplication.cs 2009-08-30 20:21:03 UTC (rev 1034) +++ trunk/AgateLib/AgateApplication.cs 2009-08-31 05:13:07 UTC (rev 1035) @@ -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, @@ -233,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: trunk/AgateLib/AgateException.cs =================================================================== --- trunk/AgateLib/AgateException.cs 2009-08-30 20:21:03 UTC (rev 1034) +++ trunk/AgateLib/AgateException.cs 2009-08-31 05:13:07 UTC (rev 1035) @@ -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: trunk/AgateLib/AgateFileProvider.cs ___________________________________________________________________ Modified: svn:mergeinfo - /branches/build/AgateLib/Utility/AgateFileProvider.cs:447-517 /branches/font/AgateLib/AgateFileProvider.cs:778-916 /branches/merge-tests/AgateLib/AgateFileProvider.cs:806-810 /branches/registrar/AgateLib/Utility/AgateFileProvider.cs:595-599 /branches/sprites/AgateLib/Utility/AgateFileProvider.cs:463-513 + /branches/agate3d-3.2/AgateLib/AgateFileProvider.cs:923-1034 /branches/build/AgateLib/Utility/AgateFileProvider.cs:447-517 /branches/font/AgateLib/AgateFileProvider.cs:778-916 /branches/merge-tests/AgateLib/AgateFileProvider.cs:806-810 /branches/registrar/AgateLib/Utility/AgateFileProvider.cs:595-599 /branches/sprites/AgateLib/Utility/AgateFileProvider.cs:463-513 Modified: trunk/AgateLib/AgateSetup.cs =================================================================== --- trunk/AgateLib/AgateSetup.cs 2009-08-30 20:21:03 UTC (rev 1034) +++ trunk/AgateLib/AgateSetup.cs 2009-08-31 05:13:07 UTC (rev 1035) @@ -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; } Property changes on: trunk/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/agate3d-3.2/AgateLib/AgateSetup.cs:923-1034 /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 Modified: trunk/AgateLib/AppInitParameters.cs =================================================================== --- trunk/AgateLib/AppInitParameters.cs 2009-08-30 20:21:03 UTC (rev 1034) +++ trunk/AgateLib/AppInitParameters.cs 2009-08-31 05:13:07 UTC (rev 1035) @@ -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; } + } } Property changes on: trunk/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/agate3d-3.2/AgateLib/AudioLib:923-1034 /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: trunk/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/agate3d-3.2/AgateLib/AudioLib/Audio.cs:923-1034 /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: trunk/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/agate3d-3.2/AgateLib/BitmapFont/FontMetrics.cs:923-1034 /branches/font/AgateLib/BitmapFont/FontMetrics.cs:778-916 /branches/merge-tests/AgateLib/BitmapFont/FontMetrics.cs:806-810 Property changes on: trunk/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/agate3d-3.2/AgateLib/BitmapFont/GlyphMetrics.cs:923-1034 /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: trunk/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/agate3d-3.2/AgateLib/Core.cs:923-1034 /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: trunk/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/agate3d-3.2/AgateLib/DisplayLib:923-1034 /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: trunk/AgateLib/DisplayLib/Display.cs =================================================================== --- trunk/AgateLib/DisplayLib/Display.cs 2009-08-30 20:21:03 UTC (rev 1034) +++ trunk/AgateLib/DisplayLib/Display.cs 2009-08-31 05:13:07 UTC (rev 1035) @@ -61,6 +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>(); + private static RenderStateAdapter mRenderState = new RenderStateAdapter(); /// <summary> /// Gets the object which handles all of the actual calls to Display functions. @@ -91,8 +94,17 @@ impl.Initialize(); mSurfacePacker = new SurfacePacker(); + } + public static RenderStateAdapter RenderState + { + get { return mRenderState; } } + + private static ShaderCompilerImpl CreateShaderCompiler() + { + return impl.CreateShaderCompiler(); + } /// <summary> /// Disposes of the Display. /// </summary> @@ -125,6 +137,12 @@ } } + public static Shaders.Effect Effect + { + get { return impl.Effect; } + set { impl.Effect = value; } + } + /// <summary> /// Delegate type for functions which are called when Display.Dispose is called /// at the end of execution of the program. @@ -142,20 +160,6 @@ DisposeDisplay(); } - private static bool TestPath(string filename, out string fullPath) - { - if (File.Exists(filename)) - { - fullPath = Path.GetFullPath(filename); - return true; - } - else - { - fullPath = ""; - return false; - } - } - /// <summary> /// Returns the PixelFormat of Surfaces which are created to be compatible /// with the display mode. If you want to create a PixelBuffer which does @@ -278,6 +282,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. @@ -322,15 +327,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 AgateException("You have popped the cliprect too many times."); + } + else + { + SetClipRect(mClipRects.Pop()); + } } + /// <summary> /// Returns the maximum size a surface object can be. /// </summary> @@ -398,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> @@ -449,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. @@ -468,6 +476,7 @@ { impl.SetOrthoProjection(region); } + #region --- Drawing Functions --- /// <summary> @@ -489,7 +498,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. @@ -522,7 +531,6 @@ { if (pts.Length % 2 == 1) throw new ArgumentException("pts argument is not an even number of points!"); - impl.DrawLineSegments(pts, color); } /// <summary> @@ -555,7 +563,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> @@ -622,7 +658,7 @@ /// <summary> /// Gets the capabilities of the Display object. /// </summary> - public static IDisplayCaps Caps + public static DisplayCapsInfo Caps { get { return impl.Caps; } } @@ -630,11 +666,13 @@ /// <summary> /// Turns lighting functions off. /// </summary> + [Obsolete("Use shaders instead.")] public static void DisableLighting() { DoLighting(LightManager.Empty); } + [Obsolete("Use shaders instead.")] internal static void DoLighting(LightManager lights) { impl.DoLighting(lights); @@ -661,6 +699,4 @@ } } - - } Property changes on: trunk/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/agate3d-3.2/AgateLib/DisplayLib/Display.cs:923-1034 /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 Copied: trunk/AgateLib/DisplayLib/DisplayCapsInfo.cs (from rev 1034, branches/agate3d-3.2/AgateLib/DisplayLib/DisplayCapsInfo.cs) =================================================================== --- trunk/AgateLib/DisplayLib/DisplayCapsInfo.cs (rev 0) +++ trunk/AgateLib/DisplayLib/DisplayCapsInfo.cs 2009-08-31 05:13:07 UTC (rev 1035) @@ -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, + } +} Copied: trunk/AgateLib/DisplayLib/IndexBuffer.cs (from rev 1034, branches/agate3d-3.2/AgateLib/DisplayLib/IndexBuffer.cs) =================================================================== --- trunk/AgateLib/DisplayLib/IndexBuffer.cs (rev 0) +++ trunk/AgateLib/DisplayLib/IndexBuffer.cs 2009-08-31 05:13:07 UTC (rev 1035) @@ -0,0 +1,93 @@ +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) + { + 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; } + } + + public IndexBufferImpl Impl + { + get { return impl; } + } + } + + public enum IndexBufferType + { + Int16, + Int32, + } +} Modified: trunk/AgateLib/DisplayLib/Light.cs =================================================================== --- trunk/AgateLib/DisplayLib/Light.cs 2009-08-30 20:21:03 UTC (rev 1034) +++ trunk/AgateLib/DisplayLib/Light.cs 2009-08-31 05:13:07 UTC (rev 1035) @@ -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: trunk/AgateLib/DisplayLib/LightManager.cs =================================================================== --- trunk/AgateLib/DisplayLib/LightManager.cs 2009-08-30 20:21:03 UTC (rev 1034) +++ trunk/AgateLib/DisplayLib/LightManager.cs 2009-08-31 05:13:07 UTC (rev 1035) @@ -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: trunk/AgateLib/DisplayLib/PixelBuffer.cs =================================================================== --- trunk/AgateLib/DisplayLib/PixelBuffer.cs 2009-08-30 20:21:03 UTC (rev 1034) +++ trunk/AgateLib/DisplayLib/PixelBuffer.cs 2009-08-31 05:13:07 UTC (rev 1035) @@ -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 } } Copied: trunk/AgateLib/DisplayLib/PrimitiveType.cs (from rev 1034, branches/agate3d-3.2/AgateLib/DisplayLib/PrimitiveType.cs) =================================================================== --- trunk/AgateLib/DisplayLib/PrimitiveType.cs (rev 0) +++ trunk/AgateLib/DisplayLib/PrimitiveType.cs 2009-08-31 05:13:07 UTC (rev 1035) @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace AgateLib.DisplayLib +{ + public enum PrimitiveType + { + TriangleList, + TriangleFan, + TriangleStrip, + } +} Copied: trunk/AgateLib/DisplayLib/RenderStateAdapter.cs (from rev 1034, branches/agate3d-3.2/AgateLib/DisplayLib/RenderStateAdapter.cs) =================================================================== --- trunk/AgateLib/DisplayLib/RenderStateAdapter.cs (rev 0) +++ trunk/AgateLib/DisplayLib/RenderStateAdapter.cs 2009-08-31 05:13:07 UTC (rev 1035) @@ -0,0 +1,96 @@ +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 enum RenderStateBool + { + WaitForVerticalBlank, + + AlphaBlend, + + ZBufferTest, + ZBufferWrite, + + StencilBufferTest, + } +} Deleted: trunk/AgateLib/DisplayLib/Shaders/AgateShaderCompileError.cs =================================================================== --- branches/agate3d-3.2/AgateLib/DisplayLib/Shaders/AgateShaderCompileError.cs 2009-08-30 20:21:03 UTC (rev 1034) +++ trunk/AgateLib/DisplayLib/Shaders/AgateShaderCompileError.cs 2009-08-31 05:13:07 UTC (rev 1035) @@ -1,26 +0,0 @@ -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) { } - } -} Copied: trunk/AgateLib/DisplayLib/Shaders/AgateShaderCompileError.cs (from rev 1034, branches/agate3d-3.2/AgateLib/DisplayLib/Shaders/AgateShaderCompileError.cs) =================================================================== --- trunk/AgateLib/DisplayLib/Shaders/AgateShaderCompileError.cs (rev 0) +++ trunk/AgateLib/DisplayLib/Shaders/AgateShaderCompileError.cs 2009-08-31 05:13:07 UTC (rev 1035) @@ -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) { } + } +} Deleted: trunk/AgateLib/DisplayLib/Shaders/Effect.cs =================================================================== --- branches/agate3d-3.2/AgateLib/DisplayLib/Shaders/Effect.cs 2009-08-30 20:21:03 UTC (rev 1034) +++ trunk/AgateLib/DisplayLib/Shaders/Effect.cs 2009-08-31 05:13:07 UTC (rev 1035) @@ -1,57 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using AgateLib.Geometry; -using AgateLib.Geometry.VertexTypes; - -namespace AgateLib.DisplayLib.Shaders -{ - 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 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); - - public void SetVariable(string name, Vector2 v) - { - SetVariable(name, v.X, v.Y); - } - public void SetVariable(string name, Vector3 v) - { - SetVariable(name, v.X, v.Y, v.Z); - } - public void SetVariable(string name, Vector4 v) - { - SetVariable(name, v.X, v.Y, v.Z, v.W); - } - public void SetVariable(string name, Color color) - { - SetVariable(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 enum EffectTexture - { - Texture0, - Texture1, - Texture2, - Texture3, - } - - public delegate void RenderHandler<T>(T obj); -} Copied: trunk/AgateLib/DisplayLib/Shaders/Effect.cs (from rev 1034, branches/agate3d-3.2/AgateLib/DisplayLib/Shaders/Effect.cs) =================================================================== --- trunk/AgateLib/DisplayLib/Shaders/Effect.cs (rev 0) +++ trunk/AgateLib/DisplayLib/Shaders/Effect.cs 2009-08-31 05:13:07 UTC (rev 1035) @@ -0,0 +1,57 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using AgateLib.Geometry; +using AgateLib.Geometry.VertexTypes; + +namespace AgateLib.DisplayLib.Shaders +{ + 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 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); + + public void SetVariable(string name, Vector2 v) + { + SetVariable(name, v.X, v.Y); + } + public void SetVariable(string name, Vector3 v) + { + SetVariable(name, v.X, v.Y, v.Z); + } + public void SetVariable(string name, Vector4 v) + { + SetVariable(name, v.X, v.Y, v.Z, v.W); + } + public void SetVariable(string name, Color color) + { + SetVariable(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 enum EffectTexture + { + Texture0, + Texture1, + Texture2, + Texture3, + } + + public delegate void RenderHandler<T>(T obj); +} Deleted: trunk/AgateLib/DisplayLib/Shaders/ShaderCompiler.cs =================================================================== --- branches/agate3d-3.2/AgateLib/DisplayLib/Shaders/ShaderCompiler.cs 2009-08-30 20:21:03 UTC (rev 1034) +++ trunk/AgateLib/DisplayLib/Shaders/ShaderCompiler.cs 2009-08-31 05:13:07 UTC (rev 1035) @@ -1,35 +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 Effect CompileEffect(ShaderLanguage language, string effectSource) - { - return impl.CompileEffect(language, effectSource); - } - } -} Copied: trunk/AgateLib/DisplayLib/Shaders/ShaderCompiler.cs (from rev 1034, branches/agate3d-3.2/AgateLib/DisplayLib/Shaders/ShaderCompiler.cs) =================================================================== --- trunk/AgateLib/DisplayLib/Shaders/ShaderCompiler.cs (rev 0) +++ trunk/AgateLib/DisplayLib/Shaders/ShaderCompiler.cs 2009-08-31 05:13:07 UTC (rev 1035) @@ -0,0 +1,35 @@ +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 Effect CompileEffect(ShaderLanguage language, string effectSource) + { + return impl.CompileEffect(language, effectSource); + } + } +} Deleted: trunk/AgateLib/DisplayLib/Shaders/ShaderLanguage.cs =================================================================== --- branches/agate3d-3.2/AgateLib/DisplayLib/Shaders/ShaderLanguage.cs 2009-08-30 20:21:03 UTC (rev 1034) +++ trunk/AgateLib/DisplayLib/Shaders/ShaderLanguage.cs 2009-08-31 05:13:07 UTC (rev 1035) @@ -1,17 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace AgateLib.DisplayLib.Shaders -{ - public enum ShaderLanguage - { - None, - - Glsl, - Hlsl, - // Cg, - - } -} Copied: trunk/AgateLib/DisplayLib/Shaders/ShaderLanguage.cs (from rev 1034, branches/agate3d-3.2/AgateLib/DisplayLib/Shaders/ShaderLanguage.cs) =================================================================== --- trunk/AgateLib/DisplayLib/Shaders/ShaderLanguage.cs (rev 0) +++ trunk/AgateLib/DisplayLib/Shaders/ShaderLanguage.cs 2009-08-31 05:13:07 UTC (rev 1035) @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace AgateLib.DisplayLib.Shaders +{ + public enum ShaderLanguage + { + None, + + Glsl, + Hlsl, + // Cg, + + } +} Deleted: trunk/AgateLib/DisplayLib/Shaders/ShaderProgram.cs =================================================================== --- branches/agate3d-3.2/AgateLib/DisplayLib/Shaders/ShaderProgram.cs 2009-08-30 20:21:03 UTC (rev 1034) +++ trunk/AgateLib/DisplayLib/Shaders/ShaderProgram.cs 2009-08-31 05:13:07 UTC (rev 1035) @@ -1,44 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using AgateLib.Geometry; -using AgateLib.Geometry.VertexTypes; - -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; } - - public abstract void Render(RenderHandler handler, object obj); - } - - public delegate void RenderHandler(object obj); - * */ -} Copied: trunk/AgateLib/DisplayLib/Shaders/ShaderProgram.cs (from rev 1034, branches/agate3d-3.2/AgateLib/DisplayLib/Shaders/ShaderProgram.cs) =================================================================== --- trunk/AgateLib/DisplayLib/Shaders/ShaderProgram.cs (rev 0) +++ trunk/AgateLib/DisplayLib/Shaders/ShaderProgram.cs 2009-08-31 05:13:07 UTC (rev 1035) @@ -0,0 +1,44 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using AgateLib.Geometry; +using AgateLib.Geometry.VertexTypes; + +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(str... [truncated message content] |
From: <ka...@us...> - 2009-08-30 20:21:17
|
Revision: 1034 http://agate.svn.sourceforge.net/agate/?rev=1034&view=rev Author: kanato Date: 2009-08-30 20:21:03 +0000 (Sun, 30 Aug 2009) Log Message: ----------- Removed unnecessary renderstates from lighting shader. Modified Paths: -------------- branches/agate3d-3.2/Tests/Data/shaders/hlsl/Lighting.fx Modified: branches/agate3d-3.2/Tests/Data/shaders/hlsl/Lighting.fx =================================================================== --- branches/agate3d-3.2/Tests/Data/shaders/hlsl/Lighting.fx 2009-08-30 18:37:59 UTC (rev 1033) +++ branches/agate3d-3.2/Tests/Data/shaders/hlsl/Lighting.fx 2009-08-30 20:21:03 UTC (rev 1034) @@ -70,8 +70,7 @@ pass Pass_0 { AlphaBlendEnable = TRUE; - SrcBlend = SrcAlpha; - DestBlend = InvSrcAlpha; + VertexShader = compile vs_2_0 vs_main(); PixelShader = compile ps_2_0 ps_main(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ka...@us...> - 2009-08-30 18:38:30
|
Revision: 1033 http://agate.svn.sourceforge.net/agate/?rev=1033&view=rev Author: kanato Date: 2009-08-30 18:37:59 +0000 (Sun, 30 Aug 2009) Log Message: ----------- Fix alpha blending in lighting test. Modified Paths: -------------- branches/agate3d-3.2/Tests/Data/shaders/hlsl/Lighting.fx Modified: branches/agate3d-3.2/Tests/Data/shaders/hlsl/Lighting.fx =================================================================== --- branches/agate3d-3.2/Tests/Data/shaders/hlsl/Lighting.fx 2009-08-30 01:08:57 UTC (rev 1032) +++ branches/agate3d-3.2/Tests/Data/shaders/hlsl/Lighting.fx 2009-08-30 18:37:59 UTC (rev 1033) @@ -54,13 +54,12 @@ float atten = 1.0f / (attenuation.x + attenuation.y * dist + attenuation.z * dist * dist); - float3 color = (lightColor * atten); + float3 attenLightColor = (lightColor * atten); + float4 baseColor = IN.color * tex2D(texSampler0, IN.tex); - color *= IN.color.rgb * tex2D(texSampler0, IN.tex); + OUT.color.rgb = attenLightColor * baseColor.rgb; + OUT.color.a = baseColor.a; - OUT.color = IN.color; - OUT.color.rgb = color.rgb; - return OUT; } @@ -71,7 +70,8 @@ pass Pass_0 { AlphaBlendEnable = TRUE; - + SrcBlend = SrcAlpha; + DestBlend = InvSrcAlpha; VertexShader = compile vs_2_0 vs_main(); PixelShader = compile ps_2_0 ps_main(); } 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:09:04
|
Revision: 1032 http://agate.svn.sourceforge.net/agate/?rev=1032&view=rev Author: kanato Date: 2009-08-30 01:08:57 +0000 (Sun, 30 Aug 2009) Log Message: ----------- Update MDX driver to new caps structure. Modified Paths: -------------- branches/agate3d-3.2/Drivers/AgateMDX/MDX1_Display.cs Modified: branches/agate3d-3.2/Drivers/AgateMDX/MDX1_Display.cs =================================================================== --- branches/agate3d-3.2/Drivers/AgateMDX/MDX1_Display.cs 2009-08-30 01:03:13 UTC (rev 1031) +++ branches/agate3d-3.2/Drivers/AgateMDX/MDX1_Display.cs 2009-08-30 01:08:57 UTC (rev 1032) @@ -35,7 +35,7 @@ namespace AgateMDX { - public class MDX1_Display : DisplayImpl, IDisplayCaps, AgateLib.PlatformSpecific.IPlatformServices + public class MDX1_Display : DisplayImpl, AgateLib.PlatformSpecific.IPlatformServices { #region --- Private Variables --- @@ -767,11 +767,6 @@ FormUtil.SavePixelBuffer(pixelBuffer, filename, format); } - public override IDisplayCaps Caps - { - get { return this; } - } - protected override void HideCursor() { System.Windows.Forms.Cursor.Hide(); @@ -783,175 +778,33 @@ #region --- IDisplayCaps Members --- - bool IDisplayCaps.SupportsScaling - { - get { return true; } - } - bool IDisplayCaps.SupportsRotation + public override bool Supports(DisplayBoolCaps caps) { - 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) { - Caps c = Direct3D.Manager.GetDeviceCaps(0, 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.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; } - } - #endregion - bool IDisplayCaps.CanCreateBitmapFont - { - get { return true; } - } - - #region --- 3D stuff --- - - Matrix4x4 projection = Matrix4x4.Identity; - Matrix4x4 world = Matrix4x4.Identity; - Matrix4x4 view = Matrix4x4.Identity; - - protected override VertexBufferImpl CreateVertexBuffer( - AgateLib.Geometry.VertexTypes.VertexLayout layout, int vertexCount) - { - 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(Matrix4x4 value) - { - Matrix retval = new Matrix(); - - retval.M11 = value[0, 0]; - retval.M12 = value[1, 0]; - retval.M13 = value[2, 0]; - retval.M14 = value[3, 0]; - - retval.M21 = value[0, 1]; - retval.M22 = value[1, 1]; - retval.M23 = value[2, 1]; - retval.M24 = value[3, 1]; - - retval.M31 = value[0, 2]; - retval.M32 = value[1, 2]; - retval.M33 = value[2, 2]; - retval.M34 = value[3, 2]; - - retval.M41 = value[0, 3]; - retval.M42 = value[1, 3]; - retval.M43 = value[2, 3]; - retval.M44 = value[3, 3]; - - return retval; - } - public override Matrix4x4 MatrixProjection - { - get - { - return projection; - } - set - { - //value = Matrix4x4.Projection(45, 800 / 600f, 1f, 1000f); - var x = Microsoft.DirectX.Matrix.PerspectiveFovRH( - (float)(45 * Math.PI / 180), 800 / 600f, 1f, 1000f); - - projection = value; - mDevice.Device.SetTransform(TransformType.Projection, - TransformAgateMatrix(value)); - } - } - - public override Matrix4x4 MatrixView - { - get - { - return view; - } - set - { - view = value; - - mDevice.Device.SetTransform(TransformType.View, - TransformAgateMatrix(value)); - } - } - public override Matrix4x4 MatrixWorld - { - get - { - return world; - } - set - { - world = value; - - mDevice.Device.SetTransform(TransformType.World, - TransformAgateMatrix(value)); - } - } - - Matrix GetTotalTransform() - { - return TransformAgateMatrix(MatrixProjection * MatrixView * MatrixWorld); - } - - #endregion - #region --- IPlatformServices Members --- protected override AgateLib.PlatformSpecific.IPlatformServices GetPlatformServices() 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. |
From: <ka...@us...> - 2009-08-29 16:59:20
|
Revision: 1030 http://agate.svn.sourceforge.net/agate/?rev=1030&view=rev Author: kanato Date: 2009-08-29 16:59:07 +0000 (Sat, 29 Aug 2009) Log Message: ----------- Connect checkbox to whether shader is used or not. Modified Paths: -------------- branches/agate3d-3.2/Tests/Data/shaders/hlsl/Lighting.fx branches/agate3d-3.2/Tests/Shaders/LightingTest/LightingTest.cs branches/agate3d-3.2/Tests/Shaders/LightingTest/LightingTestForm.Designer.cs Modified: branches/agate3d-3.2/Tests/Data/shaders/hlsl/Lighting.fx =================================================================== --- branches/agate3d-3.2/Tests/Data/shaders/hlsl/Lighting.fx 2009-08-29 04:35:14 UTC (rev 1029) +++ branches/agate3d-3.2/Tests/Data/shaders/hlsl/Lighting.fx 2009-08-29 16:59:07 UTC (rev 1030) @@ -54,7 +54,7 @@ float atten = 1.0f / (attenuation.x + attenuation.y * dist + attenuation.z * dist * dist); - float3 color = saturate(lightColor * atten); + float3 color = (lightColor * atten); color *= IN.color.rgb * tex2D(texSampler0, IN.tex); Modified: branches/agate3d-3.2/Tests/Shaders/LightingTest/LightingTest.cs =================================================================== --- branches/agate3d-3.2/Tests/Shaders/LightingTest/LightingTest.cs 2009-08-29 04:35:14 UTC (rev 1029) +++ branches/agate3d-3.2/Tests/Shaders/LightingTest/LightingTest.cs 2009-08-29 16:59:07 UTC (rev 1030) @@ -63,7 +63,7 @@ //lights[1].AttenuationConstant = 0.01f; //lights[1].AttenuationQuadratic = 5e-7f; - fx.SetVariable("attenuation", 0.01f, 0, 5e-4f); + fx.SetVariable("attenuation", 0.5f, 0, 5e-4f); fx.SetTexture(EffectTexture.Texture0, "texture0"); Mouse.MouseMove += delegate(InputEventArgs e) @@ -93,7 +93,12 @@ //lights.DoLighting(); fx.SetVariable("worldViewProj", Display.GetOrthoProjection()); - Display.Effect = fx; + if (frm.enableShader.Checked) + { + Display.Effect = fx; + } + else + Display.Effect = null; if (frm.chkSurfaceGradient.Checked) { Modified: branches/agate3d-3.2/Tests/Shaders/LightingTest/LightingTestForm.Designer.cs =================================================================== --- branches/agate3d-3.2/Tests/Shaders/LightingTest/LightingTestForm.Designer.cs 2009-08-29 04:35:14 UTC (rev 1029) +++ branches/agate3d-3.2/Tests/Shaders/LightingTest/LightingTestForm.Designer.cs 2009-08-29 16:59:07 UTC (rev 1030) @@ -29,6 +29,7 @@ private void InitializeComponent() { this.panel1 = new System.Windows.Forms.Panel(); + this.chkSurfaceGradient = new System.Windows.Forms.CheckBox(); this.nudAngle = new System.Windows.Forms.NumericUpDown(); this.label4 = new System.Windows.Forms.Label(); this.btnDiffuse = new System.Windows.Forms.Button(); @@ -36,22 +37,19 @@ this.label3 = new System.Windows.Forms.Label(); this.chkMoveLight = new System.Windows.Forms.CheckBox(); this.label2 = new System.Windows.Forms.Label(); - this.label1 = new System.Windows.Forms.Label(); - this.nudTess = new System.Windows.Forms.NumericUpDown(); - this.enableLightingCheck = new System.Windows.Forms.CheckBox(); + this.enableShader = new System.Windows.Forms.CheckBox(); this.lblFPS = new System.Windows.Forms.Label(); this.colorDialog1 = new System.Windows.Forms.ColorDialog(); this.agateRenderTarget1 = new AgateLib.WinForms.AgateRenderTarget(); - this.chkSurfaceGradient = new System.Windows.Forms.CheckBox(); this.panel1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.nudAngle)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.nudTess)).BeginInit(); this.SuspendLayout(); // // panel1 // this.panel1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Right))); + this.panel1.Controls.Add(this.enableShader); this.panel1.Controls.Add(this.chkSurfaceGradient); this.panel1.Controls.Add(this.nudAngle); this.panel1.Controls.Add(this.label4); @@ -60,14 +58,21 @@ this.panel1.Controls.Add(this.label3); this.panel1.Controls.Add(this.chkMoveLight); this.panel1.Controls.Add(this.label2); - this.panel1.Controls.Add(this.label1); - this.panel1.Controls.Add(this.nudTess); - this.panel1.Controls.Add(this.enableLightingCheck); this.panel1.Location = new System.Drawing.Point(385, 0); this.panel1.Name = "panel1"; this.panel1.Size = new System.Drawing.Size(126, 352); this.panel1.TabIndex = 0; // + // chkSurfaceGradient + // + this.chkSurfaceGradient.AutoSize = true; + this.chkSurfaceGradient.Location = new System.Drawing.Point(6, 220); + this.chkSurfaceGradient.Name = "chkSurfaceGradient"; + this.chkSurfaceGradient.Size = new System.Drawing.Size(106, 17); + this.chkSurfaceGradient.TabIndex = 4; + this.chkSurfaceGradient.Text = "Surface Gradient"; + this.chkSurfaceGradient.UseVisualStyleBackColor = true; + // // nudAngle // this.nudAngle.Increment = new decimal(new int[] { @@ -144,44 +149,18 @@ this.label2.TabIndex = 4; this.label2.Text = "Diffuse"; // - // label1 + // enableShader // - this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(3, 28); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(55, 13); - this.label1.TabIndex = 2; - this.label1.Text = "Tessellate"; + this.enableShader.AutoSize = true; + this.enableShader.Checked = true; + this.enableShader.CheckState = System.Windows.Forms.CheckState.Checked; + this.enableShader.Location = new System.Drawing.Point(3, 3); + this.enableShader.Name = "enableShader"; + this.enableShader.Size = new System.Drawing.Size(101, 17); + this.enableShader.TabIndex = 0; + this.enableShader.Text = "Enable Shading"; + this.enableShader.UseVisualStyleBackColor = true; // - // nudTess - // - this.nudTess.Location = new System.Drawing.Point(65, 26); - this.nudTess.Minimum = new decimal(new int[] { - 1, - 0, - 0, - 0}); - this.nudTess.Name = "nudTess"; - this.nudTess.Size = new System.Drawing.Size(37, 20); - this.nudTess.TabIndex = 1; - this.nudTess.Value = new decimal(new int[] { - 1, - 0, - 0, - 0}); - // - // enableLightingCheck - // - this.enableLightingCheck.AutoSize = true; - this.enableLightingCheck.Checked = true; - this.enableLightingCheck.CheckState = System.Windows.Forms.CheckState.Checked; - this.enableLightingCheck.Location = new System.Drawing.Point(3, 3); - this.enableLightingCheck.Name = "enableLightingCheck"; - this.enableLightingCheck.Size = new System.Drawing.Size(99, 17); - this.enableLightingCheck.TabIndex = 0; - this.enableLightingCheck.Text = "Enable Lighting"; - this.enableLightingCheck.UseVisualStyleBackColor = true; - // // lblFPS // this.lblFPS.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); @@ -201,16 +180,6 @@ this.agateRenderTarget1.Size = new System.Drawing.Size(379, 325); this.agateRenderTarget1.TabIndex = 0; // - // chkSurfaceGradient - // - this.chkSurfaceGradient.AutoSize = true; - this.chkSurfaceGradient.Location = new System.Drawing.Point(6, 220); - this.chkSurfaceGradient.Name = "chkSurfaceGradient"; - this.chkSurfaceGradient.Size = new System.Drawing.Size(106, 17); - this.chkSurfaceGradient.TabIndex = 4; - this.chkSurfaceGradient.Text = "Surface Gradient"; - this.chkSurfaceGradient.UseVisualStyleBackColor = true; - // // LightingTestForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -225,7 +194,6 @@ this.panel1.ResumeLayout(false); this.panel1.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.nudAngle)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.nudTess)).EndInit(); this.ResumeLayout(false); } @@ -233,10 +201,8 @@ #endregion private System.Windows.Forms.Panel panel1; - public System.Windows.Forms.CheckBox enableLightingCheck; + public System.Windows.Forms.CheckBox enableShader; public AgateLib.WinForms.AgateRenderTarget agateRenderTarget1; - private System.Windows.Forms.Label label1; - public System.Windows.Forms.NumericUpDown nudTess; public System.Windows.Forms.CheckBox chkMoveLight; public System.Windows.Forms.Label lblFPS; private System.Windows.Forms.Label label3; 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:35:28
|
Revision: 1029 http://agate.svn.sourceforge.net/agate/?rev=1029&view=rev Author: kanato Date: 2009-08-29 04:35:14 +0000 (Sat, 29 Aug 2009) Log Message: ----------- Reoganize shader tests. Added Paths: ----------- branches/agate3d-3.2/Tests/Data/shaders/hlsl/Lighting.fx branches/agate3d-3.2/Tests/Shaders/ branches/agate3d-3.2/Tests/Shaders/Hlsl.cs branches/agate3d-3.2/Tests/Shaders/LightingTest/ branches/agate3d-3.2/Tests/Shaders/LightingTest/LightingTest.cs branches/agate3d-3.2/Tests/Shaders/LightingTest/LightingTestForm.Designer.cs branches/agate3d-3.2/Tests/Shaders/LightingTest/LightingTestForm.cs branches/agate3d-3.2/Tests/Shaders/LightingTest/LightingTestForm.resx Removed Paths: ------------- branches/agate3d-3.2/Tests/Display3D/ branches/agate3d-3.2/Tests/DisplayTests/LightingTest/ Added: branches/agate3d-3.2/Tests/Data/shaders/hlsl/Lighting.fx =================================================================== --- branches/agate3d-3.2/Tests/Data/shaders/hlsl/Lighting.fx (rev 0) +++ branches/agate3d-3.2/Tests/Data/shaders/hlsl/Lighting.fx 2009-08-29 04:35:14 UTC (rev 1029) @@ -0,0 +1,78 @@ +float4x4 worldViewProj; +texture texture0; +float2 lightPos; +float3 attenuation; +float3 lightColor; + +sampler2D texSampler0 : TEXUNIT0 = sampler_state +{ + Texture = (texture0); + MIPFILTER = LINEAR; + MAGFILTER = LINEAR; + MINFILTER = LINEAR; +}; + +struct VS_INPUT +{ + float3 position : POSITION; + float2 tex : TEXCOORD0; + float4 color : COLOR0; +}; + +struct VS_OUTPUT +{ + float4 position : POSITION; + float4 color : COLOR0; + float2 tex : TEXCOORD0; + float2 distance : TEXCOORD1; +}; + +struct PS_OUTPUT +{ + float4 color : COLOR0; +}; + +VS_OUTPUT vs_main(VS_INPUT IN) +{ + VS_OUTPUT OUT; + + float4 vec = float4(IN.position, 1); + + OUT.position = mul(worldViewProj, vec); + OUT.color = IN.color; + OUT.tex = IN.tex; + OUT.distance = lightPos - IN.position; + + return OUT; +} + +PS_OUTPUT ps_main(VS_OUTPUT IN) +{ + PS_OUTPUT OUT; + + float dist = sqrt(IN.distance.x*IN.distance.x + IN.distance.y*IN.distance.y); + + float atten = 1.0f / (attenuation.x + attenuation.y * dist + attenuation.z * dist * dist); + + float3 color = saturate(lightColor * atten); + + color *= IN.color.rgb * tex2D(texSampler0, IN.tex); + + OUT.color = IN.color; + OUT.color.rgb = color.rgb; + + return OUT; +} + + + +technique Lighting +{ + pass Pass_0 + { + AlphaBlendEnable = TRUE; + + VertexShader = compile vs_2_0 vs_main(); + PixelShader = compile ps_2_0 ps_main(); + } +} \ No newline at end of file Added: branches/agate3d-3.2/Tests/Shaders/Hlsl.cs =================================================================== --- branches/agate3d-3.2/Tests/Shaders/Hlsl.cs (rev 0) +++ branches/agate3d-3.2/Tests/Shaders/Hlsl.cs 2009-08-29 04:35:14 UTC (rev 1029) @@ -0,0 +1,171 @@ +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 "Shaders"; } + } + + 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.PreferredDisplay = AgateLib.Drivers.DisplayTypeID.Direct3D9_SDX; + setup.Initialize(true, false, false); + if (setup.WasCanceled) + return; + + wind = DisplayWindow.CreateWindowed("HLSL", 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"); + + double time = 0; + double frequency = 2 * Math.PI / 5; + const float size = 25; + + var shader = ShaderCompiler.CompileEffect(ShaderLanguage.Hlsl, + File.ReadAllText("Data/shaders/hlsl/PerPixelLighting.fx")); + + //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); + + Matrix4x4 proj = Matrix4x4.Projection(45f, wind.Width / (float)wind.Height, 1.0f, 1000f); // projection + Matrix4x4 view = Matrix4x4.LookAt(eye, eye + lookDir, up); + + // world transformation + Matrix4x4 world = Matrix4x4.Translation(-size / 2, -size / 2, 0) * Matrix4x4.RotateZ((float)(frequency * time)); + Matrix4x4 composite = proj * view * world; + + shader.SetVariable("worldViewProj", composite); + + shader.Render(x => x.DrawIndexed(index), buffer); + + 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; + } + } + + } +} Added: branches/agate3d-3.2/Tests/Shaders/LightingTest/LightingTest.cs =================================================================== --- branches/agate3d-3.2/Tests/Shaders/LightingTest/LightingTest.cs (rev 0) +++ branches/agate3d-3.2/Tests/Shaders/LightingTest/LightingTest.cs 2009-08-29 04:35:14 UTC (rev 1029) @@ -0,0 +1,125 @@ +using System; +using System.Collections.Generic; +using System.Windows.Forms; + +using AgateLib; +using AgateLib.DisplayLib; +using AgateLib.DisplayLib.Shaders; +using AgateLib.InputLib; +using AgateLib.Geometry; + +namespace Tests.LightingTest +{ + class LightingTest : IAgateTest + { + #region IAgateTest Members + + public string Name { get { return "Lighting"; } } + public string Category { get { return "Shaders"; } } + + #endregion + + public void Main(string[] args) + { + using (AgateSetup setup = new AgateSetup(args)) + { + setup.AskUser = true; + setup.PreferredDisplay = AgateLib.Drivers.DisplayTypeID.Direct3D9_SDX; + setup.Initialize(true, false, false); + if (setup.WasCanceled) + return; + + if (Display.Caps.SupportsShaders == false) + { + MessageBox.Show("You must have a driver that supports shaders.", "Lighting Test"); + return; + } + LightingTestForm frm = new LightingTestForm(); + frm.Show(); + + DisplayWindow wnd = new DisplayWindow(CreateWindowParams.FromControl(frm.agateRenderTarget1)); + + Surface image = new Surface("jellybean.png"); + Surface ball = new Surface("ball.png"); + Point ballPt; + double time = 0; + + image.SetScale(2.0, 2.0); + ball.DisplayAlignment = OriginAlignment.Center; + + Effect fx = ShaderCompiler.CompileEffect(ShaderLanguage.Hlsl, + System.IO.File.ReadAllText("Data/shaders/hlsl/Lighting.fx")); + + //LightManager lights = new LightManager(); + //lights.Enabled = true; + //lights.AddPointLight(new Vector3(0, 0, -1), Color.White); + //lights.AddPointLight(new Vector3(0, 0, -1), Color.Yellow); + + fx.SetVariable("lightColor", Color.White); + + Display.RenderState.WaitForVerticalBlank = false; + + //lights[0].Ambient = Color.White; + //lights[1].AttenuationConstant = 0.01f; + //lights[1].AttenuationQuadratic = 5e-7f; + + fx.SetVariable("attenuation", 0.01f, 0, 5e-4f); + fx.SetTexture(EffectTexture.Texture0, "texture0"); + + Mouse.MouseMove += delegate(InputEventArgs e) + { + fx.SetVariable("lightPos", (float) e.MousePosition.X, e.MousePosition.Y); + }; + + while (frm.Visible == true) + { + if (frm.chkMoveLight.Checked) + time += Display.DeltaTime / 1000.0; + + + ballPt = new Point((int)(120 + 110 * Math.Cos(time)), + (int)(120 + 110 * Math.Sin(time))); + + //lights[0].Position = new Vector3(ballPt.X, ballPt.Y, -1); + //lights[0].Ambient = Color.FromArgb(frm.btnAmbient.BackColor.ToArgb()); + //lights[0].Diffuse = Color.FromArgb(frm.btnDiffuse.BackColor.ToArgb()); + + image.RotationAngleDegrees = (double)frm.nudAngle.Value; + + Display.BeginFrame(); + Display.Clear(Color.DarkRed); + + //lights.Enabled = frm.enableLightingCheck.Checked; + //lights.DoLighting(); + fx.SetVariable("worldViewProj", Display.GetOrthoProjection()); + + Display.Effect = fx; + + if (frm.chkSurfaceGradient.Checked) + { + Gradient g = new Gradient(Color.Red, Color.Blue, Color.Cyan, Color.Green); + + image.ColorGradient = g; + } + else + image.Color = Color.White; + + //image.TesselateFactor = (int)frm.nudTess.Value; + + image.Draw(50, 50); + + image.Draw(50 + image.DisplayWidth, 50); + image.Draw(50, 50 + image.DisplayHeight); + + ball.Draw(ballPt); + + Display.EndFrame(); + Core.KeepAlive(); + + frm.lblFPS.Text = "FPS: " + Display.FramesPerSecond.ToString("0.00"); + } + } + } + + } +} \ No newline at end of file Added: branches/agate3d-3.2/Tests/Shaders/LightingTest/LightingTestForm.Designer.cs =================================================================== --- branches/agate3d-3.2/Tests/Shaders/LightingTest/LightingTestForm.Designer.cs (rev 0) +++ branches/agate3d-3.2/Tests/Shaders/LightingTest/LightingTestForm.Designer.cs 2009-08-29 04:35:14 UTC (rev 1029) @@ -0,0 +1,252 @@ +namespace Tests.LightingTest +{ + partial class LightingTestForm + { + /// <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.panel1 = new System.Windows.Forms.Panel(); + this.nudAngle = new System.Windows.Forms.NumericUpDown(); + this.label4 = new System.Windows.Forms.Label(); + this.btnDiffuse = new System.Windows.Forms.Button(); + this.btnAmbient = new System.Windows.Forms.Button(); + this.label3 = new System.Windows.Forms.Label(); + this.chkMoveLight = new System.Windows.Forms.CheckBox(); + this.label2 = new System.Windows.Forms.Label(); + this.label1 = new System.Windows.Forms.Label(); + this.nudTess = new System.Windows.Forms.NumericUpDown(); + this.enableLightingCheck = new System.Windows.Forms.CheckBox(); + this.lblFPS = new System.Windows.Forms.Label(); + this.colorDialog1 = new System.Windows.Forms.ColorDialog(); + this.agateRenderTarget1 = new AgateLib.WinForms.AgateRenderTarget(); + this.chkSurfaceGradient = new System.Windows.Forms.CheckBox(); + this.panel1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.nudAngle)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.nudTess)).BeginInit(); + this.SuspendLayout(); + // + // panel1 + // + this.panel1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Right))); + this.panel1.Controls.Add(this.chkSurfaceGradient); + this.panel1.Controls.Add(this.nudAngle); + this.panel1.Controls.Add(this.label4); + this.panel1.Controls.Add(this.btnDiffuse); + this.panel1.Controls.Add(this.btnAmbient); + this.panel1.Controls.Add(this.label3); + this.panel1.Controls.Add(this.chkMoveLight); + this.panel1.Controls.Add(this.label2); + this.panel1.Controls.Add(this.label1); + this.panel1.Controls.Add(this.nudTess); + this.panel1.Controls.Add(this.enableLightingCheck); + this.panel1.Location = new System.Drawing.Point(385, 0); + this.panel1.Name = "panel1"; + this.panel1.Size = new System.Drawing.Size(126, 352); + this.panel1.TabIndex = 0; + // + // nudAngle + // + this.nudAngle.Increment = new decimal(new int[] { + 5, + 0, + 0, + 0}); + this.nudAngle.Location = new System.Drawing.Point(51, 183); + this.nudAngle.Maximum = new decimal(new int[] { + 360, + 0, + 0, + 0}); + this.nudAngle.Name = "nudAngle"; + this.nudAngle.Size = new System.Drawing.Size(51, 20); + this.nudAngle.TabIndex = 9; + // + // label4 + // + this.label4.AutoSize = true; + this.label4.Location = new System.Drawing.Point(3, 185); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(39, 13); + this.label4.TabIndex = 8; + this.label4.Text = "Rotate"; + // + // btnDiffuse + // + this.btnDiffuse.BackColor = System.Drawing.Color.White; + this.btnDiffuse.Location = new System.Drawing.Point(51, 114); + this.btnDiffuse.Name = "btnDiffuse"; + this.btnDiffuse.Size = new System.Drawing.Size(20, 23); + this.btnDiffuse.TabIndex = 7; + this.btnDiffuse.UseVisualStyleBackColor = false; + this.btnDiffuse.Click += new System.EventHandler(this.btnDiffuse_Click); + // + // btnAmbient + // + this.btnAmbient.BackColor = System.Drawing.Color.Green; + this.btnAmbient.Location = new System.Drawing.Point(51, 143); + this.btnAmbient.Name = "btnAmbient"; + this.btnAmbient.Size = new System.Drawing.Size(20, 23); + this.btnAmbient.TabIndex = 6; + this.btnAmbient.UseVisualStyleBackColor = false; + this.btnAmbient.Click += new System.EventHandler(this.btnAmbient_Click); + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Location = new System.Drawing.Point(3, 149); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(45, 13); + this.label3.TabIndex = 5; + this.label3.Text = "Ambient"; + // + // chkMoveLight + // + this.chkMoveLight.AutoSize = true; + this.chkMoveLight.Checked = true; + this.chkMoveLight.CheckState = System.Windows.Forms.CheckState.Checked; + this.chkMoveLight.Location = new System.Drawing.Point(3, 80); + this.chkMoveLight.Name = "chkMoveLight"; + this.chkMoveLight.Size = new System.Drawing.Size(79, 17); + this.chkMoveLight.TabIndex = 1; + this.chkMoveLight.Text = "Move Light"; + this.chkMoveLight.UseVisualStyleBackColor = true; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(3, 119); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(40, 13); + this.label2.TabIndex = 4; + this.label2.Text = "Diffuse"; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(3, 28); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(55, 13); + this.label1.TabIndex = 2; + this.label1.Text = "Tessellate"; + // + // nudTess + // + this.nudTess.Location = new System.Drawing.Point(65, 26); + this.nudTess.Minimum = new decimal(new int[] { + 1, + 0, + 0, + 0}); + this.nudTess.Name = "nudTess"; + this.nudTess.Size = new System.Drawing.Size(37, 20); + this.nudTess.TabIndex = 1; + this.nudTess.Value = new decimal(new int[] { + 1, + 0, + 0, + 0}); + // + // enableLightingCheck + // + this.enableLightingCheck.AutoSize = true; + this.enableLightingCheck.Checked = true; + this.enableLightingCheck.CheckState = System.Windows.Forms.CheckState.Checked; + this.enableLightingCheck.Location = new System.Drawing.Point(3, 3); + this.enableLightingCheck.Name = "enableLightingCheck"; + this.enableLightingCheck.Size = new System.Drawing.Size(99, 17); + this.enableLightingCheck.TabIndex = 0; + this.enableLightingCheck.Text = "Enable Lighting"; + this.enableLightingCheck.UseVisualStyleBackColor = true; + // + // lblFPS + // + this.lblFPS.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.lblFPS.Location = new System.Drawing.Point(12, 354); + this.lblFPS.Name = "lblFPS"; + this.lblFPS.Size = new System.Drawing.Size(162, 23); + this.lblFPS.TabIndex = 3; + this.lblFPS.Text = "FPS:"; + // + // agateRenderTarget1 + // + this.agateRenderTarget1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.agateRenderTarget1.Location = new System.Drawing.Point(0, 0); + this.agateRenderTarget1.Name = "agateRenderTarget1"; + this.agateRenderTarget1.Size = new System.Drawing.Size(379, 325); + this.agateRenderTarget1.TabIndex = 0; + // + // chkSurfaceGradient + // + this.chkSurfaceGradient.AutoSize = true; + this.chkSurfaceGradient.Location = new System.Drawing.Point(6, 220); + this.chkSurfaceGradient.Name = "chkSurfaceGradient"; + this.chkSurfaceGradient.Size = new System.Drawing.Size(106, 17); + this.chkSurfaceGradient.TabIndex = 4; + this.chkSurfaceGradient.Text = "Surface Gradient"; + this.chkSurfaceGradient.UseVisualStyleBackColor = true; + // + // LightingTestForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(514, 376); + this.Controls.Add(this.lblFPS); + this.Controls.Add(this.panel1); + this.Controls.Add(this.agateRenderTarget1); + this.Name = "LightingTestForm"; + this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Show; + this.Text = "Lighting Test"; + this.panel1.ResumeLayout(false); + this.panel1.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.nudAngle)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.nudTess)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.Panel panel1; + public System.Windows.Forms.CheckBox enableLightingCheck; + public AgateLib.WinForms.AgateRenderTarget agateRenderTarget1; + private System.Windows.Forms.Label label1; + public System.Windows.Forms.NumericUpDown nudTess; + public System.Windows.Forms.CheckBox chkMoveLight; + public System.Windows.Forms.Label lblFPS; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.ColorDialog colorDialog1; + public System.Windows.Forms.Button btnDiffuse; + public System.Windows.Forms.Button btnAmbient; + private System.Windows.Forms.Label label4; + public System.Windows.Forms.NumericUpDown nudAngle; + public System.Windows.Forms.CheckBox chkSurfaceGradient; + } +} + Added: branches/agate3d-3.2/Tests/Shaders/LightingTest/LightingTestForm.cs =================================================================== --- branches/agate3d-3.2/Tests/Shaders/LightingTest/LightingTestForm.cs (rev 0) +++ branches/agate3d-3.2/Tests/Shaders/LightingTest/LightingTestForm.cs 2009-08-29 04:35:14 UTC (rev 1029) @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Text; +using System.Windows.Forms; + +namespace Tests.LightingTest +{ + public partial class LightingTestForm : Form + { + public LightingTestForm() + { + InitializeComponent(); + + Icon = AgateLib.WinForms.FormUtil.AgateLibIcon; + } + + private void btnDiffuse_Click(object sender, EventArgs e) + { + colorDialog1.Color = btnDiffuse.BackColor; + + if (colorDialog1.ShowDialog() == DialogResult.OK) + btnDiffuse.BackColor = colorDialog1.Color; + } + + private void btnAmbient_Click(object sender, EventArgs e) + { + colorDialog1.Color = btnAmbient.BackColor; + + if (colorDialog1.ShowDialog() == DialogResult.OK) + btnAmbient.BackColor = colorDialog1.Color; + } + } +} \ No newline at end of file Added: branches/agate3d-3.2/Tests/Shaders/LightingTest/LightingTestForm.resx =================================================================== --- branches/agate3d-3.2/Tests/Shaders/LightingTest/LightingTestForm.resx (rev 0) +++ branches/agate3d-3.2/Tests/Shaders/LightingTest/LightingTestForm.resx 2009-08-29 04:35:14 UTC (rev 1029) @@ -0,0 +1,123 @@ +<?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> + <metadata name="colorDialog1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> + <value>17, 17</value> + </metadata> +</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-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-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 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 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 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 00:51:31
|
Revision: 1023 http://agate.svn.sourceforge.net/agate/?rev=1023&view=rev Author: kanato Date: 2009-08-29 00:51:23 +0000 (Sat, 29 Aug 2009) Log Message: ----------- Correct matrix transpose in HLSL implementation. Modified Paths: -------------- branches/agate3d-3.2/Drivers/AgateSDX/HlslEffect.cs branches/agate3d-3.2/Drivers/AgateSDX/SDX_Display.cs Modified: branches/agate3d-3.2/Drivers/AgateSDX/HlslEffect.cs =================================================================== --- branches/agate3d-3.2/Drivers/AgateSDX/HlslEffect.cs 2009-08-24 18:18:38 UTC (rev 1022) +++ branches/agate3d-3.2/Drivers/AgateSDX/HlslEffect.cs 2009-08-29 00:51:23 UTC (rev 1023) @@ -39,7 +39,7 @@ { var param = GetParameter(name); - mEffect.SetValue<SlimDX.Matrix>(param.Handle, mDisplay.TransformAgateMatrix(matrix)); + mEffect.SetValue(name, mDisplay.TransformAgateMatrix(matrix)); } public override void SetUniform(string name, params int[] v) Modified: branches/agate3d-3.2/Drivers/AgateSDX/SDX_Display.cs =================================================================== --- branches/agate3d-3.2/Drivers/AgateSDX/SDX_Display.cs 2009-08-24 18:18:38 UTC (rev 1022) +++ branches/agate3d-3.2/Drivers/AgateSDX/SDX_Display.cs 2009-08-29 00:51:23 UTC (rev 1023) @@ -355,14 +355,14 @@ var device = mDevice.Device; - device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, color.ToArgb(), 1.0f, 0); + //device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, color.ToArgb(), 1.0f, 0); - device.Clear(ClearFlags.Target, color.ToArgb(), 0, 0); - device.Clear(ClearFlags.ZBuffer, 0, 1.0f, 0); + //device.Clear(ClearFlags.Target, color.ToArgb(), 0, 0); + //device.Clear(ClearFlags.ZBuffer, 0, 1.0f, 0); - System.Drawing.Rectangle[] rect = new System.Drawing.Rectangle[1]; - rect[0] = new System.Drawing.Rectangle(0, 0, 800, 600); - device.Clear(ClearFlags.ZBuffer, color.ToArgb(), 1.0f, 0, rect); + //System.Drawing.Rectangle[] rect = new System.Drawing.Rectangle[1]; + //rect[0] = new System.Drawing.Rectangle(0, 0, 800, 600); + //device.Clear(ClearFlags.ZBuffer, color.ToArgb(), 1.0f, 0, rect); } public override void Clear(Color color, Rectangle rect) @@ -957,23 +957,23 @@ Matrix retval = new Matrix(); retval.M11 = value[0, 0]; - retval.M12 = value[1, 0]; - retval.M13 = value[2, 0]; - retval.M14 = value[3, 0]; + retval.M21 = value[1, 0]; + retval.M31 = value[2, 0]; + retval.M41 = value[3, 0]; - retval.M21 = value[0, 1]; + retval.M12 = value[0, 1]; retval.M22 = value[1, 1]; - retval.M23 = value[2, 1]; - retval.M24 = value[3, 1]; + retval.M32 = value[2, 1]; + retval.M42 = value[3, 1]; - retval.M31 = value[0, 2]; - retval.M32 = value[1, 2]; + retval.M13 = value[0, 2]; + retval.M23 = value[1, 2]; retval.M33 = value[2, 2]; - retval.M34 = value[3, 2]; + retval.M43 = value[3, 2]; - retval.M41 = value[0, 3]; - retval.M42 = value[1, 3]; - retval.M43 = value[2, 3]; + retval.M14 = value[0, 3]; + retval.M24 = value[1, 3]; + retval.M34 = value[2, 3]; retval.M44 = value[3, 3]; return retval; 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:18:45
|
Revision: 1022 http://agate.svn.sourceforge.net/agate/?rev=1022&view=rev Author: kanato Date: 2009-08-24 18:18:38 +0000 (Mon, 24 Aug 2009) Log Message: ----------- Use HLSL effect file. Modified Paths: -------------- branches/agate3d-3.2/Tests/Data/shaders/hlsl/PerPixelLighting.fx Modified: branches/agate3d-3.2/Tests/Data/shaders/hlsl/PerPixelLighting.fx =================================================================== (Binary files differ) 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 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 = SlimDX.Direct3D9; - -namespace AgateSDX -{ - 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 - { } -} Modified: branches/agate3d-3.2/Drivers/AgateSDX/SDX_Display.cs =================================================================== --- branches/agate3d-3.2/Drivers/AgateSDX/SDX_Display.cs 2009-08-24 18:05:34 UTC (rev 1020) +++ branches/agate3d-3.2/Drivers/AgateSDX/SDX_Display.cs 2009-08-24 18:06:22 UTC (rev 1021) @@ -952,7 +952,7 @@ return new SDX_IndexBuffer(this, type, size); } - private Matrix TransformAgateMatrix(Matrix4 value) + internal Matrix TransformAgateMatrix(Matrix4 value) { Matrix retval = new Matrix(); @@ -1030,26 +1030,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 --- Added: branches/agate3d-3.2/Drivers/AgateSDX/SDX_Effect.cs =================================================================== --- branches/agate3d-3.2/Drivers/AgateSDX/SDX_Effect.cs (rev 0) +++ branches/agate3d-3.2/Drivers/AgateSDX/SDX_Effect.cs 2009-08-24 18:06:22 UTC (rev 1021) @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace AgateSDX +{ + class SDX_Effect + { + } +} Modified: branches/agate3d-3.2/Drivers/AgateSDX/SDX_Surface.cs =================================================================== --- branches/agate3d-3.2/Drivers/AgateSDX/SDX_Surface.cs 2009-08-24 18:05:34 UTC (rev 1020) +++ branches/agate3d-3.2/Drivers/AgateSDX/SDX_Surface.cs 2009-08-24 18:06:22 UTC (rev 1021) @@ -451,7 +451,7 @@ #region --- Surface saving --- - public override void SaveTo(string frameFile, ImageFileFormat format) + public override void SaveTo(string filename, ImageFileFormat format) { Direct3D.Surface surf = mTexture.Value.GetSurfaceLevel(0); Direct3D.ImageFileFormat d3dformat = SlimDX.Direct3D9.ImageFileFormat.Png; @@ -464,7 +464,31 @@ case ImageFileFormat.Tga: d3dformat = Direct3D.ImageFileFormat.Tga; break; } - throw new NotImplementedException(); + DataRectangle rect = surf.LockRectangle(LockFlags.ReadOnly); + + System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(surf.Description.Width, surf.Description.Height); + var target = bmp.LockBits(new System.Drawing.Rectangle(0, 0, bmp.Width, bmp.Height), + System.Drawing.Imaging.ImageLockMode.WriteOnly, + System.Drawing.Imaging.PixelFormat.Format32bppArgb); + + byte[] buffer = new byte[rect.Data.Length]; + rect.Data.Read(buffer, 0, (int)rect.Data.Length); + + Marshal.Copy(buffer, 0, target.Scan0, buffer.Length); + + bmp.UnlockBits(target); + surf.UnlockRectangle(); + + System.Drawing.Imaging.ImageFormat bmpFormat = System.Drawing.Imaging.ImageFormat.Png; + + switch (format) + { + case ImageFileFormat.Bmp: bmpFormat = System.Drawing.Imaging.ImageFormat.Bmp; break; + case ImageFileFormat.Jpg: bmpFormat = System.Drawing.Imaging.ImageFormat.Jpeg; break; + } + + bmp.Save(filename, bmpFormat); + //SurfaceLoader.Save(frameFile, d3dformat, surf, Interop.Convert(mSrcRect)); } Added: branches/agate3d-3.2/Tests/Data/shaders/hlsl/PerPixelLighting.fx =================================================================== (Binary files differ) Property changes on: branches/agate3d-3.2/Tests/Data/shaders/hlsl/PerPixelLighting.fx ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Deleted: branches/agate3d-3.2/Tests/Data/shaders/hlsl/PerPixelLighting_pixel.txt =================================================================== (Binary files differ) Deleted: branches/agate3d-3.2/Tests/Data/shaders/hlsl/PerPixelLighting_vertex.txt =================================================================== --- branches/agate3d-3.2/Tests/Data/shaders/hlsl/PerPixelLighting_vertex.txt 2009-08-24 18:05:34 UTC (rev 1020) +++ branches/agate3d-3.2/Tests/Data/shaders/hlsl/PerPixelLighting_vertex.txt 2009-08-24 18:06:22 UTC (rev 1021) @@ -1,31 +0,0 @@ -float4x4 worldViewProj; - -struct VS_INPUT -{ - float3 position : POSITION; - float2 texcoord0 : TEXCOORD0; - float3 normal : NORMAL; - float3 tangent : TANGENT; - float3 bitangent : BINORMAL; -}; - -struct VS_OUTPUT -{ - float4 hposition : POSITION; - 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.texcoord0 = IN.texcoord0; - - return OUT; -} Deleted: branches/agate3d-3.2/Tests/Display3D/Glsl.cs =================================================================== --- branches/agate3d-3.2/Tests/Display3D/Glsl.cs 2009-08-24 18:05:34 UTC (rev 1020) +++ branches/agate3d-3.2/Tests/Display3D/Glsl.cs 2009-08-24 18:06:22 UTC (rev 1021) @@ -1,187 +0,0 @@ -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 Glsl: IAgateTest - { - #region IAgateTest Members - - public string Name - { - get { return "Glsl (OpenGL 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.PreferredDisplay = AgateLib.Drivers.DisplayTypeID.OpenGL; - 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; - } - } - - } -} Modified: branches/agate3d-3.2/Tests/Display3D/Hlsl.cs =================================================================== --- branches/agate3d-3.2/Tests/Display3D/Hlsl.cs 2009-08-24 18:05:34 UTC (rev 1020) +++ branches/agate3d-3.2/Tests/Display3D/Hlsl.cs 2009-08-24 18:06:22 UTC (rev 1021) @@ -59,7 +59,7 @@ { using (AgateSetup setup = new AgateSetup(args)) { - setup.PreferredDisplay = AgateLib.Drivers.DisplayTypeID.Direct3D_MDX_1_1; + setup.PreferredDisplay = AgateLib.Drivers.DisplayTypeID.Direct3D9_SDX; setup.Initialize(true, false, false); if (setup.WasCanceled) return; @@ -86,9 +86,8 @@ double frequency = 2 * Math.PI / 5; const float size = 25; - var shader = ShaderCompiler.CompileShader(ShaderLanguage.Glsl, - File.ReadAllText("Data/shaders/hlsl/PerPixelLighting_vertex.txt"), - File.ReadAllText("Data/shaders/hlsl/PerPixelLighting_pixel.txt")); + var shader = ShaderCompiler.CompileEffect(ShaderLanguage.Hlsl, + File.ReadAllText("Data/shaders/hlsl/PerPixelLighting.fx")); //HeightMapTerrain b = new HeightMapTerrain(height.ReadPixels()); //b.Width = size; @@ -106,7 +105,6 @@ PixelBuffer.NormalMapFromHeightMap(height.ReadPixels(), 2.0f)); buffer.Textures[1].SaveTo("normal.png"); - resetmouse(); Mouse.Hide(); @@ -150,22 +148,18 @@ Display.BeginFrame(); Display.Clear(Color.Gray); - Display.Shader = shader; + Matrix4 proj = Matrix4.Projection(45f, wind.Width / (float)wind.Height, 1.0f, 1000f); // projection - 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)); + // world transformation + proj *= Matrix4.Translation(-size / 2, -size / 2, 0) * Matrix4.RotateZ((float)(frequency * time)); - buffer.DrawIndexed(index); + shader.SetUniform("worldViewProj", proj); + shader.Render(x => x.DrawIndexed(index), buffer); + Debug.Print("x, y, z = {0}", eye.ToString()); Debug.Print("angle = {0}", phi * 180 / Math.PI); Deleted: branches/agate3d-3.2/Tests/Display3D/Matrices.cs =================================================================== --- branches/agate3d-3.2/Tests/Display3D/Matrices.cs 2009-08-24 18:05:34 UTC (rev 1020) +++ branches/agate3d-3.2/Tests/Display3D/Matrices.cs 2009-08-24 18:06:22 UTC (rev 1021) @@ -1,207 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Linq; -using AgateLib; -using AgateLib.DisplayLib; -using AgateLib.Geometry; -using AgateLib.Geometry.Builders; -using AgateLib.InputLib; - -namespace Tests.Display3D.TestMatrices -{ - public class Matrices : IAgateTest - { - #region IAgateTest Members - - public string Name - { - 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; - - 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.AskUser = true; - setup.Initialize(true, false, false); - if (setup.WasCanceled == true) - return; - DisplayWindow wind = DisplayWindow.CreateWindowed( - "Test3D", 800, 600); - - Keyboard.KeyDown += new InputEventHandler(Keyboard_KeyDown); - Keyboard.KeyUp += new InputEventHandler(Keyboard_KeyUp); - Surface surf = new Surface("bg-bricks.png"); - - CubeBuilder cube = new CubeBuilder(); - cube.Length = 8; - cube.Location = new Vector3(cube.Length / 2 + 6, cube.Length / 2 + 6, 0); - cube.CreateVertexBuffer(); - - IndexBuffer indices = cube.IndexBuffer; - VertexBuffer b = cube.VertexBuffer; - b.Textures[0] = surf; - - int lastMyMatrix = matrixIndex - 1; - Matrix4 myproj = new Matrix4(); - Matrix4 myview = new Matrix4(); - - LightManager m = new LightManager(); - m.Enabled = true; - m.AddPointLight(new Vector3(3, 3, -0.5), Color.Gray); - - m[0].AttenuationConstant = 0.002f; - m[0].AttenuationLinear = 0.00f; - m[0].AttenuationQuadratic = 0.002f; - - Vector3 position = new Vector3(-5, 0, 10); - double facingAngle = Math.PI / 4; - float speed = 0.03f; - float turnSpeed = 0.004f; - - Surface s = new Surface("ball.png"); - - while (wind.IsClosed == false) - { - //System.Threading.Thread.Sleep(1000); - - Vector3 lookDirection = CalculateLookDirection(facingAngle); - - if (move != 0) - { - position += move * speed * lookDirection * (float)Display.DeltaTime; - } - if (turn != 0) - { - facingAngle -= turn * turnSpeed * (float)Display.DeltaTime; - } - - Vector3 lookTarget = position + lookDirection* 20; - lookTarget.Z = 0; - - Display.BeginFrame(); - Display.Clear(Color.Gray); - - Rectangle ortho = new Rectangle(-9, -9, 20, 20); - - switch (matrixIndex) - { - case 0: - myproj = Matrix4.Ortho((RectangleF)ortho, -1, 1); - myview = Matrix4.Identity; - - Display.MatrixProjection = myproj; - Display.MatrixView = myview; - Display.MatrixWorld = Matrix4.Identity; - - break; - - case 1: - myproj = Matrix4.Projection(45, wind.Width / (float)wind.Height, 1f, 100f); - myview = Matrix4.LookAt(position, lookTarget, - new Vector3(0, 0, 1)); - - Display.MatrixProjection = myproj; - Display.MatrixView = myview; - Display.MatrixWorld = Matrix4.Identity; - - break; - } - - if (lastMyMatrix != matrixIndex) - { - Debug.Write("=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-="); - Debug.Print("Matrix Index: {0}", matrixIndex); - - //DisplayMatrices(GetPName.ProjectionMatrix, myproj, false); - //DisplayMatrices(GetPName.ModelviewMatrix, myview, false); - } - - lastMyMatrix = matrixIndex; - - Display.MatrixWorld = Matrix4.Translation(0, 0, 0); - - m[0].Position = position; - //m.DoLighting(); - - // draw a weird checkerboard - for (int x = 0; x < 8; x += 2) - { - for (int y = 0; y < 8; y++) - { - int sx = (y % 2 == 0) ? 1 : 0; - Color clr = (y / 4 == 0) ? Color.Red : Color.Blue; - - Display.FillRect(new Rectangle((x + sx), y, 1, 1), clr); - } - } - Display.DrawRect(new Rectangle(0, 0, 8, 8), Color.Black); - - b.DrawIndexed(indices); - - Display.EndFrame(); - Core.KeepAlive(); - } - } - } - - private static Vector3 CalculateLookDirection(double facingAngle) - { - return new Vector3(Math.Cos(facingAngle), Math.Sin(facingAngle), 0); - } - - private static 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) - { - if (e.KeyCode == KeyCode.Up || e.KeyCode == KeyCode.Down) - move = 0; - if (e.KeyCode == KeyCode.Left || e.KeyCode == KeyCode.Right) - turn = 0; - } - - static void Keyboard_KeyDown(AgateLib.InputLib.InputEventArgs e) - { - if (e.KeyCode == AgateLib.InputLib.KeyCode.Space) - matrixIndex++; - - if (matrixIndex > 1) - matrixIndex = 0; - - if (e.KeyCode == KeyCode.Up) - move = 1; - if (e.KeyCode == KeyCode.Down) - move = -1; - if (e.KeyCode == KeyCode.Left) - turn = -1; - if (e.KeyCode == KeyCode.Right) - turn = 1; - } - } -} Deleted: branches/agate3d-3.2/Tests/Display3D/Test3d.cs =================================================================== --- branches/agate3d-3.2/Tests/Display3D/Test3d.cs 2009-08-24 18:05:34 UTC (rev 1020) +++ branches/agate3d-3.2/Tests/Display3D/Test3d.cs 2009-08-24 18:06:22 UTC (rev 1021) @@ -1,211 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Linq; -using System.Text; -using AgateLib; -using AgateLib.Geometry; -using AgateLib.Geometry.Builders; -using AgateLib.DisplayLib; -using AgateLib.InputLib; - -namespace Tests.Display3D.Test3D -{ - class Test3d //: IAgateTest - { - #region IAgateTest Members - - public string Name - { - get { return "Test 3D"; } - } - - public string Category - { - get { return "Display 3D"; } - } - - public void 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); - - return; - - // 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()) - { - setup.AskUser = true; - setup.Initialize(true, false, false); - if (setup.WasCanceled) - return; - - DisplayWindow wind = DisplayWindow.CreateWindowed( - "Test3D", 800, 600); - - Keyboard.KeyDown += new InputEventHandler(Keyboard_KeyDown); - Keyboard.KeyUp += new InputEventHandler(Keyboard_KeyUp); - Surface surf = new Surface("bg-bricks.png"); - - CubeBuilder cube = new CubeBuilder(); - cube.Length = 4; - cube.CreateVertexBuffer(); - - VertexBuffer b = cube.VertexBuffer; - b.Textures[0] = surf; - - int lastMyMatrix = matrixIndex - 1; - Matrix4 myproj = new Matrix4(); - Matrix4 myview = new Matrix4(); - - LightManager m = new LightManager(); - m.Enabled = true; - m.AddPointLight(new Vector3(3, 3, -0.5), Color.Gray); - - m[0].AttenuationConstant = 0.002f; - m[0].AttenuationLinear = 0.00f; - m[0].AttenuationQuadratic = 0.002f; - - Vector3 position = new Vector3(-5, 0, 2); - float facingAngle = 0; - float speed = 0.03f; - float turnSpeed = 0.004f; - - while (wind.IsClosed == false) - { - Vector3 lookDirection = CalculateLookDirection(facingAngle); - - if (move != 0) - { - position += move * speed * lookDirection * (float)Display.DeltaTime; - } - if (turn != 0) - { - facingAngle -= turn * turnSpeed * (float)Display.DeltaTime; - } - - Vector3 lookTarget = position + lookDirection; - - Display.BeginFrame(); - Display.Clear(Color.Gray); - - Rectangle ortho = new Rectangle(-9, -9, 20, 20); - - switch (matrixIndex) - { - case 0: - myproj = Matrix4.Ortho((RectangleF)ortho, -1, 1); - myview = Matrix4.Identity; - - Display.MatrixProjection = myproj; - Display.MatrixView = myview; - Display.MatrixWorld = Matrix4.Identity; - - break; - - case 1: - myproj = Matrix4.Projection(45, wind.Width / (float)wind.Height, 1f, 100); - myview = Matrix4.LookAt(position, lookTarget, - new Vector3(0, 0, 1)); - - Display.MatrixProjection = myproj; - Display.MatrixView = myview; - Display.MatrixWorld = Matrix4.Identity; - - break; - } - - if (lastMyMatrix != matrixIndex) - { - Debug.Write("=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-="); - Debug.Print("Matrix Index: {0}", matrixIndex); - - //DisplayMatrices(GetPName.ProjectionMatrix, myproj, false); - //DisplayMatrices(GetPName.ModelviewMatrix, myview, false); - } - - lastMyMatrix = matrixIndex; - - Display.MatrixWorld = Matrix4.Translation(0.5, 0.5, 0.5); - - m[0].Position = position; - m.DoLighting(); - - // draw a weird checkerboard - for (int x = 0; x < 8; x += 2) - { - for (int y = 0; y < 8; y++) - { - int sx = (y % 2 == 0) ? 1 : 0; - Color clr = (y / 4 == 0) ? Color.Red : Color.Blue; - - Display.FillRect(new Rectangle(x + sx, y, 1, 1), clr); - } - } - Display.DrawRect(new Rectangle(0, 0, 8, 8), Color.Black); - - - b.Draw(); - - Display.EndFrame(); - Core.KeepAlive(); - - - } - } - } - - private Vector3 CalculateLookDirection(float facingAngle) - { - return new Vector3(Math.Cos(facingAngle), Math.Sin(facingAngle), 0); - } - - private Vector3 CalculateLookTarget(Vector3 position, float facingAngle) - { - Vector3 lookTarget = position; - lookTarget += new Vector3(Math.Cos(facingAngle), Math.Sin(facingAngle), 0); - return lookTarget; - } - - void Keyboard_KeyUp(InputEventArgs e) - { - if (e.KeyCode == KeyCode.Up || e.KeyCode == KeyCode.Down) - move = 0; - if (e.KeyCode == KeyCode.Left || e.KeyCode == KeyCode.Right) - turn = 0; - } - - void Keyboard_KeyDown(AgateLib.InputLib.InputEventArgs e) - { - if (e.KeyCode == AgateLib.InputLib.KeyCode.Space) - matrixIndex++; - - if (matrixIndex > 1) - matrixIndex = 0; - - if (e.KeyCode == KeyCode.Up) - move = 1; - if (e.KeyCode == KeyCode.Down) - move = -1; - if (e.KeyCode == KeyCode.Left) - turn = -1; - if (e.KeyCode == KeyCode.Right) - turn = 1; - } - } -} 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:05:41
|
Revision: 1020 http://agate.svn.sourceforge.net/agate/?rev=1020&view=rev Author: kanato Date: 2009-08-24 18:05:34 +0000 (Mon, 24 Aug 2009) Log Message: ----------- Add AgateDriverInfo.ToString method. Modified Paths: -------------- branches/agate3d-3.2/AgateLib/Drivers/AgateDriverInfo.cs Modified: branches/agate3d-3.2/AgateLib/Drivers/AgateDriverInfo.cs =================================================================== --- branches/agate3d-3.2/AgateLib/Drivers/AgateDriverInfo.cs 2009-08-24 04:55:30 UTC (rev 1019) +++ branches/agate3d-3.2/AgateLib/Drivers/AgateDriverInfo.cs 2009-08-24 18:05:34 UTC (rev 1020) @@ -178,6 +178,10 @@ internal set { mAssemblyFile = value; } } + public override string ToString() + { + return "AgateDriverInfo: " + AssemblyFile; + } } /// <summary> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ka...@us...> - 2009-08-24 04:55:37
|
Revision: 1019 http://agate.svn.sourceforge.net/agate/?rev=1019&view=rev Author: kanato Date: 2009-08-24 04:55:30 +0000 (Mon, 24 Aug 2009) Log Message: ----------- Fix textbox positioning on mouse click. Modified Paths: -------------- branches/gui-3.2/AgateLib/Gui/ThemeEngines/Mercury/Mercury.cs Modified: branches/gui-3.2/AgateLib/Gui/ThemeEngines/Mercury/Mercury.cs =================================================================== --- branches/gui-3.2/AgateLib/Gui/ThemeEngines/Mercury/Mercury.cs 2009-08-24 04:46:07 UTC (rev 1018) +++ branches/gui-3.2/AgateLib/Gui/ThemeEngines/Mercury/Mercury.cs 2009-08-24 04:55:30 UTC (rev 1019) @@ -294,6 +294,9 @@ { if (textBox.Text[index] == '\n') { + if (index < textBox.Text.Length - 1) + index++; + line--; linestart = index; } @@ -310,12 +313,18 @@ { sz = Scheme.WidgetFont.MeasureString(textBox.Text, linestart, index - linestart); + if (textBox.Text[index] == '\n') + { + break; + } + if (sz.Width > clientLocation.X) { goto found; } last = sz.Width; + } found: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ka...@us...> - 2009-08-24 04:46:15
|
Revision: 1018 http://agate.svn.sourceforge.net/agate/?rev=1018&view=rev Author: kanato Date: 2009-08-24 04:46:07 +0000 (Mon, 24 Aug 2009) Log Message: ----------- Delete unimplemented scroll bar classes. Modified Paths: -------------- branches/gui-3.2/AgateLib/Gui/AgateGuiException.cs branches/gui-3.2/AgateLib/Gui/ListBox.cs branches/gui-3.2/AgateLib/Gui/ThemeEngines/Mercury/Mercury.cs branches/gui-3.2/AgateLib/Gui/ThemeEngines/Mercury/MercuryScheme.cs branches/gui-3.2/AgateLib/InternalResources/agate-black-gui.zip Removed Paths: ------------- branches/gui-3.2/AgateLib/Gui/HScrollBar.cs branches/gui-3.2/AgateLib/Gui/VScrollBar.cs Modified: branches/gui-3.2/AgateLib/Gui/AgateGuiException.cs =================================================================== --- branches/gui-3.2/AgateLib/Gui/AgateGuiException.cs 2009-08-24 04:27:39 UTC (rev 1017) +++ branches/gui-3.2/AgateLib/Gui/AgateGuiException.cs 2009-08-24 04:46:07 UTC (rev 1018) @@ -6,23 +6,23 @@ namespace AgateLib.Gui { - [global::System.Serializable] - public class AgateGuiException : AgateException - { - // - // 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 - // + [global::System.Serializable] + public class AgateGuiException : AgateException + { + // + // 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 AgateGuiException() { } - public AgateGuiException(string message) : base(message) { } - public AgateGuiException(string message, Exception inner) : base(message, inner) { } - protected AgateGuiException( - System.Runtime.Serialization.SerializationInfo info, - System.Runtime.Serialization.StreamingContext context) - : base(info, context) { } - } + public AgateGuiException() { } + public AgateGuiException(string message) : base(message) { } + public AgateGuiException(string message, Exception inner) : base(message, inner) { } + protected AgateGuiException( + System.Runtime.Serialization.SerializationInfo info, + System.Runtime.Serialization.StreamingContext context) + : base(info, context) { } + } } Deleted: branches/gui-3.2/AgateLib/Gui/HScrollBar.cs =================================================================== --- branches/gui-3.2/AgateLib/Gui/HScrollBar.cs 2009-08-24 04:27:39 UTC (rev 1017) +++ branches/gui-3.2/AgateLib/Gui/HScrollBar.cs 2009-08-24 04:46:07 UTC (rev 1018) @@ -1,11 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace AgateLib.Gui -{ - public class HScrollBar : Widget - { - } -} Modified: branches/gui-3.2/AgateLib/Gui/ListBox.cs =================================================================== --- branches/gui-3.2/AgateLib/Gui/ListBox.cs 2009-08-24 04:27:39 UTC (rev 1017) +++ branches/gui-3.2/AgateLib/Gui/ListBox.cs 2009-08-24 04:46:07 UTC (rev 1018) @@ -5,7 +5,50 @@ namespace AgateLib.Gui { - public class ListBox : Widget + class ListBox : Widget { + List<object> mItems = new List<object>(); + ListBoxItemText mItemTextGetter; + + public ListBox() + { + mItemTextGetter = ItemToString; + } + + string ItemToString(object item) + { + return item.ToString(); + } + + public List<object> Items + { + get { return mItems; } + set + { + if (value == null) + throw new ArgumentNullException("Cannot set the ListBox's item collection to null."); + + mItems = value; + } + } + public ListBoxItemText ItemTextGetter + { + get { return mItemTextGetter; } + set + { + if (value == null) + mItemTextGetter = ItemToString; + else + mItemTextGetter = value; + } + } + + public string GetItemText(int index) + { + return mItemTextGetter(Items[index]); + } + } + + public delegate string ListBoxItemText(object item); } Modified: branches/gui-3.2/AgateLib/Gui/ThemeEngines/Mercury/Mercury.cs =================================================================== --- branches/gui-3.2/AgateLib/Gui/ThemeEngines/Mercury/Mercury.cs 2009-08-24 04:27:39 UTC (rev 1017) +++ branches/gui-3.2/AgateLib/Gui/ThemeEngines/Mercury/Mercury.cs 2009-08-24 04:46:07 UTC (rev 1018) @@ -61,6 +61,7 @@ if (widget is CheckBox) DrawCheckbox((CheckBox)widget); if (widget is RadioButton) DrawRadioButton((RadioButton)widget); if (widget is TextBox) DrawTextBox((TextBox)widget); + if (widget is ListBox) DrawListBox((ListBox)widget); } public Size RequestClientAreaSize(Container widget, Size clientSize) @@ -114,13 +115,27 @@ if (widget is TextBox) MouseUpInTextBox((TextBox)widget, clientLocation); } + #endregion + #region --- ListBox --- + private void DrawListBox(ListBox listBox) + { + Surface image = Scheme.ListBox.Image; + + if (listBox.Enabled == false) + image = Scheme.ListBox.Disabled; + + Point location = listBox.PointToScreen(new Point(0, 0)); + Size size = listBox.Size; + + DrawStretchImage(location, size, + image, Scheme.TextBox.StretchRegion); + } + #endregion - #region --- TextBox --- - private void MouseDownInTextBox(TextBox textBox, Point clientLocation) { textBox.MoveInsertionPoint( Modified: branches/gui-3.2/AgateLib/Gui/ThemeEngines/Mercury/MercuryScheme.cs =================================================================== --- branches/gui-3.2/AgateLib/Gui/ThemeEngines/Mercury/MercuryScheme.cs 2009-08-24 04:27:39 UTC (rev 1017) +++ branches/gui-3.2/AgateLib/Gui/ThemeEngines/Mercury/MercuryScheme.cs 2009-08-24 04:46:07 UTC (rev 1018) @@ -63,8 +63,22 @@ SetTextBoxImages(new Surface(files, "textbox.png"), new Size(64, 16)); TextBox.StretchRegion = new Rectangle(3, 3, 58, 10); + + SetListBoxImages(new Surface(files, "textbox.png"), new Size(64, 16)); + ListBox.StretchRegion = new Rectangle(3, 3, 58, 10); } + private void SetListBoxImages(Surface surface, Size boxSize) + { + Surface[] surfs = SplitSurface("Listbox", surface, boxSize, 4, 4); + + ListBox.Image = surfs[0]; + ListBox.Disabled = surfs[1]; + ListBox.Hover = surfs[2]; + ListBox.Focus = surfs[3]; + + surface.Dispose(); + } private void SetTextBoxImages(Surface surface, Size boxSize) { Surface[] surfs = SplitSurface("textbox", surface, boxSize, 4, 4); Deleted: branches/gui-3.2/AgateLib/Gui/VScrollBar.cs =================================================================== --- branches/gui-3.2/AgateLib/Gui/VScrollBar.cs 2009-08-24 04:27:39 UTC (rev 1017) +++ branches/gui-3.2/AgateLib/Gui/VScrollBar.cs 2009-08-24 04:46:07 UTC (rev 1018) @@ -1,11 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace AgateLib.Gui -{ - public class VScrollBar : Widget - { - } -} Modified: branches/gui-3.2/AgateLib/InternalResources/agate-black-gui.zip =================================================================== (Binary files differ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ka...@us...> - 2009-08-24 04:27:48
|
Revision: 1017 http://agate.svn.sourceforge.net/agate/?rev=1017&view=rev Author: kanato Date: 2009-08-24 04:27:39 +0000 (Mon, 24 Aug 2009) Log Message: ----------- Add test for winforms converters. Added Paths: ----------- trunk/Tests/WinFormsTests/ trunk/Tests/WinFormsTests/Converters.cs Added: trunk/Tests/WinFormsTests/Converters.cs =================================================================== --- trunk/Tests/WinFormsTests/Converters.cs (rev 0) +++ trunk/Tests/WinFormsTests/Converters.cs 2009-08-24 04:27:39 UTC (rev 1017) @@ -0,0 +1,38 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using AgateLib; +using AgateLib.DisplayLib; +using AgateLib.Geometry; +using AgateLib.WinForms; + +namespace Tests.WinFormsTests +{ + class Converters : AgateApplication, IAgateTest + { + public string Name + { + get { return "Conversion Tests"; } + } + + public string Category + { + get { return "WinForms"; } + } + + public void Main(string[] args) + { + Run(args); + } + + protected override void Initialize() + { + Surface surf = new Surface("attacke.png"); + + System.Drawing.Bitmap bmp = surf.ToBitmap(); + + bmp.Save("test.bmp", System.Drawing.Imaging.ImageFormat.Bmp); + } + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ka...@us...> - 2009-08-24 04:26:46
|
Revision: 1016 http://agate.svn.sourceforge.net/agate/?rev=1016&view=rev Author: kanato Date: 2009-08-24 04:26:38 +0000 (Mon, 24 Aug 2009) Log Message: ----------- Queue up deletion of surfaces when they are run on the finalizer thread. Modified Paths: -------------- trunk/Drivers/AgateOTK/GL_Display.cs trunk/Drivers/AgateOTK/GL_Surface.cs Modified: trunk/Drivers/AgateOTK/GL_Display.cs =================================================================== --- trunk/Drivers/AgateOTK/GL_Display.cs 2009-08-19 14:38:45 UTC (rev 1015) +++ trunk/Drivers/AgateOTK/GL_Display.cs 2009-08-24 04:26:38 UTC (rev 1016) @@ -142,8 +142,11 @@ mState.DrawBuffer.Flush(); mRenderTarget.EndRender(); + + FlushDeleteQueue(); } + internal GLState State { get { return mState; } @@ -610,5 +613,31 @@ #endregion #endregion + + #region --- Deletion queuing --- + + List<int> mTexturesToDelete = new List<int>(); + + + private void FlushDeleteQueue() + { + lock (mTexturesToDelete) + { + int[] tex = mTexturesToDelete.ToArray(); + mTexturesToDelete.Clear(); + + GL.DeleteTextures(mTexturesToDelete.Count, tex); + } + } + + internal void QueueDeleteTexture(int p) + { + lock (mTexturesToDelete) + { + mTexturesToDelete.Add(p); + } + } + + #endregion } } \ No newline at end of file Modified: trunk/Drivers/AgateOTK/GL_Surface.cs =================================================================== --- trunk/Drivers/AgateOTK/GL_Surface.cs 2009-08-19 14:38:45 UTC (rev 1015) +++ trunk/Drivers/AgateOTK/GL_Surface.cs 2009-08-24 04:26:38 UTC (rev 1016) @@ -157,7 +157,12 @@ int[] array = new int[1]; array[0] = mTextureID; - GL.DeleteTextures(1, array); + if (OpenTK.Graphics.GraphicsContext.CurrentContext == null) + { + mDisplay.QueueDeleteTexture(array[0]); + } + else + GL.DeleteTextures(1, array); mTextureIDs.Remove(mTextureID); } @@ -167,7 +172,6 @@ public override void Dispose() { ReleaseTextureRef(); - } public override void Draw(SurfaceState state) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ac...@us...> - 2009-08-19 14:38:52
|
Revision: 1015 http://agate.svn.sourceforge.net/agate/?rev=1015&view=rev Author: accagon Date: 2009-08-19 14:38:45 +0000 (Wed, 19 Aug 2009) Log Message: ----------- * ParticleTests.cs: Tests for SpriteParticles. Modified Paths: -------------- branches/particles/Tests/DisplayTests/ParticleTests/ParticleTests.cs Modified: branches/particles/Tests/DisplayTests/ParticleTests/ParticleTests.cs =================================================================== --- branches/particles/Tests/DisplayTests/ParticleTests/ParticleTests.cs 2009-08-19 14:36:08 UTC (rev 1014) +++ branches/particles/Tests/DisplayTests/ParticleTests/ParticleTests.cs 2009-08-19 14:38:45 UTC (rev 1015) @@ -7,6 +7,7 @@ using AgateLib.DisplayLib; using AgateLib.Geometry; using AgateLib.Particles; +using AgateLib.Sprites; namespace Tests.ParticleTest { @@ -43,8 +44,11 @@ GravityManipulator gm2; //SurfaceParticle - SurfaceEmitter sm; + SurfaceEmitter sm; + //SpriteParticle + SpriteEmitter se; + FontSurface fontSurface; protected override void Initialize() @@ -52,32 +56,49 @@ //PixelParticle pe = new PixelEmitter(new Vector2(400f, 550f) ,Color.Blue, 5000); pe.EmitLife = 4f; - pe.EmitFrequenzy = 0.002f; + pe.EmitFrequency = 0.001f; pe.PixelSize = new Size(3, 3); //SurfaceParticle sm = new SurfaceEmitter(new Vector2(150f, 550f), 4.2f, 50, 0); Surface surf = new Surface(@"smoke2.png"); sm.AddSurface(surf); - sm.EmitFrequenzy = 0.1f; + sm.EmitFrequency = 0.1f; sm.EmitAlpha = 1d; sm.EmitAcceleration = new Vector2(0, -20); sm.EmitVelocity = new Vector2(0, -10); + //SpriteParticle + Surface surf2 = new Surface(@"smoke.png"); + Sprite sprite = new Sprite(100, 100); + sprite.AddFrame(surf); + sprite.AddFrame(surf2); + sprite.TimePerFrame = 0.5d; + sprite.AnimationType = SpriteAnimType.Looping; + se = new SpriteEmitter(new Vector2(600f, 550f), 4.2f, 100, 0); + se.AddSprite(sprite); + se.EmitFrequency = 0.05f; + se.EmitAlpha = 1d; + se.EmitAcceleration = new Vector2(0, -20); + se.EmitVelocity = new Vector2(0, -10); + //Manipulators gm = new GravityManipulator(new Vector2(0f, -50f)); gm.SubscribeToEmitter(pe); gm.SubscribeToEmitter(sm); + gm.SubscribeToEmitter(se); gm2 = new GravityManipulator(Vector2.Empty); gm2.SubscribeToEmitter(pe); gm2.SubscribeToEmitter(sm); + gm2.SubscribeToEmitter(se); FadeOutManipulator fom = new FadeOutManipulator(3f, 0.8f); fom.SubscribeToEmitter(pe); FadeOutManipulator fom2 = new FadeOutManipulator(4f, 0.4f); fom2.SubscribeToEmitter(sm); + fom2.SubscribeToEmitter(se); fontSurface = new FontSurface("Arial", 10f, FontStyle.Bold); } @@ -87,6 +108,7 @@ gm2.Gravity = new Vector2((float)ran.Next(-300, 300), 0f); pe.Update(time_ms); sm.Update(time_ms); + se.Update(time_ms); } protected override void Render() @@ -100,6 +122,9 @@ sm.Draw(); fontSurface.DrawText(sm.Position.X, sm.Position.Y, "Particles: " + sm.Particles.Count + "/" + sm.Particles.Capacity); + + se.Draw(); + fontSurface.DrawText(se.Position.X, se.Position.Y, "Particles: " + se.Particles.Count + "/" + se.Particles.Capacity); } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ac...@us...> - 2009-08-19 14:36:17
|
Revision: 1014 http://agate.svn.sourceforge.net/agate/?rev=1014&view=rev Author: accagon Date: 2009-08-19 14:36:08 +0000 (Wed, 19 Aug 2009) Log Message: ----------- * Sprite.cs: Simpler variant of AddFrame. Modified Paths: -------------- branches/particles/AgateLib/Sprites/Sprite.cs Modified: branches/particles/AgateLib/Sprites/Sprite.cs =================================================================== --- branches/particles/AgateLib/Sprites/Sprite.cs 2009-08-18 17:50:38 UTC (rev 1013) +++ branches/particles/AgateLib/Sprites/Sprite.cs 2009-08-19 14:36:08 UTC (rev 1014) @@ -241,8 +241,16 @@ } } + public void AddFrame(Surface surface) + { + SpriteFrame frame = new SpriteFrame(surface); + frame.SourceRect = new Rectangle(0, 0, surface.SurfaceWidth, surface.SurfaceHeight); + frame.Offset = Point.Empty; + frame.SpriteSize = SpriteSize; + + mFrames.Add(frame); + } - /// <summary> /// Adds a frame to the sprite. /// </summary> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ac...@us...> - 2009-08-18 17:50:56
|
Revision: 1013 http://agate.svn.sourceforge.net/agate/?rev=1013&view=rev Author: accagon Date: 2009-08-18 17:50:38 +0000 (Tue, 18 Aug 2009) Log Message: ----------- Initial commit of Particles/SpriteParticle.cs, Emitters/SpriteEmitter.cs adds basic Sprite support. Added Paths: ----------- branches/particles/AgateLib/Particles/Emitters/SpriteEmitter.cs branches/particles/AgateLib/Particles/Particles/SpriteParticle.cs Added: branches/particles/AgateLib/Particles/Emitters/SpriteEmitter.cs =================================================================== --- branches/particles/AgateLib/Particles/Emitters/SpriteEmitter.cs (rev 0) +++ branches/particles/AgateLib/Particles/Emitters/SpriteEmitter.cs 2009-08-18 17:50:38 UTC (rev 1013) @@ -0,0 +1,215 @@ +// 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.Particles. +// +// The Initial Developer of the Original Code is Marcel Hauf +// Portions created by Marcel Hauf are Copyright (C) 2009. +// All Rights Reserved. +// +// Contributor(s): Marcel Hauf. +// +using System; +using System.Linq; +using System.Collections.Generic; + +using AgateLib.DisplayLib; +using AgateLib.Geometry; +using AgateLib.Sprites; + +namespace AgateLib.Particles +{ + /// <summary> + /// Emitter class optimized for simulating sprite particles. + /// </summary> + public class SpriteEmitter : ParticleEmitter + { + private List<Sprite> mSprites = new List<Sprite>(); + + private int mEmitSpriteKey; + private double mEmitAlpha = 1d; + + private float time; + + /// <value> + /// Gets or sets the alpha channel of emitting <see cref="SpriteParticle"/>s. + /// </value> + public double EmitAlpha + { + get { return mEmitAlpha; } + set { mEmitAlpha = value; } + } + + /// <value> + /// Gets or sets the SpriteKey of emitting <see cref="SpriteParticle"/>s. + /// </value> + public int EmitSpriteKey + { + get { return mEmitSpriteKey; } + set { mEmitSpriteKey = value; } + } + + /// <summary> + /// Constructs a SpriteEmitter with default values: + /// EmitLife = 1f, maxParticle = 1000, emitSpriteKey = 0 + /// </summary> + /// <param name="position"></param> + public SpriteEmitter(Vector2 position) : this(position, 1f, 1000, 0) {} + + /// <summary> + /// Constructs a SpriteEmitter with default values: + /// maxParticle = 1000, emitSpriteKey = 0 + /// </summary> + /// <param name="position"></param> + /// <param name="emitLife"></param> + public SpriteEmitter(Vector2 position, float emitLife) : this(position, emitLife, 1000, 0) {} + + /// <summary> + /// Constructs a SpriteEmitter with default values: + /// emitSpriteKey = 0 + /// </summary> + /// <param name="position"></param> + /// <param name="emitLife"></param> + /// <param name="maxParticle"></param> + public SpriteEmitter(Vector2 position, float emitLife, int maxParticle) : this(position, emitLife, maxParticle, 0) {} + + /// <summary> + /// Constructs a SpriteEmitter. + /// </summary> + /// <param name="position"></param> + /// <param name="emitLife"></param> + /// <param name="maxParticle"></param> + /// <param name="emitSpriteKey"></param> + public SpriteEmitter(Vector2 position, float emitLife, int maxParticle, int emitSpriteKey) + { + base.Position = position; + base.EmitLife = emitLife; + base.Particles = new List<Particle>(maxParticle); + mEmitSpriteKey = emitSpriteKey; + } + + /// <summary> + /// Gets a stored <see cref="Sprite"/> by key. + /// </summary> + /// <param name="key"></param> + /// <returns></returns> + public Sprite GetSpriteByKey(int key) + { + return mSprites[key]; + } + + /// <summary> + /// Adds a <see cref="Sprite"/> to the storage. + /// </summary> + /// <param name="sprite"></param> + /// <returns>Returns the key related to the stored <see cref="Sprite"/>.</returns> + public int AddSprite(Sprite sprite) + { + int index = mSprites.Count; + mSprites.Insert(index, sprite); + return index; + } + + /// <summary>s + /// Overridden Draw method. + /// Draws each living particle. + /// </summary> + public override void Draw () + { + if(base.Particles.Count <= 0) + return; + + foreach(Sprite s in mSprites) + { + s.AdvanceFrame(); + } + + foreach(SpriteParticle sp in base.Particles) + { + if(sp.Condition == Condition.Alive || sp.Condition == Condition.Frozen) + { + mSprites[sp.SpriteKey].Alpha = sp.Alpha; + mSprites[sp.SpriteKey].Draw(sp.Position); + } + } + } + + /// <summary> + /// Overridden Update mehtod. + /// Emits particles based on the frequency property. + /// Updates the emitter position. + /// Calls particle manipulators to manipulate particles. + /// Updates the animation of each <see cref="Sprite"/>. + /// </summary> + /// <param name="time_ms">Time in milliseconds.</param> + public override void Update (double time_ms) + { + time += (float)time_ms; + float frequency = EmitFrequency*1000; + + while(time >= frequency) + { + //int index = Particles.IndexOf(Particles.FirstOrDefault(pt => pt.IsAlive == false)); + int index = -1; + for (int i = 0; i < Particles.Count; i++) + { + if (Particles[i].IsAlive == false) + { + index = i; + break; + } + } + + if(index > -1) + { + // Recycle a dead particle + Particles[index].Acceleration = EmitAcceleration; + (Particles[index] as SpriteParticle).SpriteKey = mEmitSpriteKey; + (Particles[index] as SpriteParticle).Alpha = mEmitAlpha; + Particles[index].Condition = Condition.Alive; + Particles[index].Life = EmitLife; + Particles[index].Position = Position; + Particles[index].Velocity = EmitVelocity; + NewRecyledParticle(Particles[index]); + } + else if(Particles.Count < Particles.Capacity) + { + // Add a new particle + SpriteParticle sp = new SpriteParticle(); + sp.Acceleration = EmitAcceleration; + sp.SpriteKey = mEmitSpriteKey; + sp.Alpha = mEmitAlpha; + sp.Condition = Condition.Alive; + sp.Life = EmitLife; + sp.Position = Position; + sp.Velocity = EmitVelocity; + NewParticle(sp); + Particles.Add(sp); + } + else + { + // No capacity left and no dead particles to recycle + time = 0; + break; + } + time -= frequency; + } + + // Update animation + foreach(Sprite sp in mSprites) + { + sp.Update(time_ms); + } + + // updates own position, particle positions and calls manipulators + base.Update (time_ms); + } + } +} Added: branches/particles/AgateLib/Particles/Particles/SpriteParticle.cs =================================================================== --- branches/particles/AgateLib/Particles/Particles/SpriteParticle.cs (rev 0) +++ branches/particles/AgateLib/Particles/Particles/SpriteParticle.cs 2009-08-18 17:50:38 UTC (rev 1013) @@ -0,0 +1,61 @@ +// 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.Particles. +// +// The Initial Developer of the Original Code is Marcel Hauf +// Portions created by Marcel Hauf are Copyright (C) 2009. +// All Rights Reserved. +// +// Contributor(s): Marcel Hauf. +// +using System; + +namespace AgateLib.Particles +{ + public class SpriteParticle : Particle + { + private int mSpriteKey; + + private double mAlpha = 1d; + + /// <value> + /// Gets or sets the sprite key. + /// </value> + public int SpriteKey + { + get { return mSpriteKey; } + set { mSpriteKey = value; } + } + + /// <value> + /// Gets or sets the alpha of the surface. + /// </value> + public double Alpha + { + get { return mAlpha; } + set { mAlpha = value; } + } + + /// <summary> + /// Constructs a SpriteParticle with the default value 0 for the spriteKey. + /// </summary> + public SpriteParticle() : this(0) {} + + /// <summary> + /// Constructs a SpriteParticle. + /// </summary> + /// <param name="spriteKey"></param> + public SpriteParticle(int spriteKey) + { + mSpriteKey = spriteKey; + } + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |