agate-svn-commit Mailing List for AgateLib (Page 17)
Status: Alpha
Brought to you by:
kanato
You can subscribe to this list here.
| 2009 |
Jan
|
Feb
|
Mar
|
Apr
(86) |
May
(77) |
Jun
|
Jul
(1) |
Aug
(31) |
Sep
(12) |
Oct
(31) |
Nov
(53) |
Dec
(39) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2010 |
Jan
(53) |
Feb
(14) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(2) |
Sep
|
Oct
|
Nov
(7) |
Dec
(13) |
| 2011 |
Jan
(17) |
Feb
(5) |
Mar
(1) |
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
(10) |
Nov
(21) |
Dec
|
| 2012 |
Jan
(6) |
Feb
(14) |
Mar
(5) |
Apr
(4) |
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2013 |
Jan
(1) |
Feb
(8) |
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
|
Aug
(2) |
Sep
(1) |
Oct
(5) |
Nov
(9) |
Dec
(5) |
| 2014 |
Jan
(3) |
Feb
(2) |
Mar
(4) |
Apr
(3) |
May
|
Jun
(5) |
Jul
(33) |
Aug
(69) |
Sep
(35) |
Oct
(4) |
Nov
(1) |
Dec
|
|
From: <ka...@us...> - 2009-12-01 18:01:39
|
Revision: 1137
http://agate.svn.sourceforge.net/agate/?rev=1137&view=rev
Author: kanato
Date: 2009-12-01 18:01:28 +0000 (Tue, 01 Dec 2009)
Log Message:
-----------
Removed old GuiTests/ScrollBar.cs file in favor of GuiTests/ScrollBars.cs replacement.
Removed Paths:
-------------
trunk/Tests/GuiTests/ScrollBar.cs
Deleted: trunk/Tests/GuiTests/ScrollBar.cs
===================================================================
--- trunk/Tests/GuiTests/ScrollBar.cs 2009-12-01 17:59:26 UTC (rev 1136)
+++ trunk/Tests/GuiTests/ScrollBar.cs 2009-12-01 18:01:28 UTC (rev 1137)
@@ -1,59 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using AgateLib;
-using AgateLib.DisplayLib;
-using AgateLib.Geometry;
-using AgateLib.Gui;
-
-namespace Tests.GuiTests
-{
- public class ScrollBar : AgateGame, IAgateTest
- {
- public string Name
- {
- get { return "Scroll Bars"; }
- }
-
- public string Category
- {
- get { return "Gui"; }
- }
-
- public void Main(string[] args)
- {
- Run(args);
- }
-
- protected override void AdjustAppInitParameters(ref AppInitParameters initParams)
- {
- initParams.ShowSplashScreen = false;
- initParams.InitializeAudio = false;
- initParams.InitializeJoysticks = false;
-
- }
-
- protected override void Initialize()
- {
- base.GuiRoot = new GuiRoot();
-
- Window wind = new Window("Scroll Bars test");
- wind.Size = new Size(400, 300);
-
- wind.Layout = new AgateLib.Gui.Layout.VerticalBox();
-
- Panel rightPanel = new Panel();
- Label vbarValueLabel = new Label();
- rightPanel.Children.Add(vbarValueLabel);
-
- VerticalScrollBar vbar = new VerticalScrollBar();
- vbar.ValueChanged += (sender, e) => { vbarValueLabel.Text = "Vertical value: " + vbar.Value.ToString(); };
-
- wind.Children.Add(vbar);
- wind.Children.Add(rightPanel);
-
- base.GuiRoot.Children.Add(wind);
- }
- }
-}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ka...@us...> - 2009-12-01 17:59:35
|
Revision: 1136
http://agate.svn.sourceforge.net/agate/?rev=1136&view=rev
Author: kanato
Date: 2009-12-01 17:59:26 +0000 (Tue, 01 Dec 2009)
Log Message:
-----------
Implement scrollbar-mouse interaction for vertical scrollbar.
Add documentation and license information to GUI and DisplayLib files.
Modified Paths:
--------------
trunk/AgateLib/DisplayLib/Display.cs
trunk/AgateLib/DisplayLib/IndexBuffer.cs
trunk/AgateLib/DisplayLib/Shaders/AgateBuiltInShaders.cs
trunk/AgateLib/DisplayLib/Shaders/Basic2DShader.cs
trunk/AgateLib/DisplayLib/Shaders/Implementation/Basic2DImpl.cs
trunk/AgateLib/DisplayLib/Shaders/Implementation/Lighting2DImpl.cs
trunk/AgateLib/DisplayLib/Shaders/Implementation/Lighting3DImpl.cs
trunk/AgateLib/DisplayLib/Shaders/Lighting2D.cs
trunk/AgateLib/DisplayLib/Shaders/Lighting3D.cs
trunk/AgateLib/DisplayLib/Surface.cs
trunk/AgateLib/DisplayLib/SurfaceState.cs
trunk/AgateLib/DisplayLib/TextLayout.cs
trunk/AgateLib/DisplayLib/VertexBuffer.cs
trunk/AgateLib/Gui/AgateGuiException.cs
trunk/AgateLib/Gui/Button.cs
trunk/AgateLib/Gui/Cache/WidgetCache.cs
trunk/AgateLib/Gui/CheckBox.cs
trunk/AgateLib/Gui/ComboBox.cs
trunk/AgateLib/Gui/Container.cs
trunk/AgateLib/Gui/GuiRoot.cs
trunk/AgateLib/Gui/IGuiThemeEngine.cs
trunk/AgateLib/Gui/ILayoutPerformer.cs
trunk/AgateLib/Gui/Label.cs
trunk/AgateLib/Gui/Layout/BoxLayoutBase.cs
trunk/AgateLib/Gui/Layout/Grid.cs
trunk/AgateLib/Gui/Layout/HorizontalBox.cs
trunk/AgateLib/Gui/Layout/VerticalBox.cs
trunk/AgateLib/Gui/LayoutExpand.cs
trunk/AgateLib/Gui/ListBox.cs
trunk/AgateLib/Gui/Panel.cs
trunk/AgateLib/Gui/RadioButton.cs
trunk/AgateLib/Gui/ScrollBar.cs
trunk/AgateLib/Gui/TextBox.cs
trunk/AgateLib/Gui/ThemeEngines/Mercury/Cache/ScrollBarCache.cs
trunk/AgateLib/Gui/ThemeEngines/Mercury/Cache/TextBoxCache.cs
trunk/AgateLib/Gui/ThemeEngines/Mercury/Mercury.cs
trunk/AgateLib/Gui/ThemeEngines/Mercury/MercuryButton.cs
trunk/AgateLib/Gui/ThemeEngines/Mercury/MercuryCheckBox.cs
trunk/AgateLib/Gui/ThemeEngines/Mercury/MercuryGuiRoot.cs
trunk/AgateLib/Gui/ThemeEngines/Mercury/MercuryLabel.cs
trunk/AgateLib/Gui/ThemeEngines/Mercury/MercuryListBox.cs
trunk/AgateLib/Gui/ThemeEngines/Mercury/MercuryPanel.cs
trunk/AgateLib/Gui/ThemeEngines/Mercury/MercuryScheme.cs
trunk/AgateLib/Gui/ThemeEngines/Mercury/MercuryScrollBar.cs
trunk/AgateLib/Gui/ThemeEngines/Mercury/MercuryTextBox.cs
trunk/AgateLib/Gui/ThemeEngines/Mercury/MercuryWidget.cs
trunk/AgateLib/Gui/ThemeEngines/Mercury/MercuryWindow.cs
trunk/AgateLib/Gui/Widget.cs
trunk/AgateLib/Gui/WidgetList.cs
trunk/AgateLib/Gui/Window.cs
trunk/Tests/Tests.csproj
Modified: trunk/AgateLib/DisplayLib/Display.cs
===================================================================
--- trunk/AgateLib/DisplayLib/Display.cs 2009-12-01 07:06:38 UTC (rev 1135)
+++ trunk/AgateLib/DisplayLib/Display.cs 2009-12-01 17:59:26 UTC (rev 1136)
@@ -144,13 +144,6 @@
}
}
- [Obsolete]
- public static Shaders.Effect Effect
- {
- get { return null; }
- set { throw new Exception(); }
- }
-
public static Shaders.AgateShader Shader
{
get { return impl.Shader; }
Modified: trunk/AgateLib/DisplayLib/IndexBuffer.cs
===================================================================
--- trunk/AgateLib/DisplayLib/IndexBuffer.cs 2009-12-01 07:06:38 UTC (rev 1135)
+++ trunk/AgateLib/DisplayLib/IndexBuffer.cs 2009-12-01 17:59:26 UTC (rev 1136)
@@ -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/AgateLib/DisplayLib/Shaders/AgateBuiltInShaders.cs
===================================================================
--- trunk/AgateLib/DisplayLib/Shaders/AgateBuiltInShaders.cs 2009-12-01 07:06:38 UTC (rev 1135)
+++ trunk/AgateLib/DisplayLib/Shaders/AgateBuiltInShaders.cs 2009-12-01 17:59:26 UTC (rev 1136)
@@ -1,3 +1,21 @@
+// 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;
@@ -5,6 +23,9 @@
namespace AgateLib.DisplayLib.Shaders
{
+ /// <summary>
+ /// Static class containing AgateLib built in shaders.
+ /// </summary>
public static class AgateBuiltInShaders
{
internal static void InitializeShaders()
Modified: trunk/AgateLib/DisplayLib/Shaders/Basic2DShader.cs
===================================================================
--- trunk/AgateLib/DisplayLib/Shaders/Basic2DShader.cs 2009-12-01 07:06:38 UTC (rev 1135)
+++ trunk/AgateLib/DisplayLib/Shaders/Basic2DShader.cs 2009-12-01 17:59:26 UTC (rev 1136)
@@ -25,13 +25,22 @@
namespace AgateLib.DisplayLib.Shaders
{
+ /// <summary>
+ /// The default 2D shader. This shader supports no effects, and must be implemented
+ /// by every AgateLib display driver.
+ /// </summary>
public class Basic2DShader : AgateInternalShader
{
+ /// <summary>
+ /// Constructs a 2D shader.
+ /// </summary>
public Basic2DShader()
{
}
-
+ /// <summary>
+ /// Returns the implementation.
+ /// </summary>
protected new Basic2DImpl Impl
{
get { return (Basic2DImpl)base.Impl; }
@@ -42,6 +51,11 @@
get { return BuiltInShader.Basic2DShader; }
}
+ /// <summary>
+ /// Gets or sets the coordinate system used for drawing.
+ /// The default for any render target is to use a one-to-one
+ /// mapping for pixels.
+ /// </summary>
public Rectangle CoordinateSystem
{
get { return Impl.CoordinateSystem; }
Modified: trunk/AgateLib/DisplayLib/Shaders/Implementation/Basic2DImpl.cs
===================================================================
--- trunk/AgateLib/DisplayLib/Shaders/Implementation/Basic2DImpl.cs 2009-12-01 07:06:38 UTC (rev 1135)
+++ trunk/AgateLib/DisplayLib/Shaders/Implementation/Basic2DImpl.cs 2009-12-01 17:59:26 UTC (rev 1136)
@@ -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/AgateLib/DisplayLib/Shaders/Implementation/Lighting2DImpl.cs
===================================================================
--- trunk/AgateLib/DisplayLib/Shaders/Implementation/Lighting2DImpl.cs 2009-12-01 07:06:38 UTC (rev 1135)
+++ trunk/AgateLib/DisplayLib/Shaders/Implementation/Lighting2DImpl.cs 2009-12-01 17:59:26 UTC (rev 1136)
@@ -1,3 +1,21 @@
+// 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;
Modified: trunk/AgateLib/DisplayLib/Shaders/Implementation/Lighting3DImpl.cs
===================================================================
--- trunk/AgateLib/DisplayLib/Shaders/Implementation/Lighting3DImpl.cs 2009-12-01 07:06:38 UTC (rev 1135)
+++ trunk/AgateLib/DisplayLib/Shaders/Implementation/Lighting3DImpl.cs 2009-12-01 17:59:26 UTC (rev 1136)
@@ -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/AgateLib/DisplayLib/Shaders/Lighting2D.cs
===================================================================
--- trunk/AgateLib/DisplayLib/Shaders/Lighting2D.cs 2009-12-01 07:06:38 UTC (rev 1135)
+++ trunk/AgateLib/DisplayLib/Shaders/Lighting2D.cs 2009-12-01 17:59:26 UTC (rev 1136)
@@ -1,3 +1,21 @@
+// 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;
@@ -7,6 +25,9 @@
namespace AgateLib.DisplayLib.Shaders
{
+ /// <summary>
+ /// Lighting2D is the Basic2DShader with lighting effects added.
+ /// </summary>
public class Lighting2D : AgateInternalShader
{
protected override BuiltInShader BuiltInShaderType
@@ -19,20 +40,32 @@
get { return (Lighting2DImpl)base.Impl; }
}
+ /// <summary>
+ /// Gets the list of lights.
+ /// </summary>
public List<Light> Lights
{
get { return Impl.Lights; }
}
+ /// <summary>
+ /// Gets or sets the ambient light value.
+ /// </summary>
public Color AmbientLight
{
get { return Impl.AmbientLight; }
set { Impl.AmbientLight = value; }
}
+ /// <summary>
+ /// Gets the maximum number of active lights.
+ /// </summary>
public int MaxActiveLights
{
get { return Impl.MaxActiveLights; }
}
-
+ /// <summary>
+ /// Adds a light to the list.
+ /// </summary>
+ /// <param name="ptLight"></param>
public void AddLight(Light ptLight)
{
for (int i = 0; i < Lights.Count; i++)
Modified: trunk/AgateLib/DisplayLib/Shaders/Lighting3D.cs
===================================================================
--- trunk/AgateLib/DisplayLib/Shaders/Lighting3D.cs 2009-12-01 07:06:38 UTC (rev 1135)
+++ trunk/AgateLib/DisplayLib/Shaders/Lighting3D.cs 2009-12-01 17:59:26 UTC (rev 1136)
@@ -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;
@@ -7,19 +25,37 @@
namespace AgateLib.DisplayLib.Shaders
{
+ /// <summary>
+ /// Lighting3D is the basic 3D shader. Any driver with support for 3D must implement
+ /// this shader.
+ /// </summary>
public class Lighting3D : Implementation.AgateInternalShader
{
protected override BuiltInShader BuiltInShaderType
{
get { return BuiltInShader.Lighting3D; }
}
-
+ /// <summary>
+ /// Returns the implementation.
+ /// </summary>
protected new Lighting3DImpl Impl { get { return (Lighting3DImpl)base.Impl;}}
+ /// <summary>
+ /// Projection matrix for 3D view. Best obtained by Matrix4x4.Projection.
+ /// </summary>
public Matrix4x4 Projection { get { return Impl.Projection; } set { Impl.Projection = value; } }
+ /// <summary>
+ /// View matrix for 3D view. Best obtained by Matrix4x4.ViewLookAt.
+ /// </summary>
public Matrix4x4 View { get { return Impl.View; } set { Impl.View = value; } }
+ /// <summary>
+ /// World matrix for 3D view.
+ /// </summary>
public Matrix4x4 World { get { return Impl.World; } set { Impl.World= value; } }
+ /// <summary>
+ /// Set to true to enable lighting effects.
+ /// </summary>
public bool EnableLighting { get { return Impl.EnableLighting; } set { Impl.EnableLighting = value; } }
public Light[] Lights { get { return Impl.Lights; } }
public Color AmbientLight { get { return Impl.AmbientLight; } set { Impl.AmbientLight = value; } }
Modified: trunk/AgateLib/DisplayLib/Surface.cs
===================================================================
--- trunk/AgateLib/DisplayLib/Surface.cs 2009-12-01 07:06:38 UTC (rev 1135)
+++ trunk/AgateLib/DisplayLib/Surface.cs 2009-12-01 17:59:26 UTC (rev 1136)
@@ -50,12 +50,22 @@
Tga,
}
+ /// <summary>
+ /// Enum for indicating the sampling mode used when stretching or shrinking surfaces.
+ /// </summary>
public enum InterpolationMode
{
+ /// <summary>
+ /// Use whatever the driver default is.
+ /// </summary>
Default,
-
+ /// <summary>
+ /// Use the fastest method, usually nearest neighbor pixel sampling.
+ /// </summary>
Fastest,
-
+ /// <summary>
+ /// Use the nicest method, usually bilinear sampling.
+ /// </summary>
Nicest,
}
/// <summary>
@@ -114,7 +124,7 @@
/// <summary>
/// Creates a surface object, from the specified image file.
/// </summary>
- /// <param name="filename"></param>
+ /// <param name="filename">Path and file name for the image file to load.</param>
public Surface(string filename)
: this(AgateFileProvider.Images, filename)
{
@@ -122,8 +132,8 @@
/// <summary>
/// Creates a surface object using the specified file provider to open the image file.
/// </summary>
- /// <param name="filename"></param>
- /// <param name="fileProvider"></param>
+ /// <param name="filename">Path and file name for the image file to load.</param>
+ /// <param name="fileProvider">The IFileProvider object which will resolve the filename and open the stream</param>
public Surface(IFileProvider fileProvider, string filename)
{
if (Display.Impl == null)
@@ -140,7 +150,7 @@
/// <summary>
/// Creates a surface object from the data in the specified stream.
/// </summary>
- /// <param name="st"></param>
+ /// <param name="st">Stream from which to load the surface data from.</param>
public Surface(Stream st)
{
if (Display.Impl == null)
@@ -152,10 +162,11 @@
Display.PackAllSurfacesEvent += new EventHandler(Display_PackAllSurfacesEvent);
}
/// <summary>
- /// Creates a surface object of the specified size.
+ /// Creates a surface object of the specified size.
+ /// The surface is initialized to contain pixels with ARGB = (0,0,0,0).
/// </summary>
- /// <param name="width"></param>
- /// <param name="height"></param>
+ /// <param name="width">Width of the newly created surface.</param>
+ /// <param name="height">Height of the newly created surface.</param>
public Surface(int width, int height)
: this(new Size(width, height))
{
@@ -163,8 +174,9 @@
}
/// <summary>
/// Creates a surface object of the specified size.
+ /// The surface is initialized to contain pixels with ARGB = (0,0,0,0).
/// </summary>
- /// <param name="size"></param>
+ /// <param name="size">Size of the newly created surface.</param>
public Surface(Size size)
{
if (Display.Impl == null)
@@ -178,7 +190,7 @@
/// <summary>
/// Constructs a surface object from the specified PixelBuffer object.
/// </summary>
- /// <param name="pixels"></param>
+ /// <param name="pixels">The PixelBuffer containing the pixel data to use.</param>
public Surface(PixelBuffer pixels)
: this(pixels.Size)
{
@@ -254,6 +266,14 @@
/// </summary>
public Size SurfaceSize { get { return impl.SurfaceSize; } }
+ /// <summary>
+ /// Gets or sets a value indicating how to sample points from this surface.
+ /// </summary>
+ public InterpolationMode InterpolationHint
+ {
+ get { return impl.InterpolationHint; }
+ set { impl.InterpolationHint = value; }
+ }
/// <summary>
/// Gets or sets the state of the surface.
@@ -458,8 +478,8 @@
/// using all the state information defined in the properties
/// of this surface.
/// </summary>
- /// <param name="destX"></param>
- /// <param name="destY"></param>
+ /// <param name="destX">X position to draw to.</param>
+ /// <param name="destY">Y position to draw to.</param>
public void Draw(int destX, int destY)
{
mState.DrawInstances.SetCount(1);
@@ -472,8 +492,8 @@
/// using all the state information defined in the properties
/// of this surface.
/// </summary>
- /// <param name="destX"></param>
- /// <param name="destY"></param>
+ /// <param name="destX">X position to draw to.</param>
+ /// <param name="destY">Y position to draw to.</param>
public void Draw(float destX, float destY)
{
mState.DrawInstances.SetCount(1);
@@ -486,7 +506,7 @@
/// using all the state information defined in the properties
/// of this surface.
/// </summary>
- /// <param name="destPt"></param>
+ /// <param name="destPt">Destination point to draw to.</param>
public void Draw(Point destPt)
{
Draw(destPt.X, destPt.Y);
@@ -496,7 +516,7 @@
/// using all the state information defined in the properties
/// of this surface.
/// </summary>
- /// <param name="destPt"></param>
+ /// <param name="destPt">Destination point to draw to.</param>
public void Draw(Vector2 destPt)
{
Draw(destPt.X, destPt.Y);
@@ -506,7 +526,7 @@
/// using all the state information defined in the properties
/// of this surface.
/// </summary>
- /// <param name="destPt"></param>
+ /// <param name="destPt">Destination point to draw to.</param>
public void Draw(PointF destPt)
{
Draw(destPt.X, destPt.Y);
@@ -518,7 +538,7 @@
/// Ignores the value of RotationCenter and uses the specified
/// point to rotate around instead.
/// </summary>
- /// <param name="destPt"></param>
+ /// <param name="destPt">Destination point to draw to.</param>
/// <param name="rotationCenter">Center of rotation to use, relative
/// to the top-left of the surface.</param>
public void Draw(PointF destPt, PointF rotationCenter)
@@ -554,9 +574,12 @@
State.RotationCenter = oldrotation;
}
+ /// <summary>
+ /// Draws the surface using the parameters in the specified state object.
+ /// </summary>
+ /// <param name="state">The surface state information to use when drawing.</param>
public void Draw(SurfaceState state)
{
- // TODO: fix this
impl.Draw(state);
}
@@ -569,8 +592,8 @@
/// DisplayAlignment and Scaling. Color and alpha values
/// are still used.
/// </summary>
- /// <param name="srcRect"></param>
- /// <param name="destRect"></param>
+ /// <param name="srcRect">Source rectangle on the surface to draw from.</param>
+ /// <param name="destRect">Destination rectangle in the render target to draw to.</param>
public void Draw(Rectangle srcRect, Rectangle destRect)
{
if (rectState == null)
@@ -599,7 +622,7 @@
/// DisplayAlignment and Scaling. Color and alpha values
/// are still used.
/// </summary>
- /// <param name="destRect"></param>
+ /// <param name="destRect">Destination rectangle in the render target to draw to.</param>
public void Draw(Rectangle destRect)
{
Draw(new Rectangle(0, 0, SurfaceWidth, SurfaceHeight), destRect);
@@ -691,11 +714,6 @@
#region --- Surface Data Manipulation ---
- public InterpolationMode InterpolationHint
- {
- get { return impl.InterpolationHint; }
- set { impl.InterpolationHint = value; }
- }
/// <summary>
/// Saves the surface to the specified file.
@@ -704,7 +722,7 @@
/// is no extension present or it is unrecognized, PNG is
/// assumed.
/// </summary>
- /// <param name="filename"></param>
+ /// <param name="filename">File name to save to.</param>
public void SaveTo(string filename)
{
SaveTo(filename, FormatFromExtension(filename));
@@ -715,8 +733,8 @@
/// ".bmp" than the SaveTo(string) overload is prefered, as it
/// chooses a file format which is consistent with the extension.
/// </summary>
- /// <param name="filename"></param>
- /// <param name="format"></param>
+ /// <param name="filename">File name to save to.</param>
+ /// <param name="format">Image format for the target file.</param>
public void SaveTo(string filename, ImageFileFormat format)
{
impl.SaveTo(filename, format);
@@ -860,8 +878,8 @@
/// <summary>
/// Gets the object which does actual rendering of this surface.
/// This may be cast to a surface object in whatever rendering library
- /// is being used (eg. if using the MDX_1_1 library, this can be cast
- /// to an MDX1_Surface object). You only need to use this if you
+ /// is being used (eg. if using the SDX library, this can be cast
+ /// to an SDX_Surface object). You only need to use this if you
/// want to access features which are specific to the graphics library
/// you're using.
/// </summary>
Modified: trunk/AgateLib/DisplayLib/SurfaceState.cs
===================================================================
--- trunk/AgateLib/DisplayLib/SurfaceState.cs 2009-12-01 07:06:38 UTC (rev 1135)
+++ trunk/AgateLib/DisplayLib/SurfaceState.cs 2009-12-01 17:59:26 UTC (rev 1136)
@@ -25,6 +25,9 @@
namespace AgateLib.DisplayLib
{
+ /// <summary>
+ /// Surface state data used for drawing.
+ /// </summary>
public class SurfaceState
{
private SurfaceStateCache mCache;
Modified: trunk/AgateLib/DisplayLib/TextLayout.cs
===================================================================
--- trunk/AgateLib/DisplayLib/TextLayout.cs 2009-12-01 07:06:38 UTC (rev 1135)
+++ trunk/AgateLib/DisplayLib/TextLayout.cs 2009-12-01 17:59:26 UTC (rev 1136)
@@ -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/AgateLib/DisplayLib/VertexBuffer.cs
===================================================================
--- trunk/AgateLib/DisplayLib/VertexBuffer.cs 2009-12-01 07:06:38 UTC (rev 1135)
+++ trunk/AgateLib/DisplayLib/VertexBuffer.cs 2009-12-01 17:59:26 UTC (rev 1136)
@@ -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/AgateLib/Gui/AgateGuiException.cs
===================================================================
--- trunk/AgateLib/Gui/AgateGuiException.cs 2009-12-01 07:06:38 UTC (rev 1135)
+++ trunk/AgateLib/Gui/AgateGuiException.cs 2009-12-01 17:59:26 UTC (rev 1136)
@@ -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;
@@ -6,19 +24,32 @@
namespace AgateLib.Gui
{
+ /// <summary>
+ /// Exception which is thrown when there is an error in the AgateLib Gui.
+ /// </summary>
[global::System.Serializable]
public class AgateGuiException : AgateException
{
- //
- // For guidelines regarding the creation of new exception types, see
- // http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconerrorraisinghandlingguidelines.asp
- // and
- // http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dncscol/html/csharp07192001.asp
- //
-
+ /// <summary>
+ /// Constructs a new AgateGuiException.
+ /// </summary>
public AgateGuiException() { }
+ /// <summary>
+ /// Constructs a new AgateGuiException.
+ /// </summary>
+ /// <param name="message"></param>
public AgateGuiException(string message) : base(message) { }
+ /// <summary>
+ /// Constructs a new AgateGuiException.
+ /// </summary>
+ /// <param name="message"></param>
+ /// <param name="inner"></param>
public AgateGuiException(string message, Exception inner) : base(message, inner) { }
+ /// <summary>
+ /// Constructs a new AgateGuiException.
+ /// </summary>
+ /// <param name="info"></param>
+ /// <param name="context"></param>
protected AgateGuiException(
System.Runtime.Serialization.SerializationInfo info,
System.Runtime.Serialization.StreamingContext context)
Modified: trunk/AgateLib/Gui/Button.cs
===================================================================
--- trunk/AgateLib/Gui/Button.cs 2009-12-01 07:06:38 UTC (rev 1135)
+++ trunk/AgateLib/Gui/Button.cs 2009-12-01 17:59:26 UTC (rev 1136)
@@ -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;
@@ -6,6 +24,10 @@
namespace AgateLib.Gui
{
+ /// <summary>
+ /// Class for a button in the GUI. A button is a very simple "command" interface, which
+ /// the user can click on to activate.
+ /// </summary>
public class Button : Widget
{
public Button() { Name = "Button"; }
Modified: trunk/AgateLib/Gui/Cache/WidgetCache.cs
===================================================================
--- trunk/AgateLib/Gui/Cache/WidgetCache.cs 2009-12-01 07:06:38 UTC (rev 1135)
+++ trunk/AgateLib/Gui/Cache/WidgetCache.cs 2009-12-01 17:59:26 UTC (rev 1136)
@@ -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/AgateLib/Gui/CheckBox.cs
===================================================================
--- trunk/AgateLib/Gui/CheckBox.cs 2009-12-01 07:06:38 UTC (rev 1135)
+++ trunk/AgateLib/Gui/CheckBox.cs 2009-12-01 17:59:26 UTC (rev 1136)
@@ -1,10 +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.Linq;
using System.Text;
namespace AgateLib.Gui
{
+ /// <summary>
+ /// A checkbox object.
+ /// </summary>
public class CheckBox : Widget
{
public CheckBox()
Modified: trunk/AgateLib/Gui/ComboBox.cs
===================================================================
--- trunk/AgateLib/Gui/ComboBox.cs 2009-12-01 07:06:38 UTC (rev 1135)
+++ trunk/AgateLib/Gui/ComboBox.cs 2009-12-01 17:59:26 UTC (rev 1136)
@@ -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/AgateLib/Gui/Container.cs
===================================================================
--- trunk/AgateLib/Gui/Container.cs 2009-12-01 07:06:38 UTC (rev 1135)
+++ trunk/AgateLib/Gui/Container.cs 2009-12-01 17:59:26 UTC (rev 1136)
@@ -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/AgateLib/Gui/GuiRoot.cs
===================================================================
--- trunk/AgateLib/Gui/GuiRoot.cs 2009-12-01 07:06:38 UTC (rev 1135)
+++ trunk/AgateLib/Gui/GuiRoot.cs 2009-12-01 17:59:26 UTC (rev 1136)
@@ -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/AgateLib/Gui/IGuiThemeEngine.cs
===================================================================
--- trunk/AgateLib/Gui/IGuiThemeEngine.cs 2009-12-01 07:06:38 UTC (rev 1135)
+++ trunk/AgateLib/Gui/IGuiThemeEngine.cs 2009-12-01 17:59:26 UTC (rev 1136)
@@ -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/AgateLib/Gui/ILayoutPerformer.cs
===================================================================
--- trunk/AgateLib/Gui/ILayoutPerformer.cs 2009-12-01 07:06:38 UTC (rev 1135)
+++ trunk/AgateLib/Gui/ILayoutPerformer.cs 2009-12-01 17:59:26 UTC (rev 1136)
@@ -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/AgateLib/Gui/Label.cs
===================================================================
--- trunk/AgateLib/Gui/Label.cs 2009-12-01 07:06:38 UTC (rev 1135)
+++ trunk/AgateLib/Gui/Label.cs 2009-12-01 17:59:26 UTC (rev 1136)
@@ -1,13 +1,42 @@
-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;
namespace AgateLib.Gui
{
+ /// <summary>
+ /// A label displays a text string for the user. It has no decorations
+ /// and does not interact with the user at all.
+ /// </summary>
public class Label : Widget
{
+ /// <summary>
+ /// Constructs a label.
+ /// </summary>
public Label() { Name = "Label"; }
+ /// <summary>
+ /// Constructs a label.
+ /// </summary>
+ /// <param name="text">The initial text used in the label.</param>
public Label(string text)
{
Name = text;
@@ -16,6 +45,9 @@
TextAlignment = AgateLib.DisplayLib.OriginAlignment.CenterLeft;
}
+ /// <summary>
+ /// Gets or sets where the text should be aligned to.
+ /// </summary>
public DisplayLib.OriginAlignment TextAlignment { get; set; }
}
}
Modified: trunk/AgateLib/Gui/Layout/BoxLayoutBase.cs
===================================================================
--- trunk/AgateLib/Gui/Layout/BoxLayoutBase.cs 2009-12-01 07:06:38 UTC (rev 1135)
+++ trunk/AgateLib/Gui/Layout/BoxLayoutBase.cs 2009-12-01 17:59:26 UTC (rev 1136)
@@ -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;
@@ -6,321 +24,321 @@
namespace AgateLib.Gui.Layout
{
- public abstract class BoxLayoutBase : ILayoutPerformer
- {
- bool doingLayout = false;
- List<int> sizes = new List<int>();
- Container container;
+ public abstract class BoxLayoutBase : ILayoutPerformer
+ {
+ bool doingLayout = false;
+ List<int> sizes = new List<int>();
+ Container container;
- public Size RecalcMinSize(Container container)
- {
- this.container = container;
- return RecalcMinSizeInternal();
- }
+ public Size RecalcMinSize(Container container)
+ {
+ this.container = container;
+ return RecalcMinSizeInternal();
+ }
- protected Size RecalcMinSizeBox(bool horizontal)
- {
- _horizontal = horizontal;
+ protected Size RecalcMinSizeBox(bool horizontal)
+ {
+ _horizontal = horizontal;
- Size minSize = new Size();
- int totalSize = 0;
+ Size minSize = new Size();
+ int totalSize = 0;
- foreach (Widget child in container.Children)
- {
- child.RecalcSizeRange();
+ foreach (Widget child in container.Children)
+ {
+ child.RecalcSizeRange();
- minSize.Width = Math.Max(minSize.Width, child.MinSize.Width + child.ThemeMargin * 2);
- minSize.Height = Math.Max(minSize.Height, child.MinSize.Height + child.ThemeMargin * 2);
+ minSize.Width = Math.Max(minSize.Width, child.MinSize.Width + child.ThemeMargin * 2);
+ minSize.Height = Math.Max(minSize.Height, child.MinSize.Height + child.ThemeMargin * 2);
- totalSize += GetMinSize(child) + child.ThemeMargin * 2;
- }
+ totalSize += GetMinSize(child) + child.ThemeMargin * 2;
+ }
- return SetSize(minSize, totalSize);
- }
+ return SetSize(minSize, totalSize);
+ }
- public void DoLayout(Container container)
- {
- if (doingLayout)
- return;
+ public void DoLayout(Container container)
+ {
+ if (doingLayout)
+ return;
- this.container = container;
+ this.container = container;
- try
- {
- doingLayout = true;
+ try
+ {
+ doingLayout = true;
- DoLayoutInternal();
- }
- finally
- {
- doingLayout = false;
- }
- }
+ DoLayoutInternal();
+ }
+ finally
+ {
+ doingLayout = false;
+ }
+ }
- protected abstract void DoLayoutInternal();
- protected abstract Size RecalcMinSizeInternal();
+ protected abstract void DoLayoutInternal();
+ protected abstract Size RecalcMinSizeInternal();
- bool _horizontal;
- protected void DoBoxLayout(bool horizontal)
- {
- _horizontal = horizontal;
-
- int containerSize = GetContainerSize();
- int totalMinSize = 0;
- int expandCount = 0;
- int shrinkCount = 0;
- sizes.Clear();
+ bool _horizontal;
+ protected void DoBoxLayout(bool horizontal)
+ {
+ _horizontal = horizontal;
- foreach (Widget child in container.Children.VisibleItems)
- {
- int minSize = GetMinSize(child) + child.ThemeMargin * 2;
-
- switch (child.LayoutExpand)
- {
- case LayoutExpand.Default:
- totalMinSize += minSize;
- break;
+ int containerSize = GetContainerSize();
+ int totalMinSize = 0;
+ int expandCount = 0;
+ int shrinkCount = 0;
+ sizes.Clear();
- case LayoutExpand.ExpandToMax:
- expandCount++;
- break;
+ foreach (Widget child in container.Children.VisibleItems)
+ {
+ int minSize = GetMinSize(child) + child.ThemeMargin * 2;
- case LayoutExpand.ShrinkToMin:
- totalMinSize += minSize;
- shrinkCount++;
- break;
- }
- }
+ switch (child.LayoutExpand)
+ {
+ case LayoutExpand.Default:
+ totalMinSize += minSize;
+ break;
- int extraSpace = containerSize - totalMinSize;
- if (extraSpace < 0)
- extraSpace = 0;
+ case LayoutExpand.ExpandToMax:
+ expandCount++;
+ break;
- if (expandCount == 0)
- {
- if (shrinkCount < container.Children.VisibleItems.Count()
- && extraSpace > 0)
- {
- int expandSize = extraSpace /
- (container.Children.VisibleItems.Count() - shrinkCount);
+ case LayoutExpand.ShrinkToMin:
+ totalMinSize += minSize;
+ shrinkCount++;
+ break;
+ }
+ }
- ShareSpace(expandSize);
- }
- else
- ShareSpaceEqually(extraSpace);
+ int extraSpace = containerSize - totalMinSize;
+ if (extraSpace < 0)
+ extraSpace = 0;
- }
- else
- {
- int expandSize = extraSpace / expandCount;
+ if (expandCount == 0)
+ {
+ if (shrinkCount < container.Children.VisibleItems.Count()
+ && extraSpace > 0)
+ {
+ int expandSize = extraSpace /
+ (container.Children.VisibleItems.Count() - shrinkCount);
- SetMinSizes(expandSize);
- }
- }
+ ShareSpace(expandSize);
+ }
+ else
+ ShareSpaceEqually(extraSpace);
- private void SetMinSizes(int expandSize)
- {
- int loc = 0;
+ }
+ else
+ {
+ int expandSize = extraSpace / expandCount;
- foreach (Widget child in container.Children.VisibleItems)
- {
- int size;
- loc += child.ThemeMargin;
+ SetMinSizes(expandSize);
+ }
+ }
- switch (child.LayoutExpand)
- {
- case LayoutExpand.Default:
- case LayoutExpand.ShrinkToMin:
- size = GetMinSize(child);
- break;
+ private void SetMinSizes(int expandSize)
+ {
+ int loc = 0;
- case LayoutExpand.ExpandToMax:
- size = expandSize;
- break;
+ foreach (Widget child in container.Children.VisibleItems)
+ {
+ int size;
+ loc += child.ThemeMargin;
- default:
- throw new NotImplementedException();
- }
+ switch (child.LayoutExpand)
+ {
+ case LayoutExpand.Default:
+ case LayoutExpand.ShrinkToMin:
+ size = GetMinSize(child);
+ break;
- if (loc + size > GetSize(container.Size))
- throw new AgateGuiException("Container size is not right.");
+ case LayoutExpand.ExpandToMax:
+ size = expandSize;
+ break;
- SetLocation(child, loc);
- SetSize(child, size);
+ default:
+ throw new NotImplementedException();
+ }
- loc += size + child.ThemeMargin;
- }
- }
+ if (loc + size > GetSize(container.Size))
+ throw new AgateGuiException("Container size is not right.");
- private void ShareSpace(int extraSpace)
- {
- int loc = 0;
- int containerSize = GetContainerSize();
+ SetLocation(child, loc);
+ SetSize(child, size);
- int totalExtraSpace = 0;
- int nonMaxedControls = 0;
- foreach (Widget child in container.Children.VisibleItems)
- {
- int size = GetMinSize(child);
- int maxSize = GetMaxSize(child);
+ loc += size + child.ThemeMargin;
+ }
+ }
- if (size + extraSpace > maxSize)
- {
- totalExtraSpace += size + extraSpace - maxSize;
- }
- else
- nonMaxedControls++;
- }
+ private void ShareSpace(int extraSpace)
+ {
+ int loc = 0;
+ int containerSize = GetContainerSize();
- foreach (Widget child in container.Children.VisibleItems)
- {
- loc += child.ThemeMargin;
+ int totalExtraSpace = 0;
+ int nonMaxedControls = 0;
+ foreach (Widget child in container.Children.VisibleItems)
+ {
+ int size = GetMinSize(child);
+ int maxSize = GetMaxSize(child);
- int size = GetMinSize(child);
- int maxSize = GetMaxSize(child);
+ if (size + extraSpace > maxSize)
+ {
+ totalExtraSpace += size + extraSpace - maxSize;
+ }
+ else
+ nonMaxedControls++;
+ }
- if (child.LayoutExpand != LayoutExpand.ShrinkToMin)
- size += extraSpace;
+ foreach (Widget child in container.Children.VisibleItems)
+ {
+ loc += child.ThemeMargin;
- if (size > maxSize)
- size = maxSize;
- else if (nonMaxedControls > 0 && totalExtraSpace > 0)
- {
- size += totalExtraSpace / nonMaxedControls;
- }
+ int size = GetMinSize(child);
+ int maxSize = GetMaxSize(child);
- SetLocation(child, loc);
- SetSize(child, size);
+ if (child.LayoutExpand != LayoutExpand.ShrinkToMin)
+ size += extraSpace;
- loc += size + child.ThemeMargin;
- }
+ if (size > maxSize)
+ size = maxSize;
+ else if (nonMaxedControls > 0 && totalExtraSpace > 0)
+ {
+ size += totalExtraSpace / nonMaxedControls;
+ }
- }
- private void ShareSpaceEqually(int extraSpace)
- {
- if (extraSpace < 0)
- throw new ArgumentOutOfRangeException("extraSpace must be positive.");
+ SetLocation(child, loc);
+ SetSize(child, size);
- int loc = 0;
- int containerSize = GetContainerSize();
- int expandSize = extraSpace / container.Children.VisibleItems.Count();
+ loc += size + child.ThemeMargin;
+ }
- foreach (Widget child in container.Children.VisibleItems)
- {
- int minSize = GetMinSize(child);
- int size;
- loc += child.ThemeMargin;
+ }
+ private void ShareSpaceEqually(int extraSpace)
+ {
+ if (extraSpace < 0)
+ throw new ArgumentOutOfRangeException("extraSpace must be positive.");
- if (child.LayoutExpand == LayoutExpand.ShrinkToMin)
- size = minSize;
- else
- size = minSize + expandSize;
+ int loc = 0;
+ int containerSize = GetContainerSize();
+ int expandSize = extraSpace / container.Children.VisibleItems.Count();
- SetLocation(child, loc);
- SetSize(child, size);
+ foreach (Widget child in container.Children.VisibleItems)
+ {
+ int minSize = GetMinSize(child);
+ int size;
+ loc += child.ThemeMargin;
- loc += size + child.ThemeMargin;
- }
-
- }
- int GetSize(Size size)
- {
- if (_horizontal)
- return size.Width;
- else
- return size.Height;
- }
- int GetMinSize(Widget widget)
- {
- return GetSize(widget.MinSize);
- }
- int GetMaxSize(Widget widget)
- {
- return GetSize(widget.MaxSize);
- }
+ if (child.LayoutExpand == LayoutExpand.ShrinkToMin)
+ size = minSize;
+ else
+ size = minSize + expandSize;
- private Size SetSize(Size size, int value)
- {
- if (_horizontal)
- return new Size(value, size.Height);
- else
- return new Size(size.Width, value);
- }
- void SetSize(Widget widget, int value)
- {
+ SetLocation(child, loc);
+ SetSize(child, size);
+
+ loc += size + child.ThemeMargin;
+ }
+
+ }
+ int GetSize(Size size)
+ {
if (_horizontal)
+ return size.Width;
+ else
+ return size.Height;
+ }
+ int GetMinSize(Widget widget)
+ {
+ return GetSize(widget.MinSize);
+ }
+ int GetMaxSize(Widget widget)
+ {
+ return GetSize(widget.MaxSize);
+ }
+
+ private Size SetSize(Size size, int value)
+ {
+ if (_horizontal)
+ return new Size(value, size.Height);
+ else
+ return new Size(size.Width, value);
+ }
+ void SetSize(Widget widget, int value)
+ {
+ if (_horizontal)
widget.Size = new Size(value, Math.Min(widget.MaxSize.Height, container.ClientArea.Height - widget.ThemeMargin * 2));
else
widget.Size = new Size(Math.Min(widget.MaxSize.Width, container.ClientArea.Width - widget.ThemeMargin * 2), value);
- }
- void SetLocation(Widget widget, int value)
- {
- if (_horizontal)
- widget.Location = new Point(value, widget.ThemeMargin);
- else
- widget.Location = new Point(widget.ThemeMargin, value);
- }
+ }
+ void SetLocation(Widget widget, int value)
+ {
+ if (_horizontal)
+ widget.Location = new Point(value, widget.ThemeMargin);
+ else
+ widget.Location = new Point(widget.ThemeMargin, value);
+ }
- int GetContainerSize()
- {
- if (_horizontal)
- return container.ClientArea.Width;
- else
- return container.ClientArea.Height;
- }
+ int GetContainerSize()
+ {
+ if (_horizontal)
+ return container.ClientArea.Width;
+ else
+ return container.ClientArea.Height;
+ }
- public virtual bool AcceptInputKey(AgateLib.InputLib.KeyCode keyCode)
- {
- return false;
+ public virtual bool AcceptInputKey(AgateLib.InputLib.KeyCode keyCode)
+ {
+ return false;
- }
+ }
- protected GuiRoot Root(Widget widget)
- {
- if (widget is GuiRoot)
- return (GuiRoot)widget;
- else
- return Root(widget.Parent);
- }
- protected int GetParentIndex(Container container, Widget widget)
- {
- if (widget is GuiRoot)
- throw new AgateGuiException("Specified widget is not a child of the container.");
+ protected GuiRoot Root(Widget widget)
+ {
+ if (widget is GuiRoot)
+ return (GuiRoot)widget;
+ else
+ return Root(widget.Parent);
+ }
+ protected int GetParentIndex(Container container, Widget widget)
+ {
+ if (widget is GuiRoot)
+ throw new AgateGuiException("Specified widget is not a child of the container.");
- if (widget.Parent == container)
- return container.Children.IndexOf(widget);
- else
- return GetParentIndex(container, widget.Parent);
- }
+ if (widget.Parent == container)
+ return container.Children.IndexOf(widget);
+ else
+ return GetParentIndex(container, widget.Parent);
+ }
- public abstract Widget CanMoveFocus(Container container, Widget currentFocus, Direction direction);
+ public abstract Widget CanMoveFocus(Container container, Widget currentFocus, Direction direction);
- protected Widget GetNextChild(Container container, int index, int direction)
- {
- for (index += direction; index >= 0 && index < container.Children.Count; index += direction)
- {
- Widget child = container.Children[index];
+ protected Widget GetNextChild(Container container, int index, int direction)
+ {
+ for (index += direction; index >= 0 && index < container.Children.Count; index += direction)
+ {
+ Widget child = container.Children[index];
- if (child is Container)
- {
- if (((Container)child).AnyChildCanHaveFocus)
- return child;
- }
- if (child.CanHaveFocus == false)
- continue;
- if (child.Enabled == false)
- continue;
+ if (child is Container)
+ {
+ if (((Container)child).AnyChildCanHaveFocus)
+ return child;
+ }
+ if (child.CanHaveFocus == false)
+ continue;
+ if (child.Enabled == false)
+ continue;
- return child;
- }
+ return child;
+ }
- return null;
- }
+ return null;
+ }
- }
+ }
}
Modified: trunk/AgateLib/Gui/Layout/Grid.cs
===================================================================
--- trunk/AgateLib/Gui/Layout/Grid.cs 2009-12-01 07:06:38 UTC (rev 1135)
+++ trunk/AgateLib/Gui/Layout/Grid.cs 2009-12-01 17:59:26 UTC (rev 1136)
@@ -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;
@@ -6,36 +24,36 @@
namespace AgateLib.Gui.Layout
{
- public class Grid : ILayoutPerformer
- {
+ public class Grid : ILayoutPerformer
+ {
- public bool DoingLayout
- ...
[truncated message content] |
|
From: <ka...@us...> - 2009-12-01 07:06:48
|
Revision: 1135
http://agate.svn.sourceforge.net/agate/?rev=1135&view=rev
Author: kanato
Date: 2009-12-01 07:06:38 +0000 (Tue, 01 Dec 2009)
Log Message:
-----------
Include missing files from last commit.
Added Paths:
-----------
trunk/AgateLib/Gui/ThemeEngines/Mercury/Cache/ScrollBarCache.cs
trunk/AgateLib/Gui/ThemeEngines/Mercury/MercuryGuiRoot.cs
trunk/AgateLib/Gui/ThemeEngines/Mercury/MercuryLabel.cs
trunk/AgateLib/Gui/ThemeEngines/Mercury/MercuryPanel.cs
trunk/AgateLib/Gui/ThemeEngines/Mercury/MercuryWidget.cs
Removed Paths:
-------------
trunk/AgateLib/Gui/ThemeEngines/Mercury/MercurySchemeCommon.cs
Added: trunk/AgateLib/Gui/ThemeEngines/Mercury/Cache/ScrollBarCache.cs
===================================================================
--- trunk/AgateLib/Gui/ThemeEngines/Mercury/Cache/ScrollBarCache.cs (rev 0)
+++ trunk/AgateLib/Gui/ThemeEngines/Mercury/Cache/ScrollBarCache.cs 2009-12-01 07:06:38 UTC (rev 1135)
@@ -0,0 +1,22 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using AgateLib.Geometry;
+using AgateLib.Gui.Cache;
+
+namespace AgateLib.Gui.ThemeEngines.Mercury.Cache
+{
+ class ScrollBarCache : WidgetCache
+ {
+ public bool DownInDecrease { get; set; }
+ public bool DownInIncrease { get; set; }
+ public bool DownInPageDecrease { get; set; }
+ public bool DownInPageIncrease { get; set; }
+
+ public double LastUpdate { get; set; }
+
+ public bool DragThumb { get; set; }
+ public Point ThumbGrabSpot { get; set; }
+ }
+}
Added: trunk/AgateLib/Gui/ThemeEngines/Mercury/MercuryGuiRoot.cs
===================================================================
--- trunk/AgateLib/Gui/ThemeEngines/Mercury/MercuryGuiRoot.cs (rev 0)
+++ trunk/AgateLib/Gui/ThemeEngines/Mercury/MercuryGuiRoot.cs 2009-12-01 07:06:38 UTC (rev 1135)
@@ -0,0 +1,18 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace AgateLib.Gui.ThemeEngines.Mercury
+{
+ public class MercuryGuiRoot : MercuryWidget
+ {
+ public MercuryGuiRoot(MercuryScheme scheme)
+ : base(scheme)
+ { }
+
+ public override void DrawWidget(Widget w)
+ {
+ }
+ }
+}
Added: trunk/AgateLib/Gui/ThemeEngines/Mercury/MercuryLabel.cs
===================================================================
--- trunk/AgateLib/Gui/ThemeEngines/Mercury/MercuryLabel.cs (rev 0)
+++ trunk/AgateLib/Gui/ThemeEngines/Mercury/MercuryLabel.cs 2009-12-01 07:06:38 UTC (rev 1135)
@@ -0,0 +1,46 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using AgateLib.DisplayLib;
+using AgateLib.Geometry;
+
+namespace AgateLib.Gui.ThemeEngines.Mercury
+{
+ public class MercuryLabel : MercuryWidget
+ {
+ public MercuryLabel(MercuryScheme scheme)
+ : base(scheme)
+ { }
+
+ public override void DrawWidget(Widget w)
+ {
+ DrawLabel((Label)w);
+ }
+ public void DrawLabel(Label label)
+ {
+ Point location = new Point();
+
+ location = DisplayLib.Origin.Calc(label.TextAlignment, label.Size);
+ location.X += label.ScreenLocation.X;
+ location.Y += label.ScreenLocation.Y;
+
+ SetControlFontColor(label);
+
+ WidgetFont.DisplayAlignment = label.TextAlignment;
+ WidgetFont.DrawText(location, label.Text);
+ }
+
+ public override Size MinSize(Widget w)
+ {
+ return CalcMinLabelSize((Label)w);
+ }
+ public Size CalcMinLabelSize(Label label)
+ {
+ Size retval = WidgetFont.MeasureString(label.Text);
+
+ return retval;
+ }
+
+ }
+}
Added: trunk/AgateLib/Gui/ThemeEngines/Mercury/MercuryPanel.cs
===================================================================
--- trunk/AgateLib/Gui/ThemeEngines/Mercury/MercuryPanel.cs (rev 0)
+++ trunk/AgateLib/Gui/ThemeEngines/Mercury/MercuryPanel.cs 2009-12-01 07:06:38 UTC (rev 1135)
@@ -0,0 +1,17 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace AgateLib.Gui.ThemeEngines.Mercury
+{
+ public class MercuryPanel : MercuryWidget
+ {
+ public MercuryPanel(MercuryScheme scheme)
+ : base(scheme)
+ { }
+ public override void DrawWidget(Widget w)
+ {
+ }
+ }
+}
Deleted: trunk/AgateLib/Gui/ThemeEngines/Mercury/MercurySchemeCommon.cs
===================================================================
--- trunk/AgateLib/Gui/ThemeEngines/Mercury/MercurySchemeCommon.cs 2009-12-01 07:05:35 UTC (rev 1134)
+++ trunk/AgateLib/Gui/ThemeEngines/Mercury/MercurySchemeCommon.cs 2009-12-01 07:06:38 UTC (rev 1135)
@@ -1,69 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-
-namespace AgateLib.Gui.ThemeEngines.Mercury
-{
-
- public class MercurySchemeCommon
- {
- protected internal static void DrawStretchImage(Point loc, Size size,
- Surface surface, Rectangle stretchRegion)
- {
- Rectangle scaled = new Rectangle(
- loc.X + stretchRegion.X,
- loc.Y + stretchRegion.Y,
- size.Width - (surface.SurfaceWidth - stretchRegion.Right) - stretchRegion.X,
- size.Height - (surface.SurfaceHeight - stretchRegion.Bottom) - stretchRegion.Y);
-
- // draw top left
- surface.Draw(
- new Rectangle(0, 0, stretchRegion.Left, stretchRegion.Top),
- new Rectangle(loc.X, loc.Y, stretchRegion.Left, stretchRegion.Top));
-
- // draw top middle
- surface.Draw(
- new Rectangle(stretchRegion.Left, 0, stretchRegion.Width, stretchRegion.Top),
- new Rectangle(loc.X + stretchRegion.Left, loc.Y,
- scaled.Width, stretchRegion.Top));
-
- // draw top right
- surface.Draw(
- new Rectangle(stretchRegion.Right, 0, surface.SurfaceWidth - stretchRegion.Right, stretchRegion.Top),
- new Rectangle(scaled.Right, loc.Y, surface.SurfaceWidth - stretchRegion.Right, stretchRegion.Top));
-
- // draw middle left
- surface.Draw(
- new Rectangle(0, stretchRegion.Top, stretchRegion.Left, stretchRegion.Height),
- new Rectangle(loc.X, loc.Y + stretchRegion.Top, stretchRegion.Left, scaled.Height));
-
- // draw middle
- surface.Draw(
- stretchRegion,
- scaled);
-
- // draw middle right
- surface.Draw(
- new Rectangle(stretchRegion.Right, stretchRegion.Top, surface.SurfaceWidth - stretchRegion.Right, stretchRegion.Height),
- new Rectangle(scaled.Right, scaled.Top, surface.SurfaceWidth - stretchRegion.Right, scaled.Height));
-
- // draw bottom left
- surface.Draw(
- new Rectangle(0, stretchRegion.Bottom, stretchRegion.Left, surface.SurfaceHeight - stretchRegion.Bottom),
- new Rectangle(loc.X, scaled.Bottom, stretchRegion.Left, surface.SurfaceHeight - stretchRegion.Bottom));
-
- // draw bottom middle
- surface.Draw(
- new Rectangle(stretchRegion.Left, stretchRegion.Bottom, stretchRegion.Width, surface.SurfaceHeight - stretchRegion.Bottom),
- new Rectangle(scaled.Left, scaled.Bottom, scaled.Width, surface.SurfaceHeight - stretchRegion.Bottom));
-
- // draw bottom right
- surface.Draw(
- new Rectangle(stretchRegion.Right, stretchRegion.Bottom, surface.SurfaceWidth - stretchRegion.Right, surface.SurfaceHeight - stretchRegion.Bottom),
- new Rectangle(scaled.Right, scaled.Bottom, surface.SurfaceWidth - stretchRegion.Right, surface.SurfaceHeight - stretchRegion.Bottom));
-
- }
-
- }
-}
Added: trunk/AgateLib/Gui/ThemeEngines/Mercury/MercuryWidget.cs
===================================================================
--- trunk/AgateLib/Gui/ThemeEngines/Mercury/MercuryWidget.cs (rev 0)
+++ trunk/AgateLib/Gui/ThemeEngines/Mercury/MercuryWidget.cs 2009-12-01 07:06:38 UTC (rev 1135)
@@ -0,0 +1,135 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using AgateLib.DisplayLib;
+using AgateLib.Geometry;
+
+namespace AgateLib.Gui.ThemeEngines.Mercury
+{
+ public abstract class MercuryWidget
+ {
+ MercuryScheme scheme;
+
+ public MercuryWidget(MercuryScheme scheme)
+ {
+ this.scheme = scheme;
+ }
+
+ public int Margin { get; set; }
+ //public MercuryScheme Scheme
+ //{
+ // get { return scheme; }
+ //}
+
+ protected internal static void DrawStretchImage(Point loc, Size size,
+ Surface surface, Rectangle stretchRegion)
+ {
+ Rectangle scaled = new Rectangle(
+ loc.X + stretchRegion.X,
+ loc.Y + stretchRegion.Y,
+ size.Width - (surface.SurfaceWidth - stretchRegion.Right) - stretchRegion.X,
+ size.Height - (surface.SurfaceHeight - stretchRegion.Bottom) - stretchRegion.Y);
+
+ // draw top left
+ surface.Draw(
+ new Rectangle(0, 0, stretchRegion.Left, stretchRegion.Top),
+ new Rectangle(loc.X, loc.Y, stretchRegion.Left, stretchRegion.Top));
+
+ // draw top middle
+ surface.Draw(
+ new Rectangle(stretchRegion.Left, 0, stretchRegion.Width, stretchRegion.Top),
+ new Rectangle(loc.X + stretchRegion.Left, loc.Y,
+ scaled.Width, stretchRegion.Top));
+
+ // draw top right
+ surface.Draw(
+ new Rectangle(stretchRegion.Right, 0, surface.SurfaceWidth - stretchRegion.Right, stretchRegion.Top),
+ new Rectangle(scaled.Right, loc.Y, surface.SurfaceWidth - stretchRegion.Right, stretchRegion.Top));
+
+ // draw middle left
+ surface.Draw(
+ new Rectangle(0, stretchRegion.Top, stretchRegion.Left, stretchRegion.Height),
+ new Rectangle(loc.X, loc.Y + stretchRegion.Top, stretchRegion.Left, scaled.Height));
+
+ // draw middle
+ surface.Draw(
+ stretchRegion,
+ scaled);
+
+ // draw middle right
+ surface.Draw(
+ new Rectangle(stretchRegion.Right, stretchRegion.Top, surface.SurfaceWidth - stretchRegion.Right, stretchRegion.Height),
+ new Rectangle(scaled.Right, scaled.Top, surface.SurfaceWidth - stretchRegion.Right, scaled.Height));
+
+ // draw bottom left
+ surface.Draw(
+ new Rectangle(0, stretchRegion.Bottom, stretchRegion.Left, surface.SurfaceHeight - stretchRegion.Bottom),
+ new Rectangle(loc.X, scaled.Bottom, stretchRegion.Left, surface.SurfaceHeight - stretchRegion.Bottom));
+
+ // draw bottom middle
+ surface.Draw(
+ new Rectangle(stretchRegion.Left, stretchRegion.Bottom, stretchRegion.Width, surface.SurfaceHeight - stretchRegion.Bottom),
+ new Rectangle(scaled.Left, scaled.Bottom, scaled.Width, surface.SurfaceHeight - stretchRegion.Bottom));
+
+ // draw bottom right
+ surface.Draw(
+ new Rectangle(stretchRegion.Right, stretchRegion.Bottom, surface.SurfaceWidth - stretchRegion.Right, surface.SurfaceHeight - stretchRegion.Bottom),
+ new Rectangle(scaled.Right, scaled.Bottom, surface.SurfaceWidth - stretchRegion.Right, surface.SurfaceHeight - stretchRegion.Bottom));
+
+ }
+
+ protected void SetControlFontColor(Widget widget)
+ {
+ if (widget.Enabled)
+ WidgetFont.Color = FontColor;
+ else
+ WidgetFont.Color = FontColorDisabled;
+ }
+
+ protected FontSurface WidgetFont { get { return scheme.WidgetFont; } }
+ protected FontSurface TitleFont { get { return scheme.TitleFont; } }
+
+ protected Color FontColor { get { return scheme.FontColor; } }
+ protected Color FontColorDisabled { get { return scheme.FontColorDisabled; } }
+
+ protected Size StretchRegionFixedSize(Size imageSize, Rectangle stretchRegion)
+ {
+ return new Size(
+ imageSize.Width - stretchRegion.Width,
+ imageSize.Height - stretchRegion.Height);
+ }
+
+ protected int InsertionPointHeight { get { return scheme.InsertionPointHeight; } }
+ protected int InsertionPointBlinkTime { get { return scheme.InsertionPointBlinkTime; } }
+
+ public virtual Size MinSize(Widget w)
+ {
+ return new Size(0, 0);
+ }
+ public virtual Size MaxSize(Widget w)
+ {
+ return new Size(int.MaxValue / 2, int.MaxValue / 2);
+ }
+ public abstract void DrawWidget(Widget w);
+ public virtual bool HitTest(Widget w, Point clientLocation)
+ {
+ return true;
+ }
+
+ public virtual Rectangle ClientArea(Container widget)
+ {
+ return new Rectangle(Point.Empty, widget.Size);
+ }
+
+ public virtual void MouseDownInWidget(Widget widget, Point clientLocation)
+ {
+ }
+ public virtual void MouseMoveInWidget(Widget widget, Point clientLocation)
+ {
+ }
+ public virtual void MouseUpInWidget(Widget widget, Point clientLocation)
+ {
+ }
+ }
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ka...@us...> - 2009-12-01 07:05:46
|
Revision: 1134
http://agate.svn.sourceforge.net/agate/?rev=1134&view=rev
Author: kanato
Date: 2009-12-01 07:05:35 +0000 (Tue, 01 Dec 2009)
Log Message:
-----------
Refactor Mercury so that separate classes handle rendering of controls.
Modified Paths:
--------------
trunk/AgateLib/AgateLib.csproj
trunk/AgateLib/Gui/Layout/BoxLayoutBase.cs
trunk/AgateLib/Gui/TextBox.cs
trunk/AgateLib/Gui/ThemeEngines/Mercury/Mercury.cs
trunk/AgateLib/Gui/ThemeEngines/Mercury/MercuryButton.cs
trunk/AgateLib/Gui/ThemeEngines/Mercury/MercuryCheckBox.cs
trunk/AgateLib/Gui/ThemeEngines/Mercury/MercuryListBox.cs
trunk/AgateLib/Gui/ThemeEngines/Mercury/MercuryScheme.cs
trunk/AgateLib/Gui/ThemeEngines/Mercury/MercuryScrollBar.cs
trunk/AgateLib/Gui/ThemeEngines/Mercury/MercuryTextBox.cs
trunk/AgateLib/Gui/ThemeEngines/Mercury/MercuryWindow.cs
trunk/AgateLib/Gui/Widget.cs
trunk/AgateLib/ImplementationBase/FontSurfaceImpl.cs
Modified: trunk/AgateLib/AgateLib.csproj
===================================================================
--- trunk/AgateLib/AgateLib.csproj 2009-11-28 02:57:18 UTC (rev 1133)
+++ trunk/AgateLib/AgateLib.csproj 2009-12-01 07:05:35 UTC (rev 1134)
@@ -129,14 +129,18 @@
<Compile Include="Gui\Panel.cs" />
<Compile Include="Gui\RadioButton.cs" />
<Compile Include="Gui\TextBox.cs" />
+ <Compile Include="Gui\ThemeEngines\Mercury\Cache\ScrollBarCache.cs" />
<Compile Include="Gui\ThemeEngines\Mercury\Cache\TextBoxCache.cs" />
<Compile Include="Gui\ThemeEngines\Mercury\Mercury.cs" />
<Compile Include="Gui\ThemeEngines\Mercury\MercuryButton.cs" />
<Compile Include="Gui\ThemeEngines\Mercury\MercuryCheckBox.cs" />
+ <Compile Include="Gui\ThemeEngines\Mercury\MercuryGuiRoot.cs" />
+ <Compile Include="Gui\ThemeEngines\Mercury\MercuryLabel.cs" />
<Compile Include="Gui\ThemeEngines\Mercury\MercuryListBox.cs" />
+ <Compile Include="Gui\ThemeEngines\Mercury\MercuryPanel.cs" />
<Compile Include="Gui\ThemeEngines\Mercury\MercuryScheme.cs" />
<Compile Include="Gui\ScrollBar.cs" />
- <Compile Include="Gui\ThemeEngines\Mercury\MercurySchemeCommon.cs" />
+ <Compile Include="Gui\ThemeEngines\Mercury\MercuryWidget.cs" />
<Compile Include="Gui\ThemeEngines\Mercury\MercuryScrollBar.cs" />
<Compile Include="Gui\ThemeEngines\Mercury\MercuryTextBox.cs" />
<Compile Include="Gui\ThemeEngines\Mercury\MercuryWindow.cs" />
Modified: trunk/AgateLib/Gui/Layout/BoxLayoutBase.cs
===================================================================
--- trunk/AgateLib/Gui/Layout/BoxLayoutBase.cs 2009-11-28 02:57:18 UTC (rev 1133)
+++ trunk/AgateLib/Gui/Layout/BoxLayoutBase.cs 2009-12-01 07:05:35 UTC (rev 1134)
@@ -250,10 +250,10 @@
}
void SetSize(Widget widget, int value)
{
- if (_horizontal)
- widget.Size = new Size(value, container.ClientArea.Height - widget.ThemeMargin * 2);
- else
- widget.Size = new Size(container.ClientArea.Width - widget.ThemeMargin * 2, value);
+ if (_horizontal)
+ widget.Size = new Size(value, Math.Min(widget.MaxSize.Height, container.ClientArea.Height - widget.ThemeMargin * 2));
+ else
+ widget.Size = new Size(Math.Min(widget.MaxSize.Width, container.ClientArea.Width - widget.ThemeMargin * 2), value);
}
void SetLocation(Widget widget, int value)
{
Modified: trunk/AgateLib/Gui/TextBox.cs
===================================================================
--- trunk/AgateLib/Gui/TextBox.cs 2009-11-28 02:57:18 UTC (rev 1133)
+++ trunk/AgateLib/Gui/TextBox.cs 2009-12-01 07:05:35 UTC (rev 1134)
@@ -55,10 +55,7 @@
protected internal override void SendMouseMove(InputEventArgs e)
{
base.SendMouseMove(e);
- if (Root != null)
- {
- Root.ThemeEngine.MouseMoveInWidget(this, PointToClient(e.MousePosition));
- }
+
}
protected internal override void SendMouseUp(InputEventArgs e)
{
Modified: trunk/AgateLib/Gui/ThemeEngines/Mercury/Mercury.cs
===================================================================
--- trunk/AgateLib/Gui/ThemeEngines/Mercury/Mercury.cs 2009-11-28 02:57:18 UTC (rev 1133)
+++ trunk/AgateLib/Gui/ThemeEngines/Mercury/Mercury.cs 2009-12-01 07:05:35 UTC (rev 1134)
@@ -36,7 +36,7 @@
if (widget is Container)
UpdateCaches((Container)widget);
else if (widget is TextBox)
- UpdateCache((TextBox)widget);
+ Scheme.TextBox.UpdateCache((TextBox)widget);
}
}
@@ -55,15 +55,7 @@
Color.Red);
}
- if (widget is Window) DrawWindow((Window)widget);
- if (widget is Label) DrawLabel((Label)widget);
- if (widget is Button) DrawButton((Button)widget);
- if (widget is CheckBox) DrawCheckbox((CheckBox)widget);
- if (widget is RadioButton) DrawRadioButton((RadioButton)widget);
- if (widget is TextBox) DrawTextBox((TextBox)widget);
- if (widget is ListBox) DrawListBox((ListBox)widget);
- if (widget is VerticalScrollBar) Scheme.VerticalScrollBar.DrawScrollBar((ScrollBar)widget);
- if (widget is HorizontalScrollBar) Scheme.HorizontalScrollBar.DrawScrollBar((ScrollBar)widget);
+ Scheme.Themer(widget).DrawWidget(widget);
}
@@ -73,708 +65,41 @@
}
public Size CalcMinSize(Widget widget)
{
- if (widget is Label) return CalcMinLabelSize((Label)widget);
- if (widget is Button) return CalcMinButtonSize((Button)widget);
- if (widget is CheckBox) return CalcMinCheckBoxSize((CheckBox)widget);
- if (widget is TextBox) return CalcTextBoxMinSize((TextBox)widget);
- if (widget is RadioButton) return CalcMinRadioButtonSize((RadioButton)widget);
- if (widget is VerticalScrollBar) return Scheme.VerticalScrollBar.CalcMinScrollBarSize((ScrollBar)widget);
- if (widget is HorizontalScrollBar) return Scheme.HorizontalScrollBar.CalcMinScrollBarSize((ScrollBar)widget);
-
- return Size.Empty;
+ return Scheme.Themer(widget).MinSize(widget);
}
-
public Size CalcMaxSize(Widget widget)
{
- if (widget is TextBox) return CalcTextBoxMaxSize((TextBox)widget);
-
- return new Size(int.MaxValue, int.MinValue);
+ return Scheme.Themer(widget).MaxSize(widget);
}
public bool HitTest(Widget widget, Point screenLocation)
{
- if (widget is Button) return HitTestButton((Button)widget, screenLocation);
- if (widget is CheckBox) return HitTestCheckBox((CheckBox)widget, screenLocation);
- if (widget is TextBox) return HitTestTextBox((TextBox)widget, screenLocation);
+ Point client = widget.PointToClient(screenLocation);
- return true;
+ return Scheme.Themer(widget).HitTest(widget, client);
}
public int ThemeMargin(Widget widget)
{
- if (widget is Button) return Scheme.Button.Margin;
- if (widget is CheckBox) return Scheme.CheckBox.Margin;
- if (widget is TextBox) return Scheme.TextBox.Margin;
-
- return 0;
+ return Scheme.Themer(widget).Margin;
}
public void MouseDownInWidget(Widget widget, Point clientLocation)
{
- if (widget is TextBox) MouseDownInTextBox((TextBox)widget, clientLocation);
- if (widget is VerticalScrollBar) Scheme.VerticalScrollBar.MouseDownInScrollBar((ScrollBar)widget, clientLocation);
- if (widget is HorizontalScrollBar) Scheme.HorizontalScrollBar.MouseDownInScrollBar((ScrollBar)widget, clientLocation);
-
+ Scheme.Themer(widget).MouseDownInWidget(widget, clientLocation);
}
public void MouseMoveInWidget(Widget widget, Point clientLocation)
{
- if (widget is TextBox) MouseMoveInTextBox((TextBox)widget, clientLocation);
- if (widget is VerticalScrollBar) Scheme.VerticalScrollBar.MouseMoveInScrollBar((ScrollBar)widget, clientLocation);
- if (widget is HorizontalScrollBar) Scheme.HorizontalScrollBar.MouseMoveInScrollBar((ScrollBar)widget, clientLocation);
+ Scheme.Themer(widget).MouseMoveInWidget(widget, clientLocation);
}
public void MouseUpInWidget(Widget widget, Point clientLocation)
{
- if (widget is TextBox) MouseUpInTextBox((TextBox)widget, clientLocation);
- if (widget is VerticalScrollBar) Scheme.VerticalScrollBar.MouseUpInScrollBar((ScrollBar)widget, clientLocation);
- if (widget is HorizontalScrollBar) Scheme.HorizontalScrollBar.MouseUpInScrollBar((ScrollBar)widget, clientLocation);
+ Scheme.Themer(widget).MouseUpInWidget(widget, clientLocation);
}
#endregion
- #region --- ListBox ---
- private void DrawListBox(ListBox listBox)
- {
- Surface image = Scheme.ListBox.Image;
-
- if (listBox.Enabled == false)
- image = Scheme.ListBox.Disabled;
-
- Point location = listBox.PointToScreen(new Point(0, 0));
- Size size = listBox.Size;
-
- DrawStretchImage(location, size,
- image, Scheme.TextBox.StretchRegion);
- }
-
- #endregion
- #region --- TextBox ---
-
- private void MouseDownInTextBox(TextBox textBox, Point clientLocation)
- {
- textBox.MoveInsertionPoint(
- TextBoxClientToTextLocation(textBox, clientLocation), false);
-
- }
- private void MouseMoveInTextBox(TextBox textBox, Point clientLocation)
- {
- if (textBox.MouseDownIn)
- {
- textBox.MoveInsertionPoint(
- TextBoxClientToTextLocation(textBox, clientLocation), true);
- }
- }
- private void MouseUpInTextBox(TextBox textBox, Point clientLocation)
- {
-
- }
-
- private static TextBoxCache GetTextBoxCache(TextBox textBox)
- {
- if (textBox.Cache == null)
- textBox.Cache = new TextBoxCache();
-
- return (TextBoxCache)textBox.Cache;
- }
- private void UpdateCache(TextBox textBox)
- {
- TextBoxCache c = GetTextBoxCache(textBox);
-
- if (c.Dirty == false)
- return;
-
- Size fixedSize = StretchRegionFixedSize(Scheme.TextBox.Image.SurfaceSize,
- Scheme.TextBox.StretchRegion);
-
- Size surfSize = new Size(textBox.Size.Width - fixedSize.Width,
- textBox.Size.Height - fixedSize.Height);
-
- if (c.TextBoxFrameBuffer == null || c.TextBoxFrameBuffer.Size != surfSize)
- {
- if (c.TextBoxFrameBuffer != null)
- c.TextBoxFrameBuffer.Dispose();
-
- c.TextBoxFrameBuffer = new FrameBuffer(surfSize);
- c.Origin = Point.Empty;
- }
-
- Point ip = InsertionPointLocation(textBox);
- ip.X -= Scheme.TextBox.StretchRegion.X;
- ip.Y -= Scheme.TextBox.StretchRegion.Y;
- int bottom = ip.Y + Scheme.InsertionPointHeight;
-
- if (ip.Y < 0)
- c.Origin.Y += ip.Y;
- if (bottom > surfSize.Height)
- c.Origin.Y += bottom - surfSize.Height;
- if (ip.X < 0)
- c.Origin.X += ip.X;
- if (ip.X >= surfSize.Width)
- c.Origin.X += ip.X - surfSize.Width + 1;
-
- FrameBuffer old = Display.RenderTarget;
- Display.RenderTarget = c.TextBoxFrameBuffer;
- Display.RenderState.AlphaBlend = false;
- Display.BeginFrame();
-
- Display.Clear(Color.FromArgb(0,0,0,0));
-
- if (textBox.Enabled)
- Scheme.WidgetFont.Color = Scheme.FontColor;
- else
- Scheme.WidgetFont.Color = Scheme.FontColorDisabled;
-
- Scheme.WidgetFont.DrawText(-c.Origin.X, -c.Origin.Y, textBox.Text);
-
- Display.EndFrame();
- Display.RenderTarget = old;
- Display.RenderState.AlphaBlend = true;
-
- c.Dirty = false;
- }
-
- private void DrawTextBox(TextBox textBox)
- {
- Surface image = Scheme.TextBox.Image;
-
- if (textBox.Enabled == false)
- image = Scheme.TextBox.Disabled;
-
- Point location = textBox.PointToScreen(new Point(0, 0));
- Size size = textBox.Size;
-
- DrawStretchImage(location, size,
- image, Scheme.TextBox.StretchRegion);
-
- if (textBox.Enabled)
- {
- if (textBox.HasFocus)
- {
- DrawStretchImage(location, size,
- Scheme.TextBox.Focus, Scheme.TextBox.StretchRegion);
- }
- if (textBox.MouseIn)
- {
- DrawStretchImage(location, size,
- Scheme.TextBox.Hover, Scheme.TextBox.StretchRegion);
- }
- }
-
- Scheme.WidgetFont.DisplayAlignment = OriginAlignment.TopLeft;
-
- SetControlFontColor(textBox);
-
- location.X += Scheme.TextBox.StretchRegion.X;
- location.Y += Scheme.TextBox.StretchRegion.Y;
-
- TextBoxCache c = (TextBoxCache)textBox.Cache;
-
- if (c == null || c.TextBoxSurface == null)
- {
- Scheme.WidgetFont.DrawText(
- location,
- textBox.Text);
- }
- else
- {
- c.TextBoxSurface.Draw(location);
- }
-
- if (textBox.HasFocus)
- {
- Point loc = InsertionPointLocation(textBox);
-
- loc = textBox.PointToScreen(loc);
-
- DrawInsertionPoint(textBox, loc, Scheme.InsertionPointHeight,
- Timing.TotalMilliseconds - textBox.IPTime);
- }
- }
-
- private int TextBoxClientToTextLocation(TextBox textBox, Point clientLocation)
- {
- TextBoxCache c = GetTextBoxCache(textBox);
-
- clientLocation.X += c.Origin.X - Scheme.TextBox.StretchRegion.X;
- clientLocation.Y += c.Origin.Y - Scheme.TextBox.StretchRegion.Y;
-
- Size sz = Size.Empty;
- int last = 0;
- int index;
-
- int line = clientLocation.Y / Scheme.WidgetFont.FontHeight;
- int linestart = 0;
- for (index = 0; index < textBox.Text.Length; index++)
- {
- if (textBox.Text[index] == '\n')
- {
- if (index < textBox.Text.Length - 1)
- index++;
-
- line--;
- linestart = index;
- }
-
- if (line == 0)
- goto searchX;
- }
-
- // we only get here if the mouse click was below the last line.
- index = linestart;
-
- searchX:
- for (; index < textBox.Text.Length; index++)
- {
- sz = Scheme.WidgetFont.MeasureString(textBox.Text.Substring(linestart, index - linestart));
-
- if (textBox.Text[index] == '\n')
- {
- break;
- }
-
- if (sz.Width > clientLocation.X)
- {
- goto found;
- }
-
- last = sz.Width;
-
- }
-
- found:
- double pass = (sz.Width - clientLocation.X) / (double)(sz.Width - last);
-
- // if it's halfway over, put the insertion on the right side of the character,
- // otherwise put it on the left.
- if (pass <= 0.5)
- return index;
- else
- return index - 1;
- }
-
- /// <summary>
- /// Returns the local insertion point location in the textbox in pixels.
- /// </summary>
- /// <param name="textBox"></param>
- /// <returns></returns>
- private Point InsertionPointLocation(TextBox textBox)
- {
- int lineStart = 0;
- int lines = 0;
-
- if (textBox.MultiLine)
- {
- for (int i = 0; i < textBox.InsertionPoint; i++)
- {
- if (textBox.Text[i] == '\n')
- {
- lineStart = i;
- lines++;
- }
- }
- }
-
- Size sz = Scheme.WidgetFont.StringDisplaySize(
- textBox.Text.Substring(lineStart, textBox.InsertionPoint - lineStart));
-
- Point loc = new Point(
- sz.Width + Scheme.TextBox.StretchRegion.X,
- lines * Scheme.WidgetFont.FontHeight + Scheme.TextBox.StretchRegion.Y);
-
- TextBoxCache c = textBox.Cache as TextBoxCache;
-
- if (c != null)
- {
- loc.X -= c.Origin.X;
- loc.Y -= c.Origin.Y;
- }
-
- loc.Y++;
-
- return loc;
- }
-
- private void DrawInsertionPoint(Widget widget, Point location, int size, double time)
- {
- int val = (int)time / Scheme.InsertionPointBlinkTime;
-
- if (val % 2 == 1)
- return;
-
- Display.DrawLine(location,
- new Point(location.X, location.Y + size),
- Scheme.WidgetFont.Color);
- }
-
- private Size CalcTextBoxMinSize(TextBox textBox)
- {
- Size retval = new Size();
-
- retval.Width = 40;
- retval.Height = Scheme.WidgetFont.FontHeight;
- retval.Height += Scheme.TextBox.Image.SurfaceHeight - Scheme.TextBox.StretchRegion.Height;
-
- return retval;
- }
- private Size CalcTextBoxMaxSize(TextBox textBox)
- {
- Size retval = CalcTextBoxMinSize(textBox);
-
- retval.Width = 9000;
-
- if (textBox.MultiLine)
- retval.Height = 9000;
-
- return retval;
- }
-
- private bool HitTestTextBox(TextBox textBox, Point screenLocation)
- {
- Point local = textBox.PointToClient(screenLocation);
-
- return true;
- }
-
- #endregion
- #region --- CheckBox ---
-
- private void DrawCheckbox(CheckBox checkbox)
- {
- Surface surf;
-
- if (checkbox.Enabled == false)
- surf = Scheme.CheckBox.Disabled;
- else
- surf = Scheme.CheckBox.Image;
-
- Point destPoint = checkbox.PointToScreen(
- Origin.Calc(OriginAlignment.CenterLeft, checkbox.Size));
-
- surf.DisplayAlignment = OriginAlignment.CenterLeft;
- surf.Draw(destPoint);
-
- if (checkbox.Enabled)
- {
- if (checkbox.HasFocus)
- {
- Scheme.CheckBox.Focus.DisplayAlignment = OriginAlignment.CenterLeft;
- Scheme.CheckBox.Focus.Draw(destPoint);
- }
- if (checkbox.MouseIn)
- {
- Scheme.CheckBox.Hover.DisplayAlignment = OriginAlignment.CenterLeft;
- Scheme.CheckBox.Hover.Draw(destPoint);
- }
- if (checkbox.Checked)
- {
- Scheme.CheckBox.Check.Color = Color.White;
- Scheme.CheckBox.Check.DisplayAlignment = OriginAlignment.CenterLeft;
- Scheme.CheckBox.Check.Draw(destPoint);
- }
- }
- else if (checkbox.Checked)
- {
- Scheme.CheckBox.Check.Color = Color.Gray;
- Scheme.CheckBox.Check.DisplayAlignment = OriginAlignment.CenterLeft;
- Scheme.CheckBox.Check.Draw(destPoint);
- }
-
- SetControlFontColor(checkbox);
-
- destPoint.X += surf.DisplayWidth + Scheme.CheckBox.Spacing;
-
- Scheme.WidgetFont.DisplayAlignment = OriginAlignment.CenterLeft;
- Scheme.WidgetFont.DrawText(destPoint, checkbox.Text);
- }
- private Size CalcMinCheckBoxSize(CheckBox checkbox)
- {
- Size text = Scheme.WidgetFont.StringDisplaySize(checkbox.Text);
- Size box = Scheme.CheckBox.Image.SurfaceSize;
-
- return new Size(
- box.Width + Scheme.CheckBox.Spacing + text.Width,
- Math.Max(box.Height, text.Height));
- }
- private bool HitTestCheckBox(CheckBox checkBox, Point screenLocation)
- {
- Point local = checkBox.PointToClient(screenLocation);
-
- int right = Scheme.CheckBox.Image.SurfaceWidth +
- Scheme.WidgetFont.StringDisplayWidth(checkBox.Text) + Scheme.CheckBox.Spacing * 2;
-
- if (local.X > right)
- return false;
-
- return true;
- }
-
- #endregion
- #region --- Radio Button ---
-
- private void DrawRadioButton(RadioButton radiobutton)
- {
- Surface surf;
-
- if (radiobutton.Enabled == false)
- surf = Scheme.RadioButton.Disabled;
- else
- surf = Scheme.RadioButton.Image;
-
- Point destPoint = radiobutton.PointToScreen(
- Origin.Calc(OriginAlignment.CenterLeft, radiobutton.Size));
-
- surf.DisplayAlignment = OriginAlignment.CenterLeft;
- surf.Draw(destPoint);
-
- if (radiobutton.Enabled)
- {
- if (radiobutton.HasFocus)
- {
- Scheme.RadioButton.Focus.DisplayAlignment = OriginAlignment.CenterLeft;
- Scheme.RadioButton.Focus.Draw(destPoint);
- }
- if (radiobutton.MouseIn)
- {
- Scheme.RadioButton.Hover.DisplayAlignment = OriginAlignment.CenterLeft;
- Scheme.RadioButton.Hover.Draw(destPoint);
- }
- if (radiobutton.Checked)
- {
- Scheme.RadioButton.Check.Color = Color.White;
- Scheme.RadioButton.Check.DisplayAlignment = OriginAlignment.CenterLeft;
- Scheme.RadioButton.Check.Draw(destPoint);
- }
- }
- else if (radiobutton.Checked)
- {
- Scheme.RadioButton.Check.Color = Scheme.FontColorDisabled;
- Scheme.RadioButton.Check.DisplayAlignment = OriginAlignment.CenterLeft;
- Scheme.RadioButton.Check.Draw(destPoint);
- }
-
- SetControlFontColor(radiobutton);
-
- destPoint.X += surf.DisplayWidth + Scheme.RadioButton.Spacing;
-
- Scheme.WidgetFont.DisplayAlignment = OriginAlignment.CenterLeft;
- Scheme.WidgetFont.DrawText(destPoint, radiobutton.Text);
- }
-
- private Size CalcMinRadioButtonSize(RadioButton radiobutton)
- {
- Size text = Scheme.WidgetFont.StringDisplaySize(radiobutton.Text);
- Size box = Scheme.RadioButton.Image.SurfaceSize;
-
- return new Size(
- box.Width + Scheme.RadioButton.Spacing + text.Width,
- Math.Max(box.Height, text.Height));
- }
-
-
- private bool HitTestRadioButton(RadioButton radioButton, Point screenLocation)
- {
- Point local = radioButton.PointToClient(screenLocation);
-
- int right = Scheme.RadioButton.Image.SurfaceWidth +
- Scheme.WidgetFont.StringDisplayWidth(radioButton.Text) + Scheme.RadioButton.Spacing * 2;
-
- if (local.X > right)
- return false;
-
- return true;
- }
-
-
- #endregion
- #region --- Label ---
-
- private void DrawLabel(Label label)
- {
- Point location = new Point();
-
- location = DisplayLib.Origin.Calc(label.TextAlignment, label.Size);
- location.X += label.ScreenLocation.X;
- location.Y += label.ScreenLocation.Y;
-
- SetControlFontColor(label);
-
- Scheme.WidgetFont.DisplayAlignment = label.TextAlignment;
- Scheme.WidgetFont.DrawText(location, label.Text);
- }
-
- private Size CalcMinLabelSize(Label label)
- {
- Size retval = Scheme.WidgetFont.StringDisplaySize(label.Text);
-
- return retval;
- }
-
- #endregion
- #region --- Button ---
-
- private void DrawButton(Button button)
- {
- Surface image = Scheme.Button.Image;
-
- bool isDefault = button.IsDefaultButton;
-
- if (button.Enabled == false)
- image = Scheme.Button.Disabled;
- else if (button.DrawActivated)
- image = Scheme.Button.Pressed;
- else if (isDefault)
- image = Scheme.Button.Default;
-
- Point location = button.PointToScreen(Point.Empty);
- Size size = new Size(button.Width, button.Height);
-
- DrawStretchImage(location, size,
- image, Scheme.Button.StretchRegion);
-
- if (button.Enabled)
- {
- if (button.MouseIn)
- {
- DrawStretchImage(location, size,
- Scheme.Button.Hover, Scheme.Button.StretchRegion);
- }
- if (button.HasFocus)
- {
- DrawStretchImage(location, size,
- Scheme.Button.Focus, Scheme.Button.StretchRegion);
- }
- }
-
-
- // Draw button text
- SetControlFontColor(button);
-
- Scheme.WidgetFont.DisplayAlignment = OriginAlignment.Center;
- location = Origin.Calc(OriginAlignment.Center, button.Size);
-
- // drop the text down a bit if the button is being pushed.
- if (button.DrawActivated)
- {
- location.X++;
- location.Y++;
- }
-
- Scheme.WidgetFont.DrawText(
- button.PointToScreen(location),
- button.Text);
- }
-
- private Size CalcMinButtonSize(Button button)
- {
- Size textSize = Scheme.WidgetFont.StringDisplaySize(button.Text);
- Size buttonBorder = new Size(
- Scheme.Button.Image.SurfaceWidth - Scheme.Button.StretchRegion.Width,
- Scheme.Button.Image.SurfaceHeight - Scheme.Button.StretchRegion.Height);
-
- textSize.Width += Scheme.Button.TextPadding * 2;
- textSize.Height += Scheme.Button.TextPadding * 2;
-
- return new Size(
- textSize.Width + buttonBorder.Width,
- textSize.Height + buttonBorder.Height);
- }
-
- private bool HitTestButton(Button button, Point screenLocation)
- {
- Point local = button.PointToClient(screenLocation);
-
- return true;
- }
-
- #endregion
- #region --- Window ---
-
- public void DrawWindow(Window window)
- {
- DrawWindowBackground(window);
- DrawWindowTitle(window);
- DrawWindowDecorations(window);
- }
-
- // TODO: fix this
- public int WindowTitlebarSize
- {
- get { return Scheme.TitleFont.FontHeight + 6; }
- }
-
- protected virtual void DrawWindowBackground(Window window)
- {
- if (window.ShowTitleBar)
- {
- DrawStretchImage(window.Parent.PointToScreen(
- new Point(window.Location.X, window.Location.Y + this.WindowTitlebarSize)),
- window.Size, Scheme.Window.WithTitle, Scheme.Window.WithTitleStretchRegion);
-
- }
- else
- throw new NotImplementedException();
- }
-
- private void DrawDropShadow(Rectangle rect)
- {
- for (int i = 0; i <= Scheme.DropShadowSize; i++)
- {
- Color fadeColor = Color.Red;// Scheme.WindowBorderColor;
- fadeColor.A = (byte)(
- fadeColor.A * (Scheme.DropShadowSize - i) / (2 * Scheme.DropShadowSize));
-
- Display.DrawRect(rect, fadeColor);
-
- rect.X--;
- rect.Y--;
- rect.Width += 2;
- rect.Height += 2;
- }
- }
- protected virtual void DrawWindowTitle(Window window)
- {
- Point windowLocation = window.ScreenLocation;
-
- DrawStretchImage(windowLocation,
- new Size(window.Width, WindowTitlebarSize), Scheme.Window.TitleBar,
- Scheme.Window.TitleBarStretchRegion);
-
- Point fontPosition = new Point(windowLocation.X + 8, windowLocation.Y + 3);
- if (Scheme.Window.CenterTitle)
- {
- fontPosition.X = windowLocation.X + window.Width / 2;
- fontPosition.Y = windowLocation.Y + WindowTitlebarSize / 2;
- Scheme.TitleFont.DisplayAlignment = OriginAlignment.Center;
- }
-
- Scheme.TitleFont.Color = Scheme.FontColor;
-
- Scheme.TitleFont.DrawText(
- fontPosition,
- window.Text);
-
- Scheme.TitleFont.DisplayAlignment = OriginAlignment.TopLeft;
- }
- protected virtual void DrawWindowDecorations(Window window)
- {
- Scheme.Window.CloseButton.DisplayAlignment = OriginAlignment.TopRight;
- Scheme.Window.CloseButton.Draw(
- new Point(window.ScreenLocation.X + window.Size.Width,
- window.ScreenLocation.Y));
- }
-
- #endregion
-
-
- //private bool PointInMargin(Widget widget, Point localPoint, int margin)
- //{
- // if (localPoint.X < margin) return true;
- // if (localPoint.Y < margin) return true;
- // if (localPoint.X >= widget.Width - margin) return true;
- // if (localPoint.Y >= widget.Height - margin) return true;
-
- // return false;
- //}
-
+ [Obsolete]
private Size StretchRegionFixedSize(Size imageSize, Rectangle stretchRegion)
{
return new Size(
@@ -839,35 +164,10 @@
}
+
public Rectangle GetClientArea(Container widget)
{
- if (widget is Window) return GetWindowClientArea((Window)widget);
-
- return new Rectangle(Point.Empty, widget.Size);
+ return Scheme.Themer(widget).ClientArea(widget);
}
- public Rectangle GetWindowClientArea(Window widget)
- {
- if (widget.ShowTitleBar)
- {
- return new Rectangle(
- Scheme.Window.WithTitleStretchRegion.Left,
- Scheme.Window.WithTitleStretchRegion.Top + WindowTitlebarSize,
- widget.Width - (Scheme.Window.WithTitle.SurfaceWidth - Scheme.Window.WithTitleStretchRegion.Width),
- widget.Height - (Scheme.Window.WithTitle.SurfaceHeight - Scheme.Window.WithTitleStretchRegion.Height));
- }
- else
- {
- throw new NotImplementedException();
- }
- }
-
- private void SetControlFontColor(Widget widget)
- {
- if (widget.Enabled)
- Scheme.WidgetFont.Color = Scheme.FontColor;
- else
- Scheme.WidgetFont.Color = Scheme.FontColorDisabled;
- }
-
}
}
\ No newline at end of file
Modified: trunk/AgateLib/Gui/ThemeEngines/Mercury/MercuryButton.cs
===================================================================
--- trunk/AgateLib/Gui/ThemeEngines/Mercury/MercuryButton.cs 2009-11-28 02:57:18 UTC (rev 1133)
+++ trunk/AgateLib/Gui/ThemeEngines/Mercury/MercuryButton.cs 2009-12-01 07:05:35 UTC (rev 1134)
@@ -2,10 +2,12 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
+using AgateLib.DisplayLib;
+using AgateLib.Geometry;
namespace AgateLib.Gui.ThemeEngines.Mercury
{
- public class MercuryButton : MercurySchemeCommon
+ public class MercuryButton : MercuryWidget
{
public Rectangle StretchRegion { get; set; }
public Surface Image { get; set; }
@@ -15,7 +17,88 @@
public Surface Hover { get; set; }
public Surface Focus { get; set; }
public int TextPadding { get; set; }
- public int Margin { get; set; }
+
+ public MercuryButton(MercuryScheme scheme)
+ : base(scheme)
+ { }
+
+ public override void DrawWidget(Widget w)
+ {
+ DrawButton((Button)w);
+ }
+ public void DrawButton(Button button)
+ {
+ Surface image = Image;
+
+ bool isDefault = button.IsDefaultButton;
+
+ if (button.Enabled == false)
+ image = Disabled;
+ else if (button.DrawActivated)
+ image = Pressed;
+ else if (isDefault)
+ image = Default;
+
+ Point location = button.PointToScreen(Point.Empty);
+ Size size = new Size(button.Width, button.Height);
+
+ DrawStretchImage(location, size,
+ image, StretchRegion);
+
+ if (button.Enabled)
+ {
+ if (button.MouseIn)
+ {
+ DrawStretchImage(location, size, Hover, StretchRegion);
+ }
+ if (button.HasFocus)
+ {
+ DrawStretchImage(location, size,
+ Focus, StretchRegion);
+ }
+ }
+
+
+ // Draw button text
+ SetControlFontColor(button);
+
+ WidgetFont.DisplayAlignment = OriginAlignment.Center;
+ location = Origin.Calc(OriginAlignment.Center, button.Size);
+
+ // drop the text down a bit if the button is being pushed.
+ if (button.DrawActivated)
+ {
+ location.X++;
+ location.Y++;
+ }
+
+ WidgetFont.DrawText(
+ button.PointToScreen(location),
+ button.Text);
+ }
+
+ public override Size MinSize(Widget w)
+ {
+ return CalcMinButtonSize((Button)w);
+ }
+ public Size CalcMinButtonSize(Button button)
+ {
+ Size textSize = WidgetFont.MeasureString(button.Text);
+ Size buttonBorder = new Size(
+ Image.SurfaceWidth - StretchRegion.Width,
+ Image.SurfaceHeight - StretchRegion.Height);
+
+ textSize.Width += TextPadding * 2;
+ textSize.Height += TextPadding * 2;
+
+ return new Size(
+ textSize.Width + buttonBorder.Width,
+ textSize.Height + buttonBorder.Height);
+ }
+
+ public override bool HitTest(Widget w, Point screenLocation)
+ {
+ return true;
+ }
}
-
}
Modified: trunk/AgateLib/Gui/ThemeEngines/Mercury/MercuryCheckBox.cs
===================================================================
--- trunk/AgateLib/Gui/ThemeEngines/Mercury/MercuryCheckBox.cs 2009-11-28 02:57:18 UTC (rev 1133)
+++ trunk/AgateLib/Gui/ThemeEngines/Mercury/MercuryCheckBox.cs 2009-12-01 07:05:35 UTC (rev 1134)
@@ -2,10 +2,12 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
+using AgateLib.DisplayLib;
+using AgateLib.Geometry;
namespace AgateLib.Gui.ThemeEngines.Mercury
{
- public class MercuryCheckBox : MercurySchemeCommon
+ public class MercuryCheckBox : MercuryWidget
{
public Surface Image { get; set; }
public Surface Disabled { get; set; }
@@ -13,12 +15,140 @@
public Surface Hover { get; set; }
public Surface Focus { get; set; }
public int Spacing { get; set; }
- public int Margin { get; set; }
-
- public MercuryCheckBox()
+
+ public MercuryCheckBox(MercuryScheme scheme)
+ : base(scheme)
{
Spacing = 5;
Margin = 2;
}
+
+ public override void DrawWidget(Widget w)
+ {
+ if (w is CheckBox)
+ DrawCheckbox((CheckBox)w);
+ else
+ DrawRadioButton((RadioButton)w);
+ }
+ public void DrawCheckbox(CheckBox checkbox)
+ {
+ Surface surf;
+
+ if (checkbox.Enabled == false)
+ surf = Disabled;
+ else
+ surf = Image;
+
+ Point destPoint = checkbox.PointToScreen(
+ Origin.Calc(OriginAlignment.CenterLeft, checkbox.Size));
+
+ surf.DisplayAlignment = OriginAlignment.CenterLeft;
+ surf.Draw(destPoint);
+
+ if (checkbox.Enabled)
+ {
+ if (checkbox.HasFocus)
+ {
+ Focus.DisplayAlignment = OriginAlignment.CenterLeft;
+ Focus.Draw(destPoint);
+ }
+ if (checkbox.MouseIn)
+ {
+ Hover.DisplayAlignment = OriginAlignment.CenterLeft;
+ Hover.Draw(destPoint);
+ }
+ if (checkbox.Checked)
+ {
+ Check.Color = Color.White;
+ Check.DisplayAlignment = OriginAlignment.CenterLeft;
+ Check.Draw(destPoint);
+ }
+ }
+ else if (checkbox.Checked)
+ {
+ Check.Color = Color.Gray;
+ Check.DisplayAlignment = OriginAlignment.CenterLeft;
+ Check.Draw(destPoint);
+ }
+
+ SetControlFontColor(checkbox);
+
+ destPoint.X += surf.DisplayWidth + Spacing;
+
+ WidgetFont.DisplayAlignment = OriginAlignment.CenterLeft;
+ WidgetFont.DrawText(destPoint, checkbox.Text);
+ }
+ public void DrawRadioButton(RadioButton radiobutton)
+ {
+ Surface surf;
+
+ if (radiobutton.Enabled == false)
+ surf = Disabled;
+ else
+ surf = Image;
+
+ Point destPoint = radiobutton.PointToScreen(
+ Origin.Calc(OriginAlignment.CenterLeft, radiobutton.Size));
+
+ surf.DisplayAlignment = OriginAlignment.CenterLeft;
+ surf.Draw(destPoint);
+
+ if (radiobutton.Enabled)
+ {
+ if (radiobutton.HasFocus)
+ {
+ Focus.DisplayAlignment = OriginAlignment.CenterLeft;
+ Focus.Draw(destPoint);
+ }
+ if (radiobutton.MouseIn)
+ {
+ Hover.DisplayAlignment = OriginAlignment.CenterLeft;
+ Hover.Draw(destPoint);
+ }
+ if (radiobutton.Checked)
+ {
+ Check.Color = Color.White;
+ Check.DisplayAlignment = OriginAlignment.CenterLeft;
+ Check.Draw(destPoint);
+ }
+ }
+ else if (radiobutton.Checked)
+ {
+ Check.Color = FontColorDisabled;
+ Check.DisplayAlignment = OriginAlignment.CenterLeft;
+ Check.Draw(destPoint);
+ }
+
+ SetControlFontColor(radiobutton);
+
+ destPoint.X += surf.DisplayWidth + Spacing;
+
+ WidgetFont.DisplayAlignment = OriginAlignment.CenterLeft;
+ WidgetFont.DrawText(destPoint, radiobutton.Text);
+ }
+
+ public override Size MinSize(Widget w)
+ {
+ Size text = WidgetFont.MeasureString(w.Text);
+ Size box = Image.SurfaceSize;
+
+ return new Size(
+ box.Width + Spacing + text.Width,
+ Math.Max(box.Height, text.Height));
+ }
+
+ public override bool HitTest(Widget w, Point screenLocation)
+ {
+ Point local = w.PointToClient(screenLocation);
+
+ int right = Image.SurfaceWidth +
+ WidgetFont.MeasureString(w.Text).Width + Spacing * 2;
+
+ if (local.X > right)
+ return false;
+
+ return true;
+ }
+
}
}
Modified: trunk/AgateLib/Gui/ThemeEngines/Mercury/MercuryListBox.cs
===================================================================
--- trunk/AgateLib/Gui/ThemeEngines/Mercury/MercuryListBox.cs 2009-11-28 02:57:18 UTC (rev 1133)
+++ trunk/AgateLib/Gui/ThemeEngines/Mercury/MercuryListBox.cs 2009-12-01 07:05:35 UTC (rev 1134)
@@ -2,22 +2,44 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
+using AgateLib.DisplayLib;
+using AgateLib.Geometry;
namespace AgateLib.Gui.ThemeEngines.Mercury
{
- public class MercuryListBox : MercurySchemeCommon
+ public class MercuryListBox : MercuryWidget
{
public Surface Image { get; set; }
public Surface Disabled { get; set; }
public Surface Hover { get; set; }
public Surface Focus { get; set; }
public Rectangle StretchRegion { get; set; }
- public int Margin { get; set; }
- public MercuryListBox()
+ public MercuryListBox(MercuryScheme scheme)
+ :base(scheme)
{
Margin = 3;
}
+
+ public override void DrawWidget(Widget w)
+ {
+ DrawListBox((ListBox)w);
+ }
+
+ private void DrawListBox(ListBox listBox)
+ {
+ Surface image = Image;
+
+ if (listBox.Enabled == false)
+ image = Disabled;
+
+ Point location = listBox.PointToScreen(new Point(0, 0));
+ Size size = listBox.Size;
+
+ DrawStretchImage(location, size, image, StretchRegion);
+ }
+
+
}
}
Modified: trunk/AgateLib/Gui/ThemeEngines/Mercury/MercuryScheme.cs
===================================================================
--- trunk/AgateLib/Gui/ThemeEngines/Mercury/MercuryScheme.cs 2009-11-28 02:57:18 UTC (rev 1133)
+++ trunk/AgateLib/Gui/ThemeEngines/Mercury/MercuryScheme.cs 2009-12-01 07:05:35 UTC (rev 1134)
@@ -11,19 +11,56 @@
public class MercuryScheme
{
int mInsertionPointBlinkTime = 500;
- MercuryWindow mWindow = new MercuryWindow();
- MercuryButton mButton = new MercuryButton();
- MercuryCheckBox mCheckBox = new MercuryCheckBox();
- MercuryCheckBox mRadioButton = new MercuryCheckBox();
- MercuryTextBox mTextBox = new MercuryTextBox();
- MercuryListBox mListBox = new MercuryListBox();
- MercuryScrollBar mVScroll = new MercuryScrollBar();
- MercuryScrollBar mHScroll = new MercuryScrollBar();
+ MercuryLabel mLabel;
+ MercuryWindow mWindow;
+ MercuryButton mButton;
+ MercuryCheckBox mCheckBox;
+ MercuryCheckBox mRadioButton;
+ MercuryTextBox mTextBox;
+ MercuryListBox mListBox;
+ MercuryScrollBar mVScroll;
+ MercuryScrollBar mHScroll;
+ Dictionary<Type, MercuryWidget> mDispatch = new Dictionary<Type, MercuryWidget>();
private MercuryScheme()
{
+ mLabel = new MercuryLabel(this);
+ mWindow = new MercuryWindow(this);
+ mButton = new MercuryButton(this);
+ mCheckBox = new MercuryCheckBox(this);
+ mRadioButton = new MercuryCheckBox(this);
+ mTextBox = new MercuryTextBox(this);
+ mListBox = new MercuryListBox(this);
+ mVScroll = new MercuryScrollBar(this);
+ mHScroll = new MercuryScrollBar(this);
+
+ mDispatch.Add(typeof(Label), mLabel);
+ mDispatch.Add(typeof(Window), mWindow);
+ mDispatch.Add(typeof(Button), mButton);
+ mDispatch.Add(typeof(CheckBox), mCheckBox);
+ mDispatch.Add(typeof(RadioButton), mRadioButton);
+ mDispatch.Add(typeof(TextBox), mTextBox);
+ mDispatch.Add(typeof(ListBox), mListBox);
+ mDispatch.Add(typeof(VerticalScrollBar), mVScroll);
+ mDispatch.Add(typeof(HorizontalScrollBar), mHScroll);
+ mDispatch.Add(typeof(Panel), new MercuryPanel(this));
+ mDispatch.Add(typeof(GuiRoot), new MercuryGuiRoot(this));
+
}
+ public MercuryWidget Themer(Widget w)
+ {
+ return Themer(w.GetType());
+ }
+ public MercuryWidget Themer(Type type)
+ {
+ return mDispatch[type];
+ }
+ public void RegisterThemer(Type type, MercuryWidget themer)
+ {
+ mDispatch.Add(type, themer);
+ }
+
public static MercuryScheme CreateDefaultScheme()
{
MercuryScheme retval = new MercuryScheme();
@@ -41,8 +78,7 @@
FontColor = Color.White;
FontColorDisabled = Color.Gray;
- DropShadowSize = 10;
-
+
SelectionFontColor = Color.Black;
SelectionBackColor = Color.Yellow;
@@ -52,6 +88,7 @@
Window.TitleBarStretchRegion = new Rectangle(6, 3, 52, 27);
Window.NoTitleStretchRegion = new Rectangle(5, 5, 54, 54);
Window.WithTitleStretchRegion = new Rectangle(7, 4, 50, 53);
+ Window.DropShadowSize = 10;
SetButtonImages(new Surface(files, "button.png"), new Size(64, 32));
Button.StretchRegion = new Rectangle(6, 6, 52, 20);
@@ -209,13 +246,21 @@
public FontSurface WidgetFont { get; set; }
public FontSurface TitleFont { get; set; }
- public int DropShadowSize { get; set; }
-
+
public Color FontColor { get; set; }
public Color FontColorDisabled { get; set; }
public Color SelectionFontColor { get; set; }
public Color SelectionBackColor { get; set; }
+ public MercuryLabel Label
+ {
+ get { return mLabel; }
+ set
+ {
+ if (value == null) throw new ArgumentNullException();
+ mLabel = value;
+ }
+ }
public MercuryWindow Window
{
get { return mWindow; }
Modified: trunk/AgateLib/Gui/ThemeEngines/Mercury/MercuryScrollBar.cs
===================================================================
--- trunk/AgateLib/Gui/ThemeEngines/Mercury/MercuryScrollBar.cs 2009-11-28 02:57:18 UTC (rev 1133)
+++ trunk/AgateLib/Gui/ThemeEngines/Mercury/MercuryScrollBar.cs 2009-12-01 07:05:35 UTC (rev 1134)
@@ -2,10 +2,14 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
+using AgateLib.DisplayLib;
+using AgateLib.Geometry;
namespace AgateLib.Gui.ThemeEngines.Mercury
{
- public class MercuryScrollBar : MercurySchemeCommon
+ using Cache;
+
+ public class MercuryScrollBar : MercuryWidget
{
public Surface Decrease { get; set; }
public Surface Increase { get; set; }
@@ -30,11 +34,16 @@
public int FixedBarSize { get; set; }
+ public MercuryScrollBar(MercuryScheme scheme)
+ : base(scheme)
+ {
+ FixedBarSize = 16;
+ }
- public void DrawScrollBar(ScrollBar scrollBar)
+ public override void DrawWidget(Widget w)
{
- if (scrollBar is VerticalScrollBar)
- DrawVerticalScrollBar(scrollBar);
+ if (w is VerticalScrollBar)
+ DrawVerticalScrollBar((ScrollBar)w);
}
private void DrawVerticalScrollBar(ScrollBar scrollBar)
@@ -52,6 +61,14 @@
DrawStretchImage(barLoc, sz, Bar, BarStretchRegion);
}
+ public override Size MinSize(Widget w)
+ {
+ return CalcMinScrollBarSize((ScrollBar)w);
+ }
+ public override Size MaxSize(Widget w)
+ {
+ return CalcMaxScrollBarSize((ScrollBar)w);
+ }
public Size CalcMinScrollBarSize(ScrollBar scrollBar)
{
if (scrollBar is VerticalScrollBar)
@@ -65,24 +82,100 @@
{
if (scrollBar is VerticalScrollBar)
return new Size(FixedBarSize, int.MaxValue);
- else
+ else if (scrollBar is HorizontalScrollBar)
return new Size(int.MaxValue, FixedBarSize);
throw new ArgumentException();
}
+ public override void MouseDownInWidget(Widget widget, Point clientLocation)
+ {
+ MouseDownInScrollBar((ScrollBar)widget, clientLocation);
+ }
+ public override void MouseMoveInWidget(Widget widget, Point clientLocation)
+ {
+ MouseMoveInScrollBar((ScrollBar)widget, clientLocation);
+ }
+ public override void MouseUpInWidget(Widget widget, Point clientLocation)
+ {
+ MouseUpInScrollBar((ScrollBar)widget, clientLocation);
+ }
+ ScrollBarCache GetCache(ScrollBar bar)
+ {
+ if (bar.Cache == null)
+ bar.Cache = new ScrollBarCache();
+
+ return (ScrollBarCache)bar.Cache;
+ }
public void MouseDownInScrollBar(ScrollBar scrollBar, Point clientLocation)
{
- throw new NotImplementedException();
+ var cache = GetCache(scrollBar);
+ Rectangle thumb = ThumbRegion(scrollBar);
+
+ cache.LastUpdate = Timing.TotalSeconds + 0.25;
+
+ if (DecreaseRegion(scrollBar).Contains(clientLocation))
+ {
+ cache.DownInDecrease = true;
+ scrollBar.Value -= scrollBar.SmallChange;
+ }
+ else if (IncreaseRegion(scrollBar).Contains(clientLocation))
+ {
+ cache.DownInIncrease = true;
+ scrollBar.Value += scrollBar.SmallChange;
+ }
+ else if (thumb.Contains(clientLocation))
+ {
+ cache.DragThumb = true;
+ cache.ThumbGrabSpot = new Point(clientLocation.X - thumb.X, clientLocation.Y - thumb.Y);
+ }
+ else if (PageDecreaseRegion(scrollBar).Contains(clientLocation))
+ {
+ cache.DownInPageDecrease = true;
+ scrollBar.Value -= scrollBar.LargeChange;
+ }
+ else if (PageIncreaseRegion(scrollBar).Contains(clientLocation))
+ {
+ cache.DownInPageIncrease = true;
+ scrollBar.Value += scrollBar.LargeChange;
+ }
}
public void MouseMoveInScrollBar(ScrollBar scrollBar, Point clientLocation)
{
- throw new NotImplementedException();
}
public void MouseUpInScrollBar(ScrollBar scrollBar, Point clientLocation)
{
+ var cache = GetCache(scrollBar);
+
+ cache.DownInDecrease = false;
+ cache.DownInIncrease = false;
+ cache.DownInPageDecrease = false;
+ cache.DownInPageIncrease = false;
+ }
+
+ private Rectangle DecreaseRegion(ScrollBar scrollBar)
+ {
+ return new Rectangle(0, 0, FixedBarSize, FixedBarSize);
+ }
+ private Rectangle IncreaseRegion(ScrollBar scrollBar)
+ {
+ if (scrollBar is VerticalScrollBar)
+ return new Rectangle(0, scrollBar.Height - FixedBarSize, FixedBarSize, FixedBarSize);
+ else
+ return new Rectangle(scrollBar.Width - FixedBarSize, 0, FixedBarSize, FixedBarSize);
+ }
+ private Rectangle ThumbRegion(ScrollBar scrollBar)
+ {
+ return new Rectangle(0, 0, 0, 0);
+ }
+ private Rectangle PageDecreaseRegion(ScrollBar scrollBar)
+ {
throw new NotImplementedException();
}
+ private Rectangle PageIncreaseRegion(ScrollBar scrollBar)
+ {
+ throw new NotImplementedException();
+ }
}
}
Modified: trunk/AgateLib/Gui/ThemeEngines/Mercury/MercuryTextBox.cs
===================================================================
--- trunk/AgateLib/Gui/ThemeEngines/Mercury/MercuryTextBox.cs 2009-11-28 02:57:18 UTC (rev 1133)
+++ trunk/AgateLib/Gui/ThemeEngines/Mercury/MercuryTextBox.cs 2009-12-01 07:05:35 UTC (rev 1134)
@@ -2,21 +2,303 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
+using AgateLib.DisplayLib;
+using AgateLib.Geometry;
namespace AgateLib.Gui.ThemeEngines.Mercury
{
- public class MercuryTextBox : MercurySchemeCommon
+ using Cache;
+
+ public class MercuryTextBox : MercuryWidget
{
public Surface Image { get; set; }
public Surface Disabled { get; set; }
public Surface Hover { get; set; }
public Surface Focus { get; set; }
public Rectangle StretchRegion { get; set; }
- public int Margin { get; set; }
- public MercuryTextBox()
+ public MercuryTextBox(MercuryScheme scheme) : base(scheme)
{
Margin = 3;
}
+
+
+ public void MouseDownInTextBox(TextBox textBox, Point clientLocation)
+ {
+ textBox.MoveInsertionPoint(
+ TextBoxClientToTextLocation(textBox, clientLocation), false);
+
+ }
+ public void MouseMoveInTextBox(TextBox textBox, Point clientLocation)
+ {
+ if (textBox.MouseDownIn)
+ {
+ textBox.MoveInsertionPoint(
+ TextBoxClientToTextLocation(textBox, clientLocation), true);
+ }
+ }
+ public void MouseUpInTextBox(TextBox textBox, Point clientLocation)
+ {
+
+ }
+
+ private static TextBoxCache GetTextBoxCache(TextBox textBox)
+ {
+ if (textBox.Cache == null)
+ textBox.Cache = new TextBoxCache();
+
+ return (TextBoxCache)textBox.Cache;
+ }
+ public void UpdateCache(TextBox textBox)
+ {
+ TextBoxCache c = GetTextBoxCache(textBox);
+
+ if (c.Dirty == false)
+ return;
+
+ Size fixedSize = StretchRegionFixedSize(Image.SurfaceSize, StretchRegion);
+
+ Size surfSize = new Size(textBox.Size.Width - fixedSize.Width,
+ textBox.Size.Height - fixedSize.Height);
+
+ if (c.TextBoxFrameBuffer == null || c.TextBoxFrameBuffer.Size != surfSize)
+ {
+ if (c.TextBoxFrameBuffer != null)
+ c.TextBoxFrameBuffer.Dispose();
+
+ c.TextBoxFrameBuffer = new FrameBuffer(surfSize);
+ c.Origin = Point.Empty;
+ }
+
+ Point ip = InsertionPointLocation(textBox);
+ ip.X -= StretchRegion.X;
+ ip.Y -= StretchRegion.Y;
+ int bottom = ip.Y + InsertionPointHeight;
+
+ if (ip.Y < 0)
+ c.Origin.Y += ip.Y;
+ if (bottom > surfSize.Height)
+ c.Origin.Y += bottom - surfSize.Height;
+ if (ip.X < 0)
+ c.Origin.X += ip.X;
+ if (ip.X >= surfSize.Width)
+ c.Origin.X += ip.X - surfSize.Width + 1;
+
+ FrameBuffer old = Display.RenderTarget;
+ Display.RenderTarget = c.TextBoxFrameBuffer;
+ Display.RenderState.AlphaBlend = false;
+ Display.BeginFrame();
+
+ Display.Clear(Color.FromArgb(0, 0, 0, 0));
+
+ if (textBox.Enabled)
+ WidgetFont.Color = FontColor;
+ else
+ WidgetFont.Color = FontColorDisabled;
+
+ WidgetFont.DrawText(-c.Origin.X, -c.Origin.Y, textBox.Text);
+
+ Display.EndFrame();
+ Display.RenderTarget = old;
+ Display.RenderState.AlphaBlend = true;
+
+ c.Dirty = false;
+ }
+
+ public override void DrawWidget(Widget w)
+ {
+ DrawTextBox((TextBox)w);
+ }
+ public void DrawTextBox(TextBox textBox)
+ {
+ Surface image = Image;
+
+ if (textBox.Enabled == false)
+ image = Disabled;
+
+ Point location = textBox.PointToScreen(new Point(0, 0));
+ Size size = textBox.Size;
+
+ DrawStretchImage(location, size,
+ image, StretchRegion);
+
+ if (textBox.Enabled)
+ {
+ if (textBox.HasFocus)
+ {
+ DrawStretchImage(location, size, Focus, StretchRegion);
+ }
+ if (textBox.MouseIn)
+ {
+ DrawStretchImage(location, size, Hover, StretchRegion);
+ }
+ }
+
+ WidgetFont.DisplayAlignment = OriginAlignment.TopLeft;
+
+ SetControlFontColor(textBox);
+
+ location.X += StretchRegion.X;
+ location.Y += StretchRegion.Y;
+
+ TextBoxCache c = (TextBoxCache)textBox.Cache;
+
+ if (c == null || c.TextBoxSurface == null)
+ {
+ WidgetFont.DrawText( location, textBox.Text);
+ }
+ else
+ {
+ c.TextBoxSurface.Draw(location);
+ }
+
+ if (textBox.HasFocus)
+ {
+ Point loc = InsertionPointLocation(textBox);
+
+ loc = textBox.PointToScreen(loc);
+
+ DrawInsertionPoint(textBox, loc, InsertionPointHeight,
+ Timing.TotalMilliseconds - textBox.IPTime);
+ }
+ }
+
+ private int TextBoxClientToTextLocation(TextBox textBox, Point clientLocation)
+ {
+ TextBoxCache c = GetTextBoxCache(textBox);
+
+ clientLocation.X += c.Origin.X - StretchRegion.X;
+ clientLocation.Y += c.Origin.Y - StretchRegion.Y;
+
+ Size sz = Size.Empty;
+ int last = 0;
+ int index;
+
+ int line = clientLocation.Y / WidgetFont.FontHeight;
+ int linestart = 0;
+ for (index = 0; index < textBox.Text.Length; index++)
+ {
+ if (textBox.Text[index] == '\n')
+ {
+ if (index < textBox.Text.Length - 1)
+ index++;
+
+ line--;
+ linestart = index;
+ }
+
+ if (line == 0)
+ goto searchX;
+ }
+
+ // we only get here if the mouse click was below the last line.
+ index = linestart;
+
+ searchX:
+ for (; index < textBox.Text.Length; index++)
+ {
+ sz = WidgetFont.MeasureString(textBox.Text.Substring(linestart, index - linestart));
+
+ if (textBox.Text[index] == '\n')
+ {
+ break;
+ }
+
+ if (sz.Width > clientLocation.X)
+ {
+ goto found;
+ }
+
+ last = sz.Width;
+
+ }
+
+ found:
+ double pass = (sz.Width - clientLocation.X) / (double)(sz.Width - last);
+
+ // if it's halfway over, put the insertion on the right side of the character,
+ // otherwise put it on the left.
+ if (pass <= 0.5)
+ return index;
+ else
+ return index - 1;
+ }
+
+ /// <summary>
+ /// Returns the local insertion point location in the textbox in pixels.
+ /// </summary>
+ /// <param name="textBox"></param>
+ /// <returns></returns>
+ private Point InsertionPointLocation(TextBox textBox)
+ {
+ int lineStart = 0;
+ int lines = 0;
+
+ if (textBox.MultiLine)
+ {
+ for (int i = 0; i < textBox.InsertionPoint; i++)
+ {
+ if (textBox.Text[i] == '\n')
+ {
+ lineStart = i;
+ lines++;
+ }
+ }
+ }
+
+ Size sz = WidgetFont.StringDisplaySize(
+ textBox.Text.Substring(lineStart, textBox.InsertionPoint - lineStart));
+
+ Point loc = new Point(
+ sz.Width + StretchRegion.X,
+ lines * WidgetFont.FontHeight + StretchRegion.Y);
+
+ TextBoxCache c = textBox.Cache as TextBoxCache;
+
+ if (c != null)
+ {
+ loc.X -= c.Origin.X;
+ loc.Y -= c.Origin.Y;
+ }
+
+ loc.Y++;
+
+ return loc;
+ }
+
+ private void DrawInsertionPoint(Widget widget, Point location, int size, double time)
+ {
+ int val = (int)time / InsertionPointBlinkTime;
+
+ if (val % 2 == 1)
+ return;
+
+ Display.DrawLine(location,
+ new Point(location.X, location.Y + size),
+ WidgetFont.Color);
+ }
+
+ public override Size MinSize(Widget w)
+ {
+ Size retval = new Size();
+
+ retval.Width = 40;
+ retval.Height = WidgetFont.FontHeight;
+ retval.Height += Image.SurfaceHeight - StretchRegion.Height;
+
+ return retval;
+ }
+ public override Size MaxSize(Widget w)
+ {
+ Size retval = MinSize(w);
+ TextBox t = (TextBox)w;
+
+ retval.Width = 9000;
+
+ if (t.MultiLine)
+ retval.Height = 9000;
+
+ return retval;
+ }
}
}
Modified: trunk/AgateLib/Gui/ThemeEngines/Mercury/MercuryWindow.cs
===================================================================
--- trunk/AgateLib/Gui/ThemeEngines/Mercury/MercuryWindow.cs 2009-11-28 02:57:18 UTC (rev 1133)
+++ trunk/AgateLib/Gui/ThemeEngines/Mercury/MercuryWindow.cs 2009-12-01 07:05:35 UTC (rev 1134)
@@ -2,10 +2,12 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
+using AgateLib.DisplayLib;
+using AgateLib.Geometry;
namespace AgateLib.Gui.ThemeEngines.Mercury
{
- public class MercuryWindow : MercurySchemeCommon
+ public class MercuryWindow : MercuryWidget
{
public Surface NoTitle { get; set; }
public Surface WithTitle { get; set; }
@@ -20,9 +22,112 @@
public Surface CloseButtonHover { get; set; }
public Surface CloseButtonInactive { get; set; }
- public MercuryWindow()
+ public int DropShadowSize { get; set; }
+
+ public MercuryWindow(MercuryScheme scheme) : base(scheme)
{
CenterTitle = true;
}
+
+ public override void DrawWidget(Widget w)
+ {
+ DrawWindow((Window)w);
+ }
+ public void DrawWindow(Window window)
+ {
+ DrawWindowBackground(window);
+ DrawWindowTitle(window);
+ DrawWindowDecorations(window);
+ }
+
+ // TODO: fix this
+ public int WindowTitlebarSize
+ {
+ get { return TitleFont.FontHeight + 6; }
+ }
+
+ protected virtual void DrawWindowBackground(Window window)
+ {
+ if (window.ShowTitleBar)
+ {
+ DrawStretchImage(window.Parent.PointToScreen(
+ new Point(window.Location.X, window.Location.Y + this.WindowTitlebarSize)),
+ window.Size, WithTitle, WithTitleStretchRegion);
+
+ }
+ else
+ throw new NotImplementedException();
+ }
+
+ private void DrawDropShadow(Rectangle rect)
+ {
+ for (int i = 0; i <= DropShadowSize; i++)
+ {
+ Color fadeColor = Color.Red;// Scheme.WindowBorderColor;
+ fadeColor.A = (byte)(
+ fadeColor.A * (DropShadowSize - i) / (2 * DropShadowSize));
+
+ Display.DrawRect(rect, fadeColor);
+
+ rect.X--;
+ rect.Y--;
+ rect.Width += 2;
+ rect.Height += 2;
+ }
+ }
+ protected virtual void DrawWindowTitle(Window window)
+ {
+ Point windowLocation = window.ScreenLocation;
+
+ DrawStretchImage(windowLocation,
+ new Size(window.Width, WindowTitlebarSize), TitleBar, TitleBarStretchRegion);
+
+ Point fontPosition = new Point(windowLocation.X + 8, windowLocation.Y + 3);
+ if (CenterTitle)
+ {
+ fontPosition.X = windowLocation.X + window.Width / 2;
+ fontPosition.Y = windowLocation.Y + WindowTitlebarSize / 2;
+ TitleFont.DisplayAlignment = OriginAlignment.Center;
+ }
+
+ TitleFont.Color = FontColor;
+
+ TitleFont.DrawText(
+ fontPosition,
+ window.Text);
+
+ TitleFont.DisplayAlignment = OriginAlignment.TopLeft;
+ }
+ protected virtual void DrawWindowDecorations(Window window)
+ {
+ CloseButton.DisplayAlignment = OriginAlignment.TopRight;
+ CloseButton.Draw(
+ new Point(window.ScreenLocation.X + window.Size.Width,
+ window.ScreenLocation.Y));
+ }
+
+ public override Size MinSize(Widget w)
+ {
+ return new Size(10, 10);
+ }
+
+ public override Rectangle ClientArea(Container widget)
+ {
+ Window window = (Window)widget;
+
+ if (window.ShowTitleBar)
+ {
+ return new Rectangle(
+ WithTitleStretchRegion.Left,
+ WithTitleStretchRegion.Top + WindowTitlebarSize,
+ widget.Width - (WithTitle.SurfaceWidth - WithTitleStretchRegion.Width),
+ widget.Height - (WithTitle.SurfaceHeight - WithTitleStretchRegion.Height));
+ }
+ else
+ {
+ throw new NotImplementedException();
+ }
+ }
+
}
}
Modified: trunk/AgateLib/Gui/Widget.cs
===================================================================
--- trunk/AgateLib/Gui/Widget.cs 2009-11-28 02:57:18 UTC (rev 1133)
+++ trunk/AgateLib/Gui/Widget.cs 2009-12-01 07:05:35 UTC (rev 1134)
@@ -212,6 +212,9 @@
get { return mMaxSize; }
set
{
+ if (value.Width < 1 || value.Height < 1)
+ throw new ArgumentException();
+
mMaxSize = value;
if (this == Root) return;
@@ -371,6 +374,11 @@
mMouseDownIn = true;
OnMouseDown(e);
+
+ if (Root != null)
+ {
+ Root.ThemeEngine.MouseDownInWidget(this, PointToClient(e.MousePosition));
+ }
}
protected internal virtual void SendMouseUp(InputEventArgs e)
{
@@ -378,13 +386,24 @@
return;
mMouseDownIn = false;
- OnMouseUp(e);
+ OnMouseUp(e);
+
+ if (Root != null)
+ {
+ Root.ThemeEngine.MouseUpInWidget(this, PointToClient(e.MousePosition));
+ }
}
protected internal virtual void SendMouseMove(InputEventArgs e)
{
if (Enabled == false)
return;
+
OnMouseMove(e);
+
+ if (Root != null)
+ {
+ Root.ThemeEngine.MouseMoveInWidget(this, PointToClient(e.MousePosition));
+ }
}
protected internal virtual void SendMouseDoubleClick(InputEventArgs e)
{
Modified: trunk/AgateLib/ImplementationBase/FontSurfaceImpl.cs
===================================================================
--- trunk/AgateLib/ImplementationBase/FontSurfaceImpl.cs 2009-11-28 02:57:18 UTC (rev 1133)
+++ trunk/AgateLib/ImplementationBase/FontSurfaceImpl.cs 2009-12-01 07:05:35 UTC (rev 1134)
@@ -30,10 +30,6 @@
/// </summary>
public abstract class FontSurfaceImpl : IDisposable
{
- private OriginAlignment mAlignment = OriginAlignment.TopLeft;
- private Color mColor = Color.White;
- private double mScaleWidth = 1.0;
- private double mScaleHeight = 1.0;
private string mFontName = "Unknown";
/// <summary>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ka...@us...> - 2009-11-28 02:57:29
|
Revision: 1133
http://agate.svn.sourceforge.net/agate/?rev=1133&view=rev
Author: kanato
Date: 2009-11-28 02:57:18 +0000 (Sat, 28 Nov 2009)
Log Message:
-----------
Add GUI tests.
Modified Paths:
--------------
trunk/Tests/DisplayTests/BasicDrawing/BasicDrawing.cs
trunk/Tests/Tests.csproj
Added Paths:
-----------
trunk/Tests/GuiTests/Listboxes.cs
trunk/Tests/GuiTests/ScrollBar.cs
Modified: trunk/Tests/DisplayTests/BasicDrawing/BasicDrawing.cs
===================================================================
--- trunk/Tests/DisplayTests/BasicDrawing/BasicDrawing.cs 2009-11-28 02:56:58 UTC (rev 1132)
+++ trunk/Tests/DisplayTests/BasicDrawing/BasicDrawing.cs 2009-11-28 02:57:18 UTC (rev 1133)
@@ -169,7 +169,27 @@
static void btnDrawLine_Click(object sender, EventArgs e)
{
- shapes.Add(new Shape(ShapeType.DrawLine, Color.FromArgb(frm.SelectedColor.ToArgb()), RandomRect()));
+ int x = random.Next(0, frm.panel1.Width * 2 / 3);
+ int y = random.Next(0, frm.panel1.Width * 2 / 3);
+
+ switch (random.Next(10))
+ {
+ case 0:
+ case 1:
+ case 2:
+ shapes.Add(new Shape(ShapeType.DrawLine, Color.FromArgb(frm.SelectedColor.ToArgb()), new Rectangle(x, y, 14, 0)));
+ break;
+
+ case 3:
+ case 4:
+ case 5:
+ shapes.Add(new Shape(ShapeType.DrawLine, Color.FromArgb(frm.SelectedColor.ToArgb()), new Rectangle(x, y, 0, 14)));
+ break;
+
+ default:
+ shapes.Add(new Shape(ShapeType.DrawLine, Color.FromArgb(frm.SelectedColor.ToArgb()), RandomRect()));
+ break;
+ }
}
static void btnClear_Click(object sender, EventArgs e)
Added: trunk/Tests/GuiTests/Listboxes.cs
===================================================================
--- trunk/Tests/GuiTests/Listboxes.cs (rev 0)
+++ trunk/Tests/GuiTests/Listboxes.cs 2009-11-28 02:57:18 UTC (rev 1133)
@@ -0,0 +1,55 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using AgateLib;
+using AgateLib.Gui;
+
+namespace Tests.GuiTests
+{
+ class Listboxes : AgateGame, IAgateTest
+ {
+ #region IAgateTest Members
+
+ public string Name
+ {
+ get { return "Listboxes"; }
+ }
+
+ public string Category
+ {
+ get { return "Gui"; }
+ }
+
+ public void Main(string[] args)
+ {
+ Run(args);
+ }
+
+ #endregion
+
+ protected override void AdjustAppInitParameters(ref AppInitParameters initParams)
+ {
+ initParams.ShowSplashScreen = false;
+ }
+ protected override void Initialize()
+ {
+ this.GuiRoot = new GuiRoot();
+
+ Window wind = new Window("Textboxes test");
+ wind.Size = new AgateLib.Geometry.Size(320, 240);
+
+ ListBox a = new ListBox();
+
+ wind.Children.Add(a);
+
+ ListBox b = new ListBox();
+ b.Text = "This is a multiline textbox.\nYou can enter multiple lines.\n" +
+ "In code, these lines are separated by the usual \"\\n\" character.";
+
+ wind.Children.Add(b);
+
+ this.GuiRoot.Children.Add(wind);
+ }
+ }
+}
\ No newline at end of file
Added: trunk/Tests/GuiTests/ScrollBar.cs
===================================================================
--- trunk/Tests/GuiTests/ScrollBar.cs (rev 0)
+++ trunk/Tests/GuiTests/ScrollBar.cs 2009-11-28 02:57:18 UTC (rev 1133)
@@ -0,0 +1,59 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using AgateLib;
+using AgateLib.DisplayLib;
+using AgateLib.Geometry;
+using AgateLib.Gui;
+
+namespace Tests.GuiTests
+{
+ public class ScrollBar : AgateGame, IAgateTest
+ {
+ public string Name
+ {
+ get { return "Scroll Bars"; }
+ }
+
+ public string Category
+ {
+ get { return "Gui"; }
+ }
+
+ public void Main(string[] args)
+ {
+ Run(args);
+ }
+
+ protected override void AdjustAppInitParameters(ref AppInitParameters initParams)
+ {
+ initParams.ShowSplashScreen = false;
+ initParams.InitializeAudio = false;
+ initParams.InitializeJoysticks = false;
+
+ }
+
+ protected override void Initialize()
+ {
+ base.GuiRoot = new GuiRoot();
+
+ Window wind = new Window("Scroll Bars test");
+ wind.Size = new Size(400, 300);
+
+ wind.Layout = new AgateLib.Gui.Layout.VerticalBox();
+
+ Panel rightPanel = new Panel();
+ Label vbarValueLabel = new Label();
+ rightPanel.Children.Add(vbarValueLabel);
+
+ VerticalScrollBar vbar = new VerticalScrollBar();
+ vbar.ValueChanged += (sender, e) => { vbarValueLabel.Text = "Vertical value: " + vbar.Value.ToString(); };
+
+ wind.Children.Add(vbar);
+ wind.Children.Add(rightPanel);
+
+ base.GuiRoot.Children.Add(wind);
+ }
+ }
+}
Modified: trunk/Tests/Tests.csproj
===================================================================
--- trunk/Tests/Tests.csproj 2009-11-28 02:56:58 UTC (rev 1132)
+++ trunk/Tests/Tests.csproj 2009-11-28 02:57:18 UTC (rev 1133)
@@ -111,7 +111,9 @@
<DependentUpon>frmLauncher.cs</DependentUpon>
<SubType>Code</SubType>
</Compile>
+ <Compile Include="GuiTests\Listboxes.cs" />
<Compile Include="GuiTests\RenderGui.cs" />
+ <Compile Include="GuiTests\ScrollBar.cs" />
<Compile Include="GuiTests\Textboxes.cs" />
<Compile Include="IAgateTest.cs">
<SubType>Code</SubType>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ka...@us...> - 2009-11-28 02:57:07
|
Revision: 1132
http://agate.svn.sourceforge.net/agate/?rev=1132&view=rev
Author: kanato
Date: 2009-11-28 02:56:58 +0000 (Sat, 28 Nov 2009)
Log Message:
-----------
Separate files for MercuryScheme.
Modified Paths:
--------------
trunk/AgateLib/AgateLib.csproj
trunk/AgateLib/Gui/ThemeEngines/Mercury/MercuryScheme.cs
Added Paths:
-----------
trunk/AgateLib/Gui/ThemeEngines/Mercury/MercuryButton.cs
trunk/AgateLib/Gui/ThemeEngines/Mercury/MercuryCheckBox.cs
trunk/AgateLib/Gui/ThemeEngines/Mercury/MercuryListBox.cs
trunk/AgateLib/Gui/ThemeEngines/Mercury/MercurySchemeCommon.cs
trunk/AgateLib/Gui/ThemeEngines/Mercury/MercuryScrollBar.cs
trunk/AgateLib/Gui/ThemeEngines/Mercury/MercuryTextBox.cs
trunk/AgateLib/Gui/ThemeEngines/Mercury/MercuryWindow.cs
Modified: trunk/AgateLib/AgateLib.csproj
===================================================================
--- trunk/AgateLib/AgateLib.csproj 2009-11-28 02:17:30 UTC (rev 1131)
+++ trunk/AgateLib/AgateLib.csproj 2009-11-28 02:56:58 UTC (rev 1132)
@@ -131,8 +131,15 @@
<Compile Include="Gui\TextBox.cs" />
<Compile Include="Gui\ThemeEngines\Mercury\Cache\TextBoxCache.cs" />
<Compile Include="Gui\ThemeEngines\Mercury\Mercury.cs" />
+ <Compile Include="Gui\ThemeEngines\Mercury\MercuryButton.cs" />
+ <Compile Include="Gui\ThemeEngines\Mercury\MercuryCheckBox.cs" />
+ <Compile Include="Gui\ThemeEngines\Mercury\MercuryListBox.cs" />
<Compile Include="Gui\ThemeEngines\Mercury\MercuryScheme.cs" />
<Compile Include="Gui\ScrollBar.cs" />
+ <Compile Include="Gui\ThemeEngines\Mercury\MercurySchemeCommon.cs" />
+ <Compile Include="Gui\ThemeEngines\Mercury\MercuryScrollBar.cs" />
+ <Compile Include="Gui\ThemeEngines\Mercury\MercuryTextBox.cs" />
+ <Compile Include="Gui\ThemeEngines\Mercury\MercuryWindow.cs" />
<Compile Include="Gui\Widget.cs" />
<Compile Include="Gui\WidgetList.cs" />
<Compile Include="Gui\Window.cs" />
Added: trunk/AgateLib/Gui/ThemeEngines/Mercury/MercuryButton.cs
===================================================================
--- trunk/AgateLib/Gui/ThemeEngines/Mercury/MercuryButton.cs (rev 0)
+++ trunk/AgateLib/Gui/ThemeEngines/Mercury/MercuryButton.cs 2009-11-28 02:56:58 UTC (rev 1132)
@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace AgateLib.Gui.ThemeEngines.Mercury
+{
+ public class MercuryButton : MercurySchemeCommon
+ {
+ public Rectangle StretchRegion { get; set; }
+ public Surface Image { get; set; }
+ public Surface Default { get; set; }
+ public Surface Pressed { get; set; }
+ public Surface Disabled { get; set; }
+ public Surface Hover { get; set; }
+ public Surface Focus { get; set; }
+ public int TextPadding { get; set; }
+ public int Margin { get; set; }
+ }
+
+}
Added: trunk/AgateLib/Gui/ThemeEngines/Mercury/MercuryCheckBox.cs
===================================================================
--- trunk/AgateLib/Gui/ThemeEngines/Mercury/MercuryCheckBox.cs (rev 0)
+++ trunk/AgateLib/Gui/ThemeEngines/Mercury/MercuryCheckBox.cs 2009-11-28 02:56:58 UTC (rev 1132)
@@ -0,0 +1,24 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace AgateLib.Gui.ThemeEngines.Mercury
+{
+ public class MercuryCheckBox : MercurySchemeCommon
+ {
+ public Surface Image { get; set; }
+ public Surface Disabled { get; set; }
+ public Surface Check { get; set; }
+ public Surface Hover { get; set; }
+ public Surface Focus { get; set; }
+ public int Spacing { get; set; }
+ public int Margin { get; set; }
+
+ public MercuryCheckBox()
+ {
+ Spacing = 5;
+ Margin = 2;
+ }
+ }
+}
Added: trunk/AgateLib/Gui/ThemeEngines/Mercury/MercuryListBox.cs
===================================================================
--- trunk/AgateLib/Gui/ThemeEngines/Mercury/MercuryListBox.cs (rev 0)
+++ trunk/AgateLib/Gui/ThemeEngines/Mercury/MercuryListBox.cs 2009-11-28 02:56:58 UTC (rev 1132)
@@ -0,0 +1,23 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace AgateLib.Gui.ThemeEngines.Mercury
+{
+ public class MercuryListBox : MercurySchemeCommon
+ {
+ public Surface Image { get; set; }
+ public Surface Disabled { get; set; }
+ public Surface Hover { get; set; }
+ public Surface Focus { get; set; }
+ public Rectangle StretchRegion { get; set; }
+ public int Margin { get; set; }
+
+ public MercuryListBox()
+ {
+ Margin = 3;
+ }
+ }
+
+}
Modified: trunk/AgateLib/Gui/ThemeEngines/Mercury/MercuryScheme.cs
===================================================================
--- trunk/AgateLib/Gui/ThemeEngines/Mercury/MercuryScheme.cs 2009-11-28 02:17:30 UTC (rev 1131)
+++ trunk/AgateLib/Gui/ThemeEngines/Mercury/MercuryScheme.cs 2009-11-28 02:56:58 UTC (rev 1132)
@@ -289,221 +289,4 @@
}
}
}
-
- public class MercurySchemeCommon
- {
- protected internal static void DrawStretchImage(Point loc, Size size,
- Surface surface, Rectangle stretchRegion)
- {
- Rectangle scaled = new Rectangle(
- loc.X + stretchRegion.X,
- loc.Y + stretchRegion.Y,
- size.Width - (surface.SurfaceWidth - stretchRegion.Right) - stretchRegion.X,
- size.Height - (surface.SurfaceHeight - stretchRegion.Bottom) - stretchRegion.Y);
-
- // draw top left
- surface.Draw(
- new Rectangle(0, 0, stretchRegion.Left, stretchRegion.Top),
- new Rectangle(loc.X, loc.Y, stretchRegion.Left, stretchRegion.Top));
-
- // draw top middle
- surface.Draw(
- new Rectangle(stretchRegion.Left, 0, stretchRegion.Width, stretchRegion.Top),
- new Rectangle(loc.X + stretchRegion.Left, loc.Y,
- scaled.Width, stretchRegion.Top));
-
- // draw top right
- surface.Draw(
- new Rectangle(stretchRegion.Right, 0, surface.SurfaceWidth - stretchRegion.Right, stretchRegion.Top),
- new Rectangle(scaled.Right, loc.Y, surface.SurfaceWidth - stretchRegion.Right, stretchRegion.Top));
-
- // draw middle left
- surface.Draw(
- new Rectangle(0, stretchRegion.Top, stretchRegion.Left, stretchRegion.Height),
- new Rectangle(loc.X, loc.Y + stretchRegion.Top, stretchRegion.Left, scaled.Height));
-
- // draw middle
- surface.Draw(
- stretchRegion,
- scaled);
-
- // draw middle right
- surface.Draw(
- new Rectangle(stretchRegion.Right, stretchRegion.Top, surface.SurfaceWidth - stretchRegion.Right, stretchRegion.Height),
- new Rectangle(scaled.Right, scaled.Top, surface.SurfaceWidth - stretchRegion.Right, scaled.Height));
-
- // draw bottom left
- surface.Draw(
- new Rectangle(0, stretchRegion.Bottom, stretchRegion.Left, surface.SurfaceHeight - stretchRegion.Bottom),
- new Rectangle(loc.X, scaled.Bottom, stretchRegion.Left, surface.SurfaceHeight - stretchRegion.Bottom));
-
- // draw bottom middle
- surface.Draw(
- new Rectangle(stretchRegion.Left, stretchRegion.Bottom, stretchRegion.Width, surface.SurfaceHeight - stretchRegion.Bottom),
- new Rectangle(scaled.Left, scaled.Bottom, scaled.Width, surface.SurfaceHeight - stretchRegion.Bottom));
-
- // draw bottom right
- surface.Draw(
- new Rectangle(stretchRegion.Right, stretchRegion.Bottom, surface.SurfaceWidth - stretchRegion.Right, surface.SurfaceHeight - stretchRegion.Bottom),
- new Rectangle(scaled.Right, scaled.Bottom, surface.SurfaceWidth - stretchRegion.Right, surface.SurfaceHeight - stretchRegion.Bottom));
-
- }
-
- }
- public class MercuryWindow : MercurySchemeCommon
- {
- public Surface NoTitle { get; set; }
- public Surface WithTitle { get; set; }
- public Surface TitleBar { get; set; }
- public Rectangle NoTitleStretchRegion { get; set; }
- public Rectangle WithTitleStretchRegion { get; set; }
- public Rectangle TitleBarStretchRegion { get; set; }
-
- public bool CenterTitle { get; set; }
-
- public Surface CloseButton { get; set; }
- public Surface CloseButtonHover { get; set; }
- public Surface CloseButtonInactive { get; set; }
-
- public MercuryWindow()
- {
- CenterTitle = true;
- }
- }
- public class MercuryButton : MercurySchemeCommon
- {
- public Rectangle StretchRegion { get; set; }
- public Surface Image { get; set; }
- public Surface Default { get; set; }
- public Surface Pressed { get; set; }
- public Surface Disabled { get; set; }
- public Surface Hover { get; set; }
- public Surface Focus { get; set; }
- public int TextPadding { get; set; }
- public int Margin { get; set; }
- }
- public class MercuryTextBox : MercurySchemeCommon
- {
- public Surface Image { get; set; }
- public Surface Disabled { get; set; }
- public Surface Hover { get; set; }
- public Surface Focus { get; set; }
- public Rectangle StretchRegion { get; set; }
- public int Margin { get; set; }
-
- public MercuryTextBox()
- {
- Margin = 3;
- }
- }
- public class MercuryListBox : MercurySchemeCommon
- {
- public Surface Image { get; set; }
- public Surface Disabled { get; set; }
- public Surface Hover { get; set; }
- public Surface Focus { get; set; }
- public Rectangle StretchRegion { get; set; }
- public int Margin { get; set; }
-
- public MercuryListBox()
- {
- Margin = 3;
- }
- }
- public class MercuryCheckBox : MercurySchemeCommon
- {
- public Surface Image { get; set; }
- public Surface Disabled { get; set; }
- public Surface Check { get; set; }
- public Surface Hover { get; set; }
- public Surface Focus { get; set; }
- public int Spacing { get; set; }
- public int Margin { get; set; }
-
- public MercuryCheckBox()
- {
- Spacing = 5;
- Margin = 2;
- }
- }
- public class MercuryScrollBar : MercurySchemeCommon
- {
- public Surface Decrease { get; set; }
- public Surface Increase { get; set; }
-
- public Surface DecreaseHover { get; set; }
- public Surface IncreaseHover { get; set; }
-
- public Surface DecreasePressed { get; set; }
- public Surface IncreasePressed { get; set; }
-
- public Surface DecreaseDisabled { get; set; }
- public Surface IncreaseDisabled { get; set; }
-
- public Surface Bar { get; set; }
- public Surface BarDisabled { get; set; }
-
- public Surface Thumb { get; set; }
- public Surface ThumbHover { get; set; }
-
- public Rectangle BarStretchRegion { get; set; }
- public Rectangle ThumbStretchRegion { get; set; }
-
- public int FixedBarSize { get; set; }
-
-
- public void DrawScrollBar(ScrollBar scrollBar)
- {
- if (scrollBar is VerticalScrollBar)
- DrawVerticalScrollBar(scrollBar);
- }
-
- private void DrawVerticalScrollBar(ScrollBar scrollBar)
- {
- Point location = scrollBar.PointToScreen(Point.Empty);
-
- Decrease.Draw(location);
- Increase.Draw(location.X, location.Y + scrollBar.Height - Decrease.DisplayHeight);
-
- Point barLoc = location;
- barLoc.Y += Increase.DisplayHeight;
- Size sz = new Size(Increase.DisplayHeight,
- scrollBar.Height - Increase.DisplayHeight - Decrease.DisplayHeight);
-
- DrawStretchImage(barLoc, sz, Bar, BarStretchRegion);
- }
-
- public Size CalcMinScrollBarSize(ScrollBar scrollBar)
- {
- if (scrollBar is VerticalScrollBar)
- return new Size(FixedBarSize, FixedBarSize * 3);
- else
- return new Size(FixedBarSize * 3, FixedBarSize);
-
- throw new ArgumentException();
- }
- public Size CalcMaxScrollBarSize(ScrollBar scrollBar)
- {
- if (scrollBar is VerticalScrollBar)
- return new Size(FixedBarSize, int.MaxValue);
- else
- return new Size(int.MaxValue, FixedBarSize);
-
- throw new ArgumentException();
- }
-
-
- public void MouseDownInScrollBar(ScrollBar scrollBar, Point clientLocation)
- {
- throw mnew NotImplementedException();
- }
- public void MouseMoveInScrollBar(ScrollBar scrollBar, Point clientLocation)
- {
- throw new NotImplementedException();
- }
- public void MouseUpInScrollBar(ScrollBar scrollBar, Point clientLocation)
- {
- throw new NotImplementedException();
- }
- }
}
Added: trunk/AgateLib/Gui/ThemeEngines/Mercury/MercurySchemeCommon.cs
===================================================================
--- trunk/AgateLib/Gui/ThemeEngines/Mercury/MercurySchemeCommon.cs (rev 0)
+++ trunk/AgateLib/Gui/ThemeEngines/Mercury/MercurySchemeCommon.cs 2009-11-28 02:56:58 UTC (rev 1132)
@@ -0,0 +1,69 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace AgateLib.Gui.ThemeEngines.Mercury
+{
+
+ public class MercurySchemeCommon
+ {
+ protected internal static void DrawStretchImage(Point loc, Size size,
+ Surface surface, Rectangle stretchRegion)
+ {
+ Rectangle scaled = new Rectangle(
+ loc.X + stretchRegion.X,
+ loc.Y + stretchRegion.Y,
+ size.Width - (surface.SurfaceWidth - stretchRegion.Right) - stretchRegion.X,
+ size.Height - (surface.SurfaceHeight - stretchRegion.Bottom) - stretchRegion.Y);
+
+ // draw top left
+ surface.Draw(
+ new Rectangle(0, 0, stretchRegion.Left, stretchRegion.Top),
+ new Rectangle(loc.X, loc.Y, stretchRegion.Left, stretchRegion.Top));
+
+ // draw top middle
+ surface.Draw(
+ new Rectangle(stretchRegion.Left, 0, stretchRegion.Width, stretchRegion.Top),
+ new Rectangle(loc.X + stretchRegion.Left, loc.Y,
+ scaled.Width, stretchRegion.Top));
+
+ // draw top right
+ surface.Draw(
+ new Rectangle(stretchRegion.Right, 0, surface.SurfaceWidth - stretchRegion.Right, stretchRegion.Top),
+ new Rectangle(scaled.Right, loc.Y, surface.SurfaceWidth - stretchRegion.Right, stretchRegion.Top));
+
+ // draw middle left
+ surface.Draw(
+ new Rectangle(0, stretchRegion.Top, stretchRegion.Left, stretchRegion.Height),
+ new Rectangle(loc.X, loc.Y + stretchRegion.Top, stretchRegion.Left, scaled.Height));
+
+ // draw middle
+ surface.Draw(
+ stretchRegion,
+ scaled);
+
+ // draw middle right
+ surface.Draw(
+ new Rectangle(stretchRegion.Right, stretchRegion.Top, surface.SurfaceWidth - stretchRegion.Right, stretchRegion.Height),
+ new Rectangle(scaled.Right, scaled.Top, surface.SurfaceWidth - stretchRegion.Right, scaled.Height));
+
+ // draw bottom left
+ surface.Draw(
+ new Rectangle(0, stretchRegion.Bottom, stretchRegion.Left, surface.SurfaceHeight - stretchRegion.Bottom),
+ new Rectangle(loc.X, scaled.Bottom, stretchRegion.Left, surface.SurfaceHeight - stretchRegion.Bottom));
+
+ // draw bottom middle
+ surface.Draw(
+ new Rectangle(stretchRegion.Left, stretchRegion.Bottom, stretchRegion.Width, surface.SurfaceHeight - stretchRegion.Bottom),
+ new Rectangle(scaled.Left, scaled.Bottom, scaled.Width, surface.SurfaceHeight - stretchRegion.Bottom));
+
+ // draw bottom right
+ surface.Draw(
+ new Rectangle(stretchRegion.Right, stretchRegion.Bottom, surface.SurfaceWidth - stretchRegion.Right, surface.SurfaceHeight - stretchRegion.Bottom),
+ new Rectangle(scaled.Right, scaled.Bottom, surface.SurfaceWidth - stretchRegion.Right, surface.SurfaceHeight - stretchRegion.Bottom));
+
+ }
+
+ }
+}
Added: trunk/AgateLib/Gui/ThemeEngines/Mercury/MercuryScrollBar.cs
===================================================================
--- trunk/AgateLib/Gui/ThemeEngines/Mercury/MercuryScrollBar.cs (rev 0)
+++ trunk/AgateLib/Gui/ThemeEngines/Mercury/MercuryScrollBar.cs 2009-11-28 02:56:58 UTC (rev 1132)
@@ -0,0 +1,88 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace AgateLib.Gui.ThemeEngines.Mercury
+{
+ public class MercuryScrollBar : MercurySchemeCommon
+ {
+ public Surface Decrease { get; set; }
+ public Surface Increase { get; set; }
+
+ public Surface DecreaseHover { get; set; }
+ public Surface IncreaseHover { get; set; }
+
+ public Surface DecreasePressed { get; set; }
+ public Surface IncreasePressed { get; set; }
+
+ public Surface DecreaseDisabled { get; set; }
+ public Surface IncreaseDisabled { get; set; }
+
+ public Surface Bar { get; set; }
+ public Surface BarDisabled { get; set; }
+
+ public Surface Thumb { get; set; }
+ public Surface ThumbHover { get; set; }
+
+ public Rectangle BarStretchRegion { get; set; }
+ public Rectangle ThumbStretchRegion { get; set; }
+
+ public int FixedBarSize { get; set; }
+
+
+ public void DrawScrollBar(ScrollBar scrollBar)
+ {
+ if (scrollBar is VerticalScrollBar)
+ DrawVerticalScrollBar(scrollBar);
+ }
+
+ private void DrawVerticalScrollBar(ScrollBar scrollBar)
+ {
+ Point location = scrollBar.PointToScreen(Point.Empty);
+
+ Decrease.Draw(location);
+ Increase.Draw(location.X, location.Y + scrollBar.Height - Decrease.DisplayHeight);
+
+ Point barLoc = location;
+ barLoc.Y += Increase.DisplayHeight;
+ Size sz = new Size(Increase.DisplayHeight,
+ scrollBar.Height - Increase.DisplayHeight - Decrease.DisplayHeight);
+
+ DrawStretchImage(barLoc, sz, Bar, BarStretchRegion);
+ }
+
+ public Size CalcMinScrollBarSize(ScrollBar scrollBar)
+ {
+ if (scrollBar is VerticalScrollBar)
+ return new Size(FixedBarSize, FixedBarSize * 3);
+ else
+ return new Size(FixedBarSize * 3, FixedBarSize);
+
+ throw new ArgumentException();
+ }
+ public Size CalcMaxScrollBarSize(ScrollBar scrollBar)
+ {
+ if (scrollBar is VerticalScrollBar)
+ return new Size(FixedBarSize, int.MaxValue);
+ else
+ return new Size(int.MaxValue, FixedBarSize);
+
+ throw new ArgumentException();
+ }
+
+
+ public void MouseDownInScrollBar(ScrollBar scrollBar, Point clientLocation)
+ {
+ throw new NotImplementedException();
+ }
+ public void MouseMoveInScrollBar(ScrollBar scrollBar, Point clientLocation)
+ {
+ throw new NotImplementedException();
+ }
+ public void MouseUpInScrollBar(ScrollBar scrollBar, Point clientLocation)
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
Added: trunk/AgateLib/Gui/ThemeEngines/Mercury/MercuryTextBox.cs
===================================================================
--- trunk/AgateLib/Gui/ThemeEngines/Mercury/MercuryTextBox.cs (rev 0)
+++ trunk/AgateLib/Gui/ThemeEngines/Mercury/MercuryTextBox.cs 2009-11-28 02:56:58 UTC (rev 1132)
@@ -0,0 +1,22 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace AgateLib.Gui.ThemeEngines.Mercury
+{
+ public class MercuryTextBox : MercurySchemeCommon
+ {
+ public Surface Image { get; set; }
+ public Surface Disabled { get; set; }
+ public Surface Hover { get; set; }
+ public Surface Focus { get; set; }
+ public Rectangle StretchRegion { get; set; }
+ public int Margin { get; set; }
+
+ public MercuryTextBox()
+ {
+ Margin = 3;
+ }
+ }
+}
Added: trunk/AgateLib/Gui/ThemeEngines/Mercury/MercuryWindow.cs
===================================================================
--- trunk/AgateLib/Gui/ThemeEngines/Mercury/MercuryWindow.cs (rev 0)
+++ trunk/AgateLib/Gui/ThemeEngines/Mercury/MercuryWindow.cs 2009-11-28 02:56:58 UTC (rev 1132)
@@ -0,0 +1,28 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace AgateLib.Gui.ThemeEngines.Mercury
+{
+ public class MercuryWindow : MercurySchemeCommon
+ {
+ public Surface NoTitle { get; set; }
+ public Surface WithTitle { get; set; }
+ public Surface TitleBar { get; set; }
+ public Rectangle NoTitleStretchRegion { get; set; }
+ public Rectangle WithTitleStretchRegion { get; set; }
+ public Rectangle TitleBarStretchRegion { get; set; }
+
+ public bool CenterTitle { get; set; }
+
+ public Surface CloseButton { get; set; }
+ public Surface CloseButtonHover { get; set; }
+ public Surface CloseButtonInactive { get; set; }
+
+ public MercuryWindow()
+ {
+ CenterTitle = true;
+ }
+ }
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ka...@us...> - 2009-11-28 02:17:39
|
Revision: 1131
http://agate.svn.sourceforge.net/agate/?rev=1131&view=rev
Author: kanato
Date: 2009-11-28 02:17:30 +0000 (Sat, 28 Nov 2009)
Log Message:
-----------
Initial scroll bar drawing support.
Modified Paths:
--------------
trunk/AgateLib/AgateLib.csproj
trunk/AgateLib/Gui/ListBox.cs
trunk/AgateLib/Gui/ThemeEngines/Mercury/Mercury.cs
trunk/AgateLib/Gui/ThemeEngines/Mercury/MercuryScheme.cs
trunk/AgateLib/InternalResources/agate-black-gui.zip
Added Paths:
-----------
trunk/AgateLib/Gui/ScrollBar.cs
Modified: trunk/AgateLib/AgateLib.csproj
===================================================================
--- trunk/AgateLib/AgateLib.csproj 2009-11-28 02:16:52 UTC (rev 1130)
+++ trunk/AgateLib/AgateLib.csproj 2009-11-28 02:17:30 UTC (rev 1131)
@@ -132,6 +132,7 @@
<Compile Include="Gui\ThemeEngines\Mercury\Cache\TextBoxCache.cs" />
<Compile Include="Gui\ThemeEngines\Mercury\Mercury.cs" />
<Compile Include="Gui\ThemeEngines\Mercury\MercuryScheme.cs" />
+ <Compile Include="Gui\ScrollBar.cs" />
<Compile Include="Gui\Widget.cs" />
<Compile Include="Gui\WidgetList.cs" />
<Compile Include="Gui\Window.cs" />
Modified: trunk/AgateLib/Gui/ListBox.cs
===================================================================
--- trunk/AgateLib/Gui/ListBox.cs 2009-11-28 02:16:52 UTC (rev 1130)
+++ trunk/AgateLib/Gui/ListBox.cs 2009-11-28 02:17:30 UTC (rev 1131)
@@ -5,7 +5,7 @@
namespace AgateLib.Gui
{
- class ListBox : Widget
+ public class ListBox : Widget
{
List<object> mItems = new List<object>();
ListBoxItemText mItemTextGetter;
Added: trunk/AgateLib/Gui/ScrollBar.cs
===================================================================
--- trunk/AgateLib/Gui/ScrollBar.cs (rev 0)
+++ trunk/AgateLib/Gui/ScrollBar.cs 2009-11-28 02:17:30 UTC (rev 1131)
@@ -0,0 +1,105 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace AgateLib.Gui
+{
+ public abstract class ScrollBar : Widget
+ {
+ int mMinValue = 0;
+ int mMaxValue = 100;
+ int mValue;
+ int mLargeChange = 10;
+ int mSmallChange = 1;
+
+ internal bool MouseDownInDecrease { get; set; }
+ internal bool MouseDownInIncrease { get; set; }
+ internal bool MouseDownInThumb { get; set; }
+ internal bool MouseDownInPageDecrease { get; set; }
+ internal bool MouseDownInPageIncrease { get; set; }
+
+ public event EventHandler ValueChanged;
+ private void OnValueChanged()
+ {
+ if (ValueChanged != null)
+ ValueChanged(this, EventArgs.Empty);
+ }
+
+ public int Value
+ {
+ get { return mValue; }
+ set
+ {
+ if (value < mMinValue)
+ throw new ArgumentOutOfRangeException();
+ if (value > mMaxValue)
+ throw new ArgumentOutOfRangeException();
+
+ mValue = value;
+ OnValueChanged();
+ }
+ }
+
+ public int LargeChange
+ {
+ get { return mLargeChange; }
+ set
+ {
+ if (mSmallChange < 1)
+ throw new ArgumentOutOfRangeException();
+
+ mLargeChange = value;
+ }
+ }
+ public int SmallChange
+ {
+ get { return mSmallChange; }
+ set
+ {
+ if (mSmallChange < 1)
+ throw new ArgumentOutOfRangeException();
+
+ mSmallChange = value;
+ }
+ }
+
+ public int MinValue
+ {
+ get { return mMinValue; }
+ set
+ {
+ mMinValue = value;
+
+ if (MaxValue < MinValue)
+ MaxValue = MinValue;
+
+ if (Value < MinValue)
+ Value = MinValue;
+
+ }
+ }
+
+ public int MaxValue
+ {
+ get { return mMaxValue; }
+ set
+ {
+ mMaxValue = value;
+
+ if (MinValue > MaxValue)
+ MinValue = MaxValue;
+
+ if (Value > MaxValue)
+ Value = MaxValue;
+
+ }
+ }
+ }
+
+ public class VerticalScrollBar : ScrollBar
+ { }
+
+ public class HorizontalScrollBar : ScrollBar
+ { }
+}
Modified: trunk/AgateLib/Gui/ThemeEngines/Mercury/Mercury.cs
===================================================================
--- trunk/AgateLib/Gui/ThemeEngines/Mercury/Mercury.cs 2009-11-28 02:16:52 UTC (rev 1130)
+++ trunk/AgateLib/Gui/ThemeEngines/Mercury/Mercury.cs 2009-11-28 02:17:30 UTC (rev 1131)
@@ -62,6 +62,9 @@
if (widget is RadioButton) DrawRadioButton((RadioButton)widget);
if (widget is TextBox) DrawTextBox((TextBox)widget);
if (widget is ListBox) DrawListBox((ListBox)widget);
+ if (widget is VerticalScrollBar) Scheme.VerticalScrollBar.DrawScrollBar((ScrollBar)widget);
+ if (widget is HorizontalScrollBar) Scheme.HorizontalScrollBar.DrawScrollBar((ScrollBar)widget);
+
}
public Size RequestClientAreaSize(Container widget, Size clientSize)
@@ -75,14 +78,17 @@
if (widget is CheckBox) return CalcMinCheckBoxSize((CheckBox)widget);
if (widget is TextBox) return CalcTextBoxMinSize((TextBox)widget);
if (widget is RadioButton) return CalcMinRadioButtonSize((RadioButton)widget);
+ if (widget is VerticalScrollBar) return Scheme.VerticalScrollBar.CalcMinScrollBarSize((ScrollBar)widget);
+ if (widget is HorizontalScrollBar) return Scheme.HorizontalScrollBar.CalcMinScrollBarSize((ScrollBar)widget);
return Size.Empty;
}
+
public Size CalcMaxSize(Widget widget)
{
if (widget is TextBox) return CalcTextBoxMaxSize((TextBox)widget);
- return new Size(9000, 9000);
+ return new Size(int.MaxValue, int.MinValue);
}
public bool HitTest(Widget widget, Point screenLocation)
{
@@ -105,14 +111,21 @@
public void MouseDownInWidget(Widget widget, Point clientLocation)
{
if (widget is TextBox) MouseDownInTextBox((TextBox)widget, clientLocation);
+ if (widget is VerticalScrollBar) Scheme.VerticalScrollBar.MouseDownInScrollBar((ScrollBar)widget, clientLocation);
+ if (widget is HorizontalScrollBar) Scheme.HorizontalScrollBar.MouseDownInScrollBar((ScrollBar)widget, clientLocation);
+
}
public void MouseMoveInWidget(Widget widget, Point clientLocation)
{
if (widget is TextBox) MouseMoveInTextBox((TextBox)widget, clientLocation);
+ if (widget is VerticalScrollBar) Scheme.VerticalScrollBar.MouseMoveInScrollBar((ScrollBar)widget, clientLocation);
+ if (widget is HorizontalScrollBar) Scheme.HorizontalScrollBar.MouseMoveInScrollBar((ScrollBar)widget, clientLocation);
}
public void MouseUpInWidget(Widget widget, Point clientLocation)
{
if (widget is TextBox) MouseUpInTextBox((TextBox)widget, clientLocation);
+ if (widget is VerticalScrollBar) Scheme.VerticalScrollBar.MouseUpInScrollBar((ScrollBar)widget, clientLocation);
+ if (widget is HorizontalScrollBar) Scheme.HorizontalScrollBar.MouseUpInScrollBar((ScrollBar)widget, clientLocation);
}
#endregion
@@ -175,7 +188,7 @@
Size surfSize = new Size(textBox.Size.Width - fixedSize.Width,
textBox.Size.Height - fixedSize.Height);
- if (c.TextBoxSurface == null || c.TextBoxSurface.SurfaceSize != surfSize)
+ if (c.TextBoxFrameBuffer == null || c.TextBoxFrameBuffer.Size != surfSize)
{
if (c.TextBoxFrameBuffer != null)
c.TextBoxFrameBuffer.Dispose();
@@ -383,7 +396,6 @@
private void DrawInsertionPoint(Widget widget, Point location, int size, double time)
{
int val = (int)time / Scheme.InsertionPointBlinkTime;
- //Debug.Print("{0} {1}", time, val);
if (val % 2 == 1)
return;
Modified: trunk/AgateLib/Gui/ThemeEngines/Mercury/MercuryScheme.cs
===================================================================
--- trunk/AgateLib/Gui/ThemeEngines/Mercury/MercuryScheme.cs 2009-11-28 02:16:52 UTC (rev 1130)
+++ trunk/AgateLib/Gui/ThemeEngines/Mercury/MercuryScheme.cs 2009-11-28 02:17:30 UTC (rev 1131)
@@ -17,6 +17,8 @@
MercuryCheckBox mRadioButton = new MercuryCheckBox();
MercuryTextBox mTextBox = new MercuryTextBox();
MercuryListBox mListBox = new MercuryListBox();
+ MercuryScrollBar mVScroll = new MercuryScrollBar();
+ MercuryScrollBar mHScroll = new MercuryScrollBar();
private MercuryScheme()
{
@@ -66,8 +68,30 @@
SetListBoxImages(new Surface(files, "textbox.png"), new Size(64, 16));
ListBox.StretchRegion = new Rectangle(3, 3, 58, 10);
+
+ SetScrollBarImages(new Surface(files, "scrollbar.png"), 16);
}
+ private void SetScrollBarImages(Surface surface, int barSize)
+ {
+ PixelBuffer pixels = surface.ReadPixels();
+
+ VerticalScrollBar.FixedBarSize = barSize;
+ HorizontalScrollBar.FixedBarSize = barSize;
+
+ VerticalScrollBar.Decrease = new Surface(barSize, barSize);
+ VerticalScrollBar.Decrease.WritePixels(pixels, new Rectangle(0, 0, barSize, barSize), Point.Empty);
+
+ VerticalScrollBar.Increase = new Surface(barSize, barSize);
+ VerticalScrollBar.Increase.WritePixels(pixels, new Rectangle(0, pixels.Height - barSize, barSize, barSize), Point.Empty);
+
+ VerticalScrollBar.Bar = new Surface(barSize, pixels.Height - barSize * 2);
+ VerticalScrollBar.Bar.WritePixels(pixels, new Rectangle(0, barSize, barSize, VerticalScrollBar.Bar.SurfaceHeight), Point.Empty);
+ VerticalScrollBar.BarStretchRegion = new Rectangle(1, 1, VerticalScrollBar.Bar.SurfaceWidth - 2, VerticalScrollBar.Bar.SurfaceHeight - 2);
+
+
+ }
+
private void SetListBoxImages(Surface surface, Size boxSize)
{
Surface[] surfs = SplitSurface("Listbox", surface, boxSize, 4, 4);
@@ -246,11 +270,88 @@
mRadioButton = value;
}
}
-
+ public MercuryScrollBar VerticalScrollBar
+ {
+ get { return mVScroll; }
+ set
+ {
+ if (value == null) throw new ArgumentNullException();
+ mVScroll = value;
+ }
+ }
+ public MercuryScrollBar HorizontalScrollBar
+ {
+ get { return mHScroll; }
+ set
+ {
+ if (value == null) throw new ArgumentNullException();
+ mHScroll = value;
+ }
+ }
}
- public class MercuryWindow
+ public class MercurySchemeCommon
{
+ protected internal static void DrawStretchImage(Point loc, Size size,
+ Surface surface, Rectangle stretchRegion)
+ {
+ Rectangle scaled = new Rectangle(
+ loc.X + stretchRegion.X,
+ loc.Y + stretchRegion.Y,
+ size.Width - (surface.SurfaceWidth - stretchRegion.Right) - stretchRegion.X,
+ size.Height - (surface.SurfaceHeight - stretchRegion.Bottom) - stretchRegion.Y);
+
+ // draw top left
+ surface.Draw(
+ new Rectangle(0, 0, stretchRegion.Left, stretchRegion.Top),
+ new Rectangle(loc.X, loc.Y, stretchRegion.Left, stretchRegion.Top));
+
+ // draw top middle
+ surface.Draw(
+ new Rectangle(stretchRegion.Left, 0, stretchRegion.Width, stretchRegion.Top),
+ new Rectangle(loc.X + stretchRegion.Left, loc.Y,
+ scaled.Width, stretchRegion.Top));
+
+ // draw top right
+ surface.Draw(
+ new Rectangle(stretchRegion.Right, 0, surface.SurfaceWidth - stretchRegion.Right, stretchRegion.Top),
+ new Rectangle(scaled.Right, loc.Y, surface.SurfaceWidth - stretchRegion.Right, stretchRegion.Top));
+
+ // draw middle left
+ surface.Draw(
+ new Rectangle(0, stretchRegion.Top, stretchRegion.Left, stretchRegion.Height),
+ new Rectangle(loc.X, loc.Y + stretchRegion.Top, stretchRegion.Left, scaled.Height));
+
+ // draw middle
+ surface.Draw(
+ stretchRegion,
+ scaled);
+
+ // draw middle right
+ surface.Draw(
+ new Rectangle(stretchRegion.Right, stretchRegion.Top, surface.SurfaceWidth - stretchRegion.Right, stretchRegion.Height),
+ new Rectangle(scaled.Right, scaled.Top, surface.SurfaceWidth - stretchRegion.Right, scaled.Height));
+
+ // draw bottom left
+ surface.Draw(
+ new Rectangle(0, stretchRegion.Bottom, stretchRegion.Left, surface.SurfaceHeight - stretchRegion.Bottom),
+ new Rectangle(loc.X, scaled.Bottom, stretchRegion.Left, surface.SurfaceHeight - stretchRegion.Bottom));
+
+ // draw bottom middle
+ surface.Draw(
+ new Rectangle(stretchRegion.Left, stretchRegion.Bottom, stretchRegion.Width, surface.SurfaceHeight - stretchRegion.Bottom),
+ new Rectangle(scaled.Left, scaled.Bottom, scaled.Width, surface.SurfaceHeight - stretchRegion.Bottom));
+
+ // draw bottom right
+ surface.Draw(
+ new Rectangle(stretchRegion.Right, stretchRegion.Bottom, surface.SurfaceWidth - stretchRegion.Right, surface.SurfaceHeight - stretchRegion.Bottom),
+ new Rectangle(scaled.Right, scaled.Bottom, surface.SurfaceWidth - stretchRegion.Right, surface.SurfaceHeight - stretchRegion.Bottom));
+
+ }
+
+ }
+ public class MercuryWindow : MercurySchemeCommon
+ {
public Surface NoTitle { get; set; }
public Surface WithTitle { get; set; }
public Surface TitleBar { get; set; }
@@ -269,7 +370,7 @@
CenterTitle = true;
}
}
- public class MercuryButton
+ public class MercuryButton : MercurySchemeCommon
{
public Rectangle StretchRegion { get; set; }
public Surface Image { get; set; }
@@ -281,7 +382,7 @@
public int TextPadding { get; set; }
public int Margin { get; set; }
}
- public class MercuryTextBox
+ public class MercuryTextBox : MercurySchemeCommon
{
public Surface Image { get; set; }
public Surface Disabled { get; set; }
@@ -295,7 +396,7 @@
Margin = 3;
}
}
- public class MercuryListBox
+ public class MercuryListBox : MercurySchemeCommon
{
public Surface Image { get; set; }
public Surface Disabled { get; set; }
@@ -309,7 +410,7 @@
Margin = 3;
}
}
- public class MercuryCheckBox
+ public class MercuryCheckBox : MercurySchemeCommon
{
public Surface Image { get; set; }
public Surface Disabled { get; set; }
@@ -325,4 +426,84 @@
Margin = 2;
}
}
+ public class MercuryScrollBar : MercurySchemeCommon
+ {
+ public Surface Decrease { get; set; }
+ public Surface Increase { get; set; }
+
+ public Surface DecreaseHover { get; set; }
+ public Surface IncreaseHover { get; set; }
+
+ public Surface DecreasePressed { get; set; }
+ public Surface IncreasePressed { get; set; }
+
+ public Surface DecreaseDisabled { get; set; }
+ public Surface IncreaseDisabled { get; set; }
+
+ public Surface Bar { get; set; }
+ public Surface BarDisabled { get; set; }
+
+ public Surface Thumb { get; set; }
+ public Surface ThumbHover { get; set; }
+
+ public Rectangle BarStretchRegion { get; set; }
+ public Rectangle ThumbStretchRegion { get; set; }
+
+ public int FixedBarSize { get; set; }
+
+
+ public void DrawScrollBar(ScrollBar scrollBar)
+ {
+ if (scrollBar is VerticalScrollBar)
+ DrawVerticalScrollBar(scrollBar);
+ }
+
+ private void DrawVerticalScrollBar(ScrollBar scrollBar)
+ {
+ Point location = scrollBar.PointToScreen(Point.Empty);
+
+ Decrease.Draw(location);
+ Increase.Draw(location.X, location.Y + scrollBar.Height - Decrease.DisplayHeight);
+
+ Point barLoc = location;
+ barLoc.Y += Increase.DisplayHeight;
+ Size sz = new Size(Increase.DisplayHeight,
+ scrollBar.Height - Increase.DisplayHeight - Decrease.DisplayHeight);
+
+ DrawStretchImage(barLoc, sz, Bar, BarStretchRegion);
+ }
+
+ public Size CalcMinScrollBarSize(ScrollBar scrollBar)
+ {
+ if (scrollBar is VerticalScrollBar)
+ return new Size(FixedBarSize, FixedBarSize * 3);
+ else
+ return new Size(FixedBarSize * 3, FixedBarSize);
+
+ throw new ArgumentException();
+ }
+ public Size CalcMaxScrollBarSize(ScrollBar scrollBar)
+ {
+ if (scrollBar is VerticalScrollBar)
+ return new Size(FixedBarSize, int.MaxValue);
+ else
+ return new Size(int.MaxValue, FixedBarSize);
+
+ throw new ArgumentException();
+ }
+
+
+ public void MouseDownInScrollBar(ScrollBar scrollBar, Point clientLocation)
+ {
+ throw mnew NotImplementedException();
+ }
+ public void MouseMoveInScrollBar(ScrollBar scrollBar, Point clientLocation)
+ {
+ throw new NotImplementedException();
+ }
+ public void MouseUpInScrollBar(ScrollBar scrollBar, Point clientLocation)
+ {
+ throw new NotImplementedException();
+ }
+ }
}
Modified: trunk/AgateLib/InternalResources/agate-black-gui.zip
===================================================================
(Binary files differ)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ka...@us...> - 2009-11-28 02:16:59
|
Revision: 1130
http://agate.svn.sourceforge.net/agate/?rev=1130&view=rev
Author: kanato
Date: 2009-11-28 02:16:52 +0000 (Sat, 28 Nov 2009)
Log Message:
-----------
OpenGL: Improve support for Intel graphics cards (no stencil buffer frame buffer attachment)
SDX: Improve support for Intel graphics cards (render target must be power of two)
Modified Paths:
--------------
trunk/Drivers/AgateOTK/GL_Display.cs
trunk/Drivers/AgateOTK/Legacy/FrameBufferExt.cs
trunk/Drivers/AgateOTK/Legacy/FrameBufferReadPixels.cs
trunk/Drivers/AgateSDX/FrameBufferSurface.cs
trunk/Drivers/AgateSDX/SDX_Display.cs
trunk/Drivers/AgateSDX/SDX_Surface.cs
Modified: trunk/Drivers/AgateOTK/GL_Display.cs
===================================================================
--- trunk/Drivers/AgateOTK/GL_Display.cs 2009-11-25 18:40:19 UTC (rev 1129)
+++ trunk/Drivers/AgateOTK/GL_Display.cs 2009-11-28 02:16:52 UTC (rev 1130)
@@ -281,11 +281,6 @@
mGLVersion = DetectOpenGLVersion();
LoadExtensions();
- if (mGL3)
- mPrimitives = new GL3.GLPrimitiveRenderer();
- else
- mPrimitives = new Legacy.LegacyPrimitiveRenderer();
-
mSupportsFramebufferExt = SupportsExtension("GL_EXT_FRAMEBUFFER_OBJECT");
mNonPowerOf2Textures = SupportsExtension("GL_ARB_NON_POWER_OF_TWO");
@@ -301,6 +296,11 @@
mSupportsShaders = true;
}
+ if (mGL3)
+ mPrimitives = new GL3.GLPrimitiveRenderer();
+ else
+ mPrimitives = new Legacy.LegacyPrimitiveRenderer();
+
if (SupportsExtension("GL_ARB_FRAGMENT_PROGRAM"))
{
mSupportsShaders = true;
@@ -337,7 +337,10 @@
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)
Modified: trunk/Drivers/AgateOTK/Legacy/FrameBufferExt.cs
===================================================================
--- trunk/Drivers/AgateOTK/Legacy/FrameBufferExt.cs 2009-11-25 18:40:19 UTC (rev 1129)
+++ trunk/Drivers/AgateOTK/Legacy/FrameBufferExt.cs 2009-11-28 02:16:52 UTC (rev 1130)
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using System.Diagnostics;
using System.Linq;
using System.Text;
using AgateLib;
@@ -13,43 +14,119 @@
{
Size mSize;
int mFramebufferID;
- int mDepthBuffer;
+ int mDepthBuffer, mStencilBuffer;
GL_Surface mTexture;
+ static bool sDepthSupported = true;
+ static bool sStencilSupported = true;
+
public FrameBufferExt(Size size)
{
mSize = size;
- //AgateLib.DisplayLib.PixelBuffer pixels = new AgateLib.DisplayLib.PixelBuffer(
- // AgateLib.DisplayLib.PixelFormat.RGBA8888, mSize);
+ InitializeFramebuffer();
+ }
+ void InitializeFramebuffer()
+ {
+ // try to initialize with both depth and stencil buffers.
+ if (sDepthSupported && sStencilSupported)
+ {
+ try
+ {
+ InitializeFramebuffer(true, true);
+ return;
+ }
+ catch
+ {
+ Trace.WriteLine("Failed to create FBO with both depth and stencil buffers.");
+ }
+ }
+ if (sDepthSupported)
+ {
+ try
+ {
+ InitializeFramebuffer(true, false);
+ sStencilSupported = false;
+ return;
+ }
+ catch
+ {
+ Trace.WriteLine("Failed to create FBO with just a depth buffer.");
+ }
+ }
+ if (sStencilSupported)
+ {
+ try
+ {
+ InitializeFramebuffer(false, true);
+ sDepthSupported = false;
+ return;
+ }
+ catch
+ {
+ Trace.WriteLine("Failed to create FBO with just a stencil buffer.");
+ }
+ }
+
+ try
+ {
+ InitializeFramebuffer(false, false);
+ }
+ catch
+ {
+ Trace.WriteLine("Failed to create FBO without either depth or stencil buffer.");
+ throw;
+ }
+ sDepthSupported = false;
+ sStencilSupported = false;
+ }
+
+ void InitializeFramebuffer(bool depth, bool stencil)
+ {
mTexture = new GL_Surface(mSize);
// generate the frame buffer
GL.Ext.GenFramebuffers(1, out mFramebufferID);
- GL.Ext.BindFramebuffer(FramebufferTarget.FramebufferExt, mFramebufferID);
+ GL.Ext.BindFramebuffer(FramebufferTarget.Framebuffer, mFramebufferID);
- // generate a depth buffer to render to
- GL.Ext.GenRenderbuffers(1, out mDepthBuffer);
- GL.Ext.BindRenderbuffer(RenderbufferTarget.RenderbufferExt, mDepthBuffer);
+ if (depth)
+ {
+ // generate a depth buffer to render to
+ GL.Ext.GenRenderbuffers(1, out mDepthBuffer);
+ GL.Ext.BindRenderbuffer(RenderbufferTarget.Renderbuffer, mDepthBuffer);
- // hack here because RenderbufferStorage enum is incomplete.
- GL.Ext.RenderbufferStorage(RenderbufferTarget.RenderbufferExt,
- RenderbufferStorage.Depth24Stencil8,
- mSize.Width, mSize.Height);
+ GL.Ext.RenderbufferStorage(RenderbufferTarget.Renderbuffer,
+ RenderbufferStorage.DepthComponent24, mSize.Width, mSize.Height);
+
+ // attach the depth buffer
+ GL.Ext.FramebufferRenderbuffer(FramebufferTarget.Framebuffer,
+ FramebufferAttachment.DepthAttachment, RenderbufferTarget.Renderbuffer,
+ mDepthBuffer);
+ }
- // attach the depth buffer
- GL.Ext.FramebufferRenderbuffer(FramebufferTarget.FramebufferExt,
- FramebufferAttachment.DepthAttachmentExt, RenderbufferTarget.RenderbufferExt,
- mDepthBuffer);
+ if (stencil)
+ {
+ // generate a stencil buffer
+ GL.Ext.GenRenderbuffers(1, out mStencilBuffer);
+ GL.Ext.BindRenderbuffer(RenderbufferTarget.Renderbuffer, mStencilBuffer);
+ GL.Ext.RenderbufferStorage(RenderbufferTarget.Renderbuffer,
+ RenderbufferStorage.StencilIndex8, mSize.Width, mSize.Height);
+
+ // attach it.
+ GL.Ext.FramebufferRenderbuffer(FramebufferTarget.Framebuffer,
+ FramebufferAttachment.StencilAttachment, RenderbufferTarget.Renderbuffer,
+ mStencilBuffer);
+ }
+
// attach the texture
- GL.Ext.FramebufferTexture2D(FramebufferTarget.FramebufferExt,
- FramebufferAttachment.ColorAttachment0Ext, TextureTarget.Texture2D,
+ GL.Ext.FramebufferTexture2D(FramebufferTarget.Framebuffer,
+ FramebufferAttachment.ColorAttachment0, TextureTarget.Texture2D,
mTexture.GLTextureID, 0);
FramebufferErrorCode code =
- GL.Ext.CheckFramebufferStatus(FramebufferTarget.FramebufferExt);
+ GL.Ext.CheckFramebufferStatus(FramebufferTarget.Framebuffer);
if (code != FramebufferErrorCode.FramebufferCompleteExt)
{
Modified: trunk/Drivers/AgateOTK/Legacy/FrameBufferReadPixels.cs
===================================================================
--- trunk/Drivers/AgateOTK/Legacy/FrameBufferReadPixels.cs 2009-11-25 18:40:19 UTC (rev 1129)
+++ trunk/Drivers/AgateOTK/Legacy/FrameBufferReadPixels.cs 2009-11-28 02:16:52 UTC (rev 1130)
@@ -69,5 +69,21 @@
GL.TexParameter(TextureTarget.Texture2D,
TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear);
}
+
+ public override bool CanAccessBackBuffer
+ {
+ get
+ {
+ return true;
+ }
+ }
+
+ public override AgateLib.ImplementationBase.SurfaceImpl BackBuffer
+ {
+ get
+ {
+ return surface;
+ }
+ }
}
}
Modified: trunk/Drivers/AgateSDX/FrameBufferSurface.cs
===================================================================
--- trunk/Drivers/AgateSDX/FrameBufferSurface.cs 2009-11-25 18:40:19 UTC (rev 1129)
+++ trunk/Drivers/AgateSDX/FrameBufferSurface.cs 2009-11-28 02:16:52 UTC (rev 1130)
@@ -26,9 +26,19 @@
mDevice = mDisplay.D3D_Device;
mSize = size;
- mTexture = new Texture(mDevice.Device, mSize.Width, mSize.Height,
- 0, Usage.RenderTarget, Format.A8R8G8B8, Pool.Default);
-
+ try
+ {
+ mTexture = new Texture(mDevice.Device, mSize.Width, mSize.Height,
+ 0, Usage.RenderTarget, Format.A8R8G8B8, Pool.Default);
+ }
+ catch
+ {
+ Size newSize = SDX_Surface.NextPowerOfTwo(mSize);
+
+ mTexture = new Texture(mDevice.Device, newSize.Width, newSize.Height,
+ 0, Usage.RenderTarget, Format.A8R8G8B8, Pool.Default);
+ }
+
mRenderTarget = mTexture.GetSurfaceLevel(0);
mAgateSurface = new SDX_Surface(new AgateLib.Utility.Ref<Texture>(mTexture),
Modified: trunk/Drivers/AgateSDX/SDX_Display.cs
===================================================================
--- trunk/Drivers/AgateSDX/SDX_Display.cs 2009-11-25 18:40:19 UTC (rev 1129)
+++ trunk/Drivers/AgateSDX/SDX_Display.cs 2009-11-28 02:16:52 UTC (rev 1130)
@@ -407,7 +407,6 @@
mDevice.Clear(ClearFlags, color.ToArgb(), mDepthClear, mStencilClear, rects);
}
-
public override void DrawLine(Point a, Point b, Color color)
{
mDevice.DrawBuffer.Flush();
@@ -415,8 +414,13 @@
mLines[0] = new PositionColor(a.X, a.Y, 0, color.ToArgb());
mLines[1] = new PositionColor(b.X, b.Y, 0, color.ToArgb());
+ mDevice.SetDeviceStateTexture(null);
+ mDevice.AlphaArgument1 = TextureArgument.Diffuse;
+
mDevice.Device.VertexDeclaration = mPosColorDecl;
mDevice.Device.DrawUserPrimitives(SlimDX.Direct3D9.PrimitiveType.LineList, 1, mLines);
+
+ mDevice.AlphaArgument1 = TextureArgument.Texture;
}
public override void DrawLines(Point[] pt, Color color)
{
@@ -430,8 +434,11 @@
mLines[i] = new PositionColor(pt[i].X, pt[i].Y, 0, color.ToArgb());
}
+ mDevice.SetDeviceStateTexture(null);
+ mDevice.Device.SetTextureStageState(0, TextureStage.ColorArg0, TextureArgument.Diffuse);
mDevice.Device.VertexDeclaration = mPosColorDecl;
mDevice.Device.DrawUserPrimitives(Direct3D.PrimitiveType.LineStrip, pt.Length - 1, mLines);
+ mDevice.Device.SetTextureStageState(0, TextureStage.ColorArg0, TextureArgument.Current);
}
public override void DrawRect(Rectangle rect, Color color)
{
@@ -453,6 +460,7 @@
mDevice.Device.SetTextureStageState(0, TextureStage.ColorArg0, TextureArgument.Diffuse);
mDevice.Device.VertexDeclaration = mPosColorDecl;
mDevice.Device.DrawUserPrimitives(Direct3D.PrimitiveType.LineStrip, 4, mLines);
+ mDevice.Device.SetTextureStageState(0, TextureStage.ColorArg0, TextureArgument.Current);
}
PositionColor[] polygonVerts = new PositionColor[10];
Modified: trunk/Drivers/AgateSDX/SDX_Surface.cs
===================================================================
--- trunk/Drivers/AgateSDX/SDX_Surface.cs 2009-11-25 18:40:19 UTC (rev 1129)
+++ trunk/Drivers/AgateSDX/SDX_Surface.cs 2009-11-28 02:16:52 UTC (rev 1130)
@@ -673,6 +673,21 @@
mTexture.Value.UnlockRectangle(0);
}
+
+ internal static Size NextPowerOfTwo(Size size)
+ {
+ return new Size(NextPowerOfTwo(size.Width), NextPowerOfTwo(size.Height));
+ }
+
+ private static int NextPowerOfTwo(int value)
+ {
+ double log = Math.Log(value) / Math.Log(2);
+
+ double dval = Math.Pow(2, Math.Ceiling(log));
+ int retval = (int)dval;
+
+ return retval;
+ }
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ka...@us...> - 2009-11-25 18:40:27
|
Revision: 1129
http://agate.svn.sourceforge.net/agate/?rev=1129&view=rev
Author: kanato
Date: 2009-11-25 18:40:19 +0000 (Wed, 25 Nov 2009)
Log Message:
-----------
Reenable Display.PackAllSurfaces call in BBX.
Modified Paths:
--------------
trunk/Examples/BallBuster.Net/CImage.cs
Modified: trunk/Examples/BallBuster.Net/CImage.cs
===================================================================
--- trunk/Examples/BallBuster.Net/CImage.cs 2009-11-25 18:26:57 UTC (rev 1128)
+++ trunk/Examples/BallBuster.Net/CImage.cs 2009-11-25 18:40:19 UTC (rev 1129)
@@ -139,7 +139,7 @@
//this.fontStyler = new CL_TextStyler("Font2", &resources);
- //Display.PackAllSurfaces();
+ Display.PackAllSurfaces();
}
public void unload()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ka...@us...> - 2009-11-25 18:27:09
|
Revision: 1128
http://agate.svn.sourceforge.net/agate/?rev=1128&view=rev
Author: kanato
Date: 2009-11-25 18:26:57 +0000 (Wed, 25 Nov 2009)
Log Message:
-----------
Correct order of color components in draw buffer.
Modified Paths:
--------------
trunk/Drivers/AgateOTK/GL3/DrawBuffer.cs
trunk/Drivers/AgateOTK/Legacy/LegacyDrawBuffer.cs
Modified: trunk/Drivers/AgateOTK/GL3/DrawBuffer.cs
===================================================================
--- trunk/Drivers/AgateOTK/GL3/DrawBuffer.cs 2009-11-25 18:16:29 UTC (rev 1127)
+++ trunk/Drivers/AgateOTK/GL3/DrawBuffer.cs 2009-11-25 18:26:57 UTC (rev 1128)
@@ -202,24 +202,40 @@
mVerts[mIndex].U = texCoord.Left;
mVerts[mIndex].V = texCoord.Top;
- mVerts[mIndex].Color = color.TopLeft.ToArgb();
+ mVerts[mIndex].Color = ToAbgr(color.TopLeft);
mVerts[mIndex+1].U = texCoord.Right;
mVerts[mIndex+1].V = texCoord.Top;
- mVerts[mIndex + 1].Color = color.TopRight.ToArgb();
+ mVerts[mIndex + 1].Color = ToAbgr(color.TopRight);
mVerts[mIndex + 2].U = texCoord.Right;
mVerts[mIndex + 2].V = texCoord.Bottom;
- mVerts[mIndex + 2].Color = color.BottomRight.ToArgb();
+ mVerts[mIndex + 2].Color = ToAbgr(color.BottomRight);
mVerts[mIndex + 3].U = texCoord.Left;
mVerts[mIndex + 3].V = texCoord.Bottom;
- mVerts[mIndex + 3].Color = color.BottomLeft.ToArgb();
+ mVerts[mIndex + 3].Color = ToAbgr(color.BottomLeft);
mIndex += 4;
}
+
+ private int ToAbgr(Color c)
+ {
+ int val = c.A;
+
+ val <<= 8;
+ val |= c.B;
+
+ val <<= 8;
+ val |= c.G;
+
+ val <<= 8;
+ val |= c.R;
+
+ return val;
+ }
public override void Flush()
{
if (mIndex == 0)
Modified: trunk/Drivers/AgateOTK/Legacy/LegacyDrawBuffer.cs
===================================================================
--- trunk/Drivers/AgateOTK/Legacy/LegacyDrawBuffer.cs 2009-11-25 18:16:29 UTC (rev 1127)
+++ trunk/Drivers/AgateOTK/Legacy/LegacyDrawBuffer.cs 2009-11-25 18:26:57 UTC (rev 1128)
@@ -182,7 +182,8 @@
{
AddQuad(textureID, new Gradient(color), texCoord, pts);
}
- public override void AddQuad(int textureID, Gradient color, TextureCoordinates texCoord, PointF[] pts)
+
+ public override void AddQuad(int textureID, Gradient color, TextureCoordinates texCoord, PointF[] pts)
{
SetTexture(textureID);
@@ -202,24 +203,41 @@
mVerts[mIndex].U = texCoord.Left;
mVerts[mIndex].V = texCoord.Top;
- mVerts[mIndex].Color = color.TopLeft.ToArgb();
+ mVerts[mIndex].Color = ToAbgr(color.TopLeft);
- mVerts[mIndex+1].U = texCoord.Right;
- mVerts[mIndex+1].V = texCoord.Top;
- mVerts[mIndex + 1].Color = color.TopRight.ToArgb();
+ mVerts[mIndex + 1].U = texCoord.Right;
+ mVerts[mIndex + 1].V = texCoord.Top;
+ mVerts[mIndex + 1].Color = ToAbgr(color.TopRight);
mVerts[mIndex + 2].U = texCoord.Right;
mVerts[mIndex + 2].V = texCoord.Bottom;
- mVerts[mIndex + 2].Color = color.BottomRight.ToArgb();
+ mVerts[mIndex + 2].Color = ToAbgr(color.BottomRight);
mVerts[mIndex + 3].U = texCoord.Left;
mVerts[mIndex + 3].V = texCoord.Bottom;
- mVerts[mIndex + 3].Color = color.BottomLeft.ToArgb();
+ mVerts[mIndex + 3].Color = ToAbgr(color.BottomLeft);
mIndex += 4;
}
+
+ private int ToAbgr(Color c)
+ {
+ int val = c.A;
+
+ val <<= 8;
+ val |= c.B;
+
+ val <<= 8;
+ val |= c.G;
+
+ val <<= 8;
+ val |= c.R;
+
+ return val;
+ }
+
public override void Flush()
{
if (mIndex == 0)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ka...@us...> - 2009-11-25 18:16:47
|
Revision: 1127
http://agate.svn.sourceforge.net/agate/?rev=1127&view=rev
Author: kanato
Date: 2009-11-25 18:16:29 +0000 (Wed, 25 Nov 2009)
Log Message:
-----------
Fix source rect location.
Modified Paths:
--------------
trunk/Drivers/AgateOTK/GL_Surface.cs
trunk/Drivers/AgateSDX/SDX_Surface.cs
Modified: trunk/Drivers/AgateOTK/GL_Surface.cs
===================================================================
--- trunk/Drivers/AgateOTK/GL_Surface.cs 2009-11-25 01:57:08 UTC (rev 1126)
+++ trunk/Drivers/AgateOTK/GL_Surface.cs 2009-11-25 18:16:29 UTC (rev 1127)
@@ -192,6 +192,9 @@
srcRect.Width * (float)state.ScaleWidth,
srcRect.Height * (float)state.ScaleHeight);
+ srcRect.X += mSourceRect.X;
+ srcRect.Y += mSourceRect.Y;
+
if (displaySize.Width < 0)
{
destX -= dispSize.Width;
Modified: trunk/Drivers/AgateSDX/SDX_Surface.cs
===================================================================
--- trunk/Drivers/AgateSDX/SDX_Surface.cs 2009-11-25 01:57:08 UTC (rev 1126)
+++ trunk/Drivers/AgateSDX/SDX_Surface.cs 2009-11-25 18:16:29 UTC (rev 1127)
@@ -48,7 +48,6 @@
D3DDevice mDevice;
Ref<Texture> mTexture;
- RenderToSurface mRenderToSurface;
string mFileName;
@@ -143,17 +142,17 @@
mTexture = new Ref<Texture>(new Texture(mDevice.Device, size.Width, size.Height, 1, Usage.None,
Format.A8R8G8B8, Pool.Managed));
- mRenderToSurface = new RenderToSurface(mDevice.Device, size.Width, size.Height,
+ RenderToSurface render = new RenderToSurface(mDevice.Device, size.Width, size.Height,
Format.A8R8G8B8, Format.D16);
Viewport v = new Viewport(0, 0, size.Width, size.Height);
- mRenderToSurface.BeginScene(mTexture.Value.GetSurfaceLevel(0), v);
+ render.BeginScene(mTexture.Value.GetSurfaceLevel(0), v);
mDevice.Clear(ClearFlags.Target, Color.FromArgb(0, 0, 0, 0).ToArgb(), 1.0f, 0);
- mRenderToSurface.EndScene(Filter.None);
+ render.EndScene(Filter.None);
- mRenderToSurface.Dispose();
- mRenderToSurface = null;
+ render.Dispose();
+ render = null;
mTextureSize = mSrcRect.Size;
@@ -309,6 +308,9 @@
float mRotationCos = (float)Math.Cos(state.RotationAngle);
float mRotationSin = (float)Math.Sin(state.RotationAngle);
+ srcRect.X += mSrcRect.Left;
+ srcRect.Y += mSrcRect.Top;
+
if (displaySize.Width < 0)
{
destX -= displaySize.Width;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ka...@us...> - 2009-11-25 01:57:18
|
Revision: 1126
http://agate.svn.sourceforge.net/agate/?rev=1126&view=rev
Author: kanato
Date: 2009-11-25 01:57:08 +0000 (Wed, 25 Nov 2009)
Log Message:
-----------
Rename DisplayImp.Supports to DisplayImpl.CapsBool.
Correct query of MaxSurfaceSize with OPenGL.
Modified Paths:
--------------
trunk/AgateLib/DisplayLib/DisplayCapsInfo.cs
trunk/AgateLib/ImplementationBase/DisplayImpl.cs
trunk/Drivers/AgateDrawing/Drawing_Display.cs
trunk/Drivers/AgateOTK/GL_Display.cs
trunk/Drivers/AgateSDX/SDX_Display.cs
trunk/Tests/GuiTests/Textboxes.cs
trunk/Tests/Tests.csproj
Added Paths:
-----------
trunk/Tests/DisplayTests/Capabilities/
trunk/Tests/DisplayTests/Capabilities/Capabilities.cs
trunk/Tests/DisplayTests/Capabilities/frmCapabilities.Designer.cs
trunk/Tests/DisplayTests/Capabilities/frmCapabilities.cs
trunk/Tests/DisplayTests/Capabilities/frmCapabilities.resx
Modified: trunk/AgateLib/DisplayLib/DisplayCapsInfo.cs
===================================================================
--- trunk/AgateLib/DisplayLib/DisplayCapsInfo.cs 2009-11-24 20:45:10 UTC (rev 1125)
+++ trunk/AgateLib/DisplayLib/DisplayCapsInfo.cs 2009-11-25 01:57:08 UTC (rev 1126)
@@ -20,7 +20,7 @@
/// </summary>
public bool SupportsFullScreen
{
- get { return Display.Impl.Supports(DisplayBoolCaps.FullScreen); }
+ get { return Display.Impl.CapsBool(DisplayBoolCaps.FullScreen); }
}
/// <summary>
/// Indicates whether or not the screen resolution can be changed.
@@ -30,28 +30,28 @@
/// </summary>
public bool SupportsFullScreenModeSwitching
{
- get { return Display.Impl.Supports(DisplayBoolCaps.FullScreenModeSwitching); }
+ 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.Supports(DisplayBoolCaps.Scaling); }
+ 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.Supports(DisplayBoolCaps.Rotation); }
+ 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.Supports(DisplayBoolCaps.Color); }
+ get { return Display.Impl.CapsBool(DisplayBoolCaps.Color); }
}
/// <summary>
/// Indicates whether Surface gradients are supported. If not, then setting Surface.ColorGradient
@@ -60,51 +60,35 @@
/// </summary>
public bool SupportsGradient
{
- get { return Display.Impl.Supports(DisplayBoolCaps.Gradient); }
+ 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.Supports(DisplayBoolCaps.SurfaceAlpha); }
+ 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.Supports(DisplayBoolCaps.PixelAlpha); }
+ get { return Display.Impl.CapsBool(DisplayBoolCaps.PixelAlpha); }
}
/// <summary>
- /// Indicates whether or not lighting is supported.
- /// </summary>
- [Obsolete]
- public bool SupportsLighting
- {
- get { return Display.Impl.Supports(DisplayBoolCaps.Lighting); }
- }
- /// <summary>
- /// Indicates the maximum number of lights which can be used.
- /// </summary>
- [Obsolete]
- public int MaxLights
- {
- get { return 8; }
- }
- /// <summary>
/// Indicates whether there is hardware acceleration available for 2D and 3D drawing.
/// </summary>
public bool IsHardwareAccelerated
{
- get { return Display.Impl.Supports(DisplayBoolCaps.IsHardwareAccelerated); }
+ 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.Supports(DisplayBoolCaps.CustomShaders); }
+ get { return Display.Impl.CapsBool(DisplayBoolCaps.CustomShaders); }
}
/// <summary>
/// Indicates which shader language is supported.
@@ -119,7 +103,7 @@
/// </summary>
public bool CanCreateBitmapFont
{
- get { return Display.Impl.Supports(DisplayBoolCaps.CanCreateBitmapFont); }
+ get { return Display.Impl.CapsBool(DisplayBoolCaps.CanCreateBitmapFont); }
}
public Size MaxSurfaceSize
@@ -172,11 +156,6 @@
/// </summary>
PixelAlpha,
/// <summary>
- /// Indicates whether or not lighting is supported.
- /// </summary>
- [Obsolete]
- Lighting,
- /// <summary>
/// Indicates whether there is hardware acceleration available for 2D and 3D drawing.
/// </summary>
IsHardwareAccelerated,
Modified: trunk/AgateLib/ImplementationBase/DisplayImpl.cs
===================================================================
--- trunk/AgateLib/ImplementationBase/DisplayImpl.cs 2009-11-24 20:45:10 UTC (rev 1125)
+++ trunk/AgateLib/ImplementationBase/DisplayImpl.cs 2009-11-25 01:57:08 UTC (rev 1126)
@@ -38,9 +38,13 @@
private FrameBuffer mRenderTarget;
- public abstract bool Supports(DisplayBoolCaps caps);
+ #region --- Capabilities Reporting ---
+
+ public abstract bool CapsBool(DisplayBoolCaps caps);
public abstract Size CapsSize(DisplaySizeCaps displaySizeCaps);
+ #endregion
+
public abstract IEnumerable<DisplayLib.Shaders.ShaderLanguage> SupportedShaderLanguages { get; }
private static AgateShader mShader;
Modified: trunk/Drivers/AgateDrawing/Drawing_Display.cs
===================================================================
--- trunk/Drivers/AgateDrawing/Drawing_Display.cs 2009-11-24 20:45:10 UTC (rev 1125)
+++ trunk/Drivers/AgateDrawing/Drawing_Display.cs 2009-11-25 01:57:08 UTC (rev 1126)
@@ -288,7 +288,7 @@
#region --- IDisplayCaps Members ---
- public override bool Supports(DisplayBoolCaps caps)
+ public override bool CapsBool(DisplayBoolCaps caps)
{
switch (caps)
{
Modified: trunk/Drivers/AgateOTK/GL_Display.cs
===================================================================
--- trunk/Drivers/AgateOTK/GL_Display.cs 2009-11-24 20:45:10 UTC (rev 1125)
+++ trunk/Drivers/AgateOTK/GL_Display.cs 2009-11-25 01:57:08 UTC (rev 1126)
@@ -391,7 +391,7 @@
protected override ShaderCompilerImpl CreateShaderCompiler()
{
- if (this.Supports(DisplayBoolCaps.CustomShaders))
+ if (this.CapsBool(DisplayBoolCaps.CustomShaders))
{
if (mGLVersion < 2.0m)
return new ArbShaderCompiler();
@@ -485,7 +485,7 @@
#region --- Display Capabilities ---
- public override bool Supports(DisplayBoolCaps caps)
+ public override bool CapsBool(DisplayBoolCaps caps)
{
switch (caps)
{
@@ -508,7 +508,11 @@
{
switch (displaySizeCaps)
{
- case DisplaySizeCaps.MaxSurfaceSize: return new Size(1024, 1024);
+ case DisplaySizeCaps.MaxSurfaceSize:
+ int val;
+ GL.GetInteger(GetPName.MaxTextureSize, out val);
+
+ return new Size(val, val);
}
return new Size(0, 0);
Modified: trunk/Drivers/AgateSDX/SDX_Display.cs
===================================================================
--- trunk/Drivers/AgateSDX/SDX_Display.cs 2009-11-24 20:45:10 UTC (rev 1125)
+++ trunk/Drivers/AgateSDX/SDX_Display.cs 2009-11-25 01:57:08 UTC (rev 1126)
@@ -879,7 +879,7 @@
#region --- IDisplayCaps Members ---
- public override bool Supports(DisplayBoolCaps caps)
+ public override bool CapsBool(DisplayBoolCaps caps)
{
switch (caps)
{
Added: trunk/Tests/DisplayTests/Capabilities/Capabilities.cs
===================================================================
--- trunk/Tests/DisplayTests/Capabilities/Capabilities.cs (rev 0)
+++ trunk/Tests/DisplayTests/Capabilities/Capabilities.cs 2009-11-25 01:57:08 UTC (rev 1126)
@@ -0,0 +1,37 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace Tests.DisplayTests.Capabilities
+{
+ class Capabilities : IAgateTest
+ {
+ #region IAgateTest Members
+
+ public string Name
+ {
+ get { return "Capabilities"; }
+ }
+
+ public string Category
+ {
+ get { return "Display"; }
+ }
+
+ public void Main(string[] args)
+ {
+ using (AgateLib.AgateSetup setup = new AgateLib.AgateSetup())
+ {
+ setup.AskUser = true;
+ setup.Initialize(true, false, false);
+ if (setup.WasCanceled)
+ return;
+
+ new frmCapabilities().ShowDialog();
+ }
+ }
+
+ #endregion
+ }
+}
Added: trunk/Tests/DisplayTests/Capabilities/frmCapabilities.Designer.cs
===================================================================
--- trunk/Tests/DisplayTests/Capabilities/frmCapabilities.Designer.cs (rev 0)
+++ trunk/Tests/DisplayTests/Capabilities/frmCapabilities.Designer.cs 2009-11-25 01:57:08 UTC (rev 1126)
@@ -0,0 +1,60 @@
+namespace Tests.DisplayTests.Capabilities
+{
+ partial class frmCapabilities
+ {
+ /// <summary>
+ /// Required designer variable.
+ /// </summary>
+ private System.ComponentModel.IContainer components = null;
+
+ /// <summary>
+ /// Clean up any resources being used.
+ /// </summary>
+ /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ /// <summary>
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ /// </summary>
+ private void InitializeComponent()
+ {
+ this.propertyGrid1 = new System.Windows.Forms.PropertyGrid();
+ this.SuspendLayout();
+ //
+ // propertyGrid1
+ //
+ this.propertyGrid1.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.propertyGrid1.Location = new System.Drawing.Point(12, 12);
+ this.propertyGrid1.Name = "propertyGrid1";
+ this.propertyGrid1.Size = new System.Drawing.Size(495, 385);
+ this.propertyGrid1.TabIndex = 0;
+ //
+ // frmCapabilities
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(519, 409);
+ this.Controls.Add(this.propertyGrid1);
+ this.Name = "frmCapabilities";
+ this.Text = "Capabilities";
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.PropertyGrid propertyGrid1;
+ }
+}
\ No newline at end of file
Added: trunk/Tests/DisplayTests/Capabilities/frmCapabilities.cs
===================================================================
--- trunk/Tests/DisplayTests/Capabilities/frmCapabilities.cs (rev 0)
+++ trunk/Tests/DisplayTests/Capabilities/frmCapabilities.cs 2009-11-25 01:57:08 UTC (rev 1126)
@@ -0,0 +1,22 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Windows.Forms;
+
+namespace Tests.DisplayTests.Capabilities
+{
+ public partial class frmCapabilities : Form
+ {
+ public frmCapabilities()
+ {
+ InitializeComponent();
+
+ Text += AgateLib.Drivers.Registrar.DisplayDrivers[0].FriendlyName;
+ propertyGrid1.SelectedObject = AgateLib.DisplayLib.Display.Caps;
+ }
+ }
+}
Added: trunk/Tests/DisplayTests/Capabilities/frmCapabilities.resx
===================================================================
--- trunk/Tests/DisplayTests/Capabilities/frmCapabilities.resx (rev 0)
+++ trunk/Tests/DisplayTests/Capabilities/frmCapabilities.resx 2009-11-25 01:57:08 UTC (rev 1126)
@@ -0,0 +1,120 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+ <!--
+ Microsoft ResX Schema
+
+ Version 2.0
+
+ The primary goals of this format is to allow a simple XML format
+ that is mostly human readable. The generation and parsing of the
+ various data types are done through the TypeConverter classes
+ associated with the data types.
+
+ Example:
+
+ ... ado.net/XML headers & schema ...
+ <resheader name="resmimetype">text/microsoft-resx</resheader>
+ <resheader name="version">2.0</resheader>
+ <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+ <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+ <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
+ <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+ <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+ <value>[base64 mime encoded serialized .NET Framework object]</value>
+ </data>
+ <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+ <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
+ <comment>This is a comment</comment>
+ </data>
+
+ There are any number of "resheader" rows that contain simple
+ name/value pairs.
+
+ Each data row contains a name, and value. The row also contains a
+ type or mimetype. Type corresponds to a .NET class that support
+ text/value conversion through the TypeConverter architecture.
+ Classes that don't support this are serialized and stored with the
+ mimetype set.
+
+ The mimetype is used for serialized objects, and tells the
+ ResXResourceReader how to depersist the object. This is currently not
+ extensible. For a given mimetype the value must be set accordingly:
+
+ Note - application/x-microsoft.net.object.binary.base64 is the format
+ that the ResXResourceWriter will generate, however the reader can
+ read any of the formats listed below.
+
+ mimetype: application/x-microsoft.net.object.binary.base64
+ value : The object must be serialized with
+ : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.soap.base64
+ value : The object must be serialized with
+ : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.bytearray.base64
+ value : The object must be serialized into a byte array
+ : using a System.ComponentModel.TypeConverter
+ : and then encoded with base64 encoding.
+ -->
+ <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+ <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
+ <xsd:element name="root" msdata:IsDataSet="true">
+ <xsd:complexType>
+ <xsd:choice maxOccurs="unbounded">
+ <xsd:element name="metadata">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" />
+ </xsd:sequence>
+ <xsd:attribute name="name" use="required" type="xsd:string" />
+ <xsd:attribute name="type" type="xsd:string" />
+ <xsd:attribute name="mimetype" type="xsd:string" />
+ <xsd:attribute ref="xml:space" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="assembly">
+ <xsd:complexType>
+ <xsd:attribute name="alias" type="xsd:string" />
+ <xsd:attribute name="name" type="xsd:string" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="data">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
+ <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+ <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+ <xsd:attribute ref="xml:space" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="resheader">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" />
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:choice>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:schema>
+ <resheader name="resmimetype">
+ <value>text/microsoft-resx</value>
+ </resheader>
+ <resheader name="version">
+ <value>2.0</value>
+ </resheader>
+ <resheader name="reader">
+ <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+ <resheader name="writer">
+ <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+</root>
\ No newline at end of file
Modified: trunk/Tests/GuiTests/Textboxes.cs
===================================================================
--- trunk/Tests/GuiTests/Textboxes.cs 2009-11-24 20:45:10 UTC (rev 1125)
+++ trunk/Tests/GuiTests/Textboxes.cs 2009-11-25 01:57:08 UTC (rev 1126)
@@ -37,7 +37,7 @@
this.GuiRoot = new GuiRoot();
Window wind = new Window("Textboxes test");
- wind.Size = new AgateLib.Geometry.Size(500, 400);
+ wind.Size = new AgateLib.Geometry.Size(320, 240);
TextBox b = new TextBox();
b.Text = "This is a single line textbox.";
Modified: trunk/Tests/Tests.csproj
===================================================================
--- trunk/Tests/Tests.csproj 2009-11-24 20:45:10 UTC (rev 1125)
+++ trunk/Tests/Tests.csproj 2009-11-25 01:57:08 UTC (rev 1126)
@@ -95,6 +95,13 @@
<DependentUpon>PlatformDetection.cs</DependentUpon>
</Compile>
<Compile Include="CoreTests\PlatformDetection\PlatformDetector.cs" />
+ <Compile Include="DisplayTests\Capabilities\Capabilities.cs" />
+ <Compile Include="DisplayTests\Capabilities\frmCapabilities.cs">
+ <SubType>Form</SubType>
+ </Compile>
+ <Compile Include="DisplayTests\Capabilities\frmCapabilities.Designer.cs">
+ <DependentUpon>frmCapabilities.cs</DependentUpon>
+ </Compile>
<Compile Include="DisplayTests\ClipRect.cs" />
<Compile Include="Fonts\Builtin.cs" />
<Compile Include="frmLauncher.cs">
@@ -326,6 +333,9 @@
<EmbeddedResource Include="CoreTests\PlatformDetection\PlatformDetection.resx">
<DependentUpon>PlatformDetection.cs</DependentUpon>
</EmbeddedResource>
+ <EmbeddedResource Include="DisplayTests\Capabilities\frmCapabilities.resx">
+ <DependentUpon>frmCapabilities.cs</DependentUpon>
+ </EmbeddedResource>
<EmbeddedResource Include="frmLauncher.resx">
<SubType>Designer</SubType>
<DependentUpon>frmLauncher.cs</DependentUpon>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ka...@us...> - 2009-11-24 20:45:26
|
Revision: 1125
http://agate.svn.sourceforge.net/agate/?rev=1125&view=rev
Author: kanato
Date: 2009-11-24 20:45:10 +0000 (Tue, 24 Nov 2009)
Log Message:
-----------
Merge in gui branch.
Not working in OpenGL or Direct3D yet.
Modified Paths:
--------------
trunk/AgateLib/AgateGame.cs
trunk/AgateLib/AgateLib.csproj
trunk/AgateLib/BitmapFont/BitmapFontImpl.cs
trunk/AgateLib/DisplayLib/Display.cs
trunk/AgateLib/DisplayLib/FontSurface.cs
trunk/AgateLib/DisplayLib/FrameBuffer.cs
trunk/AgateLib/ImplementationBase/FontSurfaceImpl.cs
trunk/AgateLib/InternalResources/Data.cs
trunk/AgateLib/InternalResources/DataResources.Designer.cs
trunk/AgateLib/InternalResources/DataResources.resx
trunk/AgateLib/Resources/AgateResourceCollection.cs
trunk/AgateLib/Utility/ZipFileProvider.cs
trunk/Drivers/AgateDrawing/Drawing_Display.cs
trunk/Drivers/AgateDrawing/Drawing_FontSurface.cs
trunk/Drivers/AgateLib.WinForms/BitmapFontUtil.cs
trunk/Drivers/AgateOTK/GL_Display.cs
trunk/Drivers/AgateSDX/FrameBufferWindow.cs
trunk/Drivers/AgateSDX/SDX_Display.cs
trunk/Drivers/AgateSDX/SDX_DisplayWindow.cs
trunk/Tests/Tests.csproj
trunk/Tests/frmLauncher.Designer.cs
Added Paths:
-----------
trunk/AgateLib/Gui/
trunk/AgateLib/Gui/AgateGuiException.cs
trunk/AgateLib/Gui/Button.cs
trunk/AgateLib/Gui/Cache/
trunk/AgateLib/Gui/Cache/WidgetCache.cs
trunk/AgateLib/Gui/CheckBox.cs
trunk/AgateLib/Gui/ComboBox.cs
trunk/AgateLib/Gui/Container.cs
trunk/AgateLib/Gui/GuiRoot.cs
trunk/AgateLib/Gui/IGuiThemeEngine.cs
trunk/AgateLib/Gui/ILayoutPerformer.cs
trunk/AgateLib/Gui/Label.cs
trunk/AgateLib/Gui/Layout/
trunk/AgateLib/Gui/Layout/BoxLayoutBase.cs
trunk/AgateLib/Gui/Layout/Grid.cs
trunk/AgateLib/Gui/Layout/HorizontalBox.cs
trunk/AgateLib/Gui/Layout/VerticalBox.cs
trunk/AgateLib/Gui/LayoutExpand.cs
trunk/AgateLib/Gui/ListBox.cs
trunk/AgateLib/Gui/Panel.cs
trunk/AgateLib/Gui/RadioButton.cs
trunk/AgateLib/Gui/TextBox.cs
trunk/AgateLib/Gui/ThemeEngines/
trunk/AgateLib/Gui/ThemeEngines/Mercury/
trunk/AgateLib/Gui/ThemeEngines/Mercury/Cache/
trunk/AgateLib/Gui/ThemeEngines/Mercury/Cache/TextBoxCache.cs
trunk/AgateLib/Gui/ThemeEngines/Mercury/Mercury.cs
trunk/AgateLib/Gui/ThemeEngines/Mercury/MercuryScheme.cs
trunk/AgateLib/Gui/Widget.cs
trunk/AgateLib/Gui/WidgetList.cs
trunk/AgateLib/Gui/Window.cs
trunk/AgateLib/InternalResources/Fonts.zip
trunk/AgateLib/InternalResources/agate-black-gui.zip
trunk/Tests/Fonts/Builtin.cs
trunk/Tests/GuiTests/
trunk/Tests/GuiTests/RenderGui.cs
trunk/Tests/GuiTests/Textboxes.cs
Removed Paths:
-------------
trunk/AgateLib/Gui/AgateGuiException.cs
trunk/AgateLib/Gui/Button.cs
trunk/AgateLib/Gui/Cache/
trunk/AgateLib/Gui/Cache/WidgetCache.cs
trunk/AgateLib/Gui/CheckBox.cs
trunk/AgateLib/Gui/ComboBox.cs
trunk/AgateLib/Gui/Container.cs
trunk/AgateLib/Gui/GuiRoot.cs
trunk/AgateLib/Gui/IGuiThemeEngine.cs
trunk/AgateLib/Gui/ILayoutPerformer.cs
trunk/AgateLib/Gui/Label.cs
trunk/AgateLib/Gui/Layout/
trunk/AgateLib/Gui/Layout/BoxLayoutBase.cs
trunk/AgateLib/Gui/Layout/Grid.cs
trunk/AgateLib/Gui/Layout/HorizontalBox.cs
trunk/AgateLib/Gui/Layout/VerticalBox.cs
trunk/AgateLib/Gui/LayoutExpand.cs
trunk/AgateLib/Gui/ListBox.cs
trunk/AgateLib/Gui/Panel.cs
trunk/AgateLib/Gui/RadioButton.cs
trunk/AgateLib/Gui/TextBox.cs
trunk/AgateLib/Gui/ThemeEngines/
trunk/AgateLib/Gui/ThemeEngines/Mercury/
trunk/AgateLib/Gui/ThemeEngines/Mercury/Cache/
trunk/AgateLib/Gui/ThemeEngines/Mercury/Cache/TextBoxCache.cs
trunk/AgateLib/Gui/ThemeEngines/Mercury/Mercury.cs
trunk/AgateLib/Gui/ThemeEngines/Mercury/MercuryScheme.cs
trunk/AgateLib/Gui/Widget.cs
trunk/AgateLib/Gui/WidgetList.cs
trunk/AgateLib/Gui/Window.cs
trunk/AgateLib/PlatformSpecific/
trunk/Tests/GuiTests/RenderGui.cs
trunk/Tests/GuiTests/Textboxes.cs
Property Changed:
----------------
trunk/
trunk/AgateLib/
trunk/AgateLib/AgateFileProvider.cs
trunk/AgateLib/AgateSetup.cs
trunk/AgateLib/AudioLib/
trunk/AgateLib/AudioLib/Audio.cs
trunk/AgateLib/BitmapFont/FontMetrics.cs
trunk/AgateLib/BitmapFont/GlyphMetrics.cs
trunk/AgateLib/Core.cs
trunk/AgateLib/DisplayLib/
trunk/AgateLib/DisplayLib/Display.cs
trunk/AgateLib/DisplayLib/StringTransformer.cs
trunk/AgateLib/Drivers/AgateDriverReporter.cs
trunk/AgateLib/Drivers/IDesktopDriver.cs
trunk/AgateLib/ImplementationBase/
trunk/AgateLib/ImplementationBase/AudioImpl.cs
trunk/AgateLib/InputLib/
trunk/AgateLib/Resources/AgateResourceCollection.cs
trunk/AgateLib/Resources/AgateResourceLoader.cs
trunk/AgateLib/Resources/BitmapFontResource.cs
trunk/AgateLib/Sprites/Sprite.cs
trunk/AgateLib/Sprites/SpriteFrame.cs
trunk/AgateLib/Timing.cs
trunk/AgateLib/Utility/Platform.cs
trunk/Drivers/
trunk/Drivers/AgateDrawing/Drawing_Reporter.cs
trunk/Drivers/AgateLib.WinForms/
trunk/Drivers/AgateOTK/GL3/
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/Legacy/
trunk/Drivers/AgateOTK/Legacy/ArbShader.cs
trunk/Drivers/AgateOTK/Legacy/ArbShaderCompiler.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/AgateSDL/
trunk/Drivers/AgateSDL/Audio/SDL_Audio.cs
trunk/Drivers/AgateSDL/Audio/SDL_Music.cs
trunk/Drivers/AgateSDL/Audio/SDL_SoundBuffer.cs
trunk/Drivers/AgateSDL/Audio/SDL_SoundBufferSession.cs
trunk/Drivers/AgateSDL/Input/SDL_Input.cs
trunk/Drivers/AgateSDL/Reporter.cs
trunk/Examples/BallBuster.Net/OpenTK.dll.config
trunk/Examples/ShootTheTraps/Properties/
trunk/Examples/ShootTheTraps/Properties/AssemblyInfo.cs
trunk/Tests/CoreTests/
trunk/Tests/DisplayTests/SurfaceTester/SurfaceTester.cs
trunk/Tests/DisplayTests/TestPacker/TestPacker.cs
trunk/Tests/DisplayTests/TestPacker/frmTestPacker.Designer.cs
trunk/Tests/DisplayTests/TestPacker/frmTestPacker.cs
trunk/Tests/DisplayTests/TestPacker/frmTestPacker.resx
trunk/Tests/DisplayTests/TileTester/TileTester.cs
trunk/Tests/DisplayTests/TileTester/frmTileTester.Designer.cs
trunk/Tests/DisplayTests/TileTester/frmTileTester.cs
trunk/Tests/DisplayTests/TileTester/frmTileTester.resx
trunk/Tests/InputTests/Input/
trunk/Tests/InputTests/Input/InputTester.cs
trunk/Tests/InputTests/Input/frmInputTester.Designer.cs
trunk/Tests/InputTests/Input/frmInputTester.cs
trunk/Tests/InputTests/InputState/
trunk/Tests/InputTests/InputState/InputStateTester.cs
trunk/Tools/FontCreator/CreateFont.Designer.cs
trunk/Tools/FontCreator/CreateFont.cs
trunk/Tools/FontCreator/CreateFont.resx
trunk/Tools/FontCreator/EditGlyphs.Designer.cs
trunk/Tools/FontCreator/EditGlyphs.cs
trunk/Tools/FontCreator/EditGlyphs.resx
trunk/Tools/FontCreator/SaveFont.Designer.cs
trunk/Tools/FontCreator/SaveFont.cs
trunk/Tools/FontCreator/SaveFont.resx
trunk/Tools/FontCreator/frmFontCreator.Designer.cs
trunk/Tools/FontCreator/frmFontCreator.cs
trunk/Tools/FontCreator/frmFontCreator.resx
trunk/Tools/PackedSpriteCreator/SpriteEditor.Designer.cs
trunk/Tools/PackedSpriteCreator/SpriteEditor.cs
trunk/Tools/PackedSpriteCreator/SpriteEditor.resx
trunk/Tools/PackedSpriteCreator/SpritePacker.cs
Property changes on: trunk
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/agate-3d:629-702,840-864
/branches/agate3d-3.2:923-1034
/branches/build:424-517,1081-1084
/branches/font:778-916
/branches/merge-tests:806-810
/branches/otkupdate:1068-1076
/branches/registrar:595-599
/branches/shaders:1087-1111
/branches/sprites:463-513
+ /branches/agate-3d:629-702,840-864
/branches/agate3d-3.2:923-1034
/branches/build:424-517,1081-1084
/branches/font:778-916
/branches/gui-3.2:881-1019
/branches/merge-tests:806-810
/branches/otkupdate:1068-1076
/branches/registrar:595-599
/branches/shaders:1087-1111
/branches/sprites:463-513
Property changes on: trunk/AgateLib
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/agate-3d/AgateLib:629-702,840-864
/branches/agate3d-3.2/AgateLib:923-1034
/branches/build/AgateLib:447-448,501-517,1081-1084
/branches/font/AgateLib:778-916
/branches/merge-tests/AgateLib:806-810
/branches/otkupdate/AgateLib:1068-1076
/branches/registrar/AgateLib:595-599
/branches/shaders/AgateLib:1087-1111
/branches/sprites/AgateLib:463-513
+ /branches/agate-3d/AgateLib:629-702,840-864
/branches/agate3d-3.2/AgateLib:923-1034
/branches/build/AgateLib:447-448,501-517,1081-1084
/branches/font/AgateLib:778-916
/branches/gui-3.2/AgateLib:881-1019
/branches/merge-tests/AgateLib:806-810
/branches/otkupdate/AgateLib:1068-1076
/branches/registrar/AgateLib:595-599
/branches/shaders/AgateLib:1087-1111
/branches/sprites/AgateLib:463-513
Property changes on: trunk/AgateLib/AgateFileProvider.cs
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/agate3d-3.2/AgateLib/AgateFileProvider.cs:923-1034
/branches/build/AgateLib/AgateFileProvider.cs:1081-1084
/branches/build/AgateLib/Utility/AgateFileProvider.cs:447-517
/branches/font/AgateLib/AgateFileProvider.cs:778-916
/branches/merge-tests/AgateLib/AgateFileProvider.cs:806-810
/branches/otkupdate/AgateLib/AgateFileProvider.cs:1068-1076
/branches/registrar/AgateLib/Utility/AgateFileProvider.cs:595-599
/branches/shaders/AgateLib/AgateFileProvider.cs:1087-1111
/branches/sprites/AgateLib/Utility/AgateFileProvider.cs:463-513
+ /branches/agate3d-3.2/AgateLib/AgateFileProvider.cs:923-1034
/branches/build/AgateLib/AgateFileProvider.cs:1081-1084
/branches/build/AgateLib/Utility/AgateFileProvider.cs:447-517
/branches/font/AgateLib/AgateFileProvider.cs:778-916
/branches/gui-3.2/AgateLib/AgateFileProvider.cs:881-1019
/branches/merge-tests/AgateLib/AgateFileProvider.cs:806-810
/branches/otkupdate/AgateLib/AgateFileProvider.cs:1068-1076
/branches/registrar/AgateLib/Utility/AgateFileProvider.cs:595-599
/branches/shaders/AgateLib/AgateFileProvider.cs:1087-1111
/branches/sprites/AgateLib/Utility/AgateFileProvider.cs:463-513
Modified: trunk/AgateLib/AgateGame.cs
===================================================================
--- trunk/AgateLib/AgateGame.cs 2009-11-24 18:21:02 UTC (rev 1124)
+++ trunk/AgateLib/AgateGame.cs 2009-11-24 20:45:10 UTC (rev 1125)
@@ -45,6 +45,7 @@
DisplayWindow mWindow;
AppInitParameters mInitParams;
FontSurface font;
+ Gui.GuiRoot mGui;
double totalSplashTime = 0;
bool splashFadeDone = false;
@@ -82,7 +83,7 @@
CreateDisplayWindow();
- font = new FontSurface("Arial", 12.0f);
+ font = FontSurface.Gentium12;
if (InitParams.ShowSplashScreen)
{
@@ -95,11 +96,17 @@
{
Update(Display.DeltaTime);
+ if (GuiRoot != null)
+ GuiRoot.DoUpdate();
+
Display.RenderTarget = mWindow;
Display.BeginFrame();
Render();
+ if (GuiRoot != null)
+ GuiRoot.Draw();
+
Display.EndFrame();
Core.KeepAlive();
}
@@ -112,7 +119,11 @@
{
get
{
- mInitParams = mInitParams ?? GetAppInitParameters();
+ if (mInitParams == null)
+ {
+ mInitParams = GetAppInitParameters();
+ AdjustAppInitParameters(ref mInitParams);
+ }
return mInitParams;
}
}
@@ -237,7 +248,7 @@
Surface powered = InternalResources.Data.PoweredBy;
Size size = powered.SurfaceSize;
- int left = (int)(totalSplashTime * size.Width - size.Width)+1;
+ int left = (int)(totalSplashTime * size.Width - size.Width) + 1;
Rectangle gradientRect = new Rectangle(left, MainWindow.Height - size.Height,
size.Width, size.Height);
@@ -277,11 +288,20 @@
/// Gets the initialization parameters.
/// </summary>
/// <returns></returns>
+ [Obsolete("Override AdjustAppInitParameters")]
protected virtual AppInitParameters GetAppInitParameters()
{
return new AppInitParameters();
}
+ /// <summary>
+ /// Adjusts the initialization parameters.
+ /// </summary>
+ /// <param name="initParams"></param>
+ protected virtual void AdjustAppInitParameters(ref AppInitParameters initParams)
+ {
+ }
+
protected virtual Size WindowSize { get { return new Size(800, 600); } }
protected virtual bool FullScreen { get { return false; } }
@@ -296,6 +316,24 @@
get { return mWindow; }
}
+ public Gui.GuiRoot GuiRoot
+ {
+ get { return mGui; }
+ set
+ {
+ if (value == null && mGui == null)
+ return;
+
+ if (mGui != null)
+ mGui.EnableInteraction = false;
+
+ mGui = value;
+
+ if (mGui != null)
+ mGui.EnableInteraction = true;
+ }
+ }
+
#endregion
/// <summary>
Modified: trunk/AgateLib/AgateLib.csproj
===================================================================
--- trunk/AgateLib/AgateLib.csproj 2009-11-24 18:21:02 UTC (rev 1124)
+++ trunk/AgateLib/AgateLib.csproj 2009-11-24 20:45:10 UTC (rev 1125)
@@ -110,6 +110,31 @@
<Compile Include="DisplayLib\Shaders\Lighting2D.cs" />
<Compile Include="DisplayLib\Shaders\Lighting3D.cs" />
<Compile Include="Geometry\VertexTypes\PositionTextureColorNormal.cs" />
+ <Compile Include="Gui\AgateGuiException.cs" />
+ <Compile Include="Gui\Button.cs" />
+ <Compile Include="Gui\Cache\WidgetCache.cs" />
+ <Compile Include="Gui\CheckBox.cs" />
+ <Compile Include="Gui\ComboBox.cs" />
+ <Compile Include="Gui\Container.cs" />
+ <Compile Include="Gui\GuiRoot.cs" />
+ <Compile Include="Gui\IGuiThemeEngine.cs" />
+ <Compile Include="Gui\ILayoutPerformer.cs" />
+ <Compile Include="Gui\Label.cs" />
+ <Compile Include="Gui\LayoutExpand.cs" />
+ <Compile Include="Gui\Layout\BoxLayoutBase.cs" />
+ <Compile Include="Gui\Layout\Grid.cs" />
+ <Compile Include="Gui\Layout\HorizontalBox.cs" />
+ <Compile Include="Gui\Layout\VerticalBox.cs" />
+ <Compile Include="Gui\ListBox.cs" />
+ <Compile Include="Gui\Panel.cs" />
+ <Compile Include="Gui\RadioButton.cs" />
+ <Compile Include="Gui\TextBox.cs" />
+ <Compile Include="Gui\ThemeEngines\Mercury\Cache\TextBoxCache.cs" />
+ <Compile Include="Gui\ThemeEngines\Mercury\Mercury.cs" />
+ <Compile Include="Gui\ThemeEngines\Mercury\MercuryScheme.cs" />
+ <Compile Include="Gui\Widget.cs" />
+ <Compile Include="Gui\WidgetList.cs" />
+ <Compile Include="Gui\Window.cs" />
<Compile Include="IFileProvider.cs">
<SubType>Code</SubType>
</Compile>
@@ -525,6 +550,11 @@
<LastGenOutput>DataResources.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
+ <ItemGroup>
+ <None Include="InternalResources\agate-black-gui.zip" />
+ <None Include="InternalResources\Fonts.zip" />
+ <None Include="InternalResources\images.tar.gz" />
+ </ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />
<PropertyGroup>
<PreBuildEvent>
Property changes on: trunk/AgateLib/AgateSetup.cs
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/agate-3d/AgateLib/AgateSetup.cs:629-702,840-864
/branches/agate3d-3.2/AgateLib/AgateSetup.cs:923-1034
/branches/build/AgateLib/AgateSetup.cs:501-517,1081-1084
/branches/font/AgateLib/AgateSetup.cs:778-916
/branches/merge-tests/AgateLib/AgateSetup.cs:806-810
/branches/otkupdate/AgateLib/AgateSetup.cs:1068-1076
/branches/registrar/AgateLib/AgateSetup.cs:595-599
/branches/shaders/AgateLib/AgateSetup.cs:1087-1111
/branches/sprites/AgateLib/AgateSetup.cs:463-513
+ /branches/agate-3d/AgateLib/AgateSetup.cs:629-702,840-864
/branches/agate3d-3.2/AgateLib/AgateSetup.cs:923-1034
/branches/build/AgateLib/AgateSetup.cs:501-517,1081-1084
/branches/font/AgateLib/AgateSetup.cs:778-916
/branches/gui-3.2/AgateLib/AgateSetup.cs:881-1019
/branches/merge-tests/AgateLib/AgateSetup.cs:806-810
/branches/otkupdate/AgateLib/AgateSetup.cs:1068-1076
/branches/registrar/AgateLib/AgateSetup.cs:595-599
/branches/shaders/AgateLib/AgateSetup.cs:1087-1111
/branches/sprites/AgateLib/AgateSetup.cs:463-513
Property changes on: trunk/AgateLib/AudioLib
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/agate-3d/AgateLib/AudioLib:629-702,840-864
/branches/agate3d-3.2/AgateLib/AudioLib:923-1034
/branches/build/AgateLib/AudioLib:1081-1084
/branches/font/AgateLib/AudioLib:778-916
/branches/merge-tests/AgateLib/AudioLib:806-810
/branches/otkupdate/AgateLib/AudioLib:1068-1076
/branches/registrar/AgateLib/AudioLib:595-599
/branches/shaders/AgateLib/AudioLib:1087-1111
/branches/sprites/AgateLib/AudioLib:463-513
+ /branches/agate-3d/AgateLib/AudioLib:629-702,840-864
/branches/agate3d-3.2/AgateLib/AudioLib:923-1034
/branches/build/AgateLib/AudioLib:1081-1084
/branches/font/AgateLib/AudioLib:778-916
/branches/gui-3.2/AgateLib/AudioLib:881-1019
/branches/merge-tests/AgateLib/AudioLib:806-810
/branches/otkupdate/AgateLib/AudioLib:1068-1076
/branches/registrar/AgateLib/AudioLib:595-599
/branches/shaders/AgateLib/AudioLib:1087-1111
/branches/sprites/AgateLib/AudioLib:463-513
Property changes on: trunk/AgateLib/AudioLib/Audio.cs
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/agate-3d/AgateLib/AudioLib/Audio.cs:629-702,840-864
/branches/agate3d-3.2/AgateLib/AudioLib/Audio.cs:923-1034
/branches/build/AgateLib/AudioLib/Audio.cs:501-517,1081-1084
/branches/font/AgateLib/AudioLib/Audio.cs:778-916
/branches/merge-tests/AgateLib/AudioLib/Audio.cs:806-810
/branches/otkupdate/AgateLib/AudioLib/Audio.cs:1068-1076
/branches/registrar/AgateLib/AudioLib/Audio.cs:595-599
/branches/shaders/AgateLib/AudioLib/Audio.cs:1087-1111
/branches/sprites/AgateLib/AudioLib/Audio.cs:463-513
+ /branches/agate-3d/AgateLib/AudioLib/Audio.cs:629-702,840-864
/branches/agate3d-3.2/AgateLib/AudioLib/Audio.cs:923-1034
/branches/build/AgateLib/AudioLib/Audio.cs:501-517,1081-1084
/branches/font/AgateLib/AudioLib/Audio.cs:778-916
/branches/gui-3.2/AgateLib/AudioLib/Audio.cs:881-1019
/branches/merge-tests/AgateLib/AudioLib/Audio.cs:806-810
/branches/otkupdate/AgateLib/AudioLib/Audio.cs:1068-1076
/branches/registrar/AgateLib/AudioLib/Audio.cs:595-599
/branches/shaders/AgateLib/AudioLib/Audio.cs:1087-1111
/branches/sprites/AgateLib/AudioLib/Audio.cs:463-513
Modified: trunk/AgateLib/BitmapFont/BitmapFontImpl.cs
===================================================================
--- trunk/AgateLib/BitmapFont/BitmapFontImpl.cs 2009-11-24 18:21:02 UTC (rev 1124)
+++ trunk/AgateLib/BitmapFont/BitmapFontImpl.cs 2009-11-24 20:45:10 UTC (rev 1125)
@@ -86,6 +86,7 @@
/// <param name="characterSize"></param>
public BitmapFontImpl(string filename, Size characterSize)
{
+ FontName = System.IO.Path.GetFileNameWithoutExtension(filename);
mFontMetrics = new FontMetrics();
mSurface = new Surface(filename);
@@ -101,8 +102,9 @@
/// <param name="surface">Surface which contains the image data for the font glyphs.</param>
/// <param name="fontMetrics">FontMetrics structure which describes how characters
/// are laid out.</param>
- public BitmapFontImpl(Surface surface, FontMetrics fontMetrics)
+ public BitmapFontImpl(Surface surface, FontMetrics fontMetrics, string name)
{
+ FontName = name;
mFontMetrics = (FontMetrics)((ICloneable)fontMetrics).Clone();
float maxHeight = 0;
@@ -179,7 +181,7 @@
mAverageCharWidth = total / (double)count;
}
- public override Size StringDisplaySize(FontState state, string text)
+ public override Size MeasureString(FontState state, string text)
{
if (string.IsNullOrEmpty(text))
return Size.Empty;
@@ -197,6 +199,9 @@
for (int j = 0; j < line.Length; j++)
{
+ if (mFontMetrics.ContainsKey(line[j]) == false)
+ continue;
+
lineWidth += mFontMetrics[line[j]].Width;
}
@@ -262,6 +267,10 @@
break;
default:
+ if (mFontMetrics.ContainsKey(text[i]) == false)
+ {
+ break;
+ }
GlyphMetrics glyph = mFontMetrics[text[i]];
destX = Math.Max(0, destX - glyph.LeftOverhang * ScaleWidth);
@@ -332,7 +341,7 @@
if (state.DisplayAlignment != OriginAlignment.TopLeft)
{
Point value = Origin.Calc(state.DisplayAlignment,
- StringDisplaySize(state, state.Text));
+ MeasureString(state, state.Text));
dest.X -= value.X;
dest.Y -= value.Y;
Property changes on: trunk/AgateLib/BitmapFont/FontMetrics.cs
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/agate-3d/AgateLib/BitmapFont/FontMetrics.cs:629-702,840-864
/branches/agate3d-3.2/AgateLib/BitmapFont/FontMetrics.cs:923-1034
/branches/build/AgateLib/BitmapFont/FontMetrics.cs:1081-1084
/branches/font/AgateLib/BitmapFont/FontMetrics.cs:778-916
/branches/merge-tests/AgateLib/BitmapFont/FontMetrics.cs:806-810
/branches/otkupdate/AgateLib/BitmapFont/FontMetrics.cs:1068-1076
/branches/shaders/AgateLib/BitmapFont/FontMetrics.cs:1087-1111
+ /branches/agate-3d/AgateLib/BitmapFont/FontMetrics.cs:629-702,840-864
/branches/agate3d-3.2/AgateLib/BitmapFont/FontMetrics.cs:923-1034
/branches/build/AgateLib/BitmapFont/FontMetrics.cs:1081-1084
/branches/font/AgateLib/BitmapFont/FontMetrics.cs:778-916
/branches/gui-3.2/AgateLib/BitmapFont/FontMetrics.cs:881-1019
/branches/merge-tests/AgateLib/BitmapFont/FontMetrics.cs:806-810
/branches/otkupdate/AgateLib/BitmapFont/FontMetrics.cs:1068-1076
/branches/shaders/AgateLib/BitmapFont/FontMetrics.cs:1087-1111
Property changes on: trunk/AgateLib/BitmapFont/GlyphMetrics.cs
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/agate-3d/AgateLib/BitmapFont/GlyphMetrics.cs:629-702,840-864
/branches/agate3d-3.2/AgateLib/BitmapFont/GlyphMetrics.cs:923-1034
/branches/build/AgateLib/BitmapFont/GlyphMetrics.cs:1081-1084
/branches/build/AgateLib/Resources/GlyphMetrics.cs:447-517
/branches/font/AgateLib/BitmapFont/GlyphMetrics.cs:778-916
/branches/merge-tests/AgateLib/BitmapFont/GlyphMetrics.cs:806-810
/branches/otkupdate/AgateLib/BitmapFont/GlyphMetrics.cs:1068-1076
/branches/registrar/AgateLib/Resources/GlyphMetrics.cs:595-599
/branches/shaders/AgateLib/BitmapFont/GlyphMetrics.cs:1087-1111
/branches/sprites/AgateLib/Resources/GlyphMetrics.cs:463-513
+ /branches/agate-3d/AgateLib/BitmapFont/GlyphMetrics.cs:629-702,840-864
/branches/agate3d-3.2/AgateLib/BitmapFont/GlyphMetrics.cs:923-1034
/branches/build/AgateLib/BitmapFont/GlyphMetrics.cs:1081-1084
/branches/build/AgateLib/Resources/GlyphMetrics.cs:447-517
/branches/font/AgateLib/BitmapFont/GlyphMetrics.cs:778-916
/branches/gui-3.2/AgateLib/BitmapFont/GlyphMetrics.cs:881-1019
/branches/merge-tests/AgateLib/BitmapFont/GlyphMetrics.cs:806-810
/branches/otkupdate/AgateLib/BitmapFont/GlyphMetrics.cs:1068-1076
/branches/registrar/AgateLib/Resources/GlyphMetrics.cs:595-599
/branches/shaders/AgateLib/BitmapFont/GlyphMetrics.cs:1087-1111
/branches/sprites/AgateLib/Resources/GlyphMetrics.cs:463-513
Property changes on: trunk/AgateLib/Core.cs
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/agate-3d/AgateLib/Core.cs:629-702,840-864
/branches/agate3d-3.2/AgateLib/Core.cs:923-1034
/branches/build/AgateLib/Core.cs:501-517,1081-1084
/branches/font/AgateLib/Core.cs:778-916
/branches/merge-tests/AgateLib/Core.cs:806-810
/branches/otkupdate/AgateLib/Core.cs:1068-1076
/branches/registrar/AgateLib/Core.cs:595-599
/branches/shaders/AgateLib/Core.cs:1087-1111
/branches/sprites/AgateLib/Core.cs:463-513
+ /branches/agate-3d/AgateLib/Core.cs:629-702,840-864
/branches/agate3d-3.2/AgateLib/Core.cs:923-1034
/branches/build/AgateLib/Core.cs:501-517,1081-1084
/branches/font/AgateLib/Core.cs:778-916
/branches/gui-3.2/AgateLib/Core.cs:881-1019
/branches/merge-tests/AgateLib/Core.cs:806-810
/branches/otkupdate/AgateLib/Core.cs:1068-1076
/branches/registrar/AgateLib/Core.cs:595-599
/branches/shaders/AgateLib/Core.cs:1087-1111
/branches/sprites/AgateLib/Core.cs:463-513
Property changes on: trunk/AgateLib/DisplayLib
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/agate-3d/AgateLib/DisplayLib:629-702,840-864
/branches/agate3d-3.2/AgateLib/DisplayLib:923-1034
/branches/build/AgateLib/DisplayLib:1081-1084
/branches/font/AgateLib/DisplayLib:778-916
/branches/merge-tests/AgateLib/DisplayLib:806-810
/branches/otkupdate/AgateLib/DisplayLib:1068-1076
/branches/registrar/AgateLib/DisplayLib:595-599
/branches/shaders/AgateLib/DisplayLib:1087-1111
/branches/sprites/AgateLib/DisplayLib:463-513
+ /branches/agate-3d/AgateLib/DisplayLib:629-702,840-864
/branches/agate3d-3.2/AgateLib/DisplayLib:923-1034
/branches/build/AgateLib/DisplayLib:1081-1084
/branches/font/AgateLib/DisplayLib:778-916
/branches/gui-3.2/AgateLib/DisplayLib:881-1019
/branches/merge-tests/AgateLib/DisplayLib:806-810
/branches/otkupdate/AgateLib/DisplayLib:1068-1076
/branches/registrar/AgateLib/DisplayLib:595-599
/branches/shaders/AgateLib/DisplayLib:1087-1111
/branches/sprites/AgateLib/DisplayLib:463-513
Modified: trunk/AgateLib/DisplayLib/Display.cs
===================================================================
--- trunk/AgateLib/DisplayLib/Display.cs 2009-11-24 18:21:02 UTC (rev 1124)
+++ trunk/AgateLib/DisplayLib/Display.cs 2009-11-24 20:45:10 UTC (rev 1125)
@@ -412,8 +412,6 @@
return impl.EnumScreenModes();
}
-
-
/// <summary>
/// Event fired when PackAllSurfacesEvent
/// </summary>
Property changes on: trunk/AgateLib/DisplayLib/Display.cs
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/agate-3d/AgateLib/DisplayLib/Display.cs:629-702,840-864
/branches/agate3d-3.2/AgateLib/DisplayLib/Display.cs:923-1034
/branches/build/AgateLib/DisplayLib/Display.cs:501-517,1081-1084
/branches/font/AgateLib/DisplayLib/Display.cs:778-916
/branches/merge-tests/AgateLib/DisplayLib/Display.cs:806-810
/branches/otkupdate/AgateLib/DisplayLib/Display.cs:1068-1076
/branches/registrar/AgateLib/DisplayLib/Display.cs:595-599
/branches/shaders/AgateLib/DisplayLib/Display.cs:1087-1111
/branches/sprites/AgateLib/DisplayLib/Display.cs:463-513
+ /branches/agate-3d/AgateLib/DisplayLib/Display.cs:629-702,840-864
/branches/agate3d-3.2/AgateLib/DisplayLib/Display.cs:923-1034
/branches/build/AgateLib/DisplayLib/Display.cs:501-517,1081-1084
/branches/font/AgateLib/DisplayLib/Display.cs:778-916
/branches/gui-3.2/AgateLib/DisplayLib/Display.cs:881-1019
/branches/merge-tests/AgateLib/DisplayLib/Display.cs:806-810
/branches/otkupdate/AgateLib/DisplayLib/Display.cs:1068-1076
/branches/registrar/AgateLib/DisplayLib/Display.cs:595-599
/branches/shaders/AgateLib/DisplayLib/Display.cs:1087-1111
/branches/sprites/AgateLib/DisplayLib/Display.cs:463-513
Modified: trunk/AgateLib/DisplayLib/FontSurface.cs
===================================================================
--- trunk/AgateLib/DisplayLib/FontSurface.cs 2009-11-24 18:21:02 UTC (rev 1124)
+++ trunk/AgateLib/DisplayLib/FontSurface.cs 2009-11-24 20:45:10 UTC (rev 1125)
@@ -94,6 +94,8 @@
impl = Display.Impl.CreateFont(fontFamily, sizeInPoints, style);
Display.DisposeDisplay += new Display.DisposeDisplayHandler(Dispose);
+
+ System.Diagnostics.Debug.Assert(impl != null);
}
/// <summary>
/// Constructs a FontSurface object from a resource.
@@ -107,14 +109,16 @@
if (res is BitmapFontResource)
{
- Surface surf = new Surface(bmpFont.Image);
+ Surface surf = new Surface(resources.FileProvider, bmpFont.Image);
- impl = new BitmapFontImpl(surf, bmpFont.FontMetrics);
+ impl = 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);
}
/// <summary>
/// Creates a bitmap font using the options passed in. The Display driver
@@ -126,14 +130,23 @@
impl = Display.Impl.CreateFont(bitmapOptions);
Display.DisposeDisplay += new Display.DisposeDisplayHandler(Dispose);
+
+ System.Diagnostics.Debug.Assert(impl != null);
}
+ public string FontName
+ {
+ get { return impl.FontName; }
+ }
/// <summary>
/// Private initializer to tell it what impl to use.
/// </summary>
/// <param name="implToUse"></param>
private FontSurface(FontSurfaceImpl implToUse)
{
+ if (implToUse == null)
+ throw new ArgumentNullException("implToUse");
+
impl = implToUse;
}
@@ -272,6 +285,7 @@
/// </summary>
/// <param name="text"></param>
/// <returns></returns>
+ [Obsolete]
public int StringDisplayWidth(string text)
{
return StringDisplaySize(text).Width;
@@ -281,6 +295,7 @@
/// </summary>
/// <param name="text"></param>
/// <returns></returns>
+ [Obsolete]
public int StringDisplayHeight(string text)
{
return StringDisplaySize(text).Height;
@@ -290,21 +305,32 @@
/// </summary>
/// <param name="text"></param>
/// <returns></returns>
+ [Obsolete]
public Size StringDisplaySize(string text)
{
- return impl.StringDisplaySize(mState, text);
+ return impl.MeasureString(mState, text);
}
+
/// <summary>
- /// Measures the display size of the specified string, using the specified state information.
+ /// Measures the display size of the specified string.
/// </summary>
- /// <param name="state"></param>
/// <param name="text"></param>
+ /// <param name="length"></param>
/// <returns></returns>
- public Size StringDisplaySize(FontState state, string text)
+ public Size MeasureString(string text)
+ {
+ return impl.MeasureString(mState, text);
+ }
+ /// <summary>
+ /// Measures the display size of the specified string.
+ /// </summary>
+ /// <param name="text"></param>
+ /// <param name="length"></param>
+ /// <returns></returns>
+ public Size MeasureString(FontState state, string text)
{
- return impl.StringDisplaySize(state, text);
+ return impl.MeasureString(state, text);
}
-
/// <summary>
/// Gets the height in pixels of a single line of text.
/// </summary>
@@ -558,7 +584,7 @@
alter.ModifyState(t.State);
}
- var size = StringDisplaySize(t.State, text);
+ var size = MeasureString(t.State, text);
var update = Origin.Calc(DisplayAlignment, size);
int newSpaceAbove = size.Height - FontHeight;
@@ -575,6 +601,98 @@
return obj.ToString();
}
+
+ #region --- Built-in Fonts ---
+
+ /// <summary>
+ /// This sans serif bitmap font was generated from Andika at 9 points.
+ /// </summary>
+ /// <remarks>
+ /// Andika is Copyright (c) 2004-2008, SIL International and
+ /// distributed under the Open Font License.
+ /// http://scripts.sil.org/OFL
+ /// </remarks>
+ public static FontSurface Andika09
+ {
+ get { return InternalResources.Data.Andika09; }
+ }
+ /// <summary>
+ /// This sans serif bitmap font was generated from Andika at 10 points.
+ /// </summary>
+ /// <remarks>
+ /// Andika is Copyright (c) 2004-2008, SIL International and
+ /// distributed under the Open Font License.
+ /// http://scripts.sil.org/OFL
+ /// </remarks>
+ public static FontSurface Andika10
+ {
+ get { return InternalResources.Data.Andika10; }
+ }
+ /// <summary>
+ /// This sans serif bitmap font was generated from Andika at 12 points.
+ /// </summary>
+ /// <remarks>
+ /// Andika is Copyright (c) 2004-2008, SIL International and
+ /// distributed under the Open Font License.
+ /// http://scripts.sil.org/OFL
+ /// </remarks>
+ public static FontSurface Andika12
+ {
+ get { return InternalResources.Data.Andika12; }
+ }
+ /// <summary>
+ /// This sans serif bitmap font was generated from Andika at 14 points.
+ /// </summary>
+ /// <remarks>
+ /// Andika is Copyright (c) 2004-2008, SIL International and
+ /// distributed under the Open Font License.
+ /// http://scripts.sil.org/OFL
+ /// </remarks>
+ public static FontSurface Andika14
+ {
+ get { return InternalResources.Data.Andika14; }
+ }
+
+ /// <summary>
+ /// This serif bitmap font was generated from Gentium at 10 points.
+ /// </summary>
+ /// <remarks>
+ /// Gentium is Copyright (c) 2004-2008, SIL International and
+ /// distributed under the Open Font License.
+ /// http://scripts.sil.org/OFL
+ /// </remarks>
+ public static FontSurface Gentium10
+ {
+ get { return InternalResources.Data.Gentium10; }
+ }
+ /// <summary>
+ /// This serif bitmap font was generated from Gentium at 12 points.
+ /// </summary>
+ /// <remarks>
+ /// Gentium is Copyright (c) 2004-2008, SIL International and
+ /// distributed under the Open Font License.
+ /// http://scripts.sil.org/OFL
+ /// </remarks>
+ public static FontSurface Gentium12
+ {
+ get { return InternalResources.Data.Gentium12; }
+ }
+ /// <summary>
+ /// This serif bitmap font was generated from Gentium at 14 points.
+ /// </summary>
+ /// <remarks>
+ /// Gentium is Copyright (c) 2004-2008, SIL International and
+ /// distributed under the Open Font License.
+ /// http://scripts.sil.org/OFL
+ /// </remarks>
+ public static FontSurface Gentium14
+ {
+ get { return InternalResources.Data.Gentium14; }
+ }
+
+ #endregion
+
+
}
public enum TextImageLayout
Modified: trunk/AgateLib/DisplayLib/FrameBuffer.cs
===================================================================
--- trunk/AgateLib/DisplayLib/FrameBuffer.cs 2009-11-24 18:21:02 UTC (rev 1124)
+++ trunk/AgateLib/DisplayLib/FrameBuffer.cs 2009-11-24 20:45:10 UTC (rev 1125)
@@ -7,7 +7,7 @@
namespace AgateLib.DisplayLib
{
- public class FrameBuffer
+ public class FrameBuffer : IDisposable
{
FrameBufferImpl impl;
@@ -23,6 +23,11 @@
this.impl = impl;
}
+ public void Dispose()
+ {
+ impl.Dispose();
+ }
+
public FrameBufferImpl Impl
{
get { return impl; }
Property changes on: trunk/AgateLib/DisplayLib/StringTransformer.cs
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/agate-3d/AgateLib/DisplayLib/StringTransformer.cs:629-702,840-864
/branches/agate3d-3.2/AgateLib/DisplayLib/StringTransformer.cs:923-1034
/branches/build/AgateLib/DisplayLib/StringTransformer.cs:501-517,1081-1084
/branches/font/AgateLib/DisplayLib/StringTransformer.cs:778-916
/branches/merge-tests/AgateLib/DisplayLib/StringTransformer.cs:806-810
/branches/otkupdate/AgateLib/DisplayLib/StringTransformer.cs:1068-1076
/branches/registrar/AgateLib/DisplayLib/StringTransformer.cs:595-599
/branches/shaders/AgateLib/DisplayLib/StringTransformer.cs:1087-1111
/branches/sprites/AgateLib/DisplayLib/StringTransformer.cs:463-513
+ /branches/agate-3d/AgateLib/DisplayLib/StringTransformer.cs:629-702,840-864
/branches/agate3d-3.2/AgateLib/DisplayLib/StringTransformer.cs:923-1034
/branches/build/AgateLib/DisplayLib/StringTransformer.cs:501-517,1081-1084
/branches/font/AgateLib/DisplayLib/StringTransformer.cs:778-916
/branches/gui-3.2/AgateLib/DisplayLib/StringTransformer.cs:881-1019
/branches/merge-tests/AgateLib/DisplayLib/StringTransformer.cs:806-810
/branches/otkupdate/AgateLib/DisplayLib/StringTransformer.cs:1068-1076
/branches/registrar/AgateLib/DisplayLib/StringTransformer.cs:595-599
/branches/shaders/AgateLib/DisplayLib/StringTransformer.cs:1087-1111
/branches/sprites/AgateLib/DisplayLib/StringTransformer.cs:463-513
Property changes on: trunk/AgateLib/Drivers/AgateDriverReporter.cs
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/agate-3d/AgateLib/Drivers/AgateDriverReporter.cs:629-702,840-864
/branches/agate3d-3.2/AgateLib/Drivers/AgateDriverReporter.cs:923-1034
/branches/build/AgateLib/Drivers/AgateDriverReporter.cs:1081-1084
/branches/font/AgateLib/Drivers/AgateDriverReporter.cs:778-916
/branches/merge-tests/AgateLib/Drivers/AgateDriverReporter.cs:806-810
/branches/otkupdate/AgateLib/Drivers/AgateDriverReporter.cs:1068-1076
/branches/shaders/AgateLib/Drivers/AgateDriverReporter.cs:1087-1111
+ /branches/agate-3d/AgateLib/Drivers/AgateDriverReporter.cs:629-702,840-864
/branches/agate3d-3.2/AgateLib/Drivers/AgateDriverReporter.cs:923-1034
/branches/build/AgateLib/Drivers/AgateDriverReporter.cs:1081-1084
/branches/font/AgateLib/Drivers/AgateDriverReporter.cs:778-916
/branches/gui-3.2/AgateLib/Drivers/AgateDriverReporter.cs:881-1019
/branches/merge-tests/AgateLib/Drivers/AgateDriverReporter.cs:806-810
/branches/otkupdate/AgateLib/Drivers/AgateDriverReporter.cs:1068-1076
/branches/shaders/AgateLib/Drivers/AgateDriverReporter.cs:1087-1111
Property changes on: trunk/AgateLib/Drivers/IDesktopDriver.cs
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/agate-3d/AgateLib/Drivers/IDesktopDriver.cs:629-702,840-864
/branches/agate3d-3.2/AgateLib/Drivers/IDesktopDriver.cs:923-1034
/branches/build/AgateLib/Drivers/IDesktopDriver.cs:1081-1084
/branches/font/AgateLib/Drivers/IDesktopDriver.cs:778-916
/branches/merge-tests/AgateLib/Drivers/IDesktopDriver.cs:806-810
/branches/otkupdate/AgateLib/Drivers/IDesktopDriver.cs:1068-1076
/branches/shaders/AgateLib/Drivers/IDesktopDriver.cs:1087-1111
+ /branches/agate-3d/AgateLib/Drivers/IDesktopDriver.cs:629-702,840-864
/branches/agate3d-3.2/AgateLib/Drivers/IDesktopDriver.cs:923-1034
/branches/build/AgateLib/Drivers/IDesktopDriver.cs:1081-1084
/branches/font/AgateLib/Drivers/IDesktopDriver.cs:778-916
/branches/gui-3.2/AgateLib/Drivers/IDesktopDriver.cs:881-1019
/branches/merge-tests/AgateLib/Drivers/IDesktopDriver.cs:806-810
/branches/otkupdate/AgateLib/Drivers/IDesktopDriver.cs:1068-1076
/branches/shaders/AgateLib/Drivers/IDesktopDriver.cs:1087-1111
Deleted: trunk/AgateLib/Gui/AgateGuiException.cs
===================================================================
--- branches/gui-3.2/AgateLib/Gui/AgateGuiException.cs 2009-08-24 04:55:30 UTC (rev 1019)
+++ trunk/AgateLib/Gui/AgateGuiException.cs 2009-11-24 20:45:10 UTC (rev 1125)
@@ -1,28 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using AgateLib;
-
-namespace AgateLib.Gui
-{
- [global::System.Serializable]
- public class AgateGuiException : AgateException
- {
- //
- // For guidelines regarding the creation of new exception types, see
- // http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconerrorraisinghandlingguidelines.asp
- // and
- // http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dncscol/html/csharp07192001.asp
- //
-
- public AgateGuiException() { }
- public AgateGuiException(string message) : base(message) { }
- public AgateGuiException(string message, Exception inner) : base(message, inner) { }
- protected AgateGuiException(
- System.Runtime.Serialization.SerializationInfo info,
- System.Runtime.Serialization.StreamingContext context)
- : base(info, context) { }
- }
-
-}
Copied: trunk/AgateLib/Gui/AgateGuiException.cs (from rev 1019, branches/gui-3.2/AgateLib/Gui/AgateGuiException.cs)
===================================================================
--- trunk/AgateLib/Gui/AgateGuiException.cs (rev 0)
+++ trunk/AgateLib/Gui/AgateGuiException.cs 2009-11-24 20:45:10 UTC (rev 1125)
@@ -0,0 +1,28 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using AgateLib;
+
+namespace AgateLib.Gui
+{
+ [global::System.Serializable]
+ public class AgateGuiException : AgateException
+ {
+ //
+ // For guidelines regarding the creation of new exception types, see
+ // http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconerrorraisinghandlingguidelines.asp
+ // and
+ // http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dncscol/html/csharp07192001.asp
+ //
+
+ public AgateGuiException() { }
+ public AgateGuiException(string message) : base(message) { }
+ public AgateGuiException(string message, Exception inner) : base(message, inner) { }
+ protected AgateGuiException(
+ System.Runtime.Serialization.SerializationInfo info,
+ System.Runtime.Serialization.StreamingContext context)
+ : base(info, context) { }
+ }
+
+}
Deleted: trunk/AgateLib/Gui/Button.cs
===================================================================
--- branches/gui-3.2/AgateLib/Gui/Button.cs 2009-08-24 04:55:30 UTC (rev 1019)
+++ trunk/AgateLib/Gui/Button.cs 2009-11-24 20:45:10 UTC (rev 1125)
@@ -1,74 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using AgateLib.InputLib;
-
-namespace AgateLib.Gui
-{
- public class Button : Widget
- {
- public Button() { Name = "Button"; }
- public Button(string text) { Name = text; Text = text; }
-
- bool spaceDownFocus = false;
-
- public override bool CanHaveFocus
- {
- get
- {
- return true;
- }
- }
- internal bool DrawActivated
- {
- get { return MouseDownIn && MouseIn || spaceDownFocus; }
- }
- internal bool IsDefaultButton
- {
- get
- {
- Container p = this.Parent;
-
- while (p is Window == false)
- p = p.Parent;
-
- return ((Window)p).AcceptButton == this;
- }
- }
-
- protected internal override void OnKeyDown(InputEventArgs e)
- {
- if (e.KeyCode == KeyCode.Space)
- {
- spaceDownFocus = true;
- }
-
- base.OnKeyDown(e);
- }
- protected internal override void OnKeyUp(InputEventArgs e)
- {
- if (e.KeyCode == KeyCode.Space)
- {
- spaceDownFocus = false;
- OnClick();
- }
-
- base.OnKeyUp(e);
- }
- protected internal override void SendMouseUp(InputEventArgs e)
- {
- if (MouseIn && MouseDownIn)
- OnClick();
-
- base.SendMouseUp(e);
- }
-
- private void OnClick()
- {
- if (Click != null)
- Click(this, EventArgs.Empty);
- }
- public event EventHandler Click;
- }
-}
Copied: trunk/AgateLib/Gui/Button.cs (from rev 1019, branches/gui-3.2/AgateLib/Gui/Button.cs)
===================================================================
--- trunk/AgateLib/Gui/Button.cs (rev 0)
+++ trunk/AgateLib/Gui/Button.cs 2009-11-24 20:45:10 UTC (rev 1125)
@@ -0,0 +1,74 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using AgateLib.InputLib;
+
+namespace AgateLib.Gui
+{
+ public class Button : Widget
+ {
+ public Button() { Name = "Button"; }
+ public Button(string text) { Name = text; Text = text; }
+
+ bool spaceDownFocus = false;
+
+ public override bool CanHaveFocus
+ {
+ get
+ {
+ return true;
+ }
+ }
+ internal bool DrawActivated
+ {
+ get { return MouseDownIn && MouseIn || spaceDownFocus; }
+ }
+ internal bool IsDefaultButton
+ {
+ get
+ {
+ Container p = this.Parent;
+
+ while (p is Window == false)
+ p = p.Parent;
+
+ return ((Window)p).AcceptButton == this;
+ }
+ }
+
+ protected internal override void OnKeyDown(InputEventArgs e)
+ {
+ if (e.KeyCode == KeyCode.Space)
+ {
+ spaceDownFocus = true;
+ }
+
+ base.OnKeyDown(e);
+ }
+ protected internal override void OnKeyUp(InputEventArgs e)
+ {
+ if (e.KeyCode == KeyCode.Space)
+ {
+ spaceDownFocus = false;
+ OnClick();
+ }
+
+ base.OnKeyUp(e);
+ }
+ protected internal override void SendMouseUp(InputEventArgs e)
+ {
+ if (MouseIn && MouseDownIn)
+ OnClick();
+
+ base.SendMouseUp(e);
+ }
+
+ private void OnClick()
+ {
+ if (Click != null)
+ Click(this, EventArgs.Empty);
+ }
+ public event EventHandler Click;
+ }
+}
Deleted: trunk/AgateLib/Gui/Cache/WidgetCache.cs
===================================================================
--- branches/gui-3.2/AgateLib/Gui/Cache/WidgetCache.cs 2009-08-24 04:55:30 UTC (rev 1019)
+++ trunk/AgateLib/Gui/Cache/WidgetCache.cs 2009-11-24 20:45:10 UTC (rev 1125)
@@ -1,17 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-
-namespace AgateLib.Gui.Cache
-{
- public class WidgetCache
- {
- public WidgetCache()
- {
- Dirty = true;
- }
-
- public bool Dirty { get; set; }
- }
-}
Copied: trunk/AgateLib/Gui/Cache/WidgetCache.cs (from rev 1019, branches/gui-3.2/AgateLib/Gui/Cache/WidgetCache.cs)
===================================================================
--- trunk/AgateLib/Gui/Cache/WidgetCache.cs (rev 0)
+++ trunk/AgateLib/Gui/Cache/WidgetCache.cs 2009-11-24 20:45:10 UTC (rev 1125)
@@ -0,0 +1,17 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace AgateLib.Gui.Cache
+{
+ public class WidgetCache
+ {
+ public WidgetCache()
+ {
+ Dirty = true;
+ }
+
+ public bool Dirty { get; set; }
+ }
+}
Deleted: trunk/AgateLib/Gui/CheckBox.cs
===================================================================
--- branches/gui-3.2/AgateLib/Gui/CheckBox.cs 2009-08-24 04:55:30 UTC (rev 1019)
+++ trunk/AgateLib/Gui/CheckBox.cs 2009-11-24 20:45:10 UTC (rev 1125)
@@ -1,73 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-
-namespace AgateLib.Gui
-{
- public class CheckBox : Widget
- {
- public CheckBox()
- {
- Name = "Checkbox";
- }
- public CheckBox(string text)
- {
- Name = text;
- Text = text;
- }
- private bool mChecked;
-
- public bool Checked
- {
- get { return mChecked; }
- set
- {
- mChecked = value;
-
- OnCheckChanged();
- }
- }
-
- public override bool CanHaveFocus
- {
- get
- {
- return true;
- }
- }
-
- bool mouseDownIn;
- protected internal override void OnMouseDown(AgateLib.InputLib.InputEventArgs e)
- {
- if (Enabled == false)
- return;
-
- mouseDownIn = true;
- }
- protected internal override void OnMouseUp(AgateLib.InputLib.InputEventArgs e)
- {
- if (MouseIn && mouseDownIn)
- Checked = !Checked;
-
- mouseDownIn = false;
-
- }
-
- protected internal override void SendKeyDown(AgateLib.InputLib.InputEventArgs e)
- {
- if (e.KeyCode == AgateLib.InputLib.KeyCode.Space)
- {
- Checked = !Checked;
- }
- }
-
- private void OnCheckChanged()
- {
- if (CheckChanged != null)
- CheckChanged(this, EventArgs.Empty);
- }
-
- public event EventHandler CheckChanged;
- }
-}
Copied: trunk/AgateLib/Gui/CheckBox.cs (from rev 1019, branches/gui-3.2/AgateLib/Gui/CheckBox.cs)
===================================================================
--- trunk/AgateLib/Gui/CheckBox.cs (rev 0)
+++ trunk/AgateLib/Gui/CheckBox.cs 2009-11-24 20:45:10 UTC (rev 1125)
@@ -0,0 +1,73 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace AgateLib.Gui
+{
+ public class CheckBox : Widget
+ {
+ public CheckBox()
+ {
+ Name = "Checkbox";
+ }
+ public CheckBox(string text)
+ {
+ Name = text;
+ Text = text;
+ }
+ private bool mChecked;
+
+ public bool Checked
+ {
+ get { return mChecked; }
+ set
+ {
+ mChecked = value;
+
+ OnCheckChanged();
+ }
+ }
+
+ public override bool CanHaveFocus
+ {
+ get
+ {
+ return true;
+ }
+ }
+
+ bool mouseDownIn;
+ protected internal override void OnMouseDown(AgateLib.InputLib.InputEventArgs e)
+ {
+ if (Enabled == false)
+ return;
+
+ mouseDownIn = true;
+ }
+ protected internal override void OnMouseUp(AgateLib.InputLib.InputEventArgs e)
+ {
+ if (MouseIn && mouseDownIn)
+ Checked = !Checked;
+
+ mouseDownIn = false;
+
+ }
+
+ protected internal override void SendKeyDown(AgateLib.InputLib.InputEventArgs e)
+ {
+ if (e.KeyCode == AgateLib.InputLib.KeyCode.Space)
+ {
+ Checked = !Checked;
+ }
+ }
+
+ private void OnCheckChanged()
+ {
+ if (CheckChanged != null)
+ CheckChanged(this, EventArgs.Empty);
+ }
+
+ public event EventHandler CheckChanged;
+ }
+}
Deleted: trunk/AgateLib/Gui/ComboBox.cs
===================================================================
--- branches/gui-3.2/AgateLib/Gui/ComboBox.cs 2009-08-24 04:55:30 UTC (rev 1019)
+++ trunk/AgateLib/Gui/ComboBox.cs 2009-11-24 20:45:10 UTC (rev 1125)
@@ -1,11 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-
-namespace AgateLib.Gui
-{
- class ComboBox : Widget
- {
- }
-}
Copied: trunk/AgateLib/Gui/ComboBox.cs (from rev 1019, branches/gui-3.2/AgateLib/Gui/ComboBox.cs)
===================================================================
--- trunk/AgateLib/Gui/ComboBox.cs (rev 0)
+++ trunk/AgateLib/Gui/ComboBox.cs 2009-11-24 20:45:10 UTC (rev 1125)
@@ -0,0 +1,11 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace AgateLib.Gui
+{
+ class ComboBox : Widget
+ {
+ }
+}
Deleted: trunk/AgateLib/Gui/Container.cs
===================================================================
--- branches/gui-3.2/AgateLib/Gui/Container.cs 2009-08-24 04:55:30 UTC (rev 1019)
+++ trunk/AgateLib/Gui/Container.cs 2009-11-24 20:45:10 UTC (rev 1125)
@@ -1,258 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using AgateLib.Geometry;
-using AgateLib.InputLib;
-using System.Diagnostics;
-
-namespace AgateLib.Gui
-{
- public abstract class Container : Widget
- {
- WidgetList mChildren;
- Rectangle mClientArea;
- ILayoutPerformer mLayout = new Layout.VerticalBox();
- bool mLayoutSuspended;
-
- public Container()
- {
- mChildren = new WidgetList(this);
- mChildren.ListUpdated += new EventHandler(mChildren_ListUpdated);
- }
-
- internal bool AnyChildCanHaveFocus
- {
- get
- {
- for (int i = 0; i < mChildren.Count; i++)
- {
- if (mChildren[i].CanHaveFocus)
- return true;
-
- if (mChildren[i] is Container)
- {
- if (((Container)mChildren[i]).AnyChildCanHaveFocus)
- return true;
- }
- }
-
- return false;
- }
- }
- public Rectangle ClientArea { get { return mClientArea; } }
- public Size ClientSize
- {
- get { return mClientArea.Size; }
- set
- {
- Size = Root.ThemeEngine.RequestClientAreaSize(this, value);
- }
- }
- public virtual ILayoutPerformer Layout
- {
- get { return mLayout; }
- set
- {
- mLayout = value;
- RedoLayout();
- }
- }
-
- public override Point PointToScreen(Point p)
- {
- return base.PointToScreen(
- new Point(p.X + ClientArea.X, p.Y + ClientArea.Y));
- }
- public override Point PointToClient(Point p)
- {
- Point retval = base.PointToClient(p);
-
- retval.X -= ClientArea.X;
- retval.Y -= ClientArea.Y;
-
- return retval;
- }
- protected override void OnResize()
- {
- if (Root == null)
- return;
-
- mClientArea = Root.ThemeEngine.GetClientArea(this);
- DoLayoutPrivate();
-
- base.OnResize();
- }
- protected override void OnParentChanged()
- {
- if (Parent == null)
- return;
-
- OnResize();
- base.OnParentChanged();
- }
-
- public void SuspendLayout()
- {
- mLayoutSuspended = true;
-
- foreach (Container child in mChildren)
- {
- child.SuspendLayout();
- }
- }
- public void ResumeLayout()
- {
- mLayoutSuspended = false;
-
- RedoLayout();
-
- foreach (Widget child in mChildren)
- {
- if (child is Container == false)
- continue;
-
- ((Container)child).ResumeLayout();
- }
-
- }
- protected internal override void RecalcSizeRange()
- {
- if (mLayoutSuspended)
- return;
- if (Root == null)
- return;
-
- try
- {
- InLayout = true;
-
- MinSize = Layout.RecalcMinSize(this);
- }
- finally
- {
- InLayout = false;
- }
- }
-
- void mChildren_ListUpdated(object sender, EventArgs e)
- {
- DoLayoutPrivate();
- }
-
- public WidgetList Children
- {
- get { return mChildren; }
- }
-
- protected internal override void UpdateGui()
- {
- for (int i = 0; i < Children.Count; i++)
- Children[i].UpdateGui();
-
- base.UpdateGui();
- }
-
- void DoLayoutPrivate()
- {
- RedoLayout();
- Invalidate();
- }
-
- internal bool InLayout { get; private set; }
-
- public virtual void RedoLayout()
- {
- if (mLayoutSuspended)
- return;
- if (Root == null)
- return;
- if (InLayout)
- return;
-
- try
- {
- InLayout = true;
-
- RecalcSizeRange();
- Layout.DoLayout(this);
- }
- finally
- {
- InLayout = false;
- }
- }
- protected override void DoDraw()
- {
- base.DoDraw();
-
- foreach (var child in Children.VisibleItems)
- child.Draw();
- }
-
- protected internal override bool AcceptFocusOnMouseDown
- {
- get { return false; }
- }
-
- protected internal override bool AcceptInputKey(KeyCode keyCode)
- {
- return Layout.AcceptInputKey(keyCode);
- }
-
- //Widget FindMouseInControl(Point screenMousePoint)
- //{
- // foreach (Widget child in mChildren)
- // {
- // if (child.ContainsScreenPoint(screenMousePoint) == true)
- // return child;
- // }
-
- // return null;
- //}
-
-
- internal Widget NearestChildTo(Point pt, bool skipDisabled)
- {
- int distance = int.MaxValue;
- Widget retval = null;
-
- foreach (Widget child in Children)
- {
- if (child.Enabled == false && skipDisabled)
- continue;
-
- Point center = new Point(
- child.Location.X + child.Width / 2,
- child.Location.Y + child.Height / 2);
-
- int dist = Math.Abs(center.X - pt.X) + Math.Abs(center.Y - pt.Y);
-
- if (dist < distance)
- {
- retval = child;
- distance = dist;
- }
- }
-
- return retval;
- }
-
- internal Widget CanMoveFocus(Widget currentFocus, Direction direction)
- {
- if (this.Children.Contains(currentFocus) == false)
- throw new ArgumentException("currentFocus does not belong to this container.");
-
- return Layout.CanMoveFocus(this, currentFocus, direction);
- }
- }
-
- public enum Direction
- {
- Up,
- Down,
- Left,
- Right,
- }
-
-}
\ No newline at end of file
Copied: trunk/AgateLib/Gui/Container.cs (from rev 1019, branches/gui-3.2/AgateLib/Gui/Container.cs)
===================================================================
--- trunk/AgateLib/Gui/Container.cs (rev 0)
+++ trunk/AgateLib/Gui/Container.cs 2009-11-24 20:45:10 UTC (rev 1125)
@@ -0,0 +1,258 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using AgateLib.Geometry;
+using AgateLib.InputLib;
+using System.Diagnostics;
+
+namespace AgateLib.Gui
+{
+ public abstract class Container : Widget
+ {
+ WidgetList mChildren;
+ Rectangle mClientArea;
+ ILayoutPerformer mLayout = new Layout.VerticalBox();
+ bool mLayoutSuspended;
+
+ public Container()
+ {
+ mChildren = new WidgetList(this);
+ mChildren.ListUpdated += new EventHandler(mChildren_ListUpdated);
+ }
+
+ internal bool AnyChildCanHaveFocus
+ {
+ get
+ {
+ for (int i = 0; i < mChildren.Count; i++)
+ {
+ if (mChildren[i].CanHaveFocus)
+ return true;
+
+ if (mChildren[i] is Container)
+ {
+ if (((Container)mChildren[i]).AnyChildCanHaveFocus)
+ return true;
+ }
+ }
+
+ return false;
+ }
+ }
+ public Rectangle ClientArea { get { return mClientArea; } }
+ public Size ClientSize
+ {
+ get { return mClientArea.Size; }
+ set
+ {
+ Size = Root.ThemeEngine.RequestClientAreaSize(this, value);
+ }
+ }
+ public virtual ILayoutPerformer Layout
+ {
+ get { return mLayout; }
+ set
+ {
+ mLayout = value;
+ RedoLayout();
+ }
+ }
+
+ public override Point PointToScreen(Point p)
+ {
+ return base.PointToScreen(
+ new Point(p.X + ClientArea.X, p.Y + ClientArea.Y));
+ }
+ public override Point PointToClient(Point p)
+ {
+ Point retval = base.PointToClient(p);
+
+ retval.X -= ClientArea.X;
+ retval.Y -= ClientArea.Y;
+
+ return retval;
+ }
+ protected override void OnResize()
+ {
+ if (Root == null)
+ return;
+
+ mClientArea = Root.ThemeEngine.GetClientArea(this);
+ DoLayoutPrivate();
+
+ base.OnResize();
+ }
+ protected override void OnParentChanged()
+ {
+ if (Parent == null)
+ return;
+
+ OnResize();
+ base.OnParentChanged();
+ }
+
+ public void SuspendLayout()
+ {
+ mLayoutSuspended = true;
+
+ foreach (Container child in mChildren)
+ {
+ child.SuspendLayout();
+ }
+ }
+ public void ResumeLayout()
+ {
+ mLayoutSuspended = false;
+
+ RedoLayout();
+
+ foreach (Widget child in mChildren)
+ {
+ if (child is Container == false)
+ continue;
+
+ ((Container)child).ResumeLayout();
+ }
+
+ }
+ protected internal override void RecalcSizeRange()
+ {
+ if (mLayoutSuspended)
+ return;
+ if (Root == null)
+ return;
+
+ try
+ {
+ InLayout = true;
+
+ MinSize = Layout.RecalcMinSize(this);
+ }
+ finally
+ {
+ InLayout = false;
+ }
+ }
+
+ void mChildren_ListUpdated(object sender, EventArgs e)
+ {
+ DoLayoutPrivate();
+ }
+
+ public WidgetList Children
+ {
+ get { return mChildren; }
+ }
+
+ protected internal override void UpdateGui()
+ {
+ for (int i = 0; i < Children.Count; i++)
+ Children[i].UpdateGui();
+
+ base.UpdateGui();
+ }
+
+ void DoLayoutPrivate()
+ {
+ RedoLayout();
+ Invalidate();
+ }
+
+ internal bool InLayout { get; private set; }
+
+ public virtual void RedoLayout()
+ {
+ if (mLayoutSuspended)
+ return;
+ if (Root == null)
+ return;
+ if (InLayout)
+ return;
+
+ try
+ {
+ InLayout = true;
+
+ RecalcSizeRange();
+ Layout.DoLayout(this);
+ }
+ finally
+ {
+ InLayout = false;
+ }
+ }
+ protected override void DoDraw()
+ {
+ base.DoDraw();
+
+ foreach (var child in Children.VisibleItems)
+ child.Draw();
+ }
+
+ protected internal override bool AcceptFocusOnMouseDown
+ {
+ get { return false; }
+ }
+
+ protected internal override bool AcceptInputKey(KeyCode keyCode)
+ {
+ return Layout.AcceptInputKey(keyCode);
+ }
+
+ //Widget FindMouseInControl(Point screenMousePoint)
+ //{
+ // foreach (Widget child in mChildren)
+ // {
+ // if (child.ContainsScreenPoint(screenMousePoint) == true)
+ // return child;
+ // }
+
+ // return null;
+ //}
+
+
+ internal Widget NearestChildTo(Point pt, bool skipDisabled)
+ {
+ int distance = int.MaxValue;
+ Widget retval = null;
+
+ foreach (Widget child in Children)
+ {
+ if (child.Enabled == false && skipDisabled)
+ continue;
+
+ Point center = new Point(
+ child.Location.X + child.Width / 2,
+ child.Location.Y + child.Height / 2);
+
+ int dist = Math.Abs(center.X - pt.X) + Math.Abs(center.Y - pt.Y);
+
+ if (dist < distance)
+ {
+ retval = child;
+ distance = dist;
+ }
+ }
+
+ return retval;
+ }
+
+ internal Widget CanMoveFocus(Widget currentFocus, Direction direction)
+ {
+ if (this.Children.Contains(currentFocus) == false)
+ throw new ArgumentException("currentFocus does not belong to this container.");
+
+ return Layout.CanMoveFocus(this, currentFocus, direction);
+ }
+ }
+
+ public enum Direction
+ {
+ Up,
+ Down,
+ Left,
+ Right,
+ }
+
+}
\ No newline at end of file
Deleted: trunk/AgateLib/Gui/GuiRoot.cs
===================================================================
--- branches/gui-3.2/AgateLib/Gui/GuiRoot.cs 2009-08-24 04:55:30 UTC (rev 1019)
+++ trunk/AgateLib/Gui/GuiRoot.cs 2009-11-24 20:45:10 UTC (rev 1125)
@@ -1,514 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.Linq;
-using System.Text;
-using AgateLib;
-using AgateLib.Geometry;
-using AgateLib.DisplayLib;
-using AgateLib.InputLib;
-
-namespace AgateLib.Gui
-{
- public sealed class GuiRoot : Container
- {
- IGuiThemeEngine themeEngine = new ThemeEngines.Mercury.Mercury();
-
- public GuiRoot()
- {
- Name = "root";
- Layout = new Layout.Grid();
- }
- public GuiRoot(IGuiThemeEngine themeEngine)
- {
- this.themeEngine = themeEngine;
- }
- protected internal override void UpdateGui()
- {
-...
[truncated message content] |
|
From: <ka...@us...> - 2009-11-24 18:21:14
|
Revision: 1124
http://agate.svn.sourceforge.net/agate/?rev=1124&view=rev
Author: kanato
Date: 2009-11-24 18:21:02 +0000 (Tue, 24 Nov 2009)
Log Message:
-----------
Change Lighting2D to use a list instead of an array.
Modified Paths:
--------------
trunk/AgateLib/DisplayLib/Shaders/Implementation/Lighting2DImpl.cs
trunk/AgateLib/DisplayLib/Shaders/Lighting2D.cs
trunk/Drivers/AgateOTK/Shaders/FixedFunction/OTK_FF_Lighting2D.cs
trunk/Examples/BallBuster.Net/BallBuster.Net.csproj
trunk/Examples/BallBuster.Net/main.cs
Modified: trunk/AgateLib/DisplayLib/Shaders/Implementation/Lighting2DImpl.cs
===================================================================
--- trunk/AgateLib/DisplayLib/Shaders/Implementation/Lighting2DImpl.cs 2009-11-24 17:35:24 UTC (rev 1123)
+++ trunk/AgateLib/DisplayLib/Shaders/Implementation/Lighting2DImpl.cs 2009-11-24 18:21:02 UTC (rev 1124)
@@ -8,7 +8,13 @@
{
public abstract class Lighting2DImpl : AgateShaderImpl
{
- public abstract Light[] Lights { get; }
+ public Lighting2DImpl()
+ {
+ Lights = new List<Light>();
+ }
+
+ public abstract int MaxActiveLights { get; }
+ public List<Light> Lights { get; private set; }
public abstract Color AmbientLight { get; set; }
}
Modified: trunk/AgateLib/DisplayLib/Shaders/Lighting2D.cs
===================================================================
--- trunk/AgateLib/DisplayLib/Shaders/Lighting2D.cs 2009-11-24 17:35:24 UTC (rev 1123)
+++ trunk/AgateLib/DisplayLib/Shaders/Lighting2D.cs 2009-11-24 18:21:02 UTC (rev 1124)
@@ -19,19 +19,23 @@
get { return (Lighting2DImpl)base.Impl; }
}
- public Light[] Lights
+ public List<Light> Lights
{
get { return Impl.Lights; }
}
public Color AmbientLight
{
get { return Impl.AmbientLight; }
+ set { Impl.AmbientLight = value; }
}
+ public int MaxActiveLights
+ {
+ get { return Impl.MaxActiveLights; }
+ }
-
public void AddLight(Light ptLight)
{
- for (int i = 0; i < Lights.Length; i++)
+ for (int i = 0; i < Lights.Count; i++)
{
if (Lights[i] == null)
{
@@ -40,7 +44,7 @@
}
}
- for (int i = 0; i < Lights.Length; i++)
+ for (int i = 0; i < Lights.Count; i++)
{
if (Lights[i].Enabled == false)
{
Modified: trunk/Drivers/AgateOTK/Shaders/FixedFunction/OTK_FF_Lighting2D.cs
===================================================================
--- trunk/Drivers/AgateOTK/Shaders/FixedFunction/OTK_FF_Lighting2D.cs 2009-11-24 17:35:24 UTC (rev 1123)
+++ trunk/Drivers/AgateOTK/Shaders/FixedFunction/OTK_FF_Lighting2D.cs 2009-11-24 18:21:02 UTC (rev 1124)
@@ -11,31 +11,21 @@
{
class OTK_FF_Lighting2D : Lighting2DImpl
{
- Light[] mLights;
Color mAmbientLight;
public OTK_FF_Lighting2D()
{
}
- public override Light[] Lights
+ public override int MaxActiveLights
{
get
{
- if (mLights == null)
- InitializeLightsArray();
-
- return mLights;
+ int maxLights;
+ GL.GetInteger(GetPName.MaxLights, out maxLights);
+ return maxLights;
}
}
- private void InitializeLightsArray()
- {
- int maxLights;
- GL.GetInteger(GetPName.MaxLights, out maxLights);
-
- mLights = new Light[maxLights];
- }
-
public override Color AmbientLight
{
get { return mAmbientLight; }
@@ -71,12 +61,13 @@
GL.ColorMaterial(MaterialFace.FrontAndBack,
ColorMaterialParameter.AmbientAndDiffuse);
- for (int i = 0; i < mLights.Length; i++)
+ int i;
+ for (i = 0; i < Lights.Count && i < MaxActiveLights; i++)
{
EnableCap lightID = (EnableCap)((int)EnableCap.Light0 + i);
LightName lightName = (LightName)((int)LightName.Light0 + i);
- if (mLights[i] == null || mLights[i].Enabled == false)
+ if (Lights[i] == null || Lights[i].Enabled == false)
{
GL.Disable(lightID);
continue;
@@ -84,19 +75,24 @@
GL.Enable(lightID);
- SetArray(array, mLights[i].DiffuseColor);
+ SetArray(array, Lights[i].DiffuseColor);
GL.Light(lightName, LightParameter.Diffuse, array);
//SetArray(array, mLights[i]);
//GL.Lightv(lightName, LightParameter.Ambient, array);
- SetArray(array, mLights[i].Position);
+ SetArray(array, Lights[i].Position);
GL.Light(lightName, LightParameter.Position, array);
- GL.Light(lightName, LightParameter.ConstantAttenuation, mLights[i].AttenuationConstant);
- GL.Light(lightName, LightParameter.LinearAttenuation, mLights[i].AttenuationLinear);
- GL.Light(lightName, LightParameter.QuadraticAttenuation, mLights[i].AttenuationQuadratic);
+ GL.Light(lightName, LightParameter.ConstantAttenuation, Lights[i].AttenuationConstant);
+ GL.Light(lightName, LightParameter.LinearAttenuation, Lights[i].AttenuationLinear);
+ GL.Light(lightName, LightParameter.QuadraticAttenuation, Lights[i].AttenuationQuadratic);
}
+ for (; i < MaxActiveLights; i++)
+ {
+ EnableCap lightID = (EnableCap)((int)EnableCap.Light0 + i);
+ GL.Disable(lightID);
+ }
}
public override void BeginPass(int passIndex)
Modified: trunk/Examples/BallBuster.Net/BallBuster.Net.csproj
===================================================================
--- trunk/Examples/BallBuster.Net/BallBuster.Net.csproj 2009-11-24 17:35:24 UTC (rev 1123)
+++ trunk/Examples/BallBuster.Net/BallBuster.Net.csproj 2009-11-24 18:21:02 UTC (rev 1124)
@@ -95,24 +95,6 @@
<Compile Include="World.cs" />
</ItemGroup>
<ItemGroup>
- <ProjectReference Include="..\..\AgateLib\AgateLib.csproj">
- <Project>{D62BD453-79AC-4A8D-8E75-F85FFF533E4D}</Project>
- <Name>AgateLib</Name>
- </ProjectReference>
- <ProjectReference Include="..\..\Drivers\AgateDrawing\AgateDrawing.csproj">
- <Project>{27BF4286-BD36-4E2A-B565-EB2A2D73E63B}</Project>
- <Name>AgateDrawing</Name>
- </ProjectReference>
- <ProjectReference Include="..\..\drivers\AgateOTK\AgateOTK.csproj">
- <Project>{B8476DD4-981E-47CD-A8C2-9E28E84A156D}</Project>
- <Name>AgateOTK</Name>
- </ProjectReference>
- <ProjectReference Include="..\..\Drivers\AgateSDL\AgateSDL.csproj">
- <Project>{FDA3969A-9EAA-4C15-A8CC-3D8DDAF705AE}</Project>
- <Name>AgateSDL</Name>
- </ProjectReference>
- </ItemGroup>
- <ItemGroup>
<BootstrapperPackage Include="Microsoft.Net.Framework.2.0">
<Visible>False</Visible>
<ProductName>.NET Framework 2.0 %28x86%29</ProductName>
@@ -129,6 +111,20 @@
<Install>false</Install>
</BootstrapperPackage>
</ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\..\AgateLib\AgateLib.csproj">
+ <Project>{9490B719-829E-43A7-A5FE-8001F8A81759}</Project>
+ <Name>AgateLib</Name>
+ </ProjectReference>
+ <ProjectReference Include="..\..\Drivers\AgateOTK\AgateOTK.csproj">
+ <Project>{9E095F03-BA3F-4EAD-A905-2A2647CE4405}</Project>
+ <Name>AgateOTK</Name>
+ </ProjectReference>
+ <ProjectReference Include="..\..\Drivers\AgateSDL\AgateSDL.csproj">
+ <Project>{00C7FA95-98F4-43D9-9B63-34122B1DB003}</Project>
+ <Name>AgateSDL</Name>
+ </ProjectReference>
+ </ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
Modified: trunk/Examples/BallBuster.Net/main.cs
===================================================================
--- trunk/Examples/BallBuster.Net/main.cs 2009-11-24 17:35:24 UTC (rev 1123)
+++ trunk/Examples/BallBuster.Net/main.cs 2009-11-24 18:21:02 UTC (rev 1124)
@@ -25,6 +25,7 @@
using AgateLib;
using AgateLib.DisplayLib;
+using AgateLib.DisplayLib.Shaders;
using AgateLib.Geometry;
using AgateLib.Sprites;
using AgateLib.InputLib;
@@ -37,7 +38,6 @@
const float maxPaddleImbueV = 1000.0f;
const float minPaddleImbueV = 200.0f;
- LightManager lights = new LightManager();
bool doLighting = true;
public BBX()
@@ -285,7 +285,7 @@
return 0;
if (Display.Caps.IsHardwareAccelerated == false ||
- Display.Caps.SupportsLighting == false)
+ AgateBuiltInShaders.Lighting2D == null)
doLighting = false;
bool fulls = true;
@@ -612,7 +612,7 @@
resetPowerups = true;
}
- lights.Ambient = w.light;
+ AgateBuiltInShaders.Lighting2D.AmbientLight = w.light;
file = "lvls/" + worlds[world].lvls[level] + ".lvl";
@@ -702,29 +702,43 @@
Display.Clear(Color.FromArgb(128, 0, 0, 128));
- //lights.Ambient = Color.FromArgb(25, 25, 25);
- lights.Clear();
+ var shader = AgateBuiltInShaders.Lighting2D;
- for (int i = 0; i < balls.Count && i < Display.Caps.MaxLights; i++)
- {
+ while (shader.Lights.Count > balls.Count)
+ shader.Lights.RemoveAt(shader.Lights.Count-1);
+
+ for (int i = 0; i < balls.Count; i++)
+ {
+ Light light;
+
+ if (i < shader.Lights.Count)
+ light = shader.Lights[i];
+ else
+ {
+ light = new Light();
+ shader.Lights.Add(light);
+ }
+
if (balls[i].fireball)
{
- lights.AddPointLight(new Vector3(
- balls[i].ballx, balls[i].bally, -1), Color.FromArgb(255, 255, 0), Color.FromArgb(64, 32, 0));
+ light.Position = new Vector3(balls[i].ballx, balls[i].bally, -1);
+ light.DiffuseColor = Color.FromArgb(255, 255, 0);
+ light.AmbientColor = Color.FromArgb(64, 32, 0);
- lights[i].AttenuationConstant = 0.01f;
- lights[i].AttenuationLinear = 0.01f;
- lights[i].AttenuationQuadratic = 0.000001f;
-
+ light.AttenuationConstant = 0.01f;
+ light.AttenuationLinear = 0.005f;
+ light.AttenuationQuadratic = 0.000001f;
+
}
else
{
- lights.AddPointLight(new Vector3(
- balls[i].ballx, balls[i].bally, -1), Color.FromArgb(200, 200, 200));
+ light.Position = new Vector3(balls[i].ballx, balls[i].bally, -1);
+ light.DiffuseColor = Color.FromArgb(200, 200, 200);
+ light.AmbientColor = Color.Black;
- lights[i].AttenuationConstant = 0.01f;
- lights[i].AttenuationLinear = 0;
- lights[i].AttenuationQuadratic = 0.00001f;
+ light.AttenuationConstant = 0.01f;
+ light.AttenuationLinear = 0;
+ light.AttenuationQuadratic = 0.00001f;
}
}
@@ -739,7 +753,7 @@
if (doLighting)
{
- lights.DoLighting();
+ shader.Activate();
}
// Draw blocks and Update their animations...
@@ -755,7 +769,7 @@
if (doLighting)
{
- Display.DisableLighting();
+ AgateBuiltInShaders.Basic2DShader.Activate();
}
// Draw paddle, other stuff, and lastly the balls.
@@ -4074,7 +4088,6 @@
img.arrow.Color = Color.White;
- lights.Ambient = Color.White;
editorState.brush = 'r';
while (Keyboard.Keys[KeyCode.Escape] == false && Display.CurrentWindow.IsClosed == false)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ka...@us...> - 2009-11-24 17:35:43
|
Revision: 1123
http://agate.svn.sourceforge.net/agate/?rev=1123&view=rev
Author: kanato
Date: 2009-11-24 17:35:24 +0000 (Tue, 24 Nov 2009)
Log Message:
-----------
Remove IRenderTarget.cs file.
Modified Paths:
--------------
trunk/AgateLib/AgateLib.csproj
Removed Paths:
-------------
trunk/AgateLib/DisplayLib/IRenderTarget.cs
Modified: trunk/AgateLib/AgateLib.csproj
===================================================================
--- trunk/AgateLib/AgateLib.csproj 2009-11-24 16:52:15 UTC (rev 1122)
+++ trunk/AgateLib/AgateLib.csproj 2009-11-24 17:35:24 UTC (rev 1123)
@@ -164,9 +164,6 @@
<Compile Include="DisplayLib\IndexBuffer.cs">
<SubType>Code</SubType>
</Compile>
- <Compile Include="DisplayLib\IRenderTarget.cs">
- <SubType>Code</SubType>
- </Compile>
<Compile Include="DisplayLib\ISurface.cs">
<SubType>Code</SubType>
</Compile>
Deleted: trunk/AgateLib/DisplayLib/IRenderTarget.cs
===================================================================
--- trunk/AgateLib/DisplayLib/IRenderTarget.cs 2009-11-24 16:52:15 UTC (rev 1122)
+++ trunk/AgateLib/DisplayLib/IRenderTarget.cs 2009-11-24 17:35:24 UTC (rev 1123)
@@ -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.Text;
-
-using AgateLib.Geometry;
-using AgateLib.ImplementationBase;
-
-namespace AgateLib.DisplayLib
-{
- /// <summary>
- /// Defines the interface used for render targets.
- /// Implemented by DisplayWindow and Surface
- /// </summary>
- public interface IRenderTarget
- {
- /// <summary>
- /// Gets the library implementation of the render target.
- /// </summary>
- IRenderTargetImpl Impl { get; }
-
- /// <summary>
- /// Gets the width of the render target in pixels.
- /// </summary>
- int Width { get; }
- /// <summary>
- /// Gets the height of the render target in pixels.
- /// </summary>
- int Height { get; }
- /// <summary>
- /// Gets the size of the render target in pixels.
- /// </summary>
- Size Size { get; }
-
- /// <summary>
- /// Event that is fired when the render target is resized.
- /// </summary>
- event EventHandler Resize;
- }
-}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ka...@us...> - 2009-11-24 16:52:23
|
Revision: 1122
http://agate.svn.sourceforge.net/agate/?rev=1122&view=rev
Author: kanato
Date: 2009-11-24 16:52:15 +0000 (Tue, 24 Nov 2009)
Log Message:
-----------
Complete framework for adding GL3 support.
Modified Paths:
--------------
trunk/Drivers/AgateOTK/AgateOTK.csproj
trunk/Drivers/AgateOTK/GL3/FrameBuffer.cs
trunk/Drivers/AgateOTK/Legacy/LegacyVertexBuffer.cs
Added Paths:
-----------
trunk/Drivers/AgateOTK/GL3/GLPrimitiveRenderer.cs
trunk/Drivers/AgateOTK/GL3/GLVertexBuffer.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/frmFullScreen.Designer.cs
trunk/Drivers/AgateOTK/frmFullScreen.cs
trunk/Drivers/AgateOTK/frmFullScreen.resx
Removed Paths:
-------------
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/frmFullScreen.Designer.cs
trunk/Drivers/AgateOTK/frmFullScreen.cs
trunk/Drivers/AgateOTK/frmFullScreen.resx
Modified: trunk/Drivers/AgateOTK/AgateOTK.csproj
===================================================================
--- trunk/Drivers/AgateOTK/AgateOTK.csproj 2009-11-24 16:44:21 UTC (rev 1121)
+++ trunk/Drivers/AgateOTK/AgateOTK.csproj 2009-11-24 16:52:15 UTC (rev 1122)
@@ -109,6 +109,8 @@
</Compile>
<Compile Include="GL3\FrameBuffer.cs" />
<Compile Include="GL3\DrawBuffer.cs" />
+ <Compile Include="GL3\GLVertexBuffer.cs" />
+ <Compile Include="GL3\GLPrimitiveRenderer.cs" />
<Compile Include="Legacy\ArbShader.cs">
<SubType>Code</SubType>
</Compile>
Modified: trunk/Drivers/AgateOTK/GL3/FrameBuffer.cs
===================================================================
--- trunk/Drivers/AgateOTK/GL3/FrameBuffer.cs 2009-11-24 16:44:21 UTC (rev 1121)
+++ trunk/Drivers/AgateOTK/GL3/FrameBuffer.cs 2009-11-24 16:52:15 UTC (rev 1122)
@@ -9,6 +9,9 @@
namespace AgateOTK.GL3
{
+ /// <summary>
+ /// OpenGL 3.1 compatible.
+ /// </summary>
class FrameBuffer : GL_FrameBuffer
{
Size mSize;
Copied: trunk/Drivers/AgateOTK/GL3/GLPrimitiveRenderer.cs (from rev 1121, trunk/Drivers/AgateOTK/Legacy/LegacyPrimitiveRenderer.cs)
===================================================================
--- trunk/Drivers/AgateOTK/GL3/GLPrimitiveRenderer.cs (rev 0)
+++ trunk/Drivers/AgateOTK/GL3/GLPrimitiveRenderer.cs 2009-11-24 16:52:15 UTC (rev 1122)
@@ -0,0 +1,109 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using AgateLib.Geometry;
+using OpenTK.Graphics.OpenGL;
+
+namespace AgateOTK.GL3
+{
+ /// <summary>
+ /// Not OpenGL 3.1 compatible.
+ /// Need replacements for everything.
+ /// </summary>
+ class GLPrimitiveRenderer :PrimitiveRenderer
+ {
+ public void SetGLColor(Color color)
+ {
+ GL.Color4(color.R / 255.0f, color.G / 255.0f, color.B / 255.0f, color.A / 255.0f);
+ }
+
+ public override void DrawLine(Point a, Point b, Color color)
+ {
+ SetGLColor(color);
+
+ GL.Disable(EnableCap.Texture2D);
+ GL.Begin(BeginMode.Lines);
+ GL.Vertex2(a.X, a.Y);
+ GL.Vertex2(b.X, b.Y);
+
+ GL.End();
+ GL.Enable(EnableCap.Texture2D);
+ }
+
+ public override void DrawRect(RectangleF rect, Color color)
+ {
+ SetGLColor(color);
+
+ GL.Disable(EnableCap.Texture2D);
+ GL.Begin(BeginMode.Lines);
+
+ GL.Vertex2(rect.Left, rect.Top);
+ GL.Vertex2(rect.Right, rect.Top);
+
+ GL.Vertex2(rect.Right, rect.Top);
+ GL.Vertex2(rect.Right, rect.Bottom);
+
+ GL.Vertex2(rect.Left, rect.Bottom);
+ GL.Vertex2(rect.Right, rect.Bottom);
+
+ GL.Vertex2(rect.Left, rect.Top);
+ GL.Vertex2(rect.Left, rect.Bottom);
+
+ GL.End();
+ GL.Enable(EnableCap.Texture2D);
+ }
+ public override void FillRect(RectangleF rect, Color color)
+ {
+ SetGLColor(color);
+
+ GL.Disable(EnableCap.Texture2D);
+
+ 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
+
+ GL.Enable(EnableCap.Texture2D);
+ }
+ public override void FillRect(RectangleF rect, Gradient color)
+ {
+ GL.Disable(EnableCap.Texture2D);
+
+ GL.Begin(BeginMode.Quads);
+ SetGLColor(color.TopLeft);
+ GL.Vertex3(rect.Left, rect.Top, 0); // Top Left
+
+ SetGLColor(color.TopRight);
+ GL.Vertex3(rect.Right, rect.Top, 0); // Top Right
+
+ SetGLColor(color.BottomRight);
+ GL.Vertex3(rect.Right, rect.Bottom, 0); // Bottom Right
+
+ SetGLColor(color.BottomLeft);
+ GL.Vertex3(rect.Left, rect.Bottom, 0); // Bottom Left
+ GL.End(); // Done Drawing The Quad
+
+ GL.Enable(EnableCap.Texture2D);
+ }
+
+ public override void FillPolygon(PointF[] pts, Color color)
+ {
+ GL.Disable(EnableCap.Texture2D);
+
+ SetGLColor(color);
+
+ GL.Begin(BeginMode.TriangleFan);
+ for (int i = 0; i < pts.Length; i++)
+ {
+ GL.Vertex3(pts[i].X, pts[i].Y, 0);
+ }
+ GL.End(); // Done Drawing The Quad
+
+ GL.Enable(EnableCap.Texture2D);
+ }
+
+ }
+}
Copied: trunk/Drivers/AgateOTK/GL3/GLVertexBuffer.cs (from rev 1121, trunk/Drivers/AgateOTK/Legacy/LegacyVertexBuffer.cs)
===================================================================
--- trunk/Drivers/AgateOTK/GL3/GLVertexBuffer.cs (rev 0)
+++ trunk/Drivers/AgateOTK/GL3/GLVertexBuffer.cs 2009-11-24 16:52:15 UTC (rev 1122)
@@ -0,0 +1,279 @@
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Runtime.InteropServices;
+using System.Text;
+using AgateLib;
+using AgateLib.DisplayLib;
+using AgateLib.Geometry;
+using AgateLib.Geometry.VertexTypes;
+using AgateLib.ImplementationBase;
+using OpenTK.Graphics.OpenGL;
+
+namespace AgateOTK.GL3
+{
+ /// <summary>
+ /// Not OpenGL 3.1 compatible.
+ /// Need replacements for SetClientStates/IndexPointer/NormalPointer/VertexPointer
+ /// </summary>
+ public class GLVertexBuffer : VertexBufferImpl
+ {
+ GL_Display mDisplay;
+ GLDrawBuffer mDrawBuffer;
+
+ struct AttributeData
+ {
+ public string Name;
+ public int BufferID;
+ public VertexAttribPointerType Type;
+ public int ComponentCount;
+ }
+
+ int mVertexCount;
+ int mVertexBufferID;
+
+ List<AttributeData> mAttributeBuffers = new List<AttributeData>();
+
+ VertexLayout mLayout;
+
+ public GLVertexBuffer(VertexLayout layout, int count)
+ {
+ mDisplay = Display.Impl as GL_Display;
+ mDrawBuffer = mDisplay.DrawBuffer;
+ mVertexCount = count;
+ mLayout = layout;
+
+ GL.GenBuffers(1, out mVertexBufferID);
+ Debug.Print("Vertex buffer ID: {0}", mVertexBufferID);
+
+ }
+
+ public override void Write<T>(T[] vertices)
+ {
+ GL.BindBuffer(BufferTarget.ArrayBuffer, mVertexBufferID);
+ int size = vertices.Length * Marshal.SizeOf(typeof(T));
+
+ GCHandle h = new GCHandle();
+
+ try
+ {
+ h = GCHandle.Alloc(vertices, GCHandleType.Pinned);
+
+ IntPtr arrayptr = Marshal.UnsafeAddrOfPinnedArrayElement(vertices, 0);
+
+ unsafe
+ {
+ byte* ptr = (byte*)arrayptr;
+
+ GL.BufferData(
+ BufferTarget.ArrayBuffer,
+ (IntPtr)size,
+ (IntPtr)ptr,
+ BufferUsageHint.StaticDraw);
+ }
+ }
+ finally
+ {
+ h.Free();
+ }
+ }
+
+ public override void Draw(int start, int count)
+ {
+ GL.BindBuffer(BufferTarget.ArrayBuffer, mVertexBufferID);
+ SetClientStates();
+ BeginMode beginMode = SelectBeginMode();
+
+ GL.DrawArrays(beginMode, start, count);
+ }
+ public override void DrawIndexed(IndexBuffer indexbuffer, int start, int count)
+ {
+ GL_IndexBuffer gl_indexbuffer = (GL_IndexBuffer) indexbuffer.Impl;
+
+ GL.BindBuffer(BufferTarget.ElementArrayBuffer, gl_indexbuffer.BufferID);
+ GL.IndexPointer(IndexPointerType.Short, 0, start);
+
+ GL.BindBuffer(BufferTarget.ArrayBuffer, mVertexBufferID);
+ SetClientStates();
+
+ BeginMode beginMode = SelectBeginMode();
+ GL.DrawElements(beginMode, count, DrawElementsType.UnsignedShort, (IntPtr)0);
+ }
+
+ private void SetAttributes()
+ {
+ /*
+ GlslShader shader = Display.Shader as GlslShader;
+ if (shader == null)
+ return;
+
+ for (int i = 0; i < mAttributeBuffers.Count; i++)
+ {
+ if (shader.Attributes.Contains(mAttributeBuffers[i].Name) == false)
+ continue;
+
+ int size = mAttributeBuffers[i].ComponentCount;
+ int shaderAttribIndex = shader.GetAttribLocation(mAttributeBuffers[i].Name);
+
+ GL.EnableVertexAttribArray(shaderAttribIndex);
+ GL.BindBuffer(BufferTarget.ArrayBuffer, mAttributeBuffers[i].BufferID);
+ GL.VertexAttribPointer(shaderAttribIndex, size,
+ mAttributeBuffers[i].Type,
+ false, 0, IntPtr.Zero);
+ }*/
+
+ }
+
+ public void SetGLColor(Color color)
+ {
+ GL.Color4(color.R / 255.0f, color.G / 255.0f, color.B / 255.0f, color.A / 255.0f);
+ }
+ private void SetClientStates()
+ {
+ SetGLColor(Color.White);
+
+ if (UseTexture)
+ SetTextures();
+ else
+ {
+ GL.Disable(EnableCap.Texture2D);
+ GL.DisableClientState(EnableCap.TextureCoordArray);
+ }
+
+ if (HasNormals)
+ {
+ GL.EnableClientState(EnableCap.NormalArray);
+ GL.NormalPointer(NormalPointerType.Float, mLayout.VertexSize,
+ (IntPtr) mLayout.ElementByteIndex(VertexElement.Normal));
+ }
+ else
+ {
+ GL.DisableClientState(EnableCap.NormalArray);
+ }
+
+ if (HasPositions)
+ {
+ GL.EnableClientState(EnableCap.VertexArray);
+ GL.VertexPointer(
+ PositionSize / sizeof(float), VertexPointerType.Float, mLayout.VertexSize,
+ mLayout.ElementByteIndex(VertexElement.Position));
+ }
+
+ GL.DisableClientState(EnableCap.ColorArray);
+
+
+ SetAttributes();
+ }
+
+ private void SetTextures()
+ {
+ GL.Enable(EnableCap.Texture2D);
+
+ if (HasTextureCoords)
+ {
+ GL.EnableClientState(EnableCap.TextureCoordArray);
+ GL.TexCoordPointer(
+ 2, TexCoordPointerType.Float, mLayout.VertexSize,
+ (IntPtr)mLayout.ElementByteIndex(VertexElement.Texture));
+ }
+
+
+ //GlslShader shader = Display.Shader as GlslShader;
+
+ if (Textures.ActiveTextures > 1)
+ {
+ //for (int i = 0; i < Textures.Count; i++)
+ //{
+ // GL.ActiveTexture((TextureUnit)(TextureUnit.Texture0 + i));
+
+ // Surface surf = Textures[i];
+
+ // if (surf != null)
+ // {
+ // GL_Surface gl_surf = (GL_Surface)Textures[i].Impl;
+
+ // GL.Enable(EnableCap.Texture2D);
+ // GL.BindTexture(TextureTarget.Texture2D, gl_surf.GLTextureID);
+
+ // if (shader != null)
+ // {
+ // if (i < shader.Sampler2DUniforms.Count)
+ // {
+ // shader.SetUniform(shader.Sampler2DUniforms[i], i);
+ // }
+ // }
+ // }
+ // else
+ // {
+ // GL.Disable(EnableCap.Texture2D);
+ // GL.BindTexture(TextureTarget.Texture2D, 0);
+ // }
+ //}
+ }
+ else
+ {
+ GL.BindTexture(TextureTarget.Texture2D, ((GL_Surface)Textures[0].Impl).GLTextureID);
+ }
+ }
+
+ private BeginMode SelectBeginMode()
+ {
+ BeginMode beginMode;
+ switch (PrimitiveType)
+ {
+ case PrimitiveType.TriangleList: beginMode = BeginMode.Triangles; break;
+ case PrimitiveType.TriangleFan: beginMode = BeginMode.TriangleFan; break;
+ case PrimitiveType.TriangleStrip: beginMode = BeginMode.TriangleStrip; break;
+
+ default:
+ throw new AgateException(string.Format(
+ "Unsupported PrimitiveType {0}", PrimitiveType));
+ }
+ return beginMode;
+ }
+
+ private static void CheckError()
+ {
+ ErrorCode err = GL.GetError();
+
+ if (err != ErrorCode.NoError)
+ System.Diagnostics.Debug.Print("Error: {0}", err);
+ }
+
+ public override int VertexCount
+ {
+ get { return mVertexCount; }
+ }
+
+ bool UseTexture
+ {
+ get { return HasTextureCoords && Textures.ActiveTextures != 0; }
+ }
+ public bool HasTextureCoords
+ {
+ get { return mLayout.ContainsElement(VertexElement.Texture); }
+ }
+ public bool HasNormals
+ {
+ get { return mLayout.ContainsElement(VertexElement.Normal); }
+ }
+ public bool HasPositions
+ {
+ get { return mLayout.ContainsElement(VertexElement.Position); }
+ }
+ public int PositionSize
+ {
+ get
+ {
+ VertexElementDesc d = mLayout.GetElement(VertexElement.Position);
+
+ return VertexLayout.SizeOf(d.DataType);
+ }
+ }
+
+ public override VertexLayout VertexLayout
+ {
+ get { return mLayout; }
+ }
+ }
+}
Deleted: trunk/Drivers/AgateOTK/GLDrawBuffer.cs
===================================================================
--- trunk/Drivers/AgateOTK/GLDrawBuffer.cs 2009-11-24 16:44:21 UTC (rev 1121)
+++ trunk/Drivers/AgateOTK/GLDrawBuffer.cs 2009-11-24 16:52:15 UTC (rev 1122)
@@ -1,49 +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.Diagnostics;
-using System.Runtime.InteropServices;
-using System.Text;
-
-using AgateLib;
-using AgateLib.DisplayLib;
-using AgateLib.Geometry;
-using AgateLib.Geometry.VertexTypes;
-
-using OpenTK.Graphics.OpenGL;
-
-namespace AgateOTK
-{
- /// <summary>
- /// Not GL3 compatible. Need replacements for
- /// EnableClientState,TexCoordPointer, etc.
- /// </summary>
- public abstract class GLDrawBuffer
- {
- public abstract void ResetTexture();
- public abstract void SetInterpolationMode(InterpolationMode mode);
-
- public abstract void AddQuad(int textureID, Color color, TextureCoordinates texCoord, RectangleF destRect);
- public abstract void AddQuad(int textureID, Color color, TextureCoordinates texCoord, PointF[] pts);
- public abstract void AddQuad(int textureID, Gradient color, TextureCoordinates texCoord, PointF[] pts);
-
- public abstract void Flush();
- }
-}
Added: trunk/Drivers/AgateOTK/GLDrawBuffer.cs
===================================================================
--- trunk/Drivers/AgateOTK/GLDrawBuffer.cs (rev 0)
+++ trunk/Drivers/AgateOTK/GLDrawBuffer.cs 2009-11-24 16:52:15 UTC (rev 1122)
@@ -0,0 +1,45 @@
+// 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;
+using System.Text;
+
+using AgateLib;
+using AgateLib.DisplayLib;
+using AgateLib.Geometry;
+using AgateLib.Geometry.VertexTypes;
+
+using OpenTK.Graphics.OpenGL;
+
+namespace AgateOTK
+{
+ public abstract class GLDrawBuffer
+ {
+ public abstract void ResetTexture();
+ public abstract void SetInterpolationMode(InterpolationMode mode);
+
+ public abstract void AddQuad(int textureID, Color color, TextureCoordinates texCoord, RectangleF destRect);
+ public abstract void AddQuad(int textureID, Color color, TextureCoordinates texCoord, PointF[] pts);
+ public abstract void AddQuad(int textureID, Gradient color, TextureCoordinates texCoord, PointF[] pts);
+
+ public abstract void Flush();
+ }
+}
Deleted: trunk/Drivers/AgateOTK/GL_Display.cs
===================================================================
--- trunk/Drivers/AgateOTK/GL_Display.cs 2009-11-24 16:44:21 UTC (rev 1121)
+++ trunk/Drivers/AgateOTK/GL_Display.cs 2009-11-24 16:52:15 UTC (rev 1122)
@@ -1,566 +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.Diagnostics;
-using System.IO;
-using System.Linq;
-using System.Text;
-using System.Runtime.InteropServices;
-using AgateLib.BitmapFont;
-using AgateLib.DisplayLib;
-using AgateLib.Drivers;
-using AgateLib.Geometry;
-using AgateLib.Geometry.VertexTypes;
-using AgateLib.ImplementationBase;
-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 mSupportsFramebufferExt;
- private bool mNonPowerOf2Textures;
- private bool mSupportsShaders;
- private decimal mGLVersion;
-
- System.Windows.Forms.Form mFakeWindow;
- DisplayWindow mFakeDisplayWindow;
-
- PrimitiveRenderer mPrimitives;
-
- bool mGL3;
-
- public bool NonPowerOf2Textures
- {
- 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; }
- }
-
- protected override AgateLib.DisplayLib.Shaders.Implementation.AgateShaderImpl CreateBuiltInShader(AgateLib.DisplayLib.Shaders.Implementation.BuiltInShader BuiltInShaderType)
- {
- return Shaders.ShaderFactory.CreateBuiltInShader(BuiltInShaderType);
- }
- public override DisplayWindowImpl CreateDisplayWindow(CreateWindowParams windowParams)
- {
- 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 Legacy.LegacyVertexBuffer(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);
- }
-
- public GLDrawBuffer CreateDrawBuffer()
- {
- if (mGL3)
- return new GL3.DrawBuffer();
- else
- return new Legacy.LegacyDrawBuffer();
- }
-
- protected override FrameBufferImpl CreateFrameBuffer(Size size)
- {
- if (mGL3)
- return new GL3.FrameBuffer(size);
- else if (mSupportsFramebufferExt)
- return new Legacy.FrameBufferExt(size);
- else
- return new Legacy.FrameBufferReadPixels(size);
- }
-
- protected override void OnBeginFrame()
- {
- mRenderTarget.BeginRender();
- }
- protected override void OnEndFrame()
- {
- DrawBuffer.Flush();
-
- mRenderTarget.EndRender();
-
- FlushDeleteQueue();
- }
-
- internal GLDrawBuffer DrawBuffer
- {
- get { return (RenderTarget.Impl as GL_FrameBuffer).DrawBuffer; }
- }
-
-
- // TODO: Test clip rect stuff.
- public override void SetClipRect(Rectangle newClipRect)
- {
- GL.Viewport(newClipRect.X, mRenderTarget.Height - newClipRect.Bottom,
- newClipRect.Width, newClipRect.Height);
-
- 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, 1.0f);
- GL.Clear(ClearBufferMask.DepthBufferBit | ClearBufferMask.ColorBufferBit | ClearBufferMask.StencilBufferBit);
- }
- public override void Clear(Color color, Rectangle dest)
- {
- DrawBuffer.Flush();
-
- DrawRect(dest, Color.FromArgb(255, color));
- }
-
-
- 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, Color color)
- {
- DrawBuffer.Flush();
- mPrimitives.FillPolygon(pts, color);
- }
-
- 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();
- LoadExtensions();
-
- if (mGL3)
- mPrimitives = new Legacy.LegacyPrimitiveRenderer();
- else
- mPrimitives = new Legacy.LegacyPrimitiveRenderer();
-
- mSupportsFramebufferExt = SupportsExtension("GL_EXT_FRAMEBUFFER_OBJECT");
- mNonPowerOf2Textures = SupportsExtension("GL_ARB_NON_POWER_OF_TWO");
-
- if (mGLVersion >= 3m)
- {
- mNonPowerOf2Textures = true;
- mSupportsShaders = true;
- mGL3 = true;
- }
- if (mGLVersion >= 2m)
- {
- mNonPowerOf2Textures = true;
- mSupportsShaders = true;
- }
-
- if (SupportsExtension("GL_ARB_FRAGMENT_PROGRAM"))
- {
- mSupportsShaders = true;
- }
-
- Trace.WriteLine(string.Format("OpenGL version {0} from vendor {1} detected.", mGLVersion, vendor));
- Trace.WriteLine("NPOT: " + mNonPowerOf2Textures.ToString());
- Trace.WriteLine("Shaders: " + mSupportsShaders.ToString());
-
- InitializeShaders();
- }
-
- 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]);
- }
- }
-
- 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;
- }
-
-
- OtkShader mCurrentShader;
-
- public OtkShader Shader
- {
- get
- {
- return mCurrentShader;
- }
- set
- {
- if (value == null)
- return;
-
- if (value is OtkShader == false)
- throw new AgateLib.AgateException(string.Format(
- "Shader type is {0} but must be IGlShader.", value.GetType()));
-
- mCurrentShader = (OtkShader)value;
-
- if (mCurrentShader == null)
- {
- GL.UseProgram(0);
- }
- else
- {
- GL.UseProgram(mCurrentShader.Handle);
- }
-
- }
- }
- 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;
- }
-
- #region --- Shaders ---
-
- protected override ShaderCompilerImpl CreateShaderCompiler()
- {
- if (this.Supports(DisplayBoolCaps.CustomShaders))
- {
- if (mGLVersion < 2.0m)
- return new ArbShaderCompiler();
- else
- return new GlslShaderCompiler();
- }
- else
- return base.CreateShaderCompiler();
- }
-
- #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 --- IDisplayCaps Members ---
-
- public override bool Supports(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: return new Size(1024, 1024);
- }
-
- return new Size(0, 0);
- }
- public override IEnumerable<AgateLib.DisplayLib.Shaders.ShaderLanguage> SupportedShaderLanguages
- {
- get { yield return AgateLib.DisplayLib.Shaders.ShaderLanguage.Glsl; }
- }
-
-
- #endregion
-
- protected override bool GetRenderState(RenderStateBool renderStateBool)
- {
- switch (renderStateBool)
- {
- case RenderStateBool.WaitForVerticalBlank: return mVSync;
- default:
- throw new NotSupportedException(string.Format(
- "The specified render state, {0}, is not supported by this driver."));
- }
- }
-
- protected override void SetRenderState(RenderStateBool renderStateBool, bool value)
- {
- switch (renderStateBool)
- {
- case RenderStateBool.WaitForVerticalBlank:
- mVSync = value;
- break;
-
- default:
- throw new NotSupportedException(string.Format(
- "The specified render state, {0}, is not supported by this driver."));
- }
- }
-
- #region --- Deletion queuing ---
-
- List<int> mTexturesToDelete = new List<int>();
-
-
- private void FlushDeleteQueue()
- {
- lock (mTexturesToDelete)
- {
- int[] tex = mTexturesToDelete.ToArray();
- mTexturesToDelete.Clear();
-
- GL.DeleteTextures(mTexturesToDelete.Count, tex);
- }
- }
-
- internal void QueueDeleteTexture(int p)
- {
- lock (mTexturesToDelete)
- {
- mTexturesToDelete.Add(p);
- }
- }
-
- #endregion
- }
-}
\ No newline at end of file
Added: trunk/Drivers/AgateOTK/GL_Display.cs
===================================================================
--- trunk/Drivers/AgateOTK/GL_Display.cs (rev 0)
+++ trunk/Drivers/AgateOTK/GL_Display.cs 2009-11-24 16:52:15 UTC (rev 1122)
@@ -0,0 +1,576 @@
+// 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.IO;
+using System.Linq;
+using System.Text;
+using System.Runtime.InteropServices;
+using AgateLib.BitmapFont;
+using AgateLib.DisplayLib;
+using AgateLib.Drivers;
+using AgateLib.Geometry;
+using AgateLib.Geometry.VertexTypes;
+using AgateLib.ImplementationBase;
+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 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 Shaders.ShaderFactory.CreateBuiltInShader(BuiltInShaderType);
+ }
+ public override DisplayWindowImpl CreateDisplayWindow(CreateWindowParams windowParams)
+ {
+ 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)
+ return new GL3.FrameBuffer(size);
+ else if (mSupportsFramebufferExt)
+ return new Legacy.FrameBufferExt(size);
+ else
+ return new Legacy.FrameBufferReadPixels(size);
+ }
+
+ public GLDrawBuffer CreateDrawBuffer()
+ {
+ if (mGL3)
+ return new GL3.DrawBuffer();
+ else
+ return new Legacy.LegacyDrawBuffer();
+ }
+
+
+ #endregion
+
+ protected override void OnBeginFrame()
+ {
+ mRenderTarget.BeginRender();
+ }
+ protected override void OnEndFrame()
+ {
+ DrawBuffer.Flush();
+
+ mRenderTarget.EndRender();
+
+ FlushDeleteQueue();
+ }
+
+ internal GLDrawBuffer DrawBuffer
+ {
+ get { return (RenderTarget.Impl as GL_FrameBuffer).DrawBuffer; }
+ }
+
+ // TODO: Test clip rect stuff.
+ public override void SetClipRect(Rectangle newClipRect)
+ {
+ GL.Viewport(newClipRect.X, mRenderTarget.Height - newClipRect.Bottom,
+ newClipRect.Width, newClipRect.Height);
+
+ 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, 1.0f);
+ GL.Clear(ClearBufferMask.DepthBufferBit | ClearBufferMask.ColorBufferBit | ClearBufferMask.StencilBufferBit);
+ }
+ public override void Clear(Color color, Rectangle dest)
+ {
+ DrawBuffer.Flush();
+
+ DrawRect(dest, 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, Color color)
+ {
+ DrawBuffer.Flush();
+ mPrimitives.FillPolygon(pts, 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();
+ LoadExtensions();
+
+ if (mGL3)
+ mPrimitives = new GL3.GLPrimitiveRenderer();
+ else
+ mPrimitives = new Legacy.LegacyPrimitiveRenderer();
+
+ mSupportsFramebufferExt = SupportsExtension("GL_EXT_FRAMEBUFFER_OBJECT");
+ mNonPowerOf2Textures = SupportsExtension("GL_ARB_NON_POWER_OF_TWO");
+
+ if (mGLVersion >= 3m)
+ {
+ mNonPowerOf2Textures = true;
+ mSupportsShaders = true;
+ mGL3 = true;
+ }
+ if (mGLVersion >= 2m)
+ {
+ mNonPowerOf2Textures = true;
+ mSupportsShaders = true;
+ }
+
+ if (SupportsExtension("GL_ARB_FRAGMENT_PROGRAM"))
+ {
+ mSupportsShaders = true;
+ }
+
+ Trace.WriteLine(string.Format("OpenGL version {0} from vendor {1} detected.", mGLVersion, vendor));
+ Trace.WriteLine("NPOT: " + mNonPowerOf2Textures.ToString());
+ Trace.WriteLine("Shaders: " + mSupportsShaders.ToString());
+
+ InitializeShaders();
+ }
+
+ 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]);
+ }
+ }
+ 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 ---
+
+ protected override ShaderCompilerImpl CreateShaderCompiler()
+ {
+ if (this.Supports(DisplayBoolCaps.CustomShaders))
+ {
+ if (mGLVersion < 2.0m)
+ return new ArbShaderCompiler();
+ else
+ return new GlslShaderCompiler();
+ }
+ else
+ return base.CreateShaderCompiler();
+ }
+
+ OtkShader mCurrentShader;
+
+ public OtkShader Shader
+ {
+ get
+ {
+ return mCurrentShader;
+ }
+ set
+ {
+ if (value == null)
+ return;
+
+ if (value is OtkShader == false)
+ throw new AgateLib.AgateException(string.Format(
+ "Shader type is {0} but must be IGlShader.", value.GetType()));
+
+ mCurrentShader = (OtkShader)value;
+
+ if (mCurrentShader == null)
+ {
+ GL.UseProgram(0);
+ }
+ else
+ {
+ GL.UseProgram(mCurrentShader.Handle);
+ }
+
+ }
+ }
+ 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 Supports(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: return new Size(1024, 1024);
+ }
+
+ 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 ---
+
+ protected override bool GetRenderState(RenderStateBool renderStateBool)
+ {
+ switch (renderStateBool)
+ {
+ case RenderStateBool.WaitForVerticalBlank: return mVSync;
+ default:
+ throw new NotSupportedException(string.Format(
+ "The specified render state, {0}, is not supported by this driver."));
+ }
+ }
+ protected override void SetRenderState(RenderStateBool renderStateBool, bool value)
+ {
+ switch (renderStateBool)
+ {
+ case RenderStateBool.WaitForVerticalBlank:
+ mVSync = value;
+ break;
+
+ default:
+ throw new NotSupportedException(string.Format(
+ "The specified render state, {0}, is not supported by this driver."));
+ }
+ }
+
+ #endregion
+
+ #region --- Deletion queuing ---
+
+ List<int> mTexturesToDelete = new List<int>();
+
+
+ private void FlushDeleteQueue()
+ {
+ lock (mTexturesToDelete)
+ {
+ int[] tex = mTexturesToDelete.ToArray();
+ mTexturesToDelete.Clear();
+
+ GL.DeleteTextures(mTexturesToDelete.Count, tex);
+ }
+ }
+
+ internal void QueueDeleteTexture(int p)
+ {
+ lock (mTexturesToDelete)
+ {
+ mTexturesToDelete.Add(p);
+ }
+ }
+
+ #endregion
+ }
+}
\ No newline at end of file
Deleted: trunk/Drivers/AgateOTK/GL_DisplayControl.cs
===================================================================
--- trunk/Drivers/AgateOTK/GL_DisplayControl.cs 2009-11-24 16:44:21 UTC (rev 1121)
+++ trunk/Drivers/AgateOTK/GL_DisplayControl.cs 2009-11-24 16:52:15 UTC (rev 1122)
@@ -1,571 +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.Diagnostics;
-using Drawing = System.Drawing;
-using System.Runtime.InteropServices;
-using System.Text;
-using System.Windows.Forms;
-
-using AgateLib;
-using AgateLib.DisplayLib;
-using AgateLib.Drivers;
-using AgateLib.Geometry;
-using AgateLib.ImplementationBase;
-using AgateLib.InputLib;
-using AgateLib.WinForms;
-
-using OpenTK.Graphics;
-using OpenTK.Graphics.OpenGL;
-using GL = OpenTK.Graphics.OpenGL.GL;
-using OpenTK.Platform;
-
-namespace AgateOTK
-{
- /// <summary>
- /// No OpenGL code here.
- /// </summary>
- public sealed class GL_DisplayControl : DisplayWindowImpl
- {
- Form frm;
- Control mRenderTarget;
- IGraphicsContext mContext;
- IWindowInfo mWindowInfo;
-
- GL_Display mDisplay;
- Drawing.Icon mIcon;
- bool mIsClosed = false;
- bool mIsFullScreen = false;
-
- string mTitle;
- bool mChooseFullscreen;
- int mChooseWidth;
- int mChooseHeight;
- int mChooseBitDepth = 32;
- bool mChooseResize;
- WindowPosition mChoosePosition;
-
- bool mHasFrame = true;
-
- ContextFB mFrameBuffer;
-
- public override FrameBufferImpl FrameBuffer
- {
- get { return mFrameBuffer; }
- }
- public GL_DisplayControl(CreateWindowParams windowParams)
- {
- mChoosePosition = windowParams.WindowPosition;
-
- if (windowParams.RenderToControl)
- {
- if (typeof(Control).IsAssignableFrom(windowParams.RenderTarget.GetType()) == false)
- throw new AgateException(string.Format("The specified render target is of type {0}, " +
- "which does not derive from System.Windows.Forms.Control.", windowParams.RenderTarget.GetType().Name));
-
- mRenderTarget = (Control)windowParams.RenderTarget;
-
- if (mRenderTarget.TopLevelControl == null)
- throw new ArgumentException("The specified render target has not been added to a Form yet. " +
- "Check to make sure that you are creating the DisplayWindow after all controls are added " +
- "to the Form. Do not create a DisplayWindow in a constructor for a UserControl, for example.");
-
- mChooseFullscreen = false;
- mChooseWidth = mRenderTarget.ClientSize.Width;
- mChooseHeight = mRenderTarget.ClientSize.Height;
-
- mDisplay = Display.Impl as GL_Display;
-
- CreateContext();
-
- AttachEvents();
- }
- else
- {
- if (string.IsNullOrEmpty(windowParams.IconFile) == false)
- mIcon = new Drawing.Icon(windowParams.IconFile);
-
- mTitle = windowParams.Title;
- mChooseFullscreen = windowParams.IsFullScreen;
- mChooseWidth = windowParams.Width;
- mChooseHeight = windowParams.Height;
- mChooseResize = windowParams.IsResizable;
- mHasFrame = windowParams.HasFrame;
-
- if (mChooseFullscreen)
- CreateFullScreenDisplay();
- else
- CreateWindowedDisplay();
-
- mDisplay = Display.Impl as GL_Display;
- }
-
- mDisplay.ProcessEventsEvent += new EventHandler(mDisplay_ProcessEventsEvent);
- mDisplay.InitializeCurrentContext();
- }
-
- void mDisplay_ProcessEventsEvent(object sender, EventArgs e)
- {
- System.Windows.Forms.Application.DoEvents();
- }
-
- private void CreateFullScreenDisplay()
- {
- DetachEvents();
-
- Form oldForm = frm;
- IGraphicsContext oldcontext = mContext;
- IWindowInfo oldWindowInfo = mWindowInfo;
-
- mContext = null;
-
- frm = new frmFullScreen();
- frm.Show();
-
- frm.Text = mTitle;
- frm.Icon = mIcon;
- frm.TopLevel = true;
-
- mRenderTarget = frm;
-
- AttachEvents();
-
- CreateContext();
-
-
- OpenTK.DisplayResolution resolution = OpenTK.DisplayDevice.Default.SelectResolution(
- mChooseWidth, mChooseHeight, 32, 0);
- OpenTK.DisplayDevice.Default.ChangeResolution(resolution);
-
- frm.Location = System.Drawing.Point.Empty;
- frm.ClientSize = new System.Drawing.Size(mChooseWidth, mChooseHeight);
- frm.Activate();
-
- System.Threading.Thread.Sleep(1000);
- mIsFullScreen = true;
-
- if (oldWindowInfo != null) oldWindowInfo.Dispose();
- if (oldcontext != null) oldcontext.Dispose();
- if (oldForm != null) oldForm.Dispose();
-
- Core.IsActive = true;
- }
-
- private void CreateWindowedDisplay()
- {
- DetachEvents();
-
- Form oldForm = frm;
- IGraphicsContext oldcontext = mContext;
- IWindowInfo oldWindowInfo = mWindowInfo;
-
- mContext = null;
- mIsFullScreen = false;
-
- Form myform;
- Control myRenderTarget;
-
- OpenTK.DisplayDevice.Default.RestoreResolution();
-
- AgateLib.WinForms.FormUtil.InitializeWindowsForm(out myform, out myRenderTarget, mChoosePosition,
- mTitle, mChooseWidth, mChooseHeight, mChooseFullscreen, mChooseResize, mHasFrame);
-
- frm = myform;
- mRenderTarget = myRenderTarget;
-
- if (mIcon != null)
- frm.Icon = mIcon;
-
- frm.Show();
- CreateContext();
-
- AttachEvents();
-
- if (oldWindowInfo != null) oldWindowInfo.Dispose();
- if (oldcontext != null) oldcontext.Dispose();
- if (oldForm != null) oldForm.Dispose();
-
- Core.IsActive = true;
- }
-
- private void CreateContext()
- {
- GraphicsMode newMode = new GraphicsMode(
- GraphicsMode.Default.ColorFormat, GraphicsMode.Default.Depth,
- 0, 0, new ColorFormat(0), 2, false);
-
- Debug.Print("AgateLib GraphicsMode: {0}", newMode);
-
-
- mWindowInfo = CreateWindowInfo(newMode);
-
- GraphicsContextFlags flags = GraphicsContextFlags.Default;
-#if DEBUG
- //flags = GraphicsContextFlags.ForwardCompatible;
-#endif
- mContext = new OpenTK.Graphics.GraphicsContext(newMode, mWindowInfo, 3, 1, flags);
- mContext.MakeCurrent(mWindowInfo);
- (mContext as IGraphicsContextInternal).LoadAll();
-
- mFrameBuffer = new ContextFB(mContext, mWindowInfo, this.Size);
- }
-
- private IWindowInfo CreateWindowInfo(GraphicsMode mode)
- {
- switch (AgateLib.Core.Platform.PlatformType)
- {
- case AgateLib.PlatformType.Windows:
- return OpenTK.Platform.Utilities.CreateWindowsWindowInfo(mRenderTarget.Handle);
- case AgateLib.PlatformType.MacOS:
- return OpenTK.Platform.Utilities.CreateMacOSCarbonWindowInfo(mRenderTarget.Handle, false, true);
- case AgateLib.PlatformType.Linux:
- return CreateX11WindowInfo(mode);
- case AgateLib.PlatformType.Gp2x:
- default:
- throw new Exception("Platform not implemented.");
- }
- }
-
- private IWindowInfo CreateX11WindowInfo(GraphicsMode mode)
- {
- Type xplatui = Type.GetType("System.Windows.Forms.XplatUIX11, System.Windows.Forms");
- if (xplatui == null) throw new PlatformNotSupportedException(
- "System.Windows.Forms.XplatUIX11 missing. Unsupported platform or Mono runtime version, aborting.");
-
- // get the required handles from the X11 API.
- IntPtr display = (IntPtr)GetStaticFieldValue(xplatui, "DisplayHandle");
- IntPtr rootWindow = (IntPtr)GetStaticFieldValue(xplatui, "RootWindow");
- int screen = (int)GetStaticFieldValue(xplatui, "ScreenNo");
-
- // get the X11 Visual info for the display.
- XVisualInfo info = new XVisualInfo();
- info.VisualID = mode.Index.Value;
- int dummy;
- info = (XVisualInfo)Marshal.PtrToStructure(
- XGetVisualInfo(display, XVisualInfoMask.ID, ref info, out dummy), typeof(XVisualInfo));
-
- // set the X11 colormap.
- SetStaticFieldValue(xplatui, "CustomVisual", info.Visual);
- SetStaticFieldValue(xplatui, "CustomColormap",
- XCreateColormap(display, rootWindow, info.Visual, 0));
-
- IntPtr infoPtr = Marshal.AllocHGlobal(Marshal.SizeOf(info));
- Marshal.StructureToPtr(info, infoPtr, false);
-
- IWindowInfo window = OpenTK.Platform.Utilities.CreateX11WindowInfo(
- display, screen, mRenderTarget.Handle, rootWindow, infoPtr);
-
- return window;
-
- }
-
- #region --- X11 imports ---
-
- [StructLayout(LayoutKind.Sequential)]
- struct XVisualInfo
- {
- public IntPtr Visual;
- public IntPtr VisualID;
- public int Screen;
- public int Depth;
- public OpenTK.Platform.X11.XVisualClass Class;
- public long RedMask;
- public long GreenMask;
- public long blueMask;
- public int ColormapSize;
- public int BitsPerRgb;
-
- public override string ToString()
- {
- return String.Format("id ({0}), screen ({1}), depth ({2}), class ({3})",
- VisualID, Screen, Depth, Class);
- }
- }
- [DllImport("libX11")]
- public static extern IntPtr XCreateColormap(IntPtr display, IntPtr window, IntPtr visual, int alloc);
-
- [DllImport("libX11", EntryPoint = "XGetVisualInfo")]
- static extern IntPtr XGetVisualInfoInternal(IntPtr display, IntPtr vinfo_mask, ref XVisualInfo template, out int nitems);
-
- static IntPtr XGetVisualInfo(IntPtr display, XVisualInfoMask vinfo_mask, ref XVisualInfo template, out int nitems)
- {
- return XGetVisualInfoInternal(display, (IntPtr)(int)vinfo_mask, ref template, out nitems);
- }
-
- [Flags]
- internal enum XVisualInfoMask
- {
- No = 0x0,
- ID = 0x1,
- Screen = 0x2,
- Depth = 0x4,
- Class = 0x8,
- Red = 0x10,
- Green = 0x20,
- Blue = 0x40,
- ColormapSize = 0x80,
- BitsPerRGB = 0x100,
- All = 0x1FF,
- }
-
-
- #endregion
- #region --- Utility functions for reading/writing non-public static fields through reflection ---
-
- private static object GetStaticFieldValue(Type type, string fieldName)
- {
- return type.GetField(fieldName,
- System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic).GetValue(null);
- }
- private static void SetStaticFieldValue(Type type, string fieldName, object value)
- {
- type.GetField(fieldName,
- System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic).SetValue(null, value);
- }
-
- #endregion
-
- public override void Dispose()
- {
- mDisplay.ProcessEventsEvent -= mDisplay_ProcessEventsEvent;
-
- if (mContext != null)
- {
- mContext.Dispose();
- mContext = null;
- }
-
- if (frm != null)
- {
- frm.Close();
- frm = null;
- }
-
- }...
[truncated message content] |
|
From: <ka...@us...> - 2009-11-24 16:44:30
|
Revision: 1121
http://agate.svn.sourceforge.net/agate/?rev=1121&view=rev
Author: kanato
Date: 2009-11-24 16:44:21 +0000 (Tue, 24 Nov 2009)
Log Message:
-----------
Separate legacy GL code from GL_Display.
Modified Paths:
--------------
trunk/Drivers/AgateOTK/AgateOTK.csproj
trunk/Drivers/AgateOTK/GL_Display.cs
Added Paths:
-----------
trunk/Drivers/AgateOTK/Legacy/LegacyPrimitiveRenderer.cs
trunk/Drivers/AgateOTK/Legacy/LegacyVertexBuffer.cs
trunk/Drivers/AgateOTK/PrimitiveRenderer.cs
Removed Paths:
-------------
trunk/Drivers/AgateOTK/GL_VertexBuffer.cs
Modified: trunk/Drivers/AgateOTK/AgateOTK.csproj
===================================================================
--- trunk/Drivers/AgateOTK/AgateOTK.csproj 2009-11-24 16:29:37 UTC (rev 1120)
+++ trunk/Drivers/AgateOTK/AgateOTK.csproj 2009-11-24 16:44:21 UTC (rev 1121)
@@ -128,6 +128,8 @@
<SubType>Code</SubType>
</Compile>
<Compile Include="Legacy\LegacyDrawBuffer.cs" />
+ <Compile Include="Legacy\LegacyPrimitiveRenderer.cs" />
+ <Compile Include="PrimitiveRenderer.cs" />
<Compile Include="Shaders\GlslFragmentProgram.cs">
<SubType>Code</SubType>
</Compile>
@@ -156,7 +158,7 @@
<Compile Include="GL_Surface.cs">
<SubType>Code</SubType>
</Compile>
- <Compile Include="GL_VertexBuffer.cs">
+ <Compile Include="Legacy\LegacyVertexBuffer.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Legacy\FrameBufferReadPixels.cs" />
Modified: trunk/Drivers/AgateOTK/GL_Display.cs
===================================================================
--- trunk/Drivers/AgateOTK/GL_Display.cs 2009-11-24 16:29:37 UTC (rev 1120)
+++ trunk/Drivers/AgateOTK/GL_Display.cs 2009-11-24 16:44:21 UTC (rev 1121)
@@ -35,8 +35,7 @@
namespace AgateOTK
{
/// <summary>
- /// Not OpenGL 3.1 compatible. Need replacements for:
- /// Begin/End, Vertex2, Vertex3 used in DrawRect,FillRect,etc. functions.
+ /// OpenGL 3.1 compatible.
/// </summary>
public sealed class GL_Display : DisplayImpl
{
@@ -52,6 +51,8 @@
System.Windows.Forms.Form mFakeWindow;
DisplayWindow mFakeDisplayWindow;
+ PrimitiveRenderer mPrimitives;
+
bool mGL3;
public bool NonPowerOf2Textures
@@ -108,7 +109,10 @@
}
protected override VertexBufferImpl CreateVertexBuffer(VertexLayout layout, int vertexCount)
{
- return new GL_VertexBuffer(layout, vertexCount);
+ if (mGL3)
+ return new Legacy.LegacyVertexBuffer(layout, vertexCount);
+ else
+ return new Legacy.LegacyVertexBuffer(layout, vertexCount);
}
protected override IndexBufferImpl CreateIndexBuffer(IndexBufferType type, int size)
{
@@ -199,23 +203,11 @@
DrawRect(dest, Color.FromArgb(255, color));
}
- public void SetGLColor(Color color)
- {
- GL.Color4(color.R / 255.0f, color.G / 255.0f, color.B / 255.0f, color.A / 255.0f);
- }
public override void DrawLine(Point a, Point b, Color color)
{
DrawBuffer.Flush();
- SetGLColor(color);
-
- GL.Disable(EnableCap.Texture2D);
- GL.Begin(BeginMode.Lines);
- GL.Vertex2(a.X, a.Y);
- GL.Vertex2(b.X, b.Y);
-
- GL.End();
- GL.Enable(EnableCap.Texture2D);
+ mPrimitives.DrawLine(a, b, color);
}
public override void DrawRect(Rectangle rect, Color color)
@@ -225,25 +217,7 @@
public override void DrawRect(RectangleF rect, Color color)
{
DrawBuffer.Flush();
- SetGLColor(color);
-
- GL.Disable(EnableCap.Texture2D);
- GL.Begin(BeginMode.Lines);
-
- GL.Vertex2(rect.Left, rect.Top);
- GL.Vertex2(rect.Right, rect.Top);
-
- GL.Vertex2(rect.Right, rect.Top);
- GL.Vertex2(rect.Right, rect.Bottom);
-
- GL.Vertex2(rect.Left, rect.Bottom);
- GL.Vertex2(rect.Right, rect.Bottom);
-
- GL.Vertex2(rect.Left, rect.Top);
- GL.Vertex2(rect.Left, rect.Bottom);
-
- GL.End();
- GL.Enable(EnableCap.Texture2D);
+ mPrimitives.DrawRect(rect, color);
}
public override void FillRect(Rectangle rect, Color color)
@@ -253,19 +227,7 @@
public override void FillRect(RectangleF rect, Color color)
{
DrawBuffer.Flush();
-
- SetGLColor(color);
-
- GL.Disable(EnableCap.Texture2D);
-
- 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
-
- GL.Enable(EnableCap.Texture2D);
+ mPrimitives.FillRect(rect, color);
}
public override void FillRect(Rectangle rect, Gradient color)
@@ -275,42 +237,13 @@
public override void FillRect(RectangleF rect, Gradient color)
{
DrawBuffer.Flush();
-
- GL.Disable(EnableCap.Texture2D);
-
- GL.Begin(BeginMode.Quads);
- SetGLColor(color.TopLeft);
- GL.Vertex3(rect.Left, rect.Top, 0); // Top Left
-
- SetGLColor(color.TopRight);
- GL.Vertex3(rect.Right, rect.Top, 0); // Top Right
-
- SetGLColor(color.BottomRight);
- GL.Vertex3(rect.Right, rect.Bottom, 0); // Bottom Right
-
- SetGLColor(color.BottomLeft);
- GL.Vertex3(rect.Left, rect.Bottom, 0); // Bottom Left
- GL.End(); // Done Drawing The Quad
-
- GL.Enable(EnableCap.Texture2D);
+ mPrimitives.FillRect(rect, color);
}
public override void FillPolygon(PointF[] pts, Color color)
{
DrawBuffer.Flush();
-
- GL.Disable(EnableCap.Texture2D);
-
- SetGLColor(color);
-
- GL.Begin(BeginMode.TriangleFan);
- for (int i = 0; i < pts.Length; i++)
- {
- GL.Vertex3(pts[i].X, pts[i].Y, 0);
- }
- GL.End(); // Done Drawing The Quad
-
- GL.Enable(EnableCap.Texture2D);
+ mPrimitives.FillPolygon(pts, color);
}
public override void Initialize()
@@ -321,15 +254,10 @@
}
public void InitializeCurrentContext()
{
-
- //GL.ShadeModel(ShadingModel.Smooth); // Enable Smooth Shading
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
- //GL.Hint(HintTarget.PerspectiveCorrectionHint, // Really Nice Perspective Calculations
- // HintMode.Nicest);
-
}
private void CreateFakeWindow()
{
@@ -344,6 +272,11 @@
mGLVersion = DetectOpenGLVersion();
LoadExtensions();
+ if (mGL3)
+ mPrimitives = new Legacy.LegacyPrimitiveRenderer();
+ else
+ mPrimitives = new Legacy.LegacyPrimitiveRenderer();
+
mSupportsFramebufferExt = SupportsExtension("GL_EXT_FRAMEBUFFER_OBJECT");
mNonPowerOf2Textures = SupportsExtension("GL_ARB_NON_POWER_OF_TWO");
Deleted: trunk/Drivers/AgateOTK/GL_VertexBuffer.cs
===================================================================
--- trunk/Drivers/AgateOTK/GL_VertexBuffer.cs 2009-11-24 16:29:37 UTC (rev 1120)
+++ trunk/Drivers/AgateOTK/GL_VertexBuffer.cs 2009-11-24 16:44:21 UTC (rev 1121)
@@ -1,275 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.Runtime.InteropServices;
-using System.Text;
-using AgateLib;
-using AgateLib.DisplayLib;
-using AgateLib.Geometry;
-using AgateLib.Geometry.VertexTypes;
-using AgateLib.ImplementationBase;
-using OpenTK.Graphics.OpenGL;
-
-namespace AgateOTK
-{
- /// <summary>
- /// Not OpenGL 3.1 compatible.
- /// Need replacements for SetClientStates/IndexPointer/NormalPointer/VertexPointer
- /// </summary>
- public class GL_VertexBuffer : VertexBufferImpl
- {
- GL_Display mDisplay;
- GLDrawBuffer mDrawBuffer;
-
- struct AttributeData
- {
- public string Name;
- public int BufferID;
- public VertexAttribPointerType Type;
- public int ComponentCount;
- }
-
- int mVertexCount;
- int mVertexBufferID;
-
- List<AttributeData> mAttributeBuffers = new List<AttributeData>();
-
- VertexLayout mLayout;
-
- public GL_VertexBuffer(VertexLayout layout, int count)
- {
- mDisplay = Display.Impl as GL_Display;
- mDrawBuffer = mDisplay.DrawBuffer;
- mVertexCount = count;
- mLayout = layout;
-
- GL.GenBuffers(1, out mVertexBufferID);
- Debug.Print("Vertex buffer ID: {0}", mVertexBufferID);
-
- }
-
- public override void Write<T>(T[] vertices)
- {
- GL.BindBuffer(BufferTarget.ArrayBuffer, mVertexBufferID);
- int size = vertices.Length * Marshal.SizeOf(typeof(T));
-
- GCHandle h = new GCHandle();
-
- try
- {
- h = GCHandle.Alloc(vertices, GCHandleType.Pinned);
-
- IntPtr arrayptr = Marshal.UnsafeAddrOfPinnedArrayElement(vertices, 0);
-
- unsafe
- {
- byte* ptr = (byte*)arrayptr;
-
- GL.BufferData(
- BufferTarget.ArrayBuffer,
- (IntPtr)size,
- (IntPtr)ptr,
- BufferUsageHint.StaticDraw);
- }
- }
- finally
- {
- h.Free();
- }
- }
-
- public override void Draw(int start, int count)
- {
- GL.BindBuffer(BufferTarget.ArrayBuffer, mVertexBufferID);
- SetClientStates();
- BeginMode beginMode = SelectBeginMode();
-
- GL.DrawArrays(beginMode, start, count);
- }
- public override void DrawIndexed(IndexBuffer indexbuffer, int start, int count)
- {
- GL_IndexBuffer gl_indexbuffer = (GL_IndexBuffer) indexbuffer.Impl;
-
- GL.BindBuffer(BufferTarget.ElementArrayBuffer, gl_indexbuffer.BufferID);
- GL.IndexPointer(IndexPointerType.Short, 0, start);
-
- GL.BindBuffer(BufferTarget.ArrayBuffer, mVertexBufferID);
- SetClientStates();
-
- BeginMode beginMode = SelectBeginMode();
- GL.DrawElements(beginMode, count, DrawElementsType.UnsignedShort, (IntPtr)0);
- }
-
- private void SetAttributes()
- {
- /*
- GlslShader shader = Display.Shader as GlslShader;
- if (shader == null)
- return;
-
- for (int i = 0; i < mAttributeBuffers.Count; i++)
- {
- if (shader.Attributes.Contains(mAttributeBuffers[i].Name) == false)
- continue;
-
- int size = mAttributeBuffers[i].ComponentCount;
- int shaderAttribIndex = shader.GetAttribLocation(mAttributeBuffers[i].Name);
-
- GL.EnableVertexAttribArray(shaderAttribIndex);
- GL.BindBuffer(BufferTarget.ArrayBuffer, mAttributeBuffers[i].BufferID);
- GL.VertexAttribPointer(shaderAttribIndex, size,
- mAttributeBuffers[i].Type,
- false, 0, IntPtr.Zero);
- }*/
-
- }
-
- private void SetClientStates()
- {
- mDisplay.SetGLColor(Color.White);
-
- if (UseTexture)
- SetTextures();
- else
- {
- GL.Disable(EnableCap.Texture2D);
- GL.DisableClientState(EnableCap.TextureCoordArray);
- }
-
- if (HasNormals)
- {
- GL.EnableClientState(EnableCap.NormalArray);
- GL.NormalPointer(NormalPointerType.Float, mLayout.VertexSize,
- (IntPtr) mLayout.ElementByteIndex(VertexElement.Normal));
- }
- else
- {
- GL.DisableClientState(EnableCap.NormalArray);
- }
-
- if (HasPositions)
- {
- GL.EnableClientState(EnableCap.VertexArray);
- GL.VertexPointer(
- PositionSize / sizeof(float), VertexPointerType.Float, mLayout.VertexSize,
- mLayout.ElementByteIndex(VertexElement.Position));
- }
-
- GL.DisableClientState(EnableCap.ColorArray);
-
-
- SetAttributes();
- }
-
- private void SetTextures()
- {
- GL.Enable(EnableCap.Texture2D);
-
- if (HasTextureCoords)
- {
- GL.EnableClientState(EnableCap.TextureCoordArray);
- GL.TexCoordPointer(
- 2, TexCoordPointerType.Float, mLayout.VertexSize,
- (IntPtr)mLayout.ElementByteIndex(VertexElement.Texture));
- }
-
-
- //GlslShader shader = Display.Shader as GlslShader;
-
- if (Textures.ActiveTextures > 1)
- {
- //for (int i = 0; i < Textures.Count; i++)
- //{
- // GL.ActiveTexture((TextureUnit)(TextureUnit.Texture0 + i));
-
- // Surface surf = Textures[i];
-
- // if (surf != null)
- // {
- // GL_Surface gl_surf = (GL_Surface)Textures[i].Impl;
-
- // GL.Enable(EnableCap.Texture2D);
- // GL.BindTexture(TextureTarget.Texture2D, gl_surf.GLTextureID);
-
- // if (shader != null)
- // {
- // if (i < shader.Sampler2DUniforms.Count)
- // {
- // shader.SetUniform(shader.Sampler2DUniforms[i], i);
- // }
- // }
- // }
- // else
- // {
- // GL.Disable(EnableCap.Texture2D);
- // GL.BindTexture(TextureTarget.Texture2D, 0);
- // }
- //}
- }
- else
- {
- GL.BindTexture(TextureTarget.Texture2D, ((GL_Surface)Textures[0].Impl).GLTextureID);
- }
- }
-
- private BeginMode SelectBeginMode()
- {
- BeginMode beginMode;
- switch (PrimitiveType)
- {
- case PrimitiveType.TriangleList: beginMode = BeginMode.Triangles; break;
- case PrimitiveType.TriangleFan: beginMode = BeginMode.TriangleFan; break;
- case PrimitiveType.TriangleStrip: beginMode = BeginMode.TriangleStrip; break;
-
- default:
- throw new AgateException(string.Format(
- "Unsupported PrimitiveType {0}", PrimitiveType));
- }
- return beginMode;
- }
-
- private static void CheckError()
- {
- ErrorCode err = GL.GetError();
-
- if (err != ErrorCode.NoError)
- System.Diagnostics.Debug.Print("Error: {0}", err);
- }
-
- public override int VertexCount
- {
- get { return mVertexCount; }
- }
-
- bool UseTexture
- {
- get { return HasTextureCoords && Textures.ActiveTextures != 0; }
- }
- public bool HasTextureCoords
- {
- get { return mLayout.ContainsElement(VertexElement.Texture); }
- }
- public bool HasNormals
- {
- get { return mLayout.ContainsElement(VertexElement.Normal); }
- }
- public bool HasPositions
- {
- get { return mLayout.ContainsElement(VertexElement.Position); }
- }
- public int PositionSize
- {
- get
- {
- VertexElementDesc d = mLayout.GetElement(VertexElement.Position);
-
- return VertexLayout.SizeOf(d.DataType);
- }
- }
-
- public override VertexLayout VertexLayout
- {
- get { return mLayout; }
- }
- }
-}
Added: trunk/Drivers/AgateOTK/Legacy/LegacyPrimitiveRenderer.cs
===================================================================
--- trunk/Drivers/AgateOTK/Legacy/LegacyPrimitiveRenderer.cs (rev 0)
+++ trunk/Drivers/AgateOTK/Legacy/LegacyPrimitiveRenderer.cs 2009-11-24 16:44:21 UTC (rev 1121)
@@ -0,0 +1,105 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using AgateLib.Geometry;
+using OpenTK.Graphics.OpenGL;
+
+namespace AgateOTK.Legacy
+{
+ class LegacyPrimitiveRenderer :PrimitiveRenderer
+ {
+ public void SetGLColor(Color color)
+ {
+ GL.Color4(color.R / 255.0f, color.G / 255.0f, color.B / 255.0f, color.A / 255.0f);
+ }
+
+ public override void DrawLine(Point a, Point b, Color color)
+ {
+ SetGLColor(color);
+
+ GL.Disable(EnableCap.Texture2D);
+ GL.Begin(BeginMode.Lines);
+ GL.Vertex2(a.X, a.Y);
+ GL.Vertex2(b.X, b.Y);
+
+ GL.End();
+ GL.Enable(EnableCap.Texture2D);
+ }
+
+ public override void DrawRect(RectangleF rect, Color color)
+ {
+ SetGLColor(color);
+
+ GL.Disable(EnableCap.Texture2D);
+ GL.Begin(BeginMode.Lines);
+
+ GL.Vertex2(rect.Left, rect.Top);
+ GL.Vertex2(rect.Right, rect.Top);
+
+ GL.Vertex2(rect.Right, rect.Top);
+ GL.Vertex2(rect.Right, rect.Bottom);
+
+ GL.Vertex2(rect.Left, rect.Bottom);
+ GL.Vertex2(rect.Right, rect.Bottom);
+
+ GL.Vertex2(rect.Left, rect.Top);
+ GL.Vertex2(rect.Left, rect.Bottom);
+
+ GL.End();
+ GL.Enable(EnableCap.Texture2D);
+ }
+ public override void FillRect(RectangleF rect, Color color)
+ {
+ SetGLColor(color);
+
+ GL.Disable(EnableCap.Texture2D);
+
+ 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
+
+ GL.Enable(EnableCap.Texture2D);
+ }
+ public override void FillRect(RectangleF rect, Gradient color)
+ {
+ GL.Disable(EnableCap.Texture2D);
+
+ GL.Begin(BeginMode.Quads);
+ SetGLColor(color.TopLeft);
+ GL.Vertex3(rect.Left, rect.Top, 0); // Top Left
+
+ SetGLColor(color.TopRight);
+ GL.Vertex3(rect.Right, rect.Top, 0); // Top Right
+
+ SetGLColor(color.BottomRight);
+ GL.Vertex3(rect.Right, rect.Bottom, 0); // Bottom Right
+
+ SetGLColor(color.BottomLeft);
+ GL.Vertex3(rect.Left, rect.Bottom, 0); // Bottom Left
+ GL.End(); // Done Drawing The Quad
+
+ GL.Enable(EnableCap.Texture2D);
+ }
+
+ public override void FillPolygon(PointF[] pts, Color color)
+ {
+ GL.Disable(EnableCap.Texture2D);
+
+ SetGLColor(color);
+
+ GL.Begin(BeginMode.TriangleFan);
+ for (int i = 0; i < pts.Length; i++)
+ {
+ GL.Vertex3(pts[i].X, pts[i].Y, 0);
+ }
+ GL.End(); // Done Drawing The Quad
+
+ GL.Enable(EnableCap.Texture2D);
+ }
+
+ }
+}
Copied: trunk/Drivers/AgateOTK/Legacy/LegacyVertexBuffer.cs (from rev 1120, trunk/Drivers/AgateOTK/GL_VertexBuffer.cs)
===================================================================
--- trunk/Drivers/AgateOTK/Legacy/LegacyVertexBuffer.cs (rev 0)
+++ trunk/Drivers/AgateOTK/Legacy/LegacyVertexBuffer.cs 2009-11-24 16:44:21 UTC (rev 1121)
@@ -0,0 +1,279 @@
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Runtime.InteropServices;
+using System.Text;
+using AgateLib;
+using AgateLib.DisplayLib;
+using AgateLib.Geometry;
+using AgateLib.Geometry.VertexTypes;
+using AgateLib.ImplementationBase;
+using OpenTK.Graphics.OpenGL;
+
+namespace AgateOTK.Legacy
+{
+ /// <summary>
+ /// Not OpenGL 3.1 compatible.
+ /// Need replacements for SetClientStates/IndexPointer/NormalPointer/VertexPointer
+ /// </summary>
+ public class LegacyVertexBuffer : VertexBufferImpl
+ {
+ GL_Display mDisplay;
+ GLDrawBuffer mDrawBuffer;
+
+ struct AttributeData
+ {
+ public string Name;
+ public int BufferID;
+ public VertexAttribPointerType Type;
+ public int ComponentCount;
+ }
+
+ int mVertexCount;
+ int mVertexBufferID;
+
+ List<AttributeData> mAttributeBuffers = new List<AttributeData>();
+
+ VertexLayout mLayout;
+
+ public LegacyVertexBuffer(VertexLayout layout, int count)
+ {
+ mDisplay = Display.Impl as GL_Display;
+ mDrawBuffer = mDisplay.DrawBuffer;
+ mVertexCount = count;
+ mLayout = layout;
+
+ GL.GenBuffers(1, out mVertexBufferID);
+ Debug.Print("Vertex buffer ID: {0}", mVertexBufferID);
+
+ }
+
+ public override void Write<T>(T[] vertices)
+ {
+ GL.BindBuffer(BufferTarget.ArrayBuffer, mVertexBufferID);
+ int size = vertices.Length * Marshal.SizeOf(typeof(T));
+
+ GCHandle h = new GCHandle();
+
+ try
+ {
+ h = GCHandle.Alloc(vertices, GCHandleType.Pinned);
+
+ IntPtr arrayptr = Marshal.UnsafeAddrOfPinnedArrayElement(vertices, 0);
+
+ unsafe
+ {
+ byte* ptr = (byte*)arrayptr;
+
+ GL.BufferData(
+ BufferTarget.ArrayBuffer,
+ (IntPtr)size,
+ (IntPtr)ptr,
+ BufferUsageHint.StaticDraw);
+ }
+ }
+ finally
+ {
+ h.Free();
+ }
+ }
+
+ public override void Draw(int start, int count)
+ {
+ GL.BindBuffer(BufferTarget.ArrayBuffer, mVertexBufferID);
+ SetClientStates();
+ BeginMode beginMode = SelectBeginMode();
+
+ GL.DrawArrays(beginMode, start, count);
+ }
+ public override void DrawIndexed(IndexBuffer indexbuffer, int start, int count)
+ {
+ GL_IndexBuffer gl_indexbuffer = (GL_IndexBuffer) indexbuffer.Impl;
+
+ GL.BindBuffer(BufferTarget.ElementArrayBuffer, gl_indexbuffer.BufferID);
+ GL.IndexPointer(IndexPointerType.Short, 0, start);
+
+ GL.BindBuffer(BufferTarget.ArrayBuffer, mVertexBufferID);
+ SetClientStates();
+
+ BeginMode beginMode = SelectBeginMode();
+ GL.DrawElements(beginMode, count, DrawElementsType.UnsignedShort, (IntPtr)0);
+ }
+
+ private void SetAttributes()
+ {
+ /*
+ GlslShader shader = Display.Shader as GlslShader;
+ if (shader == null)
+ return;
+
+ for (int i = 0; i < mAttributeBuffers.Count; i++)
+ {
+ if (shader.Attributes.Contains(mAttributeBuffers[i].Name) == false)
+ continue;
+
+ int size = mAttributeBuffers[i].ComponentCount;
+ int shaderAttribIndex = shader.GetAttribLocation(mAttributeBuffers[i].Name);
+
+ GL.EnableVertexAttribArray(shaderAttribIndex);
+ GL.BindBuffer(BufferTarget.ArrayBuffer, mAttributeBuffers[i].BufferID);
+ GL.VertexAttribPointer(shaderAttribIndex, size,
+ mAttributeBuffers[i].Type,
+ false, 0, IntPtr.Zero);
+ }*/
+
+ }
+
+ public void SetGLColor(Color color)
+ {
+ GL.Color4(color.R / 255.0f, color.G / 255.0f, color.B / 255.0f, color.A / 255.0f);
+ }
+ private void SetClientStates()
+ {
+ SetGLColor(Color.White);
+
+ if (UseTexture)
+ SetTextures();
+ else
+ {
+ GL.Disable(EnableCap.Texture2D);
+ GL.DisableClientState(EnableCap.TextureCoordArray);
+ }
+
+ if (HasNormals)
+ {
+ GL.EnableClientState(EnableCap.NormalArray);
+ GL.NormalPointer(NormalPointerType.Float, mLayout.VertexSize,
+ (IntPtr) mLayout.ElementByteIndex(VertexElement.Normal));
+ }
+ else
+ {
+ GL.DisableClientState(EnableCap.NormalArray);
+ }
+
+ if (HasPositions)
+ {
+ GL.EnableClientState(EnableCap.VertexArray);
+ GL.VertexPointer(
+ PositionSize / sizeof(float), VertexPointerType.Float, mLayout.VertexSize,
+ mLayout.ElementByteIndex(VertexElement.Position));
+ }
+
+ GL.DisableClientState(EnableCap.ColorArray);
+
+
+ SetAttributes();
+ }
+
+ private void SetTextures()
+ {
+ GL.Enable(EnableCap.Texture2D);
+
+ if (HasTextureCoords)
+ {
+ GL.EnableClientState(EnableCap.TextureCoordArray);
+ GL.TexCoordPointer(
+ 2, TexCoordPointerType.Float, mLayout.VertexSize,
+ (IntPtr)mLayout.ElementByteIndex(VertexElement.Texture));
+ }
+
+
+ //GlslShader shader = Display.Shader as GlslShader;
+
+ if (Textures.ActiveTextures > 1)
+ {
+ //for (int i = 0; i < Textures.Count; i++)
+ //{
+ // GL.ActiveTexture((TextureUnit)(TextureUnit.Texture0 + i));
+
+ // Surface surf = Textures[i];
+
+ // if (surf != null)
+ // {
+ // GL_Surface gl_surf = (GL_Surface)Textures[i].Impl;
+
+ // GL.Enable(EnableCap.Texture2D);
+ // GL.BindTexture(TextureTarget.Texture2D, gl_surf.GLTextureID);
+
+ // if (shader != null)
+ // {
+ // if (i < shader.Sampler2DUniforms.Count)
+ // {
+ // shader.SetUniform(shader.Sampler2DUniforms[i], i);
+ // }
+ // }
+ // }
+ // else
+ // {
+ // GL.Disable(EnableCap.Texture2D);
+ // GL.BindTexture(TextureTarget.Texture2D, 0);
+ // }
+ //}
+ }
+ else
+ {
+ GL.BindTexture(TextureTarget.Texture2D, ((GL_Surface)Textures[0].Impl).GLTextureID);
+ }
+ }
+
+ private BeginMode SelectBeginMode()
+ {
+ BeginMode beginMode;
+ switch (PrimitiveType)
+ {
+ case PrimitiveType.TriangleList: beginMode = BeginMode.Triangles; break;
+ case PrimitiveType.TriangleFan: beginMode = BeginMode.TriangleFan; break;
+ case PrimitiveType.TriangleStrip: beginMode = BeginMode.TriangleStrip; break;
+
+ default:
+ throw new AgateException(string.Format(
+ "Unsupported PrimitiveType {0}", PrimitiveType));
+ }
+ return beginMode;
+ }
+
+ private static void CheckError()
+ {
+ ErrorCode err = GL.GetError();
+
+ if (err != ErrorCode.NoError)
+ System.Diagnostics.Debug.Print("Error: {0}", err);
+ }
+
+ public override int VertexCount
+ {
+ get { return mVertexCount; }
+ }
+
+ bool UseTexture
+ {
+ get { return HasTextureCoords && Textures.ActiveTextures != 0; }
+ }
+ public bool HasTextureCoords
+ {
+ get { return mLayout.ContainsElement(VertexElement.Texture); }
+ }
+ public bool HasNormals
+ {
+ get { return mLayout.ContainsElement(VertexElement.Normal); }
+ }
+ public bool HasPositions
+ {
+ get { return mLayout.ContainsElement(VertexElement.Position); }
+ }
+ public int PositionSize
+ {
+ get
+ {
+ VertexElementDesc d = mLayout.GetElement(VertexElement.Position);
+
+ return VertexLayout.SizeOf(d.DataType);
+ }
+ }
+
+ public override VertexLayout VertexLayout
+ {
+ get { return mLayout; }
+ }
+ }
+}
Added: trunk/Drivers/AgateOTK/PrimitiveRenderer.cs
===================================================================
--- trunk/Drivers/AgateOTK/PrimitiveRenderer.cs (rev 0)
+++ trunk/Drivers/AgateOTK/PrimitiveRenderer.cs 2009-11-24 16:44:21 UTC (rev 1121)
@@ -0,0 +1,20 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using AgateLib.Geometry;
+
+namespace AgateOTK
+{
+ abstract class PrimitiveRenderer
+ {
+ public abstract void DrawLine(Point a, Point b, Color color);
+
+ public abstract void DrawRect(RectangleF rect, Color color);
+ public abstract void FillRect(RectangleF rect, Color color);
+ public abstract void FillRect(RectangleF rect, Gradient color);
+
+ public abstract void FillPolygon(PointF[] pts, Color color);
+
+ }
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ka...@us...> - 2009-11-24 16:29:52
|
Revision: 1120
http://agate.svn.sourceforge.net/agate/?rev=1120&view=rev
Author: kanato
Date: 2009-11-24 16:29:37 +0000 (Tue, 24 Nov 2009)
Log Message:
-----------
Move SetGLColor to GL_Display.
Modified Paths:
--------------
trunk/Drivers/AgateOTK/GLDrawBuffer.cs
trunk/Drivers/AgateOTK/GL_Display.cs
trunk/Drivers/AgateOTK/GL_VertexBuffer.cs
Modified: trunk/Drivers/AgateOTK/GLDrawBuffer.cs
===================================================================
--- trunk/Drivers/AgateOTK/GLDrawBuffer.cs 2009-11-24 16:25:05 UTC (rev 1119)
+++ trunk/Drivers/AgateOTK/GLDrawBuffer.cs 2009-11-24 16:29:37 UTC (rev 1120)
@@ -45,12 +45,5 @@
public abstract void AddQuad(int textureID, Gradient color, TextureCoordinates texCoord, PointF[] pts);
public abstract void Flush();
-
- [Obsolete]
- public void SetGLColor(Color color)
- {
- GL.Color4(color.R / 255.0f, color.G / 255.0f, color.B / 255.0f, color.A / 255.0f);
- }
-
}
}
Modified: trunk/Drivers/AgateOTK/GL_Display.cs
===================================================================
--- trunk/Drivers/AgateOTK/GL_Display.cs 2009-11-24 16:25:05 UTC (rev 1119)
+++ trunk/Drivers/AgateOTK/GL_Display.cs 2009-11-24 16:29:37 UTC (rev 1120)
@@ -44,7 +44,7 @@
Stack<Rectangle> mClipRects = new Stack<Rectangle>();
Rectangle mCurrentClip = Rectangle.Empty;
private bool mVSync = true;
- private bool mSupportsFramebuffer;
+ private bool mSupportsFramebufferExt;
private bool mNonPowerOf2Textures;
private bool mSupportsShaders;
private decimal mGLVersion;
@@ -60,12 +60,6 @@
private set { mNonPowerOf2Textures = value; }
}
- public bool SupportsFramebuffer
- {
- get { return mSupportsFramebuffer; }
- set { mSupportsFramebuffer = value; }
- }
-
internal event EventHandler ProcessEventsEvent;
protected override void ProcessEvents()
@@ -150,17 +144,10 @@
protected override FrameBufferImpl CreateFrameBuffer(Size size)
{
- if (mSupportsFramebuffer)
- {
- if (mGL3)
- {
- return new GL3.FrameBuffer(size);
- }
- else
- {
- return new Legacy.FrameBufferExt(size);
- }
- }
+ if (mGL3)
+ return new GL3.FrameBuffer(size);
+ else if (mSupportsFramebufferExt)
+ return new Legacy.FrameBufferExt(size);
else
return new Legacy.FrameBufferReadPixels(size);
}
@@ -212,10 +199,15 @@
DrawRect(dest, Color.FromArgb(255, color));
}
+ public void SetGLColor(Color color)
+ {
+ GL.Color4(color.R / 255.0f, color.G / 255.0f, color.B / 255.0f, color.A / 255.0f);
+ }
+
public override void DrawLine(Point a, Point b, Color color)
{
DrawBuffer.Flush();
- DrawBuffer.SetGLColor(color);
+ SetGLColor(color);
GL.Disable(EnableCap.Texture2D);
GL.Begin(BeginMode.Lines);
@@ -233,7 +225,7 @@
public override void DrawRect(RectangleF rect, Color color)
{
DrawBuffer.Flush();
- DrawBuffer.SetGLColor(color);
+ SetGLColor(color);
GL.Disable(EnableCap.Texture2D);
GL.Begin(BeginMode.Lines);
@@ -262,7 +254,7 @@
{
DrawBuffer.Flush();
- DrawBuffer.SetGLColor(color);
+ SetGLColor(color);
GL.Disable(EnableCap.Texture2D);
@@ -287,16 +279,16 @@
GL.Disable(EnableCap.Texture2D);
GL.Begin(BeginMode.Quads);
- DrawBuffer.SetGLColor(color.TopLeft);
+ SetGLColor(color.TopLeft);
GL.Vertex3(rect.Left, rect.Top, 0); // Top Left
- DrawBuffer.SetGLColor(color.TopRight);
+ SetGLColor(color.TopRight);
GL.Vertex3(rect.Right, rect.Top, 0); // Top Right
- DrawBuffer.SetGLColor(color.BottomRight);
+ SetGLColor(color.BottomRight);
GL.Vertex3(rect.Right, rect.Bottom, 0); // Bottom Right
- DrawBuffer.SetGLColor(color.BottomLeft);
+ SetGLColor(color.BottomLeft);
GL.Vertex3(rect.Left, rect.Bottom, 0); // Bottom Left
GL.End(); // Done Drawing The Quad
@@ -309,7 +301,7 @@
GL.Disable(EnableCap.Texture2D);
- DrawBuffer.SetGLColor(color);
+ SetGLColor(color);
GL.Begin(BeginMode.TriangleFan);
for (int i = 0; i < pts.Length; i++)
@@ -352,12 +344,11 @@
mGLVersion = DetectOpenGLVersion();
LoadExtensions();
- mSupportsFramebuffer = SupportsExtension("GL_EXT_FRAMEBUFFER_OBJECT");
+ mSupportsFramebufferExt = SupportsExtension("GL_EXT_FRAMEBUFFER_OBJECT");
mNonPowerOf2Textures = SupportsExtension("GL_ARB_NON_POWER_OF_TWO");
if (mGLVersion >= 3m)
{
- mSupportsFramebuffer = true;
mNonPowerOf2Textures = true;
mSupportsShaders = true;
mGL3 = true;
@@ -374,7 +365,6 @@
}
Trace.WriteLine(string.Format("OpenGL version {0} from vendor {1} detected.", mGLVersion, vendor));
- Trace.WriteLine("Framebuffer: " + mSupportsFramebuffer.ToString());
Trace.WriteLine("NPOT: " + mNonPowerOf2Textures.ToString());
Trace.WriteLine("Shaders: " + mSupportsShaders.ToString());
Modified: trunk/Drivers/AgateOTK/GL_VertexBuffer.cs
===================================================================
--- trunk/Drivers/AgateOTK/GL_VertexBuffer.cs 2009-11-24 16:25:05 UTC (rev 1119)
+++ trunk/Drivers/AgateOTK/GL_VertexBuffer.cs 2009-11-24 16:29:37 UTC (rev 1120)
@@ -126,7 +126,7 @@
private void SetClientStates()
{
- mDrawBuffer.SetGLColor(Color.White);
+ mDisplay.SetGLColor(Color.White);
if (UseTexture)
SetTextures();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ka...@us...> - 2009-11-24 16:25:15
|
Revision: 1119
http://agate.svn.sourceforge.net/agate/?rev=1119&view=rev
Author: kanato
Date: 2009-11-24 16:25:05 +0000 (Tue, 24 Nov 2009)
Log Message:
-----------
Some GL3/legacy GL organization.
Modified Paths:
--------------
trunk/Drivers/AgateOTK/AgateOTK.csproj
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/GL_VertexBuffer.cs
Added Paths:
-----------
trunk/Drivers/AgateOTK/GL3/DrawBuffer.cs
trunk/Drivers/AgateOTK/Legacy/LegacyDrawBuffer.cs
Modified: trunk/Drivers/AgateOTK/AgateOTK.csproj
===================================================================
--- trunk/Drivers/AgateOTK/AgateOTK.csproj 2009-11-24 07:06:26 UTC (rev 1118)
+++ trunk/Drivers/AgateOTK/AgateOTK.csproj 2009-11-24 16:25:05 UTC (rev 1119)
@@ -108,6 +108,7 @@
<SubType>Code</SubType>
</Compile>
<Compile Include="GL3\FrameBuffer.cs" />
+ <Compile Include="GL3\DrawBuffer.cs" />
<Compile Include="Legacy\ArbShader.cs">
<SubType>Code</SubType>
</Compile>
@@ -126,6 +127,7 @@
<Compile Include="GLDrawBuffer.cs">
<SubType>Code</SubType>
</Compile>
+ <Compile Include="Legacy\LegacyDrawBuffer.cs" />
<Compile Include="Shaders\GlslFragmentProgram.cs">
<SubType>Code</SubType>
</Compile>
Copied: trunk/Drivers/AgateOTK/GL3/DrawBuffer.cs (from rev 1112, trunk/Drivers/AgateOTK/GLDrawBuffer.cs)
===================================================================
--- trunk/Drivers/AgateOTK/GL3/DrawBuffer.cs (rev 0)
+++ trunk/Drivers/AgateOTK/GL3/DrawBuffer.cs 2009-11-24 16:25:05 UTC (rev 1119)
@@ -0,0 +1,284 @@
+// 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;
+using System.Text;
+
+using AgateLib;
+using AgateLib.DisplayLib;
+using AgateLib.Geometry;
+using AgateLib.Geometry.VertexTypes;
+
+using OpenTK.Graphics.OpenGL;
+
+namespace AgateOTK.GL3
+{
+ /// <summary>
+ /// Not GL3 compatible. Need replacements for
+ /// EnableClientState,TexCoordPointer, etc.
+ /// </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
+
+ PositionTextureColorNormal[] mVerts;
+
+ int mIndex;
+ int mCurrentTexture;
+
+ InterpolationMode lastInterpolation = (InterpolationMode)(-1);
+ PointF[] cachePts = new PointF[4];
+
+ int mBufferID;
+
+ public DrawBuffer()
+ {
+ GL.GenBuffers(1, out mBufferID);
+ Debug.Print("Draw buffer ID: {0}", mBufferID);
+
+ SetBufferSize(1000);
+ }
+
+ private void SetBufferSize(int size)
+ {
+ mVerts = new PositionTextureColorNormal[size];
+
+ mIndex = 0;
+ }
+
+
+ private void BufferData()
+ {
+ int bufferSize = mIndex * Marshal.SizeOf(typeof(PositionTextureColorNormal));
+
+ 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();
+ }
+ }
+ }
+
+ private void SetTexture(int textureID)
+ {
+ if (textureID == mCurrentTexture)
+ return;
+
+ Flush();
+
+ mCurrentTexture = textureID;
+ }
+ public override void ResetTexture()
+ {
+ Flush();
+
+ mCurrentTexture = 0;
+ }
+
+
+ public override void SetInterpolationMode(InterpolationMode mode)
+ {
+ if (mode == lastInterpolation)
+ return;
+
+ Flush();
+ lastInterpolation = mode;
+ }
+
+ public override void AddQuad(int textureID, Color color, TextureCoordinates texCoord, RectangleF destRect)
+ {
+ PointF[] pt = cachePts;
+
+ pt[0].X = destRect.Left;
+ pt[0].Y = destRect.Top;
+
+ pt[1].X = destRect.Right;
+ pt[1].Y = destRect.Top;
+
+ pt[2].X = destRect.Right;
+ pt[2].Y = destRect.Bottom;
+
+ pt[3].X = destRect.Left;
+ pt[3].Y = destRect.Bottom;
+
+ AddQuad(textureID, color, texCoord, pt);
+ }
+ public override void AddQuad(int textureID, Color color, TextureCoordinates texCoord, PointF[] pts)
+ {
+ AddQuad(textureID, new Gradient(color), texCoord, pts);
+ }
+ public override void AddQuad(int textureID, Gradient color, TextureCoordinates texCoord, PointF[] pts)
+ {
+ SetTexture(textureID);
+
+ if (mIndex + 4 >= mVerts.Length)
+ {
+ Flush();
+ SetBufferSize(mVerts.Length + 1000);
+ }
+
+ for (int i = 0; i < 4; i++)
+ {
+ mVerts[mIndex + i].X = pts[i].X;
+ mVerts[mIndex + i].Y = pts[i].Y;
+
+ mVerts[mIndex + i].Normal = new Vector3(0, 0, -1);
+ }
+
+ mVerts[mIndex].U = texCoord.Left;
+ mVerts[mIndex].V = texCoord.Top;
+ mVerts[mIndex].Color = color.TopLeft.ToArgb();
+
+ mVerts[mIndex+1].U = texCoord.Right;
+ mVerts[mIndex+1].V = texCoord.Top;
+ mVerts[mIndex + 1].Color = color.TopRight.ToArgb();
+
+ mVerts[mIndex + 2].U = texCoord.Right;
+ mVerts[mIndex + 2].V = texCoord.Bottom;
+ mVerts[mIndex + 2].Color = color.BottomRight.ToArgb();
+
+ mVerts[mIndex + 3].U = texCoord.Left;
+ mVerts[mIndex + 3].V = texCoord.Bottom;
+ mVerts[mIndex + 3].Color = color.BottomLeft.ToArgb();
+
+ mIndex += 4;
+
+ }
+
+ public override void Flush()
+ {
+ if (mIndex == 0)
+ return;
+
+ BufferData();
+
+ GL.BindTexture(TextureTarget.Texture2D, mCurrentTexture);
+
+ SetGLInterpolation();
+
+ GL.EnableClientState(EnableCap.TextureCoordArray);
+ GL.EnableClientState(EnableCap.ColorArray);
+ GL.EnableClientState(EnableCap.VertexArray);
+ GL.EnableClientState(EnableCap.NormalArray);
+
+ int size = Marshal.SizeOf(typeof(PositionTextureColorNormal));
+ int tex = PositionTextureColorNormal.VertexLayout.ElementByteIndex(VertexElement.Texture);
+ int color = PositionTextureColorNormal.VertexLayout.ElementByteIndex(VertexElement.DiffuseColor);
+ int pos = PositionTextureColorNormal.VertexLayout.ElementByteIndex(VertexElement.Position);
+ int norm = PositionTextureColorNormal.VertexLayout.ElementByteIndex(VertexElement.Normal);
+
+ GL.TexCoordPointer(2, TexCoordPointerType.Float, size, (IntPtr) tex);
+ GL.ColorPointer(4, ColorPointerType.UnsignedByte, size, color);
+ GL.VertexPointer(2, VertexPointerType.Float, size, pos);
+ GL.NormalPointer(NormalPointerType.Float, size, (IntPtr)norm);
+
+ GL.DrawArrays(BeginMode.Quads, 0, mIndex);
+
+ mIndex = 0;
+ }
+
+ private void SetGLInterpolation()
+ {
+
+ switch (this.lastInterpolation)
+ {
+ case InterpolationMode.Fastest:
+ GL.TexParameter(TextureTarget.Texture2D,
+ TextureParameterName.TextureMinFilter,
+ (int)TextureMinFilter.Nearest);
+ GL.TexParameter(TextureTarget.Texture2D,
+ TextureParameterName.TextureMagFilter,
+ (int)TextureMagFilter.Nearest);
+
+ break;
+
+ case InterpolationMode.Default:
+ case InterpolationMode.Nicest:
+ GL.TexParameter(TextureTarget.Texture2D,
+ TextureParameterName.TextureMinFilter,
+ (int)TextureMinFilter.Linear);
+ GL.TexParameter(TextureTarget.Texture2D,
+ TextureParameterName.TextureMagFilter,
+ (int)TextureMagFilter.Linear);
+
+
+ break;
+ }
+ }
+ }
+}
Modified: trunk/Drivers/AgateOTK/GLDrawBuffer.cs
===================================================================
--- trunk/Drivers/AgateOTK/GLDrawBuffer.cs 2009-11-24 07:06:26 UTC (rev 1118)
+++ trunk/Drivers/AgateOTK/GLDrawBuffer.cs 2009-11-24 16:25:05 UTC (rev 1119)
@@ -31,253 +31,22 @@
namespace AgateOTK
{
- public class GLDrawBuffer
+ /// <summary>
+ /// Not GL3 compatible. Need replacements for
+ /// EnableClientState,TexCoordPointer, etc.
+ /// </summary>
+ public abstract class GLDrawBuffer
{
- #region --- Private types for Vertex Arrays ---
+ public abstract void ResetTexture();
+ public abstract void SetInterpolationMode(InterpolationMode mode);
- [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 abstract void AddQuad(int textureID, Color color, TextureCoordinates texCoord, RectangleF destRect);
+ public abstract void AddQuad(int textureID, Color color, TextureCoordinates texCoord, PointF[] pts);
+ public abstract void AddQuad(int textureID, Gradient color, TextureCoordinates texCoord, PointF[] pts);
- 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 abstract void Flush();
- public NormalCoord(float x, float y, float z)
- {
- this.x = x;
- this.y = y;
- this.z = z;
- }
- }
- #endregion
-
- PositionTextureColorNormal[] mVerts;
-
- int mIndex;
- int mCurrentTexture;
-
- InterpolationMode lastInterpolation = (InterpolationMode)(-1);
- PointF[] cachePts = new PointF[4];
-
- int mBufferID;
-
- public GLDrawBuffer()
- {
- GL.GenBuffers(1, out mBufferID);
- Debug.Print("Draw buffer ID: {0}", mBufferID);
-
- SetBufferSize(1000);
- }
-
- private void SetBufferSize(int size)
- {
- mVerts = new PositionTextureColorNormal[size];
-
- mIndex = 0;
- }
-
-
- private void BufferData()
- {
- int bufferSize = mIndex * Marshal.SizeOf(typeof(PositionTextureColorNormal));
-
- 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();
- }
- }
- }
-
- private void SetTexture(int textureID)
- {
- if (textureID == mCurrentTexture)
- return;
-
- Flush();
-
- mCurrentTexture = textureID;
- }
- public void ResetTexture()
- {
- Flush();
-
- mCurrentTexture = 0;
- }
-
-
- public void SetInterpolationMode(InterpolationMode mode)
- {
- if (mode == lastInterpolation)
- return;
-
- Flush();
- lastInterpolation = mode;
- }
-
- public void AddQuad(int textureID, Color color, TextureCoordinates texCoord, RectangleF destRect)
- {
- PointF[] pt = cachePts;
-
- pt[0].X = destRect.Left;
- pt[0].Y = destRect.Top;
-
- pt[1].X = destRect.Right;
- pt[1].Y = destRect.Top;
-
- pt[2].X = destRect.Right;
- pt[2].Y = destRect.Bottom;
-
- pt[3].X = destRect.Left;
- pt[3].Y = destRect.Bottom;
-
- AddQuad(textureID, color, texCoord, pt);
- }
- public void AddQuad(int textureID, Color color, TextureCoordinates texCoord, PointF[] pts)
- {
- AddQuad(textureID, new Gradient(color), texCoord, pts);
- }
- public void AddQuad(int textureID, Gradient color, TextureCoordinates texCoord, PointF[] pts)
- {
- SetTexture(textureID);
-
- if (mIndex + 4 >= mVerts.Length)
- {
- Flush();
- SetBufferSize(mVerts.Length + 1000);
- }
-
- for (int i = 0; i < 4; i++)
- {
- mVerts[mIndex + i].X = pts[i].X;
- mVerts[mIndex + i].Y = pts[i].Y;
-
- mVerts[mIndex + i].Normal = new Vector3(0, 0, -1);
- }
-
- mVerts[mIndex].U = texCoord.Left;
- mVerts[mIndex].V = texCoord.Top;
- mVerts[mIndex].Color = color.TopLeft.ToArgb();
-
- mVerts[mIndex+1].U = texCoord.Right;
- mVerts[mIndex+1].V = texCoord.Top;
- mVerts[mIndex + 1].Color = color.TopRight.ToArgb();
-
- mVerts[mIndex + 2].U = texCoord.Right;
- mVerts[mIndex + 2].V = texCoord.Bottom;
- mVerts[mIndex + 2].Color = color.BottomRight.ToArgb();
-
- mVerts[mIndex + 3].U = texCoord.Left;
- mVerts[mIndex + 3].V = texCoord.Bottom;
- mVerts[mIndex + 3].Color = color.BottomLeft.ToArgb();
-
- mIndex += 4;
-
- }
-
- public void Flush()
- {
- if (mIndex == 0)
- return;
-
- BufferData();
-
- GL.BindTexture(TextureTarget.Texture2D, mCurrentTexture);
-
- SetGLInterpolation();
-
- GL.EnableClientState(EnableCap.TextureCoordArray);
- GL.EnableClientState(EnableCap.ColorArray);
- GL.EnableClientState(EnableCap.VertexArray);
- GL.EnableClientState(EnableCap.NormalArray);
-
- int size = Marshal.SizeOf(typeof(PositionTextureColorNormal));
- int tex = PositionTextureColorNormal.VertexLayout.ElementByteIndex(VertexElement.Texture);
- int color = PositionTextureColorNormal.VertexLayout.ElementByteIndex(VertexElement.DiffuseColor);
- int pos = PositionTextureColorNormal.VertexLayout.ElementByteIndex(VertexElement.Position);
- int norm = PositionTextureColorNormal.VertexLayout.ElementByteIndex(VertexElement.Normal);
-
- GL.TexCoordPointer(2, TexCoordPointerType.Float, size, (IntPtr) tex);
- GL.ColorPointer(4, ColorPointerType.UnsignedByte, size, color);
- GL.VertexPointer(2, VertexPointerType.Float, size, pos);
- GL.NormalPointer(NormalPointerType.Float, size, (IntPtr)norm);
-
- GL.DrawArrays(BeginMode.Quads, 0, mIndex);
-
- mIndex = 0;
- }
-
- private void SetGLInterpolation()
- {
-
- switch (this.lastInterpolation)
- {
- case InterpolationMode.Fastest:
- GL.TexParameter(TextureTarget.Texture2D,
- TextureParameterName.TextureMinFilter,
- (int)TextureMinFilter.Nearest);
- GL.TexParameter(TextureTarget.Texture2D,
- TextureParameterName.TextureMagFilter,
- (int)TextureMagFilter.Nearest);
-
- break;
-
- case InterpolationMode.Default:
- case InterpolationMode.Nicest:
- GL.TexParameter(TextureTarget.Texture2D,
- TextureParameterName.TextureMinFilter,
- (int)TextureMinFilter.Linear);
- GL.TexParameter(TextureTarget.Texture2D,
- TextureParameterName.TextureMagFilter,
- (int)TextureMagFilter.Linear);
-
-
- break;
- }
- }
-
-
+ [Obsolete]
public void SetGLColor(Color color)
{
GL.Color4(color.R / 255.0f, color.G / 255.0f, color.B / 255.0f, color.A / 255.0f);
Modified: trunk/Drivers/AgateOTK/GL_Display.cs
===================================================================
--- trunk/Drivers/AgateOTK/GL_Display.cs 2009-11-24 07:06:26 UTC (rev 1118)
+++ trunk/Drivers/AgateOTK/GL_Display.cs 2009-11-24 16:25:05 UTC (rev 1119)
@@ -34,6 +34,10 @@
namespace AgateOTK
{
+ /// <summary>
+ /// Not OpenGL 3.1 compatible. Need replacements for:
+ /// Begin/End, Vertex2, Vertex3 used in DrawRect,FillRect,etc. functions.
+ /// </summary>
public sealed class GL_Display : DisplayImpl
{
GL_FrameBuffer mRenderTarget;
@@ -136,6 +140,14 @@
return AgateLib.WinForms.BitmapFontUtil.ConstructFromOSFont(bitmapOptions);
}
+ public GLDrawBuffer CreateDrawBuffer()
+ {
+ if (mGL3)
+ return new GL3.DrawBuffer();
+ else
+ return new Legacy.LegacyDrawBuffer();
+ }
+
protected override FrameBufferImpl CreateFrameBuffer(Size size)
{
if (mSupportsFramebuffer)
@@ -153,19 +165,6 @@
return new Legacy.FrameBufferReadPixels(size);
}
- internal void SetupGLOrtho(Rectangle ortho)
- {
- SetOrthoProjection(ortho);
-
- GL.Enable(EnableCap.Texture2D);
-
- GL.Enable(EnableCap.Blend);
- GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);
-
- GL.MatrixMode(MatrixMode.Modelview);
- GL.LoadIdentity();
- }
-
protected override void OnBeginFrame()
{
mRenderTarget.BeginRender();
@@ -191,8 +190,6 @@
GL.Viewport(newClipRect.X, mRenderTarget.Height - newClipRect.Bottom,
newClipRect.Width, newClipRect.Height);
- SetupGLOrtho(newClipRect);
-
mCurrentClip = newClipRect;
}
@@ -206,7 +203,7 @@
DrawBuffer.Flush();
GL.ClearColor(color.R / 255.0f, color.G / 255.0f, color.B / 255.0f, 1.0f);
- GL.Clear(ClearBufferMask.DepthBufferBit | ClearBufferMask.ColorBufferBit);
+ GL.Clear(ClearBufferMask.DepthBufferBit | ClearBufferMask.ColorBufferBit | ClearBufferMask.StencilBufferBit);
}
public override void Clear(Color color, Rectangle dest)
{
@@ -387,7 +384,7 @@
string[] extensions;
private void LoadExtensions()
{
- try
+ if (mGL3)
{
// Forward compatible context (GL 3.0+)
int num_extensions;
@@ -401,7 +398,7 @@
for (int i = 0; i < num_extensions; i++)
extensions[i] = GL.GetString(StringName.Extensions, i).ToLowerInvariant();
}
- catch (OpenTK.Graphics.GraphicsErrorException)
+ else
{
string ext = GL.GetString(StringName.Extensions);
@@ -411,6 +408,7 @@
Debug.Print(extensions[i]);
}
}
+
private bool SupportsExtension(string name)
{
return extensions.Contains(name.ToLowerInvariant());
Modified: trunk/Drivers/AgateOTK/GL_DisplayControl.cs
===================================================================
--- trunk/Drivers/AgateOTK/GL_DisplayControl.cs 2009-11-24 07:06:26 UTC (rev 1118)
+++ trunk/Drivers/AgateOTK/GL_DisplayControl.cs 2009-11-24 16:25:05 UTC (rev 1119)
@@ -39,6 +39,9 @@
namespace AgateOTK
{
+ /// <summary>
+ /// No OpenGL code here.
+ /// </summary>
public sealed class GL_DisplayControl : DisplayWindowImpl
{
Form frm;
@@ -357,7 +360,6 @@
}
-
private void AttachEvents()
{
if (mRenderTarget == null)
@@ -378,7 +380,6 @@
form.KeyUp += new System.Windows.Forms.KeyEventHandler(form_KeyUp);
}
-
private void DetachEvents()
{
if (mRenderTarget == null)
@@ -416,15 +417,15 @@
return retval;
}
+
void mRenderTarget_Disposed(object sender, EventArgs e)
{
mIsClosed = true;
}
-
void mRenderTarget_Resize(object sender, EventArgs e)
{
mContext.Update(mWindowInfo);
- GL.Viewport(0, 0, mRenderTarget.Width, mRenderTarget.Height);
+ mFrameBuffer.SetSize(new Size(mRenderTarget.Width, mRenderTarget.Height));
}
@@ -527,36 +528,6 @@
}
}
-
- public void MakeCurrent()
- {
- if (mContext.IsCurrent == false)
- {
- mContext.MakeCurrent(mWindowInfo);
- }
-
- GL.Viewport(0, 0, Width, Height);
-
- mDisplay.SetupGLOrtho(Rectangle.FromLTRB(0, Height, Width, 0));
-
- }
-
- public void BeginRender()
- {
- MakeCurrent();
-
- mDisplay.SetClipRect(new Rectangle(0, 0, Width, Height));
-
- }
-
- public void EndRender()
- {
- if (mContext.VSync != Display.RenderState.WaitForVerticalBlank)
- mContext.VSync = Display.RenderState.WaitForVerticalBlank;
-
- mContext.SwapBuffers();
- }
-
public override void SetFullScreen()
{
SetFullScreen(mChooseWidth, mChooseHeight, mChooseBitDepth);
Modified: trunk/Drivers/AgateOTK/GL_FrameBuffer.cs
===================================================================
--- trunk/Drivers/AgateOTK/GL_FrameBuffer.cs 2009-11-24 07:06:26 UTC (rev 1118)
+++ trunk/Drivers/AgateOTK/GL_FrameBuffer.cs 2009-11-24 16:25:05 UTC (rev 1119)
@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
+using AgateLib.DisplayLib;
using AgateLib.Geometry;
using AgateLib.ImplementationBase;
@@ -9,8 +10,13 @@
{
abstract class GL_FrameBuffer: FrameBufferImpl
{
- GLDrawBuffer mDrawBuffer = new GLDrawBuffer();
+ GLDrawBuffer mDrawBuffer;
+ public GL_FrameBuffer()
+ {
+ mDrawBuffer = ((GL_Display)Display.Impl).CreateDrawBuffer();
+ }
+
public GLDrawBuffer DrawBuffer { get { return mDrawBuffer; } }
public abstract void MakeCurrent();
Modified: trunk/Drivers/AgateOTK/GL_GameWindow.cs
===================================================================
--- trunk/Drivers/AgateOTK/GL_GameWindow.cs 2009-11-24 07:06:26 UTC (rev 1118)
+++ trunk/Drivers/AgateOTK/GL_GameWindow.cs 2009-11-24 16:25:05 UTC (rev 1119)
@@ -21,6 +21,7 @@
using System.Diagnostics;
using System.Text;
+using AgateLib.DisplayLib;
using AgateLib.ImplementationBase;
using AgateLib.InputLib;
using AgateLib.Geometry;
@@ -32,8 +33,10 @@
namespace AgateOTK
{
- using AgateLib.DisplayLib;
+ /// <summary>
+ /// Old, needs to be updated.
+ /// </summary>
class GL_GameWindow : DisplayWindowImpl
{
static Dictionary<OpenTK.Input.Key, KeyCode> keyMap = new Dictionary<OpenTK.Input.Key, KeyCode>();
@@ -201,7 +204,7 @@
mDisplay.InitializeCurrentContext();
- mDrawBuffer = new GLDrawBuffer();
+ mDrawBuffer = mDisplay.CreateDrawBuffer();
}
public override FrameBufferImpl FrameBuffer
@@ -450,9 +453,6 @@
mWindow.Context.VSync = Display.RenderState.WaitForVerticalBlank;
MakeCurrent();
-
- mDisplay.SetupGLOrtho(Rectangle.FromLTRB(0, 0, Width, Height));
-
}
public void EndRender()
Modified: trunk/Drivers/AgateOTK/GL_IndexBuffer.cs
===================================================================
--- trunk/Drivers/AgateOTK/GL_IndexBuffer.cs 2009-11-24 07:06:26 UTC (rev 1118)
+++ trunk/Drivers/AgateOTK/GL_IndexBuffer.cs 2009-11-24 16:25:05 UTC (rev 1119)
@@ -9,6 +9,9 @@
namespace AgateOTK
{
+ /// <summary>
+ /// OpenGL 3.1 compatible.
+ /// </summary>
class GL_IndexBuffer : IndexBufferImpl
{
int mCount;
Modified: trunk/Drivers/AgateOTK/GL_Surface.cs
===================================================================
--- trunk/Drivers/AgateOTK/GL_Surface.cs 2009-11-24 07:06:26 UTC (rev 1118)
+++ trunk/Drivers/AgateOTK/GL_Surface.cs 2009-11-24 16:25:05 UTC (rev 1119)
@@ -38,7 +38,9 @@
namespace AgateOTK
{
-
+ /// <summary>
+ /// OpenGL 3.1 compatible.
+ /// </summary>
public sealed class GL_Surface : SurfaceImpl
{
GL_Display mDisplay;
@@ -56,7 +58,7 @@
Rectangle mSourceRect;
/// <summary>
- /// OpenGL's texture size (always a power of 2).
+ /// OpenGL's texture size (always a power of 2, unles NPOT extension is available.).
/// </summary>
Size mTextureSize;
@@ -91,8 +93,6 @@
mTextureSize = GetOGLSize(size);
- //int[] array = new int[1];
- //GL.GenTextures(1, array);
int textureID;
GL.GenTextures(1, out textureID);
@@ -375,51 +375,6 @@
get { return mSourceRect.Size; }
}
- public void BeginRender()
- {
- GL.Viewport(0, 0, SurfaceWidth, SurfaceHeight);
-
- mDisplay.SetupGLOrtho(Rectangle.FromLTRB(0, SurfaceHeight, SurfaceWidth, 0));
-
- if (mDisplay.SupportsFramebuffer)
- {
-
-
- }
- else
- {
-
- // clear the framebuffer and draw this texture to it.
-
- }
- }
- public void EndRender()
- {
- if (mDisplay.SupportsFramebuffer)
- {
- GL.Ext.GenerateMipmap(GenerateMipmapTarget.Texture2D);
-
- GL.PopAttrib();
- GL.Ext.BindFramebuffer(FramebufferTarget.FramebufferExt, 0);
-
- //GL.Ext.DeleteRenderbuffers(1, ref mDepthBuffer);
- //GL.Ext.DeleteFramebuffers(1, ref mFramebufferID);
- }
- else
- {
-
- }
- }
-
- #region GL_IRenderTarget Members
-
- public void MakeCurrent()
- {
-
- }
-
- #endregion
-
internal int GLTextureID { get { return mTextureID; } }
private void Load()
Modified: trunk/Drivers/AgateOTK/GL_VertexBuffer.cs
===================================================================
--- trunk/Drivers/AgateOTK/GL_VertexBuffer.cs 2009-11-24 07:06:26 UTC (rev 1118)
+++ trunk/Drivers/AgateOTK/GL_VertexBuffer.cs 2009-11-24 16:25:05 UTC (rev 1119)
@@ -12,6 +12,10 @@
namespace AgateOTK
{
+ /// <summary>
+ /// Not OpenGL 3.1 compatible.
+ /// Need replacements for SetClientStates/IndexPointer/NormalPointer/VertexPointer
+ /// </summary>
public class GL_VertexBuffer : VertexBufferImpl
{
GL_Display mDisplay;
Copied: trunk/Drivers/AgateOTK/Legacy/LegacyDrawBuffer.cs (from rev 1112, trunk/Drivers/AgateOTK/GLDrawBuffer.cs)
===================================================================
--- trunk/Drivers/AgateOTK/Legacy/LegacyDrawBuffer.cs (rev 0)
+++ trunk/Drivers/AgateOTK/Legacy/LegacyDrawBuffer.cs 2009-11-24 16:25:05 UTC (rev 1119)
@@ -0,0 +1,284 @@
+// 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;
+using System.Text;
+
+using AgateLib;
+using AgateLib.DisplayLib;
+using AgateLib.Geometry;
+using AgateLib.Geometry.VertexTypes;
+
+using OpenTK.Graphics.OpenGL;
+
+namespace AgateOTK.Legacy
+{
+ /// <summary>
+ /// Not GL3 compatible. Need replacements for
+ /// EnableClientState,TexCoordPointer, etc.
+ /// </summary>
+ public class LegacyDrawBuffer: 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
+
+ PositionTextureColorNormal[] mVerts;
+
+ int mIndex;
+ int mCurrentTexture;
+
+ InterpolationMode lastInterpolation = (InterpolationMode)(-1);
+ PointF[] cachePts = new PointF[4];
+
+ int mBufferID;
+
+ public LegacyDrawBuffer()
+ {
+ GL.GenBuffers(1, out mBufferID);
+ Debug.Print("Draw buffer ID: {0}", mBufferID);
+
+ SetBufferSize(1000);
+ }
+
+ private void SetBufferSize(int size)
+ {
+ mVerts = new PositionTextureColorNormal[size];
+
+ mIndex = 0;
+ }
+
+
+ private void BufferData()
+ {
+ int bufferSize = mIndex * Marshal.SizeOf(typeof(PositionTextureColorNormal));
+
+ 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();
+ }
+ }
+ }
+
+ private void SetTexture(int textureID)
+ {
+ if (textureID == mCurrentTexture)
+ return;
+
+ Flush();
+
+ mCurrentTexture = textureID;
+ }
+ public override void ResetTexture()
+ {
+ Flush();
+
+ mCurrentTexture = 0;
+ }
+
+
+ public override void SetInterpolationMode(InterpolationMode mode)
+ {
+ if (mode == lastInterpolation)
+ return;
+
+ Flush();
+ lastInterpolation = mode;
+ }
+
+ public override void AddQuad(int textureID, Color color, TextureCoordinates texCoord, RectangleF destRect)
+ {
+ PointF[] pt = cachePts;
+
+ pt[0].X = destRect.Left;
+ pt[0].Y = destRect.Top;
+
+ pt[1].X = destRect.Right;
+ pt[1].Y = destRect.Top;
+
+ pt[2].X = destRect.Right;
+ pt[2].Y = destRect.Bottom;
+
+ pt[3].X = destRect.Left;
+ pt[3].Y = destRect.Bottom;
+
+ AddQuad(textureID, color, texCoord, pt);
+ }
+ public override void AddQuad(int textureID, Color color, TextureCoordinates texCoord, PointF[] pts)
+ {
+ AddQuad(textureID, new Gradient(color), texCoord, pts);
+ }
+ public override void AddQuad(int textureID, Gradient color, TextureCoordinates texCoord, PointF[] pts)
+ {
+ SetTexture(textureID);
+
+ if (mIndex + 4 >= mVerts.Length)
+ {
+ Flush();
+ SetBufferSize(mVerts.Length + 1000);
+ }
+
+ for (int i = 0; i < 4; i++)
+ {
+ mVerts[mIndex + i].X = pts[i].X;
+ mVerts[mIndex + i].Y = pts[i].Y;
+
+ mVerts[mIndex + i].Normal = new Vector3(0, 0, -1);
+ }
+
+ mVerts[mIndex].U = texCoord.Left;
+ mVerts[mIndex].V = texCoord.Top;
+ mVerts[mIndex].Color = color.TopLeft.ToArgb();
+
+ mVerts[mIndex+1].U = texCoord.Right;
+ mVerts[mIndex+1].V = texCoord.Top;
+ mVerts[mIndex + 1].Color = color.TopRight.ToArgb();
+
+ mVerts[mIndex + 2].U = texCoord.Right;
+ mVerts[mIndex + 2].V = texCoord.Bottom;
+ mVerts[mIndex + 2].Color = color.BottomRight.ToArgb();
+
+ mVerts[mIndex + 3].U = texCoord.Left;
+ mVerts[mIndex + 3].V = texCoord.Bottom;
+ mVerts[mIndex + 3].Color = color.BottomLeft.ToArgb();
+
+ mIndex += 4;
+
+ }
+
+ public override void Flush()
+ {
+ if (mIndex == 0)
+ return;
+
+ BufferData();
+
+ GL.BindTexture(TextureTarget.Texture2D, mCurrentTexture);
+
+ SetGLInterpolation();
+
+ GL.EnableClientState(EnableCap.TextureCoordArray);
+ GL.EnableClientState(EnableCap.ColorArray);
+ GL.EnableClientState(EnableCap.VertexArray);
+ GL.EnableClientState(EnableCap.NormalArray);
+
+ int size = Marshal.SizeOf(typeof(PositionTextureColorNormal));
+ int tex = PositionTextureColorNormal.VertexLayout.ElementByteIndex(VertexElement.Texture);
+ int color = PositionTextureColorNormal.VertexLayout.ElementByteIndex(VertexElement.DiffuseColor);
+ int pos = PositionTextureColorNormal.VertexLayout.ElementByteIndex(VertexElement.Position);
+ int norm = PositionTextureColorNormal.VertexLayout.ElementByteIndex(VertexElement.Normal);
+
+ GL.TexCoordPointer(2, TexCoordPointerType.Float, size, (IntPtr) tex);
+ GL.ColorPointer(4, ColorPointerType.UnsignedByte, size, color);
+ GL.VertexPointer(2, VertexPointerType.Float, size, pos);
+ GL.NormalPointer(NormalPointerType.Float, size, (IntPtr)norm);
+
+ GL.DrawArrays(BeginMode.Quads, 0, mIndex);
+
+ mIndex = 0;
+ }
+
+ private void SetGLInterpolation()
+ {
+
+ switch (this.lastInterpolation)
+ {
+ case InterpolationMode.Fastest:
+ GL.TexParameter(TextureTarget.Texture2D,
+ TextureParameterName.TextureMinFilter,
+ (int)TextureMinFilter.Nearest);
+ GL.TexParameter(TextureTarget.Texture2D,
+ TextureParameterName.TextureMagFilter,
+ (int)TextureMagFilter.Nearest);
+
+ break;
+
+ case InterpolationMode.Default:
+ case InterpolationMode.Nicest:
+ GL.TexParameter(TextureTarget.Texture2D,
+ TextureParameterName.TextureMinFilter,
+ (int)TextureMinFilter.Linear);
+ GL.TexParameter(TextureTarget.Texture2D,
+ TextureParameterName.TextureMagFilter,
+ (int)TextureMagFilter.Linear);
+
+
+ break;
+ }
+ }
+ }
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ka...@us...> - 2009-11-24 07:06:37
|
Revision: 1118
http://agate.svn.sourceforge.net/agate/?rev=1118&view=rev
Author: kanato
Date: 2009-11-24 07:06:26 +0000 (Tue, 24 Nov 2009)
Log Message:
-----------
Remove old rendertarget code from SDX_Surface.
Modified Paths:
--------------
trunk/Drivers/AgateSDX/AgateSDX.csproj
trunk/Drivers/AgateSDX/SDX_Surface.cs
Removed Paths:
-------------
trunk/Drivers/AgateSDX/SDX_IRenderTarget.cs
Modified: trunk/Drivers/AgateSDX/AgateSDX.csproj
===================================================================
--- trunk/Drivers/AgateSDX/AgateSDX.csproj 2009-11-24 07:05:13 UTC (rev 1117)
+++ trunk/Drivers/AgateSDX/AgateSDX.csproj 2009-11-24 07:06:26 UTC (rev 1118)
@@ -136,9 +136,6 @@
<Compile Include="SDX_Input.cs">
<SubType>Code</SubType>
</Compile>
- <Compile Include="SDX_IRenderTarget.cs">
- <SubType>Code</SubType>
- </Compile>
<Compile Include="SDX_Surface.cs">
<SubType>Code</SubType>
</Compile>
Deleted: trunk/Drivers/AgateSDX/SDX_IRenderTarget.cs
===================================================================
--- trunk/Drivers/AgateSDX/SDX_IRenderTarget.cs 2009-11-24 07:05:13 UTC (rev 1117)
+++ trunk/Drivers/AgateSDX/SDX_IRenderTarget.cs 2009-11-24 07:06:26 UTC (rev 1118)
@@ -1,30 +0,0 @@
-// The contents of this file are subject to the Mozilla Public License
-// Version 1.1 (the "License"); you may not use this file except in
-// compliance with the License. You may obtain a copy of the License at
-// http://www.mozilla.org/MPL/
-//
-// Software distributed under the License is distributed on an "AS IS"
-// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
-// License for the specific language governing rights and limitations
-// under the License.
-//
-// The Original Code is AgateLib.
-//
-// The Initial Developer of the Original Code is Erik Ylvisaker.
-// Portions created by Erik Ylvisaker are Copyright (C) 2006-2009.
-// All Rights Reserved.
-//
-// Contributor(s): Erik Ylvisaker
-//
-using System;
-using System.Collections.Generic;
-using System.Text;
-using AgateLib.ImplementationBase;
-
-namespace AgateSDX
-{
- public interface SDX_IRenderTarget : IRenderTargetImpl
- {
- //SlimDX.Direct3D9.Surface RenderSurface { get; }
- }
-}
Modified: trunk/Drivers/AgateSDX/SDX_Surface.cs
===================================================================
--- trunk/Drivers/AgateSDX/SDX_Surface.cs 2009-11-24 07:05:13 UTC (rev 1117)
+++ trunk/Drivers/AgateSDX/SDX_Surface.cs 2009-11-24 07:06:26 UTC (rev 1118)
@@ -517,46 +517,6 @@
#endregion
- #region --- MDX1_IRenderTarget Members ---
-
- public void BeginRender()
- {
- // it looks like Direct3D creates a new surface.
- // so here we will create a new texture, and draw the current texture to it
- // then discard the old one.
- Texture t = new Texture(mDevice.Device, SurfaceWidth, SurfaceHeight, 1, Usage.None,
- Format.A8R8G8B8, Pool.Managed);
-
- Direct3D.Surface surfaceTarget = t.GetSurfaceLevel(0);
-
- mRenderToSurface = new RenderToSurface(mDevice.Device, SurfaceWidth, SurfaceHeight,
- Format.A8R8G8B8, mDisplay.DepthStencilFormat);
-
- Viewport vp = new Viewport();
-
- vp.X = 0;
- vp.Y = 0;
- vp.Width = SurfaceWidth;
- vp.Height = SurfaceHeight;
-
- mRenderToSurface.BeginScene(surfaceTarget, vp);
-
- Display.Clear();
-
- SurfaceState st = new SurfaceState();
- Draw(st);
-
- mTexture.Dispose();
- mTexture = new Ref<Texture>(t);
-
- }
- public void EndRender()
- {
- mRenderToSurface.EndScene(Filter.None);
- }
-
- #endregion
-
#region --- SubSurface stuff ---
public override SurfaceImpl CarveSubSurface(Rectangle srcRect)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ka...@us...> - 2009-11-24 07:05:27
|
Revision: 1117
http://agate.svn.sourceforge.net/agate/?rev=1117&view=rev
Author: kanato
Date: 2009-11-24 07:05:13 +0000 (Tue, 24 Nov 2009)
Log Message:
-----------
Implement FrameBuffer.
Modified Paths:
--------------
trunk/AgateLib/DisplayLib/Display.cs
trunk/AgateLib/DisplayLib/DisplayWindow.cs
trunk/AgateLib/DisplayLib/FrameBuffer.cs
trunk/AgateLib/DisplayLib/Surface.cs
trunk/AgateLib/Drivers/TypeID.cs
trunk/AgateLib/ImplementationBase/DisplayImpl.cs
trunk/AgateLib/ImplementationBase/DisplayWindowImpl.cs
trunk/AgateLib/ImplementationBase/FrameBufferImpl.cs
trunk/AgateLib/ImplementationBase/SurfaceImpl.cs
trunk/Drivers/AgateDrawing/AgateDrawing.csproj
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_Surface.cs
trunk/Drivers/AgateOTK/AgateOTK.csproj
trunk/Drivers/AgateOTK/GL_Display.cs
trunk/Drivers/AgateOTK/GL_DisplayControl.cs
trunk/Drivers/AgateOTK/GL_GameWindow.cs
trunk/Drivers/AgateOTK/GL_Surface.cs
trunk/Drivers/AgateSDX/AgateSDX.csproj
trunk/Drivers/AgateSDX/D3DDevice.cs
trunk/Drivers/AgateSDX/SDX_Display.cs
trunk/Drivers/AgateSDX/SDX_DisplayWindow.cs
trunk/Drivers/AgateSDX/SDX_FrameBuffer.cs
trunk/Drivers/AgateSDX/SDX_Surface.cs
trunk/Tests/DisplayTests/MultipleWindows/MultipleWindowTest.cs
trunk/Tests/DisplayTests/ScreenCapture.cs
Added Paths:
-----------
trunk/Drivers/AgateOTK/ContextFB.cs
trunk/Drivers/AgateOTK/GL3/
trunk/Drivers/AgateOTK/GL3/FrameBuffer.cs
trunk/Drivers/AgateOTK/GL_FrameBuffer.cs
trunk/Drivers/AgateOTK/Legacy/
trunk/Drivers/AgateOTK/Legacy/ArbShader.cs
trunk/Drivers/AgateOTK/Legacy/ArbShaderCompiler.cs
trunk/Drivers/AgateOTK/Legacy/FrameBufferExt.cs
trunk/Drivers/AgateOTK/Legacy/FrameBufferReadPixels.cs
trunk/Drivers/AgateOTK/Shaders/GlslFragmentProgram.cs
trunk/Drivers/AgateOTK/Shaders/GlslShader.cs
trunk/Drivers/AgateOTK/Shaders/GlslShaderCompiler.cs
trunk/Drivers/AgateOTK/Shaders/GlslVertexProgram.cs
trunk/Drivers/AgateOTK/Shaders/OtkShader.cs
trunk/Drivers/AgateSDX/FrameBufferSurface.cs
trunk/Drivers/AgateSDX/FrameBufferWindow.cs
Removed Paths:
-------------
trunk/Drivers/AgateDrawing/Drawing_IRenderTarget.cs
trunk/Drivers/AgateOTK/ArbShader.cs
trunk/Drivers/AgateOTK/ArbShaderCompiler.cs
trunk/Drivers/AgateOTK/GLState.cs
trunk/Drivers/AgateOTK/GL_FrameBuffer.cs
trunk/Drivers/AgateOTK/GL_IRenderTarget.cs
trunk/Drivers/AgateOTK/GlslFragmentProgram.cs
trunk/Drivers/AgateOTK/GlslShader.cs
trunk/Drivers/AgateOTK/GlslShaderCompiler.cs
trunk/Drivers/AgateOTK/GlslVertexProgram.cs
trunk/Drivers/AgateOTK/OtkShader.cs
Modified: trunk/AgateLib/DisplayLib/Display.cs
===================================================================
--- trunk/AgateLib/DisplayLib/Display.cs 2009-11-24 01:36:58 UTC (rev 1116)
+++ trunk/AgateLib/DisplayLib/Display.cs 2009-11-24 07:05:13 UTC (rev 1117)
@@ -189,7 +189,7 @@
/// Must be called outside of BeginFrame..EndFrame blocks
/// (usually just before BeginFrame).
/// </summary>
- public static IRenderTarget RenderTarget
+ public static FrameBuffer RenderTarget
{
get
{
@@ -202,17 +202,19 @@
impl.RenderTarget = value;
- if (value is DisplayWindow)
- mCurrentWindow = (DisplayWindow)value;
-
+ // TODO: replace this with an ActiveWindow property.
+ //if (value is DisplayWindow)
+ // mCurrentWindow = (DisplayWindow)value;
}
}
+
/// <summary>
/// Gets the last render target used which was a DisplayWindow.
/// </summary>
public static DisplayWindow CurrentWindow
{
get { return mCurrentWindow; }
+ internal set { mCurrentWindow = value; }
}
/// <summary>
Modified: trunk/AgateLib/DisplayLib/DisplayWindow.cs
===================================================================
--- trunk/AgateLib/DisplayLib/DisplayWindow.cs 2009-11-24 01:36:58 UTC (rev 1116)
+++ trunk/AgateLib/DisplayLib/DisplayWindow.cs 2009-11-24 07:05:13 UTC (rev 1117)
@@ -35,9 +35,10 @@
///
/// Alternatively, a control may be specified to render into.
/// </remarks>
- public sealed class DisplayWindow : IRenderTarget, IDisposable
+ public sealed class DisplayWindow : IDisposable
{
DisplayWindowImpl impl;
+ FrameBuffer frameBuffer;
/// <summary>
/// Constructs a DisplayWindow from a resource.
@@ -85,8 +86,11 @@
impl = Display.Impl.CreateDisplayWindow(windowParams);
- Display.RenderTarget = this;
+ Display.RenderTarget = FrameBuffer;
Display.DisposeDisplay += new Display.DisposeDisplayHandler(Dispose);
+
+ // TODO: Fix this hack
+ Display.CurrentWindow = this;
}
#region --- Static Creation Methods ---
@@ -169,6 +173,25 @@
#endregion
+ public FrameBuffer FrameBuffer
+ {
+ get
+ {
+ if (frameBuffer == null || frameBuffer.Impl != Impl.FrameBuffer)
+ {
+ frameBuffer = new FrameBuffer(Impl.FrameBuffer);
+ }
+
+ return frameBuffer;
+ }
+ }
+
+ [Obsolete]
+ public static implicit operator FrameBuffer(DisplayWindow wind)
+ {
+ return wind.FrameBuffer;
+ }
+
/// <summary>
/// Disposes of unmanaged resources.
/// </summary>
@@ -309,12 +332,6 @@
get { return Matrix4x4.Ortho(new RectangleF(0, 0, Width, Height), -1, 1); }
}
- #region --- IRenderTarget Members ---
-
- IRenderTargetImpl IRenderTarget.Impl
- {
- get { return impl; }
- }
/// <summary>
/// Event raised when the window is resized by the user.
/// </summary>
@@ -326,6 +343,5 @@
Resize(this, EventArgs.Empty);
}
- #endregion
}
}
\ No newline at end of file
Modified: trunk/AgateLib/DisplayLib/FrameBuffer.cs
===================================================================
--- trunk/AgateLib/DisplayLib/FrameBuffer.cs 2009-11-24 01:36:58 UTC (rev 1116)
+++ trunk/AgateLib/DisplayLib/FrameBuffer.cs 2009-11-24 07:05:13 UTC (rev 1117)
@@ -27,5 +27,48 @@
{
get { return impl; }
}
+
+ public Size Size
+ {
+ get { return Impl.Size; }
+ }
+ public int Height
+ {
+ get { return Impl.Height; }
+ }
+ public int Width
+ {
+ get { return Impl.Width; }
+ }
+
+ public void BeginRender()
+ {
+ }
+ public void EndRender()
+ { }
+
+ public bool CanAccessBackBuffer
+ {
+ get { return Impl.CanAccessBackBuffer; }
+ }
+
+ Surface mBackBuffer;
+
+ public Surface BackBuffer
+ {
+ get
+ {
+ if (mBackBuffer != null && mBackBuffer.Impl != Impl.BackBuffer)
+ {
+ mBackBuffer.Dispose();
+ mBackBuffer = null;
+ }
+
+ if (mBackBuffer == null)
+ mBackBuffer = new Surface(Impl.BackBuffer);
+
+ return mBackBuffer;
+ }
+ }
}
}
Modified: trunk/AgateLib/DisplayLib/Surface.cs
===================================================================
--- trunk/AgateLib/DisplayLib/Surface.cs 2009-11-24 01:36:58 UTC (rev 1116)
+++ trunk/AgateLib/DisplayLib/Surface.cs 2009-11-24 07:05:13 UTC (rev 1117)
@@ -88,7 +88,7 @@
/// </code>
/// </example>
/// </summary>
- public sealed class Surface : IRenderTarget, IDisposable, ISurface
+ public sealed class Surface : IDisposable, ISurface
{
SurfaceImpl impl;
SurfaceState mState = new SurfaceState();
@@ -232,37 +232,6 @@
#region --- Surface properties ---
/// <summary>
- /// Gets or sets how many times this surface should be broken down
- /// when drawn. A TesselateFactor of 2 indicates that each time
- /// this surface is drawn, it's drawn in 4 (2x2) chunks.
- /// </summary>
- /// <remarks>
- /// This property is used to divide a surface drawn up into smaller
- /// surfaces which are drawn independently. The reason to do this is
- /// lighting calculations (without using shaders) are done on a per-vertex
- /// basis. When a light source is close to a large surface, this will create
- /// noticably bad lighting, because only the lighting properties at the
- /// corners are calculated, and then the lighting is interpolated between
- /// the end points.
- /// <para>
- /// Changing this value while using gradients can result in ugly transitions between
- /// different tesselation values. The reason is AgateLib will interpolate the gradient
- /// color to the vertices used, and then this is capped to integer values. So avoid
- /// doing this.</para>
- /// <para>
- /// Setting this value high may have a significant impact on performance.
- /// For each time a Surface.Draw() overload is called, the number of triangles
- /// which are calculated and sent to the rasterizer is 2 * TesselateFactor<sup>2</sup>.
- /// </para>
- /// </remarks>
- ///
- [Obsolete("Use shaders for lighting effects.")]
- public int TesselateFactor
- {
- get { return impl.TesselateFactor; }
- set { impl.TesselateFactor = value; }
- }
- /// <summary>
/// Gets or sets a bool value that indicates whether or not this surface
/// should be included in a call to Display.PackAllSurfaces.
/// </summary>
@@ -900,48 +869,5 @@
{
get { return impl; }
}
-
- #region --- IRenderTarget Members ---
-
- IRenderTargetImpl IRenderTarget.Impl
- {
- get { return impl; }
- }
-
- Size IRenderTarget.Size
- {
- get { return SurfaceSize; }
- }
-
- EventHandler ResizeEventHandlers;
-
- event EventHandler IRenderTarget.Resize
- {
- add { ResizeEventHandlers += value; }
- remove { ResizeEventHandlers -= value; }
- }
-
- internal void OnResize()
- {
- if (ResizeEventHandlers != null)
- {
- ResizeEventHandlers(this, EventArgs.Empty);
- }
- }
-
-
- int IRenderTarget.Width
- {
- get { return SurfaceWidth; }
- }
-
- int IRenderTarget.Height
- {
- get { return SurfaceHeight; }
- }
-
- #endregion
-
-
}
}
Modified: trunk/AgateLib/Drivers/TypeID.cs
===================================================================
--- trunk/AgateLib/Drivers/TypeID.cs 2009-11-24 01:36:58 UTC (rev 1116)
+++ trunk/AgateLib/Drivers/TypeID.cs 2009-11-24 07:05:13 UTC (rev 1117)
@@ -43,12 +43,13 @@
AutoSelect = 0,
/// <summary>
- /// The reference driver is implemented using System.Drawing. This is useful for
+ /// The software System.Drawing driver. This is useful for
/// debugging the development of a new driver, as it should behave exactly like the
- /// reference driver (but hopefully be much faster).
+ /// reference driver for 2D drawing.
/// </summary>
+ Drawing = 1,
Reference = 1,
-
+
/// <summary>
/// Driver Implementation using SlimDX.
/// </summary>
@@ -72,8 +73,9 @@
/// <summary>
/// Driver implementation using SDL. SDL.NET does not support many of the basic features
- /// of this library (notably);}} rotation of images) so is not considered an adequate driver
- /// for general purpose use.
+ /// of this library (notably, rotation of images) so is not considered an adequate driver
+ /// for general purpose use. However it may be the only driver available for certain target
+ /// platforms.
/// </summary>
SDL = 0x300,
Modified: trunk/AgateLib/ImplementationBase/DisplayImpl.cs
===================================================================
--- trunk/AgateLib/ImplementationBase/DisplayImpl.cs 2009-11-24 01:36:58 UTC (rev 1116)
+++ trunk/AgateLib/ImplementationBase/DisplayImpl.cs 2009-11-24 07:05:13 UTC (rev 1117)
@@ -36,7 +36,7 @@
{
private double mAlphaThreshold = 5.0 / 255.0;
- private IRenderTarget mRenderTarget;
+ private FrameBuffer mRenderTarget;
public abstract bool Supports(DisplayBoolCaps caps);
public abstract Size CapsSize(DisplaySizeCaps displaySizeCaps);
@@ -48,7 +48,7 @@
/// <summary>
/// Gets or sets the current render target.
/// </summary>
- public IRenderTarget RenderTarget
+ public FrameBuffer RenderTarget
{
get
{
@@ -62,7 +62,7 @@
if (mInFrame)
throw new AgateException("Cannot change render target between BeginFrame and EndFrame");
- IRenderTarget old = mRenderTarget;
+ FrameBuffer old = mRenderTarget;
mRenderTarget = value;
OnRenderTargetChange(old);
@@ -78,7 +78,7 @@
/// Event raised when the current render target is changed.
/// </summary>
/// <param name="oldRenderTarget"></param>
- protected abstract void OnRenderTargetChange(IRenderTarget oldRenderTarget);
+ protected abstract void OnRenderTargetChange(FrameBuffer oldRenderTarget);
/// <summary>
/// Event raised when the render target is resized.
/// </summary>
Modified: trunk/AgateLib/ImplementationBase/DisplayWindowImpl.cs
===================================================================
--- trunk/AgateLib/ImplementationBase/DisplayWindowImpl.cs 2009-11-24 01:36:58 UTC (rev 1116)
+++ trunk/AgateLib/ImplementationBase/DisplayWindowImpl.cs 2009-11-24 07:05:13 UTC (rev 1117)
@@ -28,7 +28,7 @@
/// <summary>
/// Implementation of DisplayWindow class.
/// </summary>
- public abstract class DisplayWindowImpl : IRenderTargetImpl, IDisposable
+ public abstract class DisplayWindowImpl : IDisposable
{
/// <summary>
/// Disposes of unmanaged resources.
@@ -46,37 +46,12 @@
public abstract bool IsFullScreen { get; }
/// <summary>
- /// Toggles windowed/fullscreen.
- /// If this is unsupported, this method should silently return
- /// (do not throw an error).
+ /// Returns the frame buffer that is rendered to for rendering to this
+ /// window.
/// </summary>
- public void ToggleFullScreen()
- {
- if (IsFullScreen)
- SetWindowed();
- else
- SetFullScreen();
- }
+ public abstract FrameBufferImpl FrameBuffer { get; }
/// <summary>
- /// Toggles windowed/fullscreen.
- /// If this is unsupported, this method should silently return
- /// (do not throw an error).
- ///
- /// Attempts to match width, height and bpp as best as possible.
- /// </summary>
- /// <param name="width"></param>
- /// <param name="height"></param>
- /// <param name="bpp"></param>
- public void ToggleFullScreen(int width, int height, int bpp)
- {
- if (IsFullScreen)
- SetWindowed();
- else
- SetFullScreen(width, height, bpp);
- }
-
- /// <summary>
/// Sets the display to windowed. Does nothing if the display is already
/// windowed. The DisplayWindow retains the same height and width as the
/// previous full screen resolution.
@@ -134,21 +109,5 @@
/// </summary>
public abstract Point MousePosition { get; set; }
- #region --- IRenderTargetImpl Members ---
-
- /// <summary>
- /// Utility function which may be called by the DisplayImpl when
- /// rendering begins.
- /// </summary>
- public abstract void BeginRender();
- /// <summary>
- /// Utility function which may be called by the DisplayImpl when
- /// rendering is done.
- /// </summary>
- public abstract void EndRender();
-
- #endregion
-
}
-
}
\ No newline at end of file
Modified: trunk/AgateLib/ImplementationBase/FrameBufferImpl.cs
===================================================================
--- trunk/AgateLib/ImplementationBase/FrameBufferImpl.cs 2009-11-24 01:36:58 UTC (rev 1116)
+++ trunk/AgateLib/ImplementationBase/FrameBufferImpl.cs 2009-11-24 07:05:13 UTC (rev 1117)
@@ -8,9 +8,6 @@
{
public abstract class FrameBufferImpl : IDisposable
{
- bool mIsDisposed = false;
-
-
public abstract void Dispose();
public abstract Size Size { get; }
@@ -18,5 +15,16 @@
public int Width { get { return Size.Width; } }
public int Height { get { return Size.Height; } }
+ public abstract void BeginRender();
+ public abstract void EndRender();
+
+ public virtual bool CanAccessBackBuffer
+ {
+ get { return false; }
+ }
+ public virtual SurfaceImpl BackBuffer
+ {
+ get { throw new NotImplementedException(); }
+ }
}
}
Modified: trunk/AgateLib/ImplementationBase/SurfaceImpl.cs
===================================================================
--- trunk/AgateLib/ImplementationBase/SurfaceImpl.cs 2009-11-24 01:36:58 UTC (rev 1116)
+++ trunk/AgateLib/ImplementationBase/SurfaceImpl.cs 2009-11-24 07:05:13 UTC (rev 1117)
@@ -28,15 +28,13 @@
/// <summary>
/// Base class for implementing a Surface structure.
/// </summary>
- public abstract class SurfaceImpl : IRenderTargetImpl, IDisposable
+ public abstract class SurfaceImpl : IDisposable
{
#region --- Private Fields ---
private bool mIsDisposed = false;
private bool mShouldBePacked = true;
- private int mTesselate = 1;
-
#endregion
#region --- Creation / Destruction ---
@@ -135,19 +133,6 @@
set { mInterpolationHint = value; }
}
/// <summary>
- /// Gets or sets how many squares the surface should be broken into when drawn.
- /// </summary>
- public int TesselateFactor
- {
- get { return mTesselate; }
- set
- {
- if (value < 1) value = 1;
-
- mTesselate = value;
- }
- }
- /// <summary>
/// Returns true if Dispose() has been called on this surface.
/// </summary>
public bool IsDisposed
@@ -263,38 +248,5 @@
}
#endregion
-
-
-
- #region --- IRenderTargetImpl Members ---
-
- /// <summary>
- /// Utility function which can be called by BeginFrame to begin
- /// a render pass.
- /// </summary>
- public abstract void BeginRender();
- /// <summary>
- /// Utility function which can be called by EndFrame to end a render pass.
- /// </summary>
- public abstract void EndRender();
-
- Size IRenderTargetImpl.Size
- {
- get { return SurfaceSize; }
- }
-
- int IRenderTargetImpl.Width
- {
- get { return SurfaceWidth; }
- }
-
- int IRenderTargetImpl.Height
- {
- get { return SurfaceHeight; }
- }
-
- #endregion
-
};
-
}
Modified: trunk/Drivers/AgateDrawing/AgateDrawing.csproj
===================================================================
--- trunk/Drivers/AgateDrawing/AgateDrawing.csproj 2009-11-24 01:36:58 UTC (rev 1116)
+++ trunk/Drivers/AgateDrawing/AgateDrawing.csproj 2009-11-24 07:05:13 UTC (rev 1117)
@@ -96,9 +96,6 @@
<Compile Include="Drawing_FontSurface.cs">
<SubType>Code</SubType>
</Compile>
- <Compile Include="Drawing_IRenderTarget.cs">
- <SubType>Code</SubType>
- </Compile>
<Compile Include="Drawing_Reporter.cs">
<SubType>Code</SubType>
</Compile>
Modified: trunk/Drivers/AgateDrawing/Drawing_Display.cs
===================================================================
--- trunk/Drivers/AgateDrawing/Drawing_Display.cs 2009-11-24 01:36:58 UTC (rev 1116)
+++ trunk/Drivers/AgateDrawing/Drawing_Display.cs 2009-11-24 07:05:13 UTC (rev 1117)
@@ -43,7 +43,7 @@
#region --- Private variables ---
private Graphics mGraphics;
- private Drawing_IRenderTarget mRenderTarget;
+ private Drawing_FrameBuffer mRenderTarget;
private bool mInFrame = false;
@@ -51,7 +51,7 @@
#region --- Events and Event Handlers ---
- protected override void OnRenderTargetChange(IRenderTarget oldRenderTarget)
+ protected override void OnRenderTargetChange(FrameBuffer oldRenderTarget)
{
if (mInFrame)
throw new AgateException(
@@ -59,7 +59,7 @@
System.Diagnostics.Debug.Assert(mGraphics == null);
- mRenderTarget = RenderTarget.Impl as Drawing_IRenderTarget;
+ mRenderTarget = RenderTarget.Impl as Drawing_FrameBuffer;
OnRenderTargetResize();
}
@@ -206,14 +206,14 @@
protected override void OnBeginFrame()
{
- mGraphics = Graphics.FromImage(mRenderTarget.BackBuffer);
+ mGraphics = Graphics.FromImage(mRenderTarget.BackBufferBitmap);
}
protected override void OnEndFrame()
{
mGraphics.Dispose();
mGraphics = null;
- Drawing_IRenderTarget renderTarget = RenderTarget.Impl as Drawing_IRenderTarget;
+ Drawing_FrameBuffer renderTarget = RenderTarget.Impl as Drawing_FrameBuffer;
renderTarget.EndRender();
}
Modified: trunk/Drivers/AgateDrawing/Drawing_DisplayWindow.cs
===================================================================
--- trunk/Drivers/AgateDrawing/Drawing_DisplayWindow.cs 2009-11-24 01:36:58 UTC (rev 1116)
+++ trunk/Drivers/AgateDrawing/Drawing_DisplayWindow.cs 2009-11-24 07:05:13 UTC (rev 1117)
@@ -32,11 +32,12 @@
namespace AgateDrawing
{
- class Drawing_DisplayWindow : DisplayWindowImpl, Drawing_IRenderTarget
+ class Drawing_DisplayWindow : DisplayWindowImpl
{
Form frm;
Control mRenderTarget;
bool mIsClosed = false;
+ Drawing_FrameBuffer mFrameBuffer;
Icon mIcon;
Bitmap mBackBuffer;
@@ -75,12 +76,24 @@
// and create the back buffer
OnResize();
}
+
+ mFrameBuffer = new Drawing_FrameBuffer(mBackBuffer);
+ mFrameBuffer.EndRenderEvent += new EventHandler(mFrameBuffer_EndRenderEvent);
}
- public Drawing_DisplayWindow(Control renderTarget)
+
+ void mFrameBuffer_EndRenderEvent(object sender, EventArgs e)
{
+ Graphics g = RenderTarget.CreateGraphics();
+ g.DrawImage(BackBuffer, new Rectangle(new Point(0, 0), BackBuffer.Size));
+ g.Dispose();
}
+ public override FrameBufferImpl FrameBuffer
+ {
+ get { return mFrameBuffer; }
+ }
+
private void AttachEvents()
{
mRenderTarget.Resize += new EventHandler(frm_Resize);
@@ -280,19 +293,9 @@
get { return false; }
}
- public override void BeginRender()
- {
- }
- public override void EndRender()
- {
- Graphics g = RenderTarget.CreateGraphics();
- g.DrawImage(BackBuffer, new Rectangle(new Point(0, 0), BackBuffer.Size));
- g.Dispose();
- }
-
public override string Title
{
get
Modified: trunk/Drivers/AgateDrawing/Drawing_FontSurface.cs
===================================================================
--- trunk/Drivers/AgateDrawing/Drawing_FontSurface.cs 2009-11-24 01:36:58 UTC (rev 1116)
+++ trunk/Drivers/AgateDrawing/Drawing_FontSurface.cs 2009-11-24 07:05:13 UTC (rev 1117)
@@ -89,9 +89,8 @@
if (g == null)
{
+ g = Graphics.FromImage((disp.RenderTarget.Impl as Drawing_FrameBuffer).BackBufferBitmap);
- g = Graphics.FromImage((disp.RenderTarget.Impl as Drawing_IRenderTarget).BackBuffer);
-
disposeGraphics = true;
}
Modified: trunk/Drivers/AgateDrawing/Drawing_FrameBuffer.cs
===================================================================
--- trunk/Drivers/AgateDrawing/Drawing_FrameBuffer.cs 2009-11-24 01:36:58 UTC (rev 1116)
+++ trunk/Drivers/AgateDrawing/Drawing_FrameBuffer.cs 2009-11-24 07:05:13 UTC (rev 1117)
@@ -2,16 +2,25 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
+using System.Drawing;
using AgateLib.Geometry;
using AgateLib.ImplementationBase;
+using Size = AgateLib.Geometry.Size;
namespace AgateDrawing
{
class Drawing_FrameBuffer: FrameBufferImpl
{
+ Bitmap backBuffer;
+
public Drawing_FrameBuffer(Size size)
{
+ backBuffer = new Bitmap(size.Width, size.Height);
}
+ public Drawing_FrameBuffer(Bitmap bmp)
+ {
+ backBuffer = bmp;
+ }
public override void Dispose()
{
@@ -20,7 +29,35 @@
public override Size Size
{
- get { throw new NotImplementedException(); }
+ get { return AgateLib.WinForms.Interop.Convert(backBuffer.Size); }
}
+
+ public System.Drawing.Bitmap BackBufferBitmap
+ {
+ get { return backBuffer; }
+ }
+
+ public override void BeginRender()
+ {
+ }
+ public override void EndRender()
+ {
+ if (EndRenderEvent != null)
+ EndRenderEvent(this, EventArgs.Empty);
+ }
+ public override bool CanAccessBackBuffer
+ {
+ get
+ {
+ return true;
+ }
+ }
+ public override SurfaceImpl BackBuffer
+ {
+ get { return new Drawing_Surface(backBuffer, new System.Drawing.Rectangle(System.Drawing.Point.Empty, backBuffer.Size)); }
+ }
+
+
+ public event EventHandler EndRenderEvent;
}
}
Deleted: trunk/Drivers/AgateDrawing/Drawing_IRenderTarget.cs
===================================================================
--- trunk/Drivers/AgateDrawing/Drawing_IRenderTarget.cs 2009-11-24 01:36:58 UTC (rev 1116)
+++ trunk/Drivers/AgateDrawing/Drawing_IRenderTarget.cs 2009-11-24 07:05:13 UTC (rev 1117)
@@ -1,31 +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.Drawing;
-using System.Text;
-using AgateLib.ImplementationBase;
-
-namespace AgateDrawing
-{
- public interface Drawing_IRenderTarget : IRenderTargetImpl
- {
- Bitmap BackBuffer { get; }
- }
-}
Modified: trunk/Drivers/AgateDrawing/Drawing_Surface.cs
===================================================================
--- trunk/Drivers/AgateDrawing/Drawing_Surface.cs 2009-11-24 01:36:58 UTC (rev 1116)
+++ trunk/Drivers/AgateDrawing/Drawing_Surface.cs 2009-11-24 07:05:13 UTC (rev 1117)
@@ -34,7 +34,7 @@
namespace AgateDrawing
{
- class Drawing_Surface : SurfaceImpl, Drawing_IRenderTarget
+ class Drawing_Surface : SurfaceImpl
{
#region --- Private variables ---
@@ -330,23 +330,5 @@
}
#endregion
-
- #region --- Drawing_IRenderTarget Members ---
-
- public override void BeginRender()
- {
- }
-
- public override void EndRender()
- {
- }
-
- public Bitmap BackBuffer
- {
- get { return mImage; }
- }
-
- #endregion
-
}
}
\ No newline at end of file
Modified: trunk/Drivers/AgateOTK/AgateOTK.csproj
===================================================================
--- trunk/Drivers/AgateOTK/AgateOTK.csproj 2009-11-24 01:36:58 UTC (rev 1116)
+++ trunk/Drivers/AgateOTK/AgateOTK.csproj 2009-11-24 07:05:13 UTC (rev 1117)
@@ -107,12 +107,14 @@
<Compile Include="AL_Audio.cs">
<SubType>Code</SubType>
</Compile>
- <Compile Include="ArbShader.cs">
+ <Compile Include="GL3\FrameBuffer.cs" />
+ <Compile Include="Legacy\ArbShader.cs">
<SubType>Code</SubType>
</Compile>
- <Compile Include="ArbShaderCompiler.cs">
+ <Compile Include="Legacy\ArbShaderCompiler.cs">
<SubType>Code</SubType>
</Compile>
+ <Compile Include="ContextFB.cs" />
<Compile Include="frmFullScreen.cs">
<SubType>Form</SubType>
</Compile>
@@ -124,43 +126,39 @@
<Compile Include="GLDrawBuffer.cs">
<SubType>Code</SubType>
</Compile>
- <Compile Include="GlslFragmentProgram.cs">
+ <Compile Include="Shaders\GlslFragmentProgram.cs">
<SubType>Code</SubType>
</Compile>
- <Compile Include="GlslShader.cs">
+ <Compile Include="Shaders\GlslShader.cs">
<SubType>Code</SubType>
</Compile>
- <Compile Include="GlslShaderCompiler.cs">
+ <Compile Include="Shaders\GlslShaderCompiler.cs">
<SubType>Code</SubType>
</Compile>
- <Compile Include="GlslVertexProgram.cs">
+ <Compile Include="Shaders\GlslVertexProgram.cs">
<SubType>Code</SubType>
</Compile>
- <Compile Include="GLState.cs">
- <SubType>Code</SubType>
- </Compile>
<Compile Include="GL_Display.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="GL_DisplayControl.cs">
<SubType>Code</SubType>
</Compile>
+ <Compile Include="Legacy\FrameBufferExt.cs" />
<Compile Include="GL_GameWindow.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="GL_IndexBuffer.cs">
<SubType>Code</SubType>
</Compile>
- <Compile Include="GL_IRenderTarget.cs">
- <SubType>Code</SubType>
- </Compile>
<Compile Include="GL_Surface.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="GL_VertexBuffer.cs">
<SubType>Code</SubType>
</Compile>
- <Compile Include="OtkShader.cs">
+ <Compile Include="Legacy\FrameBufferReadPixels.cs" />
+ <Compile Include="Shaders\OtkShader.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Otk_Reporter.cs">
Deleted: trunk/Drivers/AgateOTK/ArbShader.cs
===================================================================
--- trunk/Drivers/AgateOTK/ArbShader.cs 2009-11-24 01:36:58 UTC (rev 1116)
+++ trunk/Drivers/AgateOTK/ArbShader.cs 2009-11-24 07:05:13 UTC (rev 1117)
@@ -1,65 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using AgateLib.DisplayLib.Shaders;
-using OpenTK.Graphics.OpenGL;
-
-namespace AgateOTK
-{
- class ArbShader : OtkShader
- {
- int programHandle;
- Dictionary<string, int> mUniforms = new Dictionary<string, int>();
-
- public ArbShader(int handle, GlslVertexProgram vert, GlslFragmentProgram frag)
- {
- programHandle = handle;
- this.vertex = vert;
- this.pixel = frag;
- }
-
- GlslVertexProgram vertex;
- GlslFragmentProgram pixel;
-
- public GlslFragmentProgram PixelShader
- {
- get { return pixel; }
- }
- public GlslVertexProgram VertexShader
- {
- get { return vertex; }
- }
-
- public override int Handle
- {
- get { return programHandle; }
- }
-
- private int GetUniformLocation(string name)
- {
- if (mUniforms.ContainsKey(name))
- return mUniforms[name];
-
- return GL.Arb.GetUniformLocation(programHandle, name);
- }
-
- public void SetUniform(string name, params float[] v)
- {
- int loc = GetUniformLocation(name);
-
- }
- public void SetUniform(string name, params int[] v)
- {
- }
-
- public void SetUniform(string name, AgateLib.Geometry.Matrix4x4 matrix)
- {
- }
-
- public void Render<T>(RenderHandler<T> handler, T obj)
- {
- throw new NotImplementedException();
- }
- }
-}
Deleted: trunk/Drivers/AgateOTK/ArbShaderCompiler.cs
===================================================================
--- trunk/Drivers/AgateOTK/ArbShaderCompiler.cs 2009-11-24 01:36:58 UTC (rev 1116)
+++ trunk/Drivers/AgateOTK/ArbShaderCompiler.cs 2009-11-24 07:05:13 UTC (rev 1117)
@@ -1,75 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using AgateLib.DisplayLib.Shaders;
-using AgateLib.ImplementationBase;
-using OpenTK.Graphics.OpenGL;
-
-namespace AgateOTK
-{
- class ArbShaderCompiler : ShaderCompilerImpl
- {
- public ArbShaderCompiler()
- {
- }
-
- public OtkShader CompileShader(ShaderLanguage language, string vertexShaderSource, string pixelShaderSource)
- {
- if (language != ShaderLanguage.Glsl)
- throw new NotSupportedException("AgateOTK can only compile and use GLSL shaders.");
-
- GlslVertexProgram vert = CompileVertexProgram(vertexShaderSource);
- GlslFragmentProgram frag = CompileFragmentProgram(pixelShaderSource);
-
- return LinkPrograms(vert, frag);
- }
-
- private OtkShader LinkPrograms(GlslVertexProgram vert, GlslFragmentProgram frag)
- {
- int program = GL.Arb.CreateProgramObject();
-
- GL.Arb.AttachObject(program, vert.ShaderHandle);
- GL.Arb.AttachObject(program, frag.ShaderHandle);
-
- GL.Arb.LinkProgram(program);
-
- return new ArbShader(program, vert, frag);
- }
-
- private GlslVertexProgram CompileVertexProgram(string vertexShaderSource)
- {
- return new GlslVertexProgram(CompileShader(ShaderType.VertexShader, vertexShaderSource), vertexShaderSource);
- }
-
- private GlslFragmentProgram CompileFragmentProgram(string pixelShaderSource)
- {
- return new GlslFragmentProgram(CompileShader(ShaderType.FragmentShader, pixelShaderSource), pixelShaderSource);
- }
-
- private int CompileShader(ShaderType type, string source)
- {
- int shaderHandle;
-
- if (type == ShaderType.VertexShader)
- shaderHandle = GL.Arb.CreateShaderObject((ArbShaderObjects)0x8B31);
- else
- shaderHandle = GL.Arb.CreateShaderObject((ArbShaderObjects)0x8B30);
-
- string[] src = new string[1] { source };
-
- unsafe
- {
- GL.Arb.ShaderSource(shaderHandle, 1, src, (int*)IntPtr.Zero);
- }
- GL.Arb.CompileShader(shaderHandle);
-
- return shaderHandle;
- }
-
- public override Effect CompileEffect(ShaderLanguage language, string effectSource)
- {
- throw new NotImplementedException();
- }
- }
-}
Added: trunk/Drivers/AgateOTK/ContextFB.cs
===================================================================
--- trunk/Drivers/AgateOTK/ContextFB.cs (rev 0)
+++ trunk/Drivers/AgateOTK/ContextFB.cs 2009-11-24 07:05:13 UTC (rev 1117)
@@ -0,0 +1,67 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using OpenTK.Graphics;
+using OpenTK.Graphics.OpenGL;
+using OpenTK.Platform;
+using AgateLib.Geometry;
+
+namespace AgateOTK
+{
+ class ContextFB : GL_FrameBuffer
+ {
+ IGraphicsContext mContext;
+ IWindowInfo mWindowInfo;
+ Size mSize;
+
+ public ContextFB(IGraphicsContext context, IWindowInfo window, Size size)
+ {
+ mContext = context;
+ mWindowInfo = window;
+ mSize = size;
+ }
+
+ public override void Dispose()
+ {
+ }
+
+ public override AgateLib.Geometry.Size Size
+ {
+ get { return mSize; }
+ }
+
+ public void SetSize(Size size)
+ {
+ mSize = size;
+ }
+
+
+ public override void MakeCurrent()
+ {
+ if (mContext.IsCurrent == false)
+ {
+ mContext.MakeCurrent(mWindowInfo);
+ }
+
+ GL.Viewport(0, 0, Width, Height);
+
+ }
+
+ public override void BeginRender()
+ {
+ MakeCurrent();
+
+ }
+
+ public override void EndRender()
+ {
+ bool vsync = AgateLib.DisplayLib.Display.RenderState.WaitForVerticalBlank;
+ if (mContext.VSync != vsync)
+ mContext.VSync = vsync;
+
+ mContext.SwapBuffers();
+ }
+
+ }
+}
Added: trunk/Drivers/AgateOTK/GL3/FrameBuffer.cs
===================================================================
--- trunk/Drivers/AgateOTK/GL3/FrameBuffer.cs (rev 0)
+++ trunk/Drivers/AgateOTK/GL3/FrameBuffer.cs 2009-11-24 07:05:13 UTC (rev 1117)
@@ -0,0 +1,96 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using AgateLib;
+using AgateLib.Geometry;
+using OpenTK.Graphics.OpenGL;
+using OTKPixelFormat = OpenTK.Graphics.OpenGL.PixelFormat;
+
+namespace AgateOTK.GL3
+{
+ class FrameBuffer : GL_FrameBuffer
+ {
+ Size mSize;
+ int mFramebufferID;
+ int mDepthBuffer;
+ GL_Surface mTexture;
+
+ public FrameBuffer(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.");
+ }
+
+ }
+
+ public override AgateLib.ImplementationBase.SurfaceImpl BackBuffer
+ {
+ 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);
+ }
+ }
+}
Deleted: trunk/Drivers/AgateOTK/GLState.cs
===================================================================
--- trunk/Drivers/AgateOTK/GLState.cs 2009-11-24 01:36:58 UTC (rev 1116)
+++ trunk/Drivers/AgateOTK/GLState.cs 2009-11-24 07:05:13 UTC (rev 1117)
@@ -1,54 +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.Runtime.InteropServices;
-using System.Text;
-
-using AgateLib;
-using AgateLib.Geometry;
-using AgateLib.DisplayLib;
-
-using OpenTK.Graphics.OpenGL;
-
-namespace AgateOTK
-{
- [Obsolete]
- class GLState
- {
- #region --- Private variables for state management ---
-
- private GLDrawBuffer mDrawBuffer;
-
- #endregion
-
- public GLState()
- {
- mDrawBuffer = new GLDrawBuffer();
- }
-
-
- public GLDrawBuffer DrawBuffer
- {
- get { return mDrawBuffer; }
- }
-
-
- }
-}
Modified: trunk/Drivers/AgateOTK/GL_Display.cs
===================================================================
--- trunk/Drivers/AgateOTK/GL_Display.cs 2009-11-24 01:36:58 UTC (rev 1116)
+++ trunk/Drivers/AgateOTK/GL_Display.cs 2009-11-24 07:05:13 UTC (rev 1117)
@@ -36,7 +36,7 @@
{
public sealed class GL_Display : DisplayImpl
{
- GL_IRenderTarget mRenderTarget;
+ GL_FrameBuffer mRenderTarget;
Stack<Rectangle> mClipRects = new Stack<Rectangle>();
Rectangle mCurrentClip = Rectangle.Empty;
private bool mVSync = true;
@@ -48,6 +48,8 @@
System.Windows.Forms.Form mFakeWindow;
DisplayWindow mFakeDisplayWindow;
+ bool mGL3;
+
public bool NonPowerOf2Textures
{
get { return mNonPowerOf2Textures; }
@@ -68,9 +70,9 @@
ProcessEventsEvent(this, EventArgs.Empty);
}
- protected override void OnRenderTargetChange(IRenderTarget oldRenderTarget)
+ protected override void OnRenderTargetChange(FrameBuffer oldRenderTarget)
{
- mRenderTarget = RenderTarget.Impl as GL_IRenderTarget;
+ mRenderTarget = RenderTarget.Impl as GL_FrameBuffer;
mRenderTarget.MakeCurrent();
OnRenderTargetResize();
@@ -136,7 +138,19 @@
protected override FrameBufferImpl CreateFrameBuffer(Size size)
{
- return new GL_FrameBufferExt(size);
+ if (mSupportsFramebuffer)
+ {
+ if (mGL3)
+ {
+ return new GL3.FrameBuffer(size);
+ }
+ else
+ {
+ return new Legacy.FrameBufferExt(size);
+ }
+ }
+ else
+ return new Legacy.FrameBufferReadPixels(size);
}
internal void SetupGLOrtho(Rectangle ortho)
@@ -165,14 +179,9 @@
FlushDeleteQueue();
}
- [Obsolete("Use DrawBuffer instead.", true)]
- internal GLState State
- {
- get { throw new NotImplementedException(); }
- }
internal GLDrawBuffer DrawBuffer
{
- get { return (RenderTarget.Impl as GL_IRenderTarget).DrawBuffer; }
+ get { return (RenderTarget.Impl as GL_FrameBuffer).DrawBuffer; }
}
@@ -354,6 +363,7 @@
mSupportsFramebuffer = true;
mNonPowerOf2Textures = true;
mSupportsShaders = true;
+ mGL3 = true;
}
if (mGLVersion >= 2m)
{
@@ -528,7 +538,7 @@
if (Display.CurrentWindow != null)
{
DisplayWindowImpl impl = Display.CurrentWindow.Impl;
- ((GL_IRenderTarget)impl).HideCursor();
+ //((GL_DisplayW)impl).HideCursor();
}
}
protected override void ShowCursor()
@@ -538,7 +548,8 @@
if (Display.CurrentWindow != null)
{
DisplayWindowImpl impl = Display.CurrentWindow.Impl;
- ((GL_IRenderTarget)impl).ShowCursor();
+
+ //((GL_FrameBufferExt)impl).ShowCursor();
}
}
Modified: trunk/Drivers/AgateOTK/GL_DisplayControl.cs
===================================================================
--- trunk/Drivers/AgateOTK/GL_DisplayControl.cs 2009-11-24 01:36:58 UTC (rev 1116)
+++ trunk/Drivers/AgateOTK/GL_DisplayControl.cs 2009-11-24 07:05:13 UTC (rev 1117)
@@ -39,7 +39,7 @@
namespace AgateOTK
{
- public sealed class GL_DisplayControl : DisplayWindowImpl, GL_IRenderTarget
+ public sealed class GL_DisplayControl : DisplayWindowImpl
{
Form frm;
Control mRenderTarget;
@@ -60,13 +60,13 @@
WindowPosition mChoosePosition;
bool mHasFrame = true;
- GLDrawBuffer mDrawBuffer;
- public GLDrawBuffer DrawBuffer
+ ContextFB mFrameBuffer;
+
+ public override FrameBufferImpl FrameBuffer
{
- get { return mDrawBuffer; }
+ get { return mFrameBuffer; }
}
-
public GL_DisplayControl(CreateWindowParams windowParams)
{
mChoosePosition = windowParams.WindowPosition;
@@ -116,8 +116,6 @@
mDisplay.ProcessEventsEvent += new EventHandler(mDisplay_ProcessEventsEvent);
mDisplay.InitializeCurrentContext();
-
- mDrawBuffer = new GLDrawBuffer();
}
void mDisplay_ProcessEventsEvent(object sender, EventArgs e)
@@ -223,6 +221,7 @@
mContext.MakeCurrent(mWindowInfo);
(mContext as IGraphicsContextInternal).LoadAll();
+ mFrameBuffer = new ContextFB(mContext, mWindowInfo, this.Size);
}
private IWindowInfo CreateWindowInfo(GraphicsMode mode)
@@ -542,7 +541,7 @@
}
- public override void BeginRender()
+ public void BeginRender()
{
MakeCurrent();
@@ -550,7 +549,7 @@
}
- public override void EndRender()
+ public void EndRender()
{
if (mContext.VSync != Display.RenderState.WaitForVerticalBlank)
mContext.VSync = Display.RenderState.WaitForVerticalBlank;
Deleted: trunk/Drivers/AgateOTK/GL_FrameBuffer.cs
===================================================================
--- trunk/Drivers/AgateOTK/GL_FrameBuffer.cs 2009-11-24 01:36:58 UTC (rev 1116)
+++ trunk/Drivers/AgateOTK/GL_FrameBuffer.cs 2009-11-24 07:05:13 UTC (rev 1117)
@@ -1,26 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using AgateLib.Geometry;
-using AgateLib.ImplementationBase;
-
-namespace AgateOTK
-{
- class GL_FrameBufferExt: FrameBufferImpl
- {
- public GL_FrameBufferExt(Size size)
- {
- }
-
- public override void Dispose()
- {
- throw new NotImplementedException();
- }
-
- public override Size Size
- {
- get { throw new NotImplementedException(); }
- }
- }
-}
Added: trunk/Drivers/AgateOTK/GL_FrameBuffer.cs
===================================================================
--- trunk/Drivers/AgateOTK/GL_FrameBuffer.cs (rev 0)
+++ trunk/Drivers/AgateOTK/GL_FrameBuffer.cs 2009-11-24 07:05:13 UTC (rev 1117)
@@ -0,0 +1,24 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using AgateLib.Geometry;
+using AgateLib.ImplementationBase;
+
+namespace AgateOTK
+{
+ abstract class GL_FrameBuffer: FrameBufferImpl
+ {
+ GLDrawBuffer mDrawBuffer = new GLDrawBuffer();
+
+ public GLDrawBuffer DrawBuffer { get { return mDrawBuffer; } }
+ public abstract void MakeCurrent();
+
+ // TODO: fix this hack and remove these interface members.
+ [Obsolete]
+ public void HideCursor() { throw new NotImplementedException(); }
+ [Obsolete]
+ public void ShowCursor() { throw new NotImplementedException(); }
+
+ }
+}
Modified: trunk/Drivers/AgateOTK/GL_GameWindow.cs
===================================================================
--- trunk/Drivers/AgateOTK/GL_GameWindow.cs 2009-11-24 01:36:58 UTC (rev 1116)
+++ trunk/Drivers/AgateOTK/GL_GameWindow.cs 2009-11-24 07:05:13 UTC (rev 1117)
@@ -34,7 +34,7 @@
{
using AgateLib.DisplayLib;
- class GL_GameWindow : DisplayWindowImpl, GL_IRenderTarget
+ class GL_GameWindow : DisplayWindowImpl
{
static Dictionary<OpenTK.Input.Key, KeyCode> keyMap = new Dictionary<OpenTK.Input.Key, KeyCode>();
@@ -173,6 +173,7 @@
bool mHasFrame;
WindowPosition mCreatePosition;
GLDrawBuffer mDrawBuffer;
+ GL_FrameBuffer mFrameBuffer;
public GL_GameWindow(CreateWindowParams windowParams)
{
@@ -203,6 +204,11 @@
mDrawBuffer = new GLDrawBuffer();
}
+ public override FrameBufferImpl FrameBuffer
+ {
+ get { return mFrameBuffer; }
+ }
+
public GLDrawBuffer DrawBuffer
{
get { return mDrawBuffer; }
@@ -438,7 +444,7 @@
}
}
- public override void BeginRender()
+ public void BeginRender()
{
if (mWindow.Context.VSync != Display.RenderState.WaitForVerticalBlank)
mWindow.Context.VSync = Display.RenderState.WaitForVerticalBlank;
@@ -449,7 +455,7 @@
}
- public override void EndRender()
+ public void EndRender()
{
mWindow.SwapBuffers();
}
Deleted: trunk/Drivers/AgateOTK/GL_IRenderTarget.cs
===================================================================
--- trunk/Drivers/AgateOTK/GL_IRenderTarget.cs 2009-11-24 01:36:58 UTC (rev 1116)
+++ trunk/Drivers/AgateOTK/GL_IRenderTarget.cs 2009-11-24 07:05:13 UTC (rev 1117)
@@ -1,37 +0,0 @@
-// The contents of this file are subject to the Mozilla Public License
-// Version 1.1 (the "License"); you may not use this file except in
-// compliance with the License. You may obtain a copy of the License at
-// http://www.mozilla.org/MPL/
-//
-// Software distributed under the License is distributed on an "AS IS"
-// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
-// License for the specific language governing rights and limitations
-// under the License.
-//
-// The Original Code is AgateLib.
-//
-// The Initial Developer of the Original Code is Erik Ylvisaker.
-// Portions created by Erik Ylvisaker are Copyright (C) 2006-2009.
-// All Rights Reserved.
-//
-// Contributor(s): Erik Ylvisaker
-//
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-using AgateLib.ImplementationBase;
-
-namespace AgateOTK
-{
- interface GL_IRenderTarget : IRenderTargetImpl
- {
- void MakeCurrent();
-
- // TODO: fix this hack and remove these interface members.
- void HideCursor();
- void ShowCursor();
-
- GLDrawBuffer DrawBuffer { get; }
- }
-}
Modified: trunk/Drivers/AgateOTK/GL_Surface.cs
===================================================================
--- trunk/Drivers/AgateOTK/GL_Surface.cs 2009-11-24 01:36:58 UTC (rev 1116)
+++ trunk/Drivers/AgateOTK/GL_Surface.cs 2009-11-24 07:05:13 UTC (rev 1117)
@@ -39,7 +39,7 @@
namespace AgateOTK
{
- public sealed class GL_Surface : SurfaceImpl, GL_IRenderTarget
+ public sealed class GL_Surface : SurfaceImpl
{
GL_Display mDisplay;
GLDrawBuffer mDrawBuffer;
@@ -52,9 +52,6 @@
static Dictionary<int, int> mTextureIDs = new Dictionary<int, int>();
int mTextureID;
- // Render to texture fields
- int mFramebufferID;
- int mDepthBuffer;
Rectangle mSourceRect;
@@ -65,13 +62,7 @@
TextureCoordinates mTexCoord;
- GLDrawBuffer mInternalDrawBuffer;
- GLDrawBuffer GL_IRenderTarget.DrawBuffer
- {
- get { return mInternalDrawBuffer; }
- }
-
public GL_Surface(string filename)
{
mDisplay = Display.Impl as GL_Display;
@@ -216,51 +207,9 @@
mDrawBuffer.SetInterpolationMode(InterpolationHint);
- if (TesselateFactor == 1)
- {
- BufferQuad(destX, destY, rotationCenter.X, rotationCenter.Y,
- dispSize.Width, dispSize.Height, mTexCoord, state.ColorGradient,
- state.DisplayAlignment, mRotationCos, mRotationSin);
- }
- else
- {
- TextureCoordinates texCoord = new TextureCoordinates();
- float texWidth = mTexCoord.Right - mTexCoord.Left;
- float texHeight = mTexCoord.Bottom - mTexCoord.Top;
-
- float _displayWidth = displaySize.Width / (float)TesselateFactor;
- float _displayHeight = displaySize.Height / (float)TesselateFactor;
-
- for (int j = 0; j < TesselateFactor; j++)
- {
- texCoord.Top = mTexCoord.Top + j * texHeight / TesselateFactor;
- texCoord.Bottom = mTexCoord.Top + (j + 1) * texHeight / TesselateFactor;
-
- for (int i = 0; i < TesselateFactor; i++)
- {
- texCoord.Left = mTexCoord.Left + i * texWidth / TesselateFactor;
- texCoord.Right = mTexCoord.Left + (i + 1) * texWidth / TesselateFactor;
-
- float dx = destX + i * _displayWidth * mRotationCos + j * _displayHeight * mRotationSin;
- float dy = destY - i * _displayWidth * mRotationSin + j * _displayHeight * mRotationCos;
-
- double cx = i / (double)TesselateFactor;
- double cy = j / (double)TesselateFactor;
-
- Gradient color = new Gradient(
- state.ColorGradient.Interpolate(cx, cy),
- state.ColorGradient.Interpolate(cx + 1.0 / TesselateFactor, cy),
- state.ColorGradient.Interpolate(cx, cy + 1.0 / TesselateFactor),
- state.ColorGradient.Interpolate(cx + 1.0 / TesselateFactor, cy + 1.0 / TesselateFactor));
-
- BufferQuad(dx, dy,
- rotationCenter.X, rotationCenter.Y,
- _displayWidth, _displayHeight, texCoord, color,
- state.DisplayAlignment, mRotationCos, mRotationSin);
-
- }
- }
- }
+ BufferQuad(destX, destY, rotationCenter.X, rotationCenter.Y,
+ dispSize.Width, dispSize.Height, mTexCoord, state.ColorGradient,
+ state.DisplayAlignment, mRotationCos, mRotationSin);
}
PointF[] cachePt = new PointF[4];
@@ -426,76 +375,25 @@
get { return mSourceRect.Size; }
}
- public override void BeginRender()
+ public void BeginRender()
{
- if (mInternalDrawBuffer == null)
- mInternalDrawBuffer = new GLDrawBuffer();
-
GL.Viewport(0, 0, SurfaceWidth, SurfaceHeight);
mDisplay.SetupGLOrtho(Rectangle.FromLTRB(0, SurfaceHeight, SurfaceWidth, 0));
if (mDisplay.SupportsFramebuffer)
{
- // generate the frame buffer
- GL.Ext.GenFramebuffers(1, out mFramebufferID);
- GL.Ext.BindFramebuffer(FramebufferTarget.FramebufferExt, mFramebufferID);
+
- // generate a depth buffer to render to
- GL.Ext.GenRenderbuffers(1, out mDepthBuffer);
- GL.Ext.BindRenderbuffer(RenderbufferTarget.RenderbufferExt, mDepthBuffer);
-
- // hack here because RenderbufferStorage enum is incomplete.
- GL.Ext.RenderbufferStorage(RenderbufferTarget.RenderbufferExt,
- (RenderbufferStorage)OTKPixelFormat.DepthComponent,
- mTextureSize.Width, mTextureSize.Height);
-
- // attach the depth buffer
- GL.Ext.FramebufferRenderbuffer(FramebufferTarget.FramebufferExt,
- FramebufferAttachment.DepthAttachmentExt, RenderbufferTarget.RenderbufferExt,
- mDepthBuffer);
-
- // attach the texture
- GL.Ext.FramebufferTexture2D(FramebufferTarget.FramebufferExt,
- FramebufferAttachment.ColorAttachment0Ext, TextureTarget.Texture2D,
- mTextureID, 0);
-
- FramebufferErrorCode code =
- GL.Ext.CheckFramebufferStatus(FramebufferTarget.FramebufferExt);
-
- if (code != FramebufferErrorCode.FramebufferCompleteExt)
- {
- throw new AgateException(
- "Could not complete framebuffer object.");
- }
-
- GL.Ext.BindFramebuffer(FramebufferTarget.FramebufferExt, mFramebufferID);
- GL.PushAttrib(AttribMask.ViewportBit);
-
}
else
{
// clear the framebuffer and draw this texture to it.
- GL.ClearColor(0, 0, 0, 0);
- GL.Clear(ClearBufferMask.ColorBufferBit |
- ClearBufferMask.DepthBufferBit);
- GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter,
- (int)TextureMinFilter.Linear);
- GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter,
- (int)TextureMagFilter.Linear);
-
- SurfaceState s = new SurfaceState();
- Draw(s);
-
- GL.TexParameter(TextureTarget.Texture2D,
- TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Linear);
- GL.TexParameter(TextureTarget.Texture2D,
- TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear);
}
}
- public override void EndRender()
+ public void EndRender()
{
if (mDisplay.SupportsFramebuffer)
{
@@ -509,17 +407,7 @@
}
else
{
- mDrawBuffer.ResetTexture();
-
- GL.BindTexture(TextureTarget.Texture2D, mTextureID);
-
- GL.CopyTexSubImage2D(TextureTarget.Texture2D,
- 0, 0, 0, 0, 0, mSourceRect.Width, mSourceRect.Height);
-
- GL.TexParameter(TextureTarget.Texture2D,
- TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Linear);
- GL.TexParameter(TextureTarget.Texture2D,
- TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear);
+
}
}
@@ -648,16 +536,5 @@
return coords;
}
- #region GL_IRenderTarget Members
-
- void GL_IRenderTarget.HideCursor()
- {
- }
- void GL_IRenderTarget.ShowCursor()
- {
- }
-
- #endregion
-
}
}
Deleted: trunk/Drivers/AgateOTK/GlslFragmentProgram.cs
===================================================================
--- trunk/Drivers/AgateOTK/GlslFragmentProgram.cs 2009-11-24 01:36:58 UTC (rev 1116)
+++ trunk/Drivers/AgateOTK/GlslFragmentProgram.cs 2009-11-24 07:05:13 UTC (rev 1117)
@@ -1,25 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using AgateLib.DisplayLib.Shaders;
-
-namespace AgateOTK
-{
- class GlslFragmentProgram
- {
- int index;
-
- public GlslFragmentProgram(int index, string source)
- {
- this.index = index;
- this.Source = source;
- }
-
- public string Source { get; private set; }
- public int ShaderHandle
- {
- get { return index; }
- }
- }
-}
\ No newline at end of file
Deleted: trunk/Drivers/AgateOTK/GlslShader.cs
===================================================================
--- trunk/Drivers/AgateOTK/GlslShader.cs 2009-11-24 01:36:58 UTC (rev 1116)
+++ trunk/Drivers/AgateOTK/GlslShader.cs 2009-11-24 07:05:13 UTC (rev 1117)
@@ -1,252 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using AgateLib.DisplayLib.Shaders;
-using OpenTK.Graphics.OpenGL;
-
-namespace AgateOTK
-{
- class GlslShader : OtkShader
- {
- struct UniformInfo
- {
- public string Name;
- public int Location;
- public ActiveUniformType Type;
- public int Size;
-
- public override string ToString()
- {
- return "Uniform: " + Name + " | " + Type.ToString();
- }
- }
- struct AttributeInfo
- {
- public string Name;
- public int Location;
- public ActiveAttribType Type;
- public int Size;
-
- public override string ToString()
- {
- return "Uniform: " + Name + " | " + Type.ToString();
- }
- }
-
- List<UniformInfo> mUniforms = new List<UniformInfo>();
- List<AttributeInfo> mAttributes = new List<AttributeInfo>();
- List<string> mAttributeNames;
-
- List<string> mSampler2DUniforms = new List<string>();
- int programHandle;
-
- GlslVertexProgram vertex;
- GlslFragmentProgram pixel;
-
- public GlslShader(int handle, GlslVertexProgram vert, GlslFragmentProgram frag)
- {
- programHandle = handle;
- this.vertex = vert;
- this.pixel = frag;
-
- LoadUniforms();
- LoadAttributes();
- }
-
- private void LoadAttributes()
- {
- int count;
- GL.GetProgram(programHandle, ProgramParameter.ActiveAttributes, out count);
-
- StringBuilder b = new StringBuilder(1000);
- for (int i = 0; i < count; i++)
- {
- int length;
- int size;
- ActiveAttribType type;
- string name;
- GL.GetActiveAttrib(programHandle, i, 1000, out length, out size, out type, b);
- name = b.ToString();
-
- int loc = GL.GetAttribLocation(programHandle, name);
-
- // ignore active attributes that we aren't interested in because we don't set them
- // with glVertexAttribPointer
- if (loc == -1)
- continue;
-
- AttributeInfo info = new AttributeInfo();
-
- info.Name = name;
- info.Location = loc;
- info.Type = type;
- info.Size = size;
-
- mAttributes.Add(info);
- }
-
- mAttributeNames = mAttributes.Select(x => x.Name).ToList();
- }
- private void LoadUniforms()
- {
- int count;
- GL.GetProgram(programHandle, ProgramParameter.ActiveUniforms, out count);
-
- StringBuilder b = new StringBuilder(1000);
- for (int i = 0; i < count; i++)
- {
- int length;
- int size;
- ActiveUniformType type;
- string name;
- GL.GetActiveUniform(programHandle, i, 1000, out length, out size, out type, b);
- name = b.ToString();
-
- // Apparently OpenGL reports not just user uniforms, but also built-in uniforms
- // that are determined "active" and accessible in program execution. Built-in uniforms
- // won't return a location because they cannot be directly modified by the OpenGL client.
- int loc = GL.GetUniformLocation(programHandle, name);
- if (loc == -1)
- continue;
-
- UniformInfo info = new UniformInfo();
-
- info.Name = name;
- info.Location = loc;
- info.Type = type;
- info.Size = size;
-
- mUniforms.Add(info);
- }
-
- mSampler2DUniforms = mUniforms
- .Where(x => x.Type == ActiveUniformType.Sampler2D)
- .Select(x => x.Name)
- .ToList();
- }
-
- public IList<string> Attributes
- {
- get { return mAttributeNames; }
- }
-
- public IList<string> Sampler2DUniforms
- {
- get
- {
- return mSampler2DUniforms;
- }
- }
-
- public GlslFragmentProgram PixelShader
- {
- get { return pixel; }
- }
- public GlslVertexProgram VertexShader
- {
- get { return vertex; }
- }
-
- public override int Handle
- {
- get { return programHandle; }
- }
-
- private int GetUniformLocation(string name)
- {
- if (mUniforms.Any(x => x.Name == name))
- return mUniforms.First(x => x.Name == name).Location;
-
- int loc = GL.GetUniformLocation(programHandle, name);
-
- if (loc != -1)
- return loc;
- else
- throw new AgateLib.AgateException("Could not find uniform {0} in the GLSL program.", name);
- }
- internal int GetAttribLocation(string name)
- {
- if (mAttributes.Any(x => x.Name == name))
- return mAttributes.First(x => x.Name == name).Location;
-
- int loc = GL.GetAttribLocation(programHandle, name);
-
- if (loc != -1)
- return loc;
- else
- throw new AgateLib.AgateException("Could not find uniform {0} in the GLSL program.", name);
- }
-
- public void SetUniform(string name, params float[] v)
- {
- int loc = GetUniformLocation(name);
-
- switch (v.Length)
- {
- case 0: throw new AgateLib.AgateException("A value for the uniform must be specified.");
- case 1:
- GL.Uniform1(loc, v[0]);
- break;
-
- case 2:
- GL.Uniform2(loc, v[0], v[1]);
- break;
-
- case 3:
- GL.Uniform3(loc, v[0], v[1], v[2]);
- break;
-
- case 4:
- GL.Uniform4(loc, v[0], v[1], v[2], v[3]);
- break;
-
- default:
- throw new AgateLib.AgateException("Too many parameters to SetUniform.");
- }
- }
- public void SetUniform(string name, params int[] v)
- {
- int loc = GetUniformLocation(name);
-
- switch (v.Length)
- {
- case 0: throw new AgateLib.AgateException("Must specify a value.");
- case 1:
- GL.Uniform1(loc, v[0]);
- break;
-
- case 2:
- GL.Uniform2(loc, v[0], v[1]);
- break;
-
- case 3:
- GL.Uniform3(loc, v[0], v[1], v[2]);
- break;
-
- case 4:
- GL.Uniform4(loc, v[0], v[1], v[2], v[3]);
- break;
-
- default:
- throw new AgateLib.AgateException("Too many parameters to SetUniform.");
- }
- }
-
- public void SetUniform(string name, AgateLib.Geometry.Matrix4x4 matrix)
- {
- int loc = GetUniformLocation(name);
-
- unsafe
- {
- GL.UniformMatrix4(loc, 16, true, (float*)&matrix);
- }
- }
-
-
- pub...
[truncated message content] |
|
From: <ka...@us...> - 2009-11-24 01:37:12
|
Revision: 1116
http://agate.svn.sourceforge.net/agate/?rev=1116&view=rev
Author: kanato
Date: 2009-11-24 01:36:58 +0000 (Tue, 24 Nov 2009)
Log Message:
-----------
Initial FrameBuffer stubs.
Remove OpenTK.Compatibility.dll finally.
Modified Paths:
--------------
trunk/AgateLib/AgateLib.csproj
trunk/AgateLib/ImplementationBase/DisplayImpl.cs
trunk/Drivers/AgateDrawing/AgateDrawing.csproj
trunk/Drivers/AgateDrawing/Drawing_Display.cs
trunk/Drivers/AgateOTK/AgateOTK.csproj
trunk/Drivers/AgateOTK/GL_Display.cs
trunk/Drivers/AgateSDX/AgateSDX.csproj
trunk/Drivers/AgateSDX/SDX_Display.cs
Added Paths:
-----------
trunk/AgateLib/DisplayLib/FrameBuffer.cs
trunk/AgateLib/ImplementationBase/FrameBufferImpl.cs
trunk/Drivers/AgateDrawing/Drawing_FrameBuffer.cs
trunk/Drivers/AgateOTK/GL_FrameBuffer.cs
trunk/Drivers/AgateSDX/SDX_FrameBuffer.cs
Removed Paths:
-------------
trunk/Drivers/AgateOTK/OpenTK.Compatibility.dll
trunk/Drivers/AgateOTK/OpenTK.Compatibility.dll.config
trunk/Drivers/AgateOTK/OpenTK.Compatibility.xml
Modified: trunk/AgateLib/AgateLib.csproj
===================================================================
--- trunk/AgateLib/AgateLib.csproj 2009-11-23 23:22:24 UTC (rev 1115)
+++ trunk/AgateLib/AgateLib.csproj 2009-11-24 01:36:58 UTC (rev 1116)
@@ -97,6 +97,7 @@
<Compile Include="Core.cs">
<SubType>Code</SubType>
</Compile>
+ <Compile Include="DisplayLib\FrameBuffer.cs" />
<Compile Include="DisplayLib\Shaders\AgateBuiltInShaders.cs" />
<Compile Include="DisplayLib\Shaders\Basic2DShader.cs" />
<Compile Include="DisplayLib\Shaders\AgateShader.cs" />
@@ -112,6 +113,7 @@
<Compile Include="IFileProvider.cs">
<SubType>Code</SubType>
</Compile>
+ <Compile Include="ImplementationBase\FrameBufferImpl.cs" />
<Compile Include="Platform.cs" />
<Compile Include="PlatformType.cs" />
<Compile Include="Timing.cs">
Added: trunk/AgateLib/DisplayLib/FrameBuffer.cs
===================================================================
--- trunk/AgateLib/DisplayLib/FrameBuffer.cs (rev 0)
+++ trunk/AgateLib/DisplayLib/FrameBuffer.cs 2009-11-24 01:36:58 UTC (rev 1116)
@@ -0,0 +1,31 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using AgateLib.Geometry;
+using AgateLib.ImplementationBase;
+
+namespace AgateLib.DisplayLib
+{
+ public class FrameBuffer
+ {
+ FrameBufferImpl impl;
+
+ public FrameBuffer(Size size)
+ {
+ impl = Display.Impl.CreateFrameBuffer(size);
+ }
+ public FrameBuffer(int width, int height)
+ : this(new Size(width, height))
+ { }
+ public FrameBuffer(FrameBufferImpl impl)
+ {
+ this.impl = impl;
+ }
+
+ public FrameBufferImpl Impl
+ {
+ get { return impl; }
+ }
+ }
+}
Modified: trunk/AgateLib/ImplementationBase/DisplayImpl.cs
===================================================================
--- trunk/AgateLib/ImplementationBase/DisplayImpl.cs 2009-11-23 23:22:24 UTC (rev 1115)
+++ trunk/AgateLib/ImplementationBase/DisplayImpl.cs 2009-11-24 01:36:58 UTC (rev 1116)
@@ -597,7 +597,23 @@
throw new AgateException("Cannot create an index buffer with a driver that does not support 3D.");
}
+
/// <summary>
+ /// Creates one of the build in shaders in AgateLib. Implementers should
+ /// 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>
+ /// <returns></returns>
+ protected internal abstract AgateShaderImpl CreateBuiltInShader(AgateLib.DisplayLib.Shaders.Implementation.BuiltInShader BuiltInShaderType);
+
+ /// <summary>
+ /// Creates a
+ /// </summary>
+ /// <param name="size"></param>
+ protected internal abstract FrameBufferImpl CreateFrameBuffer(Size size);
+
+ /// <summary>
/// Override this method if shaders are supported.
/// Only call the base class method if shaders aren't supported, as it throws a NotSupportedException.
/// </summary>
@@ -643,13 +659,5 @@
protected internal abstract bool GetRenderState(RenderStateBool renderStateBool);
protected internal abstract void SetRenderState(RenderStateBool renderStateBool, bool value);
- /// <summary>
- /// Creates one of the build in shaders in AgateLib. Implementers should
- /// 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>
- /// <returns></returns>
- protected internal abstract AgateShaderImpl CreateBuiltInShader(AgateLib.DisplayLib.Shaders.Implementation.BuiltInShader BuiltInShaderType);
}
}
Added: trunk/AgateLib/ImplementationBase/FrameBufferImpl.cs
===================================================================
--- trunk/AgateLib/ImplementationBase/FrameBufferImpl.cs (rev 0)
+++ trunk/AgateLib/ImplementationBase/FrameBufferImpl.cs 2009-11-24 01:36:58 UTC (rev 1116)
@@ -0,0 +1,22 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using AgateLib.Geometry;
+
+namespace AgateLib.ImplementationBase
+{
+ public abstract class FrameBufferImpl : IDisposable
+ {
+ bool mIsDisposed = false;
+
+
+ public abstract void Dispose();
+
+ public abstract Size Size { get; }
+
+ public int Width { get { return Size.Width; } }
+ public int Height { get { return Size.Height; } }
+
+ }
+}
Modified: trunk/Drivers/AgateDrawing/AgateDrawing.csproj
===================================================================
--- trunk/Drivers/AgateDrawing/AgateDrawing.csproj 2009-11-23 23:22:24 UTC (rev 1115)
+++ trunk/Drivers/AgateDrawing/AgateDrawing.csproj 2009-11-24 01:36:58 UTC (rev 1116)
@@ -108,6 +108,7 @@
<Compile Include="Properties\AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
+ <Compile Include="Drawing_FrameBuffer.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\AgateLib\AgateLib.csproj">
Modified: trunk/Drivers/AgateDrawing/Drawing_Display.cs
===================================================================
--- trunk/Drivers/AgateDrawing/Drawing_Display.cs 2009-11-23 23:22:24 UTC (rev 1115)
+++ trunk/Drivers/AgateDrawing/Drawing_Display.cs 2009-11-24 01:36:58 UTC (rev 1116)
@@ -116,6 +116,10 @@
{
return AgateLib.WinForms.BitmapFontUtil.ConstructFromOSFont(bitmapOptions);
}
+ protected override FrameBufferImpl CreateFrameBuffer(AgateLib.Geometry.Size size)
+ {
+ return new Drawing_FrameBuffer(size);
+ }
#endregion
#region --- Direct modification of the back buffer ---
Added: trunk/Drivers/AgateDrawing/Drawing_FrameBuffer.cs
===================================================================
--- trunk/Drivers/AgateDrawing/Drawing_FrameBuffer.cs (rev 0)
+++ trunk/Drivers/AgateDrawing/Drawing_FrameBuffer.cs 2009-11-24 01:36:58 UTC (rev 1116)
@@ -0,0 +1,26 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using AgateLib.Geometry;
+using AgateLib.ImplementationBase;
+
+namespace AgateDrawing
+{
+ class Drawing_FrameBuffer: FrameBufferImpl
+ {
+ public Drawing_FrameBuffer(Size size)
+ {
+ }
+
+ public override void Dispose()
+ {
+ throw new NotImplementedException();
+ }
+
+ public override Size Size
+ {
+ get { throw new NotImplementedException(); }
+ }
+ }
+}
Modified: trunk/Drivers/AgateOTK/AgateOTK.csproj
===================================================================
--- trunk/Drivers/AgateOTK/AgateOTK.csproj 2009-11-23 23:22:24 UTC (rev 1115)
+++ trunk/Drivers/AgateOTK/AgateOTK.csproj 2009-11-24 01:36:58 UTC (rev 1116)
@@ -70,7 +70,6 @@
<Name>OpenTK</Name>
<HintPath>.\OpenTK.dll</HintPath>
</Reference>
- <Reference Include="OpenTK.Compatibility, Version=0.9.9.4, Culture=neutral, processorArchitecture=MSIL" />
<Reference Include="System">
<Name>System</Name>
</Reference>
@@ -102,9 +101,6 @@
</ProjectReference>
</ItemGroup>
<ItemGroup>
- <None Include="OpenTK.Compatibility.dll.config">
- <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
- </None>
<None Include="OpenTK.dll.config">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
@@ -170,6 +166,7 @@
<Compile Include="Otk_Reporter.cs">
<SubType>Code</SubType>
</Compile>
+ <Compile Include="GL_FrameBuffer.cs" />
<Compile Include="Shaders\FixedFunction\FixedFunctionShaderFactory.cs" />
<Compile Include="Shaders\FixedFunction\OTK_FF_Basic2DShader.cs" />
<Compile Include="Shaders\FixedFunction\OTK_FF_Lighting3D.cs" />
@@ -187,16 +184,9 @@
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
- <Content Include="OpenTK.Compatibility.dll">
- <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
- </Content>
- <Content Include="OpenTK.Compatibility.xml">
- <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
- </Content>
<Content Include="OpenTK.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
- <Content Include="OpenTK.GLControl.xml" />
<Content Include="OpenTK.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
Modified: trunk/Drivers/AgateOTK/GL_Display.cs
===================================================================
--- trunk/Drivers/AgateOTK/GL_Display.cs 2009-11-23 23:22:24 UTC (rev 1115)
+++ trunk/Drivers/AgateOTK/GL_Display.cs 2009-11-24 01:36:58 UTC (rev 1116)
@@ -134,6 +134,11 @@
return AgateLib.WinForms.BitmapFontUtil.ConstructFromOSFont(bitmapOptions);
}
+ protected override FrameBufferImpl CreateFrameBuffer(Size size)
+ {
+ return new GL_FrameBufferExt(size);
+ }
+
internal void SetupGLOrtho(Rectangle ortho)
{
SetOrthoProjection(ortho);
Added: trunk/Drivers/AgateOTK/GL_FrameBuffer.cs
===================================================================
--- trunk/Drivers/AgateOTK/GL_FrameBuffer.cs (rev 0)
+++ trunk/Drivers/AgateOTK/GL_FrameBuffer.cs 2009-11-24 01:36:58 UTC (rev 1116)
@@ -0,0 +1,26 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using AgateLib.Geometry;
+using AgateLib.ImplementationBase;
+
+namespace AgateOTK
+{
+ class GL_FrameBufferExt: FrameBufferImpl
+ {
+ public GL_FrameBufferExt(Size size)
+ {
+ }
+
+ public override void Dispose()
+ {
+ throw new NotImplementedException();
+ }
+
+ public override Size Size
+ {
+ get { throw new NotImplementedException(); }
+ }
+ }
+}
Deleted: trunk/Drivers/AgateOTK/OpenTK.Compatibility.dll
===================================================================
(Binary files differ)
Deleted: trunk/Drivers/AgateOTK/OpenTK.Compatibility.dll.config
===================================================================
--- trunk/Drivers/AgateOTK/OpenTK.Compatibility.dll.config 2009-11-23 23:22:24 UTC (rev 1115)
+++ trunk/Drivers/AgateOTK/OpenTK.Compatibility.dll.config 2009-11-24 01:36:58 UTC (rev 1116)
@@ -1,11 +0,0 @@
-<configuration>
- <dllmap os="linux" dll="opengl32.dll" target="libGL.so.1"/>
- <dllmap os="linux" dll="glu32.dll" target="libGLU.so.1"/>
- <dllmap os="linux" dll="openal32.dll" target="libopenal.so.1"/>
- <dllmap os="linux" dll="alut.dll" target="libalut.so.0"/>
- <dllmap os="linux" dll="opencl.dll" target="libOpenCL.so"/>
- <dllmap os="osx" dll="openal32.dll" target="/System/Library/Frameworks/OpenAL.framework/OpenAL" />
- <dllmap os="osx" dll="alut.dll" target="/System/Library/Frameworks/OpenAL.framework/OpenAL" />
- <dllmap os="osx" dll="libGLES.dll" target="/System/Library/Frameworks/OpenGLES.framework/OpenGLES" />
- <dllmap os="osx" dll="libGLESv2.dll" target="/System/Library/Frameworks/OpenGLES.framework/OpenGLES" />
-</configuration>
Deleted: trunk/Drivers/AgateOTK/OpenTK.Compatibility.xml
===================================================================
--- trunk/Drivers/AgateOTK/OpenTK.Compatibility.xml 2009-11-23 23:22:24 UTC (rev 1115)
+++ trunk/Drivers/AgateOTK/OpenTK.Compatibility.xml 2009-11-24 01:36:58 UTC (rev 1116)
@@ -1,105220 +0,0 @@
-<?xml version="1.0"?>
-<doc>
- <assembly>
- <name>OpenTK.Compatibility</name>
- </assembly>
- <members>
- <member name="T:Tao.Platform.Windows.SimpleOpenGlControl">
- <summary>
- Provides a simple OpenGL control allowing quick development of Windows.Forms-based
- OpenGL applications. Relies on OpenTK.GLControl for cross-platform compatibility.
- </summary>
- </member>
- <member name="F:Tao.Platform.Windows.SimpleOpenGlControl.components">
- <summary>
- Required designer variable.
- </summary>
- </member>
- <member name="M:Tao.Platform.Windows.SimpleOpenGlControl.Dispose(System.Boolean)">
- <summary>
- Clean up any resources being used.
- </summary>
- <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
- </member>
- <member name="M:Tao.Platform.Windows.SimpleOpenGlControl.InitializeComponent">
- <summary>
- Required method for Designer support - do not modify
- the contents of this method with the code editor.
- </summary>
- </member>
- <member name="M:Tao.Platform.Windows.SimpleOpenGlControl.#ctor">
- <summary>
- Constructor. Creates contexts and sets properties.
- </summary>
- </member>
- <member name="M:Tao.Platform.Windows.SimpleOpenGlControl.DestroyContexts">
- <summary>
-
- </summary>
- </member>
- <member name="M:Tao.Platform.Windows.SimpleOpenGlControl.Draw">
- <summary>
- Sends an see cref="UserControl.Invalidate" command to this control, thus
- forcing a redraw to occur.
- </summary>
- </member>
- <member name="M:Tao.Platform.Windows.SimpleOpenGlControl.InitializeContexts">
- <summary>
- Creates the OpenGL contexts.
- </summary>
- </member>
- <member name="M:Tao.Platform.Windows.SimpleOpenGlControl.OnPaint(System.Windows.Forms.PaintEventArgs)">
- <summary>
- Paints the control.
- </summary>
- <param name="e">The paint event arguments.</param>
- </member>
- <member name="M:Tao.Platform.Windows.SimpleOpenGlControl.InitializeBackground">
- <summary>
- Loads the bitmap from the assembly's manifest resource.
- </summary>
- </member>
- <member name="M:Tao.Platform.Windows.SimpleOpenGlControl.InitializeStyles">
- <summary>
- Initializes the control's styles.
- </summary>
- </member>
- <member name="P:Tao.Platform.Windows.SimpleOpenGlControl.LogScaleX">
- <summary>
- Gets the number of logical pixels or dots per inch (dpi) in X-direction
- </summary>
- </member>
- <member name="P:Tao.Platform.Windows.SimpleOpenGlControl.LogScaleY">
- <summary>
- Gets the number of logical pixels or dots per inch (dpi) in Y-direction
- </summary>
- </member>
- <member name="P:Tao.Platform.Windows.SimpleOpenGlControl.AccumBits">
- <summary>
- Gets and sets the OpenGL control's accumulation buffer depth.
- </summary>
- </member>
- <member name="P:Tao.Platform.Windows.SimpleOpenGlControl.ColorBits">
- <summary>
- Gets and sets the OpenGL control's color buffer depth.
- </summary>
- </member>
- <member name="P:Tao.Platform.Windows.SimpleOpenGlControl.DepthBits">
- <summary>
- Gets and sets the OpenGL control's depth buffer (Z-buffer) depth.
- </summary>
- </member>
- <member name="P:Tao.Platform.Windows.SimpleOpenGlControl.StencilBits">
- <summary>
- Gets and sets the OpenGL control's stencil buffer depth.
- </summary>
- </member>
- <member name="P:Tao.Platform.Windows.SimpleOpenGlControl.AutoCheckErrors">
- <summary>
- Gets and sets the OpenGL control's automatic sending of a glGetError command
- after drawing.
- </summary>
- </member>
- <member name="P:Tao.Platform.Windows.SimpleOpenGlControl.AutoFinish">
- <summary>
- Gets and sets the OpenGL control's automatic sending of a glFinish command
- after drawing.
- </summary>
- </member>
- <member name="P:Tao.Platform.Windows.SimpleOpenGlControl.AutoMakeCurrent">
- <summary>
- Gets and sets the OpenGL control's automatic forcing of the rendering context to
- be current before drawing.
- </summary>
- </member>
- <member name="P:Tao.Platform.Windows.SimpleOpenGlControl.AutoSwapBuffers">
- <summary>
- Gets and sets the OpenGL control's automatic sending of a SwapBuffers command
- after drawing.
- </summary>
- </member>
- <member name="P:Tao.Platform.Windows.SimpleOpenGlControl.CreateParams">
- <summary>
- Overrides the control's class style parameters.
- </summary>
- </member>
- <member name="T:Tao.OpenGl.Gl">
- <summary>
- OpenGL binding for .NET, implementing OpenGL 2.1, plus extensions.
- </summary>
- <remarks>
- <para>
- This class contains all OpenGL enums and functions defined in the 2.1 specification.
- The official .spec files can be found at: http://opengl.org/registry/.
- </para>
- <para>
- We rely on static initialization to obtain the entry points for OpenGL functions.
- Please ensure that a valid OpenGL context has been made current in the pertinent thread <b>before</b>
- any OpenGL functions are called (toolkits like GLUT, SDL or GLFW will automatically take care of
- the context initialization process). Without a valid OpenGL context, we will only be able
- to retrieve statically exported entry points (typically corresponding to OpenGL version 1.1 under Windows,
- 1.3 under Linux and 1.4 under Windows Vista), and extension methods will need to be loaded manually.
- </para>
- <para>
- If you prefer to have more control on extension loading, you can use the
- ReloadFunctions or ReloadFunction methods to manually force the initialisation of OpenGL entry points.
- The ReloadFunctions method should be called whenever you change an existing visual or pixelformat. This
- generally happens when you change the color/stencil/depth buffer associated with a window (but probably
- not the resolution). This may or may not be necessary under Linux/MacOS, but is generally required for
- Windows.
- </para>
- <para>
- You can use the Gl.IsExtensionSupported method to check whether any given category of extension functions
- exists in the current OpenGL context. The results can be cached to speed up future searches.
- Keep in mind that different OpenGL contexts may support different extensions, and under different entry
- points. Always check if all required extensions are still supported when changing visuals or pixel
- formats.
- </para>
- <para>
- You may retrieve the entry point for an OpenGL function using the Gl.GetDelegate method.
- </para>
- <para>
- <see href="http://opengl.org/registry/"/>
- <seealso cref="M:Tao.OpenGl.Gl.IsExtensionSupported(System.String)"/>
- <seealso cref="M:Tao.OpenGl.Gl.GetDelegate(System.String,System.Type)"/>
- <seealso cref="M:Tao.OpenGl.Gl.ReloadFunctions"/>
- </para>
- </remarks>
- </member>
- <member name="M:Tao.OpenGl.Gl.IsExtensionSupported(System.String)">
- <summary>
- Determines whether the specified OpenGL extension category is available in
- the current OpenGL context. Equivalent to IsExtensionSupported(name, true)
- </summary>
- <param name="name">The string for the OpenGL extension category (eg. "GL_ARB_multitexture")</param>
- <returns>True if the specified extension is available, false otherwise.</returns>
- </member>
- <member name="M:Tao.OpenGl.Gl.GetDelegate(System.String,System.Type)">
- <summary>
- Creates a System.Delegate that can be used to call an OpenGL function, core or extension.
- </summary>
- <param name="name">The name of the OpenGL function (eg. "glNewList")</param>
- <param name="signature">The signature of the OpenGL function.</param>
- <returns>
- A System.Delegate that can be used to call this OpenGL function, or null if the specified
- function name did not correspond to an OpenGL function.
- </returns>
- </member>
- <member name="M:Tao.OpenGl.Gl.ReloadFunctions">
- <summary>
- Loads all OpenGL functions (core and extensions).
- </summary>
- <remarks>
- <para>
- This function will be automatically called the first time you use any opengl function. There is
- </para>
- <para>
- Call this function manually whenever you need to update OpenGL entry points.
- This need may arise if you change the pixelformat/visual, or in case you cannot
- (or do not want) to use the automatic initialization of the GL class.
- </para>
- </remarks>
- </member>
- <member name="M:Tao.OpenGl.Gl.Load(System.String)">
- <summary>
- Tries to reload the given OpenGL function (core or extension).
- </summary>
- <param name="function">The name of the OpenGL function (i.e. glShaderSource)</param>
- <returns>True if the function was found and reloaded, false otherwise.</returns>
- <remarks>
- <para>
- Use this function if you require greater granularity when loading OpenGL entry points.
- </para>
- <para>
- While the automatic initialisation will load all OpenGL entry points, in some cases
- the initialisation can take place before an OpenGL Context has been established.
- In this case, use this function to load the entry points for the OpenGL functions
- you will need, or use ReloadFunctions() to load all available entry points.
- </para>
- <para>
- This function returns true if the given OpenGL function is supported, false otherwise.
- </para>
- <para>
- To query for supported extensions use the IsExtensionSupported() function instead.
- </para>
- </remarks>
- </member>
- <member name="M:Tao.OpenGl.Gl.BuildExtensionList">
- <summary>
- Builds a cache of all supported extensions.
- </summary>
- </member>
- <member name="M:Tao.OpenGl.Gl.GetAddress(System.String)">
- <summary>
- Retrieves the entry point for a dynamically exported OpenGL function.
- </summary>
- <param name="function">The function string for the OpenGL function (eg. "glNewList")</param>
- <returns>
- An IntPtr contaning the address for the entry point, or IntPtr.Zero if the specified
- OpenGL function is not dynamically exported.
- </returns>
- <remarks>
- <para>
- The Marshal.GetDelegateForFunctionPointer method can be used to turn the return value
- into a call-able delegate.
- </para>
- <para>
- This function is cross-platform. It determines the underlying platform and uses the
- correct wgl, glx or agl GetAddress function to retrieve the function pointer.
- </para>
- <see cref="M:System.Runtime.InteropServices.Marshal.GetDelegateForFunctionPointer(System.IntPtr,System.Type)"/>
- </remarks>
- </member>
- <member name="M:Tao.OpenGl.Gl.DetectUnixKernel">
- <summary>
- Executes "uname" which returns a string representing the name of the
- underlying Unix kernel.
- </summary>
- <returns>"Unix", "Linux", "Darwin" or null.</returns>
- <remarks>Source code from "Mono: A Developer's Notebook"</remarks>
- </member>
- <member name="M:Tao.OpenGl.Gl.GetExtensionDelegate(System.String,System.Type)">
- <summary>
- Creates a System.Delegate that can be used to call a dynamically exported OpenGL function.
- </summary>
- <param name="name">The name of the OpenGL function (eg. "glNewList")</param>
- <param name="signature">The signature of the OpenGL function.</param>
- <returns>
- A System.Delegate that can be used to call this OpenGL function or null
- if the function is not available in the current OpenGL context.
- </returns>
- </member>
- <member name="T:Tao.OpenGl.Gl.Imports">
- <summary>
- Contains DllImports for the core OpenGL functions.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Gl.Imports.FunctionMap">
- <summary>
- Build a string->MethodInfo map to speed up extension loading.
- </summary>
- </member>
- <member name="M:OpenTK.Graphics.Text.Glyph.#ctor(System.Char,System.Drawing.Font)">
- <summary>
- Constructs a new Glyph that represents the given character and Font.
- </summary>
- <param name="c">The character to represent.</param>
- <param name="font">The Font of the character.</param>
- </member>
- <member name="M:OpenTK.Graphics.Text.Glyph.Equals(System.Object)">
- <summary>
- Checks whether the given object is equal (memberwise) to the current Glyph.
- </summary>
- <param name="obj">The obj to check.</param>
- <returns>True, if the object is identical to the current Glyph.</returns>
- </member>
- <member name="M:OpenTK.Graphics.Text.Glyph.ToString">
- <summary>
- Describes this Glyph object.
- </summary>
- <returns>Returns a System.String describing this Glyph.</returns>
- </member>
- <member name="M:OpenTK.Graphics.Text.Glyph.GetHashCode">
- <summary>
- Calculates the hashcode for this Glyph.
- </summary>
- <returns>A System.Int32 containing a hashcode that uniquely identifies this Glyph.</returns>
- </member>
- <member name="P:OpenTK.Graphics.Text.Glyph.Character">
- <summary>
- Gets the character represented by this Glyph.
- </summary>
- </member>
- <member name="P:OpenTK.Graphics.Text.Glyph.Font">
- <summary>
- Gets the Font of this Glyph.
- </summary>
- </member>
- <member name="T:OpenTK.Graphics.IGraphicsResource">
- <summary>
- Defines a common interface to all OpenGL resources.
- </summary>
- </member>
- <member name="P:OpenTK.Graphics.IGraphicsResource.Context">
- <summary>
- Gets the GraphicsContext that owns this resource.
- </summary>
- </member>
- <member name="P:OpenTK.Graphics.IGraphicsResource.Id">
- <summary>
- Gets the Id of this IGraphicsResource.
- </summary>
- </member>
- <member name="P:OpenTK.Graphics.Texture2D.Width">
- <summary>Gets the width of the texture.</summary>
- </member>
- <member name="P:OpenTK.Graphics.Texture2D.Height">
- <summary>Gets the height of the texture.</summary>
- </member>
- <member name="T:OpenTK.Compatibility.Properties.Resources">
- <summary>
- A strongly-typed resource class, for looking up localized strings, etc.
- </summary>
- </member>
- <member name="P:OpenTK.Compatibility.Properties.Resources.ResourceManager">
- <summary>
- Returns the cached ResourceManager instance used by this class.
- </summary>
- </member>
- <member name="P:OpenTK.Compatibility.Properties.Resources.Culture">
- <summary>
- Overrides the current thread's CurrentUICulture property for all
- resource lookups using this strongly typed resource class.
- </summary>
- </member>
- <member name="T:Tao.OpenGl.Glu">
- <summary>
- GLU (OpenGL Utility) binding for .NET, implementing GLU 1.3.
- </summary>
- <remarks>
- <para>
- Binds functions and definitions in glu32.dll or libGLU.so.
- </para>
- <para>
- The OpenGL Utility (GLU) library contains several groups of functions that
- complement the core OpenGL interface by providing support for auxiliary features.
- These features include: mipmapping, matrix manipulation, polygon tessellation,
- quadrics, NURBS, and error handling.
- </para>
- <para>
- Mipmapping routines include image scaling and automatic mipmap generation. A
- variety of matrix manipulation functions build projection and viewing matrices,
- or project vertices from one coordinate system to another. Polygon tessellation
- routines convert concave polygons into triangles for easy rendering. Quadrics
- support renders a few basic quadrics such as spheres and cones. NURBS code maps
- complicated NURBS curves and trimmed surfaces into simpler OpenGL evaluators.
- Lastly, an error lookup routine translates OpenGL and GLU error codes into
- strings. GLU library routines may call OpenGL library routines. Thus, an OpenGL
- context should be made current before calling any GLU functions. Otherwise an
- OpenGL error may occur.
- </para>
- <para>
- These utility functions make use of core OpenGL functions, so any OpenGL
- implementation is guaranteed to support the utility functions.
- </para>
- </remarks>
- </member>
- <member name="F:Tao.OpenGl.Glu.CALLING_CONVENTION">
- <summary>
- Specifies the calling convention.
- </summary>
- <remarks>
- Specifies <see cref="F:System.Runtime.InteropServices.CallingConvention.Winapi"/> for Windows and
- Linux, to indicate that the default should be used.
- </remarks>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_VERSION_1_1">
- <summary>
- GLU API revision.
- </summary>
- <remarks>
- Specifies GLU 1.1.
- </remarks>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_VERSION_1_2">
- <summary>
- GLU API revision.
- </summary>
- <remarks>
- Specifies GLU 1.2.
- </remarks>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_VERSION_1_3">
- <summary>
- GLU API revision.
- </summary>
- <remarks>
- Specifies GLU 1.3.
- </remarks>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_INVALID_ENUM">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_INVALID_VALUE">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_OUT_OF_MEMORY">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_INCOMPATIBLE_GL_VERSION">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_INVALID_OPERATION">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_VERSION">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_EXTENSIONS">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_TRUE">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_FALSE">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_SMOOTH">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_FLAT">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_NONE">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_POINT">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_LINE">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_FILL">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_SILHOUETTE">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_OUTSIDE">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_INSIDE">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_TESS_MAX_COORD">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_TESS_WINDING_RULE">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_TESS_BOUNDARY_ONLY">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_TESS_TOLERANCE">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_TESS_WINDING_ODD">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_TESS_WINDING_NONZERO">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_TESS_WINDING_POSITIVE">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_TESS_WINDING_NEGATIVE">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_TESS_WINDING_ABS_GEQ_TWO">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_TESS_BEGIN">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_BEGIN">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_TESS_VERTEX">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_VERTEX">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_TESS_END">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_END">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_TESS_ERROR">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_TESS_EDGE_FLAG">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_EDGE_FLAG">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_TESS_COMBINE">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_TESS_BEGIN_DATA">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_TESS_VERTEX_DATA">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_TESS_END_DATA">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_TESS_ERROR_DATA">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_TESS_EDGE_FLAG_DATA">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_TESS_COMBINE_DATA">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_TESS_ERROR1">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_TESS_ERROR2">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_TESS_ERROR3">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_TESS_ERROR4">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_TESS_ERROR5">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_TESS_ERROR6">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_TESS_ERROR7">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_TESS_ERROR8">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_TESS_MISSING_BEGIN_POLYGON">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_TESS_MISSING_BEGIN_CONTOUR">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_TESS_MISSING_END_POLYGON">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_TESS_MISSING_END_CONTOUR">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_TESS_COORD_TOO_LARGE">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_TESS_NEED_COMBINE_CALLBACK">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_AUTO_LOAD_MATRIX">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_CULLING">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_PARAMETRIC_TOLERANCE">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_SAMPLING_TOLERANCE">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_DISPLAY_MODE">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_SAMPLING_METHOD">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_U_STEP">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_V_STEP">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_NURBS_MODE">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_NURBS_MODE_EXT">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_NURBS_TESSELLATOR">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_NURBS_TESSELLATOR_EXT">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_NURBS_RENDERER">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_NURBS_RENDERER_EXT">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_OBJECT_PARAMETRIC_ERROR">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_OBJECT_PARAMETRIC_ERROR_EXT">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_OBJECT_PATH_LENGTH">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_OBJECT_PATH_LENGTH_EXT">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_PATH_LENGTH">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_PARAMETRIC_ERROR">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_DOMAIN_DISTANCE">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_MAP1_TRIM_2">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_MAP1_TRIM_3">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_OUTLINE_POLYGON">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_OUTLINE_PATCH">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_NURBS_ERROR">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_ERROR">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_NURBS_BEGIN">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_NURBS_BEGIN_EXT">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_NURBS_VERTEX">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_NURBS_VERTEX_EXT">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_NURBS_NORMAL">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_NURBS_NORMAL_EXT">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_NURBS_COLOR">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_NURBS_COLOR_EXT">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_NURBS_TEXTURE_COORD">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_NURBS_TEX_COORD_EXT">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_NURBS_END">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_NURBS_END_EXT">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_NURBS_BEGIN_DATA">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_NURBS_BEGIN_DATA_EXT">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_NURBS_VERTEX_DATA">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_NURBS_VERTEX_DATA_EXT">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_NURBS_NORMAL_DATA">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_NURBS_NORMAL_DATA_EXT">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_NURBS_COLOR_DATA">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_NURBS_COLOR_DATA_EXT">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_NURBS_TEXTURE_COORD_DATA">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_NURBS_TEX_COORD_DATA_EXT">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_NURBS_END_DATA">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_NURBS_END_DATA_EXT">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_NURBS_ERROR1">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_NURBS_ERROR2">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_NURBS_ERROR3">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_NURBS_ERROR4">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_NURBS_ERROR5">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_NURBS_ERROR6">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_NURBS_ERROR7">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_NURBS_ERROR8">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_NURBS_ERROR9">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_NURBS_ERROR10">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_NURBS_ERROR11">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_NURBS_ERROR12">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_NURBS_ERROR13">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_NURBS_ERROR14">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_NURBS_ERROR15">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_NURBS_ERROR16">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_NURBS_ERROR17">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_NURBS_ERROR18">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_NURBS_ERROR19">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_NURBS_ERROR20">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_NURBS_ERROR21">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_NURBS_ERROR22">
- <summary>
- Unknown. Unable to locate definitive documentation on this constant.
- </summary>
- </member>
- <member name="F:Tao.OpenGl.Glu.GLU_NURBS_ERROR23">
- <summary...
[truncated message content] |
|
From: <ka...@us...> - 2009-11-23 23:22:33
|
Revision: 1115
http://agate.svn.sourceforge.net/agate/?rev=1115&view=rev
Author: kanato
Date: 2009-11-23 23:22:24 +0000 (Mon, 23 Nov 2009)
Log Message:
-----------
Fix bug 166
Modified Paths:
--------------
trunk/AgateLib/InputLib/Keyboard.cs
trunk/AgateLib/InputLib/Mouse.cs
Modified: trunk/AgateLib/InputLib/Keyboard.cs
===================================================================
--- trunk/AgateLib/InputLib/Keyboard.cs 2009-11-23 23:08:48 UTC (rev 1114)
+++ trunk/AgateLib/InputLib/Keyboard.cs 2009-11-23 23:22:24 UTC (rev 1115)
@@ -39,6 +39,17 @@
{
static KeyState mKeyState = new KeyState();
+ static Keyboard()
+ {
+ DisplayLib.Display.DisposeDisplay += new AgateLib.DisplayLib.Display.DisposeDisplayHandler(Display_DisposeDisplay);
+ }
+
+ static void Display_DisposeDisplay()
+ {
+ ClearEvents();
+ }
+
+
/// <summary>
/// Class which represents the state of all keys on the keyboard.
/// </summary>
@@ -438,5 +449,11 @@
/// </summary>
public static event InputEventHandler KeyUp;
+
+ private static void ClearEvents()
+ {
+ KeyDown = null;
+ KeyUp = null;
+ }
}
}
Modified: trunk/AgateLib/InputLib/Mouse.cs
===================================================================
--- trunk/AgateLib/InputLib/Mouse.cs 2009-11-23 23:08:48 UTC (rev 1114)
+++ trunk/AgateLib/InputLib/Mouse.cs 2009-11-23 23:22:24 UTC (rev 1115)
@@ -116,6 +116,16 @@
private static MouseState mState = new MouseState();
private static bool mIsHidden = false;
+ static Mouse()
+ {
+ Display.DisposeDisplay += new Display.DisposeDisplayHandler(Display_DisposeDisplay);
+ }
+
+ static void Display_DisposeDisplay()
+ {
+ ClearEvents();
+ }
+
/// <summary>
/// Gets or sets the position of the cursor, in client coordinates
/// of the current display window.
@@ -185,6 +195,15 @@
IsHidden = true;
}
+ static void ClearEvents()
+ {
+ MouseMove = null;
+ MouseDown = null;
+ MouseUp = null;
+ MouseDoubleClick = null;
+ MouseWheel = null;
+ }
+
/// <summary>
/// Event which occurs when the mouse is moved.
/// </summary>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ka...@us...> - 2009-11-23 23:08:56
|
Revision: 1114
http://agate.svn.sourceforge.net/agate/?rev=1114&view=rev
Author: kanato
Date: 2009-11-23 23:08:48 +0000 (Mon, 23 Nov 2009)
Log Message:
-----------
Rearrenge projects in Examples.sln.
Modified Paths:
--------------
trunk/Examples.sln
Modified: trunk/Examples.sln
===================================================================
--- trunk/Examples.sln 2009-11-23 23:04:04 UTC (rev 1113)
+++ trunk/Examples.sln 2009-11-23 23:08:48 UTC (rev 1114)
@@ -1,21 +1,21 @@
Microsoft Visual Studio Solution File, Format Version 10.00
# Visual Studio 2008
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AgateDrawing", "Drivers\AgateDrawing\AgateDrawing.csproj", "{AAC01466-7370-4464-B1AD-1593A3A3BEC1}"
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BallBuster.Net", "Examples\BallBuster.Net\BallBuster.Net.csproj", "{DD3CF4AA-02CC-4881-AFB1-6F10DFA1F8AF}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AgateOTK", "Drivers\AgateOTK\AgateOTK.csproj", "{3F2BD363-E2D6-4B62-8D57-7727142D6B82}"
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ShootTheTraps", "Examples\ShootTheTraps\ShootTheTraps.csproj", "{50743D1B-A19E-42F1-842F-65FAD6D168C3}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Pong", "Examples\Pong\Pong.csproj", "{436641C4-846C-42D0-8E8F-95F70E211D22}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BallBuster.Net", "Examples\BallBuster.Net\BallBuster.Net.csproj", "{DD3CF4AA-02CC-4881-AFB1-6F10DFA1F8AF}"
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AgateDrawing", "Drivers\AgateDrawing\AgateDrawing.csproj", "{164A785D-924E-40FB-A517-D7E677F3B53A}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AgateLib", "AgateLib\AgateLib.csproj", "{BED5DD5D-13C6-4BA4-80DC-A47478E74F84}"
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AgateOTK", "Drivers\AgateOTK\AgateOTK.csproj", "{9E095F03-BA3F-4EAD-A905-2A2647CE4405}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AgateLib.WinForms", "Drivers\AgateLib.WinForms\AgateLib.WinForms.csproj", "{2E6579F9-1F70-4DF9-98A9-22687425A830}"
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AgateLib", "AgateLib\AgateLib.csproj", "{9490B719-829E-43A7-A5FE-8001F8A81759}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AgateSDL", "Drivers\AgateSDL\AgateSDL.csproj", "{6ED4F92F-7C1F-478C-9AA1-938F47B68F22}"
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AgateLib.WinForms", "Drivers\AgateLib.WinForms\AgateLib.WinForms.csproj", "{BEF6D67B-4C84-4D3E-8047-6DB2C8754D77}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ShootTheTraps", "Examples\ShootTheTraps\ShootTheTraps.csproj", "{50743D1B-A19E-42F1-842F-65FAD6D168C3}"
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AgateSDL", "Drivers\AgateSDL\AgateSDL.csproj", "{00C7FA95-98F4-43D9-9B63-34122B1DB003}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -23,38 +23,38 @@
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {AAC01466-7370-4464-B1AD-1593A3A3BEC1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {AAC01466-7370-4464-B1AD-1593A3A3BEC1}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {AAC01466-7370-4464-B1AD-1593A3A3BEC1}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {AAC01466-7370-4464-B1AD-1593A3A3BEC1}.Release|Any CPU.Build.0 = Release|Any CPU
- {3F2BD363-E2D6-4B62-8D57-7727142D6B82}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {3F2BD363-E2D6-4B62-8D57-7727142D6B82}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {3F2BD363-E2D6-4B62-8D57-7727142D6B82}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {3F2BD363-E2D6-4B62-8D57-7727142D6B82}.Release|Any CPU.Build.0 = Release|Any CPU
- {436641C4-846C-42D0-8E8F-95F70E211D22}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {436641C4-846C-42D0-8E8F-95F70E211D22}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {436641C4-846C-42D0-8E8F-95F70E211D22}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {436641C4-846C-42D0-8E8F-95F70E211D22}.Release|Any CPU.Build.0 = Release|Any CPU
{DD3CF4AA-02CC-4881-AFB1-6F10DFA1F8AF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DD3CF4AA-02CC-4881-AFB1-6F10DFA1F8AF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DD3CF4AA-02CC-4881-AFB1-6F10DFA1F8AF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DD3CF4AA-02CC-4881-AFB1-6F10DFA1F8AF}.Release|Any CPU.Build.0 = Release|Any CPU
- {BED5DD5D-13C6-4BA4-80DC-A47478E74F84}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {BED5DD5D-13C6-4BA4-80DC-A47478E74F84}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {BED5DD5D-13C6-4BA4-80DC-A47478E74F84}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {BED5DD5D-13C6-4BA4-80DC-A47478E74F84}.Release|Any CPU.Build.0 = Release|Any CPU
- {2E6579F9-1F70-4DF9-98A9-22687425A830}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {2E6579F9-1F70-4DF9-98A9-22687425A830}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {2E6579F9-1F70-4DF9-98A9-22687425A830}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {2E6579F9-1F70-4DF9-98A9-22687425A830}.Release|Any CPU.Build.0 = Release|Any CPU
- {6ED4F92F-7C1F-478C-9AA1-938F47B68F22}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {6ED4F92F-7C1F-478C-9AA1-938F47B68F22}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {6ED4F92F-7C1F-478C-9AA1-938F47B68F22}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {6ED4F92F-7C1F-478C-9AA1-938F47B68F22}.Release|Any CPU.Build.0 = Release|Any CPU
{50743D1B-A19E-42F1-842F-65FAD6D168C3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{50743D1B-A19E-42F1-842F-65FAD6D168C3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{50743D1B-A19E-42F1-842F-65FAD6D168C3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{50743D1B-A19E-42F1-842F-65FAD6D168C3}.Release|Any CPU.Build.0 = Release|Any CPU
+ {436641C4-846C-42D0-8E8F-95F70E211D22}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {436641C4-846C-42D0-8E8F-95F70E211D22}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {436641C4-846C-42D0-8E8F-95F70E211D22}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {436641C4-846C-42D0-8E8F-95F70E211D22}.Release|Any CPU.Build.0 = Release|Any CPU
+ {164A785D-924E-40FB-A517-D7E677F3B53A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {164A785D-924E-40FB-A517-D7E677F3B53A}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {164A785D-924E-40FB-A517-D7E677F3B53A}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {164A785D-924E-40FB-A517-D7E677F3B53A}.Release|Any CPU.Build.0 = Release|Any CPU
+ {9E095F03-BA3F-4EAD-A905-2A2647CE4405}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {9E095F03-BA3F-4EAD-A905-2A2647CE4405}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {9E095F03-BA3F-4EAD-A905-2A2647CE4405}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {9E095F03-BA3F-4EAD-A905-2A2647CE4405}.Release|Any CPU.Build.0 = Release|Any CPU
+ {9490B719-829E-43A7-A5FE-8001F8A81759}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {9490B719-829E-43A7-A5FE-8001F8A81759}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {9490B719-829E-43A7-A5FE-8001F8A81759}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {9490B719-829E-43A7-A5FE-8001F8A81759}.Release|Any CPU.Build.0 = Release|Any CPU
+ {BEF6D67B-4C84-4D3E-8047-6DB2C8754D77}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {BEF6D67B-4C84-4D3E-8047-6DB2C8754D77}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {BEF6D67B-4C84-4D3E-8047-6DB2C8754D77}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {BEF6D67B-4C84-4D3E-8047-6DB2C8754D77}.Release|Any CPU.Build.0 = Release|Any CPU
+ {00C7FA95-98F4-43D9-9B63-34122B1DB003}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {00C7FA95-98F4-43D9-9B63-34122B1DB003}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {00C7FA95-98F4-43D9-9B63-34122B1DB003}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {00C7FA95-98F4-43D9-9B63-34122B1DB003}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ka...@us...> - 2009-11-23 23:04:12
|
Revision: 1113
http://agate.svn.sourceforge.net/agate/?rev=1113&view=rev
Author: kanato
Date: 2009-11-23 23:04:04 +0000 (Mon, 23 Nov 2009)
Log Message:
-----------
Make Tests first project in solution so it is the start up project when checked out.
Modified Paths:
--------------
trunk/AgateLib-Windows.sln
Modified: trunk/AgateLib-Windows.sln
===================================================================
--- trunk/AgateLib-Windows.sln 2009-11-23 23:02:00 UTC (rev 1112)
+++ trunk/AgateLib-Windows.sln 2009-11-23 23:04:04 UTC (rev 1113)
@@ -1,5 +1,7 @@
Microsoft Visual Studio Solution File, Format Version 10.00
# Visual Studio 2008
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tests", "Tests\Tests.csproj", "{DC687DB2-90A8-484D-AB99-B3D29FDD8D44}"
+EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AgateLib.WinForms", "Drivers\AgateLib.WinForms\AgateLib.WinForms.csproj", "{BEF6D67B-4C84-4D3E-8047-6DB2C8754D77}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AgateDrawing", "Drivers\AgateDrawing\AgateDrawing.csproj", "{164A785D-924E-40FB-A517-D7E677F3B53A}"
@@ -8,8 +10,6 @@
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AgateSDX", "Drivers\AgateSDX\AgateSDX.csproj", "{EF993B30-D9A9-4962-80BB-6826D39B3465}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tests", "Tests\Tests.csproj", "{DC687DB2-90A8-484D-AB99-B3D29FDD8D44}"
-EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AgateLib", "AgateLib\AgateLib.csproj", "{9490B719-829E-43A7-A5FE-8001F8A81759}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AgateFMOD", "Drivers\AgateFMOD\AgateFMOD.csproj", "{424C08A9-6CC6-4FFF-B782-CBD58BC42FCA}"
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|