agate-svn-commit Mailing List for AgateLib (Page 10)
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...> - 2011-11-29 02:46:15
|
Revision: 1312 http://agate.svn.sourceforge.net/agate/?rev=1312&view=rev Author: kanato Date: 2011-11-29 02:46:09 +0000 (Tue, 29 Nov 2011) Log Message: ----------- Fix GL_Surface to use draw buffer of current render target. Modified Paths: -------------- trunk/Drivers/AgateOTK/GL_Surface.cs Modified: trunk/Drivers/AgateOTK/GL_Surface.cs =================================================================== --- trunk/Drivers/AgateOTK/GL_Surface.cs 2011-11-29 02:45:24 UTC (rev 1311) +++ trunk/Drivers/AgateOTK/GL_Surface.cs 2011-11-29 02:46:09 UTC (rev 1312) @@ -123,7 +123,6 @@ private GL_Surface(int textureID, Rectangle sourceRect, Size textureSize) { mDisplay = Display.Impl as GL_Display; - mDrawBuffer = mDisplay.DrawBuffer; AddTextureRef(textureID); @@ -208,6 +207,7 @@ mTexCoord = GetTextureCoords(srcRect); + mDrawBuffer = mDisplay.DrawBuffer; mDrawBuffer.SetInterpolationMode(InterpolationHint); BufferQuad(destX, destY, rotationCenter.X, rotationCenter.Y, @@ -221,7 +221,7 @@ float displayWidth, float displayHeight, TextureCoordinates texCoord, Gradient color, OriginAlignment DisplayAlignment, float mRotationCos, float mRotationSin) { - + // order is // 1 -- 2 // | | This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ka...@us...> - 2011-11-29 02:45:30
|
Revision: 1311 http://agate.svn.sourceforge.net/agate/?rev=1311&view=rev Author: kanato Date: 2011-11-29 02:45:24 +0000 (Tue, 29 Nov 2011) Log Message: ----------- Propagate Stop event to SoundBufferSessions. Modified Paths: -------------- trunk/AgateLib/AudioLib/SoundBuffer.cs Modified: trunk/AgateLib/AudioLib/SoundBuffer.cs =================================================================== --- trunk/AgateLib/AudioLib/SoundBuffer.cs 2011-11-29 02:44:19 UTC (rev 1310) +++ trunk/AgateLib/AudioLib/SoundBuffer.cs 2011-11-29 02:45:24 UTC (rev 1311) @@ -187,6 +187,11 @@ { if (StopEvent != null) StopEvent(); + + foreach (SoundBufferSession session in mSessions) + { + session.Stop(); + } } /// <summary> /// Event which occurs when Stop is called on the SoundBuffer object. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ka...@us...> - 2011-11-29 02:44:25
|
Revision: 1310 http://agate.svn.sourceforge.net/agate/?rev=1310&view=rev Author: kanato Date: 2011-11-29 02:44:19 +0000 (Tue, 29 Nov 2011) Log Message: ----------- Fix bug in Drawing driver where no more rendering would occur of render target was resized. Modified Paths: -------------- trunk/Drivers/AgateDrawing/Drawing_DisplayWindow.cs trunk/Drivers/AgateDrawing/Drawing_FrameBuffer.cs Modified: trunk/Drivers/AgateDrawing/Drawing_DisplayWindow.cs =================================================================== --- trunk/Drivers/AgateDrawing/Drawing_DisplayWindow.cs 2011-11-24 05:54:58 UTC (rev 1309) +++ trunk/Drivers/AgateDrawing/Drawing_DisplayWindow.cs 2011-11-29 02:44:19 UTC (rev 1310) @@ -117,6 +117,7 @@ form.KeyDown += new System.Windows.Forms.KeyEventHandler(form_KeyDown); form.KeyUp += new System.Windows.Forms.KeyEventHandler(form_KeyUp); + // TODO: This can probably be removed as of 11/2011. // fuck, it seems that FormClosing had a different name in .NET 1.1, which is // the version of windows that Mono implements. // So here's an ugly System.Reflection hack around it. @@ -242,7 +243,13 @@ if (mRenderTarget.ClientSize.Width == 0 || mRenderTarget.ClientSize.Height == 0) return; + if (mBackBuffer != null) + mBackBuffer.Dispose(); + mBackBuffer = new Bitmap(mRenderTarget.ClientSize.Width, mRenderTarget.ClientSize.Height); + + if (mFrameBuffer != null) + mFrameBuffer.BackBufferBitmap = mBackBuffer; } public Control RenderTarget Modified: trunk/Drivers/AgateDrawing/Drawing_FrameBuffer.cs =================================================================== --- trunk/Drivers/AgateDrawing/Drawing_FrameBuffer.cs 2011-11-24 05:54:58 UTC (rev 1309) +++ trunk/Drivers/AgateDrawing/Drawing_FrameBuffer.cs 2011-11-29 02:44:19 UTC (rev 1310) @@ -61,6 +61,7 @@ public System.Drawing.Bitmap BackBufferBitmap { get { return backBuffer; } + set { backBuffer = value; } } public override void BeginRender() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ka...@us...> - 2011-11-24 05:55:04
|
Revision: 1309 http://agate.svn.sourceforge.net/agate/?rev=1309&view=rev Author: kanato Date: 2011-11-24 05:54:58 +0000 (Thu, 24 Nov 2011) Log Message: ----------- Fix ownSurface being ignored when creating a sprite from a surface. Modified Paths: -------------- trunk/AgateLib/Sprites/Sprite.cs Modified: trunk/AgateLib/Sprites/Sprite.cs =================================================================== --- trunk/AgateLib/Sprites/Sprite.cs 2011-11-23 04:33:21 UTC (rev 1308) +++ trunk/AgateLib/Sprites/Sprite.cs 2011-11-24 05:54:58 UTC (rev 1309) @@ -132,7 +132,7 @@ public Sprite(Surface surface, bool ownSurface, Size size) : this(size) { - AddNewFrames(surface, true, Point.Empty, Point.Empty, size, true); + AddNewFrames(surface, ownSurface, Point.Empty, Point.Empty, size, true); } /// <summary> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ka...@us...> - 2011-11-23 04:33:29
|
Revision: 1308 http://agate.svn.sourceforge.net/agate/?rev=1308&view=rev Author: kanato Date: 2011-11-23 04:33:21 +0000 (Wed, 23 Nov 2011) Log Message: ----------- Another attempt at GL3 primitives. Not working. Modified Paths: -------------- trunk/AgateLib/DisplayLib/ImplementationBase/DisplayImpl.cs trunk/AgateLib/Geometry/RectangleF.cs trunk/Drivers/AgateOTK/GL3/GLPrimitiveRenderer.cs trunk/Drivers/AgateOTK/GL_Display.cs trunk/Tests/DisplayTests/BasicDrawing/BasicDrawing.cs trunk/Tests/frmLauncher.cs trunk/Tests/settings_list.txt Modified: trunk/AgateLib/DisplayLib/ImplementationBase/DisplayImpl.cs =================================================================== --- trunk/AgateLib/DisplayLib/ImplementationBase/DisplayImpl.cs 2011-11-22 21:12:54 UTC (rev 1307) +++ trunk/AgateLib/DisplayLib/ImplementationBase/DisplayImpl.cs 2011-11-23 04:33:21 UTC (rev 1308) @@ -505,7 +505,7 @@ /// <param name="color"></param> public virtual void DrawLines(Point[] pt, int startIndex, int length, Color color) { - for (int i = startIndex; i < startIndex + pt.Length - 1; i++) + for (int i = startIndex; i < startIndex + length - 1; i++) DrawLine(pt[i], pt[i + 1], color); } /// <summary> Modified: trunk/AgateLib/Geometry/RectangleF.cs =================================================================== --- trunk/AgateLib/Geometry/RectangleF.cs 2011-11-22 21:12:54 UTC (rev 1307) +++ trunk/AgateLib/Geometry/RectangleF.cs 2011-11-23 04:33:21 UTC (rev 1308) @@ -234,6 +234,16 @@ return !a.Equals(b); } + /// <summary> + /// Conversion to Rectangle structure. + /// </summary> + /// <param name="r"></param> + /// <returns></returns> + public static explicit operator Rectangle(RectangleF r) + { + return new Rectangle((int)r.X, (int)r.Y, (int)r.Width, (int)r.Height); + } + #endregion #region --- Object Overrides --- Modified: trunk/Drivers/AgateOTK/GL3/GLPrimitiveRenderer.cs =================================================================== --- trunk/Drivers/AgateOTK/GL3/GLPrimitiveRenderer.cs 2011-11-22 21:12:54 UTC (rev 1307) +++ trunk/Drivers/AgateOTK/GL3/GLPrimitiveRenderer.cs 2011-11-23 04:33:21 UTC (rev 1308) @@ -36,49 +36,28 @@ /// </summary> class GLPrimitiveRenderer : PrimitiveRenderer { - PositionColor[] mVerts = new PositionColor[6]; + PositionTextureColor[] mVerts = new PositionTextureColor[12]; int mBufferID; int mVaoID; + GL_Display mDisplay; + public GLPrimitiveRenderer() { + mDisplay = (GL_Display)Display.Impl; + GL.GenBuffers(1, out mBufferID); GL.GenVertexArrays(1, out mVaoID); Debug.Print("GL3 PrimitiveRenderer: Draw buffer ID: {0}", mBufferID); } - public void SetGLColor(Color color) + GL_Surface WhiteSurface { - GL.Color4(color.R / 255.0f, color.G / 255.0f, color.B / 255.0f, color.A / 255.0f); + get { return (GL_Surface) mDisplay.WhiteSurface.Impl; } } - public override void DrawLine(Point a, Point b, Color color) - { - mVerts[0].Position.X = a.X; - mVerts[0].Position.Y = a.Y; - mVerts[0].Color = color.ToArgb(); - - mVerts[1].Position.X = b.X; - mVerts[1].Position.Y = b.Y; - mVerts[1].Color = color.ToArgb(); - - BufferData(); - - GL_Display display = (GL_Display)Display.Impl; - Shaders.IGL3Shader shader = (Shaders.IGL3Shader)display.Shader.Impl; - - shader.SetVertexAttributes(PositionColor.VertexLayout); - - GL.ActiveTexture(TextureUnit.Texture0); - GL.BindTexture(TextureTarget.Texture2D, 0); - shader.SetTexture(0); - - GL.DrawArrays(BeginMode.Lines, 0, 1); - - } - private void BufferData() { GL.BindVertexArray(mVaoID); @@ -97,8 +76,8 @@ IntPtr ptr = handle.AddrOfPinnedObject(); - GL.BufferData(BufferTarget.ArrayBuffer, - (IntPtr)bufferSize, ptr, + GL.BufferData(BufferTarget.ArrayBuffer, + (IntPtr)bufferSize, ptr, BufferUsageHint.StaticDraw); } finally @@ -108,78 +87,122 @@ } } - public override void DrawRect(RectangleF rect, Color color) + public override void DrawLine(Point a, Point b, Color color) { - SetGLColor(color); + mVerts[0].Position.X = a.X; + mVerts[0].Position.Y = a.Y; + mVerts[0].TexCoord.X = 0; + mVerts[0].TexCoord.Y = 0; + mVerts[0].Color = color.ToArgb(); - GL.Disable(EnableCap.Texture2D); - GL.Begin(BeginMode.Lines); + mVerts[1].Position.X = b.X; + mVerts[1].Position.Y = b.Y; + mVerts[1].TexCoord.X = 1; + mVerts[1].TexCoord.Y = 1; + mVerts[1].Color = color.ToArgb(); - GL.Vertex2(rect.Left, rect.Top); - GL.Vertex2(rect.Right, rect.Top); + BufferData(); - GL.Vertex2(rect.Right, rect.Top); - GL.Vertex2(rect.Right, rect.Bottom); + Shaders.IGL3Shader shader = (Shaders.IGL3Shader)mDisplay.Shader.Impl; - GL.Vertex2(rect.Left, rect.Bottom); - GL.Vertex2(rect.Right, rect.Bottom); + shader.SetVertexAttributes(PositionColor.VertexLayout); - GL.Vertex2(rect.Left, rect.Top); - GL.Vertex2(rect.Left, rect.Bottom); + GL.ActiveTexture(TextureUnit.Texture0); + GL.BindTexture(TextureTarget.Texture2D, WhiteSurface.GLTextureID); + shader.SetTexture(0); - GL.End(); - GL.Enable(EnableCap.Texture2D); + GL.DrawArrays(BeginMode.Lines, 0, 1); } - public override void FillRect(RectangleF rect, Color color) + public override void DrawRect(RectangleF rect, Color color) { - SetGLColor(color); + mVerts[0].Position.X = rect.Left; + mVerts[0].Position.Y = rect.Top; + mVerts[0].TexCoord.X = 0; + mVerts[0].TexCoord.Y = 0; - GL.Disable(EnableCap.Texture2D); + mVerts[1].Position.X = rect.Right; + mVerts[1].Position.Y = rect.Top; + mVerts[1].TexCoord.X = 1; + mVerts[1].TexCoord.Y = 0; - GL.Begin(BeginMode.Quads); - GL.Vertex3(rect.Left, rect.Top, 0); // Top Left - GL.Vertex3(rect.Right, rect.Top, 0); // Top Right - GL.Vertex3(rect.Right, rect.Bottom, 0); // Bottom Right - GL.Vertex3(rect.Left, rect.Bottom, 0); // Bottom Left - GL.End(); // Done Drawing The Quad + mVerts[2] = mVerts[1]; + + mVerts[3].Position.X = rect.Right; + mVerts[3].Position.Y = rect.Bottom; + mVerts[3].TexCoord.X = 1; + mVerts[3].TexCoord.Y = 1; + + mVerts[4] = mVerts[3]; - GL.Enable(EnableCap.Texture2D); - } - public override void FillRect(RectangleF rect, Gradient color) - { - GL.Disable(EnableCap.Texture2D); + mVerts[5].Position.X = rect.Left; + mVerts[5].Position.Y = rect.Bottom; + mVerts[5].TexCoord.X = 0; + mVerts[5].TexCoord.Y = 1; + + mVerts[6] = mVerts[3]; - GL.Begin(BeginMode.Quads); - SetGLColor(color.TopLeft); - GL.Vertex3(rect.Left, rect.Top, 0); // Top Left + mVerts[7].Position.X = rect.Left; + mVerts[7].Position.Y = rect.Top; + mVerts[7].TexCoord.X = 0; + mVerts[7].TexCoord.Y = 0; + + int colorValue = color.ToArgb(); + for (int i = 0; i < 7; i++) + { + mVerts[i].Color = colorValue; + } - SetGLColor(color.TopRight); - GL.Vertex3(rect.Right, rect.Top, 0); // Top Right + BufferData(); - SetGLColor(color.BottomRight); - GL.Vertex3(rect.Right, rect.Bottom, 0); // Bottom Right + GL_Display display = (GL_Display)Display.Impl; + Shaders.IGL3Shader shader = (Shaders.IGL3Shader)display.Shader.Impl; - SetGLColor(color.BottomLeft); - GL.Vertex3(rect.Left, rect.Bottom, 0); // Bottom Left - GL.End(); // Done Drawing The Quad + shader.SetVertexAttributes(PositionColor.VertexLayout); - GL.Enable(EnableCap.Texture2D); + GL.ActiveTexture(TextureUnit.Texture0); + GL.BindTexture(TextureTarget.Texture2D, WhiteSurface.GLTextureID); + shader.SetTexture(0); + + GL.DrawArrays(BeginMode.Lines, 0, 4); } + public override void FillRect(RectangleF rect, Color color) + { + mDisplay.WhiteSurface.Color = color; + mDisplay.WhiteSurface.Draw((Rectangle)rect); + mDisplay.WhiteSurface.Color = Color.White; + } + public override void FillRect(RectangleF rect, Gradient color) + { + mDisplay.WhiteSurface.ColorGradient = color; + mDisplay.WhiteSurface.Draw((Rectangle)rect); + mDisplay.WhiteSurface.Color = Color.White; + } public override void FillPolygon(PointF[] pts, int startIndex, int length, Color color) { - GL.Disable(EnableCap.Texture2D); + if (mVerts.Length < pts.Length + 1) + mVerts = new PositionTextureColor[pts.Length+1]; - SetGLColor(color); - - GL.Begin(BeginMode.TriangleFan); - for (int i = 0; i < length; i++) + for (int i = 0; i < pts.Length; i++) { - GL.Vertex3(pts[startIndex + i].X, pts[startIndex + i].Y, 0); + mVerts[i].Position.X = pts[i].X; + mVerts[i].Position.Y = pts[i].Y; + mVerts[i].TexCoord.X = 0; + mVerts[i].TexCoord.Y = 0; + mVerts[i].Color = color.ToArgb(); } - GL.End(); // Done Drawing The Quad - GL.Enable(EnableCap.Texture2D); + mVerts[pts.Length] = mVerts[0]; + + Shaders.IGL3Shader shader = (Shaders.IGL3Shader)mDisplay.Shader.Impl; + + shader.SetVertexAttributes(PositionColor.VertexLayout); + + GL.ActiveTexture(TextureUnit.Texture0); + GL.BindTexture(TextureTarget.Texture2D, WhiteSurface.GLTextureID); + shader.SetTexture(0); + + GL.DrawArrays(BeginMode.Lines, 0, 1); } } Modified: trunk/Drivers/AgateOTK/GL_Display.cs =================================================================== --- trunk/Drivers/AgateOTK/GL_Display.cs 2011-11-22 21:12:54 UTC (rev 1307) +++ trunk/Drivers/AgateOTK/GL_Display.cs 2011-11-23 04:33:21 UTC (rev 1308) @@ -1,619 +1,648 @@ -// The contents of this file are subject to the Mozilla Public License -// Version 1.1 (the "License"); you may not use this file except in -// compliance with the License. You may obtain a copy of the License at -// http://www.mozilla.org/MPL/ -// -// Software distributed under the License is distributed on an "AS IS" -// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the -// License for the specific language governing rights and limitations -// under the License. -// -// The Original Code is AgateLib. -// -// The Initial Developer of the Original Code is Erik Ylvisaker. -// Portions created by Erik Ylvisaker are Copyright (C) 2006-2011. -// All Rights Reserved. -// -// Contributor(s): Erik Ylvisaker -// -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.IO; -using System.Linq; -using System.Text; -using System.Runtime.InteropServices; -using AgateLib.BitmapFont; -using AgateLib.DisplayLib; -using AgateLib.DisplayLib.ImplementationBase; -using AgateLib.Drivers; -using AgateLib.Geometry; -using AgateLib.Geometry.VertexTypes; -using OpenTK.Graphics.OpenGL; -using PixelFormat = AgateLib.DisplayLib.PixelFormat; - -namespace AgateOTK -{ - /// <summary> - /// OpenGL 3.1 compatible. - /// </summary> - public sealed class GL_Display : DisplayImpl - { - GL_FrameBuffer mRenderTarget; - Stack<Rectangle> mClipRects = new Stack<Rectangle>(); - Rectangle mCurrentClip = Rectangle.Empty; - private bool mVSync = true; - private bool mSupportsFramebufferArb; - private bool mSupportsFramebufferExt; - private bool mNonPowerOf2Textures; - private bool mSupportsShaders; - private decimal mGLVersion; - - System.Windows.Forms.Form mFakeWindow; - DisplayWindow mFakeDisplayWindow; - - PrimitiveRenderer mPrimitives; - - bool mGL3; - - public bool SupportsNonPowerOf2Textures - { - get { return mNonPowerOf2Textures; } - private set { mNonPowerOf2Textures = value; } - } - - internal event EventHandler ProcessEventsEvent; - - protected override void ProcessEvents() - { - if (ProcessEventsEvent != null) - ProcessEventsEvent(this, EventArgs.Empty); - } - - protected override void OnRenderTargetChange(FrameBuffer oldRenderTarget) - { - mRenderTarget = RenderTarget.Impl as GL_FrameBuffer; - mRenderTarget.MakeCurrent(); - - OnRenderTargetResize(); - } - protected override void OnRenderTargetResize() - { - - } - - public override PixelFormat DefaultSurfaceFormat - { - get { return PixelFormat.RGBA8888; } - } - - #region --- Object Factory --- - - protected override AgateLib.DisplayLib.Shaders.Implementation.AgateShaderImpl CreateBuiltInShader(AgateLib.DisplayLib.Shaders.Implementation.BuiltInShader builtInShaderType) - { - return ShaderFactory.CreateBuiltInShader(builtInShaderType); - } - public override DisplayWindowImpl CreateDisplayWindow(CreateWindowParams windowParams) - { - if (windowParams.IsFullScreen && windowParams.RenderToControl == false) - return new GL_GameWindow(windowParams); - else - return new GL_DisplayControl(windowParams); - - //if (windowParams.RenderToControl) - //{ - // return new GL_DisplayControl(windowParams); - //} - //else - //{ - // return new GL_GameWindow(windowParams); - //} - } - public override SurfaceImpl CreateSurface(string fileName) - { - return new GL_Surface(fileName); - } - protected override VertexBufferImpl CreateVertexBuffer(VertexLayout layout, int vertexCount) - { - if (mGL3) - return new GL3.GLVertexBuffer(layout, vertexCount); - else - return new Legacy.LegacyVertexBuffer(layout, vertexCount); - } - protected override IndexBufferImpl CreateIndexBuffer(IndexBufferType type, int size) - { - return new GL_IndexBuffer(type, size); - } - - public override SurfaceImpl CreateSurface(Size surfaceSize) - { - return new GL_Surface(surfaceSize); - } - public override SurfaceImpl CreateSurface(System.IO.Stream fileStream) - { - return new GL_Surface(fileStream); - } - public override FontSurfaceImpl CreateFont(string fontFamily, float sizeInPoints, FontStyle style) - { - BitmapFontOptions options = new BitmapFontOptions(fontFamily, sizeInPoints, style); - - return AgateLib.WinForms.BitmapFontUtil.ConstructFromOSFont(options); - } - public override FontSurfaceImpl CreateFont(BitmapFontOptions bitmapOptions) - { - return AgateLib.WinForms.BitmapFontUtil.ConstructFromOSFont(bitmapOptions); - } - - protected override FrameBufferImpl CreateFrameBuffer(Size size) - { - if (mGL3 || (mSupportsFramebufferArb && ReadSettingsBool("DisableFramebufferArb") == false)) - return new GL3.FrameBuffer(size); - else if (mSupportsFramebufferExt && ReadSettingsBool("DisableFramebufferExt") == false) - { - try - { - return new Legacy.FrameBufferExt(size); - } - catch (Exception e) - { - Trace.WriteLine(string.Format("Caught exception {0} when trying to create GL_FrameBuffer_Ext wrapper.", e.GetType())); - Trace.Indent(); - Trace.WriteLine(e.Message); - Trace.Unindent(); - Trace.WriteLine(""); - Trace.WriteLine("Disabling frame buffer extension, and falling back onto glCopyTexSubImage2D."); - Trace.WriteLine("Extensive use of offscreen rendering targets will result in poor performance."); - Trace.WriteLine(""); - - mSupportsFramebufferExt = false; - } - } - - return new Legacy.FrameBufferReadPixels(size); - } - - bool ReadSettingsBool(string name) - { - string value; - - if (AgateLib.Core.Settings["AgateLib.OpenGL"].TryGetValue(name, out value) == false) - return false; - - if (value == "false" || value == "0") - return false; - - return true; - } - - public GLDrawBuffer CreateDrawBuffer() - { - if (mGL3) - return new GL3.DrawBuffer(); - else - return new Legacy.LegacyDrawBuffer(); - } - - - #endregion - - protected override void OnBeginFrame() - { - mRenderTarget.BeginRender(); - - GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha); - } - protected override void OnEndFrame() - { - DrawBuffer.Flush(); - - mRenderTarget.EndRender(); - - FlushDeleteQueue(); - } - - internal GLDrawBuffer DrawBuffer - { - get { return ((GL_FrameBuffer)RenderTarget.Impl).DrawBuffer; } - } - - // TODO: Test clip rect stuff. - public override void SetClipRect(Rectangle newClipRect) - { - GL.Viewport(newClipRect.X, mRenderTarget.Height - newClipRect.Bottom, - newClipRect.Width, newClipRect.Height); - - if (Display.Shader is AgateLib.DisplayLib.Shaders.IShader2D) - { - AgateLib.DisplayLib.Shaders.IShader2D s = (AgateLib.DisplayLib.Shaders.IShader2D)Display.Shader ; - - s.CoordinateSystem = newClipRect; - } - - mCurrentClip = newClipRect; - } - - public override void FlushDrawBuffer() - { - DrawBuffer.Flush(); - } - - public override void Clear(Color color) - { - DrawBuffer.Flush(); - - GL.ClearColor(color.R / 255.0f, color.G / 255.0f, color.B / 255.0f, color.A / 255.0f); - - ClearBufferMask mask = ClearBufferMask.ColorBufferBit; - - mask |= RenderTarget.HasDepthBuffer ? ClearBufferMask.DepthBufferBit : 0; - mask |= RenderTarget.HasStencilBuffer ? ClearBufferMask.StencilBufferBit : 0; - - GL.Clear(mask); - } - public override void Clear(Color color, Rectangle destRect) - { - DrawBuffer.Flush(); - - DrawRect(destRect, Color.FromArgb(255, color)); - } - - #region --- Drawing Primitives --- - - public override void DrawLine(Point a, Point b, Color color) - { - DrawBuffer.Flush(); - mPrimitives.DrawLine(a, b, color); - } - - public override void DrawRect(Rectangle rect, Color color) - { - DrawRect(new RectangleF(rect.X, rect.Y, rect.Width, rect.Height), color); - } - public override void DrawRect(RectangleF rect, Color color) - { - DrawBuffer.Flush(); - mPrimitives.DrawRect(rect, color); - } - - public override void FillRect(Rectangle rect, Color color) - { - FillRect(new RectangleF(rect.X, rect.Y, rect.Width, rect.Height), color); - } - public override void FillRect(RectangleF rect, Color color) - { - DrawBuffer.Flush(); - mPrimitives.FillRect(rect, color); - } - - public override void FillRect(Rectangle rect, Gradient color) - { - FillRect(new RectangleF(rect.X, rect.Y, rect.Width, rect.Height), color); - } - public override void FillRect(RectangleF rect, Gradient color) - { - DrawBuffer.Flush(); - mPrimitives.FillRect(rect, color); - } - - public override void FillPolygon(PointF[] pts, int startIndex, int length, Color color) - { - DrawBuffer.Flush(); - mPrimitives.FillPolygon(pts, startIndex, length, color); - } - - #endregion - #region --- Initialization --- - - public override void Initialize() - { - CreateFakeWindow(); - - Report("OpenTK / OpenGL driver instantiated for display."); - } - public void InitializeCurrentContext() - { - GL.ClearColor(0, 0, 0, 1.0f); // Black Background - GL.ClearDepth(1); // Depth Buffer Setup - GL.Enable(EnableCap.DepthTest); // Enables Depth Testing - GL.DepthFunc(DepthFunction.Lequal); // The Type Of Depth Testing To Do - } - - private void CreateFakeWindow() - { - mFakeWindow = new System.Windows.Forms.Form(); - mFakeDisplayWindow = DisplayWindow.CreateFromControl(mFakeWindow); - - mFakeWindow.Visible = false; - - string vendor = GL.GetString(StringName.Vendor); - mSupportsShaders = false; - - mGLVersion = DetectOpenGLVersion(); - if (mGLVersion >= 3m) - { - if (ReadSettingsBool("EnableGL3")) - { - mGL3 = true; - } - else - { - mGL3 = false; - mGLVersion = 2.1m; - } - } - - LoadExtensions(); - - mSupportsFramebufferArb = SupportsExtension("GL_ARB_FRAMEBUFFER_OBJECT"); - mSupportsFramebufferExt = SupportsExtension("GL_EXT_FRAMEBUFFER_OBJECT"); - mNonPowerOf2Textures = SupportsExtension("GL_ARB_NON_POWER_OF_TWO"); - - if (mGLVersion >= 3m) - { - mNonPowerOf2Textures = true; - mSupportsShaders = true; - } - if (mGLVersion >= 2m) - { - mNonPowerOf2Textures = true; - mSupportsShaders = true; - } - - if (mGL3) - mPrimitives = new GL3.GLPrimitiveRenderer(); - else - mPrimitives = new Legacy.LegacyPrimitiveRenderer(); - - if (SupportsExtension("GL_ARB_FRAGMENT_PROGRAM")) - { - mSupportsShaders = true; - } - - ShaderFactory.Initialize(mGL3); - - Trace.WriteLine(string.Format("OpenGL version {0} from vendor {1} detected.", mGLVersion, vendor)); - Trace.WriteLine("NPOT: " + mNonPowerOf2Textures.ToString()); - Trace.WriteLine("Shaders: " + mSupportsShaders.ToString()); - } - - string[] extensions; - private void LoadExtensions() - { - if (mGL3) - { - // Forward compatible context (GL 3.0+) - int num_extensions; - GL.GetInteger(GetPName.NumExtensions, out num_extensions); - - if (GL.GetError() != ErrorCode.NoError) - throw new OpenTK.Graphics.GraphicsErrorException("Not 3.0 context."); - - extensions = new string[num_extensions]; - - for (int i = 0; i < num_extensions; i++) - extensions[i] = GL.GetString(StringName.Extensions, i).ToLowerInvariant(); - } - else - { - string ext = GL.GetString(StringName.Extensions); - - extensions = ext.Split(' '); - - for (int i = 0; i < extensions.Length; i++) - { - Debug.Print(extensions[i]); - extensions[i] = extensions[i].ToLowerInvariant(); - } - } - } - private bool SupportsExtension(string name) - { - return extensions.Contains(name.ToLowerInvariant()); - } - - private static decimal DetectOpenGLVersion() - { - string versionString = GL.GetString(StringName.Version).Trim(); - - // Not sure whether OpenGL drivers will universally report version in the machine's - // culture settings or not. So we switch the current decimal separator with a period. - versionString = versionString.Replace(System.Globalization.NumberFormatInfo.CurrentInfo.NumberDecimalSeparator, "."); - int pointLoc = versionString.IndexOf("."); - - // Remove any additional version information. Some drivers report version string as - // something like 2.1.8577, which will be problematic for the decimal.Parse call below. - // We are only interested in the first two numbers, so discard everything else. - if (versionString.IndexOf(".", pointLoc + 1) > -1) - { - versionString = versionString.Substring(0, versionString.IndexOf(".", pointLoc + 1)); - } - - // Some drivers report a version like "2.0 Chromium 1", so dump everything after the space. - if (versionString.Contains(" ")) - { - versionString = versionString.Substring(0, versionString.IndexOf(" ")); - } - - decimal retval; - - if (decimal.TryParse(versionString, System.Globalization.NumberStyles.Number, - System.Globalization.CultureInfo.InvariantCulture, out retval) == false) - { - Trace.WriteLine("AgateOTK was unable to parse the OpenGL version string."); - Trace.WriteLine(" The reported string was: " + versionString); - Trace.WriteLine(" Please report this issue to http://www.agatelib.org along"); - Trace.WriteLine(" with details about your operating system and graphics drivers."); - Trace.WriteLine(" Falling back to OpenGL 1.1 supported functionality."); - - retval = 1.1m; - } - - return retval; - } - - #endregion - - #region --- Shaders --- - - public override void Dispose() - { - mFakeDisplayWindow.Dispose(); - mFakeWindow.Dispose(); - } - - - private void SetArray(float[] array, Vector3 vec) - { - array[0] = vec.X; - array[1] = vec.Y; - array[2] = vec.Z; - } - private void SetArray(float[] array, Color color) - { - array[0] = color.R / 255.0f; - array[1] = color.G / 255.0f; - array[2] = color.B / 255.0f; - array[3] = color.A / 255.0f; - } - - #endregion - - - protected override void SavePixelBuffer(PixelBuffer pixelBuffer, string filename, ImageFileFormat format) - { - AgateLib.WinForms.FormUtil.SavePixelBuffer(pixelBuffer, filename, format); - } - - protected override void HideCursor() - { - System.Windows.Forms.Cursor.Hide(); - - if (Display.CurrentWindow != null) - { - DisplayWindowImpl impl = Display.CurrentWindow.Impl; - //((GL_DisplayW)impl).HideCursor(); - } - } - protected override void ShowCursor() - { - System.Windows.Forms.Cursor.Show(); - - if (Display.CurrentWindow != null) - { - DisplayWindowImpl impl = Display.CurrentWindow.Impl; - - //((GL_FrameBufferExt)impl).ShowCursor(); - } - } - - #region --- Display Capabilities --- - - public override bool CapsBool(DisplayBoolCaps caps) - { - switch (caps) - { - 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.CustomShaders: return false; - case DisplayBoolCaps.CanCreateBitmapFont: return true; - } - - return false; - } - public override Size CapsSize(DisplaySizeCaps displaySizeCaps) - { - switch (displaySizeCaps) - { - case DisplaySizeCaps.MaxSurfaceSize: - int val; - GL.GetInteger(GetPName.MaxTextureSize, out val); - - return new Size(val, val); - } - - return new Size(0, 0); - } - public override IEnumerable<AgateLib.DisplayLib.Shaders.ShaderLanguage> SupportedShaderLanguages - { - get { yield return AgateLib.DisplayLib.Shaders.ShaderLanguage.Glsl; } - } - - #endregion - #region --- Render States --- - - bool mAlphaBlend; - - protected override bool GetRenderState(RenderStateBool renderStateBool) - { - switch (renderStateBool) - { - case RenderStateBool.WaitForVerticalBlank: return mVSync; - case RenderStateBool.AlphaBlend: return mAlphaBlend; - - default: - throw new NotSupportedException(string.Format( - "The specified render state, {0}, is not supported by this driver.")); - } - } - protected override void SetRenderState(RenderStateBool renderStateBool, bool value) - { - switch (renderStateBool) - { - case RenderStateBool.WaitForVerticalBlank: - mVSync = value; - break; - - case RenderStateBool.AlphaBlend: - mAlphaBlend = value; - if (value) - GL.Enable(EnableCap.Blend); - else - GL.Disable(EnableCap.Blend); - break; - - default: - throw new NotSupportedException(string.Format( - "The specified render state, {0}, is not supported by this driver.")); - } - } - - #endregion - - #region --- Deletion queuing --- - - List<int> mTexturesToDelete = new List<int>(); - - - private void FlushDeleteQueue() - { - lock (mTexturesToDelete) - { - if (mTexturesToDelete.Count == 0) - return; - - int[] tex = mTexturesToDelete.ToArray(); - mTexturesToDelete.Clear(); - - GL.DeleteTextures(mTexturesToDelete.Count, tex); - } - } - - internal void QueueDeleteTexture(int p) - { - lock (mTexturesToDelete) - { - mTexturesToDelete.Add(p); - } - } - - #endregion - - } +// The contents of this file are subject to the Mozilla Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.mozilla.org/MPL/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations +// under the License. +// +// The Original Code is AgateLib. +// +// The Initial Developer of the Original Code is Erik Ylvisaker. +// Portions created by Erik Ylvisaker are Copyright (C) 2006-2011. +// All Rights Reserved. +// +// Contributor(s): Erik Ylvisaker +// +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Linq; +using System.Text; +using System.Runtime.InteropServices; +using AgateLib.BitmapFont; +using AgateLib.DisplayLib; +using AgateLib.DisplayLib.ImplementationBase; +using AgateLib.Drivers; +using AgateLib.Geometry; +using AgateLib.Geometry.VertexTypes; +using OpenTK.Graphics.OpenGL; +using PixelFormat = AgateLib.DisplayLib.PixelFormat; + +namespace AgateOTK +{ + /// <summary> + /// OpenGL 3.1 compatible. + /// </summary> + public sealed class GL_Display : DisplayImpl + { + GL_FrameBuffer mRenderTarget; + Stack<Rectangle> mClipRects = new Stack<Rectangle>(); + Rectangle mCurrentClip = Rectangle.Empty; + private bool mVSync = true; + private bool mSupportsFramebufferArb; + private bool mSupportsFramebufferExt; + private bool mNonPowerOf2Textures; + private bool mSupportsShaders; + private decimal mGLVersion; + + System.Windows.Forms.Form mFakeWindow; + DisplayWindow mFakeDisplayWindow; + + PrimitiveRenderer mPrimitives; + + bool mGL3; + + internal Surface WhiteSurface + { + get; + private set; + } + public bool SupportsNonPowerOf2Textures + { + get { return mNonPowerOf2Textures; } + private set { mNonPowerOf2Textures = value; } + } + + internal event EventHandler ProcessEventsEvent; + + protected override void ProcessEvents() + { + if (ProcessEventsEvent != null) + ProcessEventsEvent(this, EventArgs.Empty); + } + + protected override void OnRenderTargetChange(FrameBuffer oldRenderTarget) + { + mRenderTarget = RenderTarget.Impl as GL_FrameBuffer; + mRenderTarget.MakeCurrent(); + + OnRenderTargetResize(); + } + protected override void OnRenderTargetResize() + { + + } + + public override PixelFormat DefaultSurfaceFormat + { + get { return PixelFormat.RGBA8888; } + } + + #region --- Object Factory --- + + protected override AgateLib.DisplayLib.Shaders.Implementation.AgateShaderImpl CreateBuiltInShader(AgateLib.DisplayLib.Shaders.Implementation.BuiltInShader builtInShaderType) + { + return ShaderFactory.CreateBuiltInShader(builtInShaderType); + } + public override DisplayWindowImpl CreateDisplayWindow(CreateWindowParams windowParams) + { + if (windowParams.IsFullScreen && windowParams.RenderToControl == false) + return new GL_GameWindow(windowParams); + else + return new GL_DisplayControl(windowParams); + + //if (windowParams.RenderToControl) + //{ + // return new GL_DisplayControl(windowParams); + //} + //else + //{ + // return new GL_GameWindow(windowParams); + //} + } + public override SurfaceImpl CreateSurface(string fileName) + { + return new GL_Surface(fileName); + } + protected override VertexBufferImpl CreateVertexBuffer(VertexLayout layout, int vertexCount) + { + if (mGL3) + return new GL3.GLVertexBuffer(layout, vertexCount); + else + return new Legacy.LegacyVertexBuffer(layout, vertexCount); + } + protected override IndexBufferImpl CreateIndexBuffer(IndexBufferType type, int size) + { + return new GL_IndexBuffer(type, size); + } + + public override SurfaceImpl CreateSurface(Size surfaceSize) + { + return new GL_Surface(surfaceSize); + } + public override SurfaceImpl CreateSurface(System.IO.Stream fileStream) + { + return new GL_Surface(fileStream); + } + public override FontSurfaceImpl CreateFont(string fontFamily, float sizeInPoints, FontStyle style) + { + BitmapFontOptions options = new BitmapFontOptions(fontFamily, sizeInPoints, style); + + return AgateLib.WinForms.BitmapFontUtil.ConstructFromOSFont(options); + } + public override FontSurfaceImpl CreateFont(BitmapFontOptions bitmapOptions) + { + return AgateLib.WinForms.BitmapFontUtil.ConstructFromOSFont(bitmapOptions); + } + + protected override FrameBufferImpl CreateFrameBuffer(Size size) + { + if (mGL3 || (mSupportsFramebufferArb && ReadSettingsBool("DisableFramebufferArb") == false)) + return new GL3.FrameBuffer(size); + else if (mSupportsFramebufferExt && ReadSettingsBool("DisableFramebufferExt") == false) + { + try + { + return new Legacy.FrameBufferExt(size); + } + catch (Exception e) + { + Trace.WriteLine(string.Format("Caught exception {0} when trying to create GL_FrameBuffer_Ext wrapper.", e.GetType())); + Trace.Indent(); + Trace.WriteLine(e.Message); + Trace.Unindent(); + Trace.WriteLine(""); + Trace.WriteLine("Disabling frame buffer extension, and falling back onto glCopyTexSubImage2D."); + Trace.WriteLine("Extensive use of offscreen rendering targets will result in poor performance."); + Trace.WriteLine(""); + + mSupportsFramebufferExt = false; + } + } + + return new Legacy.FrameBufferReadPixels(size); + } + + bool ReadSettingsBool(string name) + { + string value; + + if (AgateLib.Core.Settings["AgateLib.OpenGL"].TryGetValue(name, out value) == false) + return false; + + if (value == "false" || value == "0") + return false; + + return true; + } + + public GLDrawBuffer CreateDrawBuffer() + { + if (mGL3) + return new GL3.DrawBuffer(); + else + return new Legacy.LegacyDrawBuffer(); + } + + + #endregion + + protected override void OnBeginFrame() + { + mRenderTarget.BeginRender(); + + GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha); + } + protected override void OnEndFrame() + { + DrawBuffer.Flush(); + + mRenderTarget.EndRender(); + + FlushDeleteQueue(); + } + + internal GLDrawBuffer DrawBuffer + { + get { return ((GL_FrameBuffer)RenderTarget.Impl).DrawBuffer; } + } + + // TODO: Test clip rect stuff. + public override void SetClipRect(Rectangle newClipRect) + { + GL.Viewport(newClipRect.X, mRenderTarget.Height - newClipRect.Bottom, + newClipRect.Width, newClipRect.Height); + + if (Display.Shader is AgateLib.DisplayLib.Shaders.IShader2D) + { + AgateLib.DisplayLib.Shaders.IShader2D s = (AgateLib.DisplayLib.Shaders.IShader2D)Display.Shader; + + s.CoordinateSystem = newClipRect; + } + + mCurrentClip = newClipRect; + } + + public override void FlushDrawBuffer() + { + DrawBuffer.Flush(); + } + + public override void Clear(Color color) + { + DrawBuffer.Flush(); + + GL.ClearColor(color.R / 255.0f, color.G / 255.0f, color.B / 255.0f, color.A / 255.0f); + + ClearBufferMask mask = ClearBufferMask.ColorBufferBit; + + mask |= RenderTarget.HasDepthBuffer ? ClearBufferMask.DepthBufferBit : 0; + mask |= RenderTarget.HasStencilBuffer ? ClearBufferMask.StencilBufferBit : 0; + + GL.Clear(mask); + } + public override void Clear(Color color, Rectangle destRect) + { + DrawBuffer.Flush(); + + DrawRect(destRect, Color.FromArgb(255, color)); + } + + #region --- Drawing Primitives --- + + public override void DrawLine(Point a, Point b, Color color) + { + DrawBuffer.Flush(); + mPrimitives.DrawLine(a, b, color); + } + + public override void DrawRect(Rectangle rect, Color color) + { + DrawRect(new RectangleF(rect.X, rect.Y, rect.Width, rect.Height), color); + } + public override void DrawRect(RectangleF rect, Color color) + { + DrawBuffer.Flush(); + mPrimitives.DrawRect(rect, color); + } + + public override void FillRect(Rectangle rect, Color color) + { + FillRect(new RectangleF(rect.X, rect.Y, rect.Width, rect.Height), color); + } + public override void FillRect(RectangleF rect, Color color) + { + DrawBuffer.Flush(); + mPrimitives.FillRect(rect, color); + } + + public override void FillRect(Rectangle rect, Gradient color) + { + FillRect(new RectangleF(rect.X, rect.Y, rect.Width, rect.Height), color); + } + public override void FillRect(RectangleF rect, Gradient color) + { + DrawBuffer.Flush(); + mPrimitives.FillRect(rect, color); + } + + public override void FillPolygon(PointF[] pts, int startIndex, int length, Color color) + { + DrawBuffer.Flush(); + mPrimitives.FillPolygon(pts, startIndex, length, color); + } + + #endregion + #region --- Initialization --- + + public override void Initialize() + { + CreateFakeWindow(); + + Report("OpenTK / OpenGL driver instantiated for display."); + } + public void InitializeCurrentContext() + { + GL.ClearColor(0, 0, 0, 1.0f); // Black Background + GL.ClearDepth(1); // Depth Buffer Setup + GL.Enable(EnableCap.DepthTest); // Enables Depth Testing + GL.DepthFunc(DepthFunction.Lequal); // The Type Of Depth Testing To Do + + + } + + private void CreateWhiteSurface() + { + if (WhiteSurface == null) + { + int size = 2; + + PixelBuffer buffer = new PixelBuffer(PixelFormat.ARGB8888, new Size(size, size)); + + for (int i = 0; i < size; i++) + { + for (int j = 0; j < size; j++) + { + buffer.SetPixel(i, j, Color.White); + } + } + + WhiteSurface = new Surface(buffer); + } + } + + private void CreateFakeWindow() + { + mFakeWindow = new System.Windows.Forms.Form(); + mFakeDisplayWindow = DisplayWindow.CreateFromControl(mFakeWindow); + + mFakeWindow.Visible = false; + + string vendor = GL.GetString(StringName.Vendor); + mSupportsShaders = false; + + mGLVersion = DetectOpenGLVersion(); + if (mGLVersion >= 3m) + { + if (ReadSettingsBool("EnableGL3")) + { + mGL3 = true; + } + else + { + mGL3 = false; + mGLVersion = 2.1m; + } + } + + LoadExtensions(); + + mSupportsFramebufferArb = SupportsExtension("GL_ARB_FRAMEBUFFER_OBJECT"); + mSupportsFramebufferExt = SupportsExtension("GL_EXT_FRAMEBUFFER_OBJECT"); + mNonPowerOf2Textures = SupportsExtension("GL_ARB_NON_POWER_OF_TWO"); + + if (mGLVersion >= 3m) + { + mNonPowerOf2Textures = true; + mSupportsShaders = true; + } + if (mGLVersion >= 2m) + { + mNonPowerOf2Textures = true; + mSupportsShaders = true; + } + + if (mGL3) + mPrimitives = new GL3.GLPrimitiveRenderer(); + else + mPrimitives = new Legacy.LegacyPrimitiveRenderer(); + + if (SupportsExtension("GL_ARB_FRAGMENT_PROGRAM")) + { + mSupportsShaders = true; + } + + ShaderFactory.Initialize(mGL3); + + Trace.WriteLine(string.Format("OpenGL version {0} from vendor {1} detected.", mGLVersion, vendor)); + Trace.WriteLine("NPOT: " + mNonPowerOf2Textures.ToString()); + Trace.WriteLine("Shaders: " + mSupportsShaders.ToString()); + + CreateWhiteSurface(); + } + + string[] extensions; + private void LoadExtensions() + { + if (mGL3) + { + // Forward compatible context (GL 3.0+) + int num_extensions; + GL.GetInteger(GetPName.NumExtensions, out num_extensions); + + if (GL.GetError() != ErrorCode.NoError) + throw new OpenTK.Graphics.GraphicsErrorException("Not 3.0 context."); + + extensions = new string[num_extensions]; + + for (int i = 0; i < num_extensions; i++) + extensions[i] = GL.GetString(StringName.Extensions, i).ToLowerInvariant(); + } + else + { + string ext = GL.GetString(StringName.Extensions); + + extensions = ext.Split(' '); + + for (int i = 0; i < extensions.Length; i++) + { + Debug.Print(extensions[i]); + extensions[i] = extensions[i].ToLowerInvariant(); + } + } + } + private bool SupportsExtension(string name) + { + return extensions.Contains(name.ToLowerInvariant()); + } + + private static decimal DetectOpenGLVersion() + { + string versionString = GL.GetString(StringName.Version).Trim(); + + // Not sure whether OpenGL drivers will universally report version in the machine's + // culture settings or not. So we switch the current decimal separator with a period. + versionString = versionString.Replace(System.Globalization.NumberFormatInfo.CurrentInfo.NumberDecimalSeparator, "."); + int pointLoc = versionString.IndexOf("."); + + // Remove any additional version information. Some drivers report version string as + // something like 2.1.8577, which will be problematic for the decimal.Parse call below. + // We are only interested in the first two numbers, so discard everything else. + if (versionString.IndexOf(".", pointLoc + 1) > -1) + { + versionString = versionString.Substring(0, versionString.IndexOf(".", pointLoc + 1)); + } + + // Some drivers report a version like "2.0 Chromium 1", so dump everything after the space. + if (versionString.Contains(" ")) + { + versionString = versionString.Substring(0, versionString.IndexOf(" ")); + } + + decimal retval; + + if (decimal.TryParse(versionString, System.Globalization.NumberStyles.Number, + System.Globalization.CultureInfo.InvariantCulture, out retval) == false) + { + Trace.WriteLine("AgateOTK was unable to parse the OpenGL version string."); + Trace.WriteLine(" The reported string was: " + versionString); + Trace.WriteLine(" Please report this issue to http://www.agatelib.org along"); + Trace.WriteLine(" with details about your operating system and graphics drivers."); + Trace.WriteLine(" Falling back to OpenGL 1.1 supported functionality."); + + retval = 1.1m; + } + + return retval; + } + + #endregion + + #region --- Shaders --- + + public override void Dispose() + { + mFakeDisplayWindow.Dispose(); + mFakeWindow.Dispose(); + } + + + private void SetArray(float[] array, Vector3 vec) + { + array[0] = vec.X; + array[1] = vec.Y; + array[2] = vec.Z; + } + private void SetArray(float[] array, Color color) + { + array[0] = color.R / 255.0f; + array[1] = color.G / 255.0f; + array[2] = color.B / 255.0f; + array[3] = color.A / 255.0f; + } + + #endregion + + + protected override void SavePixelBuffer(PixelBuffer pixelBuffer, string filename, ImageFileFormat format) + { + AgateLib.WinForms.FormUtil.SavePixelBuffer(pixelBuffer, filename, format); + } + + protected override void HideCursor() + { + System.Windows.Forms.Cursor.Hide(); + + if (Display.CurrentWindow != null) + { + DisplayWindowImpl impl = Display.CurrentWindow.Impl; + //((GL_DisplayW)impl).HideCursor(); + } + } + protected override void ShowCursor() + { + System.Windows.Forms.Cursor.Show(); + + if (Display.CurrentWindow != null) + { + DisplayWindowImpl impl = Display.CurrentWindow.Impl; + + //((GL_FrameBufferExt)impl).ShowCursor(); + } + } + + #region --- Display Capabilities --- + + public override bool CapsBool(DisplayBoolCaps caps) + { + switch (caps) + { + 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.CustomShaders: return false; + case DisplayBoolCaps.CanCreateBitmapFont: return true; + } + + return false; + } + public override Size CapsSize(DisplaySizeCaps displaySizeCaps) + { + switch (displaySizeCaps) + { + case DisplaySizeCaps.MaxSurfaceSize: + int val; + GL.GetInteger(GetPName.MaxTextureSize, out val); + + return new Size(val, val); + } + + return new Size(0, 0); + } + public override IEnumerable<AgateLib.DisplayLib.Shaders.ShaderLanguage> SupportedShaderLanguages + { + get { yield return AgateLib.DisplayLib.Shaders.ShaderLanguage.Glsl; } + } + + #endregion + #region --- Render States --- + + bool mAlphaBlend; + + protected override bool GetRenderState(RenderStateBool renderStateBool) + { + switch (renderStateBool) + { + case RenderStateBool.WaitForVerticalBlank: return mVSync; + case RenderStateBool.AlphaBlend: return mAlphaBlend; + + default: + throw new NotSupportedException(string.Format( + "The specified render state, {0}, is not supported by this driver.")); + } + } + protected override void SetRenderState(RenderStateBool renderStateBool, bool value) + { + switch (renderStateBool) + { + case RenderStateBool.WaitForVerticalBlank: + mVSync = value; + break; + + case RenderStateBool.AlphaBlend: + mAlphaBlend = value; + if (value) + GL.Enable(EnableCap.Blend); + else + GL.Disable(EnableCap.Blend); + break; + + default: + throw new NotSupportedException(string.Format( + "The specified render state, {0}, is not supported by this driver.")); + } + } + + #endregion + + #region --- Deletion queuing --- + + List<int> mTexturesToDelete = new List<int>(); + + + private void FlushDeleteQueue() + { + lock (mTexturesToDelete) + { + if (mTexturesToDelete.Count == 0) + return; + + 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/Tests/DisplayTests/BasicDrawing/BasicDrawing.cs =================================================================== --- trunk/Tests/DisplayTests/BasicDrawing/BasicDrawing.cs 2011-11-22 21:12:54 UTC (rev 1307) +++ trunk/Tests/DisplayTests/BasicDrawing/BasicDrawing.cs 2011-11-23 04:33:21 UTC (rev 1308) @@ -66,9 +66,9 @@ } } - static List<Shape> shapes = new List<Shape>(); - static Random random = new Random(); - static DrawingTester frm; + List<Shape> shapes = new List<Shape>(); + Random random = new Random(); + DrawingTester frm; /// <summary> /// The main entry point for the application. @@ -142,12 +142,12 @@ shapes.Add(new Shape(ShapeType.FillEllipse, Color.FromArgb(frm.SelectedColor.ToArgb()), RandomRect())); } - static void btnDrawCircle_Click(object sender, EventArgs e) + void btnDrawCircle_Click(object sender, EventArgs e) { shapes.Add(new Shape(ShapeType.DrawEllipse, Color.FromArgb(frm.SelectedColor.ToArgb()), RandomRect())); } - static Rectangle RandomRect() + Rectangle RandomRect() { return new Rectangle( random.Next(0, frm.panel1.Width * 2 / 3), @@ -156,17 +156,17 @@ random.Next(10, frm.panel1.Height / 2) ); } - static void btnFillRect_Click(object sender, EventArgs e) + void btnFillRect_Click(object sender, EventArgs e) { shapes.Add(new Shape(ShapeType.FillRect, Color.FromArgb(frm.SelectedColor.ToArgb()), RandomRect())); } - static void btnDrawRect_Click(object sender, EventArgs e) + void btnDrawRect_Click(object sender, EventArgs e) { shapes.Add(new Shape(ShapeType.DrawRect, Color.FromArgb(frm.SelectedColor.ToArgb()), RandomRect())); } - static void btnDrawLine_Click(object sender, EventArgs e) + void btnDrawLine_Click(object sender, EventArgs e) { int x = random.Next(0, frm.panel1.Width * 2 / 3); int y = random.Next(0, frm.panel1.Width * 2 / 3); @@ -191,7 +191,7 @@ } } - static void btnClear_Click(object sender, EventArgs e) + void btnClear_Click(object sender, EventArgs e) { shapes.Clear(); Modified: trunk/Tests/frmLauncher.cs =================================================================== --- trunk/Tests/frmLauncher.cs 2011-11-22 21:12:54 UTC (rev 1307) +++ trunk/Tests/frmLauncher.cs 2011-11-23 04:33:21 UTC (rev 1308) @@ -1,118 +1,118 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.IO; -using System.Linq; -using System.Text; -using System.Windows.Forms; -using System.Reflection; - -namespace Tests -{ - public partial class frmLauncher : Form, AgateLib.Settings.ISettingsTracer - { - class TestInfo - { - public string Name { get; set; } - public string Category { get; set; } - public Type Class { get; set; } - } - - List<TestInfo> tests = new List<TestInfo>(); - Font bold; - - public frmLauncher() - { - InitializeComponent(); - - Icon = AgateLib.WinForms.FormUtil.AgateLibIcon; - - LoadTests(); - - bold = new Font(lstTests.Font, FontStyle.Bold | FontStyle.Italic); - +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.IO; +using System.Linq; +using System.Text; +using System.Windows.Forms; +using System.Reflection; + +namespace Tests +{ + public partial class frmLauncher : Form, AgateLib.Settings.ISettingsTracer + { + class TestInfo + { + public string Name { get; set; } + public string Category { get; set; } + public Type Class { get; set; } + } + + List<TestInfo> tests = new List<TestInfo>(); + Font bold; + + public frmLauncher() + { + InitializeComponent(); + + Icon = AgateLib.WinForms.FormUtil.AgateLibIcon; + + LoadTests(); + + bold = new Font(lstTests.Font, FontStyle.Bold | FontStyle.Italic); + ReadSettingsNames(); - - AgateLib.Core.Settings.SettingsTracer = this; - AgateLib.Core.Settings.Debug = true; - - FillDrivers(); - - this.FormClosed += HandleFormClosed; - } - - private void frmLauncher_Load(object sender, EventArgs e) - { - FillDrivers(); - } - - private void FillDrivers() - { - AgateLib.Core.Initialize(); - - AddDrivers(displayList, AgateLib.Drivers.Registrar.DisplayDrivers); - AddDrivers(audioList, AgateLib.Drivers.Registrar.AudioDrivers); - AddDrivers(inputList, AgateLib.Drivers.Registrar.InputDrivers); - } - - private void AddDrivers(ComboBox list, List<AgateLib.Drivers.AgateDriverInfo> drivers) - { - list.Items.Clear(); - list.Items.Add("Default"); - - foreach (var driver in drivers) - { - list.Items.Add(driver.FriendlyName); - } - - list.SelectedIndex = 0; - } - void HandleFormClosed (object sender, FormClosedEventArgs e) - { - using (StreamWriter w =new StreamWriter(settingsFile)) - { - foreach(var setting in mSettings) + + AgateLib.Core.Settings.SettingsTracer = this; + AgateLib.Core.Settings.Debug = true; + + FillDrivers(); + + this.FormClosed += HandleFormClosed; + } + + private void frmLauncher_Load(object sender, EventArgs e) + { + FillDrivers(); + } + + private void FillDrivers() + { + AgateLib.Core.Initialize(); + + AddDrivers(displayList, AgateLib.Drivers.Registrar.DisplayDrivers); + AddDrivers(audioList, AgateLib.Drivers.Registrar.AudioDrivers); + AddDrivers(inputList, AgateLib.Drivers.Registrar.InputDrivers); + } + + private void AddDrivers(ComboBox list, List<AgateLib.Drivers.AgateDriverInfo> drivers) + { + list.Items.Clear(); + list.Items.Add("Default"); + + foreach (var driver in drivers) + { + list.Items.Add(driver.FriendlyName); + } + + list.SelectedIndex = 0; + } + void HandleFormClosed(object sender, FormClosedEventArgs e) + { + using (StreamWriter w = new StreamWriter(settingsFile)) + { + foreach (var setting in mSettings) { string text = setting.Key + " " + setting.Value; - - System.Diagnostics.Debug.Print(text); - w.WriteLine(text); - } - } - } - - #region --- ISettingsTracer implementation --- - - Dictionary<string, string> mSettings = new Dictionary<string, string>(); + + System.Diagnostics.Debug.Print(text); + w.WriteLine(text); + } + } + } + + #region --- ISettingsTracer implementation --- + + Dictionary<string, string> mSettings = new Dictionary<string, string>(); string settingsFile; - - void AgateLib.Settings.ISettingsTracer.OnReadSetting (string groupName, string key, string value) - { - string name = groupName + "." + key; - - StoreSetting(name, value); - } - - void AgateLib.Settings.ISettingsTracer.OnWriteSetting (string groupName, string key, string value) - { - string name = groupName + "." + key; - - StoreSetting(name, value); - } - + + void AgateLib.Settings.ISettingsTracer.OnReadSetting(string groupName, string key, string value) + { + string name = groupName + "." + key; + + StoreSetting(name, value); + } + + void AgateLib.Settings.ISettingsTracer.OnWriteSetting(string groupName, string key, string value) + { + string name = groupName + "." + key; + + StoreSetting(name, value); + } + void ReadSettingsNames() { StreamReader r = null; string targetDirectory = "../../Tests/"; string filename = "settings_list.txt"; - + try { using (r) { - try + try { settingsFile = targetDirectory + filename; r = new StreamReader(targetDirectory + filename); @@ -120,16 +120,16 @@ catch (DirectoryNotFoundException) { settingsFile = filename; - r = new StreamReader(filename); + r = new StreamReader(filename); } - + while (r.EndOfStream == false) { string x = r.ReadLine().Trim(); if (string.IsNullOrEmpty(x) == false) { int index = x.IndexOf(' '); - + if (index == -1) { mSettings.Add(x, null); @@ -145,166 +145,197 @@ if (settingsFile == null) settingsFile = filename; } - - } - void StoreSetting(string name, string value) + + } + void StoreSetting(string name, string value) { - if (mSettings.ContainsKey(name)) return; - + if (mSettings.ContainsKey(name)) return; + System.Diagnostics.Debug.Print("Storing setting " + name); - + mSettings.Add(name, value); - } - - #endregion - - private void FillList() - { - tests.Sort((x, y) => - { - if (x.Category != y.Category) - return x.Category.CompareTo(y.Category); - else - return x.Name.CompareTo(y.Name); - }); - - string lastCategory = null; - - foreach (var test in tests) - { - if (test.Category != lastCategory) - { - lstTests.Items.Add(test.Category); - lastCategory = test.Category; - } - - this.lstTests.Items.Add(test); - } - } - - private void LoadTests() - { - Assembly myass = Assembly.GetAssembly(typeof(frmLauncher)); - - foreach (var t in myass.GetTypes()) - { - if (typeof(IAgateTest).IsAssignableFrom(t) && t.IsAbstract == false) - { - AddTest(t); - } - } - - FillList(); - } - - - private void AddTest(Type t) - { - IAgateTest obj = (IAgateTest)Activator.CreateInstance(t); - - tests.Add(new TestInfo { Name = obj.Name, Category = obj.Category, Class = t }); - } - - private void lstTests_DoubleClick(object sender, EventArgs e) - { - TestInfo t = lstTests.SelectedItem as TestInfo; - if (t == null) - return; - - LaunchTest(t); - } - - private void lstTests_KeyUp(object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.Enter) - { - TestInfo t = lstTests.SelectedItem as TestInfo; - if (t == null) - return; - - LaunchTest(t); - } - } - - bool runningTest = false; - - private void LaunchTest(TestInfo m) - { - IAgateTest obj = (IAgateTest)Activator.CreateInstance(m.Class); - if (runningTest) - { - System.Diagnostics.Debug.Print("Bug in mono? A second test was launched while the first was still running."); - return; - } - - - string[] args = { }; - - this.Hide(); - AgateLib.Core.Settings["AgateLib"]["DisplayDriver"] = displayList.Text; - AgateLib.Core.Settings["AgateLib"]["AudioDriver"] = audioList.Text; - AgateLib.Core.Settings["AgateLib"]["InputDriver"] = inputList.Text; - - - try - { - runningTest = true; - obj.Main(args); - } - catch (TargetInvocationException e) - { - Exception ex_relevant = e.InnerException ?? e; - string info = ex_relevant.Message; - - MessageBox.Show( - ex_relevant.GetType().Name + Environment.NewLine + info, - "AgateLib Test " + m.Name + " threw an exception.", - MessageBoxButtons.OK, - MessageBoxIcon.Stop); - - } - finally - { - runningTest = false; - this.Show(); - Cursor.Show(); - this.TopMost = true; - this.TopMost = false; - this.Activate(); - } - } - - private void lstTests_DrawItem(object sender, DrawItemEventArgs e) - { - object item = lstTests.Items[e.Index]; - const int indent = 15; - - e.DrawBackground(); - - PointF loc = e.Bounds.Location; - Brush b = new SolidBrush(e.ForeColor); - - if (item is string) - { - e.Graphics.DrawString((string)item, bold, b, loc); - } - else if (item is TestInfo) - { - TestInfo t = item as TestInfo; - loc.X += indent; - - e.Graphics.DrawString(t.Name, lstTests.Font, b, loc); - - var size = e.Graphics.MeasureString(t.Name, lstTests.Font); - - size.Width += indent + 5; - - if (lstTests.ColumnWidth < size.Width) - lstTests.ColumnWidth = (int)size.Width; - } - - e.DrawFocusRectangle(); - } - - } + } + + #endregion + + private void FillList() + { + tests.Sort((x, y) => + { + if (x.Category != y.Category) + return x.Category.CompareTo(y.Category); + else + return x.Name.CompareTo(y.Name); + }); + + string lastCategory = null; + + foreach (var test in tests) + { + if (test.Category != lastCategory) + { + lstTests.Items.Add(test.Category); + lastCategory = test.Category; + } + + this.lstTests.Items.Add(test); + } + } + + private void LoadTests() + { + Assembly myass = Assembly.GetAssembly(typeof(frmLauncher)); + + foreach (var t in myass.GetTypes()) + { + if (typeof(IAgateTest).IsAssignableFrom(t) && t.IsAbstract == false) + { + AddTest(t); + } + } + + FillList(); + } + + + private void AddTest(Type t) + { + IAgateTest obj = (IAgateTest)Activator.CreateInstance(t); + + tests.Add(new TestInfo { Name = obj.Name, Category = obj.Category, Class = t }); + } + + private void lstTests_DoubleClick(object sender, EventArgs e) + { + TestInfo t = lstTests.SelectedItem as TestInfo; + if (t == null) + return; + + LaunchTest(t); + } + + private void lstTests_KeyUp(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Enter) + { + TestInfo t = lstTests.SelectedItem as TestInfo; + if (t == null) + return; + + LaunchTest(t); + } + } + + bool runningTest = false; + + private void LaunchTest(TestInfo m) + { + IAgateTest obj = (IAgateTest)Activator.CreateInstance(m.Class); + if (runningTest) + { + System.Diagnostics.Debug.Print("Bug in mono? A second test was launched while the first was still running."); + return; + } + + + string[] args = { }; + + this.Hide(); + AgateLib.Core.Settings["AgateLib"]["DisplayDriver"] = displayList.Text; + AgateLib.Core.Settings["AgateLib"]["AudioDriver"] = audioList.Text; + AgateLib.Core.Settings["AgateLib"]["InputDriver"] = inputList.Text; + + foreach (var kvp in mSettings) + { + if (kvp.Value == null) + continue; + + string group, key; + SplitName(kvp.Key, out group, out key); + + if (group == "AgateLib") + { + if (key == "DisplayDriver") continue; + if (key == "AudioDriver") continue; + if (key == "InputDriver") continue; + } + + AgateLib.Core.Settings[group][key] = kvp.Value; + } + + try + { + runningTest = true; + obj.Main(args); + } + catch (TargetInvocationException e) + { + Exception ex_relevant = e.InnerException ?? e; + string info = ex_relevant.Message; + + MessageBox.Show( + ex_relevant.GetType().Name + Environment.NewLine + info, + "AgateLib Test " + m.Name + " threw an exception.", + MessageBoxButtons.OK, + MessageBoxIcon.Stop); + + } + finally + { + runningTest = false; + this.Show(); + Cursor.Show(); + this.TopMost = true; + this.TopMost = false; + this.Activate(); + } + } + + private void SplitName(string p, out string group, out string key) + { + int period = p.LastIndexOf('.'); + + if (period == -1) + throw new DataException("Invalid key name"); + + group = p.Substring(0, period); + key = p.Substring(period + 1); + + } + + + + private void lstTests_DrawItem(object sender, DrawItemEventArgs e) + { + object item = lstTests.Items[e.Index]; + const int indent = 15; + + e.DrawBackground(); + + PointF loc = e.Bounds.Location; + Brush b = new SolidBrush(e.ForeColor); + + if (item is string) + { + e.Graphics.DrawString((string)item, bold, b, loc); + } + else if (item is TestInfo) + { + TestInfo t = item as TestInfo; + loc.X += indent; + + e.Graphics.DrawString(t.N... [truncated message content] |
From: <ka...@us...> - 2011-11-22 21:13:03
|
Revision: 1307 http://agate.svn.sourceforge.net/agate/?rev=1307&view=rev Author: kanato Date: 2011-11-22 21:12:54 +0000 (Tue, 22 Nov 2011) Log Message: ----------- Storing testing settings in a file. Modified Paths: -------------- trunk/AgateLib/AgateLib.csproj trunk/AgateLib/Drivers/Registrar.cs trunk/AgateLib/Platform.cs trunk/AgateLib/Settings/PersistantSettings.cs trunk/AgateLib/Settings/SettingsGroup.cs trunk/Drivers/AgateOTK/GL_Display.cs trunk/Tests/Tests.csproj trunk/Tests/frmLauncher.cs Added Paths: ----------- trunk/AgateLib/Settings/ISettingsTracer.cs trunk/Tests/settings_list.txt Modified: trunk/AgateLib/AgateLib.csproj =================================================================== --- trunk/AgateLib/AgateLib.csproj 2011-11-22 17:57:40 UTC (rev 1306) +++ trunk/AgateLib/AgateLib.csproj 2011-11-22 21:12:54 UTC (rev 1307) @@ -584,6 +584,7 @@ <LastGenOutput>DataResources.Designer.cs</LastGenOutput> </EmbeddedResource> <Compile Include="DisplayLib\Shaders\IShader2D.cs" /> + <Compile Include="Settings\ISettingsTracer.cs" /> </ItemGroup> <ItemGroup> <None Include="InternalResources\agate-black-gui.zip" /> Modified: trunk/AgateLib/Drivers/Registrar.cs =================================================================== --- trunk/AgateLib/Drivers/Registrar.cs 2011-11-22 17:57:40 UTC (rev 1306) +++ trunk/AgateLib/Drivers/Registrar.cs 2011-11-22 21:12:54 UTC (rev 1307) @@ -1,519 +1,519 @@ -// The contents of this file are subject to the Mozilla Public License -// Version 1.1 (the "License"); you may not use this file except in -// compliance with the License. You may obtain a copy of the License at -// http://www.mozilla.org/MPL/ -// -// Software distributed under the License is distributed on an "AS IS" -// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the -// License for the specific language governing rights and limitations -// under the License. -// -// The Original Code is AgateLib. -// -// The Initial Developer of the Original Code is Erik Ylvisaker. -// Portions created by Erik Ylvisaker are Copyright (C) 2006-2011. -// All Rights Reserved. -// -// Contributor(s): Erik Ylvisaker -// -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Linq; -using System.Reflection; -using System.Text; -using AgateLib.AudioLib.ImplementationBase; -using AgateLib.DisplayLib.ImplementationBase; -using AgateLib.InputLib.ImplementationBase; -using AgateLib.Utility; - -namespace AgateLib.Drivers -{ - /// <summary> - /// Static class with which drivers register themselves so that the library can - /// instantiate them. - /// </summary> - public static class Registrar - { - private static List<AgateDriverInfo> - displayDrivers = new List<AgateDriverInfo>(), - audioDrivers = new List<AgateDriverInfo>(), - inputDrivers = new List<AgateDriverInfo>(), - desktopDrivers = new List<AgateDriverInfo>(); - - private static bool mIsInitialized = false; - - private static IDesktopDriver mDesktop; - - private static readonly string[] KnownNativeLibraries = new string[] - { - "SDL.dll", - "SDL_mixer.dll", - "libogg-0.dll", - "libvorbis-0.dll", - "libvorbisfile-3.dll", - }; - - - static bool Contains(this IEnumerable<AgateDriverInfo> list, DisplayTypeID type) - { - return list.Any( - x => Comparator(x, DriverType.Display, (int)type)); - } - static bool Contains(this IEnumerable<AgateDriverInfo> list, AudioTypeID type) - { - return list.Any( - x => Comparator(x, DriverType.Audio, (int)type)); - } - static bool Contains(this IEnumerable<AgateDriverInfo> list, InputTypeID type) - { - return list.Any( - x => Comparator(x, DriverType.Input, (int)type)); - } - static bool Comparator(AgateDriverInfo info, DriverType driverType, int type) - { - return info.DriverType == driverType && info.DriverTypeID == type; - } - - static Registrar() - { - } - /// <summary> - /// Searches through FileManager.AssemblyPath for all *.dll files. These files - /// are loaded and searched for classes which derive from DisplayImpl, AudioImpl, etc. - /// </summary> - internal static void Initialize() - { - if (mIsInitialized) - return; - - RegisterNullDrivers(); - - AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve); - AppDomain sandbox = AppDomain.CreateDomain("AgateSandBox"); - - AgateSandBoxLoader loader = (AgateSandBoxLoader) - sandbox.CreateInstanceAndUnwrap(Assembly.GetExecutingAssembly().FullName, - typeof(AgateSandBoxLoader).FullName); - - IEnumerable<string> files = AgateFileProvider.Assemblies.GetAllFiles("*.dll"); - - foreach (string file in files) - { - if (ShouldSkipLibrary(file)) - continue; - - foreach (AgateDriverInfo info in loader.ReportDrivers(file)) - { - switch (info.DriverType) - { - case DriverType.Display: - displayDrivers.Add(info); - break; - - case DriverType.Audio: - audioDrivers.Add(info); - break; - - case DriverType.Input: - inputDrivers.Add(info); - break; - - case DriverType.Desktop: - desktopDrivers.Add(info); - break; - - default: - Core.ErrorReporting.Report(ErrorLevel.Warning, string.Format( - "Could not interpret DriverType returned by type {0} in assembly {1}.", - info.DriverTypeName, info.AssemblyFile), null); - - break; - } - } - } - - AppDomain.Unload(sandbox); - - SortDriverInfo(displayDrivers); - SortDriverInfo(audioDrivers); - SortDriverInfo(inputDrivers); - SortDriverInfo(desktopDrivers); - - mIsInitialized = true; - } - private static void SortDriverInfo(List<AgateDriverInfo> driverList) - { - // sorts the driver list in reverse order. - driverList.Sort(delegate(AgateDriverInfo a, AgateDriverInfo b) - { - return -a.Priority.CompareTo(b.Priority); - }); - } - - private static void RegisterNullDrivers() - { - Assembly thisAssembly = Assembly.GetExecutingAssembly(); - - AgateDriverInfo nullAudioInfo = new AgateDriverInfo(AudioTypeID.Silent, - typeof(NullSoundImpl), "No audio", -100); - - nullAudioInfo.AssemblyFile = thisAssembly.CodeBase; - nullAudioInfo.AssemblyName = thisAssembly.FullName; - - audioDrivers.Add(nullAudioInfo); - - AgateDriverInfo nullInputInfo = new AgateDriverInfo(InputTypeID.Silent, - typeof(NullInputImpl), "No input", -100); - - nullInputInfo.AssemblyFile = thisAssembly.CodeBase; - nullInputInfo.AssemblyName = thisAssembly.FullName; - - inputDrivers.Add(nullInputInfo); - } - - private static bool ShouldSkipLibrary(string file) - { - // Native libraries in the same directory will give an error when loaded, - // so skip any ones that we know about that will probably be in the same - // directory as the drivers. - if (IsKnownNativeLibrary(file)) - return true; - - // hack, because mono crashes if AgateMDX.dll is present. - // annoying, because it should report a failure to load the types in the - // assembly, and then the try catch should continue after that. - // TODO: this hack seems unnecessary in recent versions of Mono. Should it be removed? - if ((Environment.OSVersion.Platform == PlatformID.Unix || - Environment.OSVersion.Platform == (PlatformID)128) && - (System.IO.Path.GetFileName(file).ToLower().Contains("agatemdx.dll") || - System.IO.Path.GetFileName(file).ToLower().Contains("agatesdx.dll"))) - { - Core.ErrorReporting.Report(ErrorLevel.Comment, - string.Format("DirectX not supported on non-Windows platforms. {0}Remove {1} to eliminate this message.", - Environment.NewLine, System.IO.Path.GetFileName(file)), null); - - return true; - } - - // Skip the agatelib dll. - if (System.IO.Path.GetFileName(file).ToLower().Contains("agatelib.dll")) - return true; - - return false; - } - private static bool IsKnownNativeLibrary(string path) - { - string filename = System.IO.Path.GetFileName(path).ToLowerInvariant(); - - for (int i = 0; i < KnownNativeLibraries.Length; i++) - { - if (KnownNativeLibraries[i].ToLowerInvariant() == filename) - return true; - } - return false; - } - - - /// <summary> - /// Asks the user to select which drivers to use. - /// </summary> - /// <param name="chooseDisplay"></param> - /// <param name="chooseAudio"></param> - /// <param name="chooseInput"></param> - /// <param name="selectedDisplay"></param> - /// <param name="selectedAudio"></param> - /// <param name="selectedInput"></param> - /// <returns></returns> - internal static bool UserSelectDrivers(bool chooseDisplay, bool chooseAudio, bool chooseInput, - DisplayTypeID preferredDisplay, AudioTypeID preferredAudio, InputTypeID preferredInput, - out DisplayTypeID selectedDisplay, out AudioTypeID selectedAudio, out InputTypeID selectedInput) - { - if (mDesktop == null) - { - CreateDesktopDriver(); - - if (mDesktop == null) - { - SelectBestDrivers(chooseDisplay, chooseAudio, chooseInput, - preferredDisplay, preferredAudio, preferredInput, - out selectedDisplay, out selectedAudio, out selectedInput); - - return true; - } - } - - IUserSetSystems frm = mDesktop.CreateUserSetSystems(); - - // set default values. - selectedDisplay = DisplayTypeID.AutoSelect; - selectedAudio = AudioTypeID.AutoSelect; - selectedInput = InputTypeID.AutoSelect; - - foreach (AgateDriverInfo info in displayDrivers) - { - frm.AddDisplayType(info); - } - foreach (AgateDriverInfo info in audioDrivers) - { - frm.AddAudioType(info); - } - foreach (AgateDriverInfo info in inputDrivers) - { - frm.AddInputType(info); - } - - frm.SetChoices(chooseDisplay, chooseAudio, chooseInput, - preferredDisplay, preferredAudio, preferredInput); - - // run the dialog asking user which drivers to use. - if (frm.RunDialog() == SetSystemsDialogResult.Cancel) - { - return false; - } - - selectedDisplay = frm.DisplayType; - selectedAudio = frm.AudioType; - selectedInput = frm.InputType; - - return true; - - } - - private static void SelectBestDrivers(bool chooseDisplay, bool chooseAudio, bool chooseInput, - DisplayTypeID preferredDisplay, AudioTypeID preferredAudio, InputTypeID preferredInput, - out DisplayTypeID selectedDisplay, out AudioTypeID selectedAudio, out InputTypeID selectedInput) - { - // initial return values if a driver isn't selected. - selectedDisplay = DisplayTypeID.AutoSelect; - selectedAudio = AudioTypeID.AutoSelect; - selectedInput = InputTypeID.AutoSelect; - - if (preferredDisplay != DisplayTypeID.AutoSelect && displayDrivers.Contains(preferredDisplay)) - selectedDisplay = preferredDisplay; - else if (displayDrivers.Count > 0) - selectedDisplay = (DisplayTypeID)displayDrivers[0].DriverTypeID; - - if (preferredAudio != AudioTypeID.AutoSelect && audioDrivers.Contains(preferredAudio)) - selectedAudio = preferredAudio; - else if (audioDrivers.Count > 0) - selectedAudio = (AudioTypeID)audioDrivers[0].DriverTypeID; - - if (preferredInput != InputTypeID.AutoSelect && inputDrivers.Contains(preferredInput)) - selectedInput = preferredInput; - else if (inputDrivers.Count > 0) - selectedInput = (InputTypeID)inputDrivers[0].DriverTypeID; - } - - private static void CreateDesktopDriver() - { - if (desktopDrivers.Count == 0) - return; - - mDesktop = (IDesktopDriver)CreateDriverInstance(desktopDrivers[0]); - } - - internal static IDesktopDriver WinForms - { - get { return mDesktop; } - } - - internal static DisplayImpl CreateDisplayDriver(DisplayTypeID displayType) - { - if (displayDrivers.Count == 0) - throw new AgateException("No display drivers registered."); - - AgateDriverInfo info = null; - string text; - - bool settingsSelect = displayType == DisplayTypeID.AutoSelect; - settingsSelect &= Core.Settings["AgateLib"].TryGetValue("DisplayDriver", out text); - - if (settingsSelect) - { - info = FindDriverInfo(displayDrivers, text); - - if (info == null) - settingsSelect = false; - } - - if (settingsSelect == false) - info = FindDriverInfo(displayDrivers, (int)displayType); - - if (info == null) - throw new AgateException(string.Format("Could not find the driver {0}.", displayType)); - - return (DisplayImpl)CreateDriverInstance(info); - } - internal static AudioImpl CreateAudioDriver(AudioTypeID audioType) - { - if (audioDrivers.Count == 0) - throw new AgateException("No audio drivers registered."); - - AgateDriverInfo info = null; - string text; - - bool settingsSelect = audioType == AudioTypeID.AutoSelect; - settingsSelect &= Core.Settings["AgateLib"].TryGetValue("AudioDriver", out text); - - if (settingsSelect) - { - info = FindDriverInfo(audioDrivers, text); - - if (info == null) - settingsSelect = false; - } - - if (settingsSelect == false) - info = FindDriverInfo(audioDrivers, (int)audioType); - - if (info == null) - throw new AgateException(string.Format("Could not find the driver {0}.", audioType)); - - return (AudioImpl)CreateDriverInstance(info); - } - internal static InputImpl CreateInputDriver(InputTypeID inputType) - { - if (inputDrivers.Count == 0) - throw new AgateException("No audio drivers registered."); - - AgateDriverInfo info = null; - string text; - - bool settingsSelect = inputType == InputTypeID.AutoSelect; - settingsSelect &= Core.Settings["AgateLib"].TryGetValue("AudioDriver", out text); - - if (settingsSelect) - { - info = FindDriverInfo(inputDrivers, text); - - if (info == null) - settingsSelect = false; - } - - if (settingsSelect == false) - info = FindDriverInfo(inputDrivers, (int)inputType); - - if (info == null) - throw new AgateException(string.Format("Could not find the driver {0}.", inputType)); - - return (InputImpl)CreateDriverInstance(info); - } - - private static AgateDriverInfo FindDriverInfo(List<AgateDriverInfo> driverList, string matchText) - { - AgateDriverInfo retval = null; - - if (driverList.Count == 0) - return null; - - foreach(AgateDriverInfo info in driverList) - { - if (info.FriendlyName.Contains(matchText)) - retval = info; - } - - return retval; - } - private static AgateDriverInfo FindDriverInfo(List<AgateDriverInfo> driverList, int typeID) - { - AgateDriverInfo theInfo = null; - - if (driverList.Count == 0) - return null; - - // autoselect ID's are all zero - if (typeID == 0) - return driverList[0]; - - foreach (AgateDriverInfo info in driverList) - { - if (info.DriverTypeID != typeID) - continue; - - theInfo = info; - } - return theInfo; - } - private static AgateDriverInfo FindDriverInfo(IEnumerable<AgateDriverInfo> driverList, string assemblyFullName) - { - AgateDriverInfo theInfo = null; - - foreach (AgateDriverInfo info in driverList) - { - if (info.AssemblyName != assemblyFullName) - continue; - - theInfo = info; - } - return theInfo; - } - - private static object CreateDriverInstance(AgateDriverInfo info) - { - Assembly ass = Assembly.Load(info.AssemblyName); - - Type driverType = ass.GetType(info.DriverTypeName, false); - - if (driverType == null) - throw new AgateException(string.Format( - "Could not find the type {0} in the library {1}.", - info.DriverTypeName, - ass.FullName)); - - return Activator.CreateInstance(driverType); - } - - private static Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args) - { - AgateDriverInfo info = null; - - info = info ?? FindDriverInfo(displayDrivers, args.Name); - info = info ?? FindDriverInfo(audioDrivers, args.Name); - info = info ?? FindDriverInfo(inputDrivers, args.Name); - info = info ?? FindDriverInfo(desktopDrivers, args.Name); - - if (info == null) - return null; - - return LoadAssemblyLoadFrom(info); - } - - private static Assembly LoadAssemblyLoadFrom(AgateDriverInfo info) - { - Core.ErrorReporting.Report(ErrorLevel.Warning, - string.Format("Assembly {0} was loaded in the LoadFrom context. Move it to the application directory to load in the Load context.", info.AssemblyName), null); - return Assembly.LoadFrom(info.AssemblyFile); - } - - /// <summary> - /// Returns a collection with all the DriverInfo<DisplayTypeID> structures for - /// registered display drivers. - /// </summary> - /// <returns></returns> - public static List<AgateDriverInfo> DisplayDrivers - { - get { return displayDrivers; } - } - /// <summary> - /// Returns a collection with all the DriverInfo<AudioTypeID> structures for - /// registered display drivers. - /// </summary> - /// <returns></returns> - public static List<AgateDriverInfo> AudioDrivers - { - get { return audioDrivers; } - } - /// <summary> - /// Returns a collection with all the DriverInfo<InputTypeID> structures for - /// registered display drivers. - /// </summary> - /// <returns></returns> - public static List<AgateDriverInfo> InputDrivers - { - get { return inputDrivers; } - } - - - } -} +// The contents of this file are subject to the Mozilla Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.mozilla.org/MPL/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations +// under the License. +// +// The Original Code is AgateLib. +// +// The Initial Developer of the Original Code is Erik Ylvisaker. +// Portions created by Erik Ylvisaker are Copyright (C) 2006-2011. +// All Rights Reserved. +// +// Contributor(s): Erik Ylvisaker +// +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Reflection; +using System.Text; +using AgateLib.AudioLib.ImplementationBase; +using AgateLib.DisplayLib.ImplementationBase; +using AgateLib.InputLib.ImplementationBase; +using AgateLib.Utility; + +namespace AgateLib.Drivers +{ + /// <summary> + /// Static class with which drivers register themselves so that the library can + /// instantiate them. + /// </summary> + public static class Registrar + { + private static List<AgateDriverInfo> + displayDrivers = new List<AgateDriverInfo>(), + audioDrivers = new List<AgateDriverInfo>(), + inputDrivers = new List<AgateDriverInfo>(), + desktopDrivers = new List<AgateDriverInfo>(); + + private static bool mIsInitialized = false; + + private static IDesktopDriver mDesktop; + + private static readonly string[] KnownNativeLibraries = new string[] + { + "SDL.dll", + "SDL_mixer.dll", + "libogg-0.dll", + "libvorbis-0.dll", + "libvorbisfile-3.dll", + }; + + + static bool Contains(this IEnumerable<AgateDriverInfo> list, DisplayTypeID type) + { + return list.Any( + x => Comparator(x, DriverType.Display, (int)type)); + } + static bool Contains(this IEnumerable<AgateDriverInfo> list, AudioTypeID type) + { + return list.Any( + x => Comparator(x, DriverType.Audio, (int)type)); + } + static bool Contains(this IEnumerable<AgateDriverInfo> list, InputTypeID type) + { + return list.Any( + x => Comparator(x, DriverType.Input, (int)type)); + } + static bool Comparator(AgateDriverInfo info, DriverType driverType, int type) + { + return info.DriverType == driverType && info.DriverTypeID == type; + } + + static Registrar() + { + } + /// <summary> + /// Searches through FileManager.AssemblyPath for all *.dll files. These files + /// are loaded and searched for classes which derive from DisplayImpl, AudioImpl, etc. + /// </summary> + internal static void Initialize() + { + if (mIsInitialized) + return; + + RegisterNullDrivers(); + + AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve); + AppDomain sandbox = AppDomain.CreateDomain("AgateSandBox"); + + AgateSandBoxLoader loader = (AgateSandBoxLoader) + sandbox.CreateInstanceAndUnwrap(Assembly.GetExecutingAssembly().FullName, + typeof(AgateSandBoxLoader).FullName); + + IEnumerable<string> files = AgateFileProvider.Assemblies.GetAllFiles("*.dll"); + + foreach (string file in files) + { + if (ShouldSkipLibrary(file)) + continue; + + foreach (AgateDriverInfo info in loader.ReportDrivers(file)) + { + switch (info.DriverType) + { + case DriverType.Display: + displayDrivers.Add(info); + break; + + case DriverType.Audio: + audioDrivers.Add(info); + break; + + case DriverType.Input: + inputDrivers.Add(info); + break; + + case DriverType.Desktop: + desktopDrivers.Add(info); + break; + + default: + Core.ErrorReporting.Report(ErrorLevel.Warning, string.Format( + "Could not interpret DriverType returned by type {0} in assembly {1}.", + info.DriverTypeName, info.AssemblyFile), null); + + break; + } + } + } + + AppDomain.Unload(sandbox); + + SortDriverInfo(displayDrivers); + SortDriverInfo(audioDrivers); + SortDriverInfo(inputDrivers); + SortDriverInfo(desktopDrivers); + + mIsInitialized = true; + } + private static void SortDriverInfo(List<AgateDriverInfo> driverList) + { + // sorts the driver list in reverse order. + driverList.Sort(delegate(AgateDriverInfo a, AgateDriverInfo b) + { + return -a.Priority.CompareTo(b.Priority); + }); + } + + private static void RegisterNullDrivers() + { + Assembly thisAssembly = Assembly.GetExecutingAssembly(); + + AgateDriverInfo nullAudioInfo = new AgateDriverInfo(AudioTypeID.Silent, + typeof(NullSoundImpl), "No audio", -100); + + nullAudioInfo.AssemblyFile = thisAssembly.CodeBase; + nullAudioInfo.AssemblyName = thisAssembly.FullName; + + audioDrivers.Add(nullAudioInfo); + + AgateDriverInfo nullInputInfo = new AgateDriverInfo(InputTypeID.Silent, + typeof(NullInputImpl), "No input", -100); + + nullInputInfo.AssemblyFile = thisAssembly.CodeBase; + nullInputInfo.AssemblyName = thisAssembly.FullName; + + inputDrivers.Add(nullInputInfo); + } + + private static bool ShouldSkipLibrary(string file) + { + // Native libraries in the same directory will give an error when loaded, + // so skip any ones that we know about that will probably be in the same + // directory as the drivers. + if (IsKnownNativeLibrary(file)) + return true; + + // hack, because mono crashes if AgateMDX.dll is present. + // annoying, because it should report a failure to load the types in the + // assembly, and then the try catch should continue after that. + // TODO: this hack seems unnecessary in recent versions of Mono. Should it be removed? + if ((Environment.OSVersion.Platform == PlatformID.Unix || + Environment.OSVersion.Platform == (PlatformID)128) && + (System.IO.Path.GetFileName(file).ToLower().Contains("agatemdx.dll") || + System.IO.Path.GetFileName(file).ToLower().Contains("agatesdx.dll"))) + { + Core.ErrorReporting.Report(ErrorLevel.Comment, + string.Format("DirectX not supported on non-Windows platforms. {0}Remove {1} to eliminate this message.", + Environment.NewLine, System.IO.Path.GetFileName(file)), null); + + return true; + } + + // Skip the agatelib dll. + if (System.IO.Path.GetFileName(file).ToLower().Contains("agatelib.dll")) + return true; + + return false; + } + private static bool IsKnownNativeLibrary(string path) + { + string filename = System.IO.Path.GetFileName(path).ToLowerInvariant(); + + for (int i = 0; i < KnownNativeLibraries.Length; i++) + { + if (KnownNativeLibraries[i].ToLowerInvariant() == filename) + return true; + } + return false; + } + + + /// <summary> + /// Asks the user to select which drivers to use. + /// </summary> + /// <param name="chooseDisplay"></param> + /// <param name="chooseAudio"></param> + /// <param name="chooseInput"></param> + /// <param name="selectedDisplay"></param> + /// <param name="selectedAudio"></param> + /// <param name="selectedInput"></param> + /// <returns></returns> + internal static bool UserSelectDrivers(bool chooseDisplay, bool chooseAudio, bool chooseInput, + DisplayTypeID preferredDisplay, AudioTypeID preferredAudio, InputTypeID preferredInput, + out DisplayTypeID selectedDisplay, out AudioTypeID selectedAudio, out InputTypeID selectedInput) + { + if (mDesktop == null) + { + CreateDesktopDriver(); + + if (mDesktop == null) + { + SelectBestDrivers(chooseDisplay, chooseAudio, chooseInput, + preferredDisplay, preferredAudio, preferredInput, + out selectedDisplay, out selectedAudio, out selectedInput); + + return true; + } + } + + IUserSetSystems frm = mDesktop.CreateUserSetSystems(); + + // set default values. + selectedDisplay = DisplayTypeID.AutoSelect; + selectedAudio = AudioTypeID.AutoSelect; + selectedInput = InputTypeID.AutoSelect; + + foreach (AgateDriverInfo info in displayDrivers) + { + frm.AddDisplayType(info); + } + foreach (AgateDriverInfo info in audioDrivers) + { + frm.AddAudioType(info); + } + foreach (AgateDriverInfo info in inputDrivers) + { + frm.AddInputType(info); + } + + frm.SetChoices(chooseDisplay, chooseAudio, chooseInput, + preferredDisplay, preferredAudio, preferredInput); + + // run the dialog asking user which drivers to use. + if (frm.RunDialog() == SetSystemsDialogResult.Cancel) + { + return false; + } + + selectedDisplay = frm.DisplayType; + selectedAudio = frm.AudioType; + selectedInput = frm.InputType; + + return true; + + } + + private static void SelectBestDrivers(bool chooseDisplay, bool chooseAudio, bool chooseInput, + DisplayTypeID preferredDisplay, AudioTypeID preferredAudio, InputTypeID preferredInput, + out DisplayTypeID selectedDisplay, out AudioTypeID selectedAudio, out InputTypeID selectedInput) + { + // initial return values if a driver isn't selected. + selectedDisplay = DisplayTypeID.AutoSelect; + selectedAudio = AudioTypeID.AutoSelect; + selectedInput = InputTypeID.AutoSelect; + + if (preferredDisplay != DisplayTypeID.AutoSelect && displayDrivers.Contains(preferredDisplay)) + selectedDisplay = preferredDisplay; + else if (displayDrivers.Count > 0) + selectedDisplay = (DisplayTypeID)displayDrivers[0].DriverTypeID; + + if (preferredAudio != AudioTypeID.AutoSelect && audioDrivers.Contains(preferredAudio)) + selectedAudio = preferredAudio; + else if (audioDrivers.Count > 0) + selectedAudio = (AudioTypeID)audioDrivers[0].DriverTypeID; + + if (preferredInput != InputTypeID.AutoSelect && inputDrivers.Contains(preferredInput)) + selectedInput = preferredInput; + else if (inputDrivers.Count > 0) + selectedInput = (InputTypeID)inputDrivers[0].DriverTypeID; + } + + private static void CreateDesktopDriver() + { + if (desktopDrivers.Count == 0) + return; + + mDesktop = (IDesktopDriver)CreateDriverInstance(desktopDrivers[0]); + } + + internal static IDesktopDriver WinForms + { + get { return mDesktop; } + } + + internal static DisplayImpl CreateDisplayDriver(DisplayTypeID displayType) + { + if (displayDrivers.Count == 0) + throw new AgateException("No display drivers registered."); + + AgateDriverInfo info = null; + string text; + + bool settingsSelect = displayType == DisplayTypeID.AutoSelect; + settingsSelect &= Core.Settings["AgateLib"].TryGetValue("DisplayDriver", out text); + + if (settingsSelect) + { + info = FindDriverInfo(displayDrivers, text); + + if (info == null) + settingsSelect = false; + } + + if (settingsSelect == false) + info = FindDriverInfo(displayDrivers, (int)displayType); + + if (info == null) + throw new AgateException(string.Format("Could not find the driver {0}.", displayType)); + + return (DisplayImpl)CreateDriverInstance(info); + } + internal static AudioImpl CreateAudioDriver(AudioTypeID audioType) + { + if (audioDrivers.Count == 0) + throw new AgateException("No audio drivers registered."); + + AgateDriverInfo info = null; + string text; + + bool settingsSelect = audioType == AudioTypeID.AutoSelect; + settingsSelect &= Core.Settings["AgateLib"].TryGetValue("AudioDriver", out text); + + if (settingsSelect) + { + info = FindDriverInfo(audioDrivers, text); + + if (info == null) + settingsSelect = false; + } + + if (settingsSelect == false) + info = FindDriverInfo(audioDrivers, (int)audioType); + + if (info == null) + throw new AgateException(string.Format("Could not find the driver {0}.", audioType)); + + return (AudioImpl)CreateDriverInstance(info); + } + internal static InputImpl CreateInputDriver(InputTypeID inputType) + { + if (inputDrivers.Count == 0) + throw new AgateException("No audio drivers registered."); + + AgateDriverInfo info = null; + string text; + + bool settingsSelect = inputType == InputTypeID.AutoSelect; + settingsSelect &= Core.Settings["AgateLib"].TryGetValue("InputDriver", out text); + + if (settingsSelect) + { + info = FindDriverInfo(inputDrivers, text); + + if (info == null) + settingsSelect = false; + } + + if (settingsSelect == false) + info = FindDriverInfo(inputDrivers, (int)inputType); + + if (info == null) + throw new AgateException(string.Format("Could not find the driver {0}.", inputType)); + + return (InputImpl)CreateDriverInstance(info); + } + + private static AgateDriverInfo FindDriverInfo(List<AgateDriverInfo> driverList, string matchText) + { + AgateDriverInfo retval = null; + + if (driverList.Count == 0) + return null; + + foreach(AgateDriverInfo info in driverList) + { + if (info.FriendlyName.Contains(matchText)) + retval = info; + } + + return retval; + } + private static AgateDriverInfo FindDriverInfo(List<AgateDriverInfo> driverList, int typeID) + { + AgateDriverInfo theInfo = null; + + if (driverList.Count == 0) + return null; + + // autoselect ID's are all zero + if (typeID == 0) + return driverList[0]; + + foreach (AgateDriverInfo info in driverList) + { + if (info.DriverTypeID != typeID) + continue; + + theInfo = info; + } + return theInfo; + } + private static AgateDriverInfo FindDriverInfo(IEnumerable<AgateDriverInfo> driverList, string assemblyFullName) + { + AgateDriverInfo theInfo = null; + + foreach (AgateDriverInfo info in driverList) + { + if (info.AssemblyName != assemblyFullName) + continue; + + theInfo = info; + } + return theInfo; + } + + private static object CreateDriverInstance(AgateDriverInfo info) + { + Assembly ass = Assembly.Load(info.AssemblyName); + + Type driverType = ass.GetType(info.DriverTypeName, false); + + if (driverType == null) + throw new AgateException(string.Format( + "Could not find the type {0} in the library {1}.", + info.DriverTypeName, + ass.FullName)); + + return Activator.CreateInstance(driverType); + } + + private static Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args) + { + AgateDriverInfo info = null; + + info = info ?? FindDriverInfo(displayDrivers, args.Name); + info = info ?? FindDriverInfo(audioDrivers, args.Name); + info = info ?? FindDriverInfo(inputDrivers, args.Name); + info = info ?? FindDriverInfo(desktopDrivers, args.Name); + + if (info == null) + return null; + + return LoadAssemblyLoadFrom(info); + } + + private static Assembly LoadAssemblyLoadFrom(AgateDriverInfo info) + { + Core.ErrorReporting.Report(ErrorLevel.Warning, + string.Format("Assembly {0} was loaded in the LoadFrom context. Move it to the application directory to load in the Load context.", info.AssemblyName), null); + return Assembly.LoadFrom(info.AssemblyFile); + } + + /// <summary> + /// Returns a collection with all the DriverInfo<DisplayTypeID> structures for + /// registered display drivers. + /// </summary> + /// <returns></returns> + public static List<AgateDriverInfo> DisplayDrivers + { + get { return displayDrivers; } + } + /// <summary> + /// Returns a collection with all the DriverInfo<AudioTypeID> structures for + /// registered display drivers. + /// </summary> + /// <returns></returns> + public static List<AgateDriverInfo> AudioDrivers + { + get { return audioDrivers; } + } + /// <summary> + /// Returns a collection with all the DriverInfo<InputTypeID> structures for + /// registered display drivers. + /// </summary> + /// <returns></returns> + public static List<AgateDriverInfo> InputDrivers + { + get { return inputDrivers; } + } + + + } +} Modified: trunk/AgateLib/Platform.cs =================================================================== --- trunk/AgateLib/Platform.cs 2011-11-22 17:57:40 UTC (rev 1306) +++ trunk/AgateLib/Platform.cs 2011-11-22 21:12:54 UTC (rev 1307) @@ -1,367 +1,368 @@ -// The contents of this file are subject to the Mozilla Public License -// Version 1.1 (the "License"); you may not use this file except in -// compliance with the License. You may obtain a copy of the License at -// http://www.mozilla.org/MPL/ -// -// Software distributed under the License is distributed on an "AS IS" -// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the -// License for the specific language governing rights and limitations -// under the License. -// -// The Original Code is AgateLib. -// -// The Initial Developer of the Original Code is Erik Ylvisaker. -// Portions created by Erik Ylvisaker are Copyright (C) 2006-2011. -// All Rights Reserved. -// -// Contributor(s): Erik Ylvisaker -// -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.IO; -using System.Linq; -using System.Text; -using System.Reflection; -using System.Runtime.InteropServices; - -namespace AgateLib -{ - /// <summary> - /// Class which contains known information about the platform. - /// This class also contains the folders where the application should store its data, - /// which are automatically created from the AssemblyCompanhy and AssemblyProduct - /// attributes for the assembly where the entry point for the application is. - /// </summary> - public class Platform - { - PlatformType mType; - DotNetRuntime mRuntime; - WindowsVersion mWindowsVersion; - string mDocuments; - string mAppData; - string mAppDir; - bool m64Bit; - - internal Platform() - { - mType = DetectPlatformType(); - mRuntime = DetectRuntime(); - m64Bit = Detect64Bit(); - - // According to http://msdn.microsoft.com/query/dev10.query?appId=Dev10IDEF1&l=EN-US&k=k%28SYSTEM.DIAGNOSTICS.DEBUG.LISTENERS%29;k%28TargetFrameworkMoniker-%22.NETFRAMEWORK%2cVERSION%3dV3.5%22%29;k%28DevLang-CSHARP%29&rd=true - // The Listeners collection is shared by both the Debug and the Trace classes; - // adding a trace listener to either class adds the listener to both. - // So we will just use the Trace.Listeners class. - if (PlatformType != PlatformType.Windows) - { - Trace.Listeners.Add(new TextWriterTraceListener(Console.Out)); - } - - CheckOSVersion(); - - if (mType == PlatformType.Windows) - mWindowsVersion = DetectWindowsVersion(); - - SetFolders(); - - string debugLog = "agate-debuglog.txt"; - - if (HasWriteAccessToAppDirectory()) - { - debugLog = Path.Combine(mAppDir, debugLog); - } - else - { - debugLog = Path.Combine(mAppData, debugLog); - } - - try - { - Trace.Listeners.Add(new TextWriterTraceListener(new StreamWriter(debugLog))); - } - catch (Exception) - { - Trace.WriteLine("Could not open debug or trace log for writing."); - } - - Trace.WriteLine("64-bit platform: " + m64Bit.ToString()); - } - - private bool Detect64Bit() - { - int size = Marshal.SizeOf(typeof(IntPtr)); - - switch (size) - { - case 4: return false; - case 8: return true; - default: - throw new AgateException(string.Format("Size of IntPtr is {0}.", size)); - } - } - - private bool HasWriteAccessToAppDirectory() - { - // TODO: Maybe there is a better way to inspect permissions? - // here we just stry to write and see if we fail. - string filename = Path.GetTempFileName(); - - try - { - string targetFile = Path.Combine(mAppDir, Path.GetFileName(filename)); - - using (var w = new StreamWriter(targetFile)) - { - w.WriteLine("x"); - } - - File.Delete(targetFile); - return true; - } - catch - { - return false; - } - } - - internal void EnsureAppDataDirectoryExists() - { - if (Directory.Exists(AppDataDirectory)) - return; - - Directory.CreateDirectory(AppDataDirectory); - } - - /// <summary> - /// Gets the directory where the application should store its configuration data. - /// </summary> - public string AppDataDirectory - { - get { return mAppData; } - } - - static T GetCustomAttribute<T>(Assembly ass) where T : Attribute - { - try - { - return ass.GetCustomAttributes(typeof(T), false)[0] as T; - } - catch - { - return null; - } - } - private void SetFolders() - { - Assembly entryPt = Assembly.GetEntryAssembly(); - string fqn = entryPt.GetLoadedModules()[0].FullyQualifiedName; - - var companyAttribute = GetCustomAttribute<AssemblyCompanyAttribute>(entryPt); - var nameAttribute = GetCustomAttribute<AssemblyProductAttribute>(entryPt); - - mAppDir = Path.GetDirectoryName(fqn); - Console.WriteLine("App Dir: {0}", mAppDir); - - string companyName = companyAttribute != null ? companyAttribute.Company : string.Empty; - string product = nameAttribute != null ? nameAttribute.Product : string.Empty; - - SetFolderPaths(companyName, product); - } - - /// <summary> - /// Sets the folder paths for data based on the company name and application name. - /// This only needs to be called if the values used in the AssemblyCompany and - /// AssemblyProduct are not what you want to use to define these locations. - /// </summary> - /// <param name="companyName"></param> - /// <param name="appName"></param> - public void SetFolderPaths(string companyName, string appName) - { - string combDir = Path.Combine(companyName, appName); - - if (string.IsNullOrEmpty(combDir)) - { - mAppData = mAppDir; - Trace.WriteLine("Warning: No assembly level company / product name attributes were found."); - } - else - mAppData = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); - - mDocuments = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); - - mAppData = Path.Combine(mAppData, combDir); - mDocuments = Path.Combine(mDocuments, combDir); - - Console.WriteLine("App Data: {0}", mAppData); - Console.WriteLine("Documents: {0}", mDocuments); - - } - - private DotNetRuntime DetectRuntime() - { - DotNetRuntime runtime = DotNetRuntime.MicrosoftDotNet; - - if (Type.GetType("Mono.Runtime") != null) - runtime = DotNetRuntime.Mono; - - return runtime; - } - - /// <summary> - /// Returns the version of windows being used, if the current platform is Windows. - /// An exception is thrown if this property is checked when the platform is not Windows. - /// </summary> - public WindowsVersion WindowsVersion - { - get - { - if (PlatformType != PlatformType.Windows) - throw new AgateCrossPlatformException( - "Current platform is not Windows, but the WindowsVersion propety was checked."); - - return mWindowsVersion; - } - } - - /// <summary> - /// Gets the platform type. - /// </summary> - public PlatformType PlatformType - { - get { return mType; } - } - /// <summary> - /// Gets the runtime being used. - /// </summary> - public DotNetRuntime Runtime - { - get { return mRuntime; } - } - - PlatformType DetectPlatformType() - { - switch (Environment.OSVersion.Platform) - { - case PlatformID.WinCE: - case PlatformID.Win32NT: - case PlatformID.Win32S: - case PlatformID.Win32Windows: - return AgateLib.PlatformType.Windows; - - case PlatformID.Unix: - string kernel = DetectUnixKernel(); - - if (kernel == "Darwin") - return PlatformType.MacOS; - else - return PlatformType.Linux; - - case PlatformID.MacOSX: - return PlatformType.MacOS; - - case PlatformID.Xbox: - return PlatformType.XBox360; - } - - return PlatformType.Unknown; - } - - #region private static string DetectUnixKernel() - - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] - struct utsname - { - [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)] - public string sysname; - - [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)] - public string nodename; - - [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)] - public string release; - - [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)] - public string version; - - [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)] - public string machine; - - [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 1024)] - private string extraJustInCase; - - } - - /// <summary> - /// Detects the unix kernel by p/invoking the uname call in libc. - /// </summary> - /// <returns></returns> - private static string DetectUnixKernel() - { - Debug.Print("Size: {0}", Marshal.SizeOf(typeof(utsname)).ToString()); - Debug.Flush(); - - utsname uts = new utsname(); - uname(out uts); - - Debug.WriteLine("System:"); - Debug.Indent(); - Debug.WriteLine(uts.sysname); - Debug.WriteLine(uts.nodename); - Debug.WriteLine(uts.release); - Debug.WriteLine(uts.version); - Debug.WriteLine(uts.machine); - Debug.Unindent(); - - return uts.sysname.ToString(); - } - - [DllImport("libc")] - private static extern void uname(out utsname uname_struct); - - #endregion - - - private void CheckOSVersion() - { - var version = System.Environment.OSVersion.Version; - - Debug.Print("OS Version: {0}", System.Environment.OSVersion.VersionString); - Debug.IndentLevel++; - Debug.Print("Major: {0}", version.Major); - Debug.Print("Major revision: {0}", version.MajorRevision); - Debug.Print("Minor: {0}", version.Minor); - Debug.Print("Minor revision: {0}", version.MinorRevision); - Debug.Print("Revision: {0}", version.Revision); - Debug.Print("Build: {0}", version.Build); - Debug.Print("Service Pack: {0}", System.Environment.OSVersion.ServicePack); - Debug.IndentLevel--; - } - - private WindowsVersion DetectWindowsVersion() - { - WindowsVersion retval = WindowsVersion.WindowsVista; - - switch (System.Environment.OSVersion.Version.Major) - { - case 4: - retval = WindowsVersion.Windows98; - break; - case 5: - retval = WindowsVersion.WindowsXP; - break; - case 6: - retval = WindowsVersion.WindowsVista; - break; - case 7: - retval = WindowsVersion.Windows7; - break; - case 8: - retval = WindowsVersion.Windows8; - } - - return retval; - } - - } -} +// The contents of this file are subject to the Mozilla Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.mozilla.org/MPL/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations +// under the License. +// +// The Original Code is AgateLib. +// +// The Initial Developer of the Original Code is Erik Ylvisaker. +// Portions created by Erik Ylvisaker are Copyright (C) 2006-2011. +// All Rights Reserved. +// +// Contributor(s): Erik Ylvisaker +// +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Linq; +using System.Text; +using System.Reflection; +using System.Runtime.InteropServices; + +namespace AgateLib +{ + /// <summary> + /// Class which contains known information about the platform. + /// This class also contains the folders where the application should store its data, + /// which are automatically created from the AssemblyCompanhy and AssemblyProduct + /// attributes for the assembly where the entry point for the application is. + /// </summary> + public class Platform + { + PlatformType mType; + DotNetRuntime mRuntime; + WindowsVersion mWindowsVersion; + string mDocuments; + string mAppData; + string mAppDir; + bool m64Bit; + + internal Platform() + { + mType = DetectPlatformType(); + mRuntime = DetectRuntime(); + m64Bit = Detect64Bit(); + + // According to http://msdn.microsoft.com/query/dev10.query?appId=Dev10IDEF1&l=EN-US&k=k%28SYSTEM.DIAGNOSTICS.DEBUG.LISTENERS%29;k%28TargetFrameworkMoniker-%22.NETFRAMEWORK%2cVERSION%3dV3.5%22%29;k%28DevLang-CSHARP%29&rd=true + // The Listeners collection is shared by both the Debug and the Trace classes; + // adding a trace listener to either class adds the listener to both. + // So we will just use the Trace.Listeners class. + if (PlatformType != PlatformType.Windows) + { + Trace.Listeners.Add(new TextWriterTraceListener(Console.Out)); + } + + CheckOSVersion(); + + if (mType == PlatformType.Windows) + mWindowsVersion = DetectWindowsVersion(); + + SetFolders(); + + string debugLog = "agate-debuglog.txt"; + + if (HasWriteAccessToAppDirectory()) + { + debugLog = Path.Combine(mAppDir, debugLog); + } + else + { + debugLog = Path.Combine(mAppData, debugLog); + } + + try + { + Trace.Listeners.Add(new TextWriterTraceListener(new StreamWriter(debugLog))); + } + catch (Exception) + { + Trace.WriteLine("Could not open debug or trace log for writing."); + } + + Trace.WriteLine("64-bit platform: " + m64Bit.ToString()); + } + + private bool Detect64Bit() + { + int size = Marshal.SizeOf(typeof(IntPtr)); + + switch (size) + { + case 4: return false; + case 8: return true; + default: + throw new AgateException(string.Format("Size of IntPtr is {0}.", size)); + } + } + + private bool HasWriteAccessToAppDirectory() + { + // TODO: Maybe there is a better way to inspect permissions? + // here we just stry to write and see if we fail. + string filename = Path.GetTempFileName(); + + try + { + string targetFile = Path.Combine(mAppDir, Path.GetFileName(filename)); + + using (var w = new StreamWriter(targetFile)) + { + w.WriteLine("x"); + } + + File.Delete(targetFile); + return true; + } + catch + { + return false; + } + } + + internal void EnsureAppDataDirectoryExists() + { + if (Directory.Exists(AppDataDirectory)) + return; + + Directory.CreateDirectory(AppDataDirectory); + } + + /// <summary> + /// Gets the directory where the application should store its configuration data. + /// </summary> + public string AppDataDirectory + { + get { return mAppData; } + } + + static T GetCustomAttribute<T>(Assembly ass) where T : Attribute + { + try + { + return ass.GetCustomAttributes(typeof(T), false)[0] as T; + } + catch + { + return null; + } + } + private void SetFolders() + { + Assembly entryPt = Assembly.GetEntryAssembly(); + string fqn = entryPt.GetLoadedModules()[0].FullyQualifiedName; + + var companyAttribute = GetCustomAttribute<AssemblyCompanyAttribute>(entryPt); + var nameAttribute = GetCustomAttribute<AssemblyProductAttribute>(entryPt); + + mAppDir = Path.GetDirectoryName(fqn); + Console.WriteLine("App Dir: {0}", mAppDir); + + string companyName = companyAttribute != null ? companyAttribute.Company : string.Empty; + string product = nameAttribute != null ? nameAttribute.Product : string.Empty; + + SetFolderPaths(companyName, product); + } + + /// <summary> + /// Sets the folder paths for data based on the company name and application name. + /// This only needs to be called if the values used in the AssemblyCompany and + /// AssemblyProduct are not what you want to use to define these locations. + /// </summary> + /// <param name="companyName"></param> + /// <param name="appName"></param> + public void SetFolderPaths(string companyName, string appName) + { + string combDir = Path.Combine(companyName, appName); + + if (string.IsNullOrEmpty(combDir)) + { + mAppData = mAppDir; + Trace.WriteLine("Warning: No assembly level company / product name attributes were found."); + } + else + mAppData = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); + + mDocuments = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); + + mAppData = Path.Combine(mAppData, combDir); + mDocuments = Path.Combine(mDocuments, combDir); + + Console.WriteLine("App Data: {0}", mAppData); + Console.WriteLine("Documents: {0}", mDocuments); + + } + + private DotNetRuntime DetectRuntime() + { + DotNetRuntime runtime = DotNetRuntime.MicrosoftDotNet; + + if (Type.GetType("Mono.Runtime") != null) + runtime = DotNetRuntime.Mono; + + return runtime; + } + + /// <summary> + /// Returns the version of windows being used, if the current platform is Windows. + /// An exception is thrown if this property is checked when the platform is not Windows. + /// </summary> + public WindowsVersion WindowsVersion + { + get + { + if (PlatformType != PlatformType.Windows) + throw new AgateCrossPlatformException( + "Current platform is not Windows, but the WindowsVersion propety was checked."); + + return mWindowsVersion; + } + } + + /// <summary> + /// Gets the platform type. + /// </summary> + public PlatformType PlatformType + { + get { return mType; } + } + /// <summary> + /// Gets the runtime being used. + /// </summary> + public DotNetRuntime Runtime + { + get { return mRuntime; } + } + + PlatformType DetectPlatformType() + { + switch (Environment.OSVersion.Platform) + { + case PlatformID.WinCE: + case PlatformID.Win32NT: + case PlatformID.Win32S: + case PlatformID.Win32Windows: + return AgateLib.PlatformType.Windows; + + case PlatformID.Unix: + string kernel = DetectUnixKernel(); + + if (kernel == "Darwin") + return PlatformType.MacOS; + else + return PlatformType.Linux; + + case PlatformID.MacOSX: + return PlatformType.MacOS; + + case PlatformID.Xbox: + return PlatformType.XBox360; + } + + return PlatformType.Unknown; + } + + #region private static string DetectUnixKernel() + + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] + struct utsname + { + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)] + public string sysname; + + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)] + public string nodename; + + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)] + public string release; + + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)] + public string version; + + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)] + public string machine; + + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 1024)] + private string extraJustInCase; + + } + + /// <summary> + /// Detects the unix kernel by p/invoking the uname call in libc. + /// </summary> + /// <returns></returns> + private static string DetectUnixKernel() + { + Debug.Print("Size: {0}", Marshal.SizeOf(typeof(utsname)).ToString()); + Debug.Flush(); + + utsname uts = new utsname(); + uname(out uts); + + Debug.WriteLine("System:"); + Debug.Indent(); + Debug.WriteLine(uts.sysname); + Debug.WriteLine(uts.nodename); + Debug.WriteLine(uts.release); + Debug.WriteLine(uts.version); + Debug.WriteLine(uts.machine); + Debug.Unindent(); + + return uts.sysname.ToString(); + } + + [DllImport("libc")] + private static extern void uname(out utsname uname_struct); + + #endregion + + + private void CheckOSVersion() + { + var version = System.Environment.OSVersion.Version; + + Debug.Print("OS Version: {0}", System.Environment.OSVersion.VersionString); + Debug.IndentLevel++; + Debug.Print("Major: {0}", version.Major); + Debug.Print("Major revision: {0}", version.MajorRevision); + Debug.Print("Minor: {0}", version.Minor); + Debug.Print("Minor revision: {0}", version.MinorRevision); + Debug.Print("Revision: {0}", version.Revision); + Debug.Print("Build: {0}", version.Build); + Debug.Print("Service Pack: {0}", System.Environment.OSVersion.ServicePack); + Debug.IndentLevel--; + } + + private WindowsVersion DetectWindowsVersion() + { + WindowsVersion retval = WindowsVersion.WindowsVista; + + switch (System.Environment.OSVersion.Version.Major) + { + case 4: + retval = WindowsVersion.Windows98; + break; + case 5: + retval = WindowsVersion.WindowsXP; + break; + case 6: + retval = WindowsVersion.WindowsVista; + break; + case 7: + retval = WindowsVersion.Windows7; + break; + case 8: + retval = WindowsVersion.Windows8; + break; + } + + return retval; + } + + } +} Added: trunk/AgateLib/Settings/ISettingsTracer.cs =================================================================== --- trunk/AgateLib/Settings/ISettingsTracer.cs (rev 0) +++ trunk/AgateLib/Settings/ISettingsTracer.cs 2011-11-22 21:12:54 UTC (rev 1307) @@ -0,0 +1,29 @@ +// The contents of this file are subject to the Mozilla Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.mozilla.org/MPL/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations +// under the License. +// +// The Original Code is AgateLib. +// +// The Initial Developer of the Original Code is Erik Ylvisaker. +// Portions created by Erik Ylvisaker are Copyright (C) 2006-2011. +// All Rights Reserved. +// +// Contributor(s): Erik Ylvisaker +// +using System; + +namespace AgateLib.Settings +{ + public interface ISettingsTracer + { + void OnReadSetting(string groupName, string key, string value); + void OnWriteSetting(string groupName, string key, string value); + } +} + Modified: trunk/AgateLib/Settings/PersistantSettings.cs =================================================================== --- trunk/AgateLib/Settings/PersistantSettings.cs 2011-11-22 17:57:40 UTC (rev 1306) +++ trunk/AgateLib/Settings/PersistantSettings.cs 2011-11-22 21:12:54 UTC (rev 1307) @@ -18,6 +18,7 @@ // using System; using System.Collections.Generic; +using System.Diagnostics; using System.IO; using System.Linq; using System.Text; @@ -30,7 +31,7 @@ /// in named groups, and within each group an individual setting is a key/value pair. /// These settings are stored on a per-user basis. /// </summary> - /// <remarks>On Windows Vista the file is stored in + /// <remarks>On Windows Vista and up the file is stored in /// %HOME%\AppData\Company Name\Application Name\settings.xml. /// On Unix the file is stored at /// $HOME/.config/Company Name/Application Name/settings.xml. @@ -43,7 +44,41 @@ { LoadSettings(); } - + + public ISettingsTracer SettingsTracer { get; set; } + + /// <summary> + /// Gets or sets a value indicating whether this <see cref="AgateLib.Settings.PersistantSettings"/> is in + /// debugging mode. If true, every access to a setting value will be echoed to System.Diagnostics.Trace. + /// </summary> + /// <value> + /// <c>true</c> if debug; otherwise, <c>false</c>. + /// </value> + public bool Debug { get; set; } + + internal void TraceSettingsRead(string groupName, string key, string value) + { + if (Debug) + { + Trace.WriteLine(string.Format("Settings[\"{0}\"][\"{1}\"] read.", groupName, key)); + } + + if (SettingsTracer == null) return; + + SettingsTracer.OnReadSetting(groupName, key, value); + } + internal void TraceSettingsWrite(string groupName, string key, string value) + { + if (Debug) + { + Trace.WriteLine(string.Format("Settings[\"{0}\"][\"{1}\"] written.", groupName, key)); + } + + if (SettingsTracer == null) return; + + SettingsTracer.OnWriteSetting(groupName, key, value); + } + private SettingsGroup GetOrCreateSettingsGroup(string name) { if (name.Contains(" ")) Modified: trunk/AgateLib/Settings/SettingsGroup.cs =================================================================== --- trunk/AgateLib/Settings/SettingsGroup.cs 2011-11-22 17:57:40 UTC (rev 1306) +++ trunk/AgateLib/Settings/SettingsGroup.cs 2011-11-22 21:12:54 UTC (rev 1307) @@ -39,17 +39,9 @@ /// The name. /// </value> public string Name { get; internal set; } + /// <summary> - /// Gets or sets a value indicating whether this <see cref="AgateLib.Settings.SettingsGroup"/> is in - /// debugging mode. If true, every access to a member will be echoed to System.Diagnostics.Trace. - /// </summary> - /// <value> - /// <c>true</c> if debug; otherwise, <c>false</c>. - /// </value> - public bool Debug { get; set; } - - /// <summary> /// Returns true if this settings group has no members. /// </summary> public bool IsEmpty @@ -66,12 +58,9 @@ /// <param name="value"></param> public void Add(string key, string value) { - mStore.Add(key, value); + Core.Settings.TraceSettingsWrite(Name, key, value); - if (Debug) - { - Trace.WriteLine(string.Format("Settings[\"{0}\"][\"{1}\"] written.", Name, key)); - } + mStore.Add(key, value); } /// <summary> @@ -80,12 +69,9 @@ /// <param name="key"></param> /// <returns></returns> public bool ContainsKey(string key) - { - if (Debug) - { - Trace.WriteLine(string.Format("Settings[\"{0}\"][\"{1}\"] checked.", Name, key)); - } - + { + Core.Settings.TraceSettingsRead(Name, key, (mStore.ContainsKey(key) ? mStore[key] : null)); + return mStore.ContainsKey(key); } @@ -114,11 +100,8 @@ /// <returns></returns> public bool TryGetValue(string key, out string value) { - if (Debug) - { - Trace.WriteLine(string.Format("Settings[\"{0}\"][\"{1}\"] checked.", Name, key)); - } - + Core.Settings.TraceSettingsRead(Name, key, (mStore.ContainsKey(key) ? mStore[key] : null)); + return mStore.TryGetValue(key, out value); } @@ -138,19 +121,15 @@ public string this[string key] { get - { - if (Debug) - { - Trace.WriteLine(string.Format("Settings[\"{0}\"][\"{1}\"] checked.", Name, key)); - } + { + Core.Settings.TraceSettingsRead(Name, key, (mStore.ContainsKey(key) ? mStore[key] : null)); + return mStore[key]; } set - { - if (Debug) - { - Trace.WriteLine(string.Format("Settings[\"{0}\"][\"{1}\"] written.", Name, key)); - } + { + Core.Settings.TraceSettingsWrite(Name, key, value); + mStore[key] = value; } } Modified: trunk/Drivers/AgateOTK/GL_Display.cs =================================================================== --- trunk/Drivers/AgateOTK/GL_Display.cs 2011-11-22 17:57:40 UTC (rev 1306) +++ trunk/Drivers/AgateOTK/GL_Display.cs 2011-11-22 21:12:54 UTC (rev 1307) @@ -1,601 +1,619 @@ -// The contents of this file are subject to the Mozilla Public License -// Version 1.1 (the "License"); you may not use this file except in -// compliance with the License. You may obtain a copy of the License at -// http://www.mozilla.org/MPL/ -// -// Software distributed under the License is distributed on an "AS IS" -// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the -// License for the specific language governing rights and limitations -// under the License. -// -// The Original Code is AgateLib. -// -// The Initial Developer of the Original Code is Erik Ylvisaker. -// Portions created by Erik Ylvisaker are Copyright (C) 2006-2011. -// All Rights Reserved. -// -// Contributor(s): Erik Ylvis... [truncated message content] |
From: <ka...@us...> - 2011-11-22 17:57:47
|
Revision: 1306 http://agate.svn.sourceforge.net/agate/?rev=1306&view=rev Author: kanato Date: 2011-11-22 17:57:40 +0000 (Tue, 22 Nov 2011) Log Message: ----------- Added enum values for windows 8. Modified Paths: -------------- trunk/AgateLib/Platform.cs trunk/AgateLib/PlatformType.cs Modified: trunk/AgateLib/Platform.cs =================================================================== --- trunk/AgateLib/Platform.cs 2011-11-22 08:02:14 UTC (rev 1305) +++ trunk/AgateLib/Platform.cs 2011-11-22 17:57:40 UTC (rev 1306) @@ -356,6 +356,8 @@ case 7: retval = WindowsVersion.Windows7; break; + case 8: + retval = WindowsVersion.Windows8; } return retval; Modified: trunk/AgateLib/PlatformType.cs =================================================================== --- trunk/AgateLib/PlatformType.cs 2011-11-22 08:02:14 UTC (rev 1305) +++ trunk/AgateLib/PlatformType.cs 2011-11-22 17:57:40 UTC (rev 1306) @@ -82,6 +82,10 @@ /// Windows 7. /// </summary> Windows7, + /// <summary> + /// Windows 8. + /// </summary> + Windows8 } /// <summary> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ka...@us...> - 2011-11-22 08:02:23
|
Revision: 1305 http://agate.svn.sourceforge.net/agate/?rev=1305&view=rev Author: kanato Date: 2011-11-22 08:02:14 +0000 (Tue, 22 Nov 2011) Log Message: ----------- Fixed selection of drivers based on settings. Fixed double output of debug messages. Removed unnecessary FrameBufferArb class, since the function entry points and behavior are exactly the same as for GL3. Removed AskUser for all tests, leaving that functionality to the test launcher. Fixed the display of the launcher. Modified some comments. Modified Paths: -------------- trunk/AgateLib/Core.cs trunk/AgateLib/Drivers/Registrar.cs trunk/AgateLib/Platform.cs trunk/Drivers/AgateOTK/AgateOTK.csproj trunk/Drivers/AgateOTK/GL_Display.cs trunk/Drivers/AgateOTK/GL_GameWindow.cs trunk/Tests/AudioTests/AudioPlayer/AudioPlayer.cs trunk/Tests/AudioTests/StreamAudio.cs trunk/Tests/CoreTests/TgzProviderTester.cs trunk/Tests/CoreTests/ZipProviderTester.cs trunk/Tests/DisplayTests/BasicDrawing/BasicDrawing.cs trunk/Tests/DisplayTests/Capabilities/Capabilities.cs trunk/Tests/DisplayTests/ClipRect.cs trunk/Tests/DisplayTests/ColorTest.cs trunk/Tests/DisplayTests/PixelBufferMask.cs trunk/Tests/DisplayTests/PixelBufferTest/PixelBufferTest.cs trunk/Tests/DisplayTests/Prerendered.cs trunk/Tests/DisplayTests/ScreenCapture.cs trunk/Tests/DisplayTests/SurfaceTester/SurfaceTester.cs trunk/Tests/DisplayTests/TileTester/TileTester.cs trunk/Tests/DisplayTests/Tiling.cs trunk/Tests/Fonts/BitmapFonts.cs trunk/Tests/Fonts/FontLineTester.cs trunk/Tests/Fonts/Fonts.cs trunk/Tests/Fonts/Kerning.cs trunk/Tests/InputTests/Input/InputTester.cs trunk/Tests/Launcher.cs trunk/Tests/Shaders/CoordinateSystem.cs trunk/Tests/Shaders/Lighting3DTest.cs trunk/Tests/Shaders/LightingTest/LightingTest.cs trunk/Tests/frmLauncher.Designer.cs trunk/Tests/frmLauncher.cs Removed Paths: ------------- trunk/Drivers/AgateOTK/Legacy/FrameBufferArb.cs Modified: trunk/AgateLib/Core.cs =================================================================== --- trunk/AgateLib/Core.cs 2011-11-21 22:50:40 UTC (rev 1304) +++ trunk/AgateLib/Core.cs 2011-11-22 08:02:14 UTC (rev 1305) @@ -302,7 +302,7 @@ { } /// <summary> - /// Initializes Core class. + /// Initializes Core class. Also causes the Registrar to probe drivers. /// Can be called multiple times without adverse effects. /// </summary> public static void Initialize() @@ -312,7 +312,6 @@ Drivers.Registrar.Initialize(); - sInititalized = true; } Modified: trunk/AgateLib/Drivers/Registrar.cs =================================================================== --- trunk/AgateLib/Drivers/Registrar.cs 2011-11-21 22:50:40 UTC (rev 1304) +++ trunk/AgateLib/Drivers/Registrar.cs 2011-11-22 08:02:14 UTC (rev 1305) @@ -1,497 +1,519 @@ -// The contents of this file are subject to the Mozilla Public License -// Version 1.1 (the "License"); you may not use this file except in -// compliance with the License. You may obtain a copy of the License at -// http://www.mozilla.org/MPL/ -// -// Software distributed under the License is distributed on an "AS IS" -// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the -// License for the specific language governing rights and limitations -// under the License. -// -// The Original Code is AgateLib. -// -// The Initial Developer of the Original Code is Erik Ylvisaker. -// Portions created by Erik Ylvisaker are Copyright (C) 2006-2011. -// All Rights Reserved. -// -// Contributor(s): Erik Ylvisaker -// -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Linq; -using System.Reflection; -using System.Text; -using AgateLib.AudioLib.ImplementationBase; -using AgateLib.DisplayLib.ImplementationBase; -using AgateLib.InputLib.ImplementationBase; -using AgateLib.Utility; - -namespace AgateLib.Drivers -{ - /// <summary> - /// Static class with which drivers register themselves so that the library can - /// instantiate them. - /// </summary> - public static class Registrar - { - private static List<AgateDriverInfo> - displayDrivers = new List<AgateDriverInfo>(), - audioDrivers = new List<AgateDriverInfo>(), - inputDrivers = new List<AgateDriverInfo>(), - desktopDrivers = new List<AgateDriverInfo>(); - - private static bool mIsInitialized = false; - - private static IDesktopDriver mDesktop; - - private static readonly string[] KnownNativeLibraries = new string[] - { - "SDL.dll", - }; - - - static bool Contains(this IEnumerable<AgateDriverInfo> list, DisplayTypeID type) - { - return list.Any( - x => Comparator(x, DriverType.Display, (int)type)); - } - static bool Contains(this IEnumerable<AgateDriverInfo> list, AudioTypeID type) - { - return list.Any( - x => Comparator(x, DriverType.Audio, (int)type)); - } - static bool Contains(this IEnumerable<AgateDriverInfo> list, InputTypeID type) - { - return list.Any( - x => Comparator(x, DriverType.Input, (int)type)); - } - static bool Comparator(AgateDriverInfo info, DriverType driverType, int type) - { - return info.DriverType == driverType && info.DriverTypeID == type; - } - - static Registrar() - { - } - /// <summary> - /// Searches through FileManager.AssemblyPath for all *.dll files. These files - /// are loaded and searched for classes which derive from DisplayImpl, AudioImpl, etc. - /// </summary> - internal static void Initialize() - { - if (mIsInitialized) - return; - - RegisterNullDrivers(); - - AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve); - AppDomain sandbox = AppDomain.CreateDomain("AgateSandBox"); - - AgateSandBoxLoader loader = (AgateSandBoxLoader) - sandbox.CreateInstanceAndUnwrap(Assembly.GetExecutingAssembly().FullName, - typeof(AgateSandBoxLoader).FullName); - - IEnumerable<string> files = AgateFileProvider.Assemblies.GetAllFiles("*.dll"); - - foreach (string file in files) - { - if (ShouldSkipLibrary(file)) - continue; - - foreach (AgateDriverInfo info in loader.ReportDrivers(file)) - { - switch (info.DriverType) - { - case DriverType.Display: - displayDrivers.Add(info); - break; - - case DriverType.Audio: - audioDrivers.Add(info); - break; - - case DriverType.Input: - inputDrivers.Add(info); - break; - - case DriverType.Desktop: - desktopDrivers.Add(info); - break; - - default: - Core.ErrorReporting.Report(ErrorLevel.Warning, string.Format( - "Could not interpret DriverType returned by type {0} in assembly {1}.", - info.DriverTypeName, info.AssemblyFile), null); - - break; - } - } - } - - AppDomain.Unload(sandbox); - - SortDriverInfo(displayDrivers); - SortDriverInfo(audioDrivers); - SortDriverInfo(inputDrivers); - SortDriverInfo(desktopDrivers); - - mIsInitialized = true; - } - private static void SortDriverInfo(List<AgateDriverInfo> driverList) - { - // sorts the driver list in reverse order. - driverList.Sort(delegate(AgateDriverInfo a, AgateDriverInfo b) - { - return -a.Priority.CompareTo(b.Priority); - }); - } - - private static void RegisterNullDrivers() - { - Assembly thisAssembly = Assembly.GetExecutingAssembly(); - - AgateDriverInfo nullAudioInfo = new AgateDriverInfo(AudioTypeID.Silent, - typeof(NullSoundImpl), "No audio", -100); - - nullAudioInfo.AssemblyFile = thisAssembly.CodeBase; - nullAudioInfo.AssemblyName = thisAssembly.FullName; - - audioDrivers.Add(nullAudioInfo); - - AgateDriverInfo nullInputInfo = new AgateDriverInfo(InputTypeID.Silent, - typeof(NullInputImpl), "No input", -100); - - nullInputInfo.AssemblyFile = thisAssembly.CodeBase; - nullInputInfo.AssemblyName = thisAssembly.FullName; - - inputDrivers.Add(nullInputInfo); - } - - private static bool ShouldSkipLibrary(string file) - { - // Native libraries in the same directory will give an error when loaded, - // so skip any ones that we know about that will probably be in the same - // directory as the drivers. - if (IsKnownNativeLibrary(file)) - return true; - - // hack, because mono crashes if AgateMDX.dll is present. - // annoying, because it should report a failure to load the types in the - // assembly, and then the try catch should continue after that. - // TODO: this hack seems unnecessary in recent versions of Mono. Should it be removed? - if ((Environment.OSVersion.Platform == PlatformID.Unix || - Environment.OSVersion.Platform == (PlatformID)128) && - (System.IO.Path.GetFileName(file).ToLower().Contains("agatemdx.dll") || - System.IO.Path.GetFileName(file).ToLower().Contains("agatesdx.dll"))) - { - Core.ErrorReporting.Report(ErrorLevel.Comment, - string.Format("DirectX not supported on non-Windows platforms. {0}Remove {1} to eliminate this message.", - Environment.NewLine, System.IO.Path.GetFileName(file)), null); - - return true; - } - - // Skip the agatelib dll. - if (System.IO.Path.GetFileName(file).ToLower().Contains("agatelib.dll")) - return true; - - return false; - } - private static bool IsKnownNativeLibrary(string path) - { - string filename = System.IO.Path.GetFileName(path).ToLowerInvariant(); - - for (int i = 0; i < KnownNativeLibraries.Length; i++) - { - if (KnownNativeLibraries[i].ToLowerInvariant() == filename) - return true; - } - return false; - } - - - /// <summary> - /// Asks the user to select which drivers to use. - /// </summary> - /// <param name="chooseDisplay"></param> - /// <param name="chooseAudio"></param> - /// <param name="chooseInput"></param> - /// <param name="selectedDisplay"></param> - /// <param name="selectedAudio"></param> - /// <param name="selectedInput"></param> - /// <returns></returns> - internal static bool UserSelectDrivers(bool chooseDisplay, bool chooseAudio, bool chooseInput, - DisplayTypeID preferredDisplay, AudioTypeID preferredAudio, InputTypeID preferredInput, - out DisplayTypeID selectedDisplay, out AudioTypeID selectedAudio, out InputTypeID selectedInput) - { - if (mDesktop == null) - { - CreateDesktopDriver(); - - if (mDesktop == null) - { - SelectBestDrivers(chooseDisplay, chooseAudio, chooseInput, - preferredDisplay, preferredAudio, preferredInput, - out selectedDisplay, out selectedAudio, out selectedInput); - - return true; - } - } - - IUserSetSystems frm = mDesktop.CreateUserSetSystems(); - - // set default values. - selectedDisplay = DisplayTypeID.AutoSelect; - selectedAudio = AudioTypeID.AutoSelect; - selectedInput = InputTypeID.AutoSelect; - - foreach (AgateDriverInfo info in displayDrivers) - { - frm.AddDisplayType(info); - } - foreach (AgateDriverInfo info in audioDrivers) - { - frm.AddAudioType(info); - } - foreach (AgateDriverInfo info in inputDrivers) - { - frm.AddInputType(info); - } - - frm.SetChoices(chooseDisplay, chooseAudio, chooseInput, - preferredDisplay, preferredAudio, preferredInput); - - // run the dialog asking user which drivers to use. - if (frm.RunDialog() == SetSystemsDialogResult.Cancel) - { - return false; - } - - selectedDisplay = frm.DisplayType; - selectedAudio = frm.AudioType; - selectedInput = frm.InputType; - - return true; - - } - - private static void SelectBestDrivers(bool chooseDisplay, bool chooseAudio, bool chooseInput, - DisplayTypeID preferredDisplay, AudioTypeID preferredAudio, InputTypeID preferredInput, - out DisplayTypeID selectedDisplay, out AudioTypeID selectedAudio, out InputTypeID selectedInput) - { - // initial return values if a driver isn't selected. - selectedDisplay = DisplayTypeID.AutoSelect; - selectedAudio = AudioTypeID.AutoSelect; - selectedInput = InputTypeID.AutoSelect; - - if (preferredDisplay != DisplayTypeID.AutoSelect && displayDrivers.Contains(preferredDisplay)) - selectedDisplay = preferredDisplay; - else if (displayDrivers.Count > 0) - selectedDisplay = (DisplayTypeID)displayDrivers[0].DriverTypeID; - - if (preferredAudio != AudioTypeID.AutoSelect && audioDrivers.Contains(preferredAudio)) - selectedAudio = preferredAudio; - else if (audioDrivers.Count > 0) - selectedAudio = (AudioTypeID)audioDrivers[0].DriverTypeID; - - if (preferredInput != InputTypeID.AutoSelect && inputDrivers.Contains(preferredInput)) - selectedInput = preferredInput; - else if (inputDrivers.Count > 0) - selectedInput = (InputTypeID)inputDrivers[0].DriverTypeID; - } - - private static void CreateDesktopDriver() - { - if (desktopDrivers.Count == 0) - return; - - mDesktop = (IDesktopDriver)CreateDriverInstance(desktopDrivers[0]); - } - - internal static IDesktopDriver WinForms - { - get { return mDesktop; } - } - - internal static DisplayImpl CreateDisplayDriver(DisplayTypeID displayType) - { - if (displayDrivers.Count == 0) - throw new AgateException("No display drivers registered."); - - AgateDriverInfo info; - string text; - - if (displayType == DisplayTypeID.AutoSelect && - Core.Settings["AgateLib"].TryGetValue("DisplayDriver", out text)) - { - info = FindDriverInfo(displayDrivers, text); - } - else - info = FindDriverInfo(displayDrivers, (int)displayType); - - if (info == null) - throw new AgateException(string.Format("Could not find the driver {0}.", displayType)); - - return (DisplayImpl)CreateDriverInstance(info); - } - internal static AudioImpl CreateAudioDriver(AudioTypeID audioType) - { - if (audioDrivers.Count == 0) - throw new AgateException("No audio drivers registered."); +// The contents of this file are subject to the Mozilla Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.mozilla.org/MPL/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations +// under the License. +// +// The Original Code is AgateLib. +// +// The Initial Developer of the Original Code is Erik Ylvisaker. +// Portions created by Erik Ylvisaker are Copyright (C) 2006-2011. +// All Rights Reserved. +// +// Contributor(s): Erik Ylvisaker +// +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Reflection; +using System.Text; +using AgateLib.AudioLib.ImplementationBase; +using AgateLib.DisplayLib.ImplementationBase; +using AgateLib.InputLib.ImplementationBase; +using AgateLib.Utility; + +namespace AgateLib.Drivers +{ + /// <summary> + /// Static class with which drivers register themselves so that the library can + /// instantiate them. + /// </summary> + public static class Registrar + { + private static List<AgateDriverInfo> + displayDrivers = new List<AgateDriverInfo>(), + audioDrivers = new List<AgateDriverInfo>(), + inputDrivers = new List<AgateDriverInfo>(), + desktopDrivers = new List<AgateDriverInfo>(); + + private static bool mIsInitialized = false; + + private static IDesktopDriver mDesktop; + + private static readonly string[] KnownNativeLibraries = new string[] + { + "SDL.dll", + "SDL_mixer.dll", + "libogg-0.dll", + "libvorbis-0.dll", + "libvorbisfile-3.dll", + }; + + + static bool Contains(this IEnumerable<AgateDriverInfo> list, DisplayTypeID type) + { + return list.Any( + x => Comparator(x, DriverType.Display, (int)type)); + } + static bool Contains(this IEnumerable<AgateDriverInfo> list, AudioTypeID type) + { + return list.Any( + x => Comparator(x, DriverType.Audio, (int)type)); + } + static bool Contains(this IEnumerable<AgateDriverInfo> list, InputTypeID type) + { + return list.Any( + x => Comparator(x, DriverType.Input, (int)type)); + } + static bool Comparator(AgateDriverInfo info, DriverType driverType, int type) + { + return info.DriverType == driverType && info.DriverTypeID == type; + } + + static Registrar() + { + } + /// <summary> + /// Searches through FileManager.AssemblyPath for all *.dll files. These files + /// are loaded and searched for classes which derive from DisplayImpl, AudioImpl, etc. + /// </summary> + internal static void Initialize() + { + if (mIsInitialized) + return; + + RegisterNullDrivers(); + + AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve); + AppDomain sandbox = AppDomain.CreateDomain("AgateSandBox"); + + AgateSandBoxLoader loader = (AgateSandBoxLoader) + sandbox.CreateInstanceAndUnwrap(Assembly.GetExecutingAssembly().FullName, + typeof(AgateSandBoxLoader).FullName); + + IEnumerable<string> files = AgateFileProvider.Assemblies.GetAllFiles("*.dll"); + + foreach (string file in files) + { + if (ShouldSkipLibrary(file)) + continue; + + foreach (AgateDriverInfo info in loader.ReportDrivers(file)) + { + switch (info.DriverType) + { + case DriverType.Display: + displayDrivers.Add(info); + break; + + case DriverType.Audio: + audioDrivers.Add(info); + break; + + case DriverType.Input: + inputDrivers.Add(info); + break; + + case DriverType.Desktop: + desktopDrivers.Add(info); + break; + + default: + Core.ErrorReporting.Report(ErrorLevel.Warning, string.Format( + "Could not interpret DriverType returned by type {0} in assembly {1}.", + info.DriverTypeName, info.AssemblyFile), null); + + break; + } + } + } + + AppDomain.Unload(sandbox); + + SortDriverInfo(displayDrivers); + SortDriverInfo(audioDrivers); + SortDriverInfo(inputDrivers); + SortDriverInfo(desktopDrivers); + + mIsInitialized = true; + } + private static void SortDriverInfo(List<AgateDriverInfo> driverList) + { + // sorts the driver list in reverse order. + driverList.Sort(delegate(AgateDriverInfo a, AgateDriverInfo b) + { + return -a.Priority.CompareTo(b.Priority); + }); + } + + private static void RegisterNullDrivers() + { + Assembly thisAssembly = Assembly.GetExecutingAssembly(); + + AgateDriverInfo nullAudioInfo = new AgateDriverInfo(AudioTypeID.Silent, + typeof(NullSoundImpl), "No audio", -100); + + nullAudioInfo.AssemblyFile = thisAssembly.CodeBase; + nullAudioInfo.AssemblyName = thisAssembly.FullName; + + audioDrivers.Add(nullAudioInfo); + + AgateDriverInfo nullInputInfo = new AgateDriverInfo(InputTypeID.Silent, + typeof(NullInputImpl), "No input", -100); + + nullInputInfo.AssemblyFile = thisAssembly.CodeBase; + nullInputInfo.AssemblyName = thisAssembly.FullName; + + inputDrivers.Add(nullInputInfo); + } + + private static bool ShouldSkipLibrary(string file) + { + // Native libraries in the same directory will give an error when loaded, + // so skip any ones that we know about that will probably be in the same + // directory as the drivers. + if (IsKnownNativeLibrary(file)) + return true; + + // hack, because mono crashes if AgateMDX.dll is present. + // annoying, because it should report a failure to load the types in the + // assembly, and then the try catch should continue after that. + // TODO: this hack seems unnecessary in recent versions of Mono. Should it be removed? + if ((Environment.OSVersion.Platform == PlatformID.Unix || + Environment.OSVersion.Platform == (PlatformID)128) && + (System.IO.Path.GetFileName(file).ToLower().Contains("agatemdx.dll") || + System.IO.Path.GetFileName(file).ToLower().Contains("agatesdx.dll"))) + { + Core.ErrorReporting.Report(ErrorLevel.Comment, + string.Format("DirectX not supported on non-Windows platforms. {0}Remove {1} to eliminate this message.", + Environment.NewLine, System.IO.Path.GetFileName(file)), null); + + return true; + } + + // Skip the agatelib dll. + if (System.IO.Path.GetFileName(file).ToLower().Contains("agatelib.dll")) + return true; + + return false; + } + private static bool IsKnownNativeLibrary(string path) + { + string filename = System.IO.Path.GetFileName(path).ToLowerInvariant(); + + for (int i = 0; i < KnownNativeLibraries.Length; i++) + { + if (KnownNativeLibraries[i].ToLowerInvariant() == filename) + return true; + } + return false; + } + + + /// <summary> + /// Asks the user to select which drivers to use. + /// </summary> + /// <param name="chooseDisplay"></param> + /// <param name="chooseAudio"></param> + /// <param name="chooseInput"></param> + /// <param name="selectedDisplay"></param> + /// <param name="selectedAudio"></param> + /// <param name="selectedInput"></param> + /// <returns></returns> + internal static bool UserSelectDrivers(bool chooseDisplay, bool chooseAudio, bool chooseInput, + DisplayTypeID preferredDisplay, AudioTypeID preferredAudio, InputTypeID preferredInput, + out DisplayTypeID selectedDisplay, out AudioTypeID selectedAudio, out InputTypeID selectedInput) + { + if (mDesktop == null) + { + CreateDesktopDriver(); + + if (mDesktop == null) + { + SelectBestDrivers(chooseDisplay, chooseAudio, chooseInput, + preferredDisplay, preferredAudio, preferredInput, + out selectedDisplay, out selectedAudio, out selectedInput); + + return true; + } + } + + IUserSetSystems frm = mDesktop.CreateUserSetSystems(); + + // set default values. + selectedDisplay = DisplayTypeID.AutoSelect; + selectedAudio = AudioTypeID.AutoSelect; + selectedInput = InputTypeID.AutoSelect; + + foreach (AgateDriverInfo info in displayDrivers) + { + frm.AddDisplayType(info); + } + foreach (AgateDriverInfo info in audioDrivers) + { + frm.AddAudioType(info); + } + foreach (AgateDriverInfo info in inputDrivers) + { + frm.AddInputType(info); + } + + frm.SetChoices(chooseDisplay, chooseAudio, chooseInput, + preferredDisplay, preferredAudio, preferredInput); + + // run the dialog asking user which drivers to use. + if (frm.RunDialog() == SetSystemsDialogResult.Cancel) + { + return false; + } + + selectedDisplay = frm.DisplayType; + selectedAudio = frm.AudioType; + selectedInput = frm.InputType; + + return true; + + } + + private static void SelectBestDrivers(bool chooseDisplay, bool chooseAudio, bool chooseInput, + DisplayTypeID preferredDisplay, AudioTypeID preferredAudio, InputTypeID preferredInput, + out DisplayTypeID selectedDisplay, out AudioTypeID selectedAudio, out InputTypeID selectedInput) + { + // initial return values if a driver isn't selected. + selectedDisplay = DisplayTypeID.AutoSelect; + selectedAudio = AudioTypeID.AutoSelect; + selectedInput = InputTypeID.AutoSelect; + + if (preferredDisplay != DisplayTypeID.AutoSelect && displayDrivers.Contains(preferredDisplay)) + selectedDisplay = preferredDisplay; + else if (displayDrivers.Count > 0) + selectedDisplay = (DisplayTypeID)displayDrivers[0].DriverTypeID; + + if (preferredAudio != AudioTypeID.AutoSelect && audioDrivers.Contains(preferredAudio)) + selectedAudio = preferredAudio; + else if (audioDrivers.Count > 0) + selectedAudio = (AudioTypeID)audioDrivers[0].DriverTypeID; + + if (preferredInput != InputTypeID.AutoSelect && inputDrivers.Contains(preferredInput)) + selectedInput = preferredInput; + else if (inputDrivers.Count > 0) + selectedInput = (InputTypeID)inputDrivers[0].DriverTypeID; + } + + private static void CreateDesktopDriver() + { + if (desktopDrivers.Count == 0) + return; + + mDesktop = (IDesktopDriver)CreateDriverInstance(desktopDrivers[0]); + } + + internal static IDesktopDriver WinForms + { + get { return mDesktop; } + } + + internal static DisplayImpl CreateDisplayDriver(DisplayTypeID displayType) + { + if (displayDrivers.Count == 0) + throw new AgateException("No display drivers registered."); - AgateDriverInfo info; + AgateDriverInfo info = null; string text; + + bool settingsSelect = displayType == DisplayTypeID.AutoSelect; + settingsSelect &= Core.Settings["AgateLib"].TryGetValue("DisplayDriver", out text); + + if (settingsSelect) + { + info = FindDriverInfo(displayDrivers, text); + + if (info == null) + settingsSelect = false; + } - if (audioType == AudioTypeID.AutoSelect && - Core.Settings["AgateLib"].TryGetValue("AudioDriver", out text)) + if (settingsSelect == false) + info = FindDriverInfo(displayDrivers, (int)displayType); + + if (info == null) + throw new AgateException(string.Format("Could not find the driver {0}.", displayType)); + + return (DisplayImpl)CreateDriverInstance(info); + } + internal static AudioImpl CreateAudioDriver(AudioTypeID audioType) + { + if (audioDrivers.Count == 0) + throw new AgateException("No audio drivers registered."); + + AgateDriverInfo info = null; + string text; + + bool settingsSelect = audioType == AudioTypeID.AutoSelect; + settingsSelect &= Core.Settings["AgateLib"].TryGetValue("AudioDriver", out text); + + if (settingsSelect) { info = FindDriverInfo(audioDrivers, text); + + if (info == null) + settingsSelect = false; } - else - info = FindDriverInfo(audioDrivers, (int)audioType); - - if (info == null) - throw new AgateException(string.Format("Could not find the driver {0}.", audioType)); - - return (AudioImpl)CreateDriverInstance(info); - } - internal static InputImpl CreateInputDriver(InputTypeID inputType) - { - if (inputDrivers.Count == 0) - throw new AgateException("No audio drivers registered."); - AgateDriverInfo info; + if (settingsSelect == false) + info = FindDriverInfo(audioDrivers, (int)audioType); + + if (info == null) + throw new AgateException(string.Format("Could not find the driver {0}.", audioType)); + + return (AudioImpl)CreateDriverInstance(info); + } + internal static InputImpl CreateInputDriver(InputTypeID inputType) + { + if (inputDrivers.Count == 0) + throw new AgateException("No audio drivers registered."); + + AgateDriverInfo info = null; string text; - - if (inputType == InputTypeID.AutoSelect && - Core.Settings["AgateLib"].TryGetValue("InputDriver", out text)) + + bool settingsSelect = inputType == InputTypeID.AutoSelect; + settingsSelect &= Core.Settings["AgateLib"].TryGetValue("AudioDriver", out text); + + if (settingsSelect) { info = FindDriverInfo(inputDrivers, text); + + if (info == null) + settingsSelect = false; } - else + + if (settingsSelect == false) info = FindDriverInfo(inputDrivers, (int)inputType); - - if (info == null) - throw new AgateException(string.Format("Could not find the driver {0}.", inputType)); - - return (InputImpl)CreateDriverInstance(info); - } - - private static AgateDriverInfo FindDriverInfo(List<AgateDriverInfo> driverList, string matchText) - { - AgateDriverInfo retval = null; - - if (driverList.Count == 0) - return null; - - foreach(AgateDriverInfo info in driverList) - { - if (info.FriendlyName.Contains(matchText)) - retval = info; - } - - return retval; - } - private static AgateDriverInfo FindDriverInfo(List<AgateDriverInfo> driverList, int typeID) - { - AgateDriverInfo theInfo = null; - - if (driverList.Count == 0) - return null; - - // autoselect ID's are all zero - if (typeID == 0) - return driverList[0]; - - foreach (AgateDriverInfo info in driverList) - { - if (info.DriverTypeID != typeID) - continue; - - theInfo = info; - } - return theInfo; - } - private static AgateDriverInfo FindDriverInfo(IEnumerable<AgateDriverInfo> driverList, string assemblyFullName) - { - AgateDriverInfo theInfo = null; - - foreach (AgateDriverInfo info in driverList) - { - if (info.AssemblyName != assemblyFullName) - continue; - - theInfo = info; - } - return theInfo; - } - - private static object CreateDriverInstance(AgateDriverInfo info) - { - Assembly ass = Assembly.Load(info.AssemblyName); - - Type driverType = ass.GetType(info.DriverTypeName, false); - - if (driverType == null) - throw new AgateException(string.Format( - "Could not find the type {0} in the library {1}.", - info.DriverTypeName, - ass.FullName)); - - return Activator.CreateInstance(driverType); - } - - private static Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args) - { - AgateDriverInfo info = null; - - info = info ?? FindDriverInfo(displayDrivers, args.Name); - info = info ?? FindDriverInfo(audioDrivers, args.Name); - info = info ?? FindDriverInfo(inputDrivers, args.Name); - info = info ?? FindDriverInfo(desktopDrivers, args.Name); - - if (info == null) - return null; - - return LoadAssemblyLoadFrom(info); - } - - private static Assembly LoadAssemblyLoadFrom(AgateDriverInfo info) - { - Core.ErrorReporting.Report(ErrorLevel.Warning, - string.Format("Assembly {0} was loaded in the LoadFrom context. Move it to the application directory to load in the Load context.", info.AssemblyName), null); - return Assembly.LoadFrom(info.AssemblyFile); - } - - /// <summary> - /// Returns a collection with all the DriverInfo<DisplayTypeID> structures for - /// registered display drivers. - /// </summary> - /// <returns></returns> - public static List<AgateDriverInfo> DisplayDrivers - { - get { return displayDrivers; } - } - /// <summary> - /// Returns a collection with all the DriverInfo<AudioTypeID> structures for - /// registered display drivers. - /// </summary> - /// <returns></returns> - public static List<AgateDriverInfo> AudioDrivers - { - get { return audioDrivers; } - } - /// <summary> - /// Returns a collection with all the DriverInfo<InputTypeID> structures for - /// registered display drivers. - /// </summary> - /// <returns></returns> - public static List<AgateDriverInfo> InputDrivers - { - get { return inputDrivers; } - } - - - } -} + + if (info == null) + throw new AgateException(string.Format("Could not find the driver {0}.", inputType)); + + return (InputImpl)CreateDriverInstance(info); + } + + private static AgateDriverInfo FindDriverInfo(List<AgateDriverInfo> driverList, string matchText) + { + AgateDriverInfo retval = null; + + if (driverList.Count == 0) + return null; + + foreach(AgateDriverInfo info in driverList) + { + if (info.FriendlyName.Contains(matchText)) + retval = info; + } + + return retval; + } + private static AgateDriverInfo FindDriverInfo(List<AgateDriverInfo> driverList, int typeID) + { + AgateDriverInfo theInfo = null; + + if (driverList.Count == 0) + return null; + + // autoselect ID's are all zero + if (typeID == 0) + return driverList[0]; + + foreach (AgateDriverInfo info in driverList) + { + if (info.DriverTypeID != typeID) + continue; + + theInfo = info; + } + return theInfo; + } + private static AgateDriverInfo FindDriverInfo(IEnumerable<AgateDriverInfo> driverList, string assemblyFullName) + { + AgateDriverInfo theInfo = null; + + foreach (AgateDriverInfo info in driverList) + { + if (info.AssemblyName != assemblyFullName) + continue; + + theInfo = info; + } + return theInfo; + } + + private static object CreateDriverInstance(AgateDriverInfo info) + { + Assembly ass = Assembly.Load(info.AssemblyName); + + Type driverType = ass.GetType(info.DriverTypeName, false); + + if (driverType == null) + throw new AgateException(string.Format( + "Could not find the type {0} in the library {1}.", + info.DriverTypeName, + ass.FullName)); + + return Activator.CreateInstance(driverType); + } + + private static Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args) + { + AgateDriverInfo info = null; + + info = info ?? FindDriverInfo(displayDrivers, args.Name); + info = info ?? FindDriverInfo(audioDrivers, args.Name); + info = info ?? FindDriverInfo(inputDrivers, args.Name); + info = info ?? FindDriverInfo(desktopDrivers, args.Name); + + if (info == null) + return null; + + return LoadAssemblyLoadFrom(info); + } + + private static Assembly LoadAssemblyLoadFrom(AgateDriverInfo info) + { + Core.ErrorReporting.Report(ErrorLevel.Warning, + string.Format("Assembly {0} was loaded in the LoadFrom context. Move it to the application directory to load in the Load context.", info.AssemblyName), null); + return Assembly.LoadFrom(info.AssemblyFile); + } + + /// <summary> + /// Returns a collection with all the DriverInfo<DisplayTypeID> structures for + /// registered display drivers. + /// </summary> + /// <returns></returns> + public static List<AgateDriverInfo> DisplayDrivers + { + get { return displayDrivers; } + } + /// <summary> + /// Returns a collection with all the DriverInfo<AudioTypeID> structures for + /// registered display drivers. + /// </summary> + /// <returns></returns> + public static List<AgateDriverInfo> AudioDrivers + { + get { return audioDrivers; } + } + /// <summary> + /// Returns a collection with all the DriverInfo<InputTypeID> structures for + /// registered display drivers. + /// </summary> + /// <returns></returns> + public static List<AgateDriverInfo> InputDrivers + { + get { return inputDrivers; } + } + + + } +} Modified: trunk/AgateLib/Platform.cs =================================================================== --- trunk/AgateLib/Platform.cs 2011-11-21 22:50:40 UTC (rev 1304) +++ trunk/AgateLib/Platform.cs 2011-11-22 08:02:14 UTC (rev 1305) @@ -49,9 +49,12 @@ mRuntime = DetectRuntime(); m64Bit = Detect64Bit(); + // According to http://msdn.microsoft.com/query/dev10.query?appId=Dev10IDEF1&l=EN-US&k=k%28SYSTEM.DIAGNOSTICS.DEBUG.LISTENERS%29;k%28TargetFrameworkMoniker-%22.NETFRAMEWORK%2cVERSION%3dV3.5%22%29;k%28DevLang-CSHARP%29&rd=true + // The Listeners collection is shared by both the Debug and the Trace classes; + // adding a trace listener to either class adds the listener to both. + // So we will just use the Trace.Listeners class. if (PlatformType != PlatformType.Windows) { - Debug.Listeners.Add(new TextWriterTraceListener(Console.Out)); Trace.Listeners.Add(new TextWriterTraceListener(Console.Out)); } @@ -63,23 +66,19 @@ SetFolders(); string debugLog = "agate-debuglog.txt"; - string traceLog = "debuglog.txt"; if (HasWriteAccessToAppDirectory()) { debugLog = Path.Combine(mAppDir, debugLog); - traceLog = Path.Combine(mAppDir, traceLog); } else { debugLog = Path.Combine(mAppData, debugLog); - traceLog = Path.Combine(mAppData, traceLog); } try { - Debug.Listeners.Add(new TextWriterTraceListener(new StreamWriter(debugLog))); - Trace.Listeners.Add(new TextWriterTraceListener(new StreamWriter(traceLog))); + Trace.Listeners.Add(new TextWriterTraceListener(new StreamWriter(debugLog))); } catch (Exception) { Modified: trunk/Drivers/AgateOTK/AgateOTK.csproj =================================================================== --- trunk/Drivers/AgateOTK/AgateOTK.csproj 2011-11-21 22:50:40 UTC (rev 1304) +++ trunk/Drivers/AgateOTK/AgateOTK.csproj 2011-11-22 08:02:14 UTC (rev 1305) @@ -1,4 +1,4 @@ -<?xml version="1.0" encoding="utf-8"?> +<?xml version="1.0" encoding="utf-8"?> <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0"> <PropertyGroup> <ProjectType>Local</ProjectType> @@ -165,7 +165,6 @@ <Compile Include="GLDrawBuffer.cs"> <SubType>Code</SubType> </Compile> - <Compile Include="Legacy\FrameBufferArb.cs" /> <Compile Include="Legacy\LegacyDrawBuffer.cs" /> <Compile Include="Legacy\LegacyPrimitiveRenderer.cs" /> <Compile Include="PrimitiveRenderer.cs" /> Modified: trunk/Drivers/AgateOTK/GL_Display.cs =================================================================== --- trunk/Drivers/AgateOTK/GL_Display.cs 2011-11-21 22:50:40 UTC (rev 1304) +++ trunk/Drivers/AgateOTK/GL_Display.cs 2011-11-22 08:02:14 UTC (rev 1305) @@ -146,10 +146,8 @@ protected override FrameBufferImpl CreateFrameBuffer(Size size) { - if (mGL3) + if (mGL3 || mSupportsFramebufferArb) return new GL3.FrameBuffer(size); - else if (mSupportsFramebufferArb) - return new Legacy.FrameBufferArb(size); else if (mSupportsFramebufferExt) { try Modified: trunk/Drivers/AgateOTK/GL_GameWindow.cs =================================================================== --- trunk/Drivers/AgateOTK/GL_GameWindow.cs 2011-11-21 22:50:40 UTC (rev 1304) +++ trunk/Drivers/AgateOTK/GL_GameWindow.cs 2011-11-22 08:02:14 UTC (rev 1305) @@ -31,7 +31,6 @@ namespace AgateOTK { - /// <summary> /// Old, needs to be updated. /// </summary> Deleted: trunk/Drivers/AgateOTK/Legacy/FrameBufferArb.cs =================================================================== --- trunk/Drivers/AgateOTK/Legacy/FrameBufferArb.cs 2011-11-21 22:50:40 UTC (rev 1304) +++ trunk/Drivers/AgateOTK/Legacy/FrameBufferArb.cs 2011-11-22 08:02:14 UTC (rev 1305) @@ -1,121 +0,0 @@ -// The contents of this file are subject to the Mozilla Public License -// Version 1.1 (the "License"); you may not use this file except in -// compliance with the License. You may obtain a copy of the License at -// http://www.mozilla.org/MPL/ -// -// Software distributed under the License is distributed on an "AS IS" -// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the -// License for the specific language governing rights and limitations -// under the License. -// -// The Original Code is AgateLib. -// -// The Initial Developer of the Original Code is Erik Ylvisaker. -// Portions created by Erik Ylvisaker are Copyright (C) 2006-2011. -// All Rights Reserved. -// -// Contributor(s): Erik Ylvisaker -// -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using AgateLib; -using AgateLib.DisplayLib.ImplementationBase; -using AgateLib.Geometry; -using OpenTK.Graphics.OpenGL; -using OTKPixelFormat = OpenTK.Graphics.OpenGL.PixelFormat; - -namespace AgateOTK.Legacy -{ - /// <summary> - /// Framebuffer using ARB extension. - /// </summary> - class FrameBufferArb : GL_FrameBuffer - { - Size mSize; - int mFramebufferID; - int mDepthBuffer; - GL_Surface mTexture; - - public FrameBufferArb(Size size) - { - mSize = size; - - //AgateLib.DisplayLib.PixelBuffer pixels = new AgateLib.DisplayLib.PixelBuffer( - // AgateLib.DisplayLib.PixelFormat.RGBA8888, mSize); - - mTexture = new GL_Surface(mSize); - - // generate the frame buffer - GL.GenFramebuffers(1, out mFramebufferID); - GL.BindFramebuffer(FramebufferTarget.Framebuffer, mFramebufferID); - - // generate a depth buffer to render to - GL.GenRenderbuffers(1, out mDepthBuffer); - GL.BindRenderbuffer(RenderbufferTarget.Renderbuffer, mDepthBuffer); - - // hack here because RenderbufferStorage enum is incomplete. - GL.RenderbufferStorage(RenderbufferTarget.Renderbuffer, - RenderbufferStorage.Depth24Stencil8, - mSize.Width, mSize.Height); - - // attach the depth buffer - GL.FramebufferRenderbuffer(FramebufferTarget.Framebuffer, - FramebufferAttachment.DepthAttachment, RenderbufferTarget.Renderbuffer, - mDepthBuffer); - - // attach the texture - GL.FramebufferTexture2D(FramebufferTarget.Framebuffer, - FramebufferAttachment.ColorAttachment0, TextureTarget.Texture2D, - mTexture.GLTextureID, 0); - - FramebufferErrorCode code = - GL.CheckFramebufferStatus(FramebufferTarget.Framebuffer); - - if (code != FramebufferErrorCode.FramebufferComplete) - { - throw new AgateException( - "Could not complete framebuffer object. Received error code " - + code.ToString()); - } - - mHasDepth = true; - mHasStencil = true; - } - - public override SurfaceImpl RenderTarget - { - get { return mTexture; } - } - public override void Dispose() - { - throw new NotImplementedException(); - } - - public override AgateLib.Geometry.Size Size - { - get { return mSize; } - } - - public override void BeginRender() - { - GL.BindFramebuffer(FramebufferTarget.Framebuffer, mFramebufferID); - //GL.PushAttrib(AttribMask.ViewportBit); - } - - public override void EndRender() - { - //GL.PopAttrib(); - GL.BindFramebuffer(FramebufferTarget.Framebuffer, 0); - - GL.BindTexture(TextureTarget.Texture2D, mTexture.GLTextureID); - GL.GenerateMipmap(GenerateMipmapTarget.Texture2D); - } - - public override void MakeCurrent() - { - GL.BindFramebuffer(FramebufferTarget.Framebuffer, mFramebufferID); - } - } -} Modified: trunk/Tests/AudioTests/AudioPlayer/AudioPlayer.cs =================================================================== --- trunk/Tests/AudioTests/AudioPlayer/AudioPlayer.cs 2011-11-21 22:50:40 UTC (rev 1304) +++ trunk/Tests/AudioTests/AudioPlayer/AudioPlayer.cs 2011-11-22 08:02:14 UTC (rev 1305) @@ -17,7 +17,6 @@ { using (AgateLib.AgateSetup setup = new AgateLib.AgateSetup("Agate Audio Tester", args)) { - setup.AskUser = true; setup.Initialize(false, true, false); if (setup.WasCanceled) return; Modified: trunk/Tests/AudioTests/StreamAudio.cs =================================================================== --- trunk/Tests/AudioTests/StreamAudio.cs 2011-11-21 22:50:40 UTC (rev 1304) +++ trunk/Tests/AudioTests/StreamAudio.cs 2011-11-22 08:02:14 UTC (rev 1305) @@ -107,7 +107,6 @@ { using (AgateSetup setup = new AgateSetup()) { - setup.AskUser = true; setup.Initialize(true, true, false); if (setup.WasCanceled) return; Modified: trunk/Tests/CoreTests/TgzProviderTester.cs =================================================================== --- trunk/Tests/CoreTests/TgzProviderTester.cs 2011-11-21 22:50:40 UTC (rev 1304) +++ trunk/Tests/CoreTests/TgzProviderTester.cs 2011-11-22 08:02:14 UTC (rev 1305) @@ -16,7 +16,6 @@ using (AgateSetup setup = new AgateSetup()) { - setup.AskUser = true; setup.Initialize(true, false, false); if (setup.WasCanceled) return; Modified: trunk/Tests/CoreTests/ZipProviderTester.cs =================================================================== --- trunk/Tests/CoreTests/ZipProviderTester.cs 2011-11-21 22:50:40 UTC (rev 1304) +++ trunk/Tests/CoreTests/ZipProviderTester.cs 2011-11-22 08:02:14 UTC (rev 1305) @@ -17,7 +17,6 @@ using (AgateSetup setup = new AgateSetup()) { - setup.AskUser = true; setup.Initialize(true, false, false); if (setup.WasCanceled) return; Modified: trunk/Tests/DisplayTests/BasicDrawing/BasicDrawing.cs =================================================================== --- trunk/Tests/DisplayTests/BasicDrawing/BasicDrawing.cs 2011-11-21 22:50:40 UTC (rev 1304) +++ trunk/Tests/DisplayTests/BasicDrawing/BasicDrawing.cs 2011-11-22 08:02:14 UTC (rev 1305) @@ -84,7 +84,6 @@ Random rand = new Random(); // initialize the display, asking the user what display driver to use. - setup.AskUser = true; setup.Initialize(true, false, false); // normally, the display should initialize fine, and goahead will be true. Modified: trunk/Tests/DisplayTests/Capabilities/Capabilities.cs =================================================================== --- trunk/Tests/DisplayTests/Capabilities/Capabilities.cs 2011-11-21 22:50:40 UTC (rev 1304) +++ trunk/Tests/DisplayTests/Capabilities/Capabilities.cs 2011-11-22 08:02:14 UTC (rev 1305) @@ -23,7 +23,6 @@ { using (AgateLib.AgateSetup setup = new AgateLib.AgateSetup()) { - setup.AskUser = true; setup.Initialize(true, false, false); if (setup.WasCanceled) return; Modified: trunk/Tests/DisplayTests/ClipRect.cs =================================================================== --- trunk/Tests/DisplayTests/ClipRect.cs 2011-11-21 22:50:40 UTC (rev 1304) +++ trunk/Tests/DisplayTests/ClipRect.cs 2011-11-22 08:02:14 UTC (rev 1305) @@ -26,7 +26,6 @@ { using (AgateSetup setup = new AgateSetup()) { - setup.AskUser = true; setup.Initialize(true, false, false); if (setup.WasCanceled) return; Modified: trunk/Tests/DisplayTests/ColorTest.cs =================================================================== --- trunk/Tests/DisplayTests/ColorTest.cs 2011-11-21 22:50:40 UTC (rev 1304) +++ trunk/Tests/DisplayTests/ColorTest.cs 2011-11-22 08:02:14 UTC (rev 1305) @@ -26,7 +26,6 @@ { using (AgateSetup setup = new AgateSetup()) { - setup.AskUser = true; setup.Initialize(true, false, false); if (setup.WasCanceled) return; Modified: trunk/Tests/DisplayTests/PixelBufferMask.cs =================================================================== --- trunk/Tests/DisplayTests/PixelBufferMask.cs 2011-11-21 22:50:40 UTC (rev 1304) +++ trunk/Tests/DisplayTests/PixelBufferMask.cs 2011-11-22 08:02:14 UTC (rev 1305) @@ -25,7 +25,6 @@ { using (AgateSetup setup = new AgateSetup()) { - setup.AskUser = true; setup.InitializeAll(); if (setup.WasCanceled) Modified: trunk/Tests/DisplayTests/PixelBufferTest/PixelBufferTest.cs =================================================================== --- trunk/Tests/DisplayTests/PixelBufferTest/PixelBufferTest.cs 2011-11-21 22:50:40 UTC (rev 1304) +++ trunk/Tests/DisplayTests/PixelBufferTest/PixelBufferTest.cs 2011-11-22 08:02:14 UTC (rev 1305) @@ -26,7 +26,6 @@ { using (AgateSetup setup = new AgateSetup(args)) { - setup.AskUser = true; setup.Initialize(true, false, false); if (setup.WasCanceled) return; Modified: trunk/Tests/DisplayTests/Prerendered.cs =================================================================== --- trunk/Tests/DisplayTests/Prerendered.cs 2011-11-21 22:50:40 UTC (rev 1304) +++ trunk/Tests/DisplayTests/Prerendered.cs 2011-11-22 08:02:14 UTC (rev 1305) @@ -23,7 +23,6 @@ { using (AgateSetup setup = new AgateSetup()) { - setup.AskUser = true; setup.Initialize(true, false, true); if (setup.WasCanceled) return; Modified: trunk/Tests/DisplayTests/ScreenCapture.cs =================================================================== --- trunk/Tests/DisplayTests/ScreenCapture.cs 2011-11-21 22:50:40 UTC (rev 1304) +++ trunk/Tests/DisplayTests/ScreenCapture.cs 2011-11-22 08:02:14 UTC (rev 1305) @@ -23,7 +23,6 @@ { using (AgateSetup setup = new AgateSetup()) { - setup.AskUser = true; setup.Initialize(true, false, false); if (setup.WasCanceled) return; Modified: trunk/Tests/DisplayTests/SurfaceTester/SurfaceTester.cs =================================================================== --- trunk/Tests/DisplayTests/SurfaceTester/SurfaceTester.cs 2011-11-21 22:50:40 UTC (rev 1304) +++ trunk/Tests/DisplayTests/SurfaceTester/SurfaceTester.cs 2011-11-22 08:02:14 UTC (rev 1305) @@ -25,7 +25,6 @@ using (AgateSetup displaySetup = new AgateSetup(args)) { - displaySetup.AskUser = true; displaySetup.Initialize(true, false, false); if (displaySetup.WasCanceled) return; Modified: trunk/Tests/DisplayTests/TileTester/TileTester.cs =================================================================== --- trunk/Tests/DisplayTests/TileTester/TileTester.cs 2011-11-21 22:50:40 UTC (rev 1304) +++ trunk/Tests/DisplayTests/TileTester/TileTester.cs 2011-11-22 08:02:14 UTC (rev 1305) @@ -24,7 +24,6 @@ { using (AgateSetup setup = new AgateSetup()) { - setup.AskUser = true; setup.Initialize(true, false, false); if (setup.WasCanceled) return; Modified: trunk/Tests/DisplayTests/Tiling.cs =================================================================== --- trunk/Tests/DisplayTests/Tiling.cs 2011-11-21 22:50:40 UTC (rev 1304) +++ trunk/Tests/DisplayTests/Tiling.cs 2011-11-22 08:02:14 UTC (rev 1305) @@ -20,7 +20,6 @@ { using (AgateSetup setup = new AgateSetup("Tiling Test", args)) { - setup.AskUser = true; setup.Initialize(true, false, false); if (setup.WasCanceled) Modified: trunk/Tests/Fonts/BitmapFonts.cs =================================================================== --- trunk/Tests/Fonts/BitmapFonts.cs 2011-11-21 22:50:40 UTC (rev 1304) +++ trunk/Tests/Fonts/BitmapFonts.cs 2011-11-22 08:02:14 UTC (rev 1305) @@ -22,7 +22,6 @@ { using (AgateSetup setup = new AgateSetup(args)) { - setup.AskUser = true; setup.Initialize(true, false, false); if (setup.WasCanceled) return; Modified: trunk/Tests/Fonts/FontLineTester.cs =================================================================== --- trunk/Tests/Fonts/FontLineTester.cs 2011-11-21 22:50:40 UTC (rev 1304) +++ trunk/Tests/Fonts/FontLineTester.cs 2011-11-22 08:02:14 UTC (rev 1305) @@ -28,7 +28,6 @@ { using (AgateSetup setup = new AgateSetup()) { - setup.AskUser = true; setup.Initialize(true, false, false); if (setup.WasCanceled) return; Modified: trunk/Tests/Fonts/Fonts.cs =================================================================== --- trunk/Tests/Fonts/Fonts.cs 2011-11-21 22:50:40 UTC (rev 1304) +++ trunk/Tests/Fonts/Fonts.cs 2011-11-22 08:02:14 UTC (rev 1305) @@ -24,7 +24,6 @@ { using (AgateSetup setupDisplay = new AgateSetup()) { - setupDisplay.AskUser = true; setupDisplay.Initialize(true, false, false); if (setupDisplay.WasCanceled) Modified: trunk/Tests/Fonts/Kerning.cs =================================================================== --- trunk/Tests/Fonts/Kerning.cs 2011-11-21 22:50:40 UTC (rev 1304) +++ trunk/Tests/Fonts/Kerning.cs 2011-11-22 08:02:14 UTC (rev 1305) @@ -28,7 +28,6 @@ { using (var setup = new AgateSetup()) { - setup.AskUser = true; setup.Initialize(true, false, false); if (setup.WasCanceled) return; Modified: trunk/Tests/InputTests/Input/InputTester.cs =================================================================== --- trunk/Tests/InputTests/Input/InputTester.cs 2011-11-21 22:50:40 UTC (rev 1304) +++ trunk/Tests/InputTests/Input/InputTester.cs 2011-11-22 08:02:14 UTC (rev 1305) @@ -21,7 +21,6 @@ { using (AgateSetup setup = new AgateSetup(args)) { - setup.AskUser = true; setup.Initialize(true, false, true); if (setup.WasCanceled) return; Modified: trunk/Tests/Launcher.cs =================================================================== --- trunk/Tests/Launcher.cs 2011-11-21 22:50:40 UTC (rev 1304) +++ trunk/Tests/Launcher.cs 2011-11-22 08:02:14 UTC (rev 1305) @@ -13,7 +13,7 @@ public static void Main(string[] args) { AgateFileProvider.Images.AddPath("Data"); - + Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new frmLauncher()); Modified: trunk/Tests/Shaders/CoordinateSystem.cs =================================================================== --- trunk/Tests/Shaders/CoordinateSystem.cs 2011-11-21 22:50:40 UTC (rev 1304) +++ trunk/Tests/Shaders/CoordinateSystem.cs 2011-11-22 08:02:14 UTC (rev 1305) @@ -26,7 +26,6 @@ { using (AgateSetup setup = new AgateSetup()) { - setup.AskUser = true; setup.Initialize(true, false, false); if (setup.WasCanceled) return; Modified: trunk/Tests/Shaders/Lighting3DTest.cs =================================================================== --- trunk/Tests/Shaders/Lighting3DTest.cs 2011-11-21 22:50:40 UTC (rev 1304) +++ trunk/Tests/Shaders/Lighting3DTest.cs 2011-11-22 08:02:14 UTC (rev 1305) @@ -38,7 +38,6 @@ { using (var setup = new AgateSetup()) { - setup.AskUser = true; setup.Initialize(true, false, false); if (setup.WasCanceled) return; Modified: trunk/Tests/Shaders/LightingTest/LightingTest.cs =================================================================== --- trunk/Tests/Shaders/LightingTest/LightingTest.cs 2011-11-21 22:50:40 UTC (rev 1304) +++ trunk/Tests/Shaders/LightingTest/LightingTest.cs 2011-11-22 08:02:14 UTC (rev 1305) @@ -23,8 +23,6 @@ { using (AgateSetup setup = new AgateSetup(args)) { - setup.AskUser = true; - setup.PreferredDisplay = AgateLib.Drivers.DisplayTypeID.OpenGL; setup.Initialize(true, false, false); if (setup.WasCanceled) return; Modified: trunk/Tests/frmLauncher.Designer.cs =================================================================== --- trunk/Tests/frmLauncher.Designer.cs 2011-11-21 22:50:40 UTC (rev 1304) +++ trunk/Tests/frmLauncher.Designer.cs 2011-11-22 08:02:14 UTC (rev 1305) @@ -35,103 +35,98 @@ this.label1 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label(); this.label3 = new System.Windows.Forms.Label(); - this.SuspendLayout(); - // - // lstTests - // - this.lstTests.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.lstTests.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed; - this.lstTests.FormattingEnabled = true; - this.lstTests.Location = new System.Drawing.Point(12, 95); - this.lstTests.MultiColumn = true; - this.lstTests.Name = "lstTests"; - this.lstTests.Size = new System.Drawing.Size(513, 285); - this.lstTests.TabIndex = 0; - this.lstTests.DrawItem += new System.Windows.Forms.DrawItemEventHandler(this.lstTests_DrawItem); - this.lstTests.DoubleClick += new System.EventHandler(this.lstTests_DoubleClick); - this.lstTests.KeyUp += new System.Windows.Forms.KeyEventHandler(this.lstTests_KeyUp); - // - // displayList - // - this.displayList.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.displayList.DisplayMember = "FriendlyName"; - this.displayList.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.displayList.FormattingEnabled = true; - this.displayList.Location = new System.Drawing.Point(76, 12); - this.displayList.Name = "displayList"; - this.displayList.Size = new System.Drawing.Size(228, 21); - this.displayList.TabIndex = 8; - // - // label1 - // - this.label1.Location = new System.Drawing.Point(12, 15); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(58, 27); - this.label1.TabIndex = 9; - this.label1.Text = "Display"; - this.label1.TextAlign = System.Drawing.ContentAlignment.TopRight; - // - // label2 - // - this.label2.Location = new System.Drawing.Point(12, 69); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(58, 30); - this.label2.TabIndex = 11; - this.label2.Text = "Input"; - this.label2.TextAlign = System.Drawing.ContentAlignment.TopRight; - // - // inputList - // - this.inputList.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.inputList.DisplayMember = "FriendlyName"; - this.inputList.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.inputList.FormattingEnabled = true; - this.inputList.Location = new System.Drawing.Point(76, 66); - this.inputList.Name = "inputList"; - this.inputList.Size = new System.Drawing.Size(228, 21); - this.inputList.TabIndex = 10; - // - // label3 - // - this.label3.Location = new System.Drawing.Point(12, 42); - this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(58, 27); - this.label3.TabIndex = 13; - this.label3.Text = "Audio"; - this.label3.TextAlign = System.Drawing.ContentAlignment.TopRight; - // - // audioList - // - this.audioList.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.audioList.DisplayMember = "FriendlyName"; - this.audioList.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.audioList.FormattingEnabled = true; - this.audioList.Location = new System.Drawing.Point(76, 39); - this.audioList.Name = "audioList"; - this.audioList.Size = new System.Drawing.Size(228, 21); - this.audioList.TabIndex = 12; - // - // frmLauncher - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(537, 391); - this.Controls.Add(this.lstTests); + this.SuspendLayout(); + // + // lstTests + // + this.lstTests.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.lstTests.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed; + this.lstTests.FormattingEnabled = true; + this.lstTests.Location = new System.Drawing.Point(324, 12); + this.lstTests.MultiColumn = true; + this.lstTests.Name = "lstTests"; + this.lstTests.Size = new System.Drawing.Size(349, 472); + this.lstTests.TabIndex = 0; + this.lstTests.DrawItem += new System.Windows.Forms.DrawItemEventHandler(this.lstTests_DrawItem); + this.lstTests.DoubleClick += new System.EventHandler(this.lstTests_DoubleClick); + this.lstTests.KeyUp += new System.Windows.Forms.KeyEventHandler(this.lstTests_KeyUp); + // + // displayList + // + this.displayList.DisplayMember = "FriendlyName"; + this.displayList.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.displayList.FormattingEnabled = true; + this.displayList.Location = new System.Drawing.Point(70, 12); + this.displayList.Name = "displayList"; + this.displayList.Size = new System.Drawing.Size(229, 21); + this.displayList.TabIndex = 8; + // + // inputList + // + this.inputList.DisplayMember = "FriendlyName"; + this.inputList.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.inputList.FormattingEnabled = true; + this.inputList.Location = new System.Drawing.Point(70, 66); + this.inputList.Name = "inputList"; + this.inputList.Size = new System.Drawing.Size(229, 21); + this.inputList.TabIndex = 10; + // + // audioList + // + this.audioList.DisplayMember = "FriendlyName"; + this.audioList.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.audioList.FormattingEnabled = true; + this.audioList.Location = new System.Drawing.Point(70, 39); + this.audioList.Name = "audioList"; + this.audioList.Size = new System.Drawing.Size(229, 21); + this.audioList.TabIndex = 12; + // + // label1 + // + this.label1.Location = new System.Drawing.Point(9, 15); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(55, 18); + this.label1.TabIndex = 9; + this.label1.Text = "Display"; + this.label1.TextAlign = System.Drawing.ContentAlignment.TopRight; + // + // label2 + // + this.label2.Location = new System.Drawing.Point(24, 69); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(40, 18); + this.label2.TabIndex = 11; + this.label2.Text = "Input"; + this.label2.TextAlign = System.Drawing.ContentAlignment.TopRight; + // + // label3 + // + this.label3.Location = new System.Drawing.Point(23, 42); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(41, 18); + this.label3.TabIndex = 13; + this.label3.Text = "Audio"; + this.label3.TextAlign = System.Drawing.ContentAlignment.TopRight; + // + // frmLauncher + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(685, 494); + this.Controls.Add(this.lstTests); this.Controls.Add(this.inputList); this.Controls.Add(this.audioList); ... [truncated message content] |
From: <ka...@us...> - 2011-11-21 22:50:54
|
Revision: 1304 http://agate.svn.sourceforge.net/agate/?rev=1304&view=rev Author: kanato Date: 2011-11-21 22:50:40 +0000 (Mon, 21 Nov 2011) Log Message: ----------- Add drop down boxes in tester window for driver selection. Modified Paths: -------------- trunk/AgateLib/AgateLib.csproj trunk/AgateLib/AgateSetup.cs trunk/AgateLib/Drivers/Registrar.cs trunk/AgateLib/Settings/PersistantSettings.cs trunk/AgateLib/Settings/SettingsGroup.cs trunk/Drivers/AgateOTK/AgateOTK.csproj trunk/Drivers/AgateSDL/AgateSDL.csproj trunk/Tests/DisplayTests/Capabilities/frmCapabilities.cs trunk/Tests/DisplayTests/MultipleWindows/MultipleWindowTest.cs trunk/Tests/frmLauncher.Designer.cs trunk/Tests/frmLauncher.cs trunk/Tools/DatabaseEditor/DatabaseEditor.csproj trunk/Tools/DatabaseEditor/frmDesignTable.cs trunk/Tools/FontCreator/FontCreator.csproj Modified: trunk/AgateLib/AgateLib.csproj =================================================================== --- trunk/AgateLib/AgateLib.csproj 2011-11-21 22:29:19 UTC (rev 1303) +++ trunk/AgateLib/AgateLib.csproj 2011-11-21 22:50:40 UTC (rev 1304) @@ -1,4 +1,4 @@ -<?xml version="1.0" encoding="utf-8"?> +<?xml version="1.0" encoding="utf-8"?> <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0"> <PropertyGroup> <ProjectType>Local</ProjectType> Modified: trunk/AgateLib/AgateSetup.cs =================================================================== --- trunk/AgateLib/AgateSetup.cs 2011-11-21 22:29:19 UTC (rev 1303) +++ trunk/AgateLib/AgateSetup.cs 2011-11-21 22:50:40 UTC (rev 1304) @@ -1,349 +1,349 @@ -// The contents of this file are subject to the Mozilla Public License -// Version 1.1 (the "License"); you may not use this file except in -// compliance with the License. You may obtain a copy of the License at -// http://www.mozilla.org/MPL/ -// -// Software distributed under the License is distributed on an "AS IS" -// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the -// License for the specific language governing rights and limitations -// under the License. -// -// The Original Code is AgateLib. -// -// The Initial Developer of the Original Code is Erik Ylvisaker. -// Portions created by Erik Ylvisaker are Copyright (C) 2006-2011. -// All Rights Reserved. -// -// Contributor(s): Erik Ylvisaker -// -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Text; - -using AgateLib.AudioLib; -using AgateLib.DisplayLib; -using AgateLib.Drivers; - -namespace AgateLib -{ - /// <summary> - /// Class which is designed to simplify initialization and de-initialization of the - /// library. It is recommended to have a Setup object in a using block around your game - /// code so that calling Dispose is guaranteed. - /// - /// If the program arguments are supplied, you can allow the user to choose which drivers - /// are used, if the --choose option is specified. - /// - /// <example>This example shows a typical development pattern for the use of an AgateSetup object. - /// <code> - /// using System; - /// using System.Collections.Generic; - /// using AgateLib; - /// - /// public static void Main(string[] args) - /// { - /// using(AgateSetup setup = new AgateSetup("My Application Name", args)) - /// { - /// setup.InitializeAll(); - /// if (setup.WasCanceled) - /// return; - /// - /// // TODO: write game here - /// } - /// } - /// </code> - /// </example> - /// </summary> - public sealed class AgateSetup : IDisposable - { - private static AgateSetup sCreatedSetup; - - private bool mWasCanceled = false; - private bool mAskUser = false; - private bool mAlreadyAsked = false; - private string mTitle = "AgateLib"; - - private bool mUseDisplay = true; - 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; - - private string mCompanyName; - private string mAppName; - - /// <summary> - /// Indicates the display id that is preferred by the user or application. - /// </summary> - public DisplayTypeID PreferredDisplay - { - get { return mPreferredDisplay; } - set { mPreferredDisplay = value; } - } - /// <summary> - /// Indicates the audio id that is preferred by the user or application. - /// </summary> - public AudioTypeID PreferredAudio - { - get { return mPreferredAudio; } - set { mPreferredAudio = value; } - } - /// <summary> - /// Indicates the input id that is preferred by the user or application. - /// </summary> - public InputTypeID PreferredInput - { - get { return mPreferredInput; } - set { mPreferredInput = value; } - } - - /// <summary> - /// Constructs a Setup object. - /// </summary> - public AgateSetup() : this("AgateLib", null) - { - - Core.Initialize(); - } - /// <summary> - /// Constructs a Setup object. - /// </summary> - /// <param name="title"></param> - public AgateSetup(string title) - : this(title, null) - { - } - /// <summary> - /// Constructs a Setup object. - /// </summary> - /// <param name="args">Command line arguments to the program.</param> - public AgateSetup(IEnumerable<string> args) - : this("AgateLib", args) - { - } - /// <summary> - /// Constructs a Setup object. - /// </summary> - /// <param name="title"></param> - /// <param name="args">Command line arguments to the program.</param> - public AgateSetup(string title, IEnumerable<string> args) - { - if (sCreatedSetup != null) - { - throw new AgateException("Error: You have created a second AgateSetup object without disposing the previous one."); - } - - sCreatedSetup = this; - - mTitle = title; - - if (args != null) - { - foreach (string s in args) - { - if (s == "--choose") - mAskUser = true; - } - } - } - /// <summary> - /// Initializes the specified components. This sets the values of UseDisplay, - /// UseAudio, and UseInput to the values passed in. - /// </summary> - /// <param name="display"></param> - /// <param name="audio"></param> - /// <param name="input"></param> - public void Initialize(bool display, bool audio, bool input) - { - mUseDisplay = display; - mUseAudio = audio; - mUseInput = input; - - InitializeAll(); - } - /// <summary> - /// Initializes the Display, Audio and Input controllers. - /// </summary> - public void InitializeAll() - { - if (mUseDisplay) - InitializeDisplay(); - - if (mUseAudio) - InitializeAudio(); - - if (mUseInput) - InitializeInput(); - - if (string.IsNullOrEmpty(mAppName) == false) - { - Core.Platform.SetFolderPaths(mCompanyName, mAppName); - } - } - - /// <summary> - /// Gets or sets the company name. - /// </summary> - public string CompanyName { get { return mCompanyName; } set { mCompanyName = value; } } - /// <summary> - /// Gets or sets the application name. - /// </summary> - public string ApplicationName { get { return mAppName; } set { mAppName = value; } } - - /// <summary> - /// Initializes the Display. - /// Automatically selects the driver to use, or asks the user which - /// driver to use if appropriate. - /// </summary> - private void InitializeDisplay() - { - DoAskUser(); - InitializeDisplay(mSelectDisplay); - } - - /// <summary> - /// Initializes the display to the specified subsystem. - /// </summary> - /// <param name="type"></param> - public void InitializeDisplay(DisplayTypeID type) - { - if (WasCanceled) - return; - - Display.Initialize(type); - } - /// <summary> - /// Initializes the Audio subsystem. - /// Automatically picks which driver to use. - /// </summary> - private void InitializeAudio() - { - DoAskUser(); - InitializeAudio(mSelectAudio); - } - /// <summary> - /// Initializes the Audio subsystem, to the specified driver. - /// </summary> - /// <param name="type"></param> - public void InitializeAudio(AudioTypeID type) - { - if (WasCanceled) - return; - - AudioLib.Audio.Initialize(type); - } - - /// <summary> - /// Initializes the Input subsystem. - /// Automatically picks which driver to use. - /// </summary> - private void InitializeInput() - { - DoAskUser(); - InitializeInput(mSelectInput); - } - /// <summary> - /// Initializes the Input subsystem, to the specified driver. - /// </summary> - /// <param name="inputTypeID"></param> - public void InitializeInput(InputTypeID inputTypeID) - { - if (WasCanceled) - return; - - InputLib.JoystickInput.Initialize(inputTypeID); - - } - /// <summary> - /// Disposes of the SetupDisplay object and all initialized sub-systems. - /// </summary> - public void Dispose() - { - Display.Dispose(); - Audio.Dispose(); - InputLib.JoystickInput.Dispose(); - - if (sCreatedSetup == this) - sCreatedSetup = null; - } - - /// <summary> - /// Returns true if the user hit cancel in any dialog box that showed up - /// asking the user what driver to use, or if initialization failed. - /// </summary> - public bool WasCanceled - { - get { return mWasCanceled; } - } - /// <summary> - /// Gets or sets a bool value which indicates whether or not the user - /// should be asked which driver(s) to use when Agate is initialized. - /// </summary> - /// <remarks> - /// This setting can be useful for debugging, especially when comparing - /// OpenGL vs. DirectX behavior and performance. - /// It is recommended to have AskUser turned off for release builds, however. - /// </remarks> - public bool AskUser - { - get { return mAskUser; } - set { mAskUser = value; } - } - /// <summary> - /// Gets or sets a bool value which indicates whether or not the display - /// should be initialized. - /// </summary> - public bool UseDisplay - { - get { return mUseDisplay; } - set { mUseDisplay = value; } - } - /// <summary> - /// Gets or sets a bool value which indicates whether or not the audio system - /// should be initialized. - /// </summary> - public bool UseAudio - { - get { return mUseAudio; } - set { mUseAudio = value; } - } - /// <summary> - /// Gets or sets a bool value which indicates whether or not the input system - /// should be initialized. - /// </summary> - public bool UseInput - { - get { return mUseInput; } - set { mUseInput = value; } - } - - /// <summary> - /// Checks to see whether or not the user needs to be asked, and asks them - /// if so. - /// </summary> - private void DoAskUser() - { - Core.Initialize(); - - if (mAlreadyAsked) - return; - if (mAskUser == false) - return; - - mWasCanceled = !Registrar.UserSelectDrivers(mUseDisplay, mUseAudio, mUseInput, - mPreferredDisplay, mPreferredAudio, mPreferredInput , - out mSelectDisplay, out mSelectAudio, out mSelectInput); - - mAlreadyAsked = true; - } - - } - -} +// The contents of this file are subject to the Mozilla Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.mozilla.org/MPL/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations +// under the License. +// +// The Original Code is AgateLib. +// +// The Initial Developer of the Original Code is Erik Ylvisaker. +// Portions created by Erik Ylvisaker are Copyright (C) 2006-2011. +// All Rights Reserved. +// +// Contributor(s): Erik Ylvisaker +// +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Text; + +using AgateLib.AudioLib; +using AgateLib.DisplayLib; +using AgateLib.Drivers; + +namespace AgateLib +{ + /// <summary> + /// Class which is designed to simplify initialization and de-initialization of the + /// library. It is recommended to have a Setup object in a using block around your game + /// code so that calling Dispose is guaranteed. + /// + /// If the program arguments are supplied, you can allow the user to choose which drivers + /// are used, if the --choose option is specified. + /// + /// <example>This example shows a typical development pattern for the use of an AgateSetup object. + /// <code> + /// using System; + /// using System.Collections.Generic; + /// using AgateLib; + /// + /// public static void Main(string[] args) + /// { + /// using(AgateSetup setup = new AgateSetup("My Application Name", args)) + /// { + /// setup.InitializeAll(); + /// if (setup.WasCanceled) + /// return; + /// + /// // TODO: write game here + /// } + /// } + /// </code> + /// </example> + /// </summary> + public sealed class AgateSetup : IDisposable + { + private static AgateSetup sCreatedSetup; + + private bool mWasCanceled = false; + private bool mAskUser = false; + private bool mAlreadyAsked = false; + private string mTitle = "AgateLib"; + + private bool mUseDisplay = true; + 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; + + private string mCompanyName; + private string mAppName; + + /// <summary> + /// Indicates the display id that is preferred by the user or application. + /// </summary> + public DisplayTypeID PreferredDisplay + { + get { return mPreferredDisplay; } + set { mPreferredDisplay = value; } + } + /// <summary> + /// Indicates the audio id that is preferred by the user or application. + /// </summary> + public AudioTypeID PreferredAudio + { + get { return mPreferredAudio; } + set { mPreferredAudio = value; } + } + /// <summary> + /// Indicates the input id that is preferred by the user or application. + /// </summary> + public InputTypeID PreferredInput + { + get { return mPreferredInput; } + set { mPreferredInput = value; } + } + + /// <summary> + /// Constructs a Setup object. + /// </summary> + public AgateSetup() : this("AgateLib", null) + { + + Core.Initialize(); + } + /// <summary> + /// Constructs a Setup object. + /// </summary> + /// <param name="title"></param> + public AgateSetup(string title) + : this(title, null) + { + } + /// <summary> + /// Constructs a Setup object. + /// </summary> + /// <param name="args">Command line arguments to the program.</param> + public AgateSetup(IEnumerable<string> args) + : this("AgateLib", args) + { + } + /// <summary> + /// Constructs a Setup object. + /// </summary> + /// <param name="title"></param> + /// <param name="args">Command line arguments to the program.</param> + public AgateSetup(string title, IEnumerable<string> args) + { + if (sCreatedSetup != null) + { + throw new AgateException("Error: You have created a second AgateSetup object without disposing the previous one."); + } + + sCreatedSetup = this; + + mTitle = title; + + if (args != null) + { + foreach (string s in args) + { + if (s == "--choose") + mAskUser = true; + } + } + } + /// <summary> + /// Initializes the specified components. This sets the values of UseDisplay, + /// UseAudio, and UseInput to the values passed in. + /// </summary> + /// <param name="display"></param> + /// <param name="audio"></param> + /// <param name="input"></param> + public void Initialize(bool display, bool audio, bool input) + { + mUseDisplay = display; + mUseAudio = audio; + mUseInput = input; + + InitializeAll(); + } + /// <summary> + /// Initializes the Display, Audio and Input controllers. + /// </summary> + public void InitializeAll() + { + if (mUseDisplay) + InitializeDisplay(); + + if (mUseAudio) + InitializeAudio(); + + if (mUseInput) + InitializeInput(); + + if (string.IsNullOrEmpty(mAppName) == false) + { + Core.Platform.SetFolderPaths(mCompanyName, mAppName); + } + } + + /// <summary> + /// Gets or sets the company name. + /// </summary> + public string CompanyName { get { return mCompanyName; } set { mCompanyName = value; } } + /// <summary> + /// Gets or sets the application name. + /// </summary> + public string ApplicationName { get { return mAppName; } set { mAppName = value; } } + + /// <summary> + /// Initializes the Display. + /// Automatically selects the driver to use, or asks the user which + /// driver to use if appropriate. + /// </summary> + private void InitializeDisplay() + { + DoAskUser(); + InitializeDisplay(mSelectDisplay); + } + + /// <summary> + /// Initializes the display to the specified subsystem. + /// </summary> + /// <param name="type"></param> + public void InitializeDisplay(DisplayTypeID type) + { + if (WasCanceled) + return; + + Display.Initialize(type); + } + /// <summary> + /// Initializes the Audio subsystem. + /// Automatically picks which driver to use. + /// </summary> + private void InitializeAudio() + { + DoAskUser(); + InitializeAudio(mSelectAudio); + } + /// <summary> + /// Initializes the Audio subsystem, to the specified driver. + /// </summary> + /// <param name="type"></param> + public void InitializeAudio(AudioTypeID type) + { + if (WasCanceled) + return; + + AudioLib.Audio.Initialize(type); + } + + /// <summary> + /// Initializes the Input subsystem. + /// Automatically picks which driver to use. + /// </summary> + private void InitializeInput() + { + DoAskUser(); + InitializeInput(mSelectInput); + } + /// <summary> + /// Initializes the Input subsystem, to the specified driver. + /// </summary> + /// <param name="inputTypeID"></param> + public void InitializeInput(InputTypeID inputTypeID) + { + if (WasCanceled) + return; + + InputLib.JoystickInput.Initialize(inputTypeID); + + } + /// <summary> + /// Disposes of the SetupDisplay object and all initialized sub-systems. + /// </summary> + public void Dispose() + { + Display.Dispose(); + Audio.Dispose(); + InputLib.JoystickInput.Dispose(); + + if (sCreatedSetup == this) + sCreatedSetup = null; + } + + /// <summary> + /// Returns true if the user hit cancel in any dialog box that showed up + /// asking the user what driver to use, or if initialization failed. + /// </summary> + public bool WasCanceled + { + get { return mWasCanceled; } + } + /// <summary> + /// Gets or sets a bool value which indicates whether or not the user + /// should be asked which driver(s) to use when Agate is initialized. + /// </summary> + /// <remarks> + /// This setting can be useful for debugging, especially when comparing + /// OpenGL vs. DirectX behavior and performance. + /// It is recommended to have AskUser turned off for release builds, however. + /// </remarks> + public bool AskUser + { + get { return mAskUser; } + set { mAskUser = value; } + } + /// <summary> + /// Gets or sets a bool value which indicates whether or not the display + /// should be initialized. + /// </summary> + public bool UseDisplay + { + get { return mUseDisplay; } + set { mUseDisplay = value; } + } + /// <summary> + /// Gets or sets a bool value which indicates whether or not the audio system + /// should be initialized. + /// </summary> + public bool UseAudio + { + get { return mUseAudio; } + set { mUseAudio = value; } + } + /// <summary> + /// Gets or sets a bool value which indicates whether or not the input system + /// should be initialized. + /// </summary> + public bool UseInput + { + get { return mUseInput; } + set { mUseInput = value; } + } + + /// <summary> + /// Checks to see whether or not the user needs to be asked, and asks them + /// if so. + /// </summary> + private void DoAskUser() + { + Core.Initialize(); + + if (mAlreadyAsked) + return; + if (mAskUser == false) + return; + + mWasCanceled = !Registrar.UserSelectDrivers(mUseDisplay, mUseAudio, mUseInput, + mPreferredDisplay, mPreferredAudio, mPreferredInput , + out mSelectDisplay, out mSelectAudio, out mSelectInput); + + mAlreadyAsked = true; + } + + } + +} Modified: trunk/AgateLib/Drivers/Registrar.cs =================================================================== --- trunk/AgateLib/Drivers/Registrar.cs 2011-11-21 22:29:19 UTC (rev 1303) +++ trunk/AgateLib/Drivers/Registrar.cs 2011-11-21 22:50:40 UTC (rev 1304) @@ -1,456 +1,497 @@ -// The contents of this file are subject to the Mozilla Public License -// Version 1.1 (the "License"); you may not use this file except in -// compliance with the License. You may obtain a copy of the License at -// http://www.mozilla.org/MPL/ -// -// Software distributed under the License is distributed on an "AS IS" -// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the -// License for the specific language governing rights and limitations -// under the License. -// -// The Original Code is AgateLib. -// -// The Initial Developer of the Original Code is Erik Ylvisaker. -// Portions created by Erik Ylvisaker are Copyright (C) 2006-2011. -// All Rights Reserved. -// -// Contributor(s): Erik Ylvisaker -// -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Linq; -using System.Reflection; -using System.Text; -using AgateLib.AudioLib.ImplementationBase; -using AgateLib.DisplayLib.ImplementationBase; -using AgateLib.InputLib.ImplementationBase; -using AgateLib.Utility; - -namespace AgateLib.Drivers -{ - /// <summary> - /// Static class with which drivers register themselves so that the library can - /// instantiate them. - /// </summary> - public static class Registrar - { - private static List<AgateDriverInfo> - displayDrivers = new List<AgateDriverInfo>(), - audioDrivers = new List<AgateDriverInfo>(), - inputDrivers = new List<AgateDriverInfo>(), - desktopDrivers = new List<AgateDriverInfo>(); - - private static bool mIsInitialized = false; - - private static IDesktopDriver mDesktop; - - private static readonly string[] KnownNativeLibraries = new string[] - { - "SDL.dll", - }; - - - static bool Contains(this IEnumerable<AgateDriverInfo> list, DisplayTypeID type) - { - return list.Any( - x => Comparator(x, DriverType.Display, (int)type)); - } - static bool Contains(this IEnumerable<AgateDriverInfo> list, AudioTypeID type) - { - return list.Any( - x => Comparator(x, DriverType.Audio, (int)type)); - } - static bool Contains(this IEnumerable<AgateDriverInfo> list, InputTypeID type) - { - return list.Any( - x => Comparator(x, DriverType.Input, (int)type)); - } - static bool Comparator(AgateDriverInfo info, DriverType driverType, int type) - { - return info.DriverType == driverType && info.DriverTypeID == type; - } - - static Registrar() - { - } - /// <summary> - /// Searches through FileManager.AssemblyPath for all *.dll files. These files - /// are loaded and searched for classes which derive from DisplayImpl, AudioImpl, etc. - /// </summary> - internal static void Initialize() - { - if (mIsInitialized) - return; - - RegisterNullDrivers(); - - AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve); - AppDomain sandbox = AppDomain.CreateDomain("AgateSandBox"); - - AgateSandBoxLoader loader = (AgateSandBoxLoader) - sandbox.CreateInstanceAndUnwrap(Assembly.GetExecutingAssembly().FullName, - typeof(AgateSandBoxLoader).FullName); - - IEnumerable<string> files = AgateFileProvider.Assemblies.GetAllFiles("*.dll"); - - foreach (string file in files) +// The contents of this file are subject to the Mozilla Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.mozilla.org/MPL/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations +// under the License. +// +// The Original Code is AgateLib. +// +// The Initial Developer of the Original Code is Erik Ylvisaker. +// Portions created by Erik Ylvisaker are Copyright (C) 2006-2011. +// All Rights Reserved. +// +// Contributor(s): Erik Ylvisaker +// +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Reflection; +using System.Text; +using AgateLib.AudioLib.ImplementationBase; +using AgateLib.DisplayLib.ImplementationBase; +using AgateLib.InputLib.ImplementationBase; +using AgateLib.Utility; + +namespace AgateLib.Drivers +{ + /// <summary> + /// Static class with which drivers register themselves so that the library can + /// instantiate them. + /// </summary> + public static class Registrar + { + private static List<AgateDriverInfo> + displayDrivers = new List<AgateDriverInfo>(), + audioDrivers = new List<AgateDriverInfo>(), + inputDrivers = new List<AgateDriverInfo>(), + desktopDrivers = new List<AgateDriverInfo>(); + + private static bool mIsInitialized = false; + + private static IDesktopDriver mDesktop; + + private static readonly string[] KnownNativeLibraries = new string[] + { + "SDL.dll", + }; + + + static bool Contains(this IEnumerable<AgateDriverInfo> list, DisplayTypeID type) + { + return list.Any( + x => Comparator(x, DriverType.Display, (int)type)); + } + static bool Contains(this IEnumerable<AgateDriverInfo> list, AudioTypeID type) + { + return list.Any( + x => Comparator(x, DriverType.Audio, (int)type)); + } + static bool Contains(this IEnumerable<AgateDriverInfo> list, InputTypeID type) + { + return list.Any( + x => Comparator(x, DriverType.Input, (int)type)); + } + static bool Comparator(AgateDriverInfo info, DriverType driverType, int type) + { + return info.DriverType == driverType && info.DriverTypeID == type; + } + + static Registrar() + { + } + /// <summary> + /// Searches through FileManager.AssemblyPath for all *.dll files. These files + /// are loaded and searched for classes which derive from DisplayImpl, AudioImpl, etc. + /// </summary> + internal static void Initialize() + { + if (mIsInitialized) + return; + + RegisterNullDrivers(); + + AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve); + AppDomain sandbox = AppDomain.CreateDomain("AgateSandBox"); + + AgateSandBoxLoader loader = (AgateSandBoxLoader) + sandbox.CreateInstanceAndUnwrap(Assembly.GetExecutingAssembly().FullName, + typeof(AgateSandBoxLoader).FullName); + + IEnumerable<string> files = AgateFileProvider.Assemblies.GetAllFiles("*.dll"); + + foreach (string file in files) + { + if (ShouldSkipLibrary(file)) + continue; + + foreach (AgateDriverInfo info in loader.ReportDrivers(file)) + { + switch (info.DriverType) + { + case DriverType.Display: + displayDrivers.Add(info); + break; + + case DriverType.Audio: + audioDrivers.Add(info); + break; + + case DriverType.Input: + inputDrivers.Add(info); + break; + + case DriverType.Desktop: + desktopDrivers.Add(info); + break; + + default: + Core.ErrorReporting.Report(ErrorLevel.Warning, string.Format( + "Could not interpret DriverType returned by type {0} in assembly {1}.", + info.DriverTypeName, info.AssemblyFile), null); + + break; + } + } + } + + AppDomain.Unload(sandbox); + + SortDriverInfo(displayDrivers); + SortDriverInfo(audioDrivers); + SortDriverInfo(inputDrivers); + SortDriverInfo(desktopDrivers); + + mIsInitialized = true; + } + private static void SortDriverInfo(List<AgateDriverInfo> driverList) + { + // sorts the driver list in reverse order. + driverList.Sort(delegate(AgateDriverInfo a, AgateDriverInfo b) + { + return -a.Priority.CompareTo(b.Priority); + }); + } + + private static void RegisterNullDrivers() + { + Assembly thisAssembly = Assembly.GetExecutingAssembly(); + + AgateDriverInfo nullAudioInfo = new AgateDriverInfo(AudioTypeID.Silent, + typeof(NullSoundImpl), "No audio", -100); + + nullAudioInfo.AssemblyFile = thisAssembly.CodeBase; + nullAudioInfo.AssemblyName = thisAssembly.FullName; + + audioDrivers.Add(nullAudioInfo); + + AgateDriverInfo nullInputInfo = new AgateDriverInfo(InputTypeID.Silent, + typeof(NullInputImpl), "No input", -100); + + nullInputInfo.AssemblyFile = thisAssembly.CodeBase; + nullInputInfo.AssemblyName = thisAssembly.FullName; + + inputDrivers.Add(nullInputInfo); + } + + private static bool ShouldSkipLibrary(string file) + { + // Native libraries in the same directory will give an error when loaded, + // so skip any ones that we know about that will probably be in the same + // directory as the drivers. + if (IsKnownNativeLibrary(file)) + return true; + + // hack, because mono crashes if AgateMDX.dll is present. + // annoying, because it should report a failure to load the types in the + // assembly, and then the try catch should continue after that. + // TODO: this hack seems unnecessary in recent versions of Mono. Should it be removed? + if ((Environment.OSVersion.Platform == PlatformID.Unix || + Environment.OSVersion.Platform == (PlatformID)128) && + (System.IO.Path.GetFileName(file).ToLower().Contains("agatemdx.dll") || + System.IO.Path.GetFileName(file).ToLower().Contains("agatesdx.dll"))) + { + Core.ErrorReporting.Report(ErrorLevel.Comment, + string.Format("DirectX not supported on non-Windows platforms. {0}Remove {1} to eliminate this message.", + Environment.NewLine, System.IO.Path.GetFileName(file)), null); + + return true; + } + + // Skip the agatelib dll. + if (System.IO.Path.GetFileName(file).ToLower().Contains("agatelib.dll")) + return true; + + return false; + } + private static bool IsKnownNativeLibrary(string path) + { + string filename = System.IO.Path.GetFileName(path).ToLowerInvariant(); + + for (int i = 0; i < KnownNativeLibraries.Length; i++) + { + if (KnownNativeLibraries[i].ToLowerInvariant() == filename) + return true; + } + return false; + } + + + /// <summary> + /// Asks the user to select which drivers to use. + /// </summary> + /// <param name="chooseDisplay"></param> + /// <param name="chooseAudio"></param> + /// <param name="chooseInput"></param> + /// <param name="selectedDisplay"></param> + /// <param name="selectedAudio"></param> + /// <param name="selectedInput"></param> + /// <returns></returns> + internal static bool UserSelectDrivers(bool chooseDisplay, bool chooseAudio, bool chooseInput, + DisplayTypeID preferredDisplay, AudioTypeID preferredAudio, InputTypeID preferredInput, + out DisplayTypeID selectedDisplay, out AudioTypeID selectedAudio, out InputTypeID selectedInput) + { + if (mDesktop == null) + { + CreateDesktopDriver(); + + if (mDesktop == null) + { + SelectBestDrivers(chooseDisplay, chooseAudio, chooseInput, + preferredDisplay, preferredAudio, preferredInput, + out selectedDisplay, out selectedAudio, out selectedInput); + + return true; + } + } + + IUserSetSystems frm = mDesktop.CreateUserSetSystems(); + + // set default values. + selectedDisplay = DisplayTypeID.AutoSelect; + selectedAudio = AudioTypeID.AutoSelect; + selectedInput = InputTypeID.AutoSelect; + + foreach (AgateDriverInfo info in displayDrivers) + { + frm.AddDisplayType(info); + } + foreach (AgateDriverInfo info in audioDrivers) + { + frm.AddAudioType(info); + } + foreach (AgateDriverInfo info in inputDrivers) + { + frm.AddInputType(info); + } + + frm.SetChoices(chooseDisplay, chooseAudio, chooseInput, + preferredDisplay, preferredAudio, preferredInput); + + // run the dialog asking user which drivers to use. + if (frm.RunDialog() == SetSystemsDialogResult.Cancel) + { + return false; + } + + selectedDisplay = frm.DisplayType; + selectedAudio = frm.AudioType; + selectedInput = frm.InputType; + + return true; + + } + + private static void SelectBestDrivers(bool chooseDisplay, bool chooseAudio, bool chooseInput, + DisplayTypeID preferredDisplay, AudioTypeID preferredAudio, InputTypeID preferredInput, + out DisplayTypeID selectedDisplay, out AudioTypeID selectedAudio, out InputTypeID selectedInput) + { + // initial return values if a driver isn't selected. + selectedDisplay = DisplayTypeID.AutoSelect; + selectedAudio = AudioTypeID.AutoSelect; + selectedInput = InputTypeID.AutoSelect; + + if (preferredDisplay != DisplayTypeID.AutoSelect && displayDrivers.Contains(preferredDisplay)) + selectedDisplay = preferredDisplay; + else if (displayDrivers.Count > 0) + selectedDisplay = (DisplayTypeID)displayDrivers[0].DriverTypeID; + + if (preferredAudio != AudioTypeID.AutoSelect && audioDrivers.Contains(preferredAudio)) + selectedAudio = preferredAudio; + else if (audioDrivers.Count > 0) + selectedAudio = (AudioTypeID)audioDrivers[0].DriverTypeID; + + if (preferredInput != InputTypeID.AutoSelect && inputDrivers.Contains(preferredInput)) + selectedInput = preferredInput; + else if (inputDrivers.Count > 0) + selectedInput = (InputTypeID)inputDrivers[0].DriverTypeID; + } + + private static void CreateDesktopDriver() + { + if (desktopDrivers.Count == 0) + return; + + mDesktop = (IDesktopDriver)CreateDriverInstance(desktopDrivers[0]); + } + + internal static IDesktopDriver WinForms + { + get { return mDesktop; } + } + + internal static DisplayImpl CreateDisplayDriver(DisplayTypeID displayType) + { + if (displayDrivers.Count == 0) + throw new AgateException("No display drivers registered."); + + AgateDriverInfo info; + string text; + + if (displayType == DisplayTypeID.AutoSelect && + Core.Settings["AgateLib"].TryGetValue("DisplayDriver", out text)) + { + info = FindDriverInfo(displayDrivers, text); + } + else + info = FindDriverInfo(displayDrivers, (int)displayType); + + if (info == null) + throw new AgateException(string.Format("Could not find the driver {0}.", displayType)); + + return (DisplayImpl)CreateDriverInstance(info); + } + internal static AudioImpl CreateAudioDriver(AudioTypeID audioType) + { + if (audioDrivers.Count == 0) + throw new AgateException("No audio drivers registered."); + + AgateDriverInfo info; + string text; + + if (audioType == AudioTypeID.AutoSelect && + Core.Settings["AgateLib"].TryGetValue("AudioDriver", out text)) { - if (ShouldSkipLibrary(file)) - continue; - - foreach (AgateDriverInfo info in loader.ReportDrivers(file)) - { - switch (info.DriverType) - { - case DriverType.Display: - displayDrivers.Add(info); - break; - - case DriverType.Audio: - audioDrivers.Add(info); - break; - - case DriverType.Input: - inputDrivers.Add(info); - break; - - case DriverType.Desktop: - desktopDrivers.Add(info); - break; - - default: - Core.ErrorReporting.Report(ErrorLevel.Warning, string.Format( - "Could not interpret DriverType returned by type {0} in assembly {1}.", - info.DriverTypeName, info.AssemblyFile), null); - - break; - } - } + info = FindDriverInfo(audioDrivers, text); } - - AppDomain.Unload(sandbox); - - SortDriverInfo(displayDrivers); - SortDriverInfo(audioDrivers); - SortDriverInfo(inputDrivers); - SortDriverInfo(desktopDrivers); - - mIsInitialized = true; - } - private static void SortDriverInfo(List<AgateDriverInfo> driverList) - { - // sorts the driver list in reverse order. - driverList.Sort(delegate(AgateDriverInfo a, AgateDriverInfo b) + else + info = FindDriverInfo(audioDrivers, (int)audioType); + + if (info == null) + throw new AgateException(string.Format("Could not find the driver {0}.", audioType)); + + return (AudioImpl)CreateDriverInstance(info); + } + internal static InputImpl CreateInputDriver(InputTypeID inputType) + { + if (inputDrivers.Count == 0) + throw new AgateException("No audio drivers registered."); + + AgateDriverInfo info; + string text; + + if (inputType == InputTypeID.AutoSelect && + Core.Settings["AgateLib"].TryGetValue("InputDriver", out text)) { - return -a.Priority.CompareTo(b.Priority); - }); - } - - private static void RegisterNullDrivers() - { - Assembly thisAssembly = Assembly.GetExecutingAssembly(); - - AgateDriverInfo nullAudioInfo = new AgateDriverInfo(AudioTypeID.Silent, - typeof(NullSoundImpl), "No audio", -100); - - nullAudioInfo.AssemblyFile = thisAssembly.CodeBase; - nullAudioInfo.AssemblyName = thisAssembly.FullName; - - audioDrivers.Add(nullAudioInfo); - - AgateDriverInfo nullInputInfo = new AgateDriverInfo(InputTypeID.Silent, - typeof(NullInputImpl), "No input", -100); - - nullInputInfo.AssemblyFile = thisAssembly.CodeBase; - nullInputInfo.AssemblyName = thisAssembly.FullName; - - inputDrivers.Add(nullInputInfo); - } - - private static bool ShouldSkipLibrary(string file) - { - // Native libraries in the same directory will give an error when loaded, - // so skip any ones that we know about that will probably be in the same - // directory as the drivers. - if (IsKnownNativeLibrary(file)) - return true; - - // hack, because mono crashes if AgateMDX.dll is present. - // annoying, because it should report a failure to load the types in the - // assembly, and then the try catch should continue after that. - // this seems unnecessary in the current version of Mono. - if ((Environment.OSVersion.Platform == PlatformID.Unix || - Environment.OSVersion.Platform == (PlatformID)128) && - (System.IO.Path.GetFileName(file).ToLower().Contains("agatemdx.dll") || - System.IO.Path.GetFileName(file).ToLower().Contains("agatesdx.dll"))) - { - Core.ErrorReporting.Report(ErrorLevel.Comment, - string.Format("DirectX not supported on non-Windows platforms. {0}Remove {1} to eliminate this message.", - Environment.NewLine, System.IO.Path.GetFileName(file)), null); - - return true; + info = FindDriverInfo(inputDrivers, text); } - - // Skip the agatelib dll. - if (System.IO.Path.GetFileName(file).ToLower().Contains("agatelib.dll")) - return true; - - return false; - } - private static bool IsKnownNativeLibrary(string path) - { - string filename = System.IO.Path.GetFileName(path).ToLowerInvariant(); - - for (int i = 0; i < KnownNativeLibraries.Length; i++) - { - if (KnownNativeLibraries[i].ToLowerInvariant() == filename) - return true; - } - return false; - } - - - /// <summary> - /// Asks the user to select which drivers to use. - /// </summary> - /// <param name="chooseDisplay"></param> - /// <param name="chooseAudio"></param> - /// <param name="chooseInput"></param> - /// <param name="selectedDisplay"></param> - /// <param name="selectedAudio"></param> - /// <param name="selectedInput"></param> - /// <returns></returns> - internal static bool UserSelectDrivers(bool chooseDisplay, bool chooseAudio, bool chooseInput, - DisplayTypeID preferredDisplay, AudioTypeID preferredAudio, InputTypeID preferredInput, - out DisplayTypeID selectedDisplay, out AudioTypeID selectedAudio, out InputTypeID selectedInput) - { - if (mDesktop == null) - { - CreateDesktopDriver(); - - if (mDesktop == null) - { - SelectBestDrivers(chooseDisplay, chooseAudio, chooseInput, - preferredDisplay, preferredAudio, preferredInput, - out selectedDisplay, out selectedAudio, out selectedInput); - - return true; - } - } - - IUserSetSystems frm = mDesktop.CreateUserSetSystems(); - - // set default values. - selectedDisplay = DisplayTypeID.AutoSelect; - selectedAudio = AudioTypeID.AutoSelect; - selectedInput = InputTypeID.AutoSelect; - - foreach (AgateDriverInfo info in displayDrivers) - { - frm.AddDisplayType(info); - } - foreach (AgateDriverInfo info in audioDrivers) - { - frm.AddAudioType(info); - } - foreach (AgateDriverInfo info in inputDrivers) - { - frm.AddInputType(info); - } - - frm.SetChoices(chooseDisplay, chooseAudio, chooseInput, - preferredDisplay, preferredAudio, preferredInput); - - // run the dialog asking user which drivers to use. - if (frm.RunDialog() == SetSystemsDialogResult.Cancel) - { - return false; - } - - selectedDisplay = frm.DisplayType; - selectedAudio = frm.AudioType; - selectedInput = frm.InputType; - - return true; - - } - - private static void SelectBestDrivers(bool chooseDisplay, bool chooseAudio, bool chooseInput, - DisplayTypeID preferredDisplay, AudioTypeID preferredAudio, InputTypeID preferredInput, - out DisplayTypeID selectedDisplay, out AudioTypeID selectedAudio, out InputTypeID selectedInput) - { - // initial return values if a driver isn't selected. - selectedDisplay = DisplayTypeID.AutoSelect; - selectedAudio = AudioTypeID.AutoSelect; - selectedInput = InputTypeID.AutoSelect; - - if (preferredDisplay != DisplayTypeID.AutoSelect && displayDrivers.Contains(preferredDisplay)) - selectedDisplay = preferredDisplay; - else if (displayDrivers.Count > 0) - selectedDisplay = (DisplayTypeID)displayDrivers[0].DriverTypeID; - - if (preferredAudio != AudioTypeID.AutoSelect && audioDrivers.Contains(preferredAudio)) - selectedAudio = preferredAudio; - else if (audioDrivers.Count > 0) - selectedAudio = (AudioTypeID)audioDrivers[0].DriverTypeID; - - if (preferredInput != InputTypeID.AutoSelect && inputDrivers.Contains(preferredInput)) - selectedInput = preferredInput; - else if (inputDrivers.Count > 0) - selectedInput = (InputTypeID)inputDrivers[0].DriverTypeID; - } - - private static void CreateDesktopDriver() - { - if (desktopDrivers.Count == 0) - return; - - mDesktop = (IDesktopDriver)CreateDriverInstance(desktopDrivers[0]); - } - - internal static IDesktopDriver WinForms - { - get { return mDesktop; } - } - - internal static DisplayImpl CreateDisplayDriver(DisplayTypeID displayType) - { - if (displayDrivers.Count == 0) - throw new AgateException("No display drivers registered."); - - AgateDriverInfo info = FindDriverInfo(displayDrivers, (int)displayType); - - if (info == null) - throw new AgateException(string.Format("Could not find the driver {0}.", displayType)); - - return (DisplayImpl)CreateDriverInstance(info); - } - internal static AudioImpl CreateAudioDriver(AudioTypeID audioType) - { - if (audioDrivers.Count == 0) - throw new AgateException("No audio drivers registered."); - - AgateDriverInfo info = FindDriverInfo(audioDrivers, (int)audioType); - - if (info == null) - throw new AgateException(string.Format("Could not find the driver {0}.", audioType)); - - return (AudioImpl)CreateDriverInstance(info); - } - internal static InputImpl CreateInputDriver(InputTypeID inputType) - { - if (inputDrivers.Count == 0) - throw new AgateException("No audio drivers registered."); - - AgateDriverInfo info = FindDriverInfo(inputDrivers, (int)inputType); - - if (info == null) - throw new AgateException(string.Format("Could not find the driver {0}.", inputType)); - - return (InputImpl)CreateDriverInstance(info); - } - - - private static AgateDriverInfo FindDriverInfo(List<AgateDriverInfo> driverList, int typeID) - { - AgateDriverInfo theInfo = null; - - if (driverList.Count == 0) - return null; - - // autoselect ID's are all zero - if (typeID == 0) - return driverList[0]; - - foreach (AgateDriverInfo info in driverList) - { - if (info.DriverTypeID != typeID) - continue; - - theInfo = info; - } - return theInfo; - } - private static AgateDriverInfo FindDriverInfo(IEnumerable<AgateDriverInfo> driverList, string assemblyFullName) - { - AgateDriverInfo theInfo = null; - - foreach (AgateDriverInfo info in driverList) - { - if (info.AssemblyName != assemblyFullName) - continue; - - theInfo = info; - } - return theInfo; - } - - private static object CreateDriverInstance(AgateDriverInfo info) - { - Assembly ass = Assembly.Load(info.AssemblyName); - - Type driverType = ass.GetType(info.DriverTypeName, false); - - if (driverType == null) - throw new AgateException(string.Format( - "Could not find the type {0} in the library {1}.", - info.DriverTypeName, - ass.FullName)); - - return Activator.CreateInstance(driverType); - } - - private static Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args) - { - AgateDriverInfo info = null; - - info = info ?? FindDriverInfo(displayDrivers, args.Name); - info = info ?? FindDriverInfo(audioDrivers, args.Name); - info = info ?? FindDriverInfo(inputDrivers, args.Name); - info = info ?? FindDriverInfo(desktopDrivers, args.Name); - - if (info == null) - return null; - - return LoadAssemblyLoadFrom(info); - } - - private static Assembly LoadAssemblyLoadFrom(AgateDriverInfo info) - { - Core.ErrorReporting.Report(ErrorLevel.Warning, - string.Format("Assembly {0} was loaded in the LoadFrom context. Move it to the application directory to load in the Load context.", info.AssemblyName), null); - return Assembly.LoadFrom(info.AssemblyFile); - } - - /// <summary> - /// Returns a collection with all the DriverInfo<DisplayTypeID> structures for - /// registered display drivers. - /// </summary> - /// <returns></returns> - public static List<AgateDriverInfo> DisplayDrivers - { - get { return displayDrivers; } - } - /// <summary> - /// Returns a collection with all the DriverInfo<AudioTypeID> structures for - /// registered display drivers. - /// </summary> - /// <returns></returns> - public static List<AgateDriverInfo> AudioDrivers - { - get { return audioDrivers; } - } - /// <summary> - /// Returns a collection with all the DriverInfo<InputTypeID> structures for - /// registered display drivers. - /// </summary> - /// <returns></returns> - public static List<AgateDriverInfo> InputDrivers - { - get { return inputDrivers; } - } - - - } -} + else + info = FindDriverInfo(inputDrivers, (int)inputType); + + if (info == null) + throw new AgateException(string.Format("Could not find the driver {0}.", inputType)); + + return (InputImpl)CreateDriverInstance(info); + } + + private static AgateDriverInfo FindDriverInfo(List<AgateDriverInfo> driverList, string matchText) + { + AgateDriverInfo retval = null; + + if (driverList.Count == 0) + return null; + + foreach(AgateDriverInfo info in driverList) + { + if (info.FriendlyName.Contains(matchText)) + retval = info; + } + + return retval; + } + private static AgateDriverInfo FindDriverInfo(List<AgateDriverInfo> driverList, int typeID) + { + AgateDriverInfo theInfo = null; + + if (driverList.Count == 0) + return null; + + // autoselect ID's are all zero + if (typeID == 0) + return driverList[0]; + + foreach (AgateDriverInfo info in driverList) + { + if (info.DriverTypeID != typeID) + continue; + + theInfo = info; + } + return theInfo; + } + private static AgateDriverInfo FindDriverInfo(IEnumerable<AgateDriverInfo> driverList, string assemblyFullName) + { + AgateDriverInfo theInfo = null; + + foreach (AgateDriverInfo info in driverList) + { + if (info.AssemblyName != assemblyFullName) + continue; + + theInfo = info; + } + return theInfo; + } + + private static object CreateDriverInstance(AgateDriverInfo info) + { + Assembly ass = Assembly.Load(info.AssemblyName); + + Type driverType = ass.GetType(info.DriverTypeName, false); + + if (driverType == null) + throw new AgateException(string.Format( + "Could not find the type {0} in the library {1}.", + info.DriverTypeName, + ass.FullName)); + + return Activator.CreateInstance(driverType); + } + + private static Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args) + { + AgateDriverInfo info = null; + + info = info ?? FindDriverInfo(displayDrivers, args.Name); + info = info ?? FindDriverInfo(audioDrivers, args.Name); + info = info ?? FindDriverInfo(inputDrivers, args.Name); + info = info ?? FindDriverInfo(desktopDrivers, args.Name); + + if (info == null) + return null; + + return LoadAssemblyLoadFrom(info); + } + + private static Assembly LoadAssemblyLoadFrom(AgateDriverInfo info) + { + Core.ErrorReporting.Report(ErrorLevel.Warning, + string.Format("Assembly {0} was loaded in the LoadFrom context. Move it to the application directory to load in the Load context.", info.AssemblyName), null); + return Assembly.LoadFrom(info.AssemblyFile); + } + + /// <summary> + /// Returns a collection with all the DriverInfo<DisplayTypeID> structures for + /// registered display drivers. + /// </summary> + /// <returns></returns> + public static List<AgateDriverInfo> DisplayDrivers + { + get { return displayDrivers; } + } + /// <summary> + /// Returns a collection with all the DriverInfo<AudioTypeID> structures for + /// registered display drivers. + /// </summary> + /// <returns></returns> + public static List<AgateDriverInfo> AudioDrivers + { + get { return audioDrivers; } + } + /// <summary> + /// Returns a collection with all the DriverInfo<InputTypeID> structures for + /// registered display drivers. + /// </summary> + /// <returns></returns> + public static List<AgateDriverInfo> InputDrivers + { + get { return inputDrivers; } + } + + + } +} Modified: trunk/AgateLib/Settings/PersistantSettings.cs =================================================================== --- trunk/AgateLib/Settings/PersistantSettings.cs 2011-11-21 22:29:19 UTC (rev 1303) +++ trunk/AgateLib/Settings/PersistantSettings.cs 2011-11-21 22:50:40 UTC (rev 1304) @@ -1,152 +1,156 @@ -// The contents of this file are subject to the Mozilla Public License -// Version 1.1 (the "License"); you may not use this file except in -// compliance with the License. You may obtain a copy of the License at -// http://www.mozilla.org/MPL/ -// -// Software distributed under the License is distributed on an "AS IS" -// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the -// License for the specific language governing rights and limitations -// under the License. -// -// The Original Code is AgateLib. -// -// The Initial Developer of the Original Code is Erik Ylvisaker. -// Portions created by Erik Ylvisaker are Copyright (C) 2006-2011. -// All Rights Reserved. -// -// Contributor(s): Erik Ylvisaker -// -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Xml; - -namespace AgateLib.Settings -{ - /// <summary> - /// Class which stores a simple list of persistant settings. The settings exist - /// in named groups, and within each group an individual setting is a key/value pair. - /// These settings are stored on a per-user basis. - /// </summary> - /// <remarks>On Windows Vista the file is stored in - /// %HOME%\AppData\Company Name\Application Name\settings.xml. - /// On Unix the file is stored at - /// $HOME/.config/Company Name/Application Name/settings.xml. - /// </remarks> - public class PersistantSettings - { - Dictionary<string, SettingsGroup> mSettings = new Dictionary<string, SettingsGroup>(); - - internal PersistantSettings() - { - LoadSettings(); - } - - private SettingsGroup GetOrCreateSettingsGroup(string name) - { - if (name.Contains(" ")) - throw new AgateException("Settings group name cannot contain a string."); - - if (mSettings.ContainsKey(name) == false) - mSettings[name] = new SettingsGroup(); - - return mSettings[name]; - } - - /// <summary> - /// Gets a settings group, or creates it if it does not exist. - /// </summary> - /// <param name="name">The name of the group is case-sensitive, and must not contain any spaces - /// or special characters.</param> - /// <returns></returns> - public SettingsGroup this[string name] - { - get { return GetOrCreateSettingsGroup(name); } - } - /// <summary> - /// Gets the full path to the location where the settings file is stored. - /// </summary> - public string SettingsFilename - { - get - { - return System.IO.Path.Combine(Core.Platform.AppDataDirectory, "settings.xml"); - } - } - - /// <summary> - /// Saves the settings to the persistant storage on disk. - /// </summary> - public void SaveSettings() - { - XmlDocument doc = new XmlDocument(); - XmlElement root = doc.CreateElement("Settings"); - - foreach (string group in mSettings.Keys) - { - XmlElement groupNode = doc.CreateElement(group); - - foreach (var kvp in mSettings[group]) - { - XmlElement set = doc.CreateElement(kvp.Key); - set.InnerText = kvp.Value; - - groupNode.AppendChild(set); - } - - root.AppendChild(groupNode); - } - - doc.AppendChild(root); - - System.Diagnostics.Trace.WriteLine("Saving settings to " + SettingsFilename); - - Core.Platform.EnsureAppDataDirectoryExists(); - - doc.Save(SettingsFilename); - } - - private void LoadSettings() - { - XmlDocument doc = new XmlDocument(); - try - { - doc.Load(SettingsFilename); - } - catch (FileNotFoundException) - { - return; - } - catch (DirectoryNotFoundException) - { - return; - } - catch (XmlException e) - { - System.Diagnostics.Trace.WriteLine("Error reading settings file:" + Environment.NewLine + - e.Message); - - return; - } - XmlElement root = doc.ChildNodes[0] as XmlElement; - - if (root.Name != "Settings") - throw new AgateException("Could not understand settings file\n" + SettingsFilename + - "\nYou may need to delete it."); - - foreach (XmlElement node in root.ChildNodes) - { - SettingsGroup g = new SettingsGroup(); - - foreach (XmlElement pair in node.ChildNodes) - { - g.Add(pair.Name, pair.InnerXml); - } - - mSettings.Add(node.Name, g); - } - } - } -} +// The contents of this file are subject to the Mozilla Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.mozilla.org/MPL/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations +// under the License. +// +// The Original Code is AgateLib. +// +// The Initial Developer of the Original Code is Erik Ylvisaker. +// Portions created by Erik Ylvisaker are Copyright (C) 2006-2011. +// All Rights Reserved. +// +// Contributor(s): Erik Ylvisaker +// +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Xml; + +namespace AgateLib.Settings +{ + /// <summary> + /// Class which stores a simple list of persistant settings. The settings exist + /// in named groups, and within each group an individual setting is a key/value pair. + /// These settings are stored on a per-user basis. + /// </summary> + /// <remarks>On Windows Vista the file is stored in + /// %HOME%\AppData\Company Name\Application Name\settings.xml. + /// On Unix the file is stored at + /// $HOME/.config/Company Name/Application Name/settings.xml. + /// </remarks> + public class PersistantSettings + { + Dictionary<string, SettingsGroup> mSettings = new Dictionary<string, SettingsGroup>(); + + internal PersistantSettings() + { + LoadSettings(); + } + + private SettingsGroup GetOrCreateSettingsGroup(string name) + { + if (name.Contains(" ")) + throw new AgateException("Settings group name cannot contain a space."); + + if (mSettings.ContainsKey(name) == false) + { + mSettings[name] = new SettingsGroup(); + mSettings[name].Name = name; + } + + return mSettings[name]; + } + + /// <summary> + /// Gets a settings group, or creates it if it does not exist. + /// </summary> + /// <param name="name">The name of the group is case-sensitive, and must not contain any spaces + /// or special characters.</param> + /// <returns></returns> + public SettingsGroup this[string name] + { + get { return GetOrCreateSettingsGroup(name); } + } + /// <summary> + /// Gets the full path to the location where the settings file is stored. + /// </summary> + public string SettingsFilename + { + get + { + return System.IO.Path.Combine(Core.Platform.AppDataDirectory, "settings.xml"); + } + } + + /// <summary> + /// Saves the settings to the persistant storage on disk. + /// </summary> + public void SaveSettings() + { + XmlDocument doc = new XmlDocument(); + XmlElement root = doc.CreateElement("Settings"); + + foreach (string group in mSettings.Keys) + { + XmlElement groupNode = doc.CreateElement(group); + + foreach (var kvp in mSettings[group]) + { + XmlElement set = doc.CreateElement(kvp.Key); + set.InnerText = kvp.Value; + + groupNode.AppendChild(set); + } + + root.AppendChild(groupNode); + } + + doc.AppendChild(root); + + System.Diagnostics.Trace.WriteLine("Saving settings to " + SettingsFilename); + + Core.Platform.EnsureAppDataDirectoryExists(); + + doc.Save(SettingsFilename); + } + + private void LoadSettings() + { + XmlDocument doc = new XmlDocument(); + try + { + doc.Load(SettingsFilename); + } + catch (FileNotFoundException) + { + return; + } + catch (DirectoryNotFoundException) + { + return; + } + catch (XmlException e) + { + System.Diagnostics.Trace.WriteLine("Error reading settings file:" + Environment.NewLine + + e.Message); + + return; + } + XmlElement root = doc.ChildNodes[0] as XmlElement; + + if (root.Name != "Settings") + throw new AgateException("Could not understand settings file\n" + SettingsFilename + + "\nYou may need to delete it."); + + foreach (XmlElement node in root.ChildNodes) + { + SettingsGroup g = new SettingsGroup(); + + foreach (XmlElement pair in node.ChildNodes) + { + g.Add(pair.Name, pair.InnerXml); + } + + g.Name = node.Name; + mSettings.Add(node.Name, g); + } + } + } +} Modified: trunk/AgateLib/Settings/SettingsGroup.cs =================================================================== --- trunk/AgateLib/Settings/SettingsGroup.cs 2011-11-21 22:29:19 UTC (rev 1303) +++ trunk/AgateLib/Settings/SettingsGroup.cs 2011-11-21 22:50:40 UTC (rev 1304) @@ -1,172 +1,219 @@ -// The contents of this file are subject to the Mozilla Public License -// Version 1.1 (the "License"); you may not use this file except in -// compliance with the License. You may obtain a copy of the License at -// http://www.mozilla.org/MPL/ -// -// Software distributed under the License is distributed on an "AS IS" -// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the -// License for the specific language governing rights and limitations -// under the License. -// -// The Original Code is AgateLib. -// -// The Initial Developer of the Original Code is Erik Ylvisaker. -// Portions created by Erik Ylvisaker are Copyright (C) 2006-2011. -// All Rights Reserved. -// -// Contributor(... [truncated message content] |
From: <ka...@us...> - 2011-11-21 22:29:29
|
Revision: 1303 http://agate.svn.sourceforge.net/agate/?rev=1303&view=rev Author: kanato Date: 2011-11-21 22:29:19 +0000 (Mon, 21 Nov 2011) Log Message: ----------- Fixed reporting of primary shading language. Modified Paths: -------------- trunk/AgateLib/DisplayLib/DisplayCapsInfo.cs Modified: trunk/AgateLib/DisplayLib/DisplayCapsInfo.cs =================================================================== --- trunk/AgateLib/DisplayLib/DisplayCapsInfo.cs 2011-11-21 19:03:22 UTC (rev 1302) +++ trunk/AgateLib/DisplayLib/DisplayCapsInfo.cs 2011-11-21 22:29:19 UTC (rev 1303) @@ -1,202 +1,210 @@ -// The contents of this file are subject to the Mozilla Public License -// Version 1.1 (the "License"); you may not use this file except in -// compliance with the License. You may obtain a copy of the License at -// http://www.mozilla.org/MPL/ -// -// Software distributed under the License is distributed on an "AS IS" -// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the -// License for the specific language governing rights and limitations -// under the License. -// -// The Original Code is AgateLib. -// -// The Initial Developer of the Original Code is Erik Ylvisaker. -// Portions created by Erik Ylvisaker are Copyright (C) 2006-2011. -// All Rights Reserved. -// -// Contributor(s): Erik Ylvisaker -// -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using AgateLib.Geometry; - -namespace AgateLib.DisplayLib -{ - /// <summary> - /// Class which can be used to query information about what features are supported - /// by the display driver. - /// </summary> - public class DisplayCapsInfo - { - internal DisplayCapsInfo() - { } - - /// <summary> - /// Indicates whether or not full screen windows can be created. - /// </summary> - public bool SupportsFullScreen - { - get { return Display.Impl.CapsBool(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.CapsBool(DisplayBoolCaps.FullScreenModeSwitching); } - } - /// <summary> - /// Indicates whether setting Surface.SetScale has any visible effect. - /// </summary> - public bool SupportsScaling - { - get { return Display.Impl.CapsBool(DisplayBoolCaps.Scaling); } - } - /// <summary> - /// Indicates whether setting Surface.RotationAngle has any visible effect. - /// </summary> - public bool SupportsRotation - { - get { return Display.Impl.CapsBool(DisplayBoolCaps.Rotation); } - } - /// <summary> - /// Indicates whether setting Surface.Color has any visible effect. - /// </summary> - public bool SupportsColor - { - get { return Display.Impl.CapsBool(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.CapsBool(DisplayBoolCaps.Gradient); } - } - /// <summary> - /// Indicates whether setting Surface.Alpha has any visible effect. - /// </summary> - public bool SupportsSurfaceAlpha - { - get { return Display.Impl.CapsBool(DisplayBoolCaps.SurfaceAlpha); } - } - /// <summary> - /// Indicates whether the alpha channel in surface pixels is used. - /// </summary> - public bool SupportsPixelAlpha - { - get { return Display.Impl.CapsBool(DisplayBoolCaps.PixelAlpha); } - } - /// <summary> - /// Indicates whether there is hardware acceleration available for 2D and 3D drawing. - /// </summary> - public bool IsHardwareAccelerated - { - get { return Display.Impl.CapsBool(DisplayBoolCaps.IsHardwareAccelerated); } - } - /// <summary> - /// Indicates whether or not vertex/pixel shaders are supported. - /// </summary> - public bool SupportsCustomShaders - { - get { return Display.Impl.CapsBool(DisplayBoolCaps.CustomShaders); } - } - /// <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.CapsBool(DisplayBoolCaps.CanCreateBitmapFont); } - } - - /// <summary> - /// Gets the maximum size a surface can be. - /// </summary> - public Size MaxSurfaceSize - { - get { return Display.Impl.CapsSize(DisplaySizeCaps.MaxSurfaceSize); } - } - } - - /// <summary> - /// Enum which is used to specify a Caps value which should return a Size object. - /// </summary> - public enum DisplaySizeCaps - { - /// <summary> - /// Value for getting the maximum supported surface size. - /// </summary> - MaxSurfaceSize, - } - /// <summary> - /// Enum which is used to specify a Caps value which should return a logical value. - /// </summary> - 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 there is hardware acceleration available for 2D scaling and rotations. - /// </summary> - IsHardwareAccelerated, - /// <summary> - /// Indicates whether or not vertex/pixel shaders are supported. - /// </summary> - CustomShaders, - /// <summary> - /// Indicates whether the driver can create a bitmap font from an operating - /// system font. - /// </summary> - CanCreateBitmapFont, - } -} +// The contents of this file are subject to the Mozilla Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.mozilla.org/MPL/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations +// under the License. +// +// The Original Code is AgateLib. +// +// The Initial Developer of the Original Code is Erik Ylvisaker. +// Portions created by Erik Ylvisaker are Copyright (C) 2006-2011. +// All Rights Reserved. +// +// Contributor(s): Erik Ylvisaker +// +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using AgateLib.Geometry; + +namespace AgateLib.DisplayLib +{ + /// <summary> + /// Class which can be used to query information about what features are supported + /// by the display driver. + /// </summary> + public class DisplayCapsInfo + { + internal DisplayCapsInfo() + { } + + /// <summary> + /// Indicates whether or not full screen windows can be created. + /// </summary> + public bool SupportsFullScreen + { + get { return Display.Impl.CapsBool(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.CapsBool(DisplayBoolCaps.FullScreenModeSwitching); } + } + /// <summary> + /// Indicates whether setting Surface.SetScale has any visible effect. + /// </summary> + public bool SupportsScaling + { + get { return Display.Impl.CapsBool(DisplayBoolCaps.Scaling); } + } + /// <summary> + /// Indicates whether setting Surface.RotationAngle has any visible effect. + /// </summary> + public bool SupportsRotation + { + get { return Display.Impl.CapsBool(DisplayBoolCaps.Rotation); } + } + /// <summary> + /// Indicates whether setting Surface.Color has any visible effect. + /// </summary> + public bool SupportsColor + { + get { return Display.Impl.CapsBool(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.CapsBool(DisplayBoolCaps.Gradient); } + } + /// <summary> + /// Indicates whether setting Surface.Alpha has any visible effect. + /// </summary> + public bool SupportsSurfaceAlpha + { + get { return Display.Impl.CapsBool(DisplayBoolCaps.SurfaceAlpha); } + } + /// <summary> + /// Indicates whether the alpha channel in surface pixels is used. + /// </summary> + public bool SupportsPixelAlpha + { + get { return Display.Impl.CapsBool(DisplayBoolCaps.PixelAlpha); } + } + /// <summary> + /// Indicates whether there is hardware acceleration available for 2D and 3D drawing. + /// </summary> + public bool IsHardwareAccelerated + { + get { return Display.Impl.CapsBool(DisplayBoolCaps.IsHardwareAccelerated); } + } + /// <summary> + /// Indicates whether or not vertex/pixel shaders are supported. + /// </summary> + public bool SupportsCustomShaders + { + get { return Display.Impl.CapsBool(DisplayBoolCaps.CustomShaders); } + } + /// <summary> + /// Indicates which shader language is supported. + /// </summary> + public AgateLib.DisplayLib.Shaders.ShaderLanguage ShaderLanguage + { + get + { + var shad = Display.Impl.SupportedShaderLanguages.ToList(); + + if (shad.Count == 0) + return Shaders.ShaderLanguage.None; + else + return shad[0]; + } + } + /// <summary> + /// Indicates whether the driver can create a bitmap font from an operating + /// system font. + /// </summary> + public bool CanCreateBitmapFont + { + get { return Display.Impl.CapsBool(DisplayBoolCaps.CanCreateBitmapFont); } + } + + /// <summary> + /// Gets the maximum size a surface can be. + /// </summary> + public Size MaxSurfaceSize + { + get { return Display.Impl.CapsSize(DisplaySizeCaps.MaxSurfaceSize); } + } + } + + /// <summary> + /// Enum which is used to specify a Caps value which should return a Size object. + /// </summary> + public enum DisplaySizeCaps + { + /// <summary> + /// Value for getting the maximum supported surface size. + /// </summary> + MaxSurfaceSize, + } + /// <summary> + /// Enum which is used to specify a Caps value which should return a logical value. + /// </summary> + 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 there is hardware acceleration available for 2D scaling and rotations. + /// </summary> + IsHardwareAccelerated, + /// <summary> + /// Indicates whether or not vertex/pixel shaders are supported. + /// </summary> + CustomShaders, + /// <summary> + /// Indicates whether the driver can create a bitmap font from an operating + /// system font. + /// </summary> + CanCreateBitmapFont, + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ka...@us...> - 2011-11-21 19:03:28
|
Revision: 1302 http://agate.svn.sourceforge.net/agate/?rev=1302&view=rev Author: kanato Date: 2011-11-21 19:03:22 +0000 (Mon, 21 Nov 2011) Log Message: ----------- Minor modifications to Lighting3DTest.cs Modified Paths: -------------- trunk/Tests/Shaders/Lighting3DTest.cs Modified: trunk/Tests/Shaders/Lighting3DTest.cs =================================================================== --- trunk/Tests/Shaders/Lighting3DTest.cs 2011-11-21 18:46:06 UTC (rev 1301) +++ trunk/Tests/Shaders/Lighting3DTest.cs 2011-11-21 19:03:22 UTC (rev 1302) @@ -25,9 +25,11 @@ Vector3 eye = new Vector3(-3, 0, 4); Vector3 up = new Vector3(0, 0, 1); + Vector3 lightPos = new Vector3(0, 1.5, 2.5); double lookAngle = 0; double angle = 0; - bool lightEnable; + double lightAngle = 0; + bool lightEnable = true; bool paused = false; bool advance = false; bool done = false; @@ -41,9 +43,9 @@ if (setup.WasCanceled) return; - Surface texture = new Surface("bg-bricks.png"); DisplayWindow wind = DisplayWindow.CreateWindowed("Lighting 3D", 640, 480); FontSurface font = FontSurface.AgateSerif14; + Surface texture = new Surface("bg-bricks.png"); AgateLib.Geometry.Builders.CubeBuilder cb = new AgateLib.Geometry.Builders.CubeBuilder(); cb.Location = new Vector3(0, 0, 0); @@ -54,6 +56,10 @@ int frameCount = 0; + AgateLib.Geometry.Builders.CubeBuilder lightMesh = new AgateLib.Geometry.Builders.CubeBuilder(); + lightMesh.Length = 0.02f; + lightMesh.CreateVertexBuffer(); + while (wind.IsClosed == false) { Display.BeginFrame(); @@ -64,9 +70,12 @@ if (lightEnable) { + lightPos.X = 2f * (float)Math.Sin(lightAngle); + lightPos.Y = 2f * (float)Math.Cos(lightAngle); + shader.EnableLighting = true; shader.Lights[0] = new Light(); - shader.Lights[0].Position = new Vector3(0, 3, eye.Z); + shader.Lights[0].Position = lightPos; shader.Lights[0].DiffuseColor = Color.White; shader.Lights[0].AttenuationConstant = 1f; shader.Lights[0].AttenuationLinear = 0.1f; @@ -79,7 +88,7 @@ Vector3 target = eye + dir * 3; target.Z = 0; - shader.Projection = Matrix4x4.Projection(45, 640 / 480.0f, 1, 200); + shader.Projection = Matrix4x4.Projection(45, 640 / 480.0f, 0.1f, 200); shader.View = Matrix4x4.ViewLookAt(eye, target, up); shader.World = Matrix4x4.RotateZ(angle); shader.Activate(); @@ -87,6 +96,13 @@ cb.VertexBuffer.Textures[0] = texture; cb.VertexBuffer.DrawIndexed(cb.IndexBuffer); + shader.EnableLighting = false; + shader.World = Matrix4x4.Translation(lightPos); + shader.Activate(); + + lightMesh.VertexBuffer.Textures[0] = texture; + lightMesh.VertexBuffer.DrawIndexed(lightMesh.IndexBuffer); + AgateBuiltInShaders.Basic2DShader.Activate(); font.DrawText(0, 0, "Location: {0}", eye); @@ -97,7 +113,10 @@ Core.KeepAlive(); angle += 1 * Display.DeltaTime / 1000.0f; + lightAngle += 2.1 * Display.DeltaTime / 1000.0f; + if (angle > 6 * Math.PI) angle -= 6 * Math.PI; + if (lightAngle > 6 * Math.PI) lightAngle -= 6 * Math.PI; frameCount++; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ka...@us...> - 2011-11-21 18:46:12
|
Revision: 1301 http://agate.svn.sourceforge.net/agate/?rev=1301&view=rev Author: kanato Date: 2011-11-21 18:46:06 +0000 (Mon, 21 Nov 2011) Log Message: ----------- Added obsolete message to old functions. Modified Paths: -------------- trunk/AgateLib/DisplayLib/FontSurface.cs Modified: trunk/AgateLib/DisplayLib/FontSurface.cs =================================================================== --- trunk/AgateLib/DisplayLib/FontSurface.cs 2011-11-21 18:43:49 UTC (rev 1300) +++ trunk/AgateLib/DisplayLib/FontSurface.cs 2011-11-21 18:46:06 UTC (rev 1301) @@ -310,7 +310,7 @@ /// </summary> /// <param name="text"></param> /// <returns></returns> - [Obsolete] + [Obsolete("Use MeasureString instead.", true)] public int StringDisplayWidth(string text) { return StringDisplaySize(text).Width; @@ -320,7 +320,7 @@ /// </summary> /// <param name="text"></param> /// <returns></returns> - [Obsolete] + [Obsolete("Use MeasureString instead.", true)] public int StringDisplayHeight(string text) { return StringDisplaySize(text).Height; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ka...@us...> - 2011-11-21 18:44:02
|
Revision: 1300 http://agate.svn.sourceforge.net/agate/?rev=1300&view=rev Author: kanato Date: 2011-11-21 18:43:49 +0000 (Mon, 21 Nov 2011) Log Message: ----------- Update copyright information. Modified Paths: -------------- trunk/AgateLib/AgateException.cs trunk/AgateLib/AgateFileProvider.cs trunk/AgateLib/AgateGame.cs trunk/AgateLib/AgateSetup.cs trunk/AgateLib/AppInitParameters.cs trunk/AgateLib/AudioLib/Audio.cs trunk/AgateLib/AudioLib/AudioCapsInfo.cs trunk/AgateLib/AudioLib/ImplementationBase/AudioImpl.cs trunk/AgateLib/AudioLib/ImplementationBase/MusicImpl.cs trunk/AgateLib/AudioLib/ImplementationBase/SoundBufferImpl.cs trunk/AgateLib/AudioLib/ImplementationBase/SoundBufferSessionImpl.cs trunk/AgateLib/AudioLib/ImplementationBase/StreamingSoundBufferImpl.cs trunk/AgateLib/AudioLib/Music.cs trunk/AgateLib/AudioLib/SoundBuffer.cs trunk/AgateLib/AudioLib/SoundBufferSession.cs trunk/AgateLib/AudioLib/SoundFormat.cs trunk/AgateLib/AudioLib/StreamingSoundBuffer.cs trunk/AgateLib/BitmapFont/BitmapFontImpl.cs trunk/AgateLib/BitmapFont/BitmapFontOptions.cs trunk/AgateLib/BitmapFont/FontMetrics.cs trunk/AgateLib/BitmapFont/GlyphMetrics.cs trunk/AgateLib/Core.cs trunk/AgateLib/Data/AgateColumn.cs trunk/AgateLib/Data/AgateColumnDictionary.cs trunk/AgateLib/Data/AgateDataHelper.cs trunk/AgateLib/Data/AgateDatabase.cs trunk/AgateLib/Data/AgateDatabaseException.cs trunk/AgateLib/Data/AgateRow.cs trunk/AgateLib/Data/AgateRowList.cs trunk/AgateLib/Data/AgateTable.cs trunk/AgateLib/Data/AgateTableDictionary.cs trunk/AgateLib/Data/FieldType.cs trunk/AgateLib/DisplayLib/Cache/FontStateCache.cs trunk/AgateLib/DisplayLib/Cache/SurfaceStateCache.cs trunk/AgateLib/DisplayLib/CreateWindowParams.cs trunk/AgateLib/DisplayLib/Display.cs trunk/AgateLib/DisplayLib/DisplayCapsInfo.cs trunk/AgateLib/DisplayLib/DisplayWindow.cs trunk/AgateLib/DisplayLib/FontState.cs trunk/AgateLib/DisplayLib/FontSurface.cs trunk/AgateLib/DisplayLib/FrameBuffer.cs trunk/AgateLib/DisplayLib/ISurface.cs trunk/AgateLib/DisplayLib/ImplementationBase/DisplayImpl.cs trunk/AgateLib/DisplayLib/ImplementationBase/DisplayWindowImpl.cs trunk/AgateLib/DisplayLib/ImplementationBase/FontSurfaceImpl.cs trunk/AgateLib/DisplayLib/ImplementationBase/FrameBufferImpl.cs trunk/AgateLib/DisplayLib/ImplementationBase/IndexBufferImpl.cs trunk/AgateLib/DisplayLib/ImplementationBase/ShaderCompilerImpl.cs trunk/AgateLib/DisplayLib/ImplementationBase/SurfaceImpl.cs trunk/AgateLib/DisplayLib/ImplementationBase/VertexBufferImpl.cs trunk/AgateLib/DisplayLib/IndexBuffer.cs trunk/AgateLib/DisplayLib/Origin.cs trunk/AgateLib/DisplayLib/OriginAlignment.cs trunk/AgateLib/DisplayLib/PixelBuffer.cs trunk/AgateLib/DisplayLib/PixelFormat.cs trunk/AgateLib/DisplayLib/PrimitiveType.cs trunk/AgateLib/DisplayLib/RenderStateAdapter.cs trunk/AgateLib/DisplayLib/ScreenMode.cs trunk/AgateLib/DisplayLib/Shaders/AgateBuiltInShaders.cs trunk/AgateLib/DisplayLib/Shaders/AgateShader.cs trunk/AgateLib/DisplayLib/Shaders/AgateShaderCompileException.cs trunk/AgateLib/DisplayLib/Shaders/Basic2DShader.cs trunk/AgateLib/DisplayLib/Shaders/IShader2D.cs trunk/AgateLib/DisplayLib/Shaders/Implementation/AgateInternalShader.cs trunk/AgateLib/DisplayLib/Shaders/Implementation/AgateShaderImpl.cs trunk/AgateLib/DisplayLib/Shaders/Implementation/Basic2DImpl.cs trunk/AgateLib/DisplayLib/Shaders/Implementation/BuiltInShader.cs trunk/AgateLib/DisplayLib/Shaders/Implementation/Effect.cs trunk/AgateLib/DisplayLib/Shaders/Implementation/Lighting2DImpl.cs trunk/AgateLib/DisplayLib/Shaders/Implementation/Lighting3DImpl.cs trunk/AgateLib/DisplayLib/Shaders/Implementation/ShaderCompiler.cs trunk/AgateLib/DisplayLib/Shaders/Implementation/ShaderLanguage.cs trunk/AgateLib/DisplayLib/Shaders/Implementation/ShaderProgram.cs trunk/AgateLib/DisplayLib/Shaders/Implementation/Technique.cs trunk/AgateLib/DisplayLib/Shaders/Implementation/UniformState.cs trunk/AgateLib/DisplayLib/Shaders/Lighting2D.cs trunk/AgateLib/DisplayLib/Shaders/Lighting3D.cs trunk/AgateLib/DisplayLib/StringTransformer.cs trunk/AgateLib/DisplayLib/Surface.cs trunk/AgateLib/DisplayLib/SurfaceState.cs trunk/AgateLib/DisplayLib/TextLayout.cs trunk/AgateLib/DisplayLib/VertexBuffer.cs trunk/AgateLib/Drivers/AgateDriverInfo.cs trunk/AgateLib/Drivers/AgateDriverReporter.cs trunk/AgateLib/Drivers/AgateSandBoxLoader.cs trunk/AgateLib/Drivers/DriverImplBase.cs trunk/AgateLib/Drivers/IDesktopDriver.cs trunk/AgateLib/Drivers/IUserSetSystems.cs trunk/AgateLib/Drivers/NullInputImpl.cs trunk/AgateLib/Drivers/NullSoundImpl.cs trunk/AgateLib/Drivers/Registrar.cs trunk/AgateLib/Drivers/TypeID.cs trunk/AgateLib/Geometry/Builders/Cube.cs trunk/AgateLib/Geometry/Builders/Terrain.cs trunk/AgateLib/Geometry/Color.cs trunk/AgateLib/Geometry/Gradient.cs trunk/AgateLib/Geometry/Matrix4x4.cs trunk/AgateLib/Geometry/Point.cs trunk/AgateLib/Geometry/PointF.cs trunk/AgateLib/Geometry/Rectangle.cs trunk/AgateLib/Geometry/RectangleF.cs trunk/AgateLib/Geometry/Size.cs trunk/AgateLib/Geometry/SizeF.cs trunk/AgateLib/Geometry/TypeConverters.cs trunk/AgateLib/Geometry/Vector2.cs trunk/AgateLib/Geometry/Vector3.cs trunk/AgateLib/Geometry/Vector4.cs trunk/AgateLib/Geometry/VertexTypes/PositionColor.cs trunk/AgateLib/Geometry/VertexTypes/PositionTextureColor.cs trunk/AgateLib/Geometry/VertexTypes/PositionTextureColorNormal.cs trunk/AgateLib/Geometry/VertexTypes/PositionTextureNTB.cs trunk/AgateLib/Geometry/VertexTypes/PositionTextureNormal.cs trunk/AgateLib/Geometry/VertexTypes/PositionTextureNormalTangent.cs trunk/AgateLib/Geometry/VertexTypes/VertexLayout.cs trunk/AgateLib/IFileProvider.cs trunk/AgateLib/InputLib/HatState.cs trunk/AgateLib/InputLib/ImplementationBase/InputImpl.cs trunk/AgateLib/InputLib/ImplementationBase/JoystickImpl.cs trunk/AgateLib/InputLib/InputEventArgs.cs trunk/AgateLib/InputLib/Joystick.cs trunk/AgateLib/InputLib/JoystickInput.cs trunk/AgateLib/InputLib/KeyCode.cs trunk/AgateLib/InputLib/KeyModifiers.cs trunk/AgateLib/InputLib/Keyboard.cs trunk/AgateLib/InputLib/Mouse.cs trunk/AgateLib/InternalResources/Data.cs trunk/AgateLib/Platform.cs trunk/AgateLib/PlatformType.cs trunk/AgateLib/Properties/AssemblyInfo.cs trunk/AgateLib/Resources/AgateResource.cs trunk/AgateLib/Resources/AgateResourceCollection.cs trunk/AgateLib/Resources/AgateResourceException.cs trunk/AgateLib/Resources/AgateResourceLoader.cs trunk/AgateLib/Resources/BitmapFontResource.cs trunk/AgateLib/Resources/DisplayWindowResource.cs trunk/AgateLib/Resources/ImageResource.cs trunk/AgateLib/Resources/SpriteResource.cs trunk/AgateLib/Resources/StringTable.cs trunk/AgateLib/Resources/SurfaceResource.cs trunk/AgateLib/Resources/XmlHelper.cs trunk/AgateLib/Serialization/Formatters/Xml/XmlFormatter.cs trunk/AgateLib/Serialization/Xle/ITypeBinder.cs trunk/AgateLib/Serialization/Xle/IXleSerializable.cs trunk/AgateLib/Serialization/Xle/TypeBinder.cs trunk/AgateLib/Serialization/Xle/XleSerializationException.cs trunk/AgateLib/Serialization/Xle/XleSerializationInfo.cs trunk/AgateLib/Serialization/Xle/XleSerializer.cs trunk/AgateLib/Settings/PersistantSettings.cs trunk/AgateLib/Settings/SettingsGroup.cs trunk/AgateLib/Sprites/FrameList.cs trunk/AgateLib/Sprites/IFrameList.cs trunk/AgateLib/Sprites/ISprite.cs trunk/AgateLib/Sprites/ISpriteFrame.cs trunk/AgateLib/Sprites/Sprite.cs trunk/AgateLib/Sprites/SpriteFrame.cs trunk/AgateLib/Timing.cs trunk/AgateLib/Utility/FileProviderList.cs trunk/AgateLib/Utility/FileSystemProvider.cs trunk/AgateLib/Utility/Ref.cs trunk/AgateLib/Utility/SurfacePacker.cs trunk/AgateLib/Utility/TgzFileProvider.cs trunk/AgateLib/Utility/ZipFileProvider.cs trunk/Drivers/AgateDrawing/Drawing_Display.cs trunk/Drivers/AgateDrawing/Drawing_DisplayWindow.cs trunk/Drivers/AgateDrawing/Drawing_FontSurface.cs trunk/Drivers/AgateDrawing/Drawing_FrameBuffer.cs trunk/Drivers/AgateDrawing/Drawing_Reporter.cs trunk/Drivers/AgateDrawing/Drawing_Surface.cs trunk/Drivers/AgateDrawing/Properties/AssemblyInfo.cs trunk/Drivers/AgateFMOD/FMOD_Audio.cs trunk/Drivers/AgateFMOD/FMOD_Music.cs trunk/Drivers/AgateFMOD/FMOD_SoundBuffer.cs trunk/Drivers/AgateFMOD/FMOD_SoundBufferSession.cs trunk/Drivers/AgateFMOD/Reporter.cs trunk/Drivers/AgateLib.WinForms/AgateRenderTarget.Designer.cs trunk/Drivers/AgateLib.WinForms/AgateRenderTarget.cs trunk/Drivers/AgateLib.WinForms/BitmapFontUtil.cs trunk/Drivers/AgateLib.WinForms/BitmapFontUtilRenderers.cs trunk/Drivers/AgateLib.WinForms/DisplayWindowForm.Designer.cs trunk/Drivers/AgateLib.WinForms/DisplayWindowForm.cs trunk/Drivers/AgateLib.WinForms/FormUtil.cs trunk/Drivers/AgateLib.WinForms/FormsInterop.cs trunk/Drivers/AgateLib.WinForms/Properties/AssemblyInfo.cs trunk/Drivers/AgateLib.WinForms/SetSystemsForm.Designer.cs trunk/Drivers/AgateLib.WinForms/SetSystemsForm.cs trunk/Drivers/AgateLib.WinForms/WinFormsDriver.cs trunk/Drivers/AgateLib.WinForms/WinFormsReporter.cs trunk/Drivers/AgateOTK/AL_Audio.cs trunk/Drivers/AgateOTK/ContextFB.cs trunk/Drivers/AgateOTK/GL3/DrawBuffer.cs trunk/Drivers/AgateOTK/GL3/FrameBuffer.cs trunk/Drivers/AgateOTK/GL3/GLPrimitiveRenderer.cs trunk/Drivers/AgateOTK/GL3/GLVertexBuffer.cs trunk/Drivers/AgateOTK/GL3/Shaders/GL3_Basic2DShader.cs trunk/Drivers/AgateOTK/GL3/Shaders/GlslFragmentProgram.cs trunk/Drivers/AgateOTK/GL3/Shaders/GlslShader.cs trunk/Drivers/AgateOTK/GL3/Shaders/GlslShaderCompiler.cs trunk/Drivers/AgateOTK/GL3/Shaders/GlslVertexProgram.cs trunk/Drivers/AgateOTK/GL3/Shaders/IGL3Shader.cs trunk/Drivers/AgateOTK/GL3/Shaders/ShaderFactory3.cs trunk/Drivers/AgateOTK/GLDrawBuffer.cs trunk/Drivers/AgateOTK/GL_Display.cs trunk/Drivers/AgateOTK/GL_DisplayControl.cs trunk/Drivers/AgateOTK/GL_FrameBuffer.cs trunk/Drivers/AgateOTK/GL_GameWindow.cs trunk/Drivers/AgateOTK/GL_IndexBuffer.cs trunk/Drivers/AgateOTK/GL_Surface.cs trunk/Drivers/AgateOTK/GeoHelper.cs trunk/Drivers/AgateOTK/Legacy/FixedFunction/FixedFunctionShaderFactory.cs trunk/Drivers/AgateOTK/Legacy/FixedFunction/OTK_FF_Basic2DShader.cs trunk/Drivers/AgateOTK/Legacy/FixedFunction/OTK_FF_Lighting2D.cs trunk/Drivers/AgateOTK/Legacy/FixedFunction/OTK_FF_Lighting3D.cs trunk/Drivers/AgateOTK/Legacy/FrameBufferArb.cs trunk/Drivers/AgateOTK/Legacy/FrameBufferExt.cs trunk/Drivers/AgateOTK/Legacy/FrameBufferReadPixels.cs trunk/Drivers/AgateOTK/Legacy/LegacyDrawBuffer.cs trunk/Drivers/AgateOTK/Legacy/LegacyPrimitiveRenderer.cs trunk/Drivers/AgateOTK/Legacy/LegacyVertexBuffer.cs trunk/Drivers/AgateOTK/Otk_Reporter.cs trunk/Drivers/AgateOTK/PrimitiveRenderer.cs trunk/Drivers/AgateOTK/Properties/AssemblyInfo.cs trunk/Drivers/AgateOTK/ShaderFactory.cs trunk/Drivers/AgateOTK/TextureCoordinates.cs trunk/Drivers/AgateOTK/frmFullScreen.Designer.cs trunk/Drivers/AgateOTK/frmFullScreen.cs 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/Drivers/AgateSDX/D3DDevice.cs trunk/Drivers/AgateSDX/DrawBuffer.cs trunk/Drivers/AgateSDX/EffectParameter.cs trunk/Drivers/AgateSDX/FrameBufferSurface.cs trunk/Drivers/AgateSDX/FrameBufferWindow.cs trunk/Drivers/AgateSDX/GeoHelper.cs trunk/Drivers/AgateSDX/HlslCompiler.cs trunk/Drivers/AgateSDX/HlslEffect.cs trunk/Drivers/AgateSDX/Reporter.cs trunk/Drivers/AgateSDX/SDX_Display.cs trunk/Drivers/AgateSDX/SDX_DisplayWindow.cs trunk/Drivers/AgateSDX/SDX_Effect.cs trunk/Drivers/AgateSDX/SDX_FrameBuffer.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/Shaders/FixedFunction/FixedFunctionShaderFactory.cs trunk/Drivers/AgateSDX/Shaders/FixedFunction/SDX_FF_Basic2DShader.cs trunk/Drivers/AgateSDX/Shaders/FixedFunction/SDX_FF_Lighting3D.cs trunk/Drivers/AgateSDX/Shaders/ShaderFactory.cs trunk/Drivers/AgateSDX/VertexFormats.cs trunk/Drivers/AgateSDX/XAud2/XAudio2_Audio.cs trunk/Drivers/AgateSDX/XAud2/XAudio2_Music.cs trunk/Drivers/AgateSDX/XAud2/XAudio2_SoundBuffer.cs trunk/Drivers/AgateSDX/XAud2/XAudio2_SoundBufferSession.cs trunk/Drivers/AgateSDX/XAud2/XAudio2_StreamingSoundBuffer.cs trunk/Drivers/AgateSDX/frmFullScreen.Designer.cs trunk/Drivers/AgateSDX/frmFullScreen.cs Modified: trunk/AgateLib/AgateException.cs =================================================================== --- trunk/AgateLib/AgateException.cs 2011-11-21 18:27:37 UTC (rev 1299) +++ trunk/AgateLib/AgateException.cs 2011-11-21 18:43:49 UTC (rev 1300) @@ -11,7 +11,7 @@ // The Original Code is AgateLib. // // The Initial Developer of the Original Code is Erik Ylvisaker. -// Portions created by Erik Ylvisaker are Copyright (C) 2006-2009. +// Portions created by Erik Ylvisaker are Copyright (C) 2006-2011. // All Rights Reserved. // // Contributor(s): Erik Ylvisaker Modified: trunk/AgateLib/AgateFileProvider.cs =================================================================== --- trunk/AgateLib/AgateFileProvider.cs 2011-11-21 18:27:37 UTC (rev 1299) +++ trunk/AgateLib/AgateFileProvider.cs 2011-11-21 18:43:49 UTC (rev 1300) @@ -11,7 +11,7 @@ // The Original Code is AgateLib. // // The Initial Developer of the Original Code is Erik Ylvisaker. -// Portions created by Erik Ylvisaker are Copyright (C) 2006-2009. +// Portions created by Erik Ylvisaker are Copyright (C) 2006-2011. // All Rights Reserved. // // Contributor(s): Erik Ylvisaker Modified: trunk/AgateLib/AgateGame.cs =================================================================== --- trunk/AgateLib/AgateGame.cs 2011-11-21 18:27:37 UTC (rev 1299) +++ trunk/AgateLib/AgateGame.cs 2011-11-21 18:43:49 UTC (rev 1300) @@ -1,4 +1,22 @@ -using System; +// The contents of this file are subject to the Mozilla Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.mozilla.org/MPL/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations +// under the License. +// +// The Original Code is AgateLib. +// +// The Initial Developer of the Original Code is Erik Ylvisaker. +// Portions created by Erik Ylvisaker are Copyright (C) 2006-2011. +// All Rights Reserved. +// +// Contributor(s): Erik Ylvisaker +// +using System; using System.Collections.Generic; using System.Linq; using System.Text; Modified: trunk/AgateLib/AgateSetup.cs =================================================================== --- trunk/AgateLib/AgateSetup.cs 2011-11-21 18:27:37 UTC (rev 1299) +++ trunk/AgateLib/AgateSetup.cs 2011-11-21 18:43:49 UTC (rev 1300) @@ -11,7 +11,7 @@ // The Original Code is AgateLib. // // The Initial Developer of the Original Code is Erik Ylvisaker. -// Portions created by Erik Ylvisaker are Copyright (C) 2006-2009. +// Portions created by Erik Ylvisaker are Copyright (C) 2006-2011. // All Rights Reserved. // // Contributor(s): Erik Ylvisaker Modified: trunk/AgateLib/AppInitParameters.cs =================================================================== --- trunk/AgateLib/AppInitParameters.cs 2011-11-21 18:27:37 UTC (rev 1299) +++ trunk/AgateLib/AppInitParameters.cs 2011-11-21 18:43:49 UTC (rev 1300) @@ -1,4 +1,22 @@ -using System; +// The contents of this file are subject to the Mozilla Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.mozilla.org/MPL/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations +// under the License. +// +// The Original Code is AgateLib. +// +// The Initial Developer of the Original Code is Erik Ylvisaker. +// Portions created by Erik Ylvisaker are Copyright (C) 2006-2011. +// All Rights Reserved. +// +// Contributor(s): Erik Ylvisaker +// +using System; using System.Collections.Generic; using System.Linq; using System.Text; Modified: trunk/AgateLib/AudioLib/Audio.cs =================================================================== --- trunk/AgateLib/AudioLib/Audio.cs 2011-11-21 18:27:37 UTC (rev 1299) +++ trunk/AgateLib/AudioLib/Audio.cs 2011-11-21 18:43:49 UTC (rev 1300) @@ -11,7 +11,7 @@ // The Original Code is AgateLib. // // The Initial Developer of the Original Code is Erik Ylvisaker. -// Portions created by Erik Ylvisaker are Copyright (C) 2006-2009. +// Portions created by Erik Ylvisaker are Copyright (C) 2006-2011. // All Rights Reserved. // // Contributor(s): Erik Ylvisaker Modified: trunk/AgateLib/AudioLib/AudioCapsInfo.cs =================================================================== --- trunk/AgateLib/AudioLib/AudioCapsInfo.cs 2011-11-21 18:27:37 UTC (rev 1299) +++ trunk/AgateLib/AudioLib/AudioCapsInfo.cs 2011-11-21 18:43:49 UTC (rev 1300) @@ -1,4 +1,22 @@ -using System; +// The contents of this file are subject to the Mozilla Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.mozilla.org/MPL/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations +// under the License. +// +// The Original Code is AgateLib. +// +// The Initial Developer of the Original Code is Erik Ylvisaker. +// Portions created by Erik Ylvisaker are Copyright (C) 2006-2011. +// All Rights Reserved. +// +// Contributor(s): Erik Ylvisaker +// +using System; using System.Collections.Generic; using System.Linq; using System.Text; Modified: trunk/AgateLib/AudioLib/ImplementationBase/AudioImpl.cs =================================================================== --- trunk/AgateLib/AudioLib/ImplementationBase/AudioImpl.cs 2011-11-21 18:27:37 UTC (rev 1299) +++ trunk/AgateLib/AudioLib/ImplementationBase/AudioImpl.cs 2011-11-21 18:43:49 UTC (rev 1300) @@ -11,7 +11,7 @@ // The Original Code is AgateLib. // // The Initial Developer of the Original Code is Erik Ylvisaker. -// Portions created by Erik Ylvisaker are Copyright (C) 2006-2009. +// Portions created by Erik Ylvisaker are Copyright (C) 2006-2011. // All Rights Reserved. // // Contributor(s): Erik Ylvisaker Modified: trunk/AgateLib/AudioLib/ImplementationBase/MusicImpl.cs =================================================================== --- trunk/AgateLib/AudioLib/ImplementationBase/MusicImpl.cs 2011-11-21 18:27:37 UTC (rev 1299) +++ trunk/AgateLib/AudioLib/ImplementationBase/MusicImpl.cs 2011-11-21 18:43:49 UTC (rev 1300) @@ -11,7 +11,7 @@ // The Original Code is AgateLib. // // The Initial Developer of the Original Code is Erik Ylvisaker. -// Portions created by Erik Ylvisaker are Copyright (C) 2006-2009. +// Portions created by Erik Ylvisaker are Copyright (C) 2006-2011. // All Rights Reserved. // // Contributor(s): Erik Ylvisaker Modified: trunk/AgateLib/AudioLib/ImplementationBase/SoundBufferImpl.cs =================================================================== --- trunk/AgateLib/AudioLib/ImplementationBase/SoundBufferImpl.cs 2011-11-21 18:27:37 UTC (rev 1299) +++ trunk/AgateLib/AudioLib/ImplementationBase/SoundBufferImpl.cs 2011-11-21 18:43:49 UTC (rev 1300) @@ -11,7 +11,7 @@ // The Original Code is AgateLib. // // The Initial Developer of the Original Code is Erik Ylvisaker. -// Portions created by Erik Ylvisaker are Copyright (C) 2006-2009. +// Portions created by Erik Ylvisaker are Copyright (C) 2006-2011. // All Rights Reserved. // // Contributor(s): Erik Ylvisaker Modified: trunk/AgateLib/AudioLib/ImplementationBase/SoundBufferSessionImpl.cs =================================================================== --- trunk/AgateLib/AudioLib/ImplementationBase/SoundBufferSessionImpl.cs 2011-11-21 18:27:37 UTC (rev 1299) +++ trunk/AgateLib/AudioLib/ImplementationBase/SoundBufferSessionImpl.cs 2011-11-21 18:43:49 UTC (rev 1300) @@ -11,7 +11,7 @@ // The Original Code is AgateLib. // // The Initial Developer of the Original Code is Erik Ylvisaker. -// Portions created by Erik Ylvisaker are Copyright (C) 2006-2009. +// Portions created by Erik Ylvisaker are Copyright (C) 2006-2011. // All Rights Reserved. // // Contributor(s): Erik Ylvisaker Modified: trunk/AgateLib/AudioLib/ImplementationBase/StreamingSoundBufferImpl.cs =================================================================== --- trunk/AgateLib/AudioLib/ImplementationBase/StreamingSoundBufferImpl.cs 2011-11-21 18:27:37 UTC (rev 1299) +++ trunk/AgateLib/AudioLib/ImplementationBase/StreamingSoundBufferImpl.cs 2011-11-21 18:43:49 UTC (rev 1300) @@ -11,7 +11,7 @@ // The Original Code is AgateLib. // // The Initial Developer of the Original Code is Erik Ylvisaker. -// Portions created by Erik Ylvisaker are Copyright (C) 2006-2009. +// Portions created by Erik Ylvisaker are Copyright (C) 2006-2011. // All Rights Reserved. // // Contributor(s): Erik Ylvisaker Modified: trunk/AgateLib/AudioLib/Music.cs =================================================================== --- trunk/AgateLib/AudioLib/Music.cs 2011-11-21 18:27:37 UTC (rev 1299) +++ trunk/AgateLib/AudioLib/Music.cs 2011-11-21 18:43:49 UTC (rev 1300) @@ -11,7 +11,7 @@ // The Original Code is AgateLib. // // The Initial Developer of the Original Code is Erik Ylvisaker. -// Portions created by Erik Ylvisaker are Copyright (C) 2006-2009. +// Portions created by Erik Ylvisaker are Copyright (C) 2006-2011. // All Rights Reserved. // // Contributor(s): Erik Ylvisaker Modified: trunk/AgateLib/AudioLib/SoundBuffer.cs =================================================================== --- trunk/AgateLib/AudioLib/SoundBuffer.cs 2011-11-21 18:27:37 UTC (rev 1299) +++ trunk/AgateLib/AudioLib/SoundBuffer.cs 2011-11-21 18:43:49 UTC (rev 1300) @@ -11,7 +11,7 @@ // The Original Code is AgateLib. // // The Initial Developer of the Original Code is Erik Ylvisaker. -// Portions created by Erik Ylvisaker are Copyright (C) 2006-2009. +// Portions created by Erik Ylvisaker are Copyright (C) 2006-2011. // All Rights Reserved. // // Contributor(s): Erik Ylvisaker Modified: trunk/AgateLib/AudioLib/SoundBufferSession.cs =================================================================== --- trunk/AgateLib/AudioLib/SoundBufferSession.cs 2011-11-21 18:27:37 UTC (rev 1299) +++ trunk/AgateLib/AudioLib/SoundBufferSession.cs 2011-11-21 18:43:49 UTC (rev 1300) @@ -11,7 +11,7 @@ // The Original Code is AgateLib. // // The Initial Developer of the Original Code is Erik Ylvisaker. -// Portions created by Erik Ylvisaker are Copyright (C) 2006-2009. +// Portions created by Erik Ylvisaker are Copyright (C) 2006-2011. // All Rights Reserved. // // Contributor(s): Erik Ylvisaker Modified: trunk/AgateLib/AudioLib/SoundFormat.cs =================================================================== --- trunk/AgateLib/AudioLib/SoundFormat.cs 2011-11-21 18:27:37 UTC (rev 1299) +++ trunk/AgateLib/AudioLib/SoundFormat.cs 2011-11-21 18:43:49 UTC (rev 1300) @@ -11,7 +11,7 @@ // The Original Code is AgateLib. // // The Initial Developer of the Original Code is Erik Ylvisaker. -// Portions created by Erik Ylvisaker are Copyright (C) 2006-2009. +// Portions created by Erik Ylvisaker are Copyright (C) 2006-2011. // All Rights Reserved. // // Contributor(s): Erik Ylvisaker Modified: trunk/AgateLib/AudioLib/StreamingSoundBuffer.cs =================================================================== --- trunk/AgateLib/AudioLib/StreamingSoundBuffer.cs 2011-11-21 18:27:37 UTC (rev 1299) +++ trunk/AgateLib/AudioLib/StreamingSoundBuffer.cs 2011-11-21 18:43:49 UTC (rev 1300) @@ -11,7 +11,7 @@ // The Original Code is AgateLib. // // The Initial Developer of the Original Code is Erik Ylvisaker. -// Portions created by Erik Ylvisaker are Copyright (C) 2006-2009. +// Portions created by Erik Ylvisaker are Copyright (C) 2006-2011. // All Rights Reserved. // // Contributor(s): Erik Ylvisaker Modified: trunk/AgateLib/BitmapFont/BitmapFontImpl.cs =================================================================== --- trunk/AgateLib/BitmapFont/BitmapFontImpl.cs 2011-11-21 18:27:37 UTC (rev 1299) +++ trunk/AgateLib/BitmapFont/BitmapFontImpl.cs 2011-11-21 18:43:49 UTC (rev 1300) @@ -11,7 +11,7 @@ // The Original Code is AgateLib. // // The Initial Developer of the Original Code is Erik Ylvisaker. -// Portions created by Erik Ylvisaker are Copyright (C) 2006-2009. +// Portions created by Erik Ylvisaker are Copyright (C) 2006-2011. // All Rights Reserved. // // Contributor(s): Erik Ylvisaker Modified: trunk/AgateLib/BitmapFont/BitmapFontOptions.cs =================================================================== --- trunk/AgateLib/BitmapFont/BitmapFontOptions.cs 2011-11-21 18:27:37 UTC (rev 1299) +++ trunk/AgateLib/BitmapFont/BitmapFontOptions.cs 2011-11-21 18:43:49 UTC (rev 1300) @@ -11,7 +11,7 @@ // The Original Code is AgateLib. // // The Initial Developer of the Original Code is Erik Ylvisaker. -// Portions created by Erik Ylvisaker are Copyright (C) 2006-2009. +// Portions created by Erik Ylvisaker are Copyright (C) 2006-2011. // All Rights Reserved. // // Contributor(s): Erik Ylvisaker Modified: trunk/AgateLib/BitmapFont/FontMetrics.cs =================================================================== --- trunk/AgateLib/BitmapFont/FontMetrics.cs 2011-11-21 18:27:37 UTC (rev 1299) +++ trunk/AgateLib/BitmapFont/FontMetrics.cs 2011-11-21 18:43:49 UTC (rev 1300) @@ -11,7 +11,7 @@ // The Original Code is AgateLib. // // The Initial Developer of the Original Code is Erik Ylvisaker. -// Portions created by Erik Ylvisaker are Copyright (C) 2006-2009. +// Portions created by Erik Ylvisaker are Copyright (C) 2006-2011. // All Rights Reserved. // // Contributor(s): Erik Ylvisaker Modified: trunk/AgateLib/BitmapFont/GlyphMetrics.cs =================================================================== --- trunk/AgateLib/BitmapFont/GlyphMetrics.cs 2011-11-21 18:27:37 UTC (rev 1299) +++ trunk/AgateLib/BitmapFont/GlyphMetrics.cs 2011-11-21 18:43:49 UTC (rev 1300) @@ -11,7 +11,7 @@ // The Original Code is AgateLib. // // The Initial Developer of the Original Code is Erik Ylvisaker. -// Portions created by Erik Ylvisaker are Copyright (C) 2006-2009. +// Portions created by Erik Ylvisaker are Copyright (C) 2006-2011. // All Rights Reserved. // // Contributor(s): Erik Ylvisaker Modified: trunk/AgateLib/Core.cs =================================================================== --- trunk/AgateLib/Core.cs 2011-11-21 18:27:37 UTC (rev 1299) +++ trunk/AgateLib/Core.cs 2011-11-21 18:43:49 UTC (rev 1300) @@ -11,7 +11,7 @@ // The Original Code is AgateLib. // // The Initial Developer of the Original Code is Erik Ylvisaker. -// Portions created by Erik Ylvisaker are Copyright (C) 2006-2009. +// Portions created by Erik Ylvisaker are Copyright (C) 2006-2011. // All Rights Reserved. // // Contributor(s): Erik Ylvisaker Modified: trunk/AgateLib/Data/AgateColumn.cs =================================================================== --- trunk/AgateLib/Data/AgateColumn.cs 2011-11-21 18:27:37 UTC (rev 1299) +++ trunk/AgateLib/Data/AgateColumn.cs 2011-11-21 18:43:49 UTC (rev 1300) @@ -1,4 +1,22 @@ -using System; +// The contents of this file are subject to the Mozilla Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.mozilla.org/MPL/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations +// under the License. +// +// The Original Code is AgateLib. +// +// The Initial Developer of the Original Code is Erik Ylvisaker. +// Portions created by Erik Ylvisaker are Copyright (C) 2006-2011. +// All Rights Reserved. +// +// Contributor(s): Erik Ylvisaker +// +using System; using System.Collections.Generic; using System.Linq; using System.Text; Modified: trunk/AgateLib/Data/AgateColumnDictionary.cs =================================================================== --- trunk/AgateLib/Data/AgateColumnDictionary.cs 2011-11-21 18:27:37 UTC (rev 1299) +++ trunk/AgateLib/Data/AgateColumnDictionary.cs 2011-11-21 18:43:49 UTC (rev 1300) @@ -1,4 +1,22 @@ -using System; +// The contents of this file are subject to the Mozilla Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.mozilla.org/MPL/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations +// under the License. +// +// The Original Code is AgateLib. +// +// The Initial Developer of the Original Code is Erik Ylvisaker. +// Portions created by Erik Ylvisaker are Copyright (C) 2006-2011. +// All Rights Reserved. +// +// Contributor(s): Erik Ylvisaker +// +using System; using System.Collections.Generic; using System.Linq; using System.Text; Modified: trunk/AgateLib/Data/AgateDataHelper.cs =================================================================== --- trunk/AgateLib/Data/AgateDataHelper.cs 2011-11-21 18:27:37 UTC (rev 1299) +++ trunk/AgateLib/Data/AgateDataHelper.cs 2011-11-21 18:43:49 UTC (rev 1300) @@ -1,4 +1,22 @@ -using System; +// The contents of this file are subject to the Mozilla Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.mozilla.org/MPL/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations +// under the License. +// +// The Original Code is AgateLib. +// +// The Initial Developer of the Original Code is Erik Ylvisaker. +// Portions created by Erik Ylvisaker are Copyright (C) 2006-2011. +// All Rights Reserved. +// +// Contributor(s): Erik Ylvisaker +// +using System; using System.Collections.Generic; using System.Linq; using System.Reflection; Modified: trunk/AgateLib/Data/AgateDatabase.cs =================================================================== --- trunk/AgateLib/Data/AgateDatabase.cs 2011-11-21 18:27:37 UTC (rev 1299) +++ trunk/AgateLib/Data/AgateDatabase.cs 2011-11-21 18:43:49 UTC (rev 1300) @@ -1,4 +1,22 @@ -using System; +// The contents of this file are subject to the Mozilla Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.mozilla.org/MPL/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations +// under the License. +// +// The Original Code is AgateLib. +// +// The Initial Developer of the Original Code is Erik Ylvisaker. +// Portions created by Erik Ylvisaker are Copyright (C) 2006-2011. +// All Rights Reserved. +// +// Contributor(s): Erik Ylvisaker +// +using System; using System.Collections.Generic; using System.IO; using System.Linq; Modified: trunk/AgateLib/Data/AgateDatabaseException.cs =================================================================== --- trunk/AgateLib/Data/AgateDatabaseException.cs 2011-11-21 18:27:37 UTC (rev 1299) +++ trunk/AgateLib/Data/AgateDatabaseException.cs 2011-11-21 18:43:49 UTC (rev 1300) @@ -1,4 +1,22 @@ -using System; +// The contents of this file are subject to the Mozilla Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.mozilla.org/MPL/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations +// under the License. +// +// The Original Code is AgateLib. +// +// The Initial Developer of the Original Code is Erik Ylvisaker. +// Portions created by Erik Ylvisaker are Copyright (C) 2006-2011. +// All Rights Reserved. +// +// Contributor(s): Erik Ylvisaker +// +using System; using System.Collections.Generic; using System.Linq; using System.Text; Modified: trunk/AgateLib/Data/AgateRow.cs =================================================================== --- trunk/AgateLib/Data/AgateRow.cs 2011-11-21 18:27:37 UTC (rev 1299) +++ trunk/AgateLib/Data/AgateRow.cs 2011-11-21 18:43:49 UTC (rev 1300) @@ -1,4 +1,22 @@ -using System; +// The contents of this file are subject to the Mozilla Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.mozilla.org/MPL/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations +// under the License. +// +// The Original Code is AgateLib. +// +// The Initial Developer of the Original Code is Erik Ylvisaker. +// Portions created by Erik Ylvisaker are Copyright (C) 2006-2011. +// All Rights Reserved. +// +// Contributor(s): Erik Ylvisaker +// +using System; using System.Collections.Generic; using System.Linq; using System.Text; Modified: trunk/AgateLib/Data/AgateRowList.cs =================================================================== --- trunk/AgateLib/Data/AgateRowList.cs 2011-11-21 18:27:37 UTC (rev 1299) +++ trunk/AgateLib/Data/AgateRowList.cs 2011-11-21 18:43:49 UTC (rev 1300) @@ -1,4 +1,22 @@ -using System; +// The contents of this file are subject to the Mozilla Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.mozilla.org/MPL/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations +// under the License. +// +// The Original Code is AgateLib. +// +// The Initial Developer of the Original Code is Erik Ylvisaker. +// Portions created by Erik Ylvisaker are Copyright (C) 2006-2011. +// All Rights Reserved. +// +// Contributor(s): Erik Ylvisaker +// +using System; using System.Collections.Generic; using System.Linq; using System.Text; Modified: trunk/AgateLib/Data/AgateTable.cs =================================================================== --- trunk/AgateLib/Data/AgateTable.cs 2011-11-21 18:27:37 UTC (rev 1299) +++ trunk/AgateLib/Data/AgateTable.cs 2011-11-21 18:43:49 UTC (rev 1300) @@ -1,4 +1,22 @@ -using System; +// The contents of this file are subject to the Mozilla Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.mozilla.org/MPL/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations +// under the License. +// +// The Original Code is AgateLib. +// +// The Initial Developer of the Original Code is Erik Ylvisaker. +// Portions created by Erik Ylvisaker are Copyright (C) 2006-2011. +// All Rights Reserved. +// +// Contributor(s): Erik Ylvisaker +// +using System; using System.Collections.Generic; using System.IO; using System.Linq; Modified: trunk/AgateLib/Data/AgateTableDictionary.cs =================================================================== --- trunk/AgateLib/Data/AgateTableDictionary.cs 2011-11-21 18:27:37 UTC (rev 1299) +++ trunk/AgateLib/Data/AgateTableDictionary.cs 2011-11-21 18:43:49 UTC (rev 1300) @@ -1,4 +1,22 @@ -using System; +// The contents of this file are subject to the Mozilla Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.mozilla.org/MPL/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations +// under the License. +// +// The Original Code is AgateLib. +// +// The Initial Developer of the Original Code is Erik Ylvisaker. +// Portions created by Erik Ylvisaker are Copyright (C) 2006-2011. +// All Rights Reserved. +// +// Contributor(s): Erik Ylvisaker +// +using System; using System.Collections.Generic; using System.IO; using System.Linq; Modified: trunk/AgateLib/Data/FieldType.cs =================================================================== --- trunk/AgateLib/Data/FieldType.cs 2011-11-21 18:27:37 UTC (rev 1299) +++ trunk/AgateLib/Data/FieldType.cs 2011-11-21 18:43:49 UTC (rev 1300) @@ -1,4 +1,22 @@ -using System; +// The contents of this file are subject to the Mozilla Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.mozilla.org/MPL/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations +// under the License. +// +// The Original Code is AgateLib. +// +// The Initial Developer of the Original Code is Erik Ylvisaker. +// Portions created by Erik Ylvisaker are Copyright (C) 2006-2011. +// All Rights Reserved. +// +// Contributor(s): Erik Ylvisaker +// +using System; using System.Collections.Generic; using System.Linq; using System.Text; Modified: trunk/AgateLib/DisplayLib/Cache/FontStateCache.cs =================================================================== --- trunk/AgateLib/DisplayLib/Cache/FontStateCache.cs 2011-11-21 18:27:37 UTC (rev 1299) +++ trunk/AgateLib/DisplayLib/Cache/FontStateCache.cs 2011-11-21 18:43:49 UTC (rev 1300) @@ -11,7 +11,7 @@ // The Original Code is AgateLib. // // The Initial Developer of the Original Code is Erik Ylvisaker. -// Portions created by Erik Ylvisaker are Copyright (C) 2006-2009. +// Portions created by Erik Ylvisaker are Copyright (C) 2006-2011. // All Rights Reserved. // // Contributor(s): Erik Ylvisaker Modified: trunk/AgateLib/DisplayLib/Cache/SurfaceStateCache.cs =================================================================== --- trunk/AgateLib/DisplayLib/Cache/SurfaceStateCache.cs 2011-11-21 18:27:37 UTC (rev 1299) +++ trunk/AgateLib/DisplayLib/Cache/SurfaceStateCache.cs 2011-11-21 18:43:49 UTC (rev 1300) @@ -11,7 +11,7 @@ // The Original Code is AgateLib. // // The Initial Developer of the Original Code is Erik Ylvisaker. -// Portions created by Erik Ylvisaker are Copyright (C) 2006-2009. +// Portions created by Erik Ylvisaker are Copyright (C) 2006-2011. // All Rights Reserved. // // Contributor(s): Erik Ylvisaker Modified: trunk/AgateLib/DisplayLib/CreateWindowParams.cs =================================================================== --- trunk/AgateLib/DisplayLib/CreateWindowParams.cs 2011-11-21 18:27:37 UTC (rev 1299) +++ trunk/AgateLib/DisplayLib/CreateWindowParams.cs 2011-11-21 18:43:49 UTC (rev 1300) @@ -11,7 +11,7 @@ // The Original Code is AgateLib. // // The Initial Developer of the Original Code is Erik Ylvisaker. -// Portions created by Erik Ylvisaker are Copyright (C) 2006-2009. +// Portions created by Erik Ylvisaker are Copyright (C) 2006-2011. // All Rights Reserved. // // Contributor(s): Erik Ylvisaker Modified: trunk/AgateLib/DisplayLib/Display.cs =================================================================== --- trunk/AgateLib/DisplayLib/Display.cs 2011-11-21 18:27:37 UTC (rev 1299) +++ trunk/AgateLib/DisplayLib/Display.cs 2011-11-21 18:43:49 UTC (rev 1300) @@ -11,7 +11,7 @@ // The Original Code is AgateLib. // // The Initial Developer of the Original Code is Erik Ylvisaker. -// Portions created by Erik Ylvisaker are Copyright (C) 2006-2009. +// Portions created by Erik Ylvisaker are Copyright (C) 2006-2011. // All Rights Reserved. // // Contributor(s): Erik Ylvisaker Modified: trunk/AgateLib/DisplayLib/DisplayCapsInfo.cs =================================================================== --- trunk/AgateLib/DisplayLib/DisplayCapsInfo.cs 2011-11-21 18:27:37 UTC (rev 1299) +++ trunk/AgateLib/DisplayLib/DisplayCapsInfo.cs 2011-11-21 18:43:49 UTC (rev 1300) @@ -1,4 +1,22 @@ -using System; +// The contents of this file are subject to the Mozilla Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.mozilla.org/MPL/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations +// under the License. +// +// The Original Code is AgateLib. +// +// The Initial Developer of the Original Code is Erik Ylvisaker. +// Portions created by Erik Ylvisaker are Copyright (C) 2006-2011. +// All Rights Reserved. +// +// Contributor(s): Erik Ylvisaker +// +using System; using System.Collections.Generic; using System.Linq; using System.Text; Modified: trunk/AgateLib/DisplayLib/DisplayWindow.cs =================================================================== --- trunk/AgateLib/DisplayLib/DisplayWindow.cs 2011-11-21 18:27:37 UTC (rev 1299) +++ trunk/AgateLib/DisplayLib/DisplayWindow.cs 2011-11-21 18:43:49 UTC (rev 1300) @@ -11,7 +11,7 @@ // The Original Code is AgateLib. // // The Initial Developer of the Original Code is Erik Ylvisaker. -// Portions created by Erik Ylvisaker are Copyright (C) 2006-2009. +// Portions created by Erik Ylvisaker are Copyright (C) 2006-2011. // All Rights Reserved. // // Contributor(s): Erik Ylvisaker Modified: trunk/AgateLib/DisplayLib/FontState.cs =================================================================== --- trunk/AgateLib/DisplayLib/FontState.cs 2011-11-21 18:27:37 UTC (rev 1299) +++ trunk/AgateLib/DisplayLib/FontState.cs 2011-11-21 18:43:49 UTC (rev 1300) @@ -11,7 +11,7 @@ // The Original Code is AgateLib. // // The Initial Developer of the Original Code is Erik Ylvisaker. -// Portions created by Erik Ylvisaker are Copyright (C) 2006-2009. +// Portions created by Erik Ylvisaker are Copyright (C) 2006-2011. // All Rights Reserved. // // Contributor(s): Erik Ylvisaker Modified: trunk/AgateLib/DisplayLib/FontSurface.cs =================================================================== --- trunk/AgateLib/DisplayLib/FontSurface.cs 2011-11-21 18:27:37 UTC (rev 1299) +++ trunk/AgateLib/DisplayLib/FontSurface.cs 2011-11-21 18:43:49 UTC (rev 1300) @@ -11,7 +11,7 @@ // The Original Code is AgateLib. // // The Initial Developer of the Original Code is Erik Ylvisaker. -// Portions created by Erik Ylvisaker are Copyright (C) 2006-2009. +// Portions created by Erik Ylvisaker are Copyright (C) 2006-2011. // All Rights Reserved. // // Contributor(s): Erik Ylvisaker Modified: trunk/AgateLib/DisplayLib/FrameBuffer.cs =================================================================== --- trunk/AgateLib/DisplayLib/FrameBuffer.cs 2011-11-21 18:27:37 UTC (rev 1299) +++ trunk/AgateLib/DisplayLib/FrameBuffer.cs 2011-11-21 18:43:49 UTC (rev 1300) @@ -1,4 +1,22 @@ -using System; +// The contents of this file are subject to the Mozilla Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.mozilla.org/MPL/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations +// under the License. +// +// The Original Code is AgateLib. +// +// The Initial Developer of the Original Code is Erik Ylvisaker. +// Portions created by Erik Ylvisaker are Copyright (C) 2006-2011. +// All Rights Reserved. +// +// Contributor(s): Erik Ylvisaker +// +using System; using System.Collections.Generic; using System.Linq; using System.Text; Modified: trunk/AgateLib/DisplayLib/ISurface.cs =================================================================== --- trunk/AgateLib/DisplayLib/ISurface.cs 2011-11-21 18:27:37 UTC (rev 1299) +++ trunk/AgateLib/DisplayLib/ISurface.cs 2011-11-21 18:43:49 UTC (rev 1300) @@ -11,7 +11,7 @@ // The Original Code is AgateLib. // // The Initial Developer of the Original Code is Erik Ylvisaker. -// Portions created by Erik Ylvisaker are Copyright (C) 2006-2009. +// Portions created by Erik Ylvisaker are Copyright (C) 2006-2011. // All Rights Reserved. // // Contributor(s): Erik Ylvisaker Modified: trunk/AgateLib/DisplayLib/ImplementationBase/DisplayImpl.cs =================================================================== --- trunk/AgateLib/DisplayLib/ImplementationBase/DisplayImpl.cs 2011-11-21 18:27:37 UTC (rev 1299) +++ trunk/AgateLib/DisplayLib/ImplementationBase/DisplayImpl.cs 2011-11-21 18:43:49 UTC (rev 1300) @@ -11,7 +11,7 @@ // The Original Code is AgateLib. // // The Initial Developer of the Original Code is Erik Ylvisaker. -// Portions created by Erik Ylvisaker are Copyright (C) 2006-2009. +// Portions created by Erik Ylvisaker are Copyright (C) 2006-2011. // All Rights Reserved. // // Contributor(s): Erik Ylvisaker Modified: trunk/AgateLib/DisplayLib/ImplementationBase/DisplayWindowImpl.cs =================================================================== --- trunk/AgateLib/DisplayLib/ImplementationBase/DisplayWindowImpl.cs 2011-11-21 18:27:37 UTC (rev 1299) +++ trunk/AgateLib/DisplayLib/ImplementationBase/DisplayWindowImpl.cs 2011-11-21 18:43:49 UTC (rev 1300) @@ -11,7 +11,7 @@ // The Original Code is AgateLib. // // The Initial Developer of the Original Code is Erik Ylvisaker. -// Portions created by Erik Ylvisaker are Copyright (C) 2006-2009. +// Portions created by Erik Ylvisaker are Copyright (C) 2006-2011. // All Rights Reserved. // // Contributor(s): Erik Ylvisaker Modified: trunk/AgateLib/DisplayLib/ImplementationBase/FontSurfaceImpl.cs =================================================================== --- trunk/AgateLib/DisplayLib/ImplementationBase/FontSurfaceImpl.cs 2011-11-21 18:27:37 UTC (rev 1299) +++ trunk/AgateLib/DisplayLib/ImplementationBase/FontSurfaceImpl.cs 2011-11-21 18:43:49 UTC (rev 1300) @@ -11,7 +11,7 @@ // The Original Code is AgateLib. // // The Initial Developer of the Original Code is Erik Ylvisaker. -// Portions created by Erik Ylvisaker are Copyright (C) 2006-2009. +// Portions created by Erik Ylvisaker are Copyright (C) 2006-2011. // All Rights Reserved. // // Contributor(s): Erik Ylvisaker Modified: trunk/AgateLib/DisplayLib/ImplementationBase/FrameBufferImpl.cs =================================================================== --- trunk/AgateLib/DisplayLib/ImplementationBase/FrameBufferImpl.cs 2011-11-21 18:27:37 UTC (rev 1299) +++ trunk/AgateLib/DisplayLib/ImplementationBase/FrameBufferImpl.cs 2011-11-21 18:43:49 UTC (rev 1300) @@ -11,7 +11,7 @@ // The Original Code is AgateLib. // // The Initial Developer of the Original Code is Erik Ylvisaker. -// Portions created by Erik Ylvisaker are Copyright (C) 2006-2009. +// Portions created by Erik Ylvisaker are Copyright (C) 2006-2011. // All Rights Reserved. // // Contributor(s): Erik Ylvisaker Modified: trunk/AgateLib/DisplayLib/ImplementationBase/IndexBufferImpl.cs =================================================================== --- trunk/AgateLib/DisplayLib/ImplementationBase/IndexBufferImpl.cs 2011-11-21 18:27:37 UTC (rev 1299) +++ trunk/AgateLib/DisplayLib/ImplementationBase/IndexBufferImpl.cs 2011-11-21 18:43:49 UTC (rev 1300) @@ -11,7 +11,7 @@ // The Original Code is AgateLib. // // The Initial Developer of the Original Code is Erik Ylvisaker. -// Portions created by Erik Ylvisaker are Copyright (C) 2006-2009. +// Portions created by Erik Ylvisaker are Copyright (C) 2006-2011. // All Rights Reserved. // // Contributor(s): Erik Ylvisaker Modified: trunk/AgateLib/DisplayLib/ImplementationBase/ShaderCompilerImpl.cs =================================================================== --- trunk/AgateLib/DisplayLib/ImplementationBase/ShaderCompilerImpl.cs 2011-11-21 18:27:37 UTC (rev 1299) +++ trunk/AgateLib/DisplayLib/ImplementationBase/ShaderCompilerImpl.cs 2011-11-21 18:43:49 UTC (rev 1300) @@ -11,7 +11,7 @@ // The Original Code is AgateLib. // // The Initial Developer of the Original Code is Erik Ylvisaker. -// Portions created by Erik Ylvisaker are Copyright (C) 2006-2009. +// Portions created by Erik Ylvisaker are Copyright (C) 2006-2011. // All Rights Reserved. // // Contributor(s): Erik Ylvisaker Modified: trunk/AgateLib/DisplayLib/ImplementationBase/SurfaceImpl.cs =================================================================== --- trunk/AgateLib/DisplayLib/ImplementationBase/SurfaceImpl.cs 2011-11-21 18:27:37 UTC (rev 1299) +++ trunk/AgateLib/DisplayLib/ImplementationBase/SurfaceImpl.cs 2011-11-21 18:43:49 UTC (rev 1300) @@ -11,7 +11,7 @@ // The Original Code is AgateLib. // // The Initial Developer of the Original Code is Erik Ylvisaker. -// Portions created by Erik Ylvisaker are Copyright (C) 2006-2009. +// Portions created by Erik Ylvisaker are Copyright (C) 2006-2011. // All Rights Reserved. // // Contributor(s): Erik Ylvisaker Modified: trunk/AgateLib/DisplayLib/ImplementationBase/VertexBufferImpl.cs =================================================================== --- trunk/AgateLib/DisplayLib/ImplementationBase/VertexBufferImpl.cs 2011-11-21 18:27:37 UTC (rev 1299) +++ trunk/AgateLib/DisplayLib/ImplementationBase/VertexBufferImpl.cs 2011-11-21 18:43:49 UTC (rev 1300) @@ -11,7 +11,7 @@ // The Original Code is AgateLib. // // The Initial Developer of the Original Code is Erik Ylvisaker. -// Portions created by Erik Ylvisaker are Copyright (C) 2006-2009. +// Portions created by Erik Ylvisaker are Copyright (C) 2006-2011. // All Rights Reserved. // // Contributor(s): Erik Ylvisaker Modified: trunk/AgateLib/DisplayLib/IndexBuffer.cs =================================================================== --- trunk/AgateLib/DisplayLib/IndexBuffer.cs 2011-11-21 18:27:37 UTC (rev 1299) +++ trunk/AgateLib/DisplayLib/IndexBuffer.cs 2011-11-21 18:43:49 UTC (rev 1300) @@ -11,7 +11,7 @@ // The Original Code is AgateLib. // // The Initial Developer of the Original Code is Erik Ylvisaker. -// Portions created by Erik Ylvisaker are Copyright (C) 2006-2009. +// Portions created by Erik Ylvisaker are Copyright (C) 2006-2011. // All Rights Reserved. // // Contributor(s): Erik Ylvisaker Modified: trunk/AgateLib/DisplayLib/Origin.cs =================================================================== --- trunk/AgateLib/DisplayLib/Origin.cs 2011-11-21 18:27:37 UTC (rev 1299) +++ trunk/AgateLib/DisplayLib/Origin.cs 2011-11-21 18:43:49 UTC (rev 1300) @@ -11,7 +11,7 @@ // The Original Code is AgateLib. // // The Initial Developer of the Original Code is Erik Ylvisaker. -// Portions created by Erik Ylvisaker are Copyright (C) 2006-2009. +// Portions created by Erik Ylvisaker are Copyright (C) 2006-2011. // All Rights Reserved. // // Contributor(s): Erik Ylvisaker Modified: trunk/AgateLib/DisplayLib/OriginAlignment.cs =================================================================== --- trunk/AgateLib/DisplayLib/OriginAlignment.cs 2011-11-21 18:27:37 UTC (rev 1299) +++ trunk/AgateLib/DisplayLib/OriginAlignment.cs 2011-11-21 18:43:49 UTC (rev 1300) @@ -11,7 +11,7 @@ // The Original Code is AgateLib. // // The Initial Developer of the Original Code is Erik Ylvisaker. -// Portions created by Erik Ylvisaker are Copyright (C) 2006-2009. +// Portions created by Erik Ylvisaker are Copyright (C) 2006-2011. // All Rights Reserved. // // Contributor(s): Erik Ylvisaker Modified: trunk/AgateLib/DisplayLib/PixelBuffer.cs =================================================================== --- trunk/AgateLib/DisplayLib/PixelBuffer.cs 2011-11-21 18:27:37 UTC (rev 1299) +++ trunk/AgateLib/DisplayLib/PixelBuffer.cs 2011-11-21 18:43:49 UTC (rev 1300) @@ -11,7 +11,7 @@ // The Original Code is AgateLib. // // The Initial Developer of the Original Code is Erik Ylvisaker. -// Portions created by Erik Ylvisaker are Copyright (C) 2006-2009. +// Portions created by Erik Ylvisaker are Copyright (C) 2006-2011. // All Rights Reserved. // // Contributor(s): Erik Ylvisaker Modified: trunk/AgateLib/DisplayLib/PixelFormat.cs =================================================================== --- trunk/AgateLib/DisplayLib/PixelFormat.cs 2011-11-21 18:27:37 UTC (rev 1299) +++ trunk/AgateLib/DisplayLib/PixelFormat.cs 2011-11-21 18:43:49 UTC (rev 1300) @@ -11,7 +11,7 @@ // The Original Code is AgateLib. // // The Initial Developer of the Original Code is Erik Ylvisaker. -// Portions created by Erik Ylvisaker are Copyright (C) 2006-2009. +// Portions created by Erik Ylvisaker are Copyright (C) 2006-2011. // All Rights Reserved. // // Contributor(s): Erik Ylvisaker Modified: trunk/AgateLib/DisplayLib/PrimitiveType.cs =================================================================== --- trunk/AgateLib/DisplayLib/PrimitiveType.cs 2011-11-21 18:27:37 UTC (rev 1299) +++ trunk/AgateLib/DisplayLib/PrimitiveType.cs 2011-11-21 18:43:49 UTC (rev 1300) @@ -1,4 +1,22 @@ -using System; +// The contents of this file are subject to the Mozilla Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.mozilla.org/MPL/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations +// under the License. +// +// The Original Code is AgateLib. +// +// The Initial Developer of the Original Code is Erik Ylvisaker. +// Portions created by Erik Ylvisaker are Copyright (C) 2006-2011. +// All Rights Reserved. +// +// Contributor(s): Erik Ylvisaker +// +using System; using System.Collections.Generic; using System.Text; Modified: trunk/AgateLib/DisplayLib/RenderStateAdapter.cs =================================================================== --- trunk/AgateLib/DisplayLib/RenderStateAdapter.cs 2011-11-21 18:27:37 UTC (rev 1299) +++ trunk/AgateLib/DisplayLib/RenderStateAdapter.cs 2011-11-21 18:43:49 UTC (rev 1300) @@ -1,4 +1,22 @@ -using System; +// The contents of this file are subject to the Mozilla Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.mozilla.org/MPL/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations +// under the License. +// +// The Original Code is AgateLib. +// +// The Initial Developer of the Original Code is Erik Ylvisaker. +// Portions created by Erik Ylvisaker are Copyright (C) 2006-2011. +// All Rights Reserved. +// +// Contributor(s): Erik Ylvisaker +// +using System; using System.Collections.Generic; using System.Linq; using System.Text; Modified: trunk/AgateLib/DisplayLib/ScreenMode.cs =================================================================== --- trunk/AgateLib/DisplayLib/ScreenMode.cs 2011-11-21 18:27:37 UTC (rev 1299) +++ trunk/AgateLib/DisplayLib/ScreenMode.cs 2011-11-21 18:43:49 UTC (rev 1300) @@ -11,7 +11,7 @@ // The Original Code is AgateLib. // // The Initial Developer of the Original Code is Erik Ylvisaker. -// Portions created by Erik Ylvisaker are Copyright (C) 2006-2009. +// Portions created by Erik Ylvisaker are Copyright (C) 2006-2011. // All Rights Reserved. // // Contributor(s): Erik Ylvisaker Modified: trunk/AgateLib/DisplayLib/Shaders/AgateBuiltInShaders.cs =================================================================== --- trunk/AgateLib/DisplayLib/Shaders/AgateBuiltInShaders.cs 2011-11-21 18:27:37 UTC (rev 1299) +++ trunk/AgateLib/DisplayLib/Shaders/AgateBuiltInShaders.cs 2011-11-21 18:43:49 UTC (rev 1300) @@ -11,7 +11,7 @@ // The Original Code is AgateLib. // // The Initial Developer of the Original Code is Erik Ylvisaker. -// Portions created by Erik Ylvisaker are Copyright (C) 2006-2009. +// Portions created by Erik Ylvisaker are Copyright (C) 2006-2011. // All Rights Reserved. // // Contributor(s): Erik Ylvisaker Modified: trunk/AgateLib/DisplayLib/Shad... [truncated message content] |
From: <ka...@us...> - 2011-11-21 18:27:47
|
Revision: 1299 http://agate.svn.sourceforge.net/agate/?rev=1299&view=rev Author: kanato Date: 2011-11-21 18:27:37 +0000 (Mon, 21 Nov 2011) Log Message: ----------- Removed EXT extensions in FrameBufferArb. Added copyright information. Modified Paths: -------------- trunk/Drivers/AgateOTK/Legacy/FrameBufferArb.cs trunk/Drivers/AgateOTK/Legacy/FrameBufferExt.cs trunk/Drivers/AgateOTK/Legacy/FrameBufferReadPixels.cs trunk/Drivers/AgateOTK/Legacy/LegacyPrimitiveRenderer.cs trunk/Drivers/AgateOTK/Legacy/LegacyVertexBuffer.cs Modified: trunk/Drivers/AgateOTK/Legacy/FrameBufferArb.cs =================================================================== --- trunk/Drivers/AgateOTK/Legacy/FrameBufferArb.cs 2011-11-21 18:26:57 UTC (rev 1298) +++ trunk/Drivers/AgateOTK/Legacy/FrameBufferArb.cs 2011-11-21 18:27:37 UTC (rev 1299) @@ -1,4 +1,22 @@ -using System; +// The contents of this file are subject to the Mozilla Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.mozilla.org/MPL/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations +// under the License. +// +// The Original Code is AgateLib. +// +// The Initial Developer of the Original Code is Erik Ylvisaker. +// Portions created by Erik Ylvisaker are Copyright (C) 2006-2009. +// All Rights Reserved. +// +// Contributor(s): Erik Ylvisaker +// +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -31,31 +49,31 @@ // generate the frame buffer GL.GenFramebuffers(1, out mFramebufferID); - GL.BindFramebuffer(FramebufferTarget.FramebufferExt, mFramebufferID); + GL.BindFramebuffer(FramebufferTarget.Framebuffer, mFramebufferID); // generate a depth buffer to render to GL.GenRenderbuffers(1, out mDepthBuffer); - GL.BindRenderbuffer(RenderbufferTarget.RenderbufferExt, mDepthBuffer); + GL.BindRenderbuffer(RenderbufferTarget.Renderbuffer, mDepthBuffer); // hack here because RenderbufferStorage enum is incomplete. - GL.RenderbufferStorage(RenderbufferTarget.RenderbufferExt, + GL.RenderbufferStorage(RenderbufferTarget.Renderbuffer, RenderbufferStorage.Depth24Stencil8, mSize.Width, mSize.Height); // attach the depth buffer - GL.FramebufferRenderbuffer(FramebufferTarget.FramebufferExt, - FramebufferAttachment.DepthAttachmentExt, RenderbufferTarget.RenderbufferExt, + GL.FramebufferRenderbuffer(FramebufferTarget.Framebuffer, + FramebufferAttachment.DepthAttachment, RenderbufferTarget.Renderbuffer, mDepthBuffer); // attach the texture - GL.FramebufferTexture2D(FramebufferTarget.FramebufferExt, - FramebufferAttachment.ColorAttachment0Ext, TextureTarget.Texture2D, + GL.FramebufferTexture2D(FramebufferTarget.Framebuffer, + FramebufferAttachment.ColorAttachment0, TextureTarget.Texture2D, mTexture.GLTextureID, 0); FramebufferErrorCode code = - GL.CheckFramebufferStatus(FramebufferTarget.FramebufferExt); + GL.CheckFramebufferStatus(FramebufferTarget.Framebuffer); - if (code != FramebufferErrorCode.FramebufferCompleteExt) + if (code != FramebufferErrorCode.FramebufferComplete) { throw new AgateException( "Could not complete framebuffer object. Received error code " @@ -82,14 +100,14 @@ public override void BeginRender() { - GL.BindFramebuffer(FramebufferTarget.FramebufferExt, mFramebufferID); + GL.BindFramebuffer(FramebufferTarget.Framebuffer, mFramebufferID); //GL.PushAttrib(AttribMask.ViewportBit); } public override void EndRender() { //GL.PopAttrib(); - GL.BindFramebuffer(FramebufferTarget.FramebufferExt, 0); + GL.BindFramebuffer(FramebufferTarget.Framebuffer, 0); GL.BindTexture(TextureTarget.Texture2D, mTexture.GLTextureID); GL.GenerateMipmap(GenerateMipmapTarget.Texture2D); @@ -97,7 +115,7 @@ public override void MakeCurrent() { - GL.BindFramebuffer(FramebufferTarget.FramebufferExt, mFramebufferID); + GL.BindFramebuffer(FramebufferTarget.Framebuffer, mFramebufferID); } } } Modified: trunk/Drivers/AgateOTK/Legacy/FrameBufferExt.cs =================================================================== --- trunk/Drivers/AgateOTK/Legacy/FrameBufferExt.cs 2011-11-21 18:26:57 UTC (rev 1298) +++ trunk/Drivers/AgateOTK/Legacy/FrameBufferExt.cs 2011-11-21 18:27:37 UTC (rev 1299) @@ -1,4 +1,22 @@ -using System; +// The contents of this file are subject to the Mozilla Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.mozilla.org/MPL/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations +// under the License. +// +// The Original Code is AgateLib. +// +// The Initial Developer of the Original Code is Erik Ylvisaker. +// Portions created by Erik Ylvisaker are Copyright (C) 2006-2009. +// All Rights Reserved. +// +// Contributor(s): Erik Ylvisaker +// +using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; Modified: trunk/Drivers/AgateOTK/Legacy/FrameBufferReadPixels.cs =================================================================== --- trunk/Drivers/AgateOTK/Legacy/FrameBufferReadPixels.cs 2011-11-21 18:26:57 UTC (rev 1298) +++ trunk/Drivers/AgateOTK/Legacy/FrameBufferReadPixels.cs 2011-11-21 18:27:37 UTC (rev 1299) @@ -1,4 +1,22 @@ -using System; +// The contents of this file are subject to the Mozilla Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.mozilla.org/MPL/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations +// under the License. +// +// The Original Code is AgateLib. +// +// The Initial Developer of the Original Code is Erik Ylvisaker. +// Portions created by Erik Ylvisaker are Copyright (C) 2006-2009. +// All Rights Reserved. +// +// Contributor(s): Erik Ylvisaker +// +using System; using System.Collections.Generic; using System.Linq; using System.Text; Modified: trunk/Drivers/AgateOTK/Legacy/LegacyPrimitiveRenderer.cs =================================================================== --- trunk/Drivers/AgateOTK/Legacy/LegacyPrimitiveRenderer.cs 2011-11-21 18:26:57 UTC (rev 1298) +++ trunk/Drivers/AgateOTK/Legacy/LegacyPrimitiveRenderer.cs 2011-11-21 18:27:37 UTC (rev 1299) @@ -1,4 +1,22 @@ -using System; +// The contents of this file are subject to the Mozilla Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.mozilla.org/MPL/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations +// under the License. +// +// The Original Code is AgateLib. +// +// The Initial Developer of the Original Code is Erik Ylvisaker. +// Portions created by Erik Ylvisaker are Copyright (C) 2006-2009. +// All Rights Reserved. +// +// Contributor(s): Erik Ylvisaker +// +using System; using System.Collections.Generic; using System.Linq; using System.Text; Modified: trunk/Drivers/AgateOTK/Legacy/LegacyVertexBuffer.cs =================================================================== --- trunk/Drivers/AgateOTK/Legacy/LegacyVertexBuffer.cs 2011-11-21 18:26:57 UTC (rev 1298) +++ trunk/Drivers/AgateOTK/Legacy/LegacyVertexBuffer.cs 2011-11-21 18:27:37 UTC (rev 1299) @@ -1,4 +1,22 @@ -using System; +// The contents of this file are subject to the Mozilla Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.mozilla.org/MPL/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations +// under the License. +// +// The Original Code is AgateLib. +// +// The Initial Developer of the Original Code is Erik Ylvisaker. +// Portions created by Erik Ylvisaker are Copyright (C) 2006-2009. +// All Rights Reserved. +// +// Contributor(s): Erik Ylvisaker +// +using System; using System.Collections.Generic; using System.Diagnostics; using System.Runtime.InteropServices; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ka...@us...> - 2011-11-21 18:27:07
|
Revision: 1298 http://agate.svn.sourceforge.net/agate/?rev=1298&view=rev Author: kanato Date: 2011-11-21 18:26:57 +0000 (Mon, 21 Nov 2011) Log Message: ----------- Added copyright information. Modified Paths: -------------- trunk/Drivers/AgateOTK/GL3/FrameBuffer.cs trunk/Drivers/AgateOTK/GL3/GLVertexBuffer.cs Modified: trunk/Drivers/AgateOTK/GL3/FrameBuffer.cs =================================================================== --- trunk/Drivers/AgateOTK/GL3/FrameBuffer.cs 2011-11-21 18:23:35 UTC (rev 1297) +++ trunk/Drivers/AgateOTK/GL3/FrameBuffer.cs 2011-11-21 18:26:57 UTC (rev 1298) @@ -1,4 +1,22 @@ -using System; +// The contents of this file are subject to the Mozilla Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.mozilla.org/MPL/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations +// under the License. +// +// The Original Code is AgateLib. +// +// The Initial Developer of the Original Code is Erik Ylvisaker. +// Portions created by Erik Ylvisaker are Copyright (C) 2006-2009. +// All Rights Reserved. +// +// Contributor(s): Erik Ylvisaker +// +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -31,31 +49,31 @@ // generate the frame buffer GL.GenFramebuffers(1, out mFramebufferID); - GL.BindFramebuffer(FramebufferTarget.FramebufferExt, mFramebufferID); + GL.BindFramebuffer(FramebufferTarget.Framebuffer, mFramebufferID); // generate a depth buffer to render to GL.GenRenderbuffers(1, out mDepthBuffer); - GL.BindRenderbuffer(RenderbufferTarget.RenderbufferExt, mDepthBuffer); + GL.BindRenderbuffer(RenderbufferTarget.Renderbuffer, mDepthBuffer); // hack here because RenderbufferStorage enum is incomplete. - GL.RenderbufferStorage(RenderbufferTarget.RenderbufferExt, + GL.RenderbufferStorage(RenderbufferTarget.Renderbuffer, RenderbufferStorage.Depth24Stencil8, mSize.Width, mSize.Height); // attach the depth buffer - GL.FramebufferRenderbuffer(FramebufferTarget.FramebufferExt, - FramebufferAttachment.DepthAttachmentExt, RenderbufferTarget.RenderbufferExt, + GL.FramebufferRenderbuffer(FramebufferTarget.Framebuffer, + FramebufferAttachment.DepthAttachment, RenderbufferTarget.Renderbuffer, mDepthBuffer); // attach the texture - GL.FramebufferTexture2D(FramebufferTarget.FramebufferExt, - FramebufferAttachment.ColorAttachment0Ext, TextureTarget.Texture2D, + GL.FramebufferTexture2D(FramebufferTarget.Framebuffer, + FramebufferAttachment.ColorAttachment0, TextureTarget.Texture2D, mTexture.GLTextureID, 0); FramebufferErrorCode code = - GL.CheckFramebufferStatus(FramebufferTarget.FramebufferExt); + GL.CheckFramebufferStatus(FramebufferTarget.Framebuffer); - if (code != FramebufferErrorCode.FramebufferCompleteExt) + if (code != FramebufferErrorCode.FramebufferComplete) { throw new AgateException( "Could not complete framebuffer object. Received error code " @@ -82,14 +100,14 @@ public override void BeginRender() { - GL.BindFramebuffer(FramebufferTarget.FramebufferExt, mFramebufferID); + GL.BindFramebuffer(FramebufferTarget.Framebuffer, mFramebufferID); //GL.PushAttrib(AttribMask.ViewportBit); } public override void EndRender() { //GL.PopAttrib(); - GL.BindFramebuffer(FramebufferTarget.FramebufferExt, 0); + GL.BindFramebuffer(FramebufferTarget.Framebuffer, 0); GL.BindTexture(TextureTarget.Texture2D, mTexture.GLTextureID); GL.GenerateMipmap(GenerateMipmapTarget.Texture2D); @@ -97,7 +115,7 @@ public override void MakeCurrent() { - GL.BindFramebuffer(FramebufferTarget.FramebufferExt, mFramebufferID); + GL.BindFramebuffer(FramebufferTarget.Framebuffer, mFramebufferID); } } } Modified: trunk/Drivers/AgateOTK/GL3/GLVertexBuffer.cs =================================================================== --- trunk/Drivers/AgateOTK/GL3/GLVertexBuffer.cs 2011-11-21 18:23:35 UTC (rev 1297) +++ trunk/Drivers/AgateOTK/GL3/GLVertexBuffer.cs 2011-11-21 18:26:57 UTC (rev 1298) @@ -1,4 +1,22 @@ -using System; +// The contents of this file are subject to the Mozilla Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.mozilla.org/MPL/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations +// under the License. +// +// The Original Code is AgateLib. +// +// The Initial Developer of the Original Code is Erik Ylvisaker. +// Portions created by Erik Ylvisaker are Copyright (C) 2006-2009. +// All Rights Reserved. +// +// Contributor(s): Erik Ylvisaker +// +using System; using System.Collections.Generic; using System.Diagnostics; using System.Runtime.InteropServices; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ka...@us...> - 2011-11-21 18:23:41
|
Revision: 1297 http://agate.svn.sourceforge.net/agate/?rev=1297&view=rev Author: kanato Date: 2011-11-21 18:23:35 +0000 (Mon, 21 Nov 2011) Log Message: ----------- Added code to use the ARB framebuffer object, which is just a subset of OpenGL 3. Modified Paths: -------------- trunk/Drivers/AgateOTK/AgateOTK.csproj trunk/Drivers/AgateOTK/GL_Display.cs trunk/Drivers/AgateOTK/GL_GameWindow.cs trunk/Drivers/AgateOTK/Resources/Basic2D_pixel.txt Added Paths: ----------- trunk/Drivers/AgateOTK/Legacy/FrameBufferArb.cs Modified: trunk/Drivers/AgateOTK/AgateOTK.csproj =================================================================== --- trunk/Drivers/AgateOTK/AgateOTK.csproj 2011-11-21 18:22:58 UTC (rev 1296) +++ trunk/Drivers/AgateOTK/AgateOTK.csproj 2011-11-21 18:23:35 UTC (rev 1297) @@ -167,6 +167,7 @@ <Compile Include="GLDrawBuffer.cs"> <SubType>Code</SubType> </Compile> + <Compile Include="Legacy\FrameBufferArb.cs" /> <Compile Include="Legacy\LegacyDrawBuffer.cs" /> <Compile Include="Legacy\LegacyPrimitiveRenderer.cs" /> <Compile Include="PrimitiveRenderer.cs" /> Modified: trunk/Drivers/AgateOTK/GL_Display.cs =================================================================== --- trunk/Drivers/AgateOTK/GL_Display.cs 2011-11-21 18:22:58 UTC (rev 1296) +++ trunk/Drivers/AgateOTK/GL_Display.cs 2011-11-21 18:23:35 UTC (rev 1297) @@ -43,6 +43,7 @@ Stack<Rectangle> mClipRects = new Stack<Rectangle>(); Rectangle mCurrentClip = Rectangle.Empty; private bool mVSync = true; + private bool mSupportsFramebufferArb; private bool mSupportsFramebufferExt; private bool mNonPowerOf2Textures; private bool mSupportsShaders; @@ -147,13 +148,15 @@ { if (mGL3) return new GL3.FrameBuffer(size); + else if (mSupportsFramebufferArb) + return new Legacy.FrameBufferArb(size); else if (mSupportsFramebufferExt) { try { return new Legacy.FrameBufferExt(size); } - catch(Exception e) + catch (Exception e) { Trace.WriteLine(string.Format("Caught exception {0} when trying to create GL_FrameBuffer_Ext wrapper.", e.GetType())); Trace.Indent(); @@ -318,7 +321,6 @@ if (mGLVersion >= 3m) { //mGL3 = true; - mGL3 = false; mGL3 = false; mGLVersion = 2.1m; @@ -326,6 +328,7 @@ LoadExtensions(); + mSupportsFramebufferArb = SupportsExtension("GL_ARB_FRAMEBUFFER_OBJECT"); mSupportsFramebufferExt = SupportsExtension("GL_EXT_FRAMEBUFFER_OBJECT"); mNonPowerOf2Textures = SupportsExtension("GL_ARB_NON_POWER_OF_TWO"); Modified: trunk/Drivers/AgateOTK/GL_GameWindow.cs =================================================================== --- trunk/Drivers/AgateOTK/GL_GameWindow.cs 2011-11-21 18:22:58 UTC (rev 1296) +++ trunk/Drivers/AgateOTK/GL_GameWindow.cs 2011-11-21 18:23:35 UTC (rev 1297) @@ -37,6 +37,8 @@ /// </summary> class GL_GameWindow : DisplayWindowImpl { + #region --- Static Members --- + static Dictionary<OpenTK.Input.Key, KeyCode> keyMap = new Dictionary<OpenTK.Input.Key, KeyCode>(); static GL_GameWindow() @@ -164,6 +166,8 @@ } + #endregion + GL_Display mDisplay; System.Drawing.Icon mIcon; GameWindow mWindow; Copied: trunk/Drivers/AgateOTK/Legacy/FrameBufferArb.cs (from rev 1283, trunk/Drivers/AgateOTK/GL3/FrameBuffer.cs) =================================================================== --- trunk/Drivers/AgateOTK/Legacy/FrameBufferArb.cs (rev 0) +++ trunk/Drivers/AgateOTK/Legacy/FrameBufferArb.cs 2011-11-21 18:23:35 UTC (rev 1297) @@ -0,0 +1,103 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using AgateLib; +using AgateLib.DisplayLib.ImplementationBase; +using AgateLib.Geometry; +using OpenTK.Graphics.OpenGL; +using OTKPixelFormat = OpenTK.Graphics.OpenGL.PixelFormat; + +namespace AgateOTK.Legacy +{ + /// <summary> + /// Framebuffer using ARB extension. + /// </summary> + class FrameBufferArb : GL_FrameBuffer + { + Size mSize; + int mFramebufferID; + int mDepthBuffer; + GL_Surface mTexture; + + public FrameBufferArb(Size size) + { + mSize = size; + + //AgateLib.DisplayLib.PixelBuffer pixels = new AgateLib.DisplayLib.PixelBuffer( + // AgateLib.DisplayLib.PixelFormat.RGBA8888, mSize); + + mTexture = new GL_Surface(mSize); + + // generate the frame buffer + GL.GenFramebuffers(1, out mFramebufferID); + GL.BindFramebuffer(FramebufferTarget.FramebufferExt, mFramebufferID); + + // generate a depth buffer to render to + GL.GenRenderbuffers(1, out mDepthBuffer); + GL.BindRenderbuffer(RenderbufferTarget.RenderbufferExt, mDepthBuffer); + + // hack here because RenderbufferStorage enum is incomplete. + GL.RenderbufferStorage(RenderbufferTarget.RenderbufferExt, + RenderbufferStorage.Depth24Stencil8, + mSize.Width, mSize.Height); + + // attach the depth buffer + GL.FramebufferRenderbuffer(FramebufferTarget.FramebufferExt, + FramebufferAttachment.DepthAttachmentExt, RenderbufferTarget.RenderbufferExt, + mDepthBuffer); + + // attach the texture + GL.FramebufferTexture2D(FramebufferTarget.FramebufferExt, + FramebufferAttachment.ColorAttachment0Ext, TextureTarget.Texture2D, + mTexture.GLTextureID, 0); + + FramebufferErrorCode code = + GL.CheckFramebufferStatus(FramebufferTarget.FramebufferExt); + + if (code != FramebufferErrorCode.FramebufferCompleteExt) + { + throw new AgateException( + "Could not complete framebuffer object. Received error code " + + code.ToString()); + } + + mHasDepth = true; + mHasStencil = true; + } + + public override SurfaceImpl RenderTarget + { + get { return mTexture; } + } + public override void Dispose() + { + throw new NotImplementedException(); + } + + public override AgateLib.Geometry.Size Size + { + get { return mSize; } + } + + public override void BeginRender() + { + GL.BindFramebuffer(FramebufferTarget.FramebufferExt, mFramebufferID); + //GL.PushAttrib(AttribMask.ViewportBit); + } + + public override void EndRender() + { + //GL.PopAttrib(); + GL.BindFramebuffer(FramebufferTarget.FramebufferExt, 0); + + GL.BindTexture(TextureTarget.Texture2D, mTexture.GLTextureID); + GL.GenerateMipmap(GenerateMipmapTarget.Texture2D); + } + + public override void MakeCurrent() + { + GL.BindFramebuffer(FramebufferTarget.FramebufferExt, mFramebufferID); + } + } +} Modified: trunk/Drivers/AgateOTK/Resources/Basic2D_pixel.txt =================================================================== --- trunk/Drivers/AgateOTK/Resources/Basic2D_pixel.txt 2011-11-21 18:22:58 UTC (rev 1296) +++ trunk/Drivers/AgateOTK/Resources/Basic2D_pixel.txt 2011-11-21 18:23:35 UTC (rev 1297) @@ -9,5 +9,6 @@ void main() { - color = texture2D(texture, texCoordVal); + color = texture2D(texture, texCoordVal); + color = color * colorVal; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ka...@us...> - 2011-11-21 18:23:08
|
Revision: 1296 http://agate.svn.sourceforge.net/agate/?rev=1296&view=rev Author: kanato Date: 2011-11-21 18:22:58 +0000 (Mon, 21 Nov 2011) Log Message: ----------- Remove obsolete types in GL3/DrawBuffer.cs. Removed obsolete call to PushAttrib. Updated some primitive renderings. Modified Paths: -------------- trunk/Drivers/AgateOTK/GL3/DrawBuffer.cs trunk/Drivers/AgateOTK/GL3/FrameBuffer.cs trunk/Drivers/AgateOTK/GL3/GLPrimitiveRenderer.cs Modified: trunk/Drivers/AgateOTK/GL3/DrawBuffer.cs =================================================================== --- trunk/Drivers/AgateOTK/GL3/DrawBuffer.cs 2011-10-26 04:03:11 UTC (rev 1295) +++ trunk/Drivers/AgateOTK/GL3/DrawBuffer.cs 2011-11-21 18:22:58 UTC (rev 1296) @@ -38,52 +38,6 @@ /// </summary> public class DrawBuffer : GLDrawBuffer { - #region --- Private types for Vertex Arrays --- - - [StructLayout(LayoutKind.Sequential)] - private struct TexCoord - { - public float u; - public float v; - } - [StructLayout(LayoutKind.Sequential)] - private struct VertexCoord - { - public float x; - public float y; - } - [StructLayout(LayoutKind.Sequential)] - private struct ColorCoord - { - public float r; - public float g; - public float b; - public float a; - - public ColorCoord(Color clr) - { - r = clr.R / 255.0f; - g = clr.G / 255.0f; - b = clr.B / 255.0f; - a = clr.A / 255.0f; - } - } - [StructLayout(LayoutKind.Sequential)] - private struct NormalCoord - { - public float x; - public float y; - public float z; - - public NormalCoord(float x, float y, float z) - { - this.x = x; - this.y = y; - this.z = z; - } - } - #endregion - PositionTextureColor[] mVerts; int mIndex; Modified: trunk/Drivers/AgateOTK/GL3/FrameBuffer.cs =================================================================== --- trunk/Drivers/AgateOTK/GL3/FrameBuffer.cs 2011-10-26 04:03:11 UTC (rev 1295) +++ trunk/Drivers/AgateOTK/GL3/FrameBuffer.cs 2011-11-21 18:22:58 UTC (rev 1296) @@ -83,12 +83,12 @@ public override void BeginRender() { GL.BindFramebuffer(FramebufferTarget.FramebufferExt, mFramebufferID); - GL.PushAttrib(AttribMask.ViewportBit); + //GL.PushAttrib(AttribMask.ViewportBit); } public override void EndRender() { - GL.PopAttrib(); + //GL.PopAttrib(); GL.BindFramebuffer(FramebufferTarget.FramebufferExt, 0); GL.BindTexture(TextureTarget.Texture2D, mTexture.GLTextureID); Modified: trunk/Drivers/AgateOTK/GL3/GLPrimitiveRenderer.cs =================================================================== --- trunk/Drivers/AgateOTK/GL3/GLPrimitiveRenderer.cs 2011-10-26 04:03:11 UTC (rev 1295) +++ trunk/Drivers/AgateOTK/GL3/GLPrimitiveRenderer.cs 2011-11-21 18:22:58 UTC (rev 1296) @@ -1,8 +1,31 @@ -using System; +// The contents of this file are subject to the Mozilla Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.mozilla.org/MPL/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations +// under the License. +// +// The Original Code is AgateLib. +// +// The Initial Developer of the Original Code is Erik Ylvisaker. +// Portions created by Erik Ylvisaker are Copyright (C) 2006-2009. +// All Rights Reserved. +// +// Contributor(s): Erik Ylvisaker +// +using System; using System.Collections.Generic; +using System.Diagnostics; using System.Linq; +using System.Runtime; +using System.Runtime.InteropServices; using System.Text; +using AgateLib.DisplayLib; using AgateLib.Geometry; +using AgateLib.Geometry.VertexTypes; using OpenTK.Graphics.OpenGL; namespace AgateOTK.GL3 @@ -13,6 +36,19 @@ /// </summary> class GLPrimitiveRenderer : PrimitiveRenderer { + PositionColor[] mVerts = new PositionColor[6]; + + int mBufferID; + int mVaoID; + + public GLPrimitiveRenderer() + { + GL.GenBuffers(1, out mBufferID); + GL.GenVertexArrays(1, out mVaoID); + + Debug.Print("GL3 PrimitiveRenderer: Draw buffer ID: {0}", mBufferID); + } + public void SetGLColor(Color color) { GL.Color4(color.R / 255.0f, color.G / 255.0f, color.B / 255.0f, color.A / 255.0f); @@ -20,17 +56,58 @@ public override void DrawLine(Point a, Point b, Color color) { - SetGLColor(color); + mVerts[0].Position.X = a.X; + mVerts[0].Position.Y = a.Y; + mVerts[0].Color = color.ToArgb(); - GL.Disable(EnableCap.Texture2D); - GL.Begin(BeginMode.Lines); - GL.Vertex2(a.X, a.Y); - GL.Vertex2(b.X, b.Y); + mVerts[1].Position.X = b.X; + mVerts[1].Position.Y = b.Y; + mVerts[1].Color = color.ToArgb(); - GL.End(); - GL.Enable(EnableCap.Texture2D); + BufferData(); + + GL_Display display = (GL_Display)Display.Impl; + Shaders.IGL3Shader shader = (Shaders.IGL3Shader)display.Shader.Impl; + + shader.SetVertexAttributes(PositionColor.VertexLayout); + + GL.ActiveTexture(TextureUnit.Texture0); + GL.BindTexture(TextureTarget.Texture2D, 0); + shader.SetTexture(0); + + GL.DrawArrays(BeginMode.Lines, 0, 1); + } + private void BufferData() + { + GL.BindVertexArray(mVaoID); + + int bufferSize = mVerts.Length * Marshal.SizeOf(typeof(PositionColor)); + + GL.BindBuffer(BufferTarget.ArrayBuffer, mBufferID); + + unsafe + { + GCHandle handle = new GCHandle(); + + try + { + handle = GCHandle.Alloc(mVerts, GCHandleType.Pinned); + + IntPtr ptr = handle.AddrOfPinnedObject(); + + GL.BufferData(BufferTarget.ArrayBuffer, + (IntPtr)bufferSize, ptr, + BufferUsageHint.StaticDraw); + } + finally + { + handle.Free(); + } + } + } + public override void DrawRect(RectangleF rect, Color color) { SetGLColor(color); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ka...@us...> - 2011-10-26 04:03:18
|
Revision: 1295 http://agate.svn.sourceforge.net/agate/?rev=1295&view=rev Author: kanato Date: 2011-10-26 04:03:11 +0000 (Wed, 26 Oct 2011) Log Message: ----------- Implement POV hats for joysticks with support from AgateSDL. Modified Paths: -------------- trunk/AgateLib/AgateLib.csproj trunk/AgateLib/AgateSetup.cs trunk/AgateLib/InputLib/ImplementationBase/JoystickImpl.cs trunk/AgateLib/InputLib/Joystick.cs trunk/ChangeLog.txt trunk/Drivers/AgateSDL/Input/SDL_Input.cs trunk/Drivers/AgateSDL/SDL.dll trunk/Drivers/AgateSDL/Tao.Sdl/Sdl.cs trunk/Drivers/AgateSDX/SDX_Input.cs trunk/TODO.txt trunk/Tests/InputTests/Input/InputTester.cs trunk/Tests/InputTests/Input/frmInputTester.Designer.cs trunk/Tests/InputTests/Input/frmInputTester.cs trunk/Tests/InputTests/Input/frmInputTester.resx Added Paths: ----------- trunk/AgateLib/InputLib/HatState.cs Modified: trunk/AgateLib/AgateLib.csproj =================================================================== --- trunk/AgateLib/AgateLib.csproj 2011-10-26 02:52:06 UTC (rev 1294) +++ trunk/AgateLib/AgateLib.csproj 2011-10-26 04:03:11 UTC (rev 1295) @@ -172,6 +172,7 @@ <SubType>Code</SubType> </Compile> <Compile Include="DisplayLib\ImplementationBase\FrameBufferImpl.cs" /> + <Compile Include="InputLib\HatState.cs" /> <Compile Include="Platform.cs" /> <Compile Include="PlatformType.cs" /> <Compile Include="Resources\ImageResource.cs" /> Modified: trunk/AgateLib/AgateSetup.cs =================================================================== --- trunk/AgateLib/AgateSetup.cs 2011-10-26 02:52:06 UTC (rev 1294) +++ trunk/AgateLib/AgateSetup.cs 2011-10-26 04:03:11 UTC (rev 1295) @@ -330,6 +330,8 @@ /// </summary> private void DoAskUser() { + Core.Initialize(); + if (mAlreadyAsked) return; if (mAskUser == false) Added: trunk/AgateLib/InputLib/HatState.cs =================================================================== --- trunk/AgateLib/InputLib/HatState.cs (rev 0) +++ trunk/AgateLib/InputLib/HatState.cs 2011-10-26 04:03:11 UTC (rev 1295) @@ -0,0 +1,50 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace AgateLib.InputLib +{ + /// <summary> + /// An enum containing the possible states of a POV hat on a joystick. + /// </summary> + public enum HatState + { + /// <summary> + /// A value indicating the POV hat is not depressed. + /// </summary> + None, + /// <summary> + /// A value indicating the POV hat is pressed to the right. + /// </summary> + Right, + /// <summary> + /// A value indicating the POV hat is pressed to the upper right. + /// </summary> + UpRight, + /// <summary> + /// A value indicating the POV hat is pressed upwards. + /// </summary> + Up, + /// <summary> + /// A value indicating the POV hat is pressed up left. + /// </summary> + UpLeft, + /// <summary> + /// A value indicating the POV hat is pressed to the left. + /// </summary> + Left, + /// <summary> + /// A value indicating the POV hat is pressed down left. + /// </summary> + DownLeft, + /// <summary> + /// A value indicating the POV hat is pressed downwards. + /// </summary> + Down, + /// <summary> + /// A value indicating the POV hat is pressed down-right. + /// </summary> + DownRight, + } +} Modified: trunk/AgateLib/InputLib/ImplementationBase/JoystickImpl.cs =================================================================== --- trunk/AgateLib/InputLib/ImplementationBase/JoystickImpl.cs 2011-10-26 02:52:06 UTC (rev 1294) +++ trunk/AgateLib/InputLib/ImplementationBase/JoystickImpl.cs 2011-10-26 04:03:11 UTC (rev 1295) @@ -35,6 +35,10 @@ /// Gets how many buttons are on this joystick. /// </summary> public abstract int ButtonCount { get; } + /// <summary> + /// Gets how many POV hats are on this joystick. + /// </summary> + public abstract int HatCount { get; } /// <summary> /// Gets the reported name of the joystick. @@ -57,6 +61,13 @@ /// <param name="axisIndex"></param> /// <returns></returns> public abstract double GetAxisValue(int axisIndex); + + /// <summary> + /// Gets the state of the specified POV hat. + /// </summary> + /// <param name="hatIndex"></param> + /// <returns></returns> + public abstract HatState GetHatState(int hatIndex); /// <summary> /// Recalibrates the joystick. @@ -73,9 +84,11 @@ /// </summary> public abstract bool PluggedIn { get; } + /// <summary> /// Polls the joystick for input. /// </summary> public abstract void Poll(); + } } \ No newline at end of file Modified: trunk/AgateLib/InputLib/Joystick.cs =================================================================== --- trunk/AgateLib/InputLib/Joystick.cs 2011-10-26 02:52:06 UTC (rev 1294) +++ trunk/AgateLib/InputLib/Joystick.cs 2011-10-26 04:03:11 UTC (rev 1295) @@ -19,6 +19,7 @@ using System; using System.Collections.Generic; using System.Text; +using AgateLib.Geometry; using AgateLib.InputLib.ImplementationBase; namespace AgateLib.InputLib @@ -50,8 +51,21 @@ /// Returns the number of buttons this joystick has. /// </summary> public int ButtonCount { get { return impl.ButtonCount; } } + /// <summary> + /// Returns the number of POV hats this joystick has. + /// </summary> + public int HatCount { get { return impl.HatCount; } } /// <summary> + /// Gets the state of the specified POV hat. + /// </summary> + /// <param name="hatIndex"></param> + /// <returns></returns> + public HatState GetHatState(int hatIndex) + { + return impl.GetHatState(hatIndex); + } + /// <summary> /// Gets the current value for the given axis. /// Axis 0 is always the x-axis, axis 1 is always the y-axis on /// controlers which have this capability. Modified: trunk/ChangeLog.txt =================================================================== --- trunk/ChangeLog.txt 2011-10-26 02:52:06 UTC (rev 1294) +++ trunk/ChangeLog.txt 2011-10-26 04:03:11 UTC (rev 1295) @@ -1,4 +1,9 @@ +Current +=================== + +POV hat support for joysticks has been added. + Version 0.3.2 =================== Even though the version number has only been incremented slightly, there are a lot of changes in Modified: trunk/Drivers/AgateSDL/Input/SDL_Input.cs =================================================================== --- trunk/Drivers/AgateSDL/Input/SDL_Input.cs 2011-10-26 02:52:06 UTC (rev 1294) +++ trunk/Drivers/AgateSDL/Input/SDL_Input.cs 2011-10-26 04:03:11 UTC (rev 1295) @@ -49,16 +49,16 @@ public override void Initialize() { - if (Tao.Sdl.Sdl.SDL_InitSubSystem(Tao.Sdl.Sdl.SDL_INIT_JOYSTICK) != 0) + // apparently initializing the video has some side-effect + // that is required for joysticks to work on windows (at least). + if (Tao.Sdl.Sdl.SDL_InitSubSystem(Tao.Sdl.Sdl.SDL_INIT_JOYSTICK | Tao.Sdl.Sdl.SDL_INIT_VIDEO) != 0) { throw new AgateLib.AgateException("Failed to initialize SDL joysticks."); } - // apparently initializing the video has some side-effect - // that is required for joysticks to work on windows (at least). - Tao.Sdl.Sdl.SDL_InitSubSystem(Tao.Sdl.Sdl.SDL_INIT_VIDEO); + Tao.Sdl.Sdl.SDL_version version = Tao.Sdl.Sdl.SDL_VERSION(); - Report("SDL driver instantiated for joystick input."); + Report("SDL driver version " + version.ToString() + " instantiated for joystick input."); } } @@ -79,13 +79,22 @@ public override string Name { - get { return Tao.Sdl.Sdl.SDL_JoystickName(joystickIndex); } + get + { + string retval = Tao.Sdl.Sdl.SDL_JoystickName(joystickIndex); + + return retval; + } } public override int AxisCount { get { return Tao.Sdl.Sdl.SDL_JoystickNumAxes(joystick); } } + public override int HatCount + { + get { return Tao.Sdl.Sdl.SDL_JoystickNumHats(joystick); } + } public override double AxisThreshold { @@ -108,7 +117,24 @@ { return buttons[buttonIndex]; } + public override AgateLib.InputLib.HatState GetHatState(int hatIndex) + { + switch(Tao.Sdl.Sdl.SDL_JoystickGetHat(joystick, hatIndex)) + { + case Tao.Sdl.Sdl.SDL_HAT_RIGHTUP: return AgateLib.InputLib.HatState.UpRight; + case Tao.Sdl.Sdl.SDL_HAT_RIGHT: return AgateLib.InputLib.HatState.Right; + case Tao.Sdl.Sdl.SDL_HAT_RIGHTDOWN: return AgateLib.InputLib.HatState.DownRight; + case Tao.Sdl.Sdl.SDL_HAT_LEFTUP: return AgateLib.InputLib.HatState.UpLeft; + case Tao.Sdl.Sdl.SDL_HAT_LEFT: return AgateLib.InputLib.HatState.Left; + case Tao.Sdl.Sdl.SDL_HAT_LEFTDOWN: return AgateLib.InputLib.HatState.DownLeft; + case Tao.Sdl.Sdl.SDL_HAT_DOWN: return AgateLib.InputLib.HatState.Down; + case Tao.Sdl.Sdl.SDL_HAT_UP: return AgateLib.InputLib.HatState.Up; + case Tao.Sdl.Sdl.SDL_HAT_CENTERED: + default: + return AgateLib.InputLib.HatState.None; + } + } public override double GetAxisValue(int axisIndex) { // Convert joystick coordinate to the agatelib coordinate system of -1..1. Modified: trunk/Drivers/AgateSDL/SDL.dll =================================================================== (Binary files differ) Modified: trunk/Drivers/AgateSDL/Tao.Sdl/Sdl.cs =================================================================== --- trunk/Drivers/AgateSDL/Tao.Sdl/Sdl.cs 2011-10-26 02:52:06 UTC (rev 1294) +++ trunk/Drivers/AgateSDL/Tao.Sdl/Sdl.cs 2011-10-26 04:03:11 UTC (rev 1295) @@ -7893,7 +7893,7 @@ /// <seealso cref="SDL_JoystickOpen"/> public static string SDL_JoystickName(int device_index) { - return Marshal.PtrToStringAuto(__SDL_JoystickName(device_index)); + return Marshal.PtrToStringAnsi(__SDL_JoystickName(device_index)); } [DllImport(SDL_NATIVE_LIBRARY, CallingConvention = CALLING_CONVENTION, EntryPoint = "SDL_JoystickName"), Modified: trunk/Drivers/AgateSDX/SDX_Input.cs =================================================================== --- trunk/Drivers/AgateSDX/SDX_Input.cs 2011-10-26 02:52:06 UTC (rev 1294) +++ trunk/Drivers/AgateSDX/SDX_Input.cs 2011-10-26 04:03:11 UTC (rev 1295) @@ -126,6 +126,10 @@ { get { return mDevice.Capabilities.ButtonCount; } } + public override int HatCount + { + get { return mDevice.Capabilities.PovCount; } + } public override bool GetButtonState(int buttonIndex) { @@ -160,6 +164,12 @@ // return mDevice.GetCurrentState().GetSliders()[axisIndex - 4] / maxX; } + public override AgateLib.InputLib.HatState GetHatState(int hatIndex) + { + int value = mDevice.GetCurrentState().GetPointOfViewControllers()[hatIndex]; + + return (AgateLib.InputLib.HatState)value; + } private double CorrectAxisValue(int axisValue, int shiftValue, double maxX) { double retval = (axisValue - shiftValue) / (double)maxX; Modified: trunk/TODO.txt =================================================================== --- trunk/TODO.txt 2011-10-26 02:52:06 UTC (rev 1294) +++ trunk/TODO.txt 2011-10-26 04:03:11 UTC (rev 1295) @@ -28,7 +28,7 @@ * Test ClipRects with AgateOTK * Test / Debug writing pixel buffer to SDX surface. Input - * Add support for POV hats on joysticks. + D Add support for POV hats on joysticks. Goals for 0.3.5 --------------------------------------------------- Modified: trunk/Tests/InputTests/Input/InputTester.cs =================================================================== --- trunk/Tests/InputTests/Input/InputTester.cs 2011-10-26 02:52:06 UTC (rev 1294) +++ trunk/Tests/InputTests/Input/InputTester.cs 2011-10-26 04:03:11 UTC (rev 1295) @@ -26,7 +26,7 @@ if (setup.WasCanceled) return; - new Form1().ShowDialog(); + new frmInputTester().ShowDialog(); } } } Modified: trunk/Tests/InputTests/Input/frmInputTester.Designer.cs =================================================================== --- trunk/Tests/InputTests/Input/frmInputTester.Designer.cs 2011-10-26 02:52:06 UTC (rev 1294) +++ trunk/Tests/InputTests/Input/frmInputTester.Designer.cs 2011-10-26 04:03:11 UTC (rev 1295) @@ -3,7 +3,7 @@ // namespace Tests.InputTester { - partial class Form1 + partial class frmInputTester { /// <summary> /// Required designer variable. @@ -31,17 +31,19 @@ /// </summary> private void InitializeComponent() { + this.components = new System.ComponentModel.Container(); this.lblKeyPress = new System.Windows.Forms.Label(); this.lblMouseMove = new System.Windows.Forms.Label(); this.lblMouseButton = new System.Windows.Forms.Label(); this.lblKeyEvent = new System.Windows.Forms.Label(); this.lblKeyString = new System.Windows.Forms.Label(); - this.numericUpDown1 = new System.Windows.Forms.NumericUpDown(); - this.label1 = new System.Windows.Forms.Label(); - this.lblJoystick = new System.Windows.Forms.Label(); + this.lblJoystick1 = new System.Windows.Forms.Label(); this.button1 = new System.Windows.Forms.Button(); + this.timer1 = new System.Windows.Forms.Timer(this.components); this.agateRenderTarget1 = new AgateLib.WinForms.AgateRenderTarget(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit(); + this.lblJoystick2 = new System.Windows.Forms.Label(); + this.lblJoystick3 = new System.Windows.Forms.Label(); + this.lblJoystick4 = new System.Windows.Forms.Label(); this.SuspendLayout(); // // lblKeyPress @@ -86,32 +88,15 @@ this.lblKeyString.TabIndex = 5; this.lblKeyString.Text = "Pressed Key String []"; // - // numericUpDown1 + // lblJoystick1 // - this.numericUpDown1.Location = new System.Drawing.Point(297, 109); - this.numericUpDown1.Name = "numericUpDown1"; - this.numericUpDown1.Size = new System.Drawing.Size(79, 20); - this.numericUpDown1.TabIndex = 6; - this.numericUpDown1.ValueChanged += new System.EventHandler(this.numericUpDown1_ValueChanged); + this.lblJoystick1.AutoSize = true; + this.lblJoystick1.Location = new System.Drawing.Point(246, 111); + this.lblJoystick1.Name = "lblJoystick1"; + this.lblJoystick1.Size = new System.Drawing.Size(66, 13); + this.lblJoystick1.TabIndex = 8; + this.lblJoystick1.Text = "Joystick Info"; // - // label1 - // - this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(246, 111); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(45, 13); - this.label1.TabIndex = 7; - this.label1.Text = "Joystick"; - // - // lblJoystick - // - this.lblJoystick.AutoSize = true; - this.lblJoystick.Location = new System.Drawing.Point(246, 142); - this.lblJoystick.Name = "lblJoystick"; - this.lblJoystick.Size = new System.Drawing.Size(66, 13); - this.lblJoystick.TabIndex = 8; - this.lblJoystick.Text = "Joystick Info"; - // // button1 // this.button1.Location = new System.Drawing.Point(249, 80); @@ -122,32 +107,65 @@ this.button1.UseVisualStyleBackColor = true; this.button1.Click += new System.EventHandler(this.button1_Click); // + // timer1 + // + this.timer1.Enabled = true; + this.timer1.Interval = 20; + this.timer1.Tick += new System.EventHandler(this.timer1_Tick); + // // agateRenderTarget1 // this.agateRenderTarget1.Location = new System.Drawing.Point(12, 111); this.agateRenderTarget1.Name = "agateRenderTarget1"; - this.agateRenderTarget1.Size = new System.Drawing.Size(200, 180); + this.agateRenderTarget1.Size = new System.Drawing.Size(200, 200); this.agateRenderTarget1.TabIndex = 10; // - // Form1 + // lblJoystick2 // + this.lblJoystick2.AutoSize = true; + this.lblJoystick2.Location = new System.Drawing.Point(366, 111); + this.lblJoystick2.Name = "lblJoystick2"; + this.lblJoystick2.Size = new System.Drawing.Size(66, 13); + this.lblJoystick2.TabIndex = 11; + this.lblJoystick2.Text = "Joystick Info"; + // + // lblJoystick3 + // + this.lblJoystick3.AutoSize = true; + this.lblJoystick3.Location = new System.Drawing.Point(478, 111); + this.lblJoystick3.Name = "lblJoystick3"; + this.lblJoystick3.Size = new System.Drawing.Size(66, 13); + this.lblJoystick3.TabIndex = 12; + this.lblJoystick3.Text = "Joystick Info"; + // + // lblJoystick4 + // + this.lblJoystick4.AutoSize = true; + this.lblJoystick4.Location = new System.Drawing.Point(581, 111); + this.lblJoystick4.Name = "lblJoystick4"; + this.lblJoystick4.Size = new System.Drawing.Size(66, 13); + this.lblJoystick4.TabIndex = 13; + this.lblJoystick4.Text = "Joystick Info"; + // + // frmInputTester + // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(382, 303); + this.ClientSize = new System.Drawing.Size(659, 326); + this.Controls.Add(this.lblJoystick4); + this.Controls.Add(this.lblJoystick3); + this.Controls.Add(this.lblJoystick2); this.Controls.Add(this.agateRenderTarget1); this.Controls.Add(this.button1); - this.Controls.Add(this.lblJoystick); - this.Controls.Add(this.label1); - this.Controls.Add(this.numericUpDown1); + this.Controls.Add(this.lblJoystick1); this.Controls.Add(this.lblKeyString); this.Controls.Add(this.lblKeyEvent); this.Controls.Add(this.lblMouseButton); this.Controls.Add(this.lblMouseMove); this.Controls.Add(this.lblKeyPress); - this.Name = "Form1"; - this.Text = "Form1"; + this.Name = "frmInputTester"; + this.Text = "Input Tester"; this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.Form1_KeyDown); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); @@ -160,11 +178,13 @@ private System.Windows.Forms.Label lblMouseButton; private System.Windows.Forms.Label lblKeyEvent; private System.Windows.Forms.Label lblKeyString; - private System.Windows.Forms.NumericUpDown numericUpDown1; - private System.Windows.Forms.Label label1; - private System.Windows.Forms.Label lblJoystick; + private System.Windows.Forms.Label lblJoystick1; private System.Windows.Forms.Button button1; private AgateLib.WinForms.AgateRenderTarget agateRenderTarget1; + private System.Windows.Forms.Timer timer1; + private System.Windows.Forms.Label lblJoystick2; + private System.Windows.Forms.Label lblJoystick3; + private System.Windows.Forms.Label lblJoystick4; } } Modified: trunk/Tests/InputTests/Input/frmInputTester.cs =================================================================== --- trunk/Tests/InputTests/Input/frmInputTester.cs 2011-10-26 02:52:06 UTC (rev 1294) +++ trunk/Tests/InputTests/Input/frmInputTester.cs 2011-10-26 04:03:11 UTC (rev 1295) @@ -15,10 +15,11 @@ namespace Tests.InputTester { - public partial class Form1 : Form + public partial class frmInputTester : Form { + private Label[] joystickLabels = new Label[4]; - public Form1() + public frmInputTester() { InitializeComponent(); @@ -33,51 +34,76 @@ new DisplayWindow(CreateWindowParams.FromControl(agateRenderTarget1)); - Application.Idle += new EventHandler(Application_Idle); + joystickLabels[0] = lblJoystick1; + joystickLabels[1] = lblJoystick2; + joystickLabels[2] = lblJoystick3; + joystickLabels[3] = lblJoystick4; + } + private void timer1_Tick(object sender, EventArgs e) + { + Application_Idle(sender, e); + } void Application_Idle(object sender, EventArgs e) { - numericUpDown1.Maximum = JoystickInput.Joysticks.Count - 1; - if (JoystickInput.Joysticks.Count > 0) + for (int i = 0; i < JoystickInput.Joysticks.Count; i++ ) { - Joystick j = JoystickInput.Joysticks[(int)numericUpDown1.Value]; + FillJoystickInfo(i, joystickLabels[i]); + } + + Core.KeepAlive(); + } - StringBuilder b = new StringBuilder(); - b.AppendLine(j.Name); - b.Append("Axis Count: "); - b.AppendLine(j.AxisCount.ToString()); + private void FillJoystickInfo(int index, Label label) + { + Joystick j = JoystickInput.Joysticks[index]; - for (int i = 0; i < j.AxisCount; i++) - { - b.Append("Axis "); - b.Append(i.ToString()); - b.Append(": "); - b.Append(j.GetAxisValue(i).ToString()); - b.AppendLine(); - } + StringBuilder b = new StringBuilder(); + b.Append("Joystick "); + b.AppendLine(index.ToString()); + b.AppendLine(j.Name); + b.Append("Axis Count: "); + b.AppendLine(j.AxisCount.ToString()); + for (int i = 0; i < j.AxisCount; i++) + { + b.Append("Axis "); + b.Append(i.ToString()); + b.Append(": "); + b.Append(j.GetAxisValue(i).ToString()); b.AppendLine(); + } - b.Append("X: "); - b.AppendLine(j.Xaxis.ToString()); - b.Append("Y: "); - b.AppendLine(j.Yaxis.ToString()); - b.AppendLine(); + b.AppendLine(); - b.Append("Buttons: "); + b.Append("X: "); + b.AppendLine(j.Xaxis.ToString()); + b.Append("Y: "); + b.AppendLine(j.Yaxis.ToString()); + b.AppendLine(); - for (int i = 0; i < j.ButtonCount; i++) - { - if (j.GetButtonState(i)) - b.Append(i.ToString()); - } + b.Append("Buttons: "); + for (int i = 0; i < j.ButtonCount; i++) + { + if (j.GetButtonState(i)) + b.Append(i.ToString()); + } - lblJoystick.Text = b.ToString(); + b.AppendLine(); + b.Append("Hats:"); + + for (int i = 0; i < j.HatCount; i++) + { + b.Append(" "); + b.Append(i.ToString()); + b.Append(": "); + b.Append(j.GetHatState(i).ToString()); + b.AppendLine(); } - Core.KeepAlive(); + label.Text = b.ToString(); } void Mouse_MouseDoubleClickEvent(InputEventArgs e) @@ -134,5 +160,6 @@ { } + } } \ No newline at end of file Modified: trunk/Tests/InputTests/Input/frmInputTester.resx =================================================================== --- trunk/Tests/InputTests/Input/frmInputTester.resx 2011-10-26 02:52:06 UTC (rev 1294) +++ trunk/Tests/InputTests/Input/frmInputTester.resx 2011-10-26 04:03:11 UTC (rev 1295) @@ -117,4 +117,7 @@ <resheader name="writer"> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> </resheader> + <metadata name="timer1.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...> - 2011-10-26 02:52:12
|
Revision: 1294 http://agate.svn.sourceforge.net/agate/?rev=1294&view=rev Author: kanato Date: 2011-10-26 02:52:06 +0000 (Wed, 26 Oct 2011) Log Message: ----------- Added check for null with bool value. Modified Paths: -------------- trunk/Tools/DatabaseEditor/TableEditor.cs Modified: trunk/Tools/DatabaseEditor/TableEditor.cs =================================================================== --- trunk/Tools/DatabaseEditor/TableEditor.cs 2011-10-26 02:51:45 UTC (rev 1293) +++ trunk/Tools/DatabaseEditor/TableEditor.cs 2011-10-26 02:52:06 UTC (rev 1294) @@ -177,7 +177,10 @@ if (mTable.Columns[ColumnName(e.ColumnIndex)].FieldType == FieldType.Boolean) { - e.Value = bool.Parse(value); + if (value == null) + e.Value = false; + else + e.Value = bool.Parse(value); } else { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ka...@us...> - 2011-10-26 02:51:51
|
Revision: 1293 http://agate.svn.sourceforge.net/agate/?rev=1293&view=rev Author: kanato Date: 2011-10-26 02:51:45 +0000 (Wed, 26 Oct 2011) Log Message: ----------- Added method for serializing string array. Modified Paths: -------------- trunk/AgateLib/Serialization/Xle/XleSerializationInfo.cs Modified: trunk/AgateLib/Serialization/Xle/XleSerializationInfo.cs =================================================================== --- trunk/AgateLib/Serialization/Xle/XleSerializationInfo.cs 2011-10-17 18:19:46 UTC (rev 1292) +++ trunk/AgateLib/Serialization/Xle/XleSerializationInfo.cs 2011-10-26 02:51:45 UTC (rev 1293) @@ -20,6 +20,7 @@ using System.Collections.Generic; using System.IO; using System.IO.Compression; +using System.Linq; using System.Text; using System.Xml; using System.Runtime.InteropServices; @@ -482,6 +483,15 @@ nodes.Pop(); } /// <summary> + /// Writes an array of strings to the XML data as an element. + /// </summary> + /// <param name="name">The name of the XML element used.</param> + /// <param name="value">The array data to write.</param> + public void Write(string name, string[] value) + { + Write(name, value.ToList()); + } + /// <summary> /// Writes a List<T> of strings to the XML data as an element. /// </summary> /// <param name="name">The name of the XML element used.</param> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ka...@us...> - 2011-10-17 18:19:52
|
Revision: 1292 http://agate.svn.sourceforge.net/agate/?rev=1292&view=rev Author: kanato Date: 2011-10-17 18:19:46 +0000 (Mon, 17 Oct 2011) Log Message: ----------- Fixed creation of font border for GDI fonts. Modified Paths: -------------- trunk/Drivers/AgateLib.WinForms/BitmapFontUtil.cs trunk/Drivers/AgateLib.WinForms/BitmapFontUtilRenderers.cs Modified: trunk/Drivers/AgateLib.WinForms/BitmapFontUtil.cs =================================================================== --- trunk/Drivers/AgateLib.WinForms/BitmapFontUtil.cs 2011-10-16 23:13:10 UTC (rev 1291) +++ trunk/Drivers/AgateLib.WinForms/BitmapFontUtil.cs 2011-10-17 18:19:46 UTC (rev 1292) @@ -188,9 +188,13 @@ rend.DrawChar(g, i, new Point(drawX + 1, drawY + 1), System.Drawing.Color.White); if (font.SizeInPoints >= 14.0) + { glyphs[i].LeftOverhang = 1; + glyphs[i].RightOverhang = 1; + } + else + glyphs[i].RightOverhang = 1; - glyphs[i].RightOverhang = 1; } else { Modified: trunk/Drivers/AgateLib.WinForms/BitmapFontUtilRenderers.cs =================================================================== --- trunk/Drivers/AgateLib.WinForms/BitmapFontUtilRenderers.cs 2011-10-16 23:13:10 UTC (rev 1291) +++ trunk/Drivers/AgateLib.WinForms/BitmapFontUtilRenderers.cs 2011-10-17 18:19:46 UTC (rev 1292) @@ -413,8 +413,8 @@ int left = -abc.abcA; int right = -(abc.AdvanceWidth - abc.AgateWidth - 1 + left); - glyphs[c].LeftOverhang = left; - glyphs[c].RightOverhang = right; + glyphs[c].LeftOverhang += left; + glyphs[c].RightOverhang += right; } uint numPairs = GetKerningPairs(hdc, 0, null); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ka...@us...> - 2011-10-16 23:13:16
|
Revision: 1291 http://agate.svn.sourceforge.net/agate/?rev=1291&view=rev Author: kanato Date: 2011-10-16 23:13:10 +0000 (Sun, 16 Oct 2011) Log Message: ----------- Fix FontSurface to load fonts relative to resource file location. Modified Paths: -------------- trunk/AgateLib/DisplayLib/FontSurface.cs trunk/AgateLib/DisplayLib/SurfaceState.cs trunk/AgateLib/Resources/AgateResourceCollection.cs Modified: trunk/AgateLib/DisplayLib/FontSurface.cs =================================================================== --- trunk/AgateLib/DisplayLib/FontSurface.cs 2011-10-15 00:45:28 UTC (rev 1290) +++ trunk/AgateLib/DisplayLib/FontSurface.cs 2011-10-16 23:13:10 UTC (rev 1291) @@ -121,7 +121,7 @@ if (res is BitmapFontResource) { - Surface surf = new Surface(resources.FileProvider, bmpFont.Image); + Surface surf = new Surface(resources.FileProvider, resources.FullFileName(bmpFont.Image)); mImpl = new BitmapFontImpl(surf, bmpFont.FontMetrics, resourceName); } Modified: trunk/AgateLib/DisplayLib/SurfaceState.cs =================================================================== --- trunk/AgateLib/DisplayLib/SurfaceState.cs 2011-10-15 00:45:28 UTC (rev 1290) +++ trunk/AgateLib/DisplayLib/SurfaceState.cs 2011-10-16 23:13:10 UTC (rev 1291) @@ -240,6 +240,7 @@ else return Origin.CalcF(RotationCenter, displaySize); } + } /// <summary> Modified: trunk/AgateLib/Resources/AgateResourceCollection.cs =================================================================== --- trunk/AgateLib/Resources/AgateResourceCollection.cs 2011-10-15 00:45:28 UTC (rev 1290) +++ trunk/AgateLib/Resources/AgateResourceCollection.cs 2011-10-16 23:13:10 UTC (rev 1291) @@ -493,6 +493,13 @@ return mOwnedSurfaces[filename]; } } + + internal string FullFileName(string filename) + { + if (string.IsNullOrEmpty(RootDirectory)) + return filename; + + return RootDirectory + "/" + filename; + } } - } \ 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...> - 2011-10-15 00:45:34
|
Revision: 1290 http://agate.svn.sourceforge.net/agate/?rev=1290&view=rev Author: kanato Date: 2011-10-15 00:45:28 +0000 (Sat, 15 Oct 2011) Log Message: ----------- Allow serialization of null objects in Xle serializer. Remove renamed AgateShaderCompileError.cs file. Modified Paths: -------------- trunk/AgateLib/Serialization/Xle/XleSerializationInfo.cs Removed Paths: ------------- trunk/AgateLib/DisplayLib/Shaders/Implementation/AgateShaderCompileError.cs Deleted: trunk/AgateLib/DisplayLib/Shaders/Implementation/AgateShaderCompileError.cs =================================================================== --- trunk/AgateLib/DisplayLib/Shaders/Implementation/AgateShaderCompileError.cs 2011-10-11 17:45:40 UTC (rev 1289) +++ trunk/AgateLib/DisplayLib/Shaders/Implementation/AgateShaderCompileError.cs 2011-10-15 00:45:28 UTC (rev 1290) @@ -1,57 +0,0 @@ -// The contents of this file are subject to the Mozilla Public License -// Version 1.1 (the "License"); you may not use this file except in -// compliance with the License. You may obtain a copy of the License at -// http://www.mozilla.org/MPL/ -// -// Software distributed under the License is distributed on an "AS IS" -// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the -// License for the specific language governing rights and limitations -// under the License. -// -// The Original Code is AgateLib. -// -// The Initial Developer of the Original Code is Erik Ylvisaker. -// Portions created by Erik Ylvisaker are Copyright (C) 2006-2009. -// All Rights Reserved. -// -// Contributor(s): Erik Ylvisaker -// -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace AgateLib.DisplayLib.Shaders -{ - /// <summary> - /// Exception raised when there is an error with the shader compiler. - /// </summary> - [global::System.Serializable] - public class AgateShaderCompilerException : AgateException - { - /// <summary> - /// Constructs an AgateShaderCompilerException object. - /// </summary> - public AgateShaderCompilerException() { } - /// <summary> - /// Constructs an AgateShaderCompilerException object. - /// </summary> - /// <param name="message"></param> - public AgateShaderCompilerException(string message) : base(message) { } - /// <summary> - /// Constructs an AgateShaderCompilerException object. - /// </summary> - /// <param name="inner"></param> - /// <param name="message"></param> - public AgateShaderCompilerException(string message, Exception inner) : base(message, inner) { } - /// <summary> - /// Constructs an AgateShaderCompilerException object. - /// </summary> - /// <param name="context"></param> - /// <param name="info"></param> - protected AgateShaderCompilerException( - System.Runtime.Serialization.SerializationInfo info, - System.Runtime.Serialization.StreamingContext context) - : base(info, context) { } - } -} Modified: trunk/AgateLib/Serialization/Xle/XleSerializationInfo.cs =================================================================== --- trunk/AgateLib/Serialization/Xle/XleSerializationInfo.cs 2011-10-11 17:45:40 UTC (rev 1289) +++ trunk/AgateLib/Serialization/Xle/XleSerializationInfo.cs 2011-10-15 00:45:28 UTC (rev 1290) @@ -419,13 +419,19 @@ public void Write(string name, IXleSerializable value) { XmlElement element = CreateElement(name); - AddAttribute(element, "type", value.GetType().ToString()); - nodes.Push(element); + if (value == null) + AddAttribute(element, "type", "null"); + else + { + AddAttribute(element, "type", value.GetType().ToString()); - Serialize(value); + nodes.Push(element); - nodes.Pop(); + Serialize(value); + + nodes.Pop(); + } } /// <summary> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ka...@us...> - 2011-10-11 17:45:49
|
Revision: 1289 http://agate.svn.sourceforge.net/agate/?rev=1289&view=rev Author: kanato Date: 2011-10-11 17:45:40 +0000 (Tue, 11 Oct 2011) Log Message: ----------- Some refactoring done. Mostly name changes of variable names. Modified Paths: -------------- trunk/AgateLib/AgateGame.cs trunk/AgateLib/AgateLib.csproj trunk/AgateLib/AgateSetup.cs trunk/AgateLib/AudioLib/Audio.cs trunk/AgateLib/AudioLib/SoundBuffer.cs trunk/AgateLib/BitmapFont/BitmapFontImpl.cs trunk/AgateLib/Core.cs trunk/AgateLib/Data/AgateTable.cs trunk/AgateLib/Data/FieldType.cs trunk/AgateLib/DisplayLib/CreateWindowParams.cs trunk/AgateLib/DisplayLib/Display.cs trunk/AgateLib/DisplayLib/DisplayWindow.cs trunk/AgateLib/DisplayLib/FontSurface.cs trunk/AgateLib/DisplayLib/ISurface.cs trunk/AgateLib/DisplayLib/ImplementationBase/DisplayImpl.cs trunk/AgateLib/DisplayLib/ImplementationBase/SurfaceImpl.cs trunk/AgateLib/DisplayLib/ImplementationBase/VertexBufferImpl.cs trunk/AgateLib/DisplayLib/PixelBuffer.cs trunk/AgateLib/DisplayLib/Shaders/AgateShader.cs trunk/AgateLib/DisplayLib/Shaders/Implementation/Effect.cs trunk/AgateLib/DisplayLib/Shaders/Implementation/Lighting2DImpl.cs trunk/AgateLib/DisplayLib/Shaders/Implementation/Lighting3DImpl.cs trunk/AgateLib/DisplayLib/Surface.cs trunk/AgateLib/Drivers/Registrar.cs trunk/AgateLib/Meshes/Loaders/Obj/Parser.cs trunk/AgateLib/Particles/Emitters/PixelEmitter.cs trunk/AgateLib/Platform.cs trunk/AgateLib/Resources/AgateResource.cs trunk/AgateLib/Serialization/Formatters/Xml/XmlFormatter.cs trunk/AgateLib/Sprites/Sprite.cs trunk/AgateLib/Utility/TgzFileProvider.cs trunk/AgateLib/Utility/ZipFileProvider.cs trunk/Drivers/AgateDrawing/Drawing_Display.cs trunk/Drivers/AgateDrawing/Drawing_Surface.cs trunk/Drivers/AgateLib.WinForms/BitmapFontUtil.cs trunk/Drivers/AgateLib.WinForms/BitmapFontUtilRenderers.cs trunk/Drivers/AgateLib.WinForms/WinFormsDriver.cs trunk/Drivers/AgateOTK/GL3/Shaders/GlslShader.cs trunk/Drivers/AgateOTK/GL_Display.cs trunk/Drivers/AgateOTK/GL_FrameBuffer.cs trunk/Drivers/AgateOTK/GL_Surface.cs trunk/Drivers/AgateSDX/SDX_Display.cs trunk/Drivers/AgateSDX/SDX_Surface.cs Added Paths: ----------- trunk/AgateLib/DisplayLib/Shaders/AgateShaderCompileException.cs Removed Paths: ------------- trunk/AgateLib/DisplayLib/Shaders/AgateShaderCompileError.cs Modified: trunk/AgateLib/AgateGame.cs =================================================================== --- trunk/AgateLib/AgateGame.cs 2011-10-06 03:08:42 UTC (rev 1288) +++ trunk/AgateLib/AgateGame.cs 2011-10-11 17:45:40 UTC (rev 1289) @@ -44,11 +44,11 @@ { DisplayWindow mWindow; AppInitParameters mInitParams; - FontSurface font; + FontSurface mFont; //Gui.GuiRoot mGui; - double totalSplashTime = 0; - bool splashFadeDone = false; + double mTotalSplashTime = 0; + bool mSplashFadeDone = false; #region --- Run Method --- @@ -83,7 +83,7 @@ CreateDisplayWindow(); - font = FontSurface.AgateSans14; + mFont = FontSurface.AgateSans14; if (InitParams.ShowSplashScreen) { @@ -187,20 +187,20 @@ { RenderSplashScreen(); - if (splashFadeDone) + if (mSplashFadeDone) { Surface powered = InternalResources.Data.PoweredBy; Size size = powered.SurfaceSize; int bottom = MainWindow.Height - size.Height; - int h = font.FontHeight; + int h = mFont.FontHeight; - font.DisplayAlignment = OriginAlignment.BottomLeft; - font.Color = Color.Black; + mFont.DisplayAlignment = OriginAlignment.BottomLeft; + mFont.Color = Color.Black; - font.DrawText(0, bottom - 2 * h, "Welcome to AgateLib."); - font.DrawText(0, bottom - h, "Your application framework is ready."); - font.DrawText(0, bottom, "Override the Render method in order to do your own drawing."); + mFont.DrawText(0, bottom - 2 * h, "Welcome to AgateLib."); + mFont.DrawText(0, bottom - h, "Your application framework is ready."); + mFont.DrawText(0, bottom, "Override the Render method in order to do your own drawing."); } } @@ -233,9 +233,9 @@ /// <param name="time_ms"></param> protected virtual bool UpdateSplashScreen(double time_ms) { - totalSplashTime += time_ms / 1000.0; + mTotalSplashTime += time_ms / 1000.0; - if (totalSplashTime > 3.0) + if (mTotalSplashTime > 3.0) return false; else return true; @@ -251,14 +251,14 @@ Surface powered = InternalResources.Data.PoweredBy; Size size = powered.SurfaceSize; - int left = (int)(totalSplashTime * size.Width - size.Width) + 1; + int left = (int)(mTotalSplashTime * size.Width - size.Width) + 1; Rectangle gradientRect = new Rectangle(left, MainWindow.Height - size.Height, size.Width, size.Height); if (left < 0) Display.PushClipRect(gradientRect); else if (left > size.Width) - splashFadeDone = true; + mSplashFadeDone = true; powered.DisplayAlignment = OriginAlignment.BottomLeft; powered.Draw(0, MainWindow.Height); Modified: trunk/AgateLib/AgateLib.csproj =================================================================== --- trunk/AgateLib/AgateLib.csproj 2011-10-06 03:08:42 UTC (rev 1288) +++ trunk/AgateLib/AgateLib.csproj 2011-10-11 17:45:40 UTC (rev 1289) @@ -1,4 +1,4 @@ -<?xml version="1.0" encoding="utf-8"?> +<?xml version="1.0" encoding="utf-8"?> <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0"> <PropertyGroup> <ProjectType>Local</ProjectType> @@ -156,6 +156,7 @@ <Compile Include="Data\AgateTableDictionary.cs" /> <Compile Include="DisplayLib\FrameBuffer.cs" /> <Compile Include="DisplayLib\Shaders\AgateBuiltInShaders.cs" /> + <Compile Include="DisplayLib\Shaders\AgateShaderCompileException.cs" /> <Compile Include="DisplayLib\Shaders\Basic2DShader.cs" /> <Compile Include="DisplayLib\Shaders\AgateShader.cs" /> <Compile Include="DisplayLib\Shaders\Implementation\AgateInternalShader.cs" /> @@ -269,9 +270,6 @@ <Compile Include="DisplayLib\Cache\SurfaceStateCache.cs"> <SubType>Code</SubType> </Compile> - <Compile Include="DisplayLib\Shaders\Implementation\AgateShaderCompileError.cs"> - <SubType>Code</SubType> - </Compile> <Compile Include="DisplayLib\Shaders\Implementation\Effect.cs"> <SubType>Code</SubType> </Compile> Modified: trunk/AgateLib/AgateSetup.cs =================================================================== --- trunk/AgateLib/AgateSetup.cs 2011-10-06 03:08:42 UTC (rev 1288) +++ trunk/AgateLib/AgateSetup.cs 2011-10-11 17:45:40 UTC (rev 1289) @@ -124,7 +124,7 @@ /// Constructs a Setup object. /// </summary> /// <param name="args">Command line arguments to the program.</param> - public AgateSetup(string[] args) + public AgateSetup(IEnumerable<string> args) : this("AgateLib", args) { } @@ -133,7 +133,7 @@ /// </summary> /// <param name="title"></param> /// <param name="args">Command line arguments to the program.</param> - public AgateSetup(string title, string[] args) + public AgateSetup(string title, IEnumerable<string> args) { if (sCreatedSetup != null) { Modified: trunk/AgateLib/AudioLib/Audio.cs =================================================================== --- trunk/AgateLib/AudioLib/Audio.cs 2011-10-06 03:08:42 UTC (rev 1288) +++ trunk/AgateLib/AudioLib/Audio.cs 2011-10-11 17:45:40 UTC (rev 1289) @@ -32,8 +32,8 @@ /// </summary> public static class Audio { - private static AudioImpl impl; - private static AudioCapsInfo caps = new AudioCapsInfo(); + private static AudioImpl sImpl; + private static readonly AudioCapsInfo caps = new AudioCapsInfo(); /// <summary> /// Gets the capabilities querying object for the audio subsystem. @@ -47,7 +47,7 @@ /// </summary> public static AudioImpl Impl { - get { return impl; } + get { return sImpl; } } /// <summary> /// Initializes the audio system by instantiating the driver with the given @@ -59,8 +59,8 @@ { Core.Initialize(); - impl = Registrar.CreateAudioDriver(audioType); - impl.Initialize(); + sImpl = Registrar.CreateAudioDriver(audioType); + sImpl.Initialize(); } /// <summary> @@ -70,10 +70,10 @@ { OnDispose(); - if (impl != null) + if (sImpl != null) { - impl.Dispose(); - impl = null; + sImpl.Dispose(); + sImpl = null; } } private static void OnDispose() @@ -156,9 +156,9 @@ /// </summary> public static void Update() { - if (impl == null) return; + if (sImpl == null) return; - impl.Update(); + sImpl.Update(); } } Modified: trunk/AgateLib/AudioLib/SoundBuffer.cs =================================================================== --- trunk/AgateLib/AudioLib/SoundBuffer.cs 2011-10-06 03:08:42 UTC (rev 1288) +++ trunk/AgateLib/AudioLib/SoundBuffer.cs 2011-10-11 17:45:40 UTC (rev 1289) @@ -44,7 +44,7 @@ public sealed class SoundBuffer { private string mFilename; - private SoundBufferImpl impl; + private SoundBufferImpl mImpl; private double mVolume = 1.0; private double mPan = 0; private bool mIsDisposed = false; @@ -76,7 +76,7 @@ { using (System.IO.Stream s = fileProvider.OpenRead(filename)) { - impl = Audio.Impl.CreateSoundBuffer(s); + mImpl = Audio.Impl.CreateSoundBuffer(s); } mFilename = filename; @@ -88,7 +88,7 @@ /// <param name="source"></param> public SoundBuffer(Stream source) { - impl = Audio.Impl.CreateSoundBuffer(source); + mImpl = Audio.Impl.CreateSoundBuffer(source); } /// <summary> @@ -104,10 +104,10 @@ foreach (SoundBufferSession s in sessions) s.Dispose(); - if (impl != null) + if (mImpl != null) { - impl.Dispose(); - impl = null; + mImpl.Dispose(); + mImpl = null; } mIsDisposed = true; @@ -118,7 +118,7 @@ /// </summary> public SoundBufferImpl Impl { - get { return impl; } + get { return mImpl; } } /// <summary> /// Creates a SoundBufferSession object, for playing of this @@ -149,8 +149,8 @@ /// </summary> public bool Loop { - get { return impl.Loop; } - set { impl.Loop = value; } + get { return mImpl.Loop; } + set { mImpl.Loop = value; } } /// <summary> Modified: trunk/AgateLib/BitmapFont/BitmapFontImpl.cs =================================================================== --- trunk/AgateLib/BitmapFont/BitmapFontImpl.cs 2011-10-06 03:08:42 UTC (rev 1288) +++ trunk/AgateLib/BitmapFont/BitmapFontImpl.cs 2011-10-11 17:45:40 UTC (rev 1289) @@ -194,7 +194,7 @@ if (string.IsNullOrEmpty(text)) return Size.Empty; - int CRcount = 0; + int carriageReturnCount = 0; int i = 0; double highestLineWidth = 0; @@ -226,15 +226,15 @@ if (i == -1) break; - CRcount++; + carriageReturnCount++; } while (i != -1); if (text[text.Length - 1] == '\n') - CRcount--; + carriageReturnCount--; return new Size((int)Math.Ceiling(highestLineWidth * state.ScaleWidth), - (int)(mCharHeight * (CRcount + 1) * state.ScaleHeight)); + (int)(mCharHeight * (carriageReturnCount + 1) * state.ScaleHeight)); } /// <summary> Modified: trunk/AgateLib/Core.cs =================================================================== --- trunk/AgateLib/Core.cs 2011-10-06 03:08:42 UTC (rev 1288) +++ trunk/AgateLib/Core.cs 2011-10-11 17:45:40 UTC (rev 1289) @@ -87,11 +87,11 @@ /// </summary> public static class Core { - private static bool mAutoPause = false; - private static bool mIsActive = true; - private static bool mInititalized = false; - private static Platform mPlatform; - private static PersistantSettings mSettings; + private static bool sAutoPause = false; + private static bool sIsActive = true; + private static bool sInititalized = false; + private static readonly Platform mPlatform = new Platform(); + private static PersistantSettings sSettings; #region --- Error Reporting --- @@ -104,9 +104,9 @@ /// </summary> public static class ErrorReporting { - private static string mErrorFile = "errorlog.txt"; - private static bool mAutoStackTrace = false; - private static bool mWroteHeader = false; + private static string sErrorFile = "errorlog.txt"; + private static bool sAutoStackTrace = false; + private static bool sWroteHeader = false; /// <summary> /// Gets or sets the file name to which errors are recorded. Defaults @@ -114,8 +114,8 @@ /// </summary> public static string ErrorFile { - get { return mErrorFile; } - set { mErrorFile = value; } + get { return sErrorFile; } + set { sErrorFile = value; } } /// <summary> @@ -133,8 +133,8 @@ /// </example> public static bool AutoStackTrace { - get { return mAutoStackTrace; } - set { mAutoStackTrace = value; } + get { return sAutoStackTrace; } + set { sAutoStackTrace = value; } } /// <summary> @@ -244,7 +244,7 @@ { try { - if (mWroteHeader == true) + if (sWroteHeader == true) { FileStream stream = File.Open(ErrorFile, FileMode.Append, FileAccess.Write); @@ -257,7 +257,7 @@ WriteHeader(writer); - mWroteHeader = true; + sWroteHeader = true; return writer; } @@ -300,7 +300,6 @@ static Core() { - mPlatform = new Platform(); } /// <summary> /// Initializes Core class. @@ -308,13 +307,13 @@ /// </summary> public static void Initialize() { - if (mInititalized) + if (sInititalized) return; Drivers.Registrar.Initialize(); - mInititalized = true; + sInititalized = true; } /// <summary> @@ -332,12 +331,12 @@ { get { - if (mSettings == null) + if (sSettings == null) { - mSettings = new PersistantSettings(); + sSettings = new PersistantSettings(); } - return mSettings; + return sSettings; } } /// <summary> @@ -348,8 +347,8 @@ /// </summary> public static bool IsActive { - get { return mIsActive; } - set { mIsActive = value; } + get { return sIsActive; } + set { sIsActive = value; } } /// <summary> /// Gets or sets a bool value indicating whether or not Agate @@ -364,8 +363,8 @@ /// </summary> public static bool AutoPause { - get { return mAutoPause; } - set { mAutoPause = value; } + get { return sAutoPause; } + set { sAutoPause = value; } } /// <summary> /// Delegate for types which attach to the KeepAliveEvent. Modified: trunk/AgateLib/Data/AgateTable.cs =================================================================== --- trunk/AgateLib/Data/AgateTable.cs 2011-10-06 03:08:42 UTC (rev 1288) +++ trunk/AgateLib/Data/AgateTable.cs 2011-10-11 17:45:40 UTC (rev 1289) @@ -87,13 +87,13 @@ return b.ToString(); } - static readonly char[] lineSplitChars = new char[] { '\n', '\r' }; + static readonly char[] LineSplitChars = new char[] { '\n', '\r' }; private List<AgateRow> ReadRows(string rows) { List<AgateRow> retval = new List<AgateRow>(); - string[] lines = rows.Split(lineSplitChars, StringSplitOptions.RemoveEmptyEntries); + string[] lines = rows.Split(LineSplitChars, StringSplitOptions.RemoveEmptyEntries); foreach (string line in lines) { Modified: trunk/AgateLib/Data/FieldType.cs =================================================================== --- trunk/AgateLib/Data/FieldType.cs 2011-10-06 03:08:42 UTC (rev 1288) +++ trunk/AgateLib/Data/FieldType.cs 2011-10-11 17:45:40 UTC (rev 1289) @@ -98,13 +98,13 @@ [global::System.AttributeUsage(AttributeTargets.Field, Inherited = false, AllowMultiple = true)] sealed class DataTypeAttribute : Attribute { - readonly Type dataType; + readonly Type mDataType; public DataTypeAttribute(Type dataType) { - this.dataType = dataType; + this.mDataType = dataType; } - public Type DataType { get { return dataType; } } + public Type DataType { get { return mDataType; } } } } Modified: trunk/AgateLib/DisplayLib/CreateWindowParams.cs =================================================================== --- trunk/AgateLib/DisplayLib/CreateWindowParams.cs 2011-10-06 03:08:42 UTC (rev 1288) +++ trunk/AgateLib/DisplayLib/CreateWindowParams.cs 2011-10-11 17:45:40 UTC (rev 1289) @@ -63,22 +63,22 @@ { #region --- Private Fields --- - private bool isFullScreen = false; - private Size size = new Size(1024, 768); - private WindowPosition position; - private int bpp = 32; - private bool isResizable = false; + private bool mIsFullScreen = false; + private Size mSize = new Size(1024, 768); + private WindowPosition mPosition; + private int mBpp = 32; + private bool mIsResizable = false; - private bool hasFrame = true; - private bool hasMaximize = false; - private bool hasMinimize = true; + private bool mHasFrame = true; + private bool mHasMaximize = false; + private bool mHasMinimize = true; - private string iconFile = ""; + private string mIconFile = ""; - private bool renderToControl = false; - private object renderTarget = null; + private bool mRenderToControl = false; + private object mRenderTarget = null; - private string title = "AgateLib Application"; + private string mTitle = "AgateLib Application"; #endregion #region --- Properties --- @@ -88,48 +88,48 @@ /// </summary> public string Title { - get { return title; } - set { title = value; } + get { return mTitle; } + set { mTitle = value; } } /// <summary> /// Whether or not the window should be created as a full screen window. Defaults to false. /// </summary> public bool IsFullScreen { - get { return isFullScreen; } - set { isFullScreen = value; } + get { return mIsFullScreen; } + set { mIsFullScreen = value; } } /// <summary> /// Size of the window. Defaults to 1024x768. /// </summary> public Size Size { - get { return size; } - set { size = value; } + get { return mSize; } + set { mSize = value; } } /// <summary> /// Width of the window /// </summary> public int Width { - get { return size.Width; } - set { size.Width = value; } + get { return mSize.Width; } + set { mSize.Width = value; } } /// <summary> /// Height of the window /// </summary> public int Height { - get { return size.Height; } - set { size.Height = value; } + get { return mSize.Height; } + set { mSize.Height = value; } } /// <summary> /// Sets the initial position of the window. /// </summary> public WindowPosition WindowPosition { - get { return position; } - set { position = value; } + get { return mPosition; } + set { mPosition = value; } } @@ -139,8 +139,8 @@ /// </summary> public int Bpp { - get { return bpp; } - set { bpp = value; } + get { return mBpp; } + set { mBpp = value; } } /// <summary> @@ -149,8 +149,8 @@ /// </summary> public bool IsResizable { - get { return isResizable; } - set { isResizable = value; } + get { return mIsResizable; } + set { mIsResizable = value; } } /// <summary> @@ -159,8 +159,8 @@ /// </summary> public bool HasFrame { - get { return hasFrame; } - set { hasFrame = value; } + get { return mHasFrame; } + set { mHasFrame = value; } } /// <summary> @@ -169,8 +169,8 @@ /// </summary> public bool HasMaximize { - get { return hasMaximize; } - set { hasMaximize = value; } + get { return mHasMaximize; } + set { mHasMaximize = value; } } /// <summary> @@ -178,8 +178,8 @@ /// </summary> public bool HasMinimize { - get { return hasMinimize; } - set { hasMinimize = value; } + get { return mHasMinimize; } + set { mHasMinimize = value; } } /// <summary> @@ -187,10 +187,10 @@ /// </summary> public string IconFile { - get { return iconFile; } + get { return mIconFile; } set { - iconFile = value; + mIconFile = value; } } @@ -200,8 +200,8 @@ /// </summary> public bool RenderToControl { - get { return renderToControl; } - set { renderToControl = value; } + get { return mRenderToControl; } + set { mRenderToControl = value; } } /// <summary> @@ -209,8 +209,8 @@ /// </summary> public object RenderTarget { - get { return renderTarget; } - set { renderTarget = value; } + get { return mRenderTarget; } + set { mRenderTarget = value; } } #endregion @@ -248,7 +248,7 @@ retval.Title = title; retval.Width = width; retval.Height = height; - retval.bpp = bpp; + retval.mBpp = bpp; return retval; } Modified: trunk/AgateLib/DisplayLib/Display.cs =================================================================== --- trunk/AgateLib/DisplayLib/Display.cs 2011-10-06 03:08:42 UTC (rev 1288) +++ trunk/AgateLib/DisplayLib/Display.cs 2011-10-11 17:45:40 UTC (rev 1289) @@ -58,13 +58,13 @@ /// </example> public static class Display { - 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(); - private static DisplayCapsInfo mCapsInfo = new DisplayCapsInfo(); + private static DisplayImpl sImpl; + private static DisplayWindow sCurrentWindow; + private static SurfacePacker sSurfacePacker; + private static Rectangle sCurrentClipRect; + private static Stack<Rectangle> sClipRects = new Stack<Rectangle>(); + private static RenderStateAdapter sRenderState = new RenderStateAdapter(); + private static DisplayCapsInfo sCapsInfo = new DisplayCapsInfo(); /// <summary> /// Gets the object which handles all of the actual calls to Display functions. @@ -76,7 +76,7 @@ /// </summary> public static DisplayImpl Impl { - get { return impl; } + get { return sImpl; } } /// <summary> /// Initializes the display by instantiating the driver with the given @@ -91,10 +91,10 @@ { Core.Initialize(); - impl = Registrar.CreateDisplayDriver(displayType); - impl.Initialize(); + sImpl = Registrar.CreateDisplayDriver(displayType); + sImpl.Initialize(); - mSurfacePacker = new SurfacePacker(); + sSurfacePacker = new SurfacePacker(); Shaders.AgateBuiltInShaders.InitializeShaders(); } @@ -105,7 +105,7 @@ /// </summary> public static RenderStateAdapter RenderState { - get { return mRenderState; } + get { return sRenderState; } } /// <summary> @@ -115,10 +115,10 @@ { OnDispose(); - if (impl != null) + if (sImpl != null) { - impl.Dispose(); - impl = null; + sImpl.Dispose(); + sImpl = null; } Shaders.AgateBuiltInShaders.DisposeShaders(); @@ -126,19 +126,19 @@ internal static void ProcessEvents() { - if (impl == null) + if (sImpl == null) return; - impl.ProcessEvents(); + sImpl.ProcessEvents(); } internal static bool IsAppIdle { get { - if (impl == null) + if (sImpl == null) return false; - return impl.IsAppIdle; + return sImpl.IsAppIdle; } } @@ -147,8 +147,8 @@ /// </summary> public static Shaders.AgateShader Shader { - get { return impl.Shader; } - internal set { impl.Shader = value; } + get { return sImpl.Shader; } + internal set { sImpl.Shader = value; } } /// <summary> @@ -175,7 +175,7 @@ /// </summary> public static PixelFormat DefaultSurfaceFormat { - get { return impl.DefaultSurfaceFormat; } + get { return sImpl.DefaultSurfaceFormat; } } /// <summary> @@ -187,14 +187,14 @@ { get { - return impl.RenderTarget; + return sImpl.RenderTarget; } set { if (value == null) throw new ArgumentNullException("RenderTarget cannot be null."); - impl.RenderTarget = value; + sImpl.RenderTarget = value; // TODO: replace this with an ActiveWindow property. //if (value is DisplayWindow) @@ -207,8 +207,8 @@ /// </summary> public static DisplayWindow CurrentWindow { - get { return mCurrentWindow; } - internal set { mCurrentWindow = value; } + get { return sCurrentWindow; } + internal set { sCurrentWindow = value; } } /// <summary> @@ -218,8 +218,8 @@ /// </summary> public static double AlphaThreshold { - get { return impl.AlphaThreshold; } - set { impl.AlphaThreshold = value; } + get { return sImpl.AlphaThreshold; } + set { sImpl.AlphaThreshold = value; } } /// <summary> @@ -246,7 +246,7 @@ /// <param name="color"></param> public static void Clear(Color color) { - impl.Clear(color); + sImpl.Clear(color); } /// <summary> /// Clears the buffer to the specified color. @@ -254,7 +254,7 @@ /// <param name="color">32-bit integer indicating the color. The color will be constructed from Color.FromArgb.</param> public static void Clear(int color) { - impl.Clear(Color.FromArgb(color)); + sImpl.Clear(Color.FromArgb(color)); } /// <summary> /// Clears a region of the buffer to the specified color. @@ -265,7 +265,7 @@ /// <param name="dest">Destination rectangle to clear.</param> public static void Clear(Color color, Rectangle dest) { - impl.Clear(color, dest); + sImpl.Clear(color, dest); } /// <summary> /// Clears a region of the buffer to the specified color. @@ -276,7 +276,7 @@ /// <param name="dest"></param> public static void Clear(int color, Rectangle dest) { - impl.Clear(Color.FromArgb(color), dest); + sImpl.Clear(Color.FromArgb(color), dest); } // BeginFrame and EndFrame must be called at the start and end of each frame. /// <summary> @@ -291,12 +291,12 @@ if (CurrentWindow.IsClosed) 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(); + sImpl.BeginFrame(); AgateBuiltInShaders.Basic2DShader.CoordinateSystem = new Rectangle(Point.Empty, RenderTarget.Size); AgateBuiltInShaders.Basic2DShader.Activate(); - mCurrentClipRect = new Rectangle(Point.Empty, RenderTarget.Size); + sCurrentClipRect = new Rectangle(Point.Empty, RenderTarget.Size); RenderState.AlphaBlend = true; } @@ -307,27 +307,27 @@ /// </summary> public static void EndFrame() { - impl.EndFrame(); + sImpl.EndFrame(); } /// <summary> /// Gets the amount of time in milliseconds that has passed between this frame /// and the last one. /// </summary> - public static double DeltaTime { get { return impl.DeltaTime; } } + public static double DeltaTime { get { return sImpl.DeltaTime; } } /// <summary> /// Provides a means to set the value returned by DeltaTime. /// </summary> /// <param name="deltaTime"></param> public static void SetDeltaTime(double deltaTime) { - impl.SetDeltaTime(deltaTime); + sImpl.SetDeltaTime(deltaTime); } /// <summary> /// Gets the framerate /// </summary> - public static double FramesPerSecond { get { return impl.FramesPerSecond; } } + public static double FramesPerSecond { get { return sImpl.FramesPerSecond; } } /// <summary> /// Set the current clipping rect. @@ -336,7 +336,7 @@ public static void SetClipRect(Rectangle newClipRect) { FlushDrawBuffer(); - impl.SetClipRect(newClipRect); + sImpl.SetClipRect(newClipRect); } /// <summary> /// Pushes a clip rect onto the clip rect stack. @@ -344,7 +344,7 @@ /// <param name="newClipRect"></param> public static void PushClipRect(Rectangle newClipRect) { - mClipRects.Push(mCurrentClipRect); + sClipRects.Push(sCurrentClipRect); SetClipRect(newClipRect); } /// <summary> @@ -352,13 +352,13 @@ /// </summary> public static void PopClipRect() { - if (mClipRects.Count == 0) + if (sClipRects.Count == 0) { throw new AgateException("You have popped the cliprect too many times."); } else { - SetClipRect(mClipRects.Pop()); + SetClipRect(sClipRects.Pop()); } } @@ -374,7 +374,7 @@ /// </summary> public static SurfacePacker SurfacePacker { - get { return mSurfacePacker; } + get { return sSurfacePacker; } } /// <summary> @@ -388,12 +388,12 @@ /// </summary> public static void PackAllSurfaces() { - mSurfacePacker.ClearQueue(); + sSurfacePacker.ClearQueue(); if (PackAllSurfacesEvent != null) PackAllSurfacesEvent(null, EventArgs.Empty); - mSurfacePacker.PackQueue(); + sSurfacePacker.PackQueue(); GC.Collect(); } @@ -406,7 +406,7 @@ /// <returns>An array of available full-screen modes.</returns> public static ScreenMode[] EnumScreenModes() { - return impl.EnumScreenModes(); + return sImpl.EnumScreenModes(); } /// <summary> @@ -416,7 +416,7 @@ internal static Surface BuildPackedSurface(Size size, SurfacePacker.RectPacker<Surface> packedRects) { - Surface retval = impl.BuildPackedSurface(size, packedRects); + Surface retval = sImpl.BuildPackedSurface(size, packedRects); retval.ShouldBePacked = false; return retval; @@ -445,7 +445,7 @@ /// </summary> public static void FlushDrawBuffer() { - impl.FlushDrawBuffer(); + sImpl.FlushDrawBuffer(); } /// <summary> @@ -502,7 +502,7 @@ /// <param name="color"></param> public static void DrawEllipse(Rectangle rect, Color color) { - impl.DrawEllipse(rect, color); + sImpl.DrawEllipse(rect, color); } /// <summary> /// Draws a line between the two points specified. @@ -514,7 +514,7 @@ /// <param name="color"></param> public static void DrawLine(int x1, int y1, int x2, int y2, Color color) { - impl.DrawLine(new Point(x1, y1), new Point(x2, y2), color); + sImpl.DrawLine(new Point(x1, y1), new Point(x2, y2), color); } /// <summary> /// Draws a line between the two points specified. @@ -524,7 +524,7 @@ /// <param name="color"></param> public static void DrawLine(Point a, Point b, Color color) { - impl.DrawLine(a, b, color); + sImpl.DrawLine(a, b, color); } /// <summary> /// Draws a bunch of connected lines. The last point and the @@ -534,7 +534,7 @@ /// <param name="color"></param> public static void DrawLines(Point[] pts, Color color) { - impl.DrawLines(pts, color); + sImpl.DrawLines(pts, color); } /// <summary> /// Draws a bunch of line segments. Each pair of points represents @@ -547,7 +547,7 @@ { if (pts.Length % 2 == 1) throw new ArgumentException("pts argument is not an even number of points!"); - impl.DrawLineSegments(pts, color); + sImpl.DrawLineSegments(pts, color); } /// <summary> /// Draws the outline of a rectangle. @@ -556,7 +556,7 @@ /// <param name="color"></param> public static void DrawRect(Rectangle rect, Color color) { - impl.DrawRect(rect, color); + sImpl.DrawRect(rect, color); } /// <summary> /// Draws the outline of a rectangle. @@ -565,7 +565,7 @@ /// <param name="color"></param> public static void DrawRect(RectangleF rect, Color color) { - impl.DrawRect(rect, color); + sImpl.DrawRect(rect, color); } /// <summary> /// Draws the outline of a rectangle @@ -577,7 +577,7 @@ /// <param name="color"></param> public static void DrawRect(int x, int y, int width, int height, Color color) { - impl.DrawRect(new Rectangle(x, y, width, height), color); + sImpl.DrawRect(new Rectangle(x, y, width, height), color); } /// <summary> @@ -587,7 +587,7 @@ /// <param name="color"></param> public static void FillEllipse(Rectangle rect, Color color) { - impl.FillEllipse((RectangleF)rect, color); + sImpl.FillEllipse((RectangleF)rect, color); } /// <summary> /// Draws a filled ellipse inscribed in the specified rectangle. @@ -596,7 +596,7 @@ /// <param name="color"></param> public static void FillEllipse(RectangleF rect, Color color) { - impl.FillEllipse(rect, color); + sImpl.FillEllipse(rect, color); } /// <summary> /// Draws a filled polygon. The last point will be connected to the first point. @@ -605,7 +605,7 @@ /// <param name="color"></param> public static void FillPolygon(PointF[] pts, Color color) { - impl.FillPolygon(pts, color); + sImpl.FillPolygon(pts, color); } /// <summary> /// Draws a filled rectangle. @@ -614,7 +614,7 @@ /// <param name="color"></param> public static void FillRect(Rectangle rect, Color color) { - impl.FillRect(rect, color); + sImpl.FillRect(rect, color); } /// <summary> /// Draws a filled rectangle. @@ -626,7 +626,7 @@ /// <param name="color"></param> public static void FillRect(int x, int y, int width, int height, Color color) { - impl.FillRect(new Rectangle(x, y, width, height), color); + sImpl.FillRect(new Rectangle(x, y, width, height), color); } /// <summary> /// Draws a filled rectangle with a gradient. @@ -635,7 +635,7 @@ /// <param name="color"></param> public static void FillRect(Rectangle rect, Gradient color) { - impl.FillRect(rect, color); + sImpl.FillRect(rect, color); } /// <summary> /// Draws a filled rectangle with a gradient. @@ -647,7 +647,7 @@ /// <param name="color"></param> public static void FillRect(int x, int y, int width, int height, Gradient color) { - impl.FillRect(new Rectangle(x, y, width, height), color); + sImpl.FillRect(new Rectangle(x, y, width, height), color); } /// <summary> /// Draws a filled rectangle. @@ -656,7 +656,7 @@ /// <param name="color"></param> public static void FillRect(RectangleF rect, Color color) { - impl.FillRect(rect, color); + sImpl.FillRect(rect, color); } /// <summary> /// Draws a filled rectangle with a gradient. @@ -665,7 +665,7 @@ /// <param name="color"></param> public static void FillRect(RectangleF rect, Gradient color) { - impl.FillRect(rect, color); + sImpl.FillRect(rect, color); } @@ -676,21 +676,21 @@ /// </summary> public static DisplayCapsInfo Caps { - get { return mCapsInfo; } + get { return sCapsInfo; } } internal static void SavePixelBuffer(PixelBuffer pixelBuffer, string filename, ImageFileFormat format) { - impl.SavePixelBuffer(pixelBuffer, filename, format); + sImpl.SavePixelBuffer(pixelBuffer, filename, format); } internal static void HideCursor() { - impl.HideCursor(); + sImpl.HideCursor(); } internal static void ShowCursor() { - impl.ShowCursor(); + sImpl.ShowCursor(); } } Modified: trunk/AgateLib/DisplayLib/DisplayWindow.cs =================================================================== --- trunk/AgateLib/DisplayLib/DisplayWindow.cs 2011-10-06 03:08:42 UTC (rev 1288) +++ trunk/AgateLib/DisplayLib/DisplayWindow.cs 2011-10-11 17:45:40 UTC (rev 1289) @@ -36,8 +36,8 @@ /// </remarks> public sealed class DisplayWindow : IDisposable { - DisplayWindowImpl impl; - FrameBuffer frameBuffer; + DisplayWindowImpl mImpl; + FrameBuffer mFrameBuffer; /// <summary> /// Constructs a DisplayWindow from a resource. @@ -58,14 +58,14 @@ CreateWindowParams par = CreateWindowParams.FullScreen( disp.Title, disp.Size.Width, disp.Size.Height, disp.Bpp); - impl = Display.Impl.CreateDisplayWindow(par); + mImpl = Display.Impl.CreateDisplayWindow(par); } else { CreateWindowParams par = CreateWindowParams.Windowed( disp.Title, disp.Size.Width, disp.Size.Height, disp.AllowResize, null); - impl = Display.Impl.CreateDisplayWindow(par); + mImpl = Display.Impl.CreateDisplayWindow(par); } Display.RenderTarget = FrameBuffer; @@ -83,7 +83,7 @@ "Display has not been initialized." + Environment.NewLine + "Did you forget to call AgateSetup.Initialize or Display.Initialize?"); - impl = Display.Impl.CreateDisplayWindow(windowParams); + mImpl = Display.Impl.CreateDisplayWindow(windowParams); Display.RenderTarget = FrameBuffer; Display.DisposeDisplay += new Display.DisposeDisplayHandler(Dispose); @@ -179,12 +179,12 @@ { get { - if (frameBuffer == null || frameBuffer.Impl != Impl.FrameBuffer) + if (mFrameBuffer == null || mFrameBuffer.Impl != Impl.FrameBuffer) { - frameBuffer = new FrameBuffer(Impl.FrameBuffer); + mFrameBuffer = new FrameBuffer(Impl.FrameBuffer); } - return frameBuffer; + return mFrameBuffer; } } @@ -204,10 +204,10 @@ /// </summary> public void Dispose() { - if (impl != null) + if (mImpl != null) { - impl.Dispose(); - impl = null; + mImpl.Dispose(); + mImpl = null; } } /// <summary> @@ -219,10 +219,10 @@ { get { - if (impl == null) + if (mImpl == null) return true; - return impl.IsClosed; + return mImpl.IsClosed; } } @@ -231,8 +231,8 @@ /// </summary> public Size Size { - get { return impl.Size; } - set { impl.Size = value; } + get { return mImpl.Size; } + set { mImpl.Size = value; } } /// <summary> /// Gets or sets the width of the client area in pixels. @@ -263,10 +263,10 @@ /// </summary> public Point MousePosition { - get { return impl.MousePosition; } + get { return mImpl.MousePosition; } set { - impl.MousePosition = value; + mImpl.MousePosition = value; } } /// <summary> @@ -274,7 +274,7 @@ /// </summary> public DisplayWindowImpl Impl { - get { return impl; } + get { return mImpl; } } /// <summary> @@ -282,8 +282,8 @@ /// </summary> public string Title { - get { return impl.Title; } - set { impl.Title = value; } + get { return mImpl.Title; } + set { mImpl.Title = value; } } /// <summary> @@ -291,7 +291,7 @@ /// </summary> public bool IsFullScreen { - get { return impl.IsFullScreen; } + get { return mImpl.IsFullScreen; } } /// <summary> /// Sets the display to windowed. Does nothing if the display is already @@ -300,7 +300,7 @@ /// </summary> public void SetWindowed() { - impl.SetWindowed(); + mImpl.SetWindowed(); } /// <summary> @@ -314,7 +314,7 @@ /// </remarks> public void SetFullScreen() { - impl.SetFullScreen(); + mImpl.SetFullScreen(); } /// <summary> /// Sets the display to a full screen Display. The resolution chosen is @@ -331,7 +331,7 @@ /// <param name="bpp"></param> public void SetFullScreen(int width, int height, int bpp) { - impl.SetFullScreen(width, height, bpp); + mImpl.SetFullScreen(width, height, bpp); } /// <summary> Modified: trunk/AgateLib/DisplayLib/FontSurface.cs =================================================================== --- trunk/AgateLib/DisplayLib/FontSurface.cs 2011-10-06 03:08:42 UTC (rev 1288) +++ trunk/AgateLib/DisplayLib/FontSurface.cs 2011-10-11 17:45:40 UTC (rev 1289) @@ -66,7 +66,7 @@ /// </summary> public sealed class FontSurface : IDisposable { - internal FontSurfaceImpl impl; + private FontSurfaceImpl mImpl; private StringTransformer mTransformer = StringTransformer.None; FontState mState = new FontState(); @@ -103,11 +103,11 @@ throw new ArgumentOutOfRangeException("Font size must be positive and non-zero, but was " + sizeInPoints.ToString() + "."); - impl = Display.Impl.CreateFont(fontFamily, sizeInPoints, style); + mImpl = Display.Impl.CreateFont(fontFamily, sizeInPoints, style); Display.DisposeDisplay += new Display.DisposeDisplayHandler(Dispose); - System.Diagnostics.Debug.Assert(impl != null); + System.Diagnostics.Debug.Assert(mImpl != null); } /// <summary> /// Constructs a FontSurface object from a resource. @@ -123,14 +123,14 @@ { Surface surf = new Surface(resources.FileProvider, bmpFont.Image); - impl = new BitmapFontImpl(surf, bmpFont.FontMetrics, resourceName); + mImpl = new BitmapFontImpl(surf, bmpFont.FontMetrics, resourceName); } else throw new AgateResourceException(string.Format( "The resource {0} is of type {1} which cannot be used to construct a font.", resourceName, res.GetType().Name)); - System.Diagnostics.Debug.Assert(impl != null); + System.Diagnostics.Debug.Assert(mImpl != null); } /// <summary> /// Creates a bitmap font using the options passed in. The Display driver @@ -139,11 +139,11 @@ /// <param name="bitmapOptions"></param> public FontSurface(BitmapFontOptions bitmapOptions) { - impl = Display.Impl.CreateFont(bitmapOptions); + mImpl = Display.Impl.CreateFont(bitmapOptions); Display.DisposeDisplay += new Display.DisposeDisplayHandler(Dispose); - System.Diagnostics.Debug.Assert(impl != null); + System.Diagnostics.Debug.Assert(mImpl != null); } /// <summary> @@ -151,7 +151,7 @@ /// </summary> public string FontName { - get { return impl.FontName; } + get { return mImpl.FontName; } } /// <summary> /// Private initializer to tell it what impl to use. @@ -162,7 +162,7 @@ if (implToUse == null) throw new ArgumentNullException("implToUse"); - impl = implToUse; + mImpl = implToUse; } /// <summary> @@ -180,7 +180,7 @@ /// </summary> public FontSurfaceImpl Impl { - get { return impl; } + get { return mImpl; } } /// <summary> /// This function loads a monospace bitmap font from the specified image file. @@ -205,10 +205,10 @@ /// </summary> public void Dispose() { - if (impl != null) - impl.Dispose(); + if (mImpl != null) + mImpl.Dispose(); - impl = null; + mImpl = null; } /// <summary> @@ -333,7 +333,7 @@ [Obsolete("Use MeasureString instead.", true)] public Size StringDisplaySize(string text) { - return impl.MeasureString(mState, text); + return mImpl.MeasureString(mState, text); } /// <summary> @@ -343,7 +343,7 @@ /// <returns></returns> public Size MeasureString(string text) { - return impl.MeasureString(mState, text); + return mImpl.MeasureString(mState, text); } /// <summary> /// Measures the display size of the specified string. @@ -353,14 +353,14 @@ /// <returns></returns> public Size MeasureString(FontState state, string text) { - return impl.MeasureString(state, text); + return mImpl.MeasureString(state, text); } /// <summary> /// Gets the height in pixels of a single line of text. /// </summary> public int FontHeight { - get { return impl.FontHeight; } + get { return mImpl.FontHeight; } } /// <summary> @@ -425,7 +425,7 @@ if (string.IsNullOrEmpty(state.TransformedText)) state.TransformedText = StringTransformer.Transform(state.Text); - impl.DrawText(state); + mImpl.DrawText(state); } /// <summary> /// Draws formatted text. @@ -480,9 +480,8 @@ int lastIndex = 0; string result = string.Empty; - PointF dest; - dest = PointF.Empty; + PointF dest = PointF.Empty; TextLayout layout = new TextLayout(); int lineHeight = FontHeight; @@ -570,7 +569,7 @@ return layout; } - private static void ShiftLine(TextLayout layout, int lineShift, int lineIndex) + private static void ShiftLine(IEnumerable<LayoutItem> layout, int lineShift, int lineIndex) { foreach (var item in layout.Where(x => x.LineIndex == lineIndex)) { @@ -583,6 +582,9 @@ ref PointF dest, ref int lineHeight, ref int spaceAboveLine, ISurface surface) { + if (layout == null) + throw new ArgumentNullException("layout"); + int newSpaceAbove; LayoutSurface t = new LayoutSurface { Location = dest, Surface = surface, LineIndex = lineIndex }; t.State = surface.State.Clone(); Modified: trunk/AgateLib/DisplayLib/ISurface.cs =================================================================== --- trunk/AgateLib/DisplayLib/ISurface.cs 2011-10-06 03:08:42 UTC (rev 1288) +++ trunk/AgateLib/DisplayLib/ISurface.cs 2011-10-11 17:45:40 UTC (rev 1289) @@ -143,7 +143,7 @@ /// <summary> /// Draws the surface using the specified state object. /// </summary> - /// <param name="State"></param> - void Draw(SurfaceState State); + /// <param name="state"></param> + void Draw(SurfaceState state); } } Modified: trunk/AgateLib/DisplayLib/ImplementationBase/DisplayImpl.cs =================================================================== --- trunk/AgateLib/DisplayLib/ImplementationBase/DisplayImpl.cs 2011-10-06 03:08:42 UTC (rev 1288) +++ trunk/AgateLib/DisplayLib/ImplementationBase/DisplayImpl.cs 2011-10-11 17:45:40 UTC (rev 1289) @@ -374,8 +374,8 @@ /// Clears a region of the buffer to the specified color. /// </summary> /// <param name="color"></param> - /// <param name="dest"></param> - public abstract void Clear(Color color, Rectangle dest); + /// <param name="destRect"></param> + public abstract void Clear(Color color, Rectangle destRect); /// <summary> @@ -668,9 +668,9 @@ /// return null for any built in shader that is not supported. /// Basic2DShader must have an implementation, but any other shader can be unsupported. /// </summary> - /// <param name="BuiltInShaderType"></param> + /// <param name="builtInShaderType"></param> /// <returns></returns> - protected internal abstract AgateShaderImpl CreateBuiltInShader(AgateLib.DisplayLib.Shaders.Implementation.BuiltInShader BuiltInShaderType); + protected internal abstract AgateShaderImpl CreateBuiltInShader(AgateLib.DisplayLib.Shaders.Implementation.BuiltInShader builtInShaderType); /// <summary> /// Creates a Modified: trunk/AgateLib/DisplayLib/ImplementationBase/SurfaceImpl.cs =================================================================== --- trunk/AgateLib/DisplayLib/ImplementationBase/SurfaceImpl.cs 2011-10-06 03:08:42 UTC (rev 1288) +++ trunk/AgateLib/DisplayLib/ImplementationBase/SurfaceImpl.cs 2011-10-11 17:45:40 UTC (rev 1289) @@ -42,14 +42,34 @@ /// <summary> /// Constructs a SurfaceImpl object. /// </summary> - public SurfaceImpl() + protected SurfaceImpl() { } /// <summary> + /// Finalizes a SurfaceImpl object + /// </summary> + ~SurfaceImpl() + { + Dispose(false); + } + + /// <summary> /// Frees unmanaged resources. /// </summary> - public abstract void Dispose(); + public void Dispose() + { + Dispose(true); + mIsDisposed = true; + GC.SuppressFinalize(this); + } + + /// <summary> + /// Implemented by deriving classes to clean up unmanaged resources. + /// </summary> + /// <param name="disposing"></param> + protected abstract void Dispose(bool disposing); + #endregion #region --- Drawing the surface to the screen --- Modified: trunk/AgateLib/DisplayLib/ImplementationBase/VertexBufferImpl.cs =================================================================== --- trunk/AgateLib/DisplayLib/ImplementationBase/VertexBufferImpl.cs 2011-10-06 03:08:42 UTC (rev 1288) +++ trunk/AgateLib/DisplayLib/ImplementationBase/VertexBufferImpl.cs 2011-10-11 17:45:40 UTC (rev 1289) @@ -33,7 +33,7 @@ /// <summary> /// Constructs a vertex buffer implementation. /// </summary> - public VertexBufferImpl() + protected VertexBufferImpl() { Textures = new TextureList(); } Modified: trunk/AgateLib/DisplayLib/PixelBuffer.cs =================================================================== --- trunk/AgateLib/DisplayLib/PixelBuffer.cs 2011-10-06 03:08:42 UTC (rev 1288) +++ trunk/AgateLib/DisplayLib/PixelBuffer.cs 2011-10-11 17:45:40 UTC (rev 1289) @@ -608,30 +608,30 @@ if (this.PixelStride == 4) { - int A = clr.A; - int R = clr.R; - int G = clr.G; - int B = clr.B; + int a = clr.A; + int r = clr.R; + int g = clr.G; + int b = clr.B; switch (PixelFormat) { case PixelFormat.ARGB8888: - SetARGB8(A, R, G, B, Data, + SetARGB8(a, r, g, b, Data, index, index + 1, index + 2, index + 3); break; case PixelFormat.ABGR8888: - SetARGB8(A, R, G, B, Data, + SetARGB8(a, r, g, b, Data, index, index + 3, index + 2, index + 1); break; case PixelFormat.BGRA8888: - SetARGB8(A, R, G, B, Data, + SetARGB8(a, r, g, b, Data, index + 3, index + 2, index + 1, index); break; case PixelFormat.RGBA8888: - SetARGB8(A, R, G, B, Data, + SetARGB8(a, r, g, b, Data, index + 3, index, index + 1, index + 2); break; @@ -755,11 +755,11 @@ /// data in this PixelBuffer copied to the upper left corner. /// </summary> /// <param name="pixelFormat">PixelFormat that the newly created PixelBuffer should have.</param> - /// <param name="mTextureSize"></param> + /// <param name="textureSize"></param> /// <returns></returns> - public PixelBuffer ConvertTo(PixelFormat pixelFormat, Size mTextureSize) + public PixelBuffer ConvertTo(PixelFormat pixelFormat, Size textureSize) { - return ConvertTo(pixelFormat, mTextureSize, Point.Empty); + return ConvertTo(pixelFormat, textureSize, Point.Empty); } /// <summary> @@ -768,12 +768,12 @@ /// is specified by point. /// </summary> /// <param name="pixelFormat">PixelFormat that the newly created PixelBuffer should have.</param> - /// <param name="mTextureSize"></param> + /// <param name="textureSize"></param> /// <param name="point"></param> /// <returns></returns> - public PixelBuffer ConvertTo(PixelFormat pixelFormat, Size mTextureSize, Point point) + public PixelBuffer ConvertTo(PixelFormat pixelFormat, Size textureSize, Point point) { - PixelBuffer retval = new PixelBuffer(pixelFormat, mTextureSize); + var retval = new PixelBuffer(pixelFormat, textureSize); for (int y = 0; y < Height; y++) { @@ -859,11 +859,11 @@ // return; //} - double A, R, G, B; + double a, r, g, b; - GetSourcePixelAttributes(src, srcIndex, srcFormat, out A, out R, out G, out B); + GetSourcePixelAttributes(src, srcIndex, srcFormat, out a, out r, out g, out b); - SetDestPixelAttributes(dest, destIndex, destFormat, A, R, G, B); + SetDestPixelAttributes(dest, destIndex, destFormat, a, r, g, b); } /// <summary> @@ -972,33 +972,33 @@ private static void GetSourcePixelAttributes(byte[] src, int srcIndex, PixelFormat srcFormat, - out double A, out double R, out double G, out double B) + out double a, out double r, out double g, out double b) { switch (srcFormat) { case PixelFormat.ARGB8888: - GetARGB8(out A, out R, out G, out B, src, srcIndex, srcIndex + 1, srcIndex + 2, srcIndex + 3); + GetARGB8(out a, out r, out g, out b, src, srcIndex, srcIndex + 1, srcIndex + 2, srcIndex + 3); break; case PixelFormat.ABGR8888: - GetARGB8(out A, out R, out G, out B, src, srcIndex, srcIndex + 3, srcIndex + 2, srcIndex + 1); + GetARGB8(out a, out r, out g, out b, src, srcIndex, srcIndex + 3, srcIndex + 2, srcIndex + 1); break; case PixelFormat.RGBA8888: - GetARGB8(out A, out R, out G, out B, src, srcIndex + 3, srcIndex, srcIndex + 1, srcIndex + 2); + GetARGB8(out a, out r, out g, out b, src, srcIndex + 3, srcIndex, srcIndex + 1, srcIndex + 2); break; case PixelFormat.BGRA8888: - GetARGB8(out A, out R, out G, out B, src, srcIndex + 3, srcIndex + 2, srcIndex + 1, srcIndex); + GetARGB8(out a, out r, out g, out b, src, srcIndex + 3, srcIndex + 2, srcIndex + 1, srcIndex); break; case PixelFormat.XRGB8888: - GetARGB8(out A, out R, out G, out B, src, srcIndex, srcIndex + 1, srcIndex + 2, srcIndex + 3); - A = 1.0; + GetARGB8(out a, out r, out g, out b, src, srcIndex, srcIndex + 1, srcIndex + 2, srcIndex + 3); + a = 1.0; break; case PixelFormat.XBGR8888: - GetARGB8(out A, out R, out G, out B, src, srcIndex, srcIndex + 3, srcIndex + 2, srcIndex + 1); - A = 1.0; + GetARGB8(out a, out r, out g, out b, src, srcIndex, srcIndex + 3, srcIndex + 2, srcIndex + 1); + a = 1.0; break; @@ -1010,31 +1010,31 @@ } - private static void SetARGB8(int A, int R, int G, int B, - byte[] dest, int Aindex, int Rindex, int Gindex, int Bindex) + private static void SetARGB8(int a, int r, int g, int b, + byte[] dest, int aindex, int rindex, int gindex, int bindex) { - dest[Aindex] = (byte)A; - dest[Rindex] = (byte)R; - dest[Gindex] = (byte)G; - dest[Bindex] = (byte)B; + dest[aindex] = (byte)a; + dest[rindex] = (byte)r; + dest[gindex] = (byte)g; + dest[bindex] = (byte)b; } - private static void SetARGB8(double A, double R, double G, double B, - byte[] dest, int Aindex, int Rindex, int Gindex, int Bindex) + private static void SetARGB8(double a, double r, double g, double b, + byte[] dest, int aindex, int rindex, int gindex, int bindex) { - dest[Aindex] = (byte)(A * 255.0 + 0.5); - dest[Rindex] = (byte)(R * 255.0 + 0.5); - dest[Gindex] = (byte)(G * 255.0 + 0.5); - dest[Bindex] = (byte)(B * 255.0 + 0.5); + dest[aindex] = (byte)(a * 255.0 + 0.5); + dest[rindex] = (byte)(r * 255.0 + 0.5); + dest[gindex] = (byte)(g * 255.0 + 0.5); + dest[bindex] = (byte)(b * 255.0 + 0.5); } - private static void GetARGB8(out double A, out double R, out double G, out double B, - byte[] src, int Aindex, int Rindex, int Gindex, int Bindex) + private static void GetARGB8(out double a, out double r, out double g, out double b, + byte[] src, int aindex, int rindex, int gindex, int bindex) { - A = src[Aindex] / 255.0; - R = src[Rindex] / 255.0; - G = src[Gindex] / 255.0; - B = src[Bindex] / 255.0; + a = src[aindex] / 255.0; + r = src[rindex] / 255.0; + g = src[gindex] / 255.0; + b = src[bindex] / 255.0; } #endregion Modified: trunk/AgateLib/DisplayLib/Shaders/AgateShader.cs =================================================================== --- trunk/AgateLib/DisplayLib/Shaders/AgateShader.cs 2011-10-06 03:08:42 UTC (rev 1288) +++ trunk/AgateLib/DisplayLib/Shaders/AgateShader.cs 2011-10-11 17:45:40 UTC (rev 1289) @@ -30,7 +30,7 @@ /// </summary> public class AgateShader { - AgateShaderImpl impl; + AgateShaderImpl mImpl; /// <summary> /// Sets the implementation. If the implementation is already set, then @@ -39,10 +39,10 @@ /// <param name="impl"></param> protected internal void SetImpl(AgateShaderImpl impl) { - if (this.impl != null) + if (this.mImpl != null) throw new InvalidOperationException("Cannot set impl on an object which already has one."); - this.impl = impl; + this.mImpl = impl; } /// <summary> @@ -50,23 +50,23 @@ /// </summary> public AgateShaderImpl Impl { - get { return impl; } + get { return mImpl; } } /// <summary> /// Returns true if this shader has an implementation. /// </summary> public bool IsValid { - get { return impl != null; } + get { return mImpl != null; } } internal void BeginInternal() { - impl.Begin(); + mImpl.Begin(); } internal void EndInternal() { - impl.End(); + mImpl.End(); } /// <summary> Deleted: trunk/AgateLib/DisplayLib/Shaders/AgateShaderCompileError.cs =================================================================== --- trunk/AgateLib/DisplayLib/Shaders/AgateShaderCompileError.cs 2011-10-06 03:08:42 UTC (rev 1288) +++ trunk/AgateLib/DisplayLib/Shaders/AgateShaderCompileError.cs 2011-10-11 17:45:40 UTC (rev 1289) @@ -1,59 +0,0 @@ -// The contents of this file are subject to the Mozilla Public License -// Version 1.1 (the "License"); you may not use this file except in -// compliance with the License. You may obtain a copy of the License at -// http://www.mozilla.org/MPL/ -// -// Software distributed under the License is distributed on an "AS IS" -// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the -// License for the specific language governing rights and limitations -// under the License. -// -// The Original Code is AgateLib. -// -// The Initial Developer of the Original Code is Erik Ylvisaker. -// Portions created by Erik Ylvisaker are Copyright (C) 2006-2009. -// All Rights Reserved. -// -// Contributor(s): Erik Ylvisaker -// -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace AgateLib.DisplayLib.Shaders -{ - /// <summary> - /// Exception thrown when an attempt to compile a shader fails. - /// </summary> - [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 - // - - /// <summary> - /// Constructs an AgateShaderCompilerException object. - /// </summary> - public AgateShaderCompilerException() { } - /// <summary> - /// Constructs an AgateShaderCompilerException object. - /// </summary> - public AgateShaderCompilerException(string message) : base(message) { } - /// <summary> - /// Constructs an AgateShaderCompilerException object. - /// </summary> - public AgateShaderCompilerException(string message, Exception inner) : base(message, inner) { } - /// <summary> - /// Constructs an AgateShaderCompilerException object. - /// </summary> - protected AgateShaderCompilerException( - System.Runtime.Serialization.SerializationInfo info, - System.Runtime.Serialization.StreamingContext context) - : base(info, context) { } - } -} Copied: trunk/AgateLib/DisplayLib/Shaders/AgateShaderCompileException.cs (from rev 1283, trunk/AgateLib/DisplayLib/Shaders/AgateShaderCompileError.cs) =================================================================== --- trunk/AgateLib/DisplayLib/Shaders/AgateShaderCompileException.cs (rev 0) +++ trunk/AgateLib/DisplayLib/Shaders/AgateShaderCompileException.cs 2011-10-11 17:45:40 UTC (rev 1289) @@ -0,0 +1,55 @@ +// The contents of this file are subject to the Mozilla Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.mozilla.org/MPL/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations +// under the License. +// +// The Original Code is AgateLib. +// +// The Initial Developer of the Original Code is Erik Ylvisaker. +// Portions created by Erik Ylvisaker are Copyright (C) 2006-2009. +// All Rights Reserved. +// +// Contributor(s): Erik Ylvisaker +// + +using System; + +namespace AgateLib.DisplayLib.Shaders +{ + /// <summary> + /// Exception raised when there is an error with the shader compiler. + /// </summary> + [global::System.Serializable] + public class AgateShaderCompilerException : AgateException + { + /// <summary> + /// Constructs an AgateShaderCompilerException object. + /// </summary> + public AgateShaderCompilerException() { } + /// <summary> + /// Constructs an AgateShaderCompilerException object. + /// </summary> + /// <param name="message"></param> + public AgateShaderCompilerException(string message) : base(message) { } + /// <summary> + /// Constructs an AgateShaderCompilerException object. + /// </summary> + /// <param name="inner"></param> + /// <param name="message"></param> + public AgateShaderCompilerException(string message, Exception inner) : base(message, inner) { } + /// <summary> + /// Constructs an AgateShaderCompilerException object. + /// </summary> + /// <param name="context"></param> + /// <param name="info"></param> + protected AgateShaderCompilerException( + System.Runtime.Serialization.SerializationInfo info, + System.Runtime.Serialization.StreamingContext context) + : base(info, context) { } + } +} Modified: trunk/AgateLib/DisplayLib/Shaders/Implementation/Effect.cs =================================================================== --- trunk/AgateLib/DisplayLib/Shaders/Implementation/Effect.cs 2011-10-06 03:... [truncated message content] |
From: <ka...@us...> - 2011-10-06 03:08:49
|
Revision: 1288 http://agate.svn.sourceforge.net/agate/?rev=1288&view=rev Author: kanato Date: 2011-10-06 03:08:42 +0000 (Thu, 06 Oct 2011) Log Message: ----------- Added XleSerializationInfo.ContainsKey method. Modified Paths: -------------- trunk/AgateLib/Serialization/Xle/XleSerializationInfo.cs Modified: trunk/AgateLib/Serialization/Xle/XleSerializationInfo.cs =================================================================== --- trunk/AgateLib/Serialization/Xle/XleSerializationInfo.cs 2011-10-04 06:18:28 UTC (rev 1287) +++ trunk/AgateLib/Serialization/Xle/XleSerializationInfo.cs 2011-10-06 03:08:42 UTC (rev 1288) @@ -637,7 +637,26 @@ #endregion #region --- Reading methods --- + /// <summary> + /// Checks to see if the given key is in the deserialized data. + /// </summary> + /// <param name="name"></param> + /// <returns></returns> + public bool ContainsKey(string name) + { + string attribute = CurrentNode.GetAttribute(name); + if (string.IsNullOrEmpty(attribute) == false) + return true; + + XmlElement element = (XmlElement)CurrentNode[name]; + + if (element == null) + return false; + + return true; + } + private Type GetType(string name) { return Binder.GetType(name); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |