agate-svn-commit Mailing List for AgateLib (Page 23)
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: <ac...@us...> - 2009-05-18 10:59:48
|
Revision: 987
http://agate.svn.sourceforge.net/agate/?rev=987&view=rev
Author: accagon
Date: 2009-05-18 10:59:32 +0000 (Mon, 18 May 2009)
Log Message:
-----------
* PixelEmitter.cs: Add particle recycle code
Modified Paths:
--------------
branches/particles/AgateLib/Particles/Emitters/PixelEmitter.cs
Modified: branches/particles/AgateLib/Particles/Emitters/PixelEmitter.cs
===================================================================
--- branches/particles/AgateLib/Particles/Emitters/PixelEmitter.cs 2009-05-18 07:42:41 UTC (rev 986)
+++ branches/particles/AgateLib/Particles/Emitters/PixelEmitter.cs 2009-05-18 10:59:32 UTC (rev 987)
@@ -17,6 +17,7 @@
// Contributor(s): Marcel Hauf.
//
using System;
+using System.Linq;
using System.Collections.Generic;
using AgateLib.DisplayLib;
@@ -144,20 +145,38 @@
time += time_ms;
float frequenzy = EmitFrequenzy*1000;
- while(time >= frequenzy && Particles.Count < Particles.Capacity)
+ while(time >= frequenzy)
{
- // TODO: recyle dead particles
- PixelParticle pp = new PixelParticle(EmitColor);
+ int index = Particles.IndexOf(Particles.FirstOrDefault(pt => pt.IsALive == false));
+ if(index > -1)
+ {
+ // Recycle a dead particle
+ Particles[index].Acceleration = Vector2.Empty;
+ (Particles[index] as PixelParticle).Color = EmitColor;
+ Particles[index].Condition = Condition.ALive;
+ Particles[index].Life = EmitLife;
+ Particles[index].Position = Position;
+ Particles[index].Velocity = Vector2.Empty;
+ }
+ else if(Particles.Count < Particles.Capacity)
+ {
+ // Add a new particle
+ PixelParticle pp = new PixelParticle(EmitColor);
+ pp.Acceleration = Vector2.Empty;
+ pp.Color = EmitColor;
+ pp.Condition = Condition.ALive;
+ pp.Life = EmitLife;
+ pp.Position = Position;
+ pp.Velocity = Vector2.Empty;
+ Particles.Add(pp);
+ }
+ else
+ {
+ // No capacity left and no dead particles to recycle
+ time = 0;
+ break;
+ }
- pp.Acceleration = Vector2.Empty;
- pp.Color = EmitColor;
- pp.Condition = Condition.ALive;
- pp.Life = EmitLife;
- pp.Position = Position;
- pp.Velocity = Vector2.Empty;
-
- Particles.Add(pp);
-
time -= frequenzy;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ka...@us...> - 2009-05-18 07:42:47
|
Revision: 986
http://agate.svn.sourceforge.net/agate/?rev=986&view=rev
Author: kanato
Date: 2009-05-18 07:42:41 +0000 (Mon, 18 May 2009)
Log Message:
-----------
Implement Display.FillEllipse and Display.FillPolygon.
Modified Paths:
--------------
branches/agate3d-3.2/AgateLib/DisplayLib/Display.cs
branches/agate3d-3.2/AgateLib/ImplementationBase/DisplayImpl.cs
branches/agate3d-3.2/Drivers/AgateDrawing/Drawing_Display.cs
branches/agate3d-3.2/Drivers/AgateMDX/MDX1_Display.cs
branches/agate3d-3.2/Drivers/AgateOTK/GL_Display.cs
branches/agate3d-3.2/Drivers/AgateSDX/SDX_Display.cs
branches/agate3d-3.2/Tests/DisplayTests/BasicDrawing/BasicDrawing.cs
branches/agate3d-3.2/Tests/DisplayTests/BasicDrawing/DrawingTester.Designer.cs
branches/agate3d-3.2/Tests/DisplayTests/BasicDrawing/DrawingTester.cs
Modified: branches/agate3d-3.2/AgateLib/DisplayLib/Display.cs
===================================================================
--- branches/agate3d-3.2/AgateLib/DisplayLib/Display.cs 2009-05-17 19:11:31 UTC (rev 985)
+++ branches/agate3d-3.2/AgateLib/DisplayLib/Display.cs 2009-05-18 07:42:41 UTC (rev 986)
@@ -476,6 +476,27 @@
{
impl.SetOrthoProjection(region);
}
+
+ #region --- Matrix Settings ---
+
+ public static Matrix4 MatrixProjection
+ {
+ get { return impl.MatrixProjection; }
+ set { impl.MatrixProjection = value; }
+ }
+ public static Matrix4 MatrixView
+ {
+ get { return impl.MatrixView; }
+ set { impl.MatrixView = value; }
+ }
+ public static Matrix4 MatrixWorld
+ {
+ get { return impl.MatrixWorld; }
+ set { impl.MatrixWorld = value; }
+ }
+
+
+ #endregion
#region --- Drawing Functions ---
/// <summary>
@@ -497,7 +518,7 @@
/// <param name="color"></param>
public static void DrawLine(int x1, int y1, int x2, int y2, Color color)
{
- impl.DrawLine(x1, y1, x2, y2, color);
+ impl.DrawLine(new Point(x1, y1), new Point(x2, y2), color);
}
/// <summary>
/// Draws a line between the two points specified.
@@ -532,29 +553,6 @@
throw new ArgumentException("pts argument is not an even number of points!");
impl.DrawLineSegments(pts, color);
}
-
- #region --- Matrix Settings ---
-
- public static Matrix4 MatrixProjection
- {
- get { return impl.MatrixProjection; }
- set { impl.MatrixProjection = value; }
- }
- public static Matrix4 MatrixView
- {
- get { return impl.MatrixView; }
- set { impl.MatrixView = value; }
- }
- public static Matrix4 MatrixWorld
- {
- get { return impl.MatrixWorld; }
- set { impl.MatrixWorld = value; }
- }
-
-
- #endregion
-
-
/// <summary>
/// Draws the outline of a rectangle.
/// </summary>
@@ -585,7 +583,35 @@
{
impl.DrawRect(new Rectangle(x, y, width, height), color);
}
+
/// <summary>
+ /// Draws a filled ellipse inscribed in the specified rectangle.
+ /// </summary>
+ /// <param name="rect"></param>
+ /// <param name="color"></param>
+ public static void FillEllipse(Rectangle rect, Color color)
+ {
+ impl.FillEllipse((RectangleF)rect, color);
+ }
+ /// <summary>
+ /// Draws a filled ellipse inscribed in the specified rectangle.
+ /// </summary>
+ /// <param name="rect"></param>
+ /// <param name="color"></param>
+ public static void FillEllipse(RectangleF rect, Color color)
+ {
+ impl.FillEllipse(rect, color);
+ }
+ /// <summary>
+ /// Draws a filled polygon. The last point will be connected to the first point.
+ /// </summary>
+ /// <param name="pts"></param>
+ /// <param name="color"></param>
+ public static void FillPolygon(PointF[] pts, Color color)
+ {
+ impl.FillPolygon(pts, color);
+ }
+ /// <summary>
/// Draws a filled rectangle.
/// </summary>
/// <param name="rect"></param>
Modified: branches/agate3d-3.2/AgateLib/ImplementationBase/DisplayImpl.cs
===================================================================
--- branches/agate3d-3.2/AgateLib/ImplementationBase/DisplayImpl.cs 2009-05-17 19:11:31 UTC (rev 985)
+++ branches/agate3d-3.2/AgateLib/ImplementationBase/DisplayImpl.cs 2009-05-18 07:42:41 UTC (rev 986)
@@ -375,7 +375,7 @@
// we will take the circumference as being the number of points to draw
// on the ellipse.
- Point[] pts = new Point[(int)Math.Ceiling(circumference)];
+ Point[] pts = new Point[(int)Math.Ceiling(circumference * 2)];
double step = 2 * Math.PI / (pts.Length - 1);
for (int i = 0; i < pts.Length; i++)
@@ -387,16 +387,37 @@
DrawLines(pts, color);
}
+
+ public virtual void FillEllipse(RectangleF rect, Color color)
+ {
+ PointF center = new PointF(rect.Left + rect.Width / 2,
+ rect.Top + rect.Height / 2);
+
+ double radiusX = rect.Width / 2;
+ double radiusY = rect.Height / 2;
+ double h = Math.Pow(radiusX - radiusY, 2) / Math.Pow(radiusX + radiusY, 2);
+
+ //Ramanujan's second approximation to the circumference of an ellipse.
+ double circumference =
+ Math.PI * (radiusX + radiusY) * (1 + 3 * h / (10 + Math.Sqrt(4 - 3 * h)));
+
+ // we will take the circumference as being the number of points to draw
+ // on the ellipse.
+ PointF[] pts = new PointF[(int)Math.Ceiling(circumference * 2)];
+ double step = 2 * Math.PI / (pts.Length - 1);
+
+ for (int i = 0; i < pts.Length; i++)
+ {
+ pts[i] = new PointF((float)(center.X + radiusX * Math.Cos(step * i) + 0.5),
+ (float)(center.Y + radiusY * Math.Sin(step * i) + 0.5));
+ }
+
+ FillPolygon(pts, color);
+ }
+
+ public abstract void FillPolygon(PointF[] pts, Color color);
+
/// <summary>
- /// Draws a line between the two specified end-points.
- /// </summary>
- /// <param name="x1"></param>
- /// <param name="y1"></param>
- /// <param name="x2"></param>
- /// <param name="y2"></param>
- /// <param name="color"></param>
- public abstract void DrawLine(int x1, int y1, int x2, int y2, Color color);
- /// <summary>
/// Draws a line between the two specified endpoints.
/// </summary>
/// <param name="a"></param>
@@ -641,5 +662,6 @@
ShaderCompiler.Disable();
}
+
}
}
Modified: branches/agate3d-3.2/Drivers/AgateDrawing/Drawing_Display.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateDrawing/Drawing_Display.cs 2009-05-17 19:11:31 UTC (rev 985)
+++ branches/agate3d-3.2/Drivers/AgateDrawing/Drawing_Display.cs 2009-05-18 07:42:41 UTC (rev 986)
@@ -137,12 +137,6 @@
new SolidBrush(Interop.Convert(color)), Interop.Convert(dest_rect));
}
- public override void DrawLine(int x1, int y1, int x2, int y2, Geometry.Color color)
- {
- CheckInFrame("DrawLine");
-
- mGraphics.DrawLine(new Pen(Interop.Convert(color)), x1, y1, x2, y2);
- }
public override void DrawLine(Geometry.Point a, Geometry.Point b, Geometry.Color color)
{
CheckInFrame("DrawLine");
@@ -192,6 +186,20 @@
FillRect(rect, color.AverageColor);
}
+ public override void FillPolygon(Geometry.PointF[] pts, Geometry.Color color)
+ {
+ SolidBrush b = new SolidBrush(Interop.Convert(color));
+
+ PointF[] p = new PointF[pts.Length];
+ for (int i = 0; i < pts.Length; i++)
+ p[i] = Interop.Convert(pts[i]);
+
+ mGraphics.FillPolygon(b, p);
+
+ b.Dispose();
+ }
+
+
#endregion
#region --- Begin/End Frame and DeltaTime ---
Modified: branches/agate3d-3.2/Drivers/AgateMDX/MDX1_Display.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateMDX/MDX1_Display.cs 2009-05-17 19:11:31 UTC (rev 985)
+++ branches/agate3d-3.2/Drivers/AgateMDX/MDX1_Display.cs 2009-05-18 07:42:41 UTC (rev 986)
@@ -350,10 +350,6 @@
}
- public override void DrawLine(int x1, int y1, int x2, int y2, Color color)
- {
- DrawLine(new Point(x1, y1), new Point(x2, y2), color);
- }
public override void DrawLine(Point a, Point b, Color color)
{
mDevice.DrawBuffer.Flush();
@@ -442,9 +438,12 @@
mDevice.AlphaArgument1 = TextureArgument.TextureColor;
}
+ public override void FillPolygon(PointF[] pts, Color color)
+ {
+ throw new NotImplementedException();
+ }
-
#endregion
#region --- Display Mode changing stuff ---
Modified: branches/agate3d-3.2/Drivers/AgateOTK/GL_Display.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateOTK/GL_Display.cs 2009-05-17 19:11:31 UTC (rev 985)
+++ branches/agate3d-3.2/Drivers/AgateOTK/GL_Display.cs 2009-05-18 07:42:41 UTC (rev 986)
@@ -259,28 +259,20 @@
DrawRect(dest, Color.FromArgb(255, color));
}
-
- public override void DrawLine(int x1, int y1, int x2, int y2, Color color)
+ public override void DrawLine(Point a, Point b, Color color)
{
mState.DrawBuffer.Flush();
-
mState.SetGLColor(color);
GL.Disable(EnableCap.Texture2D);
GL.Begin(BeginMode.Lines);
- GL.Vertex2(x1, y1 + 0.5);
- GL.Vertex2(x2, y2 + 0.5);
+ GL.Vertex2(a.X, a.Y);
+ GL.Vertex2(b.X, b.Y);
GL.End();
GL.Enable(EnableCap.Texture2D);
}
- public override void DrawLine(Point a, Point b, Color color)
- {
- mState.DrawBuffer.Flush();
- DrawLine(a.X, a.Y, b.X, b.Y, color);
- }
-
public override void DrawRect(Rectangle rect, Color color)
{
DrawRect(new RectangleF(rect.X, rect.Y, rect.Width, rect.Height), color);
@@ -358,6 +350,24 @@
GL.Enable(EnableCap.Texture2D);
}
+ public override void FillPolygon(PointF[] pts, Color color)
+ {
+ mState.DrawBuffer.Flush();
+
+ GL.Disable(EnableCap.Texture2D);
+
+ mState.SetGLColor(color);
+
+ GL.Begin(BeginMode.TriangleFan);
+ for (int i = 0; i < pts.Length; i++)
+ {
+ GL.Vertex3(pts[i].X, pts[i].Y, 0);
+ }
+ GL.End(); // Done Drawing The Quad
+
+ GL.Enable(EnableCap.Texture2D);
+ }
+
public override bool VSync
{
get { return mVSync; }
Modified: branches/agate3d-3.2/Drivers/AgateSDX/SDX_Display.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateSDX/SDX_Display.cs 2009-05-17 19:11:31 UTC (rev 985)
+++ branches/agate3d-3.2/Drivers/AgateSDX/SDX_Display.cs 2009-05-18 07:42:41 UTC (rev 986)
@@ -376,10 +376,6 @@
}
- public override void DrawLine(int x1, int y1, int x2, int y2, Color color)
- {
- DrawLine(new Point(x1, y1), new Point(x2, y2), color);
- }
public override void DrawLine(Point a, Point b, Color color)
{
mDevice.DrawBuffer.Flush();
@@ -403,7 +399,7 @@
}
mDevice.Device.VertexDeclaration = mPosColorDecl;
- mDevice.Device.DrawUserPrimitives(Direct3D.PrimitiveType.LineList, pt.Length / 2, mLines);
+ mDevice.Device.DrawUserPrimitives(Direct3D.PrimitiveType.LineStrip, pt.Length - 1, mLines);
}
public override void DrawRect(Rectangle rect, Color color)
{
@@ -425,6 +421,32 @@
mDevice.Device.DrawUserPrimitives(Direct3D.PrimitiveType.LineStrip, 4, mLines);
}
+ PositionColor[] polygonVerts = new PositionColor[10];
+
+ public override void FillPolygon(PointF[] pts, Color color)
+ {
+ if (polygonVerts.Length < pts.Length)
+ polygonVerts = new PositionColor[pts.Length];
+
+ int clr = color.ToArgb();
+
+ for (int i = 0; i < pts.Length; i++)
+ {
+ polygonVerts[i].Position = new AgateLib.Geometry.Vector3(pts[i].X, pts[i].Y, 0);
+ polygonVerts[i].Color = clr;
+ }
+
+ mDevice.DrawBuffer.Flush();
+
+ mDevice.AlphaBlend = true;
+
+ mDevice.SetDeviceStateTexture(null);
+ mDevice.AlphaArgument1 = TextureArgument.Diffuse;
+
+ mDevice.Device.VertexDeclaration = mPosColorDecl;
+ mDevice.Device.DrawUserPrimitives(Direct3D.PrimitiveType.TriangleFan, pts.Length - 2, polygonVerts);
+ mDevice.AlphaArgument1 = TextureArgument.Texture;
+ }
public override void FillRect(Rectangle rect, Color color)
{
FillRect((RectangleF)rect, new Gradient(color));
@@ -439,7 +461,6 @@
}
public override void FillRect(RectangleF rect, Gradient color)
{
- // defining our screen sized quad, note the Z value of 1f to place it in the background
mFillRectVerts[0].Position = new AgateLib.Geometry.Vector3(rect.Left, rect.Top, 0f);
mFillRectVerts[0].Color = color.TopLeft.ToArgb();
Modified: branches/agate3d-3.2/Tests/DisplayTests/BasicDrawing/BasicDrawing.cs
===================================================================
--- branches/agate3d-3.2/Tests/DisplayTests/BasicDrawing/BasicDrawing.cs 2009-05-17 19:11:31 UTC (rev 985)
+++ branches/agate3d-3.2/Tests/DisplayTests/BasicDrawing/BasicDrawing.cs 2009-05-18 07:42:41 UTC (rev 986)
@@ -14,6 +14,7 @@
enum ShapeType
{
FillRect,
+ FillEllipse,
DrawRect,
DrawEllipse,
DrawLine,
@@ -54,6 +55,13 @@
case ShapeType.FillRect:
Display.FillRect(Rect, Color);
break;
+
+ case ShapeType.FillEllipse:
+ Display.FillEllipse(Rect, Color);
+ break;
+
+ default:
+ throw new NotImplementedException();
}
}
}
@@ -92,6 +100,7 @@
frm.btnDrawRect.Click += new EventHandler(btnDrawRect_Click);
frm.btnFillRect.Click += new EventHandler(btnFillRect_Click);
frm.btnDrawCircle.Click += new EventHandler(btnDrawCircle_Click);
+ frm.btnFillCircle.Click += new EventHandler(btnFillCircle_Click);
frm.Show();
// This creates the window that we will be drawing in.
@@ -129,6 +138,11 @@
}
}
+ void btnFillCircle_Click(object sender, EventArgs e)
+ {
+ shapes.Add(new Shape(ShapeType.FillEllipse, Color.FromArgb(frm.SelectedColor.ToArgb()), RandomRect()));
+ }
+
static void btnDrawCircle_Click(object sender, EventArgs e)
{
shapes.Add(new Shape(ShapeType.DrawEllipse, Color.FromArgb(frm.SelectedColor.ToArgb()), RandomRect()));
Modified: branches/agate3d-3.2/Tests/DisplayTests/BasicDrawing/DrawingTester.Designer.cs
===================================================================
--- branches/agate3d-3.2/Tests/DisplayTests/BasicDrawing/DrawingTester.Designer.cs 2009-05-17 19:11:31 UTC (rev 985)
+++ branches/agate3d-3.2/Tests/DisplayTests/BasicDrawing/DrawingTester.Designer.cs 2009-05-18 07:42:41 UTC (rev 986)
@@ -41,6 +41,7 @@
this.label1 = new System.Windows.Forms.Label();
this.nudAlpha = new System.Windows.Forms.NumericUpDown();
this.btnDrawCircle = new System.Windows.Forms.Button();
+ this.btnFillCircle = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.nudAlpha)).BeginInit();
this.SuspendLayout();
//
@@ -51,7 +52,7 @@
| System.Windows.Forms.AnchorStyles.Right)));
this.panel1.Location = new System.Drawing.Point(93, 12);
this.panel1.Name = "panel1";
- this.panel1.Size = new System.Drawing.Size(187, 193);
+ this.panel1.Size = new System.Drawing.Size(226, 238);
this.panel1.TabIndex = 0;
//
// btnDrawLine
@@ -96,7 +97,7 @@
// btnClear
//
this.btnClear.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
- this.btnClear.Location = new System.Drawing.Point(12, 182);
+ this.btnClear.Location = new System.Drawing.Point(12, 227);
this.btnClear.Name = "btnClear";
this.btnClear.Size = new System.Drawing.Size(75, 23);
this.btnClear.TabIndex = 4;
@@ -144,11 +145,22 @@
this.btnDrawCircle.Text = "Draw Circle";
this.btnDrawCircle.UseVisualStyleBackColor = true;
//
+ // btnFillCircle
+ //
+ this.btnFillCircle.Location = new System.Drawing.Point(12, 182);
+ this.btnFillCircle.Name = "btnFillCircle";
+ this.btnFillCircle.Size = new System.Drawing.Size(75, 23);
+ this.btnFillCircle.TabIndex = 8;
+ this.btnFillCircle.Text = "Fill Circle";
+ this.btnFillCircle.UseVisualStyleBackColor = true;
+ this.btnFillCircle.Click += new System.EventHandler(this.btnFillCircle_Click);
+ //
// DrawingTester
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(292, 217);
+ this.ClientSize = new System.Drawing.Size(331, 262);
+ this.Controls.Add(this.btnFillCircle);
this.Controls.Add(this.btnDrawCircle);
this.Controls.Add(this.nudAlpha);
this.Controls.Add(this.label1);
@@ -179,6 +191,7 @@
private System.Windows.Forms.Label label1;
private System.Windows.Forms.NumericUpDown nudAlpha;
public System.Windows.Forms.Button btnDrawCircle;
+ public System.Windows.Forms.Button btnFillCircle;
}
}
\ No newline at end of file
Modified: branches/agate3d-3.2/Tests/DisplayTests/BasicDrawing/DrawingTester.cs
===================================================================
--- branches/agate3d-3.2/Tests/DisplayTests/BasicDrawing/DrawingTester.cs 2009-05-17 19:11:31 UTC (rev 985)
+++ branches/agate3d-3.2/Tests/DisplayTests/BasicDrawing/DrawingTester.cs 2009-05-18 07:42:41 UTC (rev 986)
@@ -33,5 +33,10 @@
}
}
+ private void btnFillCircle_Click(object sender, EventArgs e)
+ {
+
+ }
+
}
}
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ac...@us...> - 2009-05-17 19:11:40
|
Revision: 985
http://agate.svn.sourceforge.net/agate/?rev=985&view=rev
Author: accagon
Date: 2009-05-17 19:11:31 +0000 (Sun, 17 May 2009)
Log Message:
-----------
* PixelEmitter.cs:
- Improve memory management
- Add more constructors
- Add PixelSize property
Modified Paths:
--------------
branches/particles/AgateLib/Particles/Emitters/PixelEmitter.cs
Modified: branches/particles/AgateLib/Particles/Emitters/PixelEmitter.cs
===================================================================
--- branches/particles/AgateLib/Particles/Emitters/PixelEmitter.cs 2009-05-13 17:01:51 UTC (rev 984)
+++ branches/particles/AgateLib/Particles/Emitters/PixelEmitter.cs 2009-05-17 19:11:31 UTC (rev 985)
@@ -26,15 +26,18 @@
{
/// <summary>
/// A pixel particle emitter.
+ /// Optimized for pixel rendering.
/// </summary>
public class PixelEmitter : ParticleEmitter
{
private Color mEmitColor = Color.White;
private float mEmitLife = 1f;
- private Surface drawSurf = new Surface(2, 2);
+ private Surface drawSurf = new Surface(1, 1);
private float time = 0f;
+ private Rectangle mRectangle = new Rectangle(0, 0, 2, 2);
+
/// <value>
/// Gets or sets the emit color.
/// </value>
@@ -53,6 +56,15 @@
set { mEmitLife = value; }
}
+ /// <value>
+ /// Gets or sets the pixel size.
+ /// </value>
+ public Size PixelSize
+ {
+ get { return mRectangle.Size; }
+ set { mRectangle.Size = value; }
+ }
+
/// <summary>
/// Constructs a pixel particle emitter.
/// </summary>
@@ -67,6 +79,17 @@
/// <summary>
/// Constructs a pixel particle emitter.
/// </summary>
+ /// <param name="position"></param>
+ /// <param name="color"></param>
+ /// <param name="emitLife"></param>
+ public PixelEmitter(Vector2 position, Color color, float emitLife) : this(position, color)
+ {
+ mEmitLife = emitLife;
+ }
+
+ /// <summary>
+ /// Constructs a pixel particle emitter.
+ /// </summary>
/// <param name="position">Position of the emitter.</param>
/// <param name="color">Emit color.</param>
/// <param name="maxParticles">Maximum amount of particles.</param>
@@ -75,6 +98,18 @@
Particles = new List<Particle>(maxParticles);
}
+ /// <summary>
+ /// Constructs a pixel particle emitter.
+ /// </summary>
+ /// <param name="position"></param>
+ /// <param name="color"></param>
+ /// <param name="maxParticles"></param>
+ /// <param name="emitLife"></param>
+ public PixelEmitter(Vector2 position, Color color, int maxParticles, float emitLife) : this(position, color, maxParticles)
+ {
+ mEmitLife = emitLife;
+ }
+
/// <summary>s
/// Overridden Draw method.
/// Draws each living particle.
@@ -85,7 +120,10 @@
{
if(ptl.Condition == Condition.ALive || ptl.Condition == Condition.Frozen)
{
- Display.DrawEllipse(new Rectangle((int)ptl.Position.X, (int)ptl.Position.Y, 2, 2), ptl.Color);
+ mRectangle.X = (int)ptl.Position.X;
+ mRectangle.Y = (int)ptl.Position.Y;
+
+ Display.DrawEllipse(mRectangle, ptl.Color);
//drawSurf.Color = ptl.Color;
//drawSurf.Draw(ptl.Position.X, ptl.Position.Y);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ka...@us...> - 2009-05-13 17:01:57
|
Revision: 984
http://agate.svn.sourceforge.net/agate/?rev=984&view=rev
Author: kanato
Date: 2009-05-13 17:01:51 +0000 (Wed, 13 May 2009)
Log Message:
-----------
Remove TesselateFactor crap from AgateSDX.
Modified Paths:
--------------
branches/agate3d-3.2/Drivers/AgateSDX/SDX_Surface.cs
Modified: branches/agate3d-3.2/Drivers/AgateSDX/SDX_Surface.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateSDX/SDX_Surface.cs 2009-05-13 16:48:44 UTC (rev 983)
+++ branches/agate3d-3.2/Drivers/AgateSDX/SDX_Surface.cs 2009-05-13 17:01:51 UTC (rev 984)
@@ -321,57 +321,16 @@
mDevice.Interpolation = InterpolationHint;
- if (TesselateFactor == 1)
- {
- SetVertsTextureCoordinates(mVerts, 0, srcRect);
- SetVertsColor(state.ColorGradient, mVerts, 0, 4);
- SetVertsPosition(mVerts, 0,
- new RectangleF(destX, destY,
- srcRect.Width * (float)state.ScaleWidth,
- srcRect.Height * (float)state.ScaleHeight),
- rotationCenter.X, rotationCenter.Y,
- state.DisplayAlignment, mRotationCos, mRotationSin);
+ SetVertsTextureCoordinates(mVerts, 0, srcRect);
+ SetVertsColor(state.ColorGradient, mVerts, 0, 4);
+ SetVertsPosition(mVerts, 0,
+ new RectangleF(destX, destY,
+ srcRect.Width * (float)state.ScaleWidth,
+ srcRect.Height * (float)state.ScaleHeight),
+ rotationCenter.X, rotationCenter.Y,
+ state.DisplayAlignment, mRotationCos, mRotationSin);
- mDevice.DrawBuffer.CacheDrawIndexedTriangles(mVerts, mIndices, mTexture.Value, alphaBlend);
- }
- else
- {
- TextureCoordinates texCoords = GetTextureCoordinates(mSrcRect);
- float texWidth = texCoords.Right - texCoords.Left;
- float texHeight = texCoords.Bottom - texCoords.Top;
-
- float displayWidth = displaySize.Width / (float)TesselateFactor;
- float displayHeight = displaySize.Height / (float)TesselateFactor;
-
- for (int j = 0; j < TesselateFactor; j++)
- {
- TextureCoordinates coords = texCoords;
- coords.Top = texCoords.Top + j * texHeight / TesselateFactor;
- coords.Bottom = coords.Top + texHeight / TesselateFactor;
-
- for (int i = 0; i < TesselateFactor; i++)
- {
- coords.Left = texCoords.Left + i * texWidth / TesselateFactor;
- coords.Right = coords.Left + texWidth / TesselateFactor;
-
- float dx = destX + i * displayWidth * mRotationCos + j * displayHeight * mRotationSin;
- float dy = destY - i * displayWidth * mRotationSin + j * displayHeight * mRotationCos;
-
- SetVertsPosition(mExtraVerts, 0,
- new RectangleF(dx, dy,
- displayWidth, displayHeight),
- rotationCenter.X, rotationCenter.Y,
- state.DisplayAlignment, mRotationCos, mRotationSin);
- SetVertsColor(state.ColorGradient, mExtraVerts, 0, 4,
- i / (double)TesselateFactor, j / (double)TesselateFactor, 1.0 / TesselateFactor, 1.0 / TesselateFactor);
-
- SetVertsTextureCoordinates(mExtraVerts, 0, coords);
-
- mDevice.DrawBuffer.CacheDrawIndexedTriangles(
- mExtraVerts, mIndices, mTexture.Value, alphaBlend);
- }
- }
- }
+ mDevice.DrawBuffer.CacheDrawIndexedTriangles(mVerts, mIndices, mTexture.Value, alphaBlend);
}
private void SetVertsTextureCoordinates(PositionTextureColor[] verts, int startIndex,
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ka...@us...> - 2009-05-13 16:48:49
|
Revision: 983
http://agate.svn.sourceforge.net/agate/?rev=983&view=rev
Author: kanato
Date: 2009-05-13 16:48:44 +0000 (Wed, 13 May 2009)
Log Message:
-----------
Update usage of VertexElement.DiffuseColor to correct name.
Modified Paths:
--------------
branches/agate3d-3.2/Drivers/AgateMDX/MDX1_VertexBuffer.cs
Modified: branches/agate3d-3.2/Drivers/AgateMDX/MDX1_VertexBuffer.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateMDX/MDX1_VertexBuffer.cs 2009-05-13 06:28:35 UTC (rev 982)
+++ branches/agate3d-3.2/Drivers/AgateMDX/MDX1_VertexBuffer.cs 2009-05-13 16:48:44 UTC (rev 983)
@@ -76,7 +76,7 @@
retval |= Microsoft.DirectX.Direct3D.VertexFormats.Texture3;
break;
- case VertexElement.Color:
+ case VertexElement.DiffuseColor:
retval |= Microsoft.DirectX.Direct3D.VertexFormats.Diffuse;
break;
}
@@ -144,7 +144,7 @@
case VertexElement.Tangent:
declUsage = Microsoft.DirectX.Direct3D.DeclarationUsage.Tangent;
break;
- case VertexElement.Color:
+ case VertexElement.DiffuseColor:
declUsage = Microsoft.DirectX.Direct3D.DeclarationUsage.Color;
break;
case VertexElement.Bitangent:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ka...@us...> - 2009-05-13 06:28:40
|
Revision: 982
http://agate.svn.sourceforge.net/agate/?rev=982&view=rev
Author: kanato
Date: 2009-05-13 06:28:35 +0000 (Wed, 13 May 2009)
Log Message:
-----------
Use a bitmap to get the size of the image file loaded in SDX_Surface.
Modified Paths:
--------------
branches/agate3d-3.2/Drivers/AgateSDX/SDX_Surface.cs
Modified: branches/agate3d-3.2/Drivers/AgateSDX/SDX_Surface.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateSDX/SDX_Surface.cs 2009-05-13 05:35:39 UTC (rev 981)
+++ branches/agate3d-3.2/Drivers/AgateSDX/SDX_Surface.cs 2009-05-13 06:28:35 UTC (rev 982)
@@ -139,13 +139,7 @@
mDisplay = Display.Impl as SDX_Display;
mDevice = mDisplay.D3D_Device;
- /*
- Bitmap bitmap = new Bitmap(size.Width, size.Height);
- Graphics g = Graphics.FromImage(bitmap);
- g.Clear(Color.FromArgb(0, 0, 0, 0));
- g.Dispose();
- */
- //mTexture = Texture.FromBitmap(mDevice, bitmap, Usage.None, Pool.Managed);
+
mTexture = new Ref<Texture>(new Texture(mDevice.Device, size.Width, size.Height, 1, Usage.None,
Format.A8R8G8B8, Pool.Managed));
@@ -198,12 +192,13 @@
Drawing.Bitmap bitmap = new Drawing.Bitmap(st);
mSrcRect = new Rectangle(Point.Empty, Interop.Convert(bitmap.Size));
+ bitmap.Dispose();
- // this is the speed issue fix in the debugger found on the net (thezbuffer.com has it documented)
- System.IO.MemoryStream stream = new System.IO.MemoryStream();
- bitmap.Save(stream, System.Drawing.Imaging.ImageFormat.Bmp);
+ //// this is the speed issue fix in the debugger found on the net (thezbuffer.com has it documented)
+ //System.IO.MemoryStream stream = new System.IO.MemoryStream();
+ //bitmap.Save(stream, System.Drawing.Imaging.ImageFormat.Bmp);
- stream.Position = 0;
+ st.Position = 0;
//mTexture = new Texture(mDevice, bitmap, Usage.None, Pool.Managed);
Format format;
@@ -226,13 +221,13 @@
}
mTexture = new Ref<Texture>(Texture.FromStream(mDevice.Device,
- stream, 0, 0, 1, Usage.None,
+ st, 0, 0, 1, Usage.None,
format, Pool.Managed, Filter.None, Filter.None, 0x00000000));
mTextureSize = new Size(mTexture.Value.GetSurfaceLevel(0).Description.Width,
mTexture.Value.GetSurfaceLevel(0).Description.Height);
- bitmap.Dispose();
+ //bitmap.Dispose();
}
public void LoadFromFile()
{
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ka...@us...> - 2009-05-13 05:35:46
|
Revision: 981
http://agate.svn.sourceforge.net/agate/?rev=981&view=rev
Author: kanato
Date: 2009-05-13 05:35:39 +0000 (Wed, 13 May 2009)
Log Message:
-----------
Eliminate use of normals in AgateSDX for drawing surfaces.
Move PositionColor and PositionTextureColor structures to AgateLib/Geometry/VertexTypes.
Modified Paths:
--------------
branches/agate3d-3.2/AgateLib/DisplayLib/Display.cs
branches/agate3d-3.2/AgateLib/DisplayLib/Light.cs
branches/agate3d-3.2/AgateLib/DisplayLib/LightManager.cs
branches/agate3d-3.2/AgateLib/DisplayLib/Surface.cs
branches/agate3d-3.2/AgateLib/Drivers/TypeID.cs
branches/agate3d-3.2/AgateLib/Geometry/VertexTypes/VertexLayout.cs
branches/agate3d-3.2/Drivers/AgateOTK/GL_Surface.cs
branches/agate3d-3.2/Drivers/AgateSDX/AgateSDX.csproj
branches/agate3d-3.2/Drivers/AgateSDX/D3DDevice.cs
branches/agate3d-3.2/Drivers/AgateSDX/DrawBuffer.cs
branches/agate3d-3.2/Drivers/AgateSDX/SDX_Display.cs
branches/agate3d-3.2/Drivers/AgateSDX/SDX_Surface.cs
branches/agate3d-3.2/Drivers/AgateSDX/SDX_VertexBuffer.cs
branches/agate3d-3.2/Tests/DisplayTests/PixelBufferTest/PixelBufferTest.cs
branches/agate3d-3.2/Tests/DisplayTests/TileTester/TileTester.cs
branches/agate3d-3.2/Tests/DisplayTests/TileTester/frmTileTester.Designer.cs
branches/agate3d-3.2/Tests/DisplayTests/TileTester/frmTileTester.cs
Added Paths:
-----------
branches/agate3d-3.2/AgateLib/Geometry/VertexTypes/PositionColor.cs
branches/agate3d-3.2/AgateLib/Geometry/VertexTypes/PositionTextureColor.cs
branches/agate3d-3.2/Drivers/AgateSDX/VertexFormats.cs
Removed Paths:
-------------
branches/agate3d-3.2/Drivers/AgateSDX/PositionColorNormalTexture.cs
Modified: branches/agate3d-3.2/AgateLib/DisplayLib/Display.cs
===================================================================
--- branches/agate3d-3.2/AgateLib/DisplayLib/Display.cs 2009-05-11 15:22:15 UTC (rev 980)
+++ branches/agate3d-3.2/AgateLib/DisplayLib/Display.cs 2009-05-13 05:35:39 UTC (rev 981)
@@ -276,6 +276,7 @@
throw new AgateException("The current window has been closed, and a new render target has not been set. A render target must be set to continue rendering.");
impl.BeginFrame();
+ mCurrentClipRect = new Rectangle(0, 0, RenderTarget.Width, RenderTarget.Height);
}
/// <summary>
/// EndFrame must be called at the end of each frame.
@@ -330,7 +331,7 @@
{
if (mClipRects.Count == 0)
{
- throw new Exception("You have popped the cliprect too many times.");
+ throw new AgateException("You have popped the cliprect too many times.");
}
else
{
Modified: branches/agate3d-3.2/AgateLib/DisplayLib/Light.cs
===================================================================
--- branches/agate3d-3.2/AgateLib/DisplayLib/Light.cs 2009-05-11 15:22:15 UTC (rev 980)
+++ branches/agate3d-3.2/AgateLib/DisplayLib/Light.cs 2009-05-13 05:35:39 UTC (rev 981)
@@ -27,6 +27,7 @@
/// Class which represents a single light source.
/// Only point light sources are supported at the moment.
/// </summary>
+ [Obsolete("Use shaders to accomplish lighting instead.")]
public class Light
{
private bool mEnabled = true;
Modified: branches/agate3d-3.2/AgateLib/DisplayLib/LightManager.cs
===================================================================
--- branches/agate3d-3.2/AgateLib/DisplayLib/LightManager.cs 2009-05-11 15:22:15 UTC (rev 980)
+++ branches/agate3d-3.2/AgateLib/DisplayLib/LightManager.cs 2009-05-13 05:35:39 UTC (rev 981)
@@ -27,6 +27,7 @@
/// The LightManager class keeps a list of Light objects which can be used
/// to setup the lighting in the rendering API.
/// </summary>
+ [Obsolete("Use shaders to accomplish lighting instead.")]
public class LightManager : IList<Light>
{
List<Light> mLights = new List<Light>();
Modified: branches/agate3d-3.2/AgateLib/DisplayLib/Surface.cs
===================================================================
--- branches/agate3d-3.2/AgateLib/DisplayLib/Surface.cs 2009-05-11 15:22:15 UTC (rev 980)
+++ branches/agate3d-3.2/AgateLib/DisplayLib/Surface.cs 2009-05-13 05:35:39 UTC (rev 981)
@@ -256,6 +256,7 @@
/// </para>
/// </remarks>
///
+ [Obsolete("Use shaders for lighting effects.")]
public int TesselateFactor
{
get { return impl.TesselateFactor; }
Modified: branches/agate3d-3.2/AgateLib/Drivers/TypeID.cs
===================================================================
--- branches/agate3d-3.2/AgateLib/Drivers/TypeID.cs 2009-05-11 15:22:15 UTC (rev 980)
+++ branches/agate3d-3.2/AgateLib/Drivers/TypeID.cs 2009-05-13 05:35:39 UTC (rev 981)
@@ -101,10 +101,9 @@
/// </summary>
DirectSound = 0x100,
/// <summary>
- /// Implementation using XNA Studio
- /// (what will this be called), anyway?)
+ /// Implementation using XAudio2, the new replacement for DirectSound.
/// </summary>
- XAct = 0x110,
+ XAudio2 = 0x110,
/// <summary>
/// Implementation using the cross-platform OpenAL library.
Added: branches/agate3d-3.2/AgateLib/Geometry/VertexTypes/PositionColor.cs
===================================================================
--- branches/agate3d-3.2/AgateLib/Geometry/VertexTypes/PositionColor.cs (rev 0)
+++ branches/agate3d-3.2/AgateLib/Geometry/VertexTypes/PositionColor.cs 2009-05-13 05:35:39 UTC (rev 981)
@@ -0,0 +1,37 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Runtime.InteropServices;
+using System.Text;
+
+namespace AgateLib.Geometry.VertexTypes
+{
+ [StructLayout(LayoutKind.Sequential)]
+ public struct PositionColor
+ {
+ public Vector3 Position;
+ public int Color;
+
+ public PositionColor(float x, float y, float z, Color color)
+ : this(x, y, z, color.ToArgb())
+ { }
+ public PositionColor(float x, float y, float z, int color)
+ {
+ Position = new Vector3(x, y, z);
+ this.Color = color;
+ }
+
+
+ public static VertexLayout VertexLayout
+ {
+ get
+ {
+ return new VertexLayout
+ {
+ new VertexElementDesc(VertexElementDataType.Float3, VertexElement.Position),
+ new VertexElementDesc(VertexElementDataType.Int, VertexElement.DiffuseColor),
+ };
+ }
+ }
+ }
+}
Added: branches/agate3d-3.2/AgateLib/Geometry/VertexTypes/PositionTextureColor.cs
===================================================================
--- branches/agate3d-3.2/AgateLib/Geometry/VertexTypes/PositionTextureColor.cs (rev 0)
+++ branches/agate3d-3.2/AgateLib/Geometry/VertexTypes/PositionTextureColor.cs 2009-05-13 05:35:39 UTC (rev 981)
@@ -0,0 +1,50 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Runtime.InteropServices;
+using System.Text;
+
+namespace AgateLib.Geometry.VertexTypes
+{
+ [StructLayout(LayoutKind.Sequential)]
+ public struct PositionTextureColor
+ {
+ public Vector3 Position;
+ public Vector2 TexCoord;
+ public int Color;
+
+ public PositionTextureColor(float x, float y, float z, Color color, float tu, float tv)
+ : this(x, y, z, color.ToArgb(), tu, tv)
+ { }
+ public PositionTextureColor(float x, float y, float z, int color, float tu, float tv)
+ {
+ Position = new Vector3(x, y, z);
+ TexCoord = new Vector2(tu, tv);
+ this.Color = color;
+ }
+
+ public float X { get { return Position.X; } set { Position.X = value; } }
+ public float Y { get { return Position.Y; } set { Position.Y = value; } }
+ public float Z { get { return Position.Z; } set { Position.Z = value; } }
+
+ public override string ToString()
+ {
+ return string.Format("X: {0} Y: {1} Z: {2} Color: {3} Tu: {4}, Tv: {5}",
+ Position.X, Position.Y, Position.Z, Color, TexCoord.X, TexCoord.Y);
+ }
+
+ public static VertexLayout VertexLayout
+ {
+ get
+ {
+ return new VertexLayout
+ {
+ new VertexElementDesc(VertexElementDataType.Float3, VertexElement.Position),
+ new VertexElementDesc(VertexElementDataType.Float2, VertexElement.Texture),
+ new VertexElementDesc(VertexElementDataType.Int, VertexElement.DiffuseColor),
+ };
+ }
+ }
+ }
+
+}
Modified: branches/agate3d-3.2/AgateLib/Geometry/VertexTypes/VertexLayout.cs
===================================================================
--- branches/agate3d-3.2/AgateLib/Geometry/VertexTypes/VertexLayout.cs 2009-05-11 15:22:15 UTC (rev 980)
+++ branches/agate3d-3.2/AgateLib/Geometry/VertexTypes/VertexLayout.cs 2009-05-13 05:35:39 UTC (rev 981)
@@ -55,6 +55,7 @@
case VertexElementDataType.Float2: return 2 * sizeof(float);
case VertexElementDataType.Float3: return 3 * sizeof(float);
case VertexElementDataType.Float4: return 4 * sizeof(float);
+ case VertexElementDataType.Int: return sizeof(int);
default: throw new NotImplementedException();
}
@@ -196,6 +197,7 @@
Float2,
Float3,
Float4,
+ Int,
}
public enum VertexElement
{
@@ -203,7 +205,7 @@
Normal,
Tangent,
Bitangent,
- Color,
+ DiffuseColor,
Texture,
Texture1,
Texture2,
Modified: branches/agate3d-3.2/Drivers/AgateOTK/GL_Surface.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateOTK/GL_Surface.cs 2009-05-11 15:22:15 UTC (rev 980)
+++ branches/agate3d-3.2/Drivers/AgateOTK/GL_Surface.cs 2009-05-13 05:35:39 UTC (rev 981)
@@ -157,7 +157,14 @@
int[] array = new int[1];
array[0] = mTextureID;
- GL.DeleteTextures(1, array);
+ try
+ {
+ GL.DeleteTextures(1, array);
+ }
+ catch (GraphicsContextMissingException)
+ {
+ System.Diagnostics.Debug.Print("Caught missing graphics context exception. Fix this someday.");
+ }
mTextureIDs.Remove(mTextureID);
}
Modified: branches/agate3d-3.2/Drivers/AgateSDX/AgateSDX.csproj
===================================================================
--- branches/agate3d-3.2/Drivers/AgateSDX/AgateSDX.csproj 2009-05-11 15:22:15 UTC (rev 980)
+++ branches/agate3d-3.2/Drivers/AgateSDX/AgateSDX.csproj 2009-05-13 05:35:39 UTC (rev 981)
@@ -90,9 +90,8 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\AgateLib\AgateLib.csproj">
+ <Project>{5E0F3C6E-5116-40FE-9F9C-3ECC3CBA9152}</Project>
<Name>AgateLib</Name>
- <Project>{C9CD5A49-13B1-4B31-8EB4-5EDBF6C3811D}</Project>
- <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
</ProjectReference>
<ProjectReference Include="..\AgateLib.WinForms\AgateLib.WinForms.csproj">
<Name>AgateLib.WinForms</Name>
@@ -122,7 +121,7 @@
</Compile>
<Compile Include="SDX_Input.cs" />
<Compile Include="SDX_Audio.cs" />
- <Compile Include="PositionColorNormalTexture.cs">
+ <Compile Include="VertexFormats.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Reporter.cs">
Modified: branches/agate3d-3.2/Drivers/AgateSDX/D3DDevice.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateSDX/D3DDevice.cs 2009-05-11 15:22:15 UTC (rev 980)
+++ branches/agate3d-3.2/Drivers/AgateSDX/D3DDevice.cs 2009-05-13 05:35:39 UTC (rev 981)
@@ -25,6 +25,7 @@
using AgateLib.DisplayLib;
using AgateLib.Geometry;
+using AgateLib.Geometry.VertexTypes;
using AgateLib.WinForms;
namespace AgateSDX
@@ -46,6 +47,7 @@
private int mMaxLightsUsed = 0;
+ private VertexDeclaration mSurfaceDecl;
//VertexBuffer mSurfaceVB;
//const int NumVertices = 1000;
@@ -60,6 +62,10 @@
//mDevice.DeviceLost += new EventHandler(mDevice_DeviceLost);
mDrawBuffer = new DrawBuffer(this);
+
+ mSurfaceDecl = SDX_VertexBuffer.CreateVertexDeclaration(
+ device, PositionTextureColor.VertexLayout);
+
}
~D3DDevice()
@@ -67,7 +73,10 @@
Dispose(false);
}
-
+ public void SetVertexDeclarationForSurfaces()
+ {
+ mDevice.VertexDeclaration = mSurfaceDecl;
+ }
void mDevice_DeviceLost(object sender, EventArgs e)
{
// set weird values which will indicate that the device's
Modified: branches/agate3d-3.2/Drivers/AgateSDX/DrawBuffer.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateSDX/DrawBuffer.cs 2009-05-11 15:22:15 UTC (rev 980)
+++ branches/agate3d-3.2/Drivers/AgateSDX/DrawBuffer.cs 2009-05-13 05:35:39 UTC (rev 981)
@@ -24,6 +24,7 @@
using SlimDX.Direct3D9;
using Direct3D = SlimDX.Direct3D9;
using AgateLib.DisplayLib;
+using AgateLib.Geometry.VertexTypes;
namespace AgateSDX
{
@@ -38,7 +39,7 @@
D3DDevice mDevice;
- PositionColorNormalTexture[] mVerts;
+ PositionTextureColor[] mVerts;
short[] mIndices;
int mVertPointer = 0;
@@ -56,10 +57,10 @@
private void AllocateVerts()
{
- mVerts = new PositionColorNormalTexture[vertPageSize * pages];
+ mVerts = new PositionTextureColor[vertPageSize * pages];
mIndices = new short[vertPageSize / 2 * 3 * pages];
}
- public void CacheDrawIndexedTriangles(PositionColorNormalTexture[] verts, short[] indices,
+ public void CacheDrawIndexedTriangles(PositionTextureColor[] verts, short[] indices,
Texture texture, bool alphaBlend)
{
if (mTexture != texture || mAlphaBlend != alphaBlend)
@@ -99,14 +100,14 @@
mDevice.SetDeviceStateTexture(mTexture);
mDevice.AlphaBlend = mAlphaBlend;
- mDevice.VertexFormat = PositionColorNormalTexture.Format;
+ mDevice.SetVertexDeclarationForSurfaces();
try
{
mDevice.Device.DrawIndexedUserPrimitives
(Direct3D.PrimitiveType.TriangleList, 0, mVertPointer,
mIndexPointer / 3, mIndices, Format.Index16, mVerts,
- Marshal.SizeOf(typeof(PositionColorNormalTexture)));
+ Marshal.SizeOf(typeof(PositionTextureColor)));
}
catch { }
Deleted: branches/agate3d-3.2/Drivers/AgateSDX/PositionColorNormalTexture.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateSDX/PositionColorNormalTexture.cs 2009-05-11 15:22:15 UTC (rev 980)
+++ branches/agate3d-3.2/Drivers/AgateSDX/PositionColorNormalTexture.cs 2009-05-13 05:35:39 UTC (rev 981)
@@ -1,89 +0,0 @@
-// The contents of this file are subject to the Mozilla Public License
-// Version 1.1 (the "License"); you may not use this file except in
-// compliance with the License. You may obtain a copy of the License at
-// http://www.mozilla.org/MPL/
-//
-// Software distributed under the License is distributed on an "AS IS"
-// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
-// License for the specific language governing rights and limitations
-// under the License.
-//
-// The Original Code is AgateLib.
-//
-// The Initial Developer of the Original Code is Erik Ylvisaker.
-// Portions created by Erik Ylvisaker are Copyright (C) 2006-2009.
-// All Rights Reserved.
-//
-// Contributor(s): Erik Ylvisaker
-//
-using System;
-using System.Collections.Generic;
-using System.Text;
-using System.Runtime.InteropServices;
-using SlimDX;
-using SlimDX.Direct3D9;
-
-namespace AgateSDX
-{
- [StructLayout(LayoutKind.Sequential)]
- public struct PositionColorNormalTexture
- {
- public float X, Y, Z;
- public float nx, ny, nz;
- public int Color;
- public float Tu, Tv;
-
- public static VertexFormat Format =
- VertexFormat.PositionNormal | VertexFormat.Diffuse | VertexFormat.Texture1;
-
- public PositionColorNormalTexture(float x, float y, float z, int color, float tu, float tv,
- float nx, float ny, float nz)
- {
- X = x;
- Y = y;
- Z = z;
- Color = color;
- Tu = tu;
- Tv = tv;
- this.nx = nx;
- this.ny = ny;
- this.nz = nz;
- }
-
- public override string ToString()
- {
- return string.Format("X: {0} Y: {1} Z: {2} Color: {3} Tu: {4}, Tv: {5}",
- X, Y, Z, Color, Tu, Tv);
- }
- }
-
- [StructLayout(LayoutKind.Sequential)]
- public struct PositionColored
- {
- public float x, y, z;
- public int Color;
-
- public Vector3 Position
- {
- get { return new Vector3(x, y, z); }
- set
- {
- x = value.X;
- y = value.Y;
- z = value.Z;
- }
- }
- public PositionColored(float x, float y, float z, AgateLib.Geometry.Color clr)
- : this(x, y, z, clr.ToArgb())
- { }
- public PositionColored(float x, float y, float z, int clr)
- {
- this.x = x;
- this.y = y;
- this.z = z;
- this.Color = clr;
- }
- public static VertexFormat Format =
- VertexFormat.Position | VertexFormat.Diffuse;
- }
-}
Modified: branches/agate3d-3.2/Drivers/AgateSDX/SDX_Display.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateSDX/SDX_Display.cs 2009-05-11 15:22:15 UTC (rev 980)
+++ branches/agate3d-3.2/Drivers/AgateSDX/SDX_Display.cs 2009-05-13 05:35:39 UTC (rev 981)
@@ -27,6 +27,7 @@
using AgateLib.DisplayLib;
using AgateLib.Drivers;
using AgateLib.Geometry;
+using AgateLib.Geometry.VertexTypes;
using AgateLib.ImplementationBase;
using AgateLib.WinForms;
@@ -47,8 +48,8 @@
private bool mInitialized = false;
// variables for drawing primitives
- PositionColored[] mLines = new PositionColored[5];
- PositionColored[] mFillRectVerts = new PositionColored[6];
+ PositionColor[] mLines = new PositionColor[5];
+ PositionColor[] mFillRectVerts = new PositionColor[6];
private bool mVSync = true;
@@ -57,8 +58,15 @@
private float mDepthClear = 1.0f;
private int mStencilClear = 0;
+ VertexDeclaration mPosColorDecl;
+
#endregion
+ public VertexDeclaration SurfaceDeclaration
+ {
+ get { return mPosColorDecl; }
+ }
+
public DisplayMode DisplayMode
{
get
@@ -131,6 +139,7 @@
InitializeShaders();
+ mPosColorDecl = SDX_VertexBuffer.CreateVertexDeclaration(device, PositionColor.VertexLayout);
}
private void SetHaveDepthStencil(Format depthFormat)
@@ -375,10 +384,10 @@
{
mDevice.DrawBuffer.Flush();
- mLines[0] = new PositionColored(a.X, a.Y, 0, color.ToArgb());
- mLines[1] = new PositionColored(b.X, b.Y, 0, color.ToArgb());
+ mLines[0] = new PositionColor(a.X, a.Y, 0, color.ToArgb());
+ mLines[1] = new PositionColor(b.X, b.Y, 0, color.ToArgb());
- mDevice.VertexFormat = PositionColored.Format;
+ mDevice.Device.VertexDeclaration = mPosColorDecl;
mDevice.Device.DrawUserPrimitives(SlimDX.Direct3D9.PrimitiveType.LineList, 1, mLines);
}
public override void DrawLines(Point[] pt, Color color)
@@ -386,14 +395,14 @@
mDevice.DrawBuffer.Flush();
if (pt.Length > mLines.Length)
- mLines = new PositionColored[pt.Length];
+ mLines = new PositionColor[pt.Length];
for (int i = 0; i < pt.Length; i++)
{
- mLines[i] = new PositionColored(pt[i].X, pt[i].Y, 0, color.ToArgb());
+ mLines[i] = new PositionColor(pt[i].X, pt[i].Y, 0, color.ToArgb());
}
- mDevice.VertexFormat = PositionColored.Format;
+ mDevice.Device.VertexDeclaration = mPosColorDecl;
mDevice.Device.DrawUserPrimitives(Direct3D.PrimitiveType.LineList, pt.Length / 2, mLines);
}
public override void DrawRect(Rectangle rect, Color color)
@@ -406,13 +415,13 @@
int c = color.ToArgb();
- mLines[0] = new PositionColored(rect.X, rect.Y, 0, c);
- mLines[1] = new PositionColored(rect.Right, rect.Y, 0, c);
- mLines[2] = new PositionColored(rect.Right, rect.Bottom, 0, c);
- mLines[3] = new PositionColored(rect.X, rect.Bottom, 0, c);
- mLines[4] = new PositionColored(rect.X, rect.Y, 0, c);
-
- mDevice.VertexFormat = PositionColored.Format;
+ mLines[0] = new PositionColor(rect.X, rect.Y, 0, c);
+ mLines[1] = new PositionColor(rect.Right, rect.Y, 0, c);
+ mLines[2] = new PositionColor(rect.Right, rect.Bottom, 0, c);
+ mLines[3] = new PositionColor(rect.X, rect.Bottom, 0, c);
+ mLines[4] = new PositionColor(rect.X, rect.Y, 0, c);
+
+ mDevice.Device.VertexDeclaration = mPosColorDecl;
mDevice.Device.DrawUserPrimitives(Direct3D.PrimitiveType.LineStrip, 4, mLines);
}
@@ -431,18 +440,18 @@
public override void FillRect(RectangleF rect, Gradient color)
{
// defining our screen sized quad, note the Z value of 1f to place it in the background
- mFillRectVerts[0].Position = new SlimDX.Vector3(rect.Left, rect.Top, 0f);
+ mFillRectVerts[0].Position = new AgateLib.Geometry.Vector3(rect.Left, rect.Top, 0f);
mFillRectVerts[0].Color = color.TopLeft.ToArgb();
- mFillRectVerts[1].Position = new SlimDX.Vector3(rect.Right, rect.Top, 0f);
+ mFillRectVerts[1].Position = new AgateLib.Geometry.Vector3(rect.Right, rect.Top, 0f);
mFillRectVerts[1].Color = color.TopRight.ToArgb();
- mFillRectVerts[2].Position = new SlimDX.Vector3(rect.Left, rect.Bottom, 0f);
+ mFillRectVerts[2].Position = new AgateLib.Geometry.Vector3(rect.Left, rect.Bottom, 0f);
mFillRectVerts[2].Color = color.BottomLeft.ToArgb();
mFillRectVerts[3] = mFillRectVerts[1];
- mFillRectVerts[4].Position = new SlimDX.Vector3(rect.Right, rect.Bottom, 0f);
+ mFillRectVerts[4].Position = new AgateLib.Geometry.Vector3(rect.Right, rect.Bottom, 0f);
mFillRectVerts[4].Color = color.BottomRight.ToArgb();
mFillRectVerts[5] = mFillRectVerts[2];
@@ -454,7 +463,7 @@
mDevice.SetDeviceStateTexture(null);
mDevice.AlphaArgument1 = TextureArgument.Diffuse;
- mDevice.VertexFormat = PositionColored.Format;
+ mDevice.Device.VertexDeclaration = mPosColorDecl;
mDevice.Device.DrawUserPrimitives(Direct3D.PrimitiveType.TriangleList, 2, mFillRectVerts);
mDevice.AlphaArgument1 = TextureArgument.Texture;
}
Modified: branches/agate3d-3.2/Drivers/AgateSDX/SDX_Surface.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateSDX/SDX_Surface.cs 2009-05-11 15:22:15 UTC (rev 980)
+++ branches/agate3d-3.2/Drivers/AgateSDX/SDX_Surface.cs 2009-05-13 05:35:39 UTC (rev 981)
@@ -22,23 +22,24 @@
using System.Runtime.InteropServices;
using System.Text;
-using SlimDX.Direct3D9;
using SlimDX;
+using SlimDX.Direct3D9;
+using Direct3D = SlimDX.Direct3D9;
using AgateLib.DisplayLib;
using AgateLib.Geometry;
+using AgateLib.Geometry.VertexTypes;
using AgateLib.ImplementationBase;
using AgateLib.Utility;
using AgateLib.WinForms;
using Drawing = System.Drawing;
using ImageFileFormat = AgateLib.DisplayLib.ImageFileFormat;
-using Direct3D = SlimDX.Direct3D9;
using Surface = AgateLib.DisplayLib.Surface;
+using Vector2 = AgateLib.Geometry.Vector2;
namespace AgateSDX
{
-
public class SDX_Surface : SurfaceImpl, SDX_IRenderTarget
{
#region --- Private Variables ---
@@ -57,10 +58,10 @@
float mRotationCos = 1.0f;
float mRotationSin = 0.0f;
- PositionColorNormalTexture[] mVerts = new PositionColorNormalTexture[4];
+ PositionTextureColor[] mVerts = new PositionTextureColor[4];
short[] mIndices = new short[] { 0, 2, 1, 1, 2, 3 };
- PositionColorNormalTexture[] mExtraVerts = new PositionColorNormalTexture[4];
+ PositionTextureColor[] mExtraVerts = new PositionTextureColor[4];
short[] mExtraIndices = new short[] { 0, 2, 1, 1, 2, 3 };
#endregion
@@ -378,7 +379,7 @@
}
}
- private void SetVertsTextureCoordinates(PositionColorNormalTexture[] verts, int startIndex,
+ private void SetVertsTextureCoordinates(PositionTextureColor[] verts, int startIndex,
Rectangle srcRect)
{
TextureCoordinates texCoords = GetTextureCoordinates(srcRect);
@@ -386,20 +387,13 @@
SetVertsTextureCoordinates(verts, startIndex, texCoords);
}
- private void SetVertsTextureCoordinates(PositionColorNormalTexture[] verts, int startIndex,
+ private void SetVertsTextureCoordinates(PositionTextureColor[] verts, int startIndex,
TextureCoordinates texCoords)
{
- verts[startIndex].Tu = texCoords.Left;
- verts[startIndex].Tv = texCoords.Top;
-
- verts[startIndex + 1].Tu = texCoords.Right;
- verts[startIndex + 1].Tv = texCoords.Top;
-
- verts[startIndex + 2].Tu = texCoords.Left;
- verts[startIndex + 2].Tv = texCoords.Bottom;
-
- verts[startIndex + 3].Tu = texCoords.Right;
- verts[startIndex + 3].Tv = texCoords.Bottom;
+ verts[startIndex].TexCoord = new Vector2(texCoords.Left, texCoords.Top);
+ verts[startIndex + 1].TexCoord = new Vector2(texCoords.Right, texCoords.Top);
+ verts[startIndex + 2].TexCoord = new Vector2(texCoords.Left, texCoords.Bottom);
+ verts[startIndex + 3].TexCoord = new Vector2(texCoords.Right, texCoords.Bottom);
}
private TextureCoordinates GetTextureCoordinates(Rectangle srcRect)
@@ -429,14 +423,14 @@
return texCoords;
}
- private void SetVertsColor(Gradient ColorGradient, PositionColorNormalTexture[] verts, int startIndex, int count)
+ private void SetVertsColor(Gradient ColorGradient, PositionTextureColor[] verts, int startIndex, int count)
{
verts[startIndex].Color = ColorGradient.TopLeft.ToArgb();
verts[startIndex + 1].Color = ColorGradient.TopRight.ToArgb();
verts[startIndex + 2].Color = ColorGradient.BottomLeft.ToArgb();
verts[startIndex + 3].Color = ColorGradient.BottomRight.ToArgb();
}
- private void SetVertsColor(Gradient ColorGradient, PositionColorNormalTexture[] verts, int startIndex, int count,
+ private void SetVertsColor(Gradient ColorGradient, PositionTextureColor[] verts, int startIndex, int count,
double x, double y, double width, double height)
{
verts[startIndex].Color = ColorGradient.Interpolate(x, y).ToArgb();
@@ -445,7 +439,7 @@
verts[startIndex + 3].Color = ColorGradient.Interpolate(x + width, y + height).ToArgb();
}
- private void SetVertsPosition(PositionColorNormalTexture[] verts, int index,
+ private void SetVertsPosition(PositionTextureColor[] verts, int index,
RectangleF dest, float rotationCenterX, float rotationCenterY,
OriginAlignment DisplayAlignment,
float mRotationCos, float mRotationSin)
@@ -455,7 +449,6 @@
float destWidth = dest.Width;
float destHeight = dest.Height;
-
mCenterPoint = Origin.CalcF(DisplayAlignment, dest.Size);
destX += rotationCenterX - mCenterPoint.X;
@@ -489,12 +482,6 @@
verts[index + 3].Y = -mRotationSin * (-rotationCenterX + destWidth) +
mRotationCos * (-rotationCenterY + destHeight) + destY;
- for (int i = 0; i < 4; i++)
- {
- verts[index + i].nx = 0;
- verts[index + i].ny = 0;
- verts[index + i].nz = -1;
- }
}
Modified: branches/agate3d-3.2/Drivers/AgateSDX/SDX_VertexBuffer.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateSDX/SDX_VertexBuffer.cs 2009-05-11 15:22:15 UTC (rev 980)
+++ branches/agate3d-3.2/Drivers/AgateSDX/SDX_VertexBuffer.cs 2009-05-13 05:35:39 UTC (rev 981)
@@ -15,25 +15,18 @@
SDX_Display mDisplay;
Direct3D.VertexBuffer mBuffer;
Direct3D.VertexDeclaration mDeclaration;
- Direct3D.VertexFormat mFormats;
int mCount;
object data;
VertexLayout mLayout;
- static StringBuilder b;
-
public SDX_VertexBuffer(SDX_Display display, VertexLayout layout, int vertexCount)
{
mDisplay = display;
mCount = vertexCount;
- b = new StringBuilder();
+ mDeclaration = CreateVertexDeclaration(mDisplay.D3D_Device.Device, layout);
+ Direct3D.VertexFormat mFormats = CreateVertexFormat(layout);
- mDeclaration = CreateVertexDeclaration(layout);
- mFormats = CreateVertexFormat(layout);
-
- System.Diagnostics.Debug.WriteLine(b.ToString());
-
mLayout = layout;
mBuffer = new SlimDX.Direct3D9.VertexBuffer(
@@ -76,7 +69,7 @@
retval |= SlimDX.Direct3D9.VertexFormat.Texture3;
break;
- case VertexElement.Color:
+ case VertexElement.DiffuseColor:
retval |= SlimDX.Direct3D9.VertexFormat.Diffuse;
break;
}
@@ -84,7 +77,7 @@
return retval;
}
- private Direct3D.VertexDeclaration CreateVertexDeclaration(VertexLayout layout)
+ public static Direct3D.VertexDeclaration CreateVertexDeclaration(Direct3D.Device d3dDevice, VertexLayout layout)
{
List<Direct3D.VertexElement> formats = new List<Direct3D.VertexElement>();
short loc = 0;
@@ -100,10 +93,9 @@
formats.Add(Direct3D.VertexElement.VertexDeclarationEnd);
- return new Direct3D.VertexDeclaration(
- mDisplay.D3D_Device.Device, formats.ToArray());
+ return new Direct3D.VertexDeclaration(d3dDevice, formats.ToArray());
}
- private Direct3D.VertexElement ConvertElement(VertexElementDesc element, ref short loc)
+ private static Direct3D.VertexElement ConvertElement(VertexElementDesc element, ref short loc)
{
Direct3D.DeclarationMethod declMethod = SlimDX.Direct3D9.DeclarationMethod.Default;
Direct3D.DeclarationUsage declUsage;
@@ -125,6 +117,9 @@
case VertexElementDataType.Float4:
declType = SlimDX.Direct3D9.DeclarationType.Float4;
break;
+ case VertexElementDataType.Int:
+ declType = SlimDX.Direct3D9.DeclarationType.Color;
+ break;
default:
throw new NotImplementedException(
element.DataType.ToString() + " not implemented.");
@@ -144,7 +139,7 @@
case VertexElement.Tangent:
declUsage = SlimDX.Direct3D9.DeclarationUsage.Tangent;
break;
- case VertexElement.Color:
+ case VertexElement.DiffuseColor:
declUsage = SlimDX.Direct3D9.DeclarationUsage.Color;
break;
case VertexElement.Bitangent:
@@ -155,8 +150,6 @@
element.ElementType.ToString() + " not implemented.");
}
- b.AppendFormat("{0} {1} {2} {3}\n", declType, declUsage, loc, size);
-
loc += (short)size;
return new Direct3D.VertexElement(0, (short)(loc - size), declType, declMethod, declUsage, 0);
Copied: branches/agate3d-3.2/Drivers/AgateSDX/VertexFormats.cs (from rev 979, branches/agate3d-3.2/Drivers/AgateSDX/PositionColorNormalTexture.cs)
===================================================================
--- branches/agate3d-3.2/Drivers/AgateSDX/VertexFormats.cs (rev 0)
+++ branches/agate3d-3.2/Drivers/AgateSDX/VertexFormats.cs 2009-05-13 05:35:39 UTC (rev 981)
@@ -0,0 +1,90 @@
+// The contents of this file are subject to the Mozilla Public License
+// Version 1.1 (the "License"); you may not use this file except in
+// compliance with the License. You may obtain a copy of the License at
+// http://www.mozilla.org/MPL/
+//
+// Software distributed under the License is distributed on an "AS IS"
+// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+// License for the specific language governing rights and limitations
+// under the License.
+//
+// The Original Code is AgateLib.
+//
+// The Initial Developer of the Original Code is Erik Ylvisaker.
+// Portions created by Erik Ylvisaker are Copyright (C) 2006-2009.
+// All Rights Reserved.
+//
+// Contributor(s): Erik Ylvisaker
+//
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Runtime.InteropServices;
+using SlimDX;
+using SlimDX.Direct3D9;
+
+namespace AgateSDX
+{
+ /*
+ public struct DX_PositionColorNormalTexture
+ {
+ public float X, Y, Z;
+ public float nx, ny, nz;
+ public int Color;
+ public float Tu, Tv;
+
+ public static VertexFormat Format =
+ VertexFormat.PositionNormal | VertexFormat.Diffuse | VertexFormat.Texture1;
+
+ public PositionColorNormalTexture(float x, float y, float z, int color, float tu, float tv,
+ float nx, float ny, float nz)
+ {
+ X = x;
+ Y = y;
+ Z = z;
+ Color = color;
+ Tu = tu;
+ Tv = tv;
+ this.nx = nx;
+ this.ny = ny;
+ this.nz = nz;
+ }
+
+ public override string ToString()
+ {
+ return string.Format("X: {0} Y: {1} Z: {2} Color: {3} Tu: {4}, Tv: {5}",
+ X, Y, Z, Color, Tu, Tv);
+ }
+ }
+
+ [StructLayout(LayoutKind.Sequential)]
+ public struct PositionColored
+ {
+ public float x, y, z;
+ public int Color;
+
+ public Vector3 Position
+ {
+ get { return new Vector3(x, y, z); }
+ set
+ {
+ x = value.X;
+ y = value.Y;
+ z = value.Z;
+ }
+ }
+ public PositionColored(float x, float y, float z, AgateLib.Geometry.Color clr)
+ : this(x, y, z, clr.ToArgb())
+ { }
+ public PositionColored(float x, float y, float z, int clr)
+ {
+ this.x = x;
+ this.y = y;
+ this.z = z;
+ this.Color = clr;
+ }
+ public static VertexFormat Format =
+ VertexFormat.Position | VertexFormat.Diffuse;
+ }
+ * */
+}
Modified: branches/agate3d-3.2/Tests/DisplayTests/PixelBufferTest/PixelBufferTest.cs
===================================================================
--- branches/agate3d-3.2/Tests/DisplayTests/PixelBufferTest/PixelBufferTest.cs 2009-05-11 15:22:15 UTC (rev 980)
+++ branches/agate3d-3.2/Tests/DisplayTests/PixelBufferTest/PixelBufferTest.cs 2009-05-13 05:35:39 UTC (rev 981)
@@ -37,7 +37,7 @@
DisplayWindow wind = new DisplayWindow(CreateWindowParams.FromControl(frm.panel1));
image = new Surface("9ball.png");
- buffer = image.ReadPixels(PixelFormat.RGBA8888);
+ buffer = image.ReadPixels(PixelFormat.Any);
Mouse.MouseDown += new InputEventHandler(Mouse_MouseDown);
Mouse.MouseMove += new InputEventHandler(Mouse_MouseMove);
Modified: branches/agate3d-3.2/Tests/DisplayTests/TileTester/TileTester.cs
===================================================================
--- branches/agate3d-3.2/Tests/DisplayTests/TileTester/TileTester.cs 2009-05-11 15:22:15 UTC (rev 980)
+++ branches/agate3d-3.2/Tests/DisplayTests/TileTester/TileTester.cs 2009-05-13 05:35:39 UTC (rev 981)
@@ -45,15 +45,17 @@
Display.EndFrame();
Core.KeepAlive();
+ // move at 100 pixels per second
if (frm.ScrollX)
{
- xval += (float)Display.DeltaTime / 20.0f;
+ xval += (float)Display.DeltaTime / 10.0f;
}
if (frm.ScrollY)
{
- // move at 50 pixels per second
- yval += (float)Display.DeltaTime / 20.0f;
+ yval += (float)Display.DeltaTime / 10.0f;
}
+
+ frm.FPS = Display.FramesPerSecond;
}
}
}
Modified: branches/agate3d-3.2/Tests/DisplayTests/TileTester/frmTileTester.Designer.cs
===================================================================
--- branches/agate3d-3.2/Tests/DisplayTests/TileTester/frmTileTester.Designer.cs 2009-05-11 15:22:15 UTC (rev 980)
+++ branches/agate3d-3.2/Tests/DisplayTests/TileTester/frmTileTester.Designer.cs 2009-05-13 05:35:39 UTC (rev 981)
@@ -32,6 +32,8 @@
this.agateRenderTarget1 = new AgateLib.WinForms.AgateRenderTarget();
this.chkScrollX = new System.Windows.Forms.CheckBox();
this.chkScrollY = new System.Windows.Forms.CheckBox();
+ this.chkVSync = new System.Windows.Forms.CheckBox();
+ this.lblFPS = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// agateRenderTarget1
@@ -63,16 +65,38 @@
this.chkScrollY.Text = "Scroll Y";
this.chkScrollY.UseVisualStyleBackColor = true;
//
- // Form1
+ // chkVSync
//
+ this.chkVSync.AutoSize = true;
+ this.chkVSync.Location = new System.Drawing.Point(380, 58);
+ this.chkVSync.Name = "chkVSync";
+ this.chkVSync.Size = new System.Drawing.Size(57, 17);
+ this.chkVSync.TabIndex = 3;
+ this.chkVSync.Text = "VSync";
+ this.chkVSync.UseVisualStyleBackColor = true;
+ this.chkVSync.CheckedChanged += new System.EventHandler(this.chkVSync_CheckedChanged);
+ //
+ // lblFPS
+ //
+ this.lblFPS.AutoSize = true;
+ this.lblFPS.Location = new System.Drawing.Point(380, 412);
+ this.lblFPS.Name = "lblFPS";
+ this.lblFPS.Size = new System.Drawing.Size(27, 13);
+ this.lblFPS.TabIndex = 4;
+ this.lblFPS.Text = "FPS";
+ //
+ // frmTileTester
+ //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(502, 437);
+ this.Controls.Add(this.lblFPS);
+ this.Controls.Add(this.chkVSync);
this.Controls.Add(this.chkScrollY);
this.Controls.Add(this.chkScrollX);
this.Controls.Add(this.agateRenderTarget1);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
- this.Name = "Form1";
+ this.Name = "frmTileTester";
this.Text = "Tile Tester";
this.ResumeLayout(false);
this.PerformLayout();
@@ -84,6 +108,8 @@
private AgateLib.WinForms.AgateRenderTarget agateRenderTarget1;
private System.Windows.Forms.CheckBox chkScrollX;
private System.Windows.Forms.CheckBox chkScrollY;
+ private System.Windows.Forms.CheckBox chkVSync;
+ private System.Windows.Forms.Label lblFPS;
}
}
Modified: branches/agate3d-3.2/Tests/DisplayTests/TileTester/frmTileTester.cs
===================================================================
--- branches/agate3d-3.2/Tests/DisplayTests/TileTester/frmTileTester.cs 2009-05-11 15:22:15 UTC (rev 980)
+++ branches/agate3d-3.2/Tests/DisplayTests/TileTester/frmTileTester.cs 2009-05-13 05:35:39 UTC (rev 981)
@@ -14,10 +14,11 @@
public frmTileTester()
{
InitializeComponent();
-
+
CreateControl();
DisplayWindow wind = DisplayWindow.CreateFromControl(agateRenderTarget1);
+ chkVSync.Checked = Display.VSync;
}
public bool ScrollX
@@ -30,5 +31,16 @@
get { return chkScrollY.Checked; }
set { chkScrollY.Checked = value; }
}
+ public double FPS
+ {
+ set
+ {
+ lblFPS.Text = "FPS: " + value.ToString("0.0");
+ }
+ }
+ private void chkVSync_CheckedChanged(object sender, EventArgs e)
+ {
+ Display.VSync = chkVSync.Checked;
+ }
}
}
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ka...@us...> - 2009-05-11 15:22:24
|
Revision: 980
http://agate.svn.sourceforge.net/agate/?rev=980&view=rev
Author: kanato
Date: 2009-05-11 15:22:15 +0000 (Mon, 11 May 2009)
Log Message:
-----------
Add STAThread attribute to launcher's main method.
Fix audio player so play nice with example launcher.
Modified Paths:
--------------
branches/agate3d-3.2/Tests/AudioTests/AudioPlayer/AudioPlayer.cs
branches/agate3d-3.2/Tests/Launcher.cs
Modified: branches/agate3d-3.2/Tests/AudioTests/AudioPlayer/AudioPlayer.cs
===================================================================
--- branches/agate3d-3.2/Tests/AudioTests/AudioPlayer/AudioPlayer.cs 2009-05-11 15:17:03 UTC (rev 979)
+++ branches/agate3d-3.2/Tests/AudioTests/AudioPlayer/AudioPlayer.cs 2009-05-11 15:22:15 UTC (rev 980)
@@ -22,7 +22,7 @@
if (setup.WasCanceled)
return;
- Application.Run(new frmAudioTester());
+ new frmAudioTester().ShowDialog();
}
}
Modified: branches/agate3d-3.2/Tests/Launcher.cs
===================================================================
--- branches/agate3d-3.2/Tests/Launcher.cs 2009-05-11 15:17:03 UTC (rev 979)
+++ branches/agate3d-3.2/Tests/Launcher.cs 2009-05-11 15:22:15 UTC (rev 980)
@@ -9,6 +9,7 @@
{
class Launcher
{
+ [STAThread]
public static void Main(string[] args)
{
AgateFileProvider.Assemblies.AddPath("../Drivers");
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ka...@us...> - 2009-05-11 15:17:13
|
Revision: 979
http://agate.svn.sourceforge.net/agate/?rev=979&view=rev
Author: kanato
Date: 2009-05-11 15:17:03 +0000 (Mon, 11 May 2009)
Log Message:
-----------
SlimDX Audio implementation initial commit. Correct namespace to be AgateSDX.
Modified Paths:
--------------
branches/agate3d-3.2/Drivers/AgateSDX/AgateSDX.csproj
branches/agate3d-3.2/Drivers/AgateSDX/D3DDevice.cs
branches/agate3d-3.2/Drivers/AgateSDX/DrawBuffer.cs
branches/agate3d-3.2/Drivers/AgateSDX/HlslCompiler.cs
branches/agate3d-3.2/Drivers/AgateSDX/HlslShaderProgram.cs
branches/agate3d-3.2/Drivers/AgateSDX/PositionColorNormalTexture.cs
branches/agate3d-3.2/Drivers/AgateSDX/Reporter.cs
branches/agate3d-3.2/Drivers/AgateSDX/SDX_Display.cs
branches/agate3d-3.2/Drivers/AgateSDX/SDX_DisplayWindow.cs
branches/agate3d-3.2/Drivers/AgateSDX/SDX_IRenderTarget.cs
branches/agate3d-3.2/Drivers/AgateSDX/SDX_IndexBuffer.cs
branches/agate3d-3.2/Drivers/AgateSDX/SDX_Input.cs
branches/agate3d-3.2/Drivers/AgateSDX/SDX_Surface.cs
branches/agate3d-3.2/Drivers/AgateSDX/SDX_VertexBuffer.cs
branches/agate3d-3.2/Drivers/AgateSDX/frmFullScreen.Designer.cs
branches/agate3d-3.2/Drivers/AgateSDX/frmFullScreen.cs
Added Paths:
-----------
branches/agate3d-3.2/Drivers/AgateSDX/SDX_Audio.cs
Modified: branches/agate3d-3.2/Drivers/AgateSDX/AgateSDX.csproj
===================================================================
--- branches/agate3d-3.2/Drivers/AgateSDX/AgateSDX.csproj 2009-05-11 14:22:20 UTC (rev 978)
+++ branches/agate3d-3.2/Drivers/AgateSDX/AgateSDX.csproj 2009-05-11 15:17:03 UTC (rev 979)
@@ -120,6 +120,8 @@
<Compile Include="HlslShaderProgram.cs">
<SubType>Code</SubType>
</Compile>
+ <Compile Include="SDX_Input.cs" />
+ <Compile Include="SDX_Audio.cs" />
<Compile Include="PositionColorNormalTexture.cs">
<SubType>Code</SubType>
</Compile>
Modified: branches/agate3d-3.2/Drivers/AgateSDX/D3DDevice.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateSDX/D3DDevice.cs 2009-05-11 14:22:20 UTC (rev 978)
+++ branches/agate3d-3.2/Drivers/AgateSDX/D3DDevice.cs 2009-05-11 15:17:03 UTC (rev 979)
@@ -27,7 +27,7 @@
using AgateLib.Geometry;
using AgateLib.WinForms;
-namespace AgateMDX
+namespace AgateSDX
{
public class D3DDevice : IDisposable
{
Modified: branches/agate3d-3.2/Drivers/AgateSDX/DrawBuffer.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateSDX/DrawBuffer.cs 2009-05-11 14:22:20 UTC (rev 978)
+++ branches/agate3d-3.2/Drivers/AgateSDX/DrawBuffer.cs 2009-05-11 15:17:03 UTC (rev 979)
@@ -25,7 +25,7 @@
using Direct3D = SlimDX.Direct3D9;
using AgateLib.DisplayLib;
-namespace AgateMDX
+namespace AgateSDX
{
/// <summary>
/// Perhaps at some point this should be converted to use a vertex buffer
Modified: branches/agate3d-3.2/Drivers/AgateSDX/HlslCompiler.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateSDX/HlslCompiler.cs 2009-05-11 14:22:20 UTC (rev 978)
+++ branches/agate3d-3.2/Drivers/AgateSDX/HlslCompiler.cs 2009-05-11 15:17:03 UTC (rev 979)
@@ -6,7 +6,7 @@
using AgateLib.ImplementationBase;
using Direct3D = SlimDX.Direct3D9;
-namespace AgateMDX
+namespace AgateSDX
{
class HlslCompiler : ShaderCompilerImpl
{
Modified: branches/agate3d-3.2/Drivers/AgateSDX/HlslShaderProgram.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateSDX/HlslShaderProgram.cs 2009-05-11 14:22:20 UTC (rev 978)
+++ branches/agate3d-3.2/Drivers/AgateSDX/HlslShaderProgram.cs 2009-05-11 15:17:03 UTC (rev 979)
@@ -6,7 +6,7 @@
using AgateLib.DisplayLib.Shaders;
using Direct3D = SlimDX.Direct3D9;
-namespace AgateMDX
+namespace AgateSDX
{
class HlslShaderProgram : ShaderProgram
{
Modified: branches/agate3d-3.2/Drivers/AgateSDX/PositionColorNormalTexture.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateSDX/PositionColorNormalTexture.cs 2009-05-11 14:22:20 UTC (rev 978)
+++ branches/agate3d-3.2/Drivers/AgateSDX/PositionColorNormalTexture.cs 2009-05-11 15:17:03 UTC (rev 979)
@@ -23,7 +23,7 @@
using SlimDX;
using SlimDX.Direct3D9;
-namespace AgateMDX
+namespace AgateSDX
{
[StructLayout(LayoutKind.Sequential)]
public struct PositionColorNormalTexture
Modified: branches/agate3d-3.2/Drivers/AgateSDX/Reporter.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateSDX/Reporter.cs 2009-05-11 14:22:20 UTC (rev 978)
+++ branches/agate3d-3.2/Drivers/AgateSDX/Reporter.cs 2009-05-11 15:17:03 UTC (rev 979)
@@ -21,7 +21,7 @@
using System.Text;
using AgateLib.Drivers;
-namespace AgateMDX
+namespace AgateSDX
{
class Reporter : AgateDriverReporter
{
@@ -33,11 +33,11 @@
"SlimDX - Direct3D 9",
500);
- //yield return new AgateDriverInfo(
- // AudioTypeID.DirectSound,
- // typeof(MDX1_Audio),
- // "SlimDX - DirectSound",
- // 100);
+ yield return new AgateDriverInfo(
+ AudioTypeID.XAudio2,
+ typeof(SDX_Audio),
+ "SlimDX - DirectSound",
+ 100);
yield return new AgateDriverInfo(
InputTypeID.DirectInput,
Copied: branches/agate3d-3.2/Drivers/AgateSDX/SDX_Audio.cs (from rev 922, branches/agate3d-3.2/Drivers/AgateMDX/MDX1_Audio.cs)
===================================================================
--- branches/agate3d-3.2/Drivers/AgateSDX/SDX_Audio.cs (rev 0)
+++ branches/agate3d-3.2/Drivers/AgateSDX/SDX_Audio.cs 2009-05-11 15:17:03 UTC (rev 979)
@@ -0,0 +1,434 @@
+// 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.IO;
+using System.Text;
+using SlimDX.XAudio2;
+using SlimDX.Multimedia;
+using AgateLib.AudioLib;
+using AgateLib.Drivers;
+using AgateLib.ImplementationBase;
+
+namespace AgateSDX
+{
+ public class SDX_Audio : AudioImpl
+ {
+ XAudio2 mDevice;
+
+ public XAudio2 Device
+ {
+ get { return mDevice; }
+ }
+
+ public SDX_Audio()
+ {
+
+ }
+
+ public override void Initialize()
+ {
+ Report("SlimDX XAudio2 driver instantiated for audio.");
+
+ mDevice = new XAudio2();
+ MasteringVoice masteringVoice = new MasteringVoice(mDevice);
+
+ }
+ public override void Dispose()
+ {
+ mDevice.Dispose();
+ }
+
+ public override SoundBufferImpl CreateSoundBuffer(Stream inStream)
+ {
+ return new SDX_SoundBuffer(this, inStream);
+ }
+ public override MusicImpl CreateMusic(System.IO.Stream musicStream)
+ {
+ CheckCoop();
+
+ return new SDX_Music(this, musicStream);
+ }
+ public override MusicImpl CreateMusic(string filename)
+ {
+ CheckCoop();
+
+ return new SDX_Music(this, filename);
+ }
+ public override SoundBufferImpl CreateSoundBuffer(string filename)
+ {
+ CheckCoop();
+
+ return new SDX_SoundBuffer(this, filename);
+ }
+ public override SoundBufferSessionImpl CreateSoundBufferSession(SoundBufferImpl buffer)
+ {
+ CheckCoop();
+
+ return new SDX_SoundBufferSession(this, buffer as SDX_SoundBuffer);
+ }
+
+
+ /// <summary>
+ /// hack to make sure the cooperative level is set after a window is created.
+ /// Is this necessary with XAudio2?
+ /// </summary>
+ private void CheckCoop()
+ {
+ if (System.Windows.Forms.Form.ActiveForm != null)
+ {
+ //mDSobject.SetCooperativeLevel(System.Windows.Forms.Form.ActiveForm.Handle,
+ // CooperativeLevel.Priority);
+ }
+ }
+ }
+
+ public class SDX_SoundBuffer : SoundBufferImpl
+ {
+ SDX_Audio mAudio;
+ AudioBuffer mBuffer;
+ double mVolume;
+ WaveFormat mFormat;
+
+ public SDX_SoundBuffer(SDX_Audio audio, Stream inStream)
+ {
+ mAudio = audio;
+
+ WaveStream stream = new WaveStream(inStream);
+
+ mBuffer = new AudioBuffer();
+ mBuffer.AudioData = stream;
+ mBuffer.AudioBytes = (int)inStream.Length;
+ mBuffer.Flags = BufferFlags.EndOfStream;
+
+ mFormat = stream.Format;
+
+ }
+ public SDX_SoundBuffer(SDX_Audio audio, string filename)
+ : this(audio, File.OpenRead(filename))
+ {
+
+ }
+ public override void Dispose()
+ {
+ mBuffer.Dispose();
+ }
+
+ public AudioBuffer Buffer
+ {
+ get { return mBuffer; }
+ }
+ public WaveFormat Format
+ {
+ get { return mFormat; }
+ }
+
+ public override double Volume
+ {
+ get { return mVolume; }
+ set { mVolume = value; }
+ }
+ }
+ public class SDX_SoundBufferSession : SoundBufferSessionImpl
+ {
+ SDX_Audio mAudio;
+ AudioBuffer mBuffer;
+ SourceVoice mVoice;
+ double mVolume;
+ double mPan;
+
+ public SDX_SoundBufferSession(SDX_Audio audio, SDX_SoundBuffer source)
+ {
+ mAudio = audio;
+ mBuffer = source.Buffer;
+
+ mVoice = new SourceVoice(mAudio.Device, source.Format);
+ mVoice.SubmitSourceBuffer(mBuffer);
+ mVoice.Start();
+
+ mVolume = source.Volume;
+ }
+ public override void Dispose()
+ {
+ mVoice.Dispose();
+ }
+
+ public override void Play()
+ {
+ mVoice.Start();
+ }
+
+ public override void Stop()
+ {
+ mVoice.Stop();
+ }
+
+ public override double Volume
+ {
+ get { return mVolume; }
+ set
+ {
+ mVoice.Volume = (float)value;
+ mVolume = value;
+ }
+ }
+
+ public override bool IsPlaying
+ {
+ get
+ {
+ //return mVoice.State.
+ return false;
+ }
+ }
+
+ float[] channelVolumes = new float[2];
+ public override double Pan
+ {
+ get { return mPan; }
+ set
+ {
+ mPan = value;
+ mVoice.SetChannelVolumes(2, GetChannelVolumes((float)value));
+ }
+ }
+
+ private float[] GetChannelVolumes(float pan)
+ {
+ if (pan < 0)
+ {
+ channelVolumes[0] = 1;
+ channelVolumes[1] = 1 + pan;
+ }
+ else
+ {
+ channelVolumes[0] = 1 - pan;
+ channelVolumes[1] = 1;
+ }
+
+ return channelVolumes;
+ }
+
+ }
+ public class SDX_Music : MusicImpl
+ {
+ SDX_Audio mAudio;
+
+ public SDX_Music(SDX_Audio audio, string filename)
+ {
+ mAudio = audio;
+
+ if (System.IO.Path.GetExtension(filename) == ".mp3")
+ throw new Exception("MP3 files cannot be played due to license restrictions.");
+
+ //LoadMusic(filename);
+ }
+
+ public SDX_Music(SDX_Audio audio, Stream infile)
+ {
+ mAudio = audio;
+
+ //string tempfile = Path.GetTempFileName();
+ //using (FileStream writer = File.OpenWrite(tempfile))
+ //{
+ // ReadWriteStream(infile, writer);
+ //}
+
+ //try
+ //{
+ // LoadMusic(tempfile);
+ //}
+ //catch (Microsoft.DirectX.DirectXException e)
+ //{
+ // throw new AgateLib.AgateException(
+ // "Could not load the music file. The file format may be unsupported by DirectX.", e);
+ //}
+ //finally
+ //{
+ // File.Delete(tempfile);
+ //}
+ }
+ /*
+ private void LoadMusic(string filename)
+ {
+ mAVAudio = new Microsoft.DirectX.AudioVideoPlayback.Audio(filename);
+ mAVAudio.Ending += new EventHandler(mAVAudio_Ending);
+ }
+
+ private void ReadWriteStream(Stream readStream, Stream writeStream)
+ {
+ int Length = 256;
+ Byte[] buffer = new Byte[Length];
+ int bytesRead = readStream.Read(buffer, 0, Length);
+ // write the required bytes
+ while (bytesRead > 0)
+ {
+ writeStream.Write(buffer, 0, bytesRead);
+ bytesRead = readStream.Read(buffer, 0, Length);
+ }
+ readStream.Close();
+ writeStream.Close();
+ }
+
+ public override void Dispose()
+ {
+ mAVAudio.Dispose();
+ }
+
+
+ protected override void OnSetLoop(bool value)
+ {
+ if (value == true)
+ mAVAudio.Ending += mAVAudio_Ending;
+ else
+ mAVAudio.Ending -= mAVAudio_Ending;
+ }
+
+ public override void Play()
+ {
+ mAVAudio.Play();
+ }
+
+ public override void Stop()
+ {
+ mAVAudio.Stop();
+ }
+
+ /// <summary>
+ /// </summary>
+ public override double Volume
+ {
+ get
+ {
+ try
+ {
+ /// The DirectX AudioVideoPlayback object takes volume in the range of
+ /// -10000 to 0, indicating the number of hundredths of decibels the volume
+ /// is attenuated by, so we convert to zero to 1.
+
+ double vol = (double)(mAVAudio.Volume + 10000) / 10000;
+ // logarithmic volume control
+ return Audio.TransformByExp(vol);
+ }
+ catch (Microsoft.DirectX.DirectXException e)
+ {
+ System.Diagnostics.Debug.WriteLine("Failed to read volume.");
+ System.Diagnostics.Debug.WriteLine(e.Message);
+ return 1.0;
+ }
+ }
+ set
+ {
+ // do a logarithmic volume control
+ try
+ {
+ mAVAudio.Volume = (int)(Audio.TransformByLog(value) * 10000.0 - 10000.0);
+ }
+ catch (Microsoft.DirectX.DirectXException e)
+ {
+ System.Diagnostics.Debug.WriteLine("Failed to set volume.");
+ System.Diagnostics.Debug.WriteLine(e.Message);
+ }
+ }
+ }
+
+
+ void mAVAudio_Ending(object sender, EventArgs e)
+ {
+ if (IsLooping)
+ {
+ mAVAudio.CurrentPosition = 0;
+ }
+ }
+
+ public override bool IsPlaying
+ {
+ get { return mAVAudio.Playing; }
+ }
+
+ public override double Pan
+ {
+ get
+ {
+ return mAVAudio.Balance / (double)10000.0;
+ }
+ set
+ {
+ try
+ {
+ mAVAudio.Balance = (int)(value * 10000.0);
+ }
+ catch (Microsoft.DirectX.DirectXException e)
+ {
+ if (e.ErrorCode != -2147220909)
+ throw e;
+ }
+ }
+ }
+ * */
+ public override void Dispose()
+ {
+ throw new NotImplementedException();
+ }
+
+ public override bool IsPlaying
+ {
+ get { throw new NotImplementedException(); }
+ }
+
+ protected override void OnSetLoop(bool value)
+ {
+ throw new NotImplementedException();
+ }
+
+ public override double Pan
+ {
+ get
+ {
+ throw new NotImplementedException();
+ }
+ set
+ {
+ throw new NotImplementedException();
+ }
+ }
+
+ public override void Play()
+ {
+ throw new NotImplementedException();
+ }
+
+ public override void Stop()
+ {
+ throw new NotImplementedException();
+ }
+
+ public override double Volume
+ {
+ get
+ {
+ throw new NotImplementedException();
+ }
+ set
+ {
+ throw new NotImplementedException();
+ }
+ }
+ }
+}
Modified: branches/agate3d-3.2/Drivers/AgateSDX/SDX_Display.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateSDX/SDX_Display.cs 2009-05-11 14:22:20 UTC (rev 978)
+++ branches/agate3d-3.2/Drivers/AgateSDX/SDX_Display.cs 2009-05-11 15:17:03 UTC (rev 979)
@@ -33,7 +33,7 @@
using Vector2 = SlimDX.Vector2;
using ImageFileFormat = AgateLib.DisplayLib.ImageFileFormat;
-namespace AgateMDX
+namespace AgateSDX
{
public class SDX_Display : DisplayImpl, IDisplayCaps, AgateLib.PlatformSpecific.IPlatformServices
{
Modified: branches/agate3d-3.2/Drivers/AgateSDX/SDX_DisplayWindow.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateSDX/SDX_DisplayWindow.cs 2009-05-11 14:22:20 UTC (rev 978)
+++ branches/agate3d-3.2/Drivers/AgateSDX/SDX_DisplayWindow.cs 2009-05-11 15:17:03 UTC (rev 979)
@@ -32,7 +32,7 @@
using AgateLib.InputLib;
using AgateLib.WinForms;
-namespace AgateMDX
+namespace AgateSDX
{
public class SDX_DisplayWindow : DisplayWindowImpl, SDX_IRenderTarget
{
Modified: branches/agate3d-3.2/Drivers/AgateSDX/SDX_IRenderTarget.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateSDX/SDX_IRenderTarget.cs 2009-05-11 14:22:20 UTC (rev 978)
+++ branches/agate3d-3.2/Drivers/AgateSDX/SDX_IRenderTarget.cs 2009-05-11 15:17:03 UTC (rev 979)
@@ -21,7 +21,7 @@
using System.Text;
using AgateLib.ImplementationBase;
-namespace AgateMDX
+namespace AgateSDX
{
public interface SDX_IRenderTarget : IRenderTargetImpl
{
Modified: branches/agate3d-3.2/Drivers/AgateSDX/SDX_IndexBuffer.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateSDX/SDX_IndexBuffer.cs 2009-05-11 14:22:20 UTC (rev 978)
+++ branches/agate3d-3.2/Drivers/AgateSDX/SDX_IndexBuffer.cs 2009-05-11 15:17:03 UTC (rev 979)
@@ -6,7 +6,7 @@
using AgateLib.ImplementationBase;
using Direct3D = SlimDX.Direct3D9;
-namespace AgateMDX
+namespace AgateSDX
{
class SDX_IndexBuffer : IndexBufferImpl
{
Modified: branches/agate3d-3.2/Drivers/AgateSDX/SDX_Input.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateSDX/SDX_Input.cs 2009-05-11 14:22:20 UTC (rev 978)
+++ branches/agate3d-3.2/Drivers/AgateSDX/SDX_Input.cs 2009-05-11 15:17:03 UTC (rev 979)
@@ -24,7 +24,7 @@
using AgateLib.Drivers;
using AgateLib.ImplementationBase;
-namespace AgateMDX
+namespace AgateSDX
{
public class SDX_Input : InputImpl
{
Modified: branches/agate3d-3.2/Drivers/AgateSDX/SDX_Surface.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateSDX/SDX_Surface.cs 2009-05-11 14:22:20 UTC (rev 978)
+++ branches/agate3d-3.2/Drivers/AgateSDX/SDX_Surface.cs 2009-05-11 15:17:03 UTC (rev 979)
@@ -36,7 +36,7 @@
using Direct3D = SlimDX.Direct3D9;
using Surface = AgateLib.DisplayLib.Surface;
-namespace AgateMDX
+namespace AgateSDX
{
public class SDX_Surface : SurfaceImpl, SDX_IRenderTarget
Modified: branches/agate3d-3.2/Drivers/AgateSDX/SDX_VertexBuffer.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateSDX/SDX_VertexBuffer.cs 2009-05-11 14:22:20 UTC (rev 978)
+++ branches/agate3d-3.2/Drivers/AgateSDX/SDX_VertexBuffer.cs 2009-05-11 15:17:03 UTC (rev 979)
@@ -8,7 +8,7 @@
using AgateLib.ImplementationBase;
using Direct3D = SlimDX.Direct3D9;
-namespace AgateMDX
+namespace AgateSDX
{
class SDX_VertexBuffer : VertexBufferImpl
{
Modified: branches/agate3d-3.2/Drivers/AgateSDX/frmFullScreen.Designer.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateSDX/frmFullScreen.Designer.cs 2009-05-11 14:22:20 UTC (rev 978)
+++ branches/agate3d-3.2/Drivers/AgateSDX/frmFullScreen.Designer.cs 2009-05-11 15:17:03 UTC (rev 979)
@@ -16,7 +16,7 @@
//
// Contributor(s): Erik Ylvisaker
//
-namespace AgateMDX
+namespace AgateSDX
{
partial class frmFullScreen
{
Modified: branches/agate3d-3.2/Drivers/AgateSDX/frmFullScreen.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateSDX/frmFullScreen.cs 2009-05-11 14:22:20 UTC (rev 978)
+++ branches/agate3d-3.2/Drivers/AgateSDX/frmFullScreen.cs 2009-05-11 15:17:03 UTC (rev 979)
@@ -24,7 +24,7 @@
using System.Text;
using System.Windows.Forms;
-namespace AgateMDX
+namespace AgateSDX
{
public partial class frmFullScreen : Form
{
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ka...@us...> - 2009-05-11 14:22:34
|
Revision: 978
http://agate.svn.sourceforge.net/agate/?rev=978&view=rev
Author: kanato
Date: 2009-05-11 14:22:20 +0000 (Mon, 11 May 2009)
Log Message:
-----------
Remove use of Discard flag on locking vertex and index buffers, since Direct3D doesn't like it.
Modified Paths:
--------------
branches/agate3d-3.2/Drivers/AgateSDX/SDX_IndexBuffer.cs
branches/agate3d-3.2/Drivers/AgateSDX/SDX_VertexBuffer.cs
Modified: branches/agate3d-3.2/Drivers/AgateSDX/SDX_IndexBuffer.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateSDX/SDX_IndexBuffer.cs 2009-05-11 14:21:03 UTC (rev 977)
+++ branches/agate3d-3.2/Drivers/AgateSDX/SDX_IndexBuffer.cs 2009-05-11 14:22:20 UTC (rev 978)
@@ -61,7 +61,7 @@
public override void WriteIndices(int[] indices)
{
- var data = mBuffer.Lock(0, 0, SlimDX.Direct3D9.LockFlags.Discard);
+ var data = mBuffer.Lock(0, 0, 0);
data.WriteRange(indices);
mBuffer.Unlock();
@@ -70,7 +70,7 @@
public override void WriteIndices(short[] indices)
{
- var data = mBuffer.Lock(0, 0, SlimDX.Direct3D9.LockFlags.Discard);
+ var data = mBuffer.Lock(0, 0, 0);
data.WriteRange(indices);
mBuffer.Unlock();
Modified: branches/agate3d-3.2/Drivers/AgateSDX/SDX_VertexBuffer.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateSDX/SDX_VertexBuffer.cs 2009-05-11 14:21:03 UTC (rev 977)
+++ branches/agate3d-3.2/Drivers/AgateSDX/SDX_VertexBuffer.cs 2009-05-11 14:22:20 UTC (rev 978)
@@ -238,7 +238,7 @@
public override void Write<T>(T[] vertices)
{
- var stream = mBuffer.Lock(0, 0, SlimDX.Direct3D9.LockFlags.Discard);
+ var stream = mBuffer.Lock(0, 0, 0);
stream.WriteRange(vertices);
mBuffer.Unlock();
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ka...@us...> - 2009-05-11 14:21:12
|
Revision: 977
http://agate.svn.sourceforge.net/agate/?rev=977&view=rev
Author: kanato
Date: 2009-05-11 14:21:03 +0000 (Mon, 11 May 2009)
Log Message:
-----------
Report SDX_Input.
Modified Paths:
--------------
branches/agate3d-3.2/Drivers/AgateSDX/Reporter.cs
Modified: branches/agate3d-3.2/Drivers/AgateSDX/Reporter.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateSDX/Reporter.cs 2009-05-11 14:20:35 UTC (rev 976)
+++ branches/agate3d-3.2/Drivers/AgateSDX/Reporter.cs 2009-05-11 14:21:03 UTC (rev 977)
@@ -36,14 +36,14 @@
//yield return new AgateDriverInfo(
// AudioTypeID.DirectSound,
// typeof(MDX1_Audio),
- // "Managed DirectX 1.1 - DirectSound",
+ // "SlimDX - DirectSound",
// 100);
- //yield return new AgateDriverInfo(
- // InputTypeID.DirectInput,
- // typeof(MDX1_Input),
- // "Managed DirectX 1.1 - DirectInput",
- // 100);
+ yield return new AgateDriverInfo(
+ InputTypeID.DirectInput,
+ typeof(SDX_Input),
+ "SlimDX - DirectInput",
+ 100);
}
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ka...@us...> - 2009-05-11 14:20:46
|
Revision: 976
http://agate.svn.sourceforge.net/agate/?rev=976&view=rev
Author: kanato
Date: 2009-05-11 14:20:35 +0000 (Mon, 11 May 2009)
Log Message:
-----------
Add joystick support to AgateSDX.
Added Paths:
-----------
branches/agate3d-3.2/Drivers/AgateSDX/SDX_Input.cs
Copied: branches/agate3d-3.2/Drivers/AgateSDX/SDX_Input.cs (from rev 922, branches/agate3d-3.2/Drivers/AgateMDX/MDX1_Input.cs)
===================================================================
--- branches/agate3d-3.2/Drivers/AgateSDX/SDX_Input.cs (rev 0)
+++ branches/agate3d-3.2/Drivers/AgateSDX/SDX_Input.cs 2009-05-11 14:20:35 UTC (rev 976)
@@ -0,0 +1,215 @@
+// The contents of this file are subject to the Mozilla Public License
+// Version 1.1 (the "License"); you may not use this file except in
+// compliance with the License. You may obtain a copy of the License at
+// http://www.mozilla.org/MPL/
+//
+// Software distributed under the License is distributed on an "AS IS"
+// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+// License for the specific language governing rights and limitations
+// under the License.
+//
+// The Original Code is AgateLib.
+//
+// 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 SlimDX.DirectInput;
+
+using AgateLib.Drivers;
+using AgateLib.ImplementationBase;
+
+namespace AgateMDX
+{
+ public class SDX_Input : InputImpl
+ {
+ DirectInput mDIobject;
+
+ public override void Initialize()
+ {
+ mDIobject = new DirectInput();
+ System.Diagnostics.Trace.WriteLine("Using Managed DirectX implementation of InputImpl.");
+ }
+
+ public override void Dispose()
+ {
+ mDIobject.Dispose();
+ }
+
+ public override int JoystickCount
+ {
+ get
+ {
+ int retval = 0;
+
+
+ foreach (DeviceInstance i in mDIobject.GetDevices())
+ {
+ switch (i.Type)
+ {
+ case DeviceType.Gamepad:
+ case DeviceType.Joystick:
+ retval++;
+ break;
+ }
+ }
+
+ return retval;
+ }
+ }
+
+ public override IEnumerable<JoystickImpl> CreateJoysticks()
+ {
+ List<JoystickImpl> retval = new List<JoystickImpl>();
+
+ foreach (DeviceInstance i in mDIobject.GetDevices())
+ {
+ switch (i.Type)
+ {
+ case DeviceType.Gamepad:
+ case DeviceType.Joystick:
+
+ Device<JoystickState> d = new Device<JoystickState>(mDIobject, i.InstanceGuid);
+
+ retval.Add(new SDX_Joystick(d));
+
+ break;
+ }
+ }
+
+ return retval;
+ }
+ }
+
+ /// <summary>
+ /// MDX1_Joystick class
+ /// Could be done with action maps? would this be better?
+ /// </summary>
+ public class SDX_Joystick : JoystickImpl
+ {
+ private Device<JoystickState> mDevice;
+ private bool[] mButtons;
+
+ private int[] shift = new int[8];
+ private double maxX, maxY, maxZ;
+
+ private double mThreshold;
+
+ public SDX_Joystick(Device<JoystickState> d)
+ {
+ mDevice = d;
+ mDevice.Acquire();
+
+ Recalibrate();
+
+ // joystick values in di seem to be from 0 (left) to 65536 (right).
+ // seems to be the right value on my joystick.
+ maxX = maxY = maxZ = 32768;
+
+ mButtons = new bool[ButtonCount];
+ shift = new int[AxisCount];
+ }
+
+ public override string Name
+ {
+ get { return mDevice.DeviceInformation.InstanceName; }
+ }
+ public override int AxisCount
+ {
+ get { return mDevice.Caps.AxesCount; }
+ }
+ public override int ButtonCount
+ {
+ get { return mDevice.Caps.ButtonCount; }
+ }
+
+ public override bool GetButtonState(int buttonIndex)
+ {
+ return mButtons[buttonIndex];
+ }
+
+ public override void Poll()
+ {
+ mDevice.Poll();
+
+ bool[] di_buttons = mDevice.GetCurrentState().GetButtons();
+
+ for (int i = 0; i < ButtonCount; i++)
+ mButtons[i] = di_buttons[i];
+ }
+
+ public override double GetAxisValue(int axisIndex)
+ {
+ return CorrectAxisValue(mDevice.GetCurrentState().GetSliders()[axisIndex], shift[axisIndex], maxX);
+
+ //if (axisIndex == 0)
+ // return CorrectAxisValue(mDevice.GetCurrentState().X, shift[0], maxX);
+ //else if (axisIndex == 1)
+ // return CorrectAxisValue(mDevice.GetCurrentState().Y, shift[1], maxY);
+ //else if (axisIndex == 2)
+ // return CorrectAxisValue(mDevice.GetCurrentState().RotationX, shift[2], maxX);
+ //else if (axisIndex == 3)
+ // return CorrectAxisValue(mDevice.GetCurrentState().RotationY, shift[3], maxY);
+ //else if (axisIndex == 4)
+ // return CorrectAxisValue(mDevice.GetCurrentState().Z, shift[2], maxZ);
+ //else
+ // return mDevice.GetCurrentState().GetSliders()[axisIndex - 4] / maxX;
+ }
+
+ private double CorrectAxisValue(int axisValue, int shiftValue, double maxX)
+ {
+ double retval = (axisValue - shiftValue) / (double)maxX;
+
+ if (Math.Abs(retval) < mThreshold)
+ return 0;
+ else
+ return retval;
+ }
+
+ public override void Recalibrate()
+ {
+ shift[0] = mDevice.GetCurrentState().X;
+ shift[1] = mDevice.GetCurrentState().Y;
+ shift[2] = mDevice.GetCurrentState().Z;
+ }
+
+ public override double AxisThreshold
+ {
+ get
+ {
+ return mThreshold;
+ }
+ set
+ {
+ mThreshold = value;
+ }
+ }
+
+ public override bool PluggedIn
+ {
+ get
+ {
+ if (mDevice == null)
+ throw new NullReferenceException("Device is null. This indicates a bug in the MDX1_1 library.");
+
+ try
+ {
+ mDevice.Poll();
+
+ return true;
+ }
+ catch (Exception e)
+ {
+ System.Diagnostics.Debug.WriteLine("Error polling joystick: " + e.Message);
+ return false;
+ }
+ }
+ }
+
+ }
+}
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ka...@us...> - 2009-05-11 06:56:14
|
Revision: 975
http://agate.svn.sourceforge.net/agate/?rev=975&view=rev
Author: kanato
Date: 2009-05-11 06:56:04 +0000 (Mon, 11 May 2009)
Log Message:
-----------
Move Push/pop clip rect implementations to DisplayLib/Display.cs.
Modified Paths:
--------------
branches/agate3d-3.2/AgateLib/AgateApplication.cs
branches/agate3d-3.2/AgateLib/DisplayLib/Display.cs
branches/agate3d-3.2/AgateLib/ImplementationBase/DisplayImpl.cs
branches/agate3d-3.2/Drivers/AgateDrawing/Drawing_Display.cs
branches/agate3d-3.2/Drivers/AgateMDX/MDX1_Display.cs
branches/agate3d-3.2/Drivers/AgateOTK/GL_Display.cs
branches/agate3d-3.2/Drivers/AgateSDX/SDX_Display.cs
Modified: branches/agate3d-3.2/AgateLib/AgateApplication.cs
===================================================================
--- branches/agate3d-3.2/AgateLib/AgateApplication.cs 2009-05-11 06:30:52 UTC (rev 974)
+++ branches/agate3d-3.2/AgateLib/AgateApplication.cs 2009-05-11 06:56:04 UTC (rev 975)
@@ -237,7 +237,7 @@
Surface powered = InternalResources.Data.PoweredBy;
Size size = powered.SurfaceSize;
- int left = (int)(totalSplashTime * size.Width - size.Width);
+ int left = (int)(totalSplashTime * size.Width - size.Width)+1;
Rectangle gradientRect = new Rectangle(left, MainWindow.Height - size.Height,
size.Width, size.Height);
Modified: branches/agate3d-3.2/AgateLib/DisplayLib/Display.cs
===================================================================
--- branches/agate3d-3.2/AgateLib/DisplayLib/Display.cs 2009-05-11 06:30:52 UTC (rev 974)
+++ branches/agate3d-3.2/AgateLib/DisplayLib/Display.cs 2009-05-11 06:56:04 UTC (rev 975)
@@ -61,7 +61,9 @@
private static DisplayImpl impl;
private static DisplayWindow mCurrentWindow;
private static SurfacePacker mSurfacePacker;
-
+ private static Rectangle mCurrentClipRect;
+ private static Stack<Rectangle> mClipRects = new Stack<Rectangle>();
+
/// <summary>
/// Gets the object which handles all of the actual calls to Display functions.
/// This may be cast to a surface object in whatever rendering library
@@ -318,15 +320,24 @@
/// <param name="newClipRect"></param>
public static void PushClipRect(Rectangle newClipRect)
{
- impl.PushClipRect(newClipRect);
+ mClipRects.Push(mCurrentClipRect);
+ SetClipRect(newClipRect);
}
/// <summary>
/// Pops the clip rect and restores the previous clip rect.
/// </summary>
public static void PopClipRect()
{
- impl.PopClipRect();
+ if (mClipRects.Count == 0)
+ {
+ throw new Exception("You have popped the cliprect too many times.");
+ }
+ else
+ {
+ SetClipRect(mClipRects.Pop());
+ }
}
+
/// <summary>
/// Returns the maximum size a surface object can be.
/// </summary>
Modified: branches/agate3d-3.2/AgateLib/ImplementationBase/DisplayImpl.cs
===================================================================
--- branches/agate3d-3.2/AgateLib/ImplementationBase/DisplayImpl.cs 2009-05-11 06:30:52 UTC (rev 974)
+++ branches/agate3d-3.2/AgateLib/ImplementationBase/DisplayImpl.cs 2009-05-11 06:56:04 UTC (rev 975)
@@ -321,22 +321,13 @@
/// </summary>
public abstract Size MaxSurfaceSize { get; }
- #region --- Clip Rect stuff ---
+ #region --- SetClipRect ---
/// <summary>
/// Set the current clipping rect.
/// </summary>
/// <param name="newClipRect"></param>
public abstract void SetClipRect(Rectangle newClipRect);
- /// <summary>
- /// Pushes a clip rect onto the clip rect stack.
- /// </summary>
- /// <param name="newClipRect"></param>
- public abstract void PushClipRect(Rectangle newClipRect);
- /// <summary>
- /// Pops the clip rect and restores the previous clip rect.
- /// </summary>
- public abstract void PopClipRect();
#endregion
#region --- Direct modification of the back buffer ---
Modified: branches/agate3d-3.2/Drivers/AgateDrawing/Drawing_Display.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateDrawing/Drawing_Display.cs 2009-05-11 06:30:52 UTC (rev 974)
+++ branches/agate3d-3.2/Drivers/AgateDrawing/Drawing_Display.cs 2009-05-11 06:56:04 UTC (rev 975)
@@ -42,9 +42,6 @@
private bool mInFrame = false;
- private Stack<Geometry.Rectangle> mClipRects = new Stack<Geometry.Rectangle>();
- private Geometry.Rectangle mCurrentClipRect;
-
#endregion
#region --- Events and Event Handlers ---
@@ -207,9 +204,6 @@
mGraphics.Dispose();
mGraphics = null;
- while (mClipRects.Count > 0)
- PopClipRect();
-
Drawing_IRenderTarget renderTarget = RenderTarget.Impl as Drawing_IRenderTarget;
renderTarget.EndRender();
@@ -220,24 +214,9 @@
public override void SetClipRect(Geometry.Rectangle newClipRect)
{
mGraphics.SetClip(Interop.Convert(newClipRect));
- mCurrentClipRect = newClipRect;
}
- public override void PushClipRect(Geometry.Rectangle newClipRect)
- {
- mClipRects.Push(mCurrentClipRect);
- SetClipRect(newClipRect);
- }
- public override void PopClipRect()
- {
-#if DEBUG
- if (mClipRects.Count == 0)
- throw new Exception("The cliprect has been popped too many times.");
-#endif
- SetClipRect(mClipRects.Pop());
- }
-
#endregion
protected override void ProcessEvents()
Modified: branches/agate3d-3.2/Drivers/AgateMDX/MDX1_Display.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateMDX/MDX1_Display.cs 2009-05-11 06:30:52 UTC (rev 974)
+++ branches/agate3d-3.2/Drivers/AgateMDX/MDX1_Display.cs 2009-05-11 06:56:04 UTC (rev 975)
@@ -261,12 +261,7 @@
protected override void OnEndFrame()
{
mDevice.DrawBuffer.Flush();
-
- while (mClipRects.Count > 0)
- PopClipRect();
-
mRenderTarget.EndRender();
-
}
#endregion
@@ -305,30 +300,12 @@
view.Height = newClipRect.Height;
mDevice.Device.Viewport = view;
- mCurrentClipRect = newClipRect;
SetOrthoProjection(newClipRect);
}
- public override void PushClipRect(Rectangle newClipRect)
- {
- mClipRects.Push(mCurrentClipRect);
- SetClipRect(newClipRect);
- }
- public override void PopClipRect()
- {
- if (mClipRects.Count == 0)
- {
- throw new Exception("You have popped the cliprect too many times.");
- }
- else
- {
- SetClipRect(mClipRects.Pop());
- }
- }
+
- private Stack<Rectangle> mClipRects = new Stack<Rectangle>();
- private Rectangle mCurrentClipRect;
-
+
#endregion
#region --- Methods for drawing to the back buffer ---
Modified: branches/agate3d-3.2/Drivers/AgateOTK/GL_Display.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateOTK/GL_Display.cs 2009-05-11 06:30:52 UTC (rev 974)
+++ branches/agate3d-3.2/Drivers/AgateOTK/GL_Display.cs 2009-05-11 06:56:04 UTC (rev 975)
@@ -173,20 +173,6 @@
mCurrentClip = newClipRect;
}
- public override void PushClipRect(Rectangle newClipRect)
- {
- mClipRects.Push(mCurrentClip);
-
- SetClipRect(newClipRect);
- }
-
- public override void PopClipRect()
- {
- SetClipRect(mClipRects.Peek());
-
- mClipRects.Pop();
- }
-
public override void FlushDrawBuffer()
{
mState.DrawBuffer.Flush();
Modified: branches/agate3d-3.2/Drivers/AgateSDX/SDX_Display.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateSDX/SDX_Display.cs 2009-05-11 06:30:52 UTC (rev 974)
+++ branches/agate3d-3.2/Drivers/AgateSDX/SDX_Display.cs 2009-05-11 06:56:04 UTC (rev 975)
@@ -269,12 +269,7 @@
protected override void OnEndFrame()
{
mDevice.DrawBuffer.Flush();
-
- while (mClipRects.Count > 0)
- PopClipRect();
-
mRenderTarget.EndRender();
-
}
#endregion
@@ -311,28 +306,19 @@
view.Y = newClipRect.Y;
view.Width = newClipRect.Width;
view.Height = newClipRect.Height;
+ view.MinZ = 0;
+ view.MaxZ = 1;
- //mDevice.Device.Viewport = view;
+ if (view.Width == 0 || view.Height == 0)
+ {
+ throw new AgateLib.AgateException("Cannot set a cliprect with a width / height of zero.");
+ }
+
+ mDevice.Device.Viewport = view;
mCurrentClipRect = newClipRect;
SetOrthoProjection(newClipRect);
}
- public override void PushClipRect(Rectangle newClipRect)
- {
- mClipRects.Push(mCurrentClipRect);
- SetClipRect(newClipRect);
- }
- public override void PopClipRect()
- {
- if (mClipRects.Count == 0)
- {
- throw new Exception("You have popped the cliprect too many times.");
- }
- else
- {
- SetClipRect(mClipRects.Pop());
- }
- }
private Stack<Rectangle> mClipRects = new Stack<Rectangle>();
private Rectangle mCurrentClipRect;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ka...@us...> - 2009-05-11 06:31:03
|
Revision: 974
http://agate.svn.sourceforge.net/agate/?rev=974&view=rev
Author: kanato
Date: 2009-05-11 06:30:52 +0000 (Mon, 11 May 2009)
Log Message:
-----------
Correct detection and use of display pixel format
Modified Paths:
--------------
branches/agate3d-3.2/Drivers/AgateSDX/SDX_Display.cs
branches/agate3d-3.2/Drivers/AgateSDX/SDX_Surface.cs
Added Paths:
-----------
branches/agate3d-3.2/Drivers/AgateSDX/AgateSDX.csproj
Added: branches/agate3d-3.2/Drivers/AgateSDX/AgateSDX.csproj
===================================================================
--- branches/agate3d-3.2/Drivers/AgateSDX/AgateSDX.csproj (rev 0)
+++ branches/agate3d-3.2/Drivers/AgateSDX/AgateSDX.csproj 2009-05-11 06:30:52 UTC (rev 974)
@@ -0,0 +1,162 @@
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
+ <PropertyGroup>
+ <ProjectType>Local</ProjectType>
+ <ProductVersion>9.0.30729</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{819F5358-7F15-4ED2-986E-94B0A2BCCDDF}</ProjectGuid>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ApplicationIcon>
+ </ApplicationIcon>
+ <AssemblyKeyContainerName>
+ </AssemblyKeyContainerName>
+ <AssemblyName>AgateSDX</AssemblyName>
+ <DefaultClientScript>JScript</DefaultClientScript>
+ <DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>
+ <DefaultTargetSchema>IE50</DefaultTargetSchema>
+ <DelaySign>false</DelaySign>
+ <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>
+ </AppDesignerFolder>
+ <RootNamespace>AgateSDX</RootNamespace>
+ <StartupObject>
+ </StartupObject>
+ <FileUpgradeFlags>
+ </FileUpgradeFlags>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <AllowUnsafeBlocks>True</AllowUnsafeBlocks>
+ <BaseAddress>285212672</BaseAddress>
+ <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
+ <ConfigurationOverrideFile>
+ </ConfigurationOverrideFile>
+ <DefineConstants>DEBUG;TRACE;</DefineConstants>
+ <DocumentationFile>
+ </DocumentationFile>
+ <DebugSymbols>True</DebugSymbols>
+ <FileAlignment>4096</FileAlignment>
+ <Optimize>False</Optimize>
+ <OutputPath>..\..\Binaries\Debug\Drivers\</OutputPath>
+ <RegisterForComInterop>False</RegisterForComInterop>
+ <RemoveIntegerChecks>False</RemoveIntegerChecks>
+ <TreatWarningsAsErrors>False</TreatWarningsAsErrors>
+ <WarningLevel>4</WarningLevel>
+ <NoWarn>
+ </NoWarn>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <AllowUnsafeBlocks>True</AllowUnsafeBlocks>
+ <BaseAddress>285212672</BaseAddress>
+ <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
+ <ConfigurationOverrideFile>
+ </ConfigurationOverrideFile>
+ <DefineConstants>TRACE;</DefineConstants>
+ <DocumentationFile>
+ </DocumentationFile>
+ <DebugSymbols>False</DebugSymbols>
+ <FileAlignment>4096</FileAlignment>
+ <Optimize>True</Optimize>
+ <OutputPath>..\..\Binaries\Release\Drivers\</OutputPath>
+ <RegisterForComInterop>False</RegisterForComInterop>
+ <RemoveIntegerChecks>False</RemoveIntegerChecks>
+ <TreatWarningsAsErrors>False</TreatWarningsAsErrors>
+ <WarningLevel>4</WarningLevel>
+ <NoWarn>
+ </NoWarn>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="SlimDX">
+ <Name>SlimDX</Name>
+ </Reference>
+ <Reference Include="System">
+ <Name>System</Name>
+ </Reference>
+ <Reference Include="System.Core">
+ <Name>System.Core</Name>
+ </Reference>
+ <Reference Include="System.Data">
+ <Name>System.Data</Name>
+ </Reference>
+ <Reference Include="System.Drawing">
+ <Name>System.Drawing</Name>
+ </Reference>
+ <Reference Include="System.Windows.Forms">
+ <Name>System.Windows.Forms</Name>
+ </Reference>
+ <Reference Include="System.Xml">
+ <Name>System.Xml</Name>
+ </Reference>
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\..\AgateLib\AgateLib.csproj">
+ <Name>AgateLib</Name>
+ <Project>{C9CD5A49-13B1-4B31-8EB4-5EDBF6C3811D}</Project>
+ <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
+ </ProjectReference>
+ <ProjectReference Include="..\AgateLib.WinForms\AgateLib.WinForms.csproj">
+ <Name>AgateLib.WinForms</Name>
+ <Project>{451F5273-F4D3-42BC-B29B-CC719523CE78}</Project>
+ <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
+ </ProjectReference>
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="D3DDevice.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="DrawBuffer.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="frmFullScreen.cs">
+ <SubType>Form</SubType>
+ </Compile>
+ <Compile Include="frmFullScreen.Designer.cs">
+ <DependentUpon>frmFullScreen.cs</DependentUpon>
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="HlslCompiler.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="HlslShaderProgram.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="PositionColorNormalTexture.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Reporter.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="SDX_Display.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="SDX_DisplayWindow.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="SDX_IndexBuffer.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="SDX_IRenderTarget.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="SDX_Surface.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="SDX_VertexBuffer.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Properties\AssemblyInfo.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <EmbeddedResource Include="frmFullScreen.resx">
+ <SubType>Designer</SubType>
+ <DependentUpon>frmFullScreen.cs</DependentUpon>
+ </EmbeddedResource>
+ </ItemGroup>
+ <Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />
+ <PropertyGroup>
+ <PreBuildEvent>
+ </PreBuildEvent>
+ <PostBuildEvent>
+ </PostBuildEvent>
+ </PropertyGroup>
+</Project>
\ No newline at end of file
Modified: branches/agate3d-3.2/Drivers/AgateSDX/SDX_Display.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateSDX/SDX_Display.cs 2009-05-11 06:29:57 UTC (rev 973)
+++ branches/agate3d-3.2/Drivers/AgateSDX/SDX_Display.cs 2009-05-11 06:30:52 UTC (rev 974)
@@ -88,7 +88,7 @@
mInitialized = true;
// ok, create D3D device
- PresentParameters present = CreateWindowedPresentParameters(window, 0, 0);
+ PresentParameters present = CreateWindowedPresentParameters(window, 0, 0, 32);
DeviceType dtype = DeviceType.Hardware;
@@ -495,7 +495,8 @@
{
if (fullScreen == true)
{
- PresentParameters present = CreateFullScreenPresentParameters(displayWindow, width, height, bpp);
+ PresentParameters present =
+ CreateFullScreenPresentParameters(displayWindow, width, height, bpp);
OnDeviceAboutToReset();
@@ -507,7 +508,8 @@
}
else
{
- PresentParameters present = CreateWindowedPresentParameters(displayWindow, width, height);
+ PresentParameters present =
+ CreateWindowedPresentParameters(displayWindow, width, height, bpp);
if (displayWindow.mSwap != null && displayWindow.IsFullScreen == true)
{
@@ -524,7 +526,7 @@
System.Diagnostics.Debug.Print("{0} Windowed mode success.", DateTime.Now);
- present = CreateWindowedPresentParameters(displayWindow, width, height);
+ present = CreateWindowedPresentParameters(displayWindow, width, height, bpp);
}
@@ -535,7 +537,7 @@
private PresentParameters CreateFullScreenPresentParameters(SDX_DisplayWindow displayWindow,
int width, int height, int bpp)
{
- PresentParameters present = CreateBasePresentParams(displayWindow);
+ PresentParameters present = CreateBasePresentParams(displayWindow, bpp);
present.SwapEffect = SwapEffect.Flip;
present.Windowed = false;
@@ -546,14 +548,14 @@
}
private PresentParameters CreateWindowedPresentParameters(SDX_DisplayWindow displayWindow,
- int width, int height)
+ int width, int height, int bpp)
{
- PresentParameters present = CreateBasePresentParams(displayWindow);
+ PresentParameters present = CreateBasePresentParams(displayWindow, bpp);
return present;
}
- private PresentParameters CreateBasePresentParams(SDX_DisplayWindow displayWindow)
+ private PresentParameters CreateBasePresentParams(SDX_DisplayWindow displayWindow, int bpp)
{
PresentParameters present = new PresentParameters();
@@ -563,7 +565,7 @@
present.DeviceWindowHandle = displayWindow.RenderTarget.Handle;
present.BackBufferWidth = displayWindow.Width;
present.BackBufferHeight = displayWindow.Height;
- present.BackBufferFormat = Format.Unknown;
+ present.BackBufferFormat = GetDisplayModeTrialPixelFormat(bpp);
present.SwapEffect = SwapEffect.Discard;
present.Windowed = true;
@@ -797,6 +799,10 @@
case Format.R8G8B8:
return 3;
+ case Format.R5G6B5:
+ case Format.X1R5G5B5:
+ return 2;
+
default:
throw new NotSupportedException("Format not supported.");
}
@@ -817,7 +823,7 @@
}
public override PixelFormat DefaultSurfaceFormat
{
- get { return PixelFormat.RGBA8888; }
+ get { return GetPixelFormat(DisplayMode.Format); }
}
public override void FlushDrawBuffer()
@@ -925,13 +931,13 @@
get { return AgateLib.DisplayLib.Shaders.ShaderLanguage.Hlsl; }
}
- #endregion
-
bool IDisplayCaps.CanCreateBitmapFont
{
get { return true; }
}
+ #endregion
+
#region --- 3D stuff ---
Matrix4 projection = Matrix4.Identity;
Modified: branches/agate3d-3.2/Drivers/AgateSDX/SDX_Surface.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateSDX/SDX_Surface.cs 2009-05-11 06:29:57 UTC (rev 973)
+++ branches/agate3d-3.2/Drivers/AgateSDX/SDX_Surface.cs 2009-05-11 06:30:52 UTC (rev 974)
@@ -207,7 +207,7 @@
//mTexture = new Texture(mDevice, bitmap, Usage.None, Pool.Managed);
Format format;
-
+
switch (mDisplay.DisplayMode.Format)
{
case Format.X8R8G8B8:
@@ -525,7 +525,7 @@
throw new NotImplementedException();
//SurfaceLoader.Save(frameFile, d3dformat, surf, Interop.Convert(mSrcRect));
-
+
}
#endregion
@@ -606,7 +606,6 @@
rect.X += mSrcRect.X;
rect.Y += mSrcRect.Y;
- int stride;
int pixelPitch = mDisplay.GetPixelPitch(surf.Description.Format);
PixelFormat pixelFormat = mDisplay.GetPixelFormat(surf.Description.Format);
@@ -614,7 +613,7 @@
if (format == PixelFormat.Any)
format = pixelFormat;
- var stm = surf.LockRectangle(
+ DataRectangle stm = surf.LockRectangle(
new Drawing.Rectangle(0, 0, mTextureSize.Width, mTextureSize.Height),
LockFlags.ReadOnly);
@@ -622,26 +621,24 @@
int length = SurfaceWidth * pixelPitch;
int index = 0;
- throw new NotImplementedException();
- //unsafe
- //{
- // DataStream st = stm.Data;
- // byte* ptr = (byte*)stm.Data.Read(;
+ unsafe
+ {
+ byte* ptr = (byte*)stm.Data.DataPointer;
- // for (int i = rect.Top; i < rect.Bottom; i++)
- // {
- // // hack if the size requested is too large.
- // if (i >= mTextureSize.Height)
- // break;
+ for (int i = rect.Top; i < rect.Bottom; i++)
+ {
+ // hack if the size requested is too large.
+ if (i >= mTextureSize.Height)
+ break;
- // //IntPtr ptr = (IntPtr)((int)stm.InternalData + i * stride + rect.Left * pixelPitch);
- // IntPtr mptr = (IntPtr)(ptr + i * stride + rect.Left * pixelPitch);
+ //IntPtr ptr = (IntPtr)((int)stm.InternalData + i * stride + rect.Left * pixelPitch);
+ IntPtr mptr = (IntPtr)(ptr + i * stm.Pitch + rect.Left * pixelPitch);
- // Marshal.Copy(mptr, array, index, length);
+ Marshal.Copy(mptr, array, index, length);
- // index += length;
- // }
- //}
+ index += length;
+ }
+ }
surf.UnlockRectangle();
surf.Dispose();
@@ -654,31 +651,28 @@
{
Direct3D.Surface surf = mTexture.Value.GetSurfaceLevel(0);
- int pitch;
int pixelPitch = mDisplay.GetPixelPitch(surf.Description.Format);
PixelFormat pixelFormat = mDisplay.GetPixelFormat(surf.Description.Format);
surf.Dispose();
- throw new NotImplementedException();
+ DataRectangle stm = mTexture.Value.LockRectangle(0, 0);
- //GraphicsStream stm = mTexture.Value.LockRectangle(0, 0, out pitch);
+ if (buffer.PixelFormat != pixelFormat)
+ buffer = buffer.ConvertTo(pixelFormat);
- //if (buffer.PixelFormat != pixelFormat)
- // buffer = buffer.ConvertTo(pixelFormat);
+ unsafe
+ {
+ for (int i = 0; i < SurfaceHeight; i++)
+ {
+ int startIndex = buffer.GetPixelIndex(0, i);
+ int rowStride = buffer.RowStride;
+ IntPtr dest = (IntPtr)((byte*)stm.Data.DataPointer + i * stm.Pitch);
- //unsafe
- //{
- // for (int i = 0; i < SurfaceHeight; i++)
- // {
- // int startIndex = buffer.GetPixelIndex(0, i);
- // int rowStride = buffer.RowStride;
- // IntPtr dest = (IntPtr)((byte*)stm.InternalData + i * pitch);
+ Marshal.Copy(buffer.Data, startIndex, dest, rowStride);
+ }
+ }
- // Marshal.Copy(buffer.Data, startIndex, dest, rowStride);
- // }
- //}
-
mTexture.Value.UnlockRectangle(0);
}
@@ -688,29 +682,29 @@
Direct3D.Surface surf = mTexture.Value.GetSurfaceLevel(0);
Rectangle updateRect = new Rectangle(startPoint, buffer.Size);
- int pitch;
int pixelPitch = mDisplay.GetPixelPitch(surf.Description.Format);
PixelFormat pixelFormat = mDisplay.GetPixelFormat(surf.Description.Format);
surf.Dispose();
- throw new NotImplementedException();
- //GraphicsStream stm = mTexture.Value.LockRectangle(0, Interop.Convert(updateRect), 0, out pitch);
+ DataRectangle stm = mTexture.Value.LockRectangle
+ (0, Interop.Convert(updateRect), LockFlags.Discard);
- //if (buffer.PixelFormat != pixelFormat)
- // buffer = buffer.ConvertTo(pixelFormat);
+ if (buffer.PixelFormat != pixelFormat)
+ buffer = buffer.ConvertTo(pixelFormat);
- //unsafe
- //{
- // for (int i = updateRect.Top; i < updateRect.Bottom; i++)
- // {
- // int startIndex = buffer.GetPixelIndex(0, i);
- // int rowStride = buffer.RowStride;
- // IntPtr dest = (IntPtr)((byte*)stm.InternalData + i * pitch + updateRect.Left * pixelPitch);
+ unsafe
+ {
+ for (int i = updateRect.Top; i < updateRect.Bottom; i++)
+ {
+ int startIndex = buffer.GetPixelIndex(0, i);
+ int rowStride = buffer.RowStride;
+ IntPtr dest = (IntPtr)
+ ((byte*)stm.Data.DataPointer + i * stm.Pitch + updateRect.Left * pixelPitch);
- // Marshal.Copy(buffer.Data, startIndex, dest, rowStride);
- // }
- //}
+ Marshal.Copy(buffer.Data, startIndex, dest, rowStride);
+ }
+ }
mTexture.Value.UnlockRectangle(0);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ka...@us...> - 2009-05-11 06:30:06
|
Revision: 973
http://agate.svn.sourceforge.net/agate/?rev=973&view=rev
Author: kanato
Date: 2009-05-11 06:29:57 +0000 (Mon, 11 May 2009)
Log Message:
-----------
Fix formatting in SurfaceImpl file.
Modified Paths:
--------------
branches/agate3d-3.2/AgateLib/ImplementationBase/SurfaceImpl.cs
Modified: branches/agate3d-3.2/AgateLib/ImplementationBase/SurfaceImpl.cs
===================================================================
--- branches/agate3d-3.2/AgateLib/ImplementationBase/SurfaceImpl.cs 2009-05-11 06:04:11 UTC (rev 972)
+++ branches/agate3d-3.2/AgateLib/ImplementationBase/SurfaceImpl.cs 2009-05-11 06:29:57 UTC (rev 973)
@@ -25,36 +25,36 @@
namespace AgateLib.ImplementationBase
{
- /// <summary>
- /// Base class for implementing a Surface structure.
- /// </summary>
- public abstract class SurfaceImpl : IRenderTargetImpl, IDisposable
- {
- #region --- Private Fields ---
+ /// <summary>
+ /// Base class for implementing a Surface structure.
+ /// </summary>
+ public abstract class SurfaceImpl : IRenderTargetImpl, IDisposable
+ {
+ #region --- Private Fields ---
- private bool mIsDisposed = false;
- private bool mShouldBePacked = true;
+ private bool mIsDisposed = false;
+ private bool mShouldBePacked = true;
- private int mTesselate = 1;
+ private int mTesselate = 1;
- #endregion
+ #endregion
- #region --- Creation / Destruction ---
+ #region --- Creation / Destruction ---
- /// <summary>
- /// Constructs a SurfaceImpl object.
- /// </summary>
- public SurfaceImpl()
- {
- }
- /// <summary>
- /// Frees unmanaged resources.
- /// </summary>
- public abstract void Dispose();
+ /// <summary>
+ /// Constructs a SurfaceImpl object.
+ /// </summary>
+ public SurfaceImpl()
+ {
+ }
+ /// <summary>
+ /// Frees unmanaged resources.
+ /// </summary>
+ public abstract void Dispose();
- #endregion
+ #endregion
- #region --- Drawing the surface to the screen ---
+ #region --- Drawing the surface to the screen ---
public abstract void Draw(SurfaceState state);
@@ -63,11 +63,11 @@
#region --- Surface Data Manipulations ---
/// <summary>
- /// Saves the surface data to the specified file in the specified format.
- /// </summary>
- /// <param name="filename"></param>
- /// <param name="format"></param>
- public abstract void SaveTo(string filename, ImageFileFormat format);
+ /// Saves the surface data to the specified file in the specified format.
+ /// </summary>
+ /// <param name="filename"></param>
+ /// <param name="format"></param>
+ public abstract void SaveTo(string filename, ImageFileFormat format);
/// <summary>
/// Creates a new SurfaceImpl object which comes from a small sub-rectangle on this surface.
@@ -77,55 +77,55 @@
/// <returns></returns>
public abstract SurfaceImpl CarveSubSurface(Rectangle srcRect);
- /// <summary>
- /// Used by Display.BuildPackedSurface.
- /// </summary>
- /// <param name="surf"></param>
- /// <param name="srcRect"></param>
- public abstract void SetSourceSurface(SurfaceImpl surf, Rectangle srcRect);
+ /// <summary>
+ /// Used by Display.BuildPackedSurface.
+ /// </summary>
+ /// <param name="surf"></param>
+ /// <param name="srcRect"></param>
+ public abstract void SetSourceSurface(SurfaceImpl surf, Rectangle srcRect);
- /// <summary>
- /// Creates a PixelBuffer object with a copy of the pixel data, in the specified format.
- /// </summary>
- /// <param name="format"></param>
- /// <returns></returns>
- public virtual PixelBuffer ReadPixels(PixelFormat format)
- {
- return ReadPixels(format, new Rectangle(Point.Empty, SurfaceSize));
- }
- /// <summary>
- /// Creates a PixelBuffer object with a copy of the pixel data in the
- /// specified rectangle, in the specified format.
- /// </summary>
- /// <param name="format"></param>
- /// <param name="rect"></param>
- /// <returns></returns>
- public abstract PixelBuffer ReadPixels(PixelFormat format, Rectangle rect);
- /// <summary>
- /// Writes pixel data to the surface.
- /// </summary>
- /// <param name="buffer"></param>
- public abstract void WritePixels(PixelBuffer buffer);
- /// <summary>
- /// Writes pixel data to the surface.
- /// </summary>
- /// <param name="buffer"></param>
- /// <param name="startPoint"></param>
- public virtual void WritePixels(PixelBuffer buffer, Point startPoint)
- {
- // poor man's method
- PixelBuffer pixels = ReadPixels(PixelFormat.RGBA8888);
+ /// <summary>
+ /// Creates a PixelBuffer object with a copy of the pixel data, in the specified format.
+ /// </summary>
+ /// <param name="format"></param>
+ /// <returns></returns>
+ public virtual PixelBuffer ReadPixels(PixelFormat format)
+ {
+ return ReadPixels(format, new Rectangle(Point.Empty, SurfaceSize));
+ }
+ /// <summary>
+ /// Creates a PixelBuffer object with a copy of the pixel data in the
+ /// specified rectangle, in the specified format.
+ /// </summary>
+ /// <param name="format"></param>
+ /// <param name="rect"></param>
+ /// <returns></returns>
+ public abstract PixelBuffer ReadPixels(PixelFormat format, Rectangle rect);
+ /// <summary>
+ /// Writes pixel data to the surface.
+ /// </summary>
+ /// <param name="buffer"></param>
+ public abstract void WritePixels(PixelBuffer buffer);
+ /// <summary>
+ /// Writes pixel data to the surface.
+ /// </summary>
+ /// <param name="buffer"></param>
+ /// <param name="startPoint"></param>
+ public virtual void WritePixels(PixelBuffer buffer, Point startPoint)
+ {
+ // poor man's method
+ PixelBuffer pixels = ReadPixels(PixelFormat.RGBA8888);
- pixels.CopyFrom(buffer, new Rectangle(Point.Empty, buffer.Size), startPoint, false);
+ pixels.CopyFrom(buffer, new Rectangle(Point.Empty, buffer.Size), startPoint, false);
- WritePixels(pixels);
- }
+ WritePixels(pixels);
+ }
- #endregion
+ #endregion
- #region --- Surface properties ---
+ #region --- Surface properties ---
private InterpolationMode mInterpolationHint;
@@ -144,156 +144,156 @@
{
if (value < 1) value = 1;
- mTesselate = value;
- }
- }
- /// <summary>
- /// Returns true if Dispose() has been called on this surface.
- /// </summary>
- public bool IsDisposed
- {
- get { return mIsDisposed; }
- }
+ mTesselate = value;
+ }
+ }
+ /// <summary>
+ /// Returns true if Dispose() has been called on this surface.
+ /// </summary>
+ public bool IsDisposed
+ {
+ get { return mIsDisposed; }
+ }
- /// <summary>
- /// Gets or sets a bool value which indicates whether or not this surface
- /// should be considered for packing when Display.PackAllSurfaces() is
- /// called.
- /// </summary>
- public bool ShouldBePacked
- {
- get { return mShouldBePacked; }
- set { mShouldBePacked = value; }
- }
+ /// <summary>
+ /// Gets or sets a bool value which indicates whether or not this surface
+ /// should be considered for packing when Display.PackAllSurfaces() is
+ /// called.
+ /// </summary>
+ public bool ShouldBePacked
+ {
+ get { return mShouldBePacked; }
+ set { mShouldBePacked = value; }
+ }
- /// <summary>
- /// Gets the width of the source surface in pixels.
- /// </summary>
- public virtual int SurfaceWidth { get { return SurfaceSize.Width; } }
- /// <summary>
- /// Gets the height of the source surface in pixels.
- /// </summary>
- public virtual int SurfaceHeight { get { return SurfaceSize.Height; } }
- /// <summary>
- /// Gets the Size of the source surface in pixels.
- /// </summary>
- public abstract Size SurfaceSize { get; }
+ /// <summary>
+ /// Gets the width of the source surface in pixels.
+ /// </summary>
+ public virtual int SurfaceWidth { get { return SurfaceSize.Width; } }
+ /// <summary>
+ /// Gets the height of the source surface in pixels.
+ /// </summary>
+ public virtual int SurfaceHeight { get { return SurfaceSize.Height; } }
+ /// <summary>
+ /// Gets the Size of the source surface in pixels.
+ /// </summary>
+ public abstract Size SurfaceSize { get; }
- #endregion
+ #endregion
- #region --- Protected Methods ---
+ #region --- Protected Methods ---
- /// <summary>
- /// Scans a memory area to see if it entirely contains pixels which won't be
- /// seen when drawn.
- /// </summary>
- /// <param name="pixelData">Pointer to the data</param>
- /// <param name="row">Which row to check</param>
- /// <param name="cols">How many columns to check</param>
- /// <param name="strideInBytes">The stride of each row</param>
- /// <param name="alphaThreshold">The maximum value of alpha to consider a pixel transparent.</param>
- /// <param name="alphaMask">The mask to use to extract the alpha value from the data.</param>
- /// <param name="alphaShift">How many bits to shift it to get alpha in the range of 0-255.
- /// For example, if alphaMask = 0xff000000 then alphaShift should be 24.</param>
- /// <returns></returns>
- [CLSCompliant(false)]
- protected bool IsRowBlankScanARGB(IntPtr pixelData, int row, int cols, int strideInBytes,
- int alphaThreshold, uint alphaMask, int alphaShift)
- {
- unsafe
- {
- uint* ptr = (uint*)pixelData;
+ /// <summary>
+ /// Scans a memory area to see if it entirely contains pixels which won't be
+ /// seen when drawn.
+ /// </summary>
+ /// <param name="pixelData">Pointer to the data</param>
+ /// <param name="row">Which row to check</param>
+ /// <param name="cols">How many columns to check</param>
+ /// <param name="strideInBytes">The stride of each row</param>
+ /// <param name="alphaThreshold">The maximum value of alpha to consider a pixel transparent.</param>
+ /// <param name="alphaMask">The mask to use to extract the alpha value from the data.</param>
+ /// <param name="alphaShift">How many bits to shift it to get alpha in the range of 0-255.
+ /// For example, if alphaMask = 0xff000000 then alphaShift should be 24.</param>
+ /// <returns></returns>
+ [CLSCompliant(false)]
+ protected bool IsRowBlankScanARGB(IntPtr pixelData, int row, int cols, int strideInBytes,
+ int alphaThreshold, uint alphaMask, int alphaShift)
+ {
+ unsafe
+ {
+ uint* ptr = (uint*)pixelData;
- int start = row * strideInBytes / sizeof(uint);
+ int start = row * strideInBytes / sizeof(uint);
- for (int i = 0; i < cols; i++)
- {
- int index = start + i;
- uint pixel = ptr[index];
- byte alpha = (byte)((pixel & alphaMask) >> alphaShift);
+ for (int i = 0; i < cols; i++)
+ {
+ int index = start + i;
+ uint pixel = ptr[index];
+ byte alpha = (byte)((pixel & alphaMask) >> alphaShift);
- if (alpha > alphaThreshold)
- {
- return false;
- }
+ if (alpha > alphaThreshold)
+ {
+ return false;
+ }
- }
- }
+ }
+ }
- return true;
- }
- /// <summary>
- /// Scans a memory area to see if it entirely contains pixels which won't be
- /// seen when drawn.
- /// </summary>
- /// <param name="pixelData">Pointer to the data</param>
- /// <param name="col">Which col to check</param>
- /// <param name="rows">How many columns to check</param>
- /// <param name="strideInBytes">The stride of each row</param>
- /// <param name="alphaThreshold">The maximum value of alpha to consider a pixel transparent.</param>
- /// <param name="alphaMask">The mask to use to extract the alpha value from the data.</param>
- /// <param name="alphaShift">How many bits to shift it to get alpha in the range of 0-255.
- /// For example, if alphaMask = 0xff000000 then alphaShift should be 24.</param>
- /// <returns></returns>
- [CLSCompliant(false)]
- protected bool IsColBlankScanARGB(IntPtr pixelData, int col, int rows, int strideInBytes,
- int alphaThreshold, uint alphaMask, int alphaShift)
- {
- unsafe
- {
- uint* ptr = (uint*)pixelData;
+ return true;
+ }
+ /// <summary>
+ /// Scans a memory area to see if it entirely contains pixels which won't be
+ /// seen when drawn.
+ /// </summary>
+ /// <param name="pixelData">Pointer to the data</param>
+ /// <param name="col">Which col to check</param>
+ /// <param name="rows">How many columns to check</param>
+ /// <param name="strideInBytes">The stride of each row</param>
+ /// <param name="alphaThreshold">The maximum value of alpha to consider a pixel transparent.</param>
+ /// <param name="alphaMask">The mask to use to extract the alpha value from the data.</param>
+ /// <param name="alphaShift">How many bits to shift it to get alpha in the range of 0-255.
+ /// For example, if alphaMask = 0xff000000 then alphaShift should be 24.</param>
+ /// <returns></returns>
+ [CLSCompliant(false)]
+ protected bool IsColBlankScanARGB(IntPtr pixelData, int col, int rows, int strideInBytes,
+ int alphaThreshold, uint alphaMask, int alphaShift)
+ {
+ unsafe
+ {
+ uint* ptr = (uint*)pixelData;
- for (int i = 0; i < rows; i++)
- {
- int index = col + i * strideInBytes / sizeof(uint);
- uint pixel = ptr[index];
- byte alpha = (byte)((pixel & alphaMask) >> alphaShift);
+ for (int i = 0; i < rows; i++)
+ {
+ int index = col + i * strideInBytes / sizeof(uint);
+ uint pixel = ptr[index];
+ byte alpha = (byte)((pixel & alphaMask) >> alphaShift);
- if (alpha > alphaThreshold)
- {
- return false;
- }
+ if (alpha > alphaThreshold)
+ {
+ return false;
+ }
- }
- }
+ }
+ }
- return true;
+ return true;
- }
- #endregion
+ }
+ #endregion
- #region --- IRenderTargetImpl Members ---
+ #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();
+ /// <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; }
- }
+ Size IRenderTargetImpl.Size
+ {
+ get { return SurfaceSize; }
+ }
- int IRenderTargetImpl.Width
- {
- get { return SurfaceWidth; }
- }
+ int IRenderTargetImpl.Width
+ {
+ get { return SurfaceWidth; }
+ }
- int IRenderTargetImpl.Height
- {
- get { return SurfaceHeight; }
- }
+ int IRenderTargetImpl.Height
+ {
+ get { return SurfaceHeight; }
+ }
- #endregion
+ #endregion
};
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ka...@us...> - 2009-05-11 06:04:22
|
Revision: 972
http://agate.svn.sourceforge.net/agate/?rev=972&view=rev
Author: kanato
Date: 2009-05-11 06:04:11 +0000 (Mon, 11 May 2009)
Log Message:
-----------
Initial commit of AgateSDX.
Modified Paths:
--------------
branches/agate3d-3.2/Build/AgateLib-Windows.xml
Added Paths:
-----------
branches/agate3d-3.2/Build/Projects/AgateSDX.proj.xml
branches/agate3d-3.2/Drivers/AgateSDX/
branches/agate3d-3.2/Drivers/AgateSDX/D3DDevice.cs
branches/agate3d-3.2/Drivers/AgateSDX/DrawBuffer.cs
branches/agate3d-3.2/Drivers/AgateSDX/HlslCompiler.cs
branches/agate3d-3.2/Drivers/AgateSDX/HlslShaderProgram.cs
branches/agate3d-3.2/Drivers/AgateSDX/PositionColorNormalTexture.cs
branches/agate3d-3.2/Drivers/AgateSDX/Properties/
branches/agate3d-3.2/Drivers/AgateSDX/Properties/AssemblyInfo.cs
branches/agate3d-3.2/Drivers/AgateSDX/Reporter.cs
branches/agate3d-3.2/Drivers/AgateSDX/SDX_Display.cs
branches/agate3d-3.2/Drivers/AgateSDX/SDX_DisplayWindow.cs
branches/agate3d-3.2/Drivers/AgateSDX/SDX_IRenderTarget.cs
branches/agate3d-3.2/Drivers/AgateSDX/SDX_IndexBuffer.cs
branches/agate3d-3.2/Drivers/AgateSDX/SDX_Surface.cs
branches/agate3d-3.2/Drivers/AgateSDX/SDX_VertexBuffer.cs
branches/agate3d-3.2/Drivers/AgateSDX/frmFullScreen.Designer.cs
branches/agate3d-3.2/Drivers/AgateSDX/frmFullScreen.cs
branches/agate3d-3.2/Drivers/AgateSDX/frmFullScreen.resx
Modified: branches/agate3d-3.2/Build/AgateLib-Windows.xml
===================================================================
--- branches/agate3d-3.2/Build/AgateLib-Windows.xml 2009-05-11 05:59:26 UTC (rev 971)
+++ branches/agate3d-3.2/Build/AgateLib-Windows.xml 2009-05-11 06:04:11 UTC (rev 972)
@@ -26,6 +26,7 @@
<?include file="Projects/AgateSDL.proj.xml" ?>
<?include file="Projects/AgateFMOD.proj.xml" ?>
<?include file="Projects/AgateMDX.proj.xml" ?>
+ <?include file="Projects/AgateSDX.proj.xml" ?>
<?include file="Projects/Tests.proj.xml" ?>
</Solution>
Added: branches/agate3d-3.2/Build/Projects/AgateSDX.proj.xml
===================================================================
--- branches/agate3d-3.2/Build/Projects/AgateSDX.proj.xml (rev 0)
+++ branches/agate3d-3.2/Build/Projects/AgateSDX.proj.xml 2009-05-11 06:04:11 UTC (rev 972)
@@ -0,0 +1,30 @@
+<Project name="AgateSDX" path="../Drivers/AgateSDX" language="C#" type="Library" frameworkVersion="v3_5">
+ <Configuration name="Debug">
+ <Options>
+ <OutputPath>../../Binaries/Debug/Drivers</OutputPath>
+ <AllowUnsafe>true</AllowUnsafe>
+ </Options>
+ </Configuration>
+
+ <Configuration name="Release">
+ <Options>
+ <OutputPath>../../Binaries/Release/Drivers</OutputPath>
+ <AllowUnsafe>true</AllowUnsafe>
+ </Options>
+ </Configuration>
+
+ <Reference name="AgateLib"/>
+ <Reference name="AgateLib.WinForms"/>
+ <Reference name="SlimDX"/>
+ <Reference name="System"/>
+ <Reference name="System.Core"/>
+ <Reference name="System.Data"/>
+ <Reference name="System.Drawing"/>
+ <Reference name="System.Windows.Forms"/>
+ <Reference name="System.Xml"/>
+
+ <Files>
+ <Match path="." pattern="*.cs" recurse="true"/>
+ <Match pattern="*.resx" recurse="true"/>
+ </Files>
+</Project>
Property changes on: branches/agate3d-3.2/Drivers/AgateSDX
___________________________________________________________________
Added: svn:ignore
+ [Bb]in
obj
[Dd]ebug
[Rr]elease
*.user
*.aps
*.eto
Copied: branches/agate3d-3.2/Drivers/AgateSDX/D3DDevice.cs (from rev 930, branches/agate3d-3.2/Drivers/AgateMDX/D3DDevice.cs)
===================================================================
--- branches/agate3d-3.2/Drivers/AgateSDX/D3DDevice.cs (rev 0)
+++ branches/agate3d-3.2/Drivers/AgateSDX/D3DDevice.cs 2009-05-11 06:04:11 UTC (rev 972)
@@ -0,0 +1,398 @@
+// The contents of this file are subject to the Mozilla Public License
+// Version 1.1 (the "License"); you may not use this file except in
+// compliance with the License. You may obtain a copy of the License at
+// http://www.mozilla.org/MPL/
+//
+// Software distributed under the License is distributed on an "AS IS"
+// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+// License for the specific language governing rights and limitations
+// under the License.
+//
+// The Original Code is AgateLib.
+//
+// The Initial Developer of the Original Code is Erik Ylvisaker.
+// Portions created by Erik Ylvisaker are Copyright (C) 2006-2009.
+// All Rights Reserved.
+//
+// Contributor(s): Erik Ylvisaker
+//
+using System;
+using System.Collections.Generic;
+using System.Text;
+using Direct3D = SlimDX.Direct3D9;
+using SlimDX.Direct3D9;
+using SlimDX;
+
+using AgateLib.DisplayLib;
+using AgateLib.Geometry;
+using AgateLib.WinForms;
+
+namespace AgateMDX
+{
+ public class D3DDevice : IDisposable
+ {
+ private Device mDevice;
+ private Texture[] mLastTexture = new Texture[8];
+ private SDX_IRenderTarget mRenderTarget;
+ private DrawBuffer mDrawBuffer;
+
+ private VertexFormat mVertexFormat;
+ private bool mAlphaBlend;
+ private TextureArgument mAlphaArgument1;
+ private TextureArgument mAlphaArgument2;
+ private TextureOperation mAlphaOperation;
+
+ private Matrix mWorld2D;
+
+ private int mMaxLightsUsed = 0;
+
+
+ //VertexBuffer mSurfaceVB;
+ //const int NumVertices = 1000;
+ //int mSurfaceVBPointer = 0;
+
+ //readonly int SurfaceVBSize = NumVertices * CustomVertex.TransformedColoredTextured.StrideSize;
+
+ public D3DDevice(Device device)
+ {
+ mDevice = device;
+ mWorld2D = Matrix.Identity;
+
+ //mDevice.DeviceLost += new EventHandler(mDevice_DeviceLost);
+ mDrawBuffer = new DrawBuffer(this);
+ }
+
+ ~D3DDevice()
+ {
+ Dispose(false);
+ }
+
+
+ void mDevice_DeviceLost(object sender, EventArgs e)
+ {
+ // set weird values which will indicate that the device's
+ // render states need to be set.
+ mAlphaBlend = false;
+ mVertexFormat = VertexFormat.None;
+ mAlphaArgument1 = TextureArgument.Temp;
+ mAlphaArgument2 = TextureArgument.Temp;
+ mAlphaOperation = TextureOperation.Add;
+ }
+
+ public void Dispose()
+ {
+ Dispose(true);
+ }
+ private void Dispose(bool disposing)
+ {
+ if (disposing)
+ GC.SuppressFinalize(this);
+
+ if (mDevice != null)
+ {
+ mDevice.Dispose();
+ mDevice = null;
+ }
+ //if (mSurfaceVB != null)
+ //{
+ // mSurfaceVB.Dispose();
+ // mSurfaceVB = null;
+ //}
+ }
+
+ //private void CreateSurfaceVB()
+ //{
+ // //mSurfaceVB = new VertexBuffer(mDevice, SurfaceVBSize,
+ // // Usage.WriteOnly | Usage.Dynamic, CustomVertex.TransformedColoredTextured.Format,
+ // // Pool.Default);
+ //}
+ public Device Device
+ {
+ get { return mDevice; }
+ }
+
+ InterpolationMode lastInterpolation;
+
+ public InterpolationMode Interpolation
+ {
+ get { return lastInterpolation; }
+ set
+ {
+ if (value == lastInterpolation)
+ return;
+
+ DrawBuffer.Flush();
+
+ switch (value)
+ {
+ case InterpolationMode.Default:
+ case InterpolationMode.Nicest:
+ mDevice.SetSamplerState(0, SamplerState.MinFilter, TextureFilter.Anisotropic);
+ mDevice.SetSamplerState(0, SamplerState.MagFilter, TextureFilter.Anisotropic);
+ break;
+
+ case InterpolationMode.Fastest:
+ mDevice.SetSamplerState(0, SamplerState.MinFilter, TextureFilter.Point);
+ mDevice.SetSamplerState(0, SamplerState.MagFilter, TextureFilter.Point);
+ break;
+ }
+
+ lastInterpolation = value;
+ }
+ }
+
+ public SDX_IRenderTarget RenderTarget
+ {
+ get { return mRenderTarget; }
+ set { mRenderTarget = value; }
+ }
+ public DrawBuffer DrawBuffer
+ {
+ get { return mDrawBuffer; }
+ }
+ public VertexFormat VertexFormat
+ {
+ get { return mVertexFormat; }
+ set
+ {
+ if (mVertexFormat != value)
+ {
+ mVertexFormat = value;
+ mDevice.VertexFormat = value;
+ }
+ }
+ }
+ public bool AlphaBlend
+ {
+ get { return mAlphaBlend; }
+ set
+ {
+ if (value != mAlphaBlend)
+ {
+ mAlphaBlend = value;
+ mDevice.SetRenderState(RenderState.AlphaBlendEnable, value);
+ }
+ }
+ }
+ public TextureArgument AlphaArgument1
+ {
+ get { return mAlphaArgument1; }
+ set
+ {
+ if (value != mAlphaArgument1)
+ {
+ mAlphaArgument1 = value;
+ mDevice.SetTextureStageState(0, TextureStage.AlphaArg1, value);
+ }
+
+ }
+ }
+ public TextureArgument AlphaArgument2
+ {
+ get { return mAlphaArgument2; }
+ set
+ {
+ if (value != mAlphaArgument2)
+ {
+ mAlphaArgument2 = value;
+ mDevice.SetTextureStageState(0, TextureStage.AlphaArg2, value);
+ }
+ }
+ }
+ public TextureOperation AlphaOperation
+ {
+ get { return mAlphaOperation; }
+ set
+ {
+ if (value != mAlphaOperation)
+ {
+ mAlphaOperation = value;
+ mDevice.SetTextureStageState(0, TextureStage.AlphaOperation, value);
+ }
+ }
+ }
+ public void Set2DDrawState()
+ {
+ mDevice.SetRenderState(RenderState.SourceBlend, Blend.SourceAlpha);
+ mDevice.SetRenderState(RenderState.DestinationBlend, Blend.InverseSourceAlpha);
+
+ mDevice.SetSamplerState(0, SamplerState.AddressU, TextureAddress.Clamp);
+ mDevice.SetSamplerState(0, SamplerState.AddressV, TextureAddress.Clamp);
+
+ mDevice.SetSamplerState(0, SamplerState.MagFilter, TextureFilter.Anisotropic);
+ mDevice.SetSamplerState(0, SamplerState.MinFilter, TextureFilter.Anisotropic);
+
+ SetView2D();
+ }
+
+
+ public void SetOrthoProjection(Rectangle region)
+ {
+ Matrix orthoProj = Matrix.OrthoOffCenterRH(
+ region.Left, region.Right, region.Bottom, region.Top, -1, 1);
+
+ mDevice.SetTransform(TransformState.Projection, orthoProj);
+ }
+
+ public void SetView2D()
+ {
+ Matrix world = mWorld2D;
+ //Matrix orthoProj = Matrix.OrthoRH(RenderTarget.Width, -RenderTarget.Height, -1, 1);
+ SetOrthoProjection(new Rectangle(0, 0, RenderTarget.Width, RenderTarget.Height));
+
+ mDevice.SetRenderState(RenderState.CullMode, Cull.None);
+ mDevice.SetRenderState(RenderState.Lighting, false);
+
+ mDevice.SetTransform(TransformState.World, world);
+ mDevice.SetTransform(TransformState.View, Matrix.Identity);
+ }
+ public void SetFontRenderState()
+ {
+ mLastTexture = null;
+ mVertexFormat = VertexFormat.PointSize;
+ }
+
+ public void SetDeviceStateTexture(Texture texture)
+ {
+ SetDeviceStateTexture(texture, 0);
+ }
+ public void SetDeviceStateTexture(Texture texture, int index)
+ {
+ if (texture == mLastTexture[index])
+ return;
+
+ mDevice.SetTexture(index, texture);
+
+ mLastTexture[index] = texture;
+
+ if (texture != null)
+ {
+ AlphaArgument1 = TextureArgument.Texture;
+ AlphaArgument2 = TextureArgument.Diffuse;
+ AlphaOperation = TextureOperation.Modulate;
+ }
+ }
+
+ public void SetOrigin(float x, float y, float z)
+ {
+ Matrix world = Matrix.Translation(x, y, z) * mWorld2D;
+
+ mDevice.SetTransform(TransformState.World, world);
+ }
+
+ public Size MaxSurfaceSize
+ {
+ get
+ {
+ Size retval = new Size(
+ mDevice.Capabilities.MaxTextureWidth, mDevice.Capabilities.MaxTextureHeight);
+
+ return retval;
+ }
+ }
+
+ public void Clear(ClearFlags flags, int color, float zdepth, int stencil)
+ {
+ mDevice.Clear(flags, color, zdepth, stencil);
+ }
+
+ public void Clear(ClearFlags flags, int color, float zdepth, int stencil, System.Drawing.Rectangle[] rects)
+ {
+ mDevice.Clear(flags, color, zdepth, stencil, rects);
+ }
+
+ //public void WriteToSurfaceVBAndRender
+ // (PrimitiveType primitiveType, int primCount, CustomVertex.TransformedColoredTextured[] verts)
+ //{
+ // GraphicsStream stm;
+
+ // if (mSurfaceVBPointer + verts.Length < NumVertices)
+ // {
+ // stm = mSurfaceVB.Lock(mSurfaceVBPointer,
+ // CustomVertex.TransformedColoredTextured.StrideSize * verts.Length,
+ // LockFlags.NoOverwrite);
+
+ // }
+ // else
+ // {
+ // mSurfaceVBPointer = 0;
+
+ // stm = mSurfaceVB.Lock(mSurfaceVBPointer,
+ // CustomVertex.TransformedColoredTextured.StrideSize * verts.Length,
+ // LockFlags.Discard);
+ // }
+
+ // stm.Write(verts);
+
+ // mSurfaceVB.Unlock();
+
+ // mDevice.SetStreamSource(0, mSurfaceVB, 0);
+ // mDevice.VertexFormat = CustomVertex.TransformedColoredTextured.Format;
+ // mDevice.DrawPrimitives(primitiveType, mSurfaceVBPointer, primCount);
+
+ // mSurfaceVBPointer += verts.Length;
+ //}
+
+
+
+ internal void DoLighting(LightManager lights)
+ {
+ if (lights.Enabled == false)
+ {
+ mDevice.SetRenderState(RenderState.Lighting, false);
+ return;
+ }
+
+ mDevice.SetRenderState(RenderState.Lighting, true);
+ mDevice.SetRenderState(RenderState.DiffuseMaterialSource, ColorSource.Color1);
+ mDevice.SetRenderState(RenderState.AmbientMaterialSource, ColorSource.Color1);
+
+ mDevice.SetRenderState(RenderState.Ambient, lights.Ambient.ToArgb());
+
+ //Material mat = new Material();
+ //mat.Diffuse = System.Drawing.Color.White;
+
+ //mDevice.Material = mat;
+ //Direct3D.Light light = new SlimDX.Direct3D9.Light();
+
+ //for (int i = 0; i < mMaxLightsUsed || i < lights.Count; i++)
+ //{
+ // if (i >= lights.Count)
+ // {
+ // mDevice.SetLight(i, Direct3D.Ligh
+ // mDevice.SetLight(i, [i].Enabled = false;
+ // mDevice.Lights[i].Update();
+
+ // continue;
+ // }
+ // if (lights[i].Enabled == false)
+ // {
+ // mDevice.Lights[i].Enabled = false;
+ // mDevice.Lights[i].Update();
+
+ // continue;
+ // }
+
+ // mDevice.Lights[i].Type = LightType.Point;
+
+ // mDevice.Lights[i].Attenuation0 = lights[i].AttenuationConstant;
+ // mDevice.Lights[i].Attenuation1 = lights[i].AttenuationLinear;
+ // mDevice.Lights[i].Attenuation2 = lights[i].AttenuationQuadratic;
+
+ // mDevice.Lights[i].Diffuse = Interop.Convert(lights[i].Diffuse);
+ // mDevice.Lights[i].Ambient = Interop.Convert(lights[i].Ambient);
+ // //mDevice.Lights[i].Specular = (System.Drawing.Color)lights[i].Specular;
+
+ // mDevice.Lights[i].Position = new SlimDX.Vector3(
+ // lights[i].Position.X, lights[i].Position.Y, lights[i].Position.Z);
+
+ // mDevice.Lights[i].Range = lights[i].Range;
+
+ // mDevice.Lights[i].Enabled = true;
+ // mDevice.Lights[i].Update();
+ //}
+
+ mMaxLightsUsed = lights.Count;
+ }
+ }
+}
\ No newline at end of file
Copied: branches/agate3d-3.2/Drivers/AgateSDX/DrawBuffer.cs (from rev 958, branches/agate3d-3.2/Drivers/AgateMDX/DrawBuffer.cs)
===================================================================
--- branches/agate3d-3.2/Drivers/AgateSDX/DrawBuffer.cs (rev 0)
+++ branches/agate3d-3.2/Drivers/AgateSDX/DrawBuffer.cs 2009-05-11 06:04:11 UTC (rev 972)
@@ -0,0 +1,119 @@
+// The contents of this file are subject to the Mozilla Public License
+// Version 1.1 (the "License"); you may not use this file except in
+// compliance with the License. You may obtain a copy of the License at
+// http://www.mozilla.org/MPL/
+//
+// Software distributed under the License is distributed on an "AS IS"
+// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+// License for the specific language governing rights and limitations
+// under the License.
+//
+// The Original Code is AgateLib.
+//
+// The Initial Developer of the Original Code is Erik Ylvisaker.
+// Portions created by Erik Ylvisaker are Copyright (C) 2006-2009.
+// All Rights Reserved.
+//
+// Contributor(s): Erik Ylvisaker
+//
+using System;
+using System.Collections.Generic;
+using System.Runtime.InteropServices;
+using System.Text;
+using SlimDX;
+using SlimDX.Direct3D9;
+using Direct3D = SlimDX.Direct3D9;
+using AgateLib.DisplayLib;
+
+namespace AgateMDX
+{
+ /// <summary>
+ /// Perhaps at some point this should be converted to use a vertex buffer
+ /// instead of a vertex array.
+ /// </summary>
+ public class DrawBuffer
+ {
+ const int vertPageSize = 1000;
+ int pages = 1;
+
+ D3DDevice mDevice;
+
+ PositionColorNormalTexture[] mVerts;
+ short[] mIndices;
+
+ int mVertPointer = 0;
+ int mIndexPointer = 0;
+
+ Texture mTexture;
+ bool mAlphaBlend;
+
+ public DrawBuffer(D3DDevice device)
+ {
+ mDevice = device;
+
+ AllocateVerts();
+ }
+
+ private void AllocateVerts()
+ {
+ mVerts = new PositionColorNormalTexture[vertPageSize * pages];
+ mIndices = new short[vertPageSize / 2 * 3 * pages];
+ }
+ public void CacheDrawIndexedTriangles(PositionColorNormalTexture[] verts, short[] indices,
+ Texture texture, bool alphaBlend)
+ {
+ if (mTexture != texture || mAlphaBlend != alphaBlend)
+ {
+ Flush();
+
+ mTexture = texture;
+ mAlphaBlend = alphaBlend;
+ }
+
+ // increase the number of vertex pages if we don't have enough space.
+ while (mVertPointer + verts.Length > mVerts.Length)
+ {
+ Flush();
+
+ // this is an arbitrary cap on the size of the vertex array.
+ if (pages < 32)
+ pages++;
+
+ AllocateVerts();
+ }
+
+ verts.CopyTo(mVerts, mVertPointer);
+
+ for (int i = 0; i < indices.Length; i++)
+ mIndices[i + mIndexPointer] = (short)(indices[i] + mVertPointer);
+
+ mVertPointer += verts.Length;
+ mIndexPointer += indices.Length;
+
+ }
+
+ public void Flush()
+ {
+ if (mVertPointer == 0)
+ return;
+
+ mDevice.SetDeviceStateTexture(mTexture);
+ mDevice.AlphaBlend = mAlphaBlend;
+ mDevice.VertexFormat = PositionColorNormalTexture.Format;
+
+ try
+ {
+ mDevice.Device.DrawIndexedUserPrimitives
+ (Direct3D.PrimitiveType.TriangleList, 0, mVertPointer,
+ mIndexPointer / 3, mIndices, Format.Index16, mVerts,
+ Marshal.SizeOf(typeof(PositionColorNormalTexture)));
+ }
+ catch { }
+
+ mVertPointer = 0;
+ mIndexPointer = 0;
+
+ }
+
+ }
+}
Copied: branches/agate3d-3.2/Drivers/AgateSDX/HlslCompiler.cs (from rev 963, branches/agate3d-3.2/Drivers/AgateMDX/HlslCompiler.cs)
===================================================================
--- branches/agate3d-3.2/Drivers/AgateSDX/HlslCompiler.cs (rev 0)
+++ branches/agate3d-3.2/Drivers/AgateSDX/HlslCompiler.cs 2009-05-11 06:04:11 UTC (rev 972)
@@ -0,0 +1,50 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using AgateLib.DisplayLib.Shaders;
+using AgateLib.ImplementationBase;
+using Direct3D = SlimDX.Direct3D9;
+
+namespace AgateMDX
+{
+ class HlslCompiler : ShaderCompilerImpl
+ {
+ SDX_Display mDisplay;
+
+ public HlslCompiler(SDX_Display display)
+ {
+ mDisplay = display;
+ }
+
+ public override ShaderProgram CompileEffect(ShaderLanguage language, string effectSource)
+ {
+ throw new NotImplementedException();
+ }
+ //public override ShaderProgram CompileEffect(ShaderLanguage language, string effectSource)
+ //{
+ // Direct3D.Effect effect = Direct3D.Effect.FromString(mDisplay.D3D_Device.Device,
+ // effectSource, null, null, Direct3D.ShaderFlags.None, null);
+
+ // return new HlslShaderProgram(effect);
+ //}
+ public override ShaderProgram CompileShader(ShaderLanguage language, string vertexShaderSource, string pixelShaderSource)
+ {
+ throw new NotImplementedException();
+
+ //var vertexShaderStream = Direct3D.ShaderLoader.CompileShader(
+ // vertexShaderSource, "main", null, "vs_1_1", Direct3D.ShaderFlags.None);
+
+
+ //var vertexShader = new Direct3D.VertexShader(mDisplay.D3D_Device.Device, vertexShaderStream);
+
+
+ //var pixelShaderStream = Direct3D.ShaderLoader.CompileShader(
+ // pixelShaderSource, "main", null, "ps_1_1", Direct3D.ShaderFlags.None);
+
+ //var pixelShader = new Direct3D.PixelShader(mDisplay.D3D_Device.Device, pixelShaderStream);
+
+ //return new HlslShaderProgram(vertexShader, pixelShader);
+ }
+ }
+}
Copied: branches/agate3d-3.2/Drivers/AgateSDX/HlslShaderProgram.cs (from rev 963, branches/agate3d-3.2/Drivers/AgateMDX/HlslShaderProgram.cs)
===================================================================
--- branches/agate3d-3.2/Drivers/AgateSDX/HlslShaderProgram.cs (rev 0)
+++ branches/agate3d-3.2/Drivers/AgateSDX/HlslShaderProgram.cs 2009-05-11 06:04:11 UTC (rev 972)
@@ -0,0 +1,83 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using AgateLib.DisplayLib;
+using AgateLib.DisplayLib.Shaders;
+using Direct3D = SlimDX.Direct3D9;
+
+namespace AgateMDX
+{
+ class HlslShaderProgram : ShaderProgram
+ {
+ Direct3D.VertexShader mVertexShader;
+ Direct3D.PixelShader mPixelShader;
+ SDX_Display mDisplay;
+
+ public HlslShaderProgram(Direct3D.VertexShader vert, Direct3D.PixelShader pix)
+ {
+ mDisplay = (SDX_Display)Display.Impl;
+
+ mVertexShader = vert;
+ mPixelShader = pix;
+ }
+ public override PixelShader PixelShader
+ {
+ get { throw new NotImplementedException(); }
+ }
+
+ public override void SetUniform(string name, AgateLib.Geometry.Matrix4 matrix)
+ {
+
+ }
+
+ public override void SetUniform(string name, params int[] v)
+ {
+
+ }
+
+ public override void SetUniform(string name, params float[] v)
+ {
+
+ }
+
+ public override VertexShader VertexShader
+ {
+ get { throw new NotImplementedException(); }
+ }
+
+ public Direct3D.VertexShader HlslVertexShader
+ {
+ get { return mVertexShader; }
+ }
+ public Direct3D.PixelShader HlslPixelShader
+ {
+ get { return mPixelShader; }
+ }
+
+ public override void Render(RenderHandler handler, object obj)
+ {
+ mDisplay.D3D_Device.Device.VertexShader = mVertexShader;
+ mDisplay.D3D_Device.Device.PixelShader = mPixelShader;
+
+ handler(obj);
+ //int passcount = mEffect.Begin(SlimDX.Direct3D9.FX.None);
+
+ //for (int i = 0; i < passcount; i++)
+ //{
+ // mEffect.BeginPass(i);
+ // handler(obj);
+ // mEffect.EndPass();
+ //}
+
+ //mEffect.End();
+ }
+ }
+
+ class HlslPixelShader : PixelShader
+ {
+ }
+
+ class HlslVertexShader : VertexShader
+ { }
+}
Copied: branches/agate3d-3.2/Drivers/AgateSDX/PositionColorNormalTexture.cs (from rev 922, branches/agate3d-3.2/Drivers/AgateMDX/PositionColorNormalTexture.cs)
===================================================================
--- branches/agate3d-3.2/Drivers/AgateSDX/PositionColorNormalTexture.cs (rev 0)
+++ branches/agate3d-3.2/Drivers/AgateSDX/PositionColorNormalTexture.cs 2009-05-11 06:04:11 UTC (rev 972)
@@ -0,0 +1,89 @@
+// The contents of this file are subject to the Mozilla Public License
+// Version 1.1 (the "License"); you may not use this file except in
+// compliance with the License. You may obtain a copy of the License at
+// http://www.mozilla.org/MPL/
+//
+// Software distributed under the License is distributed on an "AS IS"
+// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+// License for the specific language governing rights and limitations
+// under the License.
+//
+// The Original Code is AgateLib.
+//
+// The Initial Developer of the Original Code is Erik Ylvisaker.
+// Portions created by Erik Ylvisaker are Copyright (C) 2006-2009.
+// All Rights Reserved.
+//
+// Contributor(s): Erik Ylvisaker
+//
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Runtime.InteropServices;
+using SlimDX;
+using SlimDX.Direct3D9;
+
+namespace AgateMDX
+{
+ [StructLayout(LayoutKind.Sequential)]
+ public struct PositionColorNormalTexture
+ {
+ public float X, Y, Z;
+ public float nx, ny, nz;
+ public int Color;
+ public float Tu, Tv;
+
+ public static VertexFormat Format =
+ VertexFormat.PositionNormal | VertexFormat.Diffuse | VertexFormat.Texture1;
+
+ public PositionColorNormalTexture(float x, float y, float z, int color, float tu, float tv,
+ float nx, float ny, float nz)
+ {
+ X = x;
+ Y = y;
+ Z = z;
+ Color = color;
+ Tu = tu;
+ Tv = tv;
+ this.nx = nx;
+ this.ny = ny;
+ this.nz = nz;
+ }
+
+ public override string ToString()
+ {
+ return string.Format("X: {0} Y: {1} Z: {2} Color: {3} Tu: {4}, Tv: {5}",
+ X, Y, Z, Color, Tu, Tv);
+ }
+ }
+
+ [StructLayout(LayoutKind.Sequential)]
+ public struct PositionColored
+ {
+ public float x, y, z;
+ public int Color;
+
+ public Vector3 Position
+ {
+ get { return new Vector3(x, y, z); }
+ set
+ {
+ x = value.X;
+ y = value.Y;
+ z = value.Z;
+ }
+ }
+ public PositionColored(float x, float y, float z, AgateLib.Geometry.Color clr)
+ : this(x, y, z, clr.ToArgb())
+ { }
+ public PositionColored(float x, float y, float z, int clr)
+ {
+ this.x = x;
+ this.y = y;
+ this.z = z;
+ this.Color = clr;
+ }
+ public static VertexFormat Format =
+ VertexFormat.Position | VertexFormat.Diffuse;
+ }
+}
Added: branches/agate3d-3.2/Drivers/AgateSDX/Properties/AssemblyInfo.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateSDX/Properties/AssemblyInfo.cs (rev 0)
+++ branches/agate3d-3.2/Drivers/AgateSDX/Properties/AssemblyInfo.cs 2009-05-11 06:04:11 UTC (rev 972)
@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("AgateSDX")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("AgateSDX")]
+[assembly: AssemblyCopyright("Copyright © 2009")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("04704349-3b13-4991-97c6-c5e78fe93806")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
Copied: branches/agate3d-3.2/Drivers/AgateSDX/Reporter.cs (from rev 922, branches/agate3d-3.2/Drivers/AgateMDX/Reporter.cs)
===================================================================
--- branches/agate3d-3.2/Drivers/AgateSDX/Reporter.cs (rev 0)
+++ branches/agate3d-3.2/Drivers/AgateSDX/Reporter.cs 2009-05-11 06:04:11 UTC (rev 972)
@@ -0,0 +1,49 @@
+// The contents of this file are subject to the Mozilla Public License
+// Version 1.1 (the "License"); you may not use this file except in
+// compliance with the License. You may obtain a copy of the License at
+// http://www.mozilla.org/MPL/
+//
+// Software distributed under the License is distributed on an "AS IS"
+// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+// License for the specific language governing rights and limitations
+// under the License.
+//
+// The Original Code is AgateLib.
+//
+// The Initial Developer of the Original Code is Erik Ylvisaker.
+// Portions created by Erik Ylvisaker are Copyright (C) 2006-2009.
+// All Rights Reserved.
+//
+// Contributor(s): Erik Ylvisaker
+//
+using System;
+using System.Collections.Generic;
+using System.Text;
+using AgateLib.Drivers;
+
+namespace AgateMDX
+{
+ class Reporter : AgateDriverReporter
+ {
+ public override IEnumerable<AgateDriverInfo> ReportDrivers()
+ {
+ yield return new AgateDriverInfo(
+ DisplayTypeID.Direct3D9_SDX,
+ typeof(SDX_Display),
+ "SlimDX - Direct3D 9",
+ 500);
+
+ //yield return new AgateDriverInfo(
+ // AudioTypeID.DirectSound,
+ // typeof(MDX1_Audio),
+ // "Managed DirectX 1.1 - DirectSound",
+ // 100);
+
+ //yield return new AgateDriverInfo(
+ // InputTypeID.DirectInput,
+ // typeof(MDX1_Input),
+ // "Managed DirectX 1.1 - DirectInput",
+ // 100);
+ }
+ }
+}
Copied: branches/agate3d-3.2/Drivers/AgateSDX/SDX_Display.cs (from rev 963, branches/agate3d-3.2/Drivers/AgateMDX/MDX1_Display.cs)
===================================================================
--- branches/agate3d-3.2/Drivers/AgateSDX/SDX_Display.cs (rev 0)
+++ branches/agate3d-3.2/Drivers/AgateSDX/SDX_Display.cs 2009-05-11 06:04:11 UTC (rev 972)
@@ -0,0 +1,1064 @@
+// The contents of this file are subject to the Mozilla Public License
+// Version 1.1 (the "License"); you may not use this file except in
+// compliance with the License. You may obtain a copy of the License at
+// http://www.mozilla.org/MPL/
+//
+// Software distributed under the License is distributed on an "AS IS"
+// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+// License for the specific language governing rights and limitations
+// under the License.
+//
+// The Original Code is AgateLib.
+//
+// The Initial Developer of the Original Code is Erik Ylvisaker.
+// Portions created by Erik Ylvisaker are Copyright (C) 2006-2009.
+// All Rights Reserved.
+//
+// Contributor(s): Erik Ylvisaker
+//
+using System;
+using System.Collections.Generic;
+using System.Text;
+using Direct3D = SlimDX.Direct3D9;
+using SlimDX.Direct3D9;
+using SlimDX;
+
+using AgateLib.BitmapFont;
+using AgateLib.DisplayLib;
+using AgateLib.Drivers;
+using AgateLib.Geometry;
+using AgateLib.ImplementationBase;
+using AgateLib.WinForms;
+
+using Vector2 = SlimDX.Vector2;
+using ImageFileFormat = AgateLib.DisplayLib.ImageFileFormat;
+
+namespace AgateMDX
+{
+ public class SDX_Display : DisplayImpl, IDisplayCaps, AgateLib.PlatformSpecific.IPlatformServices
+ {
+ #region --- Private Variables ---
+
+ private Direct3D.Direct3D mDirect3Dobject;
+ private D3DDevice mDevice;
+
+ private SDX_IRenderTarget mRenderTarget;
+
+ private bool mInitialized = false;
+
+ // variables for drawing primitives
+ PositionColored[] mLines = new PositionColored[5];
+ PositionColored[] mFillRectVerts = new PositionColored[6];
+
+ private bool mVSync = true;
+
+ private bool mHasDepth;
+ private bool mHasStencil;
+ private float mDepthClear = 1.0f;
+ private int mStencilClear = 0;
+
+ #endregion
+
+ public DisplayMode DisplayMode
+ {
+ get
+ {
+ return mDirect3Dobject.GetAdapterDisplayMode(0);
+ }
+ }
+
+ #region --- Creation / Destruction ---
+
+ public override void Initialize()
+ {
+ mDirect3Dobject = new SlimDX.Direct3D9.Direct3D();
+ Report("SlimDX driver instantiated for display.");
+ }
+
+ internal void Initialize(SDX_DisplayWindow window)
+ {
+ if (mInitialized)
+ return;
+
+ if (window.RenderTarget.TopLevelControl == null)
+ throw new ArgumentException("The specified render target does not have a Form object yet. " +
+ "It's TopLevelControl property is null. You may not create DisplayWindow objects before " +
+ "the control to render to is added to the Form.");
+
+ mInitialized = true;
+
+ // ok, create D3D device
+ PresentParameters present = CreateWindowedPresentParameters(window, 0, 0);
+
+ DeviceType dtype = DeviceType.Hardware;
+
+ int adapterOrdinal = mDirect3Dobject.Adapters.DefaultAdapter.Adapter;
+
+ var caps = mDirect3Dobject.GetDeviceCaps(adapterOrdinal, Direct3D.DeviceType.Hardware);
+ var flags = Direct3D.CreateFlags.SoftwareVertexProcessing;
+
+ // Is there support for hardware vertex processing? If so, replace
+ // software vertex processing.
+ if ((caps.DeviceCaps & DeviceCaps.HWTransformAndLight) == DeviceCaps.HWTransformAndLight)
+ flags = Direct3D.CreateFlags.HardwareVertexProcessing;
+
+ // Does the device support a pure device?
+ if ((caps.DeviceCaps & DeviceCaps.PureDevice) == DeviceCaps.PureDevice)
+ flags |= Direct3D.CreateFlags.PureDevice;
+
+ Device device = new Device(mDirect3Dobject, adapterOrdinal, dtype,
+ window.RenderTarget.TopLevelControl.Handle,
+ flags, present);
+
+ try
+ {
+ Format f = (Format)device.DepthStencilSurface.Description.Format;
+ SetHaveDepthStencil(f);
+ }
+ catch
+ {
+ mHasDepth = false;
+ mHasStencil = false;
+ }
+
+ //device.DeviceLost += new EventHandler(mDevice_DeviceLost);
+ //device.DeviceReset += new EventHandler(mDevice_DeviceReset);
+
+ device.SetRenderState(RenderState.StencilEnable, false);
+ device.SetRenderState(RenderState.ZEnable, true);
+
+ mDevice = new D3DDevice(device);
+
+ InitializeShaders();
+
+ }
+
+ private void SetHaveDepthStencil(Format depthFormat)
+ {
+ switch (depthFormat)
+ {
+ case Format.D24X4S4:
+ case Format.D24S8:
+ case Format.D15S1:
+ mHasStencil = true;
+ mHasDepth = true;
+ break;
+
+ case Format.D24X8:
+ case Format.D32:
+ case Format.D16:
+ mHasStencil = false;
+ mHasDepth = true;
+ break;
+
+ default:
+ mHasDepth = false;
+ mHasStencil = false;
+ break;
+ }
+ }
+
+ public override void Dispose()
+ {
+ mDevice.Dispose();
+ }
+
+ #endregion
+
+ #region --- Implementation Specific Public Properties ---
+
+ public D3DDevice D3D_Device
+ {
+ get { return mDevice; }
+ }
+
+ #endregion
+
+ #region --- Events ---
+
+ public event EventHandler DeviceReset;
+ public event EventHandler DeviceLost;
+ public event EventHandler DeviceAboutToReset;
+
+ private void OnDeviceReset()
+ {
+ System.Diagnostics.Debug.Print("{0} Device Reset", DateTime.Now);
+
+ if (DeviceReset != null)
+ DeviceReset(this, EventArgs.Empty);
+ }
+ private void OnDeviceLost()
+ {
+ System.Diagnostics.Debug.Print("{0} Device Lost", DateTime.Now);
+
+ if (DeviceLost != null)
+ DeviceLost(this, EventArgs.Empty);
+ }
+ private void OnDeviceAboutToReset()
+ {
+ System.Diagnostics.Debug.Print("{0} Device About to Reset", DateTime.Now);
+
+ if (DeviceAboutToReset != null)
+ DeviceAboutToReset(this, EventArgs.Empty);
+ }
+
+
+ #endregion
+ #region --- Event Handlers ---
+
+ void mDevice_DeviceReset(object sender, EventArgs e)
+ {
+ OnDeviceReset();
+ }
+
+ void mDevice_DeviceLost(object sender, EventArgs e)
+ {
+ OnDeviceLost();
+ }
+
+
+ #endregion
+
+ #region --- Creation of objects ---
+
+ public override DisplayWindowImpl CreateDisplayWindow(CreateWindowParams windowParams)
+ {
+ return new SDX_DisplayWindow(windowParams);
+ }
+ public override SurfaceImpl CreateSurface(string fileName)
+ {
+ return new SDX_Surface(fileName);
+ }
+ public override SurfaceImpl CreateSurface(Size surfaceSize)
+ {
+ return new SDX_Surface(surfaceSize);
+ }
+ public override SurfaceImpl CreateSurface(System.IO.Stream fileStream)
+ {
+ return new SDX_Surface(fileStream);
+ }
+
+ public override FontSurfaceImpl CreateFont(string fontFamily, float sizeInPoints, FontStyle style)
+ {
+ BitmapFontOptions options = new BitmapFontOptions(fontFamily, sizeInPoints, style);
+
+ return BitmapFontUtil.ConstructFromOSFont(options);
+ }
+ public override FontSurfaceImpl CreateFont(BitmapFontOptions bitmapOptions)
+ {
+ return BitmapFontUtil.ConstructFromOSFont(bitmapOptions);
+ }
+ protected override ShaderCompilerImpl CreateShaderCompiler()
+ {
+ return new HlslCompiler(this);
+ }
+
+ #endregion
+
+ #region --- BeginFrame stuff and DeltaTime ---
+
+ protected override void OnBeginFrame()
+ {
+ mRenderTarget.BeginRender();
+
+ SetClipRect(new Rectangle(new Point(0, 0), mRenderTarget.Size));
+
+ mDevice.Set2DDrawState();
+
+ }
+ protected override void OnEndFrame()
+ {
+ mDevice.DrawBuffer.Flush();
+
+ while (mClipRects.Count > 0)
+ PopClipRect();
+
+ mRenderTarget.EndRender();
+
+ }
+
+ #endregion
+
+ #region --- Clip Rect stuff ---
+
+ public override void SetClipRect(Rectangle newClipRect)
+ {
+ if (newClipRect.X < 0)
+ {
+ newClipRect.Width += newClipRect.X;
+ newClipRect.X = 0;
+ }
+ if (newClipRect.Y < 0)
+ {
+ newClipRect.Height += newClipRect.Y;
+ newClipRect.Y = 0;
+ }
+ if (newClipRect.Right > mRenderTarget.Width)
+ {
+ newClipRect.Width -= newClipRect.Right - mRenderTarget.Width;
+ }
+ if (newClipRect.Bottom > mRenderTarget.Height)
+ {
+ newClipRect.Height -= newClipRect.Bottom - mRenderTarget.Height;
+ }
+
+ if (mRenderTarget.Width == 0 || mRenderTarget.Height == 0)
+ return;
+
+ Viewport view = new Viewport();
+
+ view.X = newClipRect.X;
+ view.Y = newClipRect.Y;
+ view.Width = newClipRect.Width;
+ view.Height = newClipRect.Height;
+
+ //mDevice.Device.Viewport = view;
+ mCurrentClipRect = newClipRect;
+
+ SetOrthoProjection(newClipRect);
+ }
+ public override void PushClipRect(Rectangle newClipRect)
+ {
+ mClipRects.Push(mCurrentClipRect);
+ SetClipRect(newClipRect);
+ }
+ public override void PopClipRect()
+ {
+ if (mClipRects.Count == 0)
+ {
+ throw new Exception("You have popped the cliprect too many times.");
+ }
+ else
+ {
+ SetClipRect(mClipRects.Pop());
+ }
+ }
+
+ private Stack<Rectangle> mClipRects = new Stack<Rectangle>();
+ private Rectangle mCurrentClipRect;
+
+ #endregion
+ #region --- Methods for drawing to the back buffer ---
+
+ ClearFlags ClearFlags
+ {
+ get
+ {
+ ClearFlags retval = ClearFlags.Target;
+
+ if (mHasDepth) retval |= ClearFlags.ZBuffer;
+ if (mHasStencil) retval |= ClearFlags.Stencil;
+
+ return retval;
+ }
+ }
+ public override void Clear(Color color)
+ {
+ mDevice.DrawBuffer.Flush();
+
+ mDevice.Clear(ClearFlags, color.ToArgb(), mDepthClear, mStencilClear);
+
+ var device = mDevice.Device;
+
+ device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, color.ToArgb(), 1.0f, 0);
+
+ device.Clear(ClearFlags.Target, color.ToArgb(), 0, 0);
+ device.Clear(ClearFlags.ZBuffer, 0, 1.0f, 0);
+
+ System.Drawing.Rectangle[] rect = new System.Drawing.Rectangle[1];
+ rect[0] = new System.Drawing.Rectangle(0, 0, 800, 600);
+ device.Clear(ClearFlags.ZBuffer, color.ToArgb(), 1.0f, 0, rect);
+
+ }
+ public override void Clear(Color color, Rectangle rect)
+ {
+ mDevice.DrawBuffer.Flush();
+
+ System.Drawing.Rectangle[] rects = new System.Drawing.Rectangle[1];
+ rects[0] = Interop.Convert(rect);
+
+ mDevice.Clear(ClearFlags, color.ToArgb(), mDepthClear, mStencilClear, rects);
+ }
+
+
+ public override void DrawLine(int x1, int y1, int x2, int y2, Color color)
+ {
+ DrawLine(new Point(x1, y1), new Point(x2, y2), color);
+ }
+ public override void DrawLine(Point a, Point b, Color color)
+ {
+ mDevice.DrawBuffer.Flush();
+
+ mLines[0] = new PositionColored(a.X, a.Y, 0, color.ToArgb());
+ mLines[1] = new PositionColored(b.X, b.Y, 0, color.ToArgb());
+
+ mDevice.VertexFormat = PositionColored.Format;
+ mDevice.Device.DrawUserPrimitives(SlimDX.Direct3D9.PrimitiveType.LineList, 1, mLines);
+ }
+ public override void DrawLines(Point[] pt, Color color)
+ {
+ mDevice.DrawBuffer.Flush();
+
+ if (pt.Length > mLines.Length)
+ mLines = new PositionColored[pt.Length];
+
+ for (int i = 0; i < pt.Length; i++)
+ {
+ mLines[i] = new PositionColored(pt[i].X, pt[i].Y, 0, color.ToArgb());
+ }
+
+ mDevice.VertexFormat = PositionColored.Format;
+ mDevice.Device.DrawUserPrimitives(Direct3D.PrimitiveType.LineList, pt.Length / 2, mLines);
+ }
+ 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)
+ {
+ mDevice.DrawBuffer.Flush();
+
+ int c = color.ToArgb();
+
+ mLines[0] = new PositionColored(rect.X, rect.Y, 0, c);
+ mLines[1] = new PositionColored(rect.Right, rect.Y, 0, c);
+ mLines[2] = new PositionColored(rect.Right, rect.Bottom, 0, c);
+ mLines[3] = new PositionColored(rect.X, rect.Bottom, 0, c);
+ mLines[4] = new PositionColored(rect.X, rect.Y, 0, c);
+
+ mDevice.VertexFormat = PositionColored.Format;
+ mDevice.Device.DrawUserPrimitives(Direct3D.PrimitiveType.LineStrip, 4, mLines);
+ }
+
+ public override void FillRect(Rectangle rect, Color color)
+ {
+ FillRect((RectangleF)rect, new Gradient(color));
+ }
+ public override void FillRect(RectangleF rect, Color color)
+ {
+ FillRect(rect, new Gradient(color));
+ }
+ public override void FillRect(Rectangle rect, Gradient color)
+ {
+ FillRect((RectangleF)rect, color);
+ }
+ public override void FillRect(RectangleF rect, Gradient color)
+ {
+ // defining our screen sized quad, note the Z value of 1f to place it in the background
+ mFillRectVerts[0].Position = new SlimDX.Vector3(rect.Left, rect.Top, 0f);
+ mFillRectVerts[0].Color = color.TopLeft.ToArgb();
+
+ mFillRectVerts[1].Position = new SlimDX.Vector3(rect.Right, rect.Top, 0f);
+ mFillRectVerts[1].Color = color.TopRight.ToArgb();
+
+ mFillRectVerts[2].Position = new SlimDX.Vector3(rect.Left, rect.Bottom, 0f);
+ mFillRectVerts[2].Color = color.BottomLeft.ToArgb();
+
+ mFillRectVerts[3] = mFillRectVerts[1];
+
+ mFillRectVerts[4].Position = new SlimDX.Vector3(rect.Right, rect.Bottom, 0f);
+ mFillRectVerts[4].Color = color.BottomRight.ToArgb();
+
+ mFillRectVerts[5] = mFillRectVerts[2];
+
+ mDevice.DrawBuffer.Flush();
+
+ mDevice.AlphaBlend = true;
+
+ mDevice.SetDeviceStateTexture(null);
+ mDevice.AlphaArgument1 = TextureArgument.Diffuse;
+
+ mDevice.VertexFormat = PositionColored.Format;
+ mDevice.Device.DrawUserPrimitives(Direct3D.PrimitiveType.TriangleList, 2, mFillRectVerts);
+ mDevice.AlphaArgument1 = TextureArgument.Texture;
+ }
+
+
+
+
+ #endregion
+
+ #region --- Display Mode changing stuff ---
+
+ protected override void OnRenderTargetResize()
+ {
+
+ }
+ protected override void OnRenderTargetChange(IRenderTarget oldRenderTarget)
+ {
+ mRenderTarget = RenderTarget.Impl as SDX_IRenderTarget;
+ mDevice.RenderTarget = mRenderTarget;
+ }
+
+ internal SwapChain CreateSwapChain(SDX_DisplayWindow displayWindow,
+ int width, int height, int bpp, bool fullScreen)
+ {
+ if (fullScreen == true)
+ {
+ PresentParameters present = CreateFullScreenPresentParameters(displayWindow, width, height, bpp);
+
+ OnDeviceAboutToReset();
+
+ System.Diagnostics.Debug.Print("{0} Going to full screen...", DateTime.Now);
+ mDevice.Device.Reset(present);
+ System.Diagnostics.Debug.Print("{0} Full screen success.", DateTime.Now);
+
+ return mDevice.Device.GetSwapChain(0);
+ }
+ else
+ {
+ PresentParameters present = CreateWindowedPresentParameters(displayWindow, width, height);
+
+ if (displayWindow.mSwap != null && displayWindow.IsFullScreen == true)
+ {
+ // if we are in full screen mode already, we must
+ // reset the device before creating the windowed swap chain.
+ present.BackBufferHeight = 1;
+ present.BackBufferWidth = 1;
+ present.DeviceWindowHandle = displayWindow.RenderTarget.TopLevelControl.Handle;
+
+ OnDeviceAboutToReset();
+
+ System.Diagnostics.Debug.Print("{0} Going to windowed mode...", DateTime.Now);
+ mDevice.Device.Reset(present);
+ System.Diagnostics.Debug.Print("{0} Windowed mode success.", DateTime.Now);
+
+
+ present = CreateWindowedPresentParameters(displayWindow, width, height);
+
+ }
+
+ return new Direct3D.SwapChain(mDevice.Device, present);
+ }
+ }
+
+ private PresentParameters CreateFullScreenPresentParameters(SDX_DisplayWindow displayWindow,
+ int width, int height, int bpp)
+ {
+ PresentParameters present = CreateBasePresentParams(displayWindow);
+
+ present.SwapEffect = SwapEffect.Flip;
+ present.Windowed = false;
+
+ SelectBestDisplayMode(present, bpp);
+
+ return present;
+ }
+
+ private PresentParameters CreateWindowedPresentParameters(SDX_DisplayWindow displayWindow,
+ int width, int height)
+ {
+ PresentParameters present = CreateBasePresentParams(displayWindow);
+
+ return present;
+ }
+
+ private PresentParameters CreateBasePresentParams(SDX_DisplayWindow displayWindow)
+ {
+ PresentParameters present = new PresentParameters();
+
+ present.BackBufferCount = 1;
+ present.AutoDepthStencilFormat = GetDepthFormat(Format.A8R8G8B8);
+ present.EnableAutoDepthStencil = true;
+ present.DeviceWindowHandle = displayWindow.RenderTarget.Handle;
+ present.BackBufferWidth = displayWindow.Width;
+ present.BackBufferHeight = displayWindow.Height;
+ present.BackBufferFormat = Format.Unknown;
+ present.SwapEffect = SwapEffect.Discard;
+ present.Windowed = true;
+
+ if (present.AutoDepthStencilFormat == Format.Unknown)
+ present.EnableAutoDepthStencil = false;
+
+ if (VSync)
+ present.PresentationInterval = PresentInterval.Default;
+ else
+ present.PresentationInterval = PresentInterval.Immediate;
+
+ return present;
+ }
+ private Format GetDepthFormat(Format backbufferFormat)
+ {
+ Format[] formats = new Format[]
+ {
+ Format.D24S8,
+ Format.D24X4S4,
+ Format.D24X8,
+ Format.D15S1,
+ Format.D32,
+ Format.D16,
+ };
+
+ var adapter = mDirect3Dobject.Adapters.DefaultAdapter.Adapter;
+ Format deviceFormat = GetDeviceFormat(backbufferFormat);
+
+ foreach (var depthFormat in formats)
+ {
+ if (mDirect3Dobject.CheckDeviceFormat(adapter, DeviceType.Hardware, deviceFormat,
+ Usage.DepthStencil, ResourceType.Surface, depthFormat) == false)
+ {
+ continue;
+ }
+ if (mDirect3Dobject.CheckDepthStencilMatch(adapter, DeviceType.Hardware,
+ deviceFormat, backbufferFormat, depthFormat) == false)
+ {
+ continue;
+ }
+
+ return depthFormat;
+ }
+
+ return Format.Unknown;
+ }
+ private Format GetDeviceFormat(Format backbufferFormat)
+ {
+ switch (backbufferFormat)
+ {
+ case Format.A8R8G8B8: return Format.X8R8G8B8;
+ case Format.A8B8G8R8: return Format.X8B8G8R8;
+ case Format.A1R5G5B5: return Format.X1R5G5B5;
+
+ default:
+ return backbufferFormat;
+ }
+ }
+
+ public override ScreenMode[] EnumScreenModes()
+ {
+ List<ScreenMode> modes = new List<ScreenMode>();
+
+
+ DisplayModeCollection dxmodes = mDirect3Dobject.Adapters[0].GetDisplayModes(Format.X8B8G8R8);
+ ConvertDisplayModesToScreenModes(modes, dxmodes);
+
+ dxmodes = mDirect3Dobject.Adapters[0].GetDisplayModes(Format.R5G6B5);
+ ConvertDisplayModesToScreenModes(modes, dxmodes);
+
+ return modes.ToArray();
+ }
+
+ private static void ConvertDisplayModesToScreenModes(List<ScreenMode> modes, DisplayModeCollection dxmodes)
+ {
+ foreach (DisplayMode mode in dxmodes)
+ {
+ int bits;
+
+ switch (mode.Format)
+ {
+ case Format.A8B8G8R8:
+ case Format.X8B8G8R8:
+ case Format.X8R8G8B8:
+ case Format.A8R8G8B8:
+ bits = 32;
+ break;
+
+ case Format.R8G8B8:
+ bits = 24;
+ break;
+
+ case Format.R5G6B5:
+ case Format.X4R4G4B4:
+ case Format.X1R5G5B5:
+ bits = 16;
+ break;
+
+ default:
+ continue;
+ }
+
+ modes.Add(new ScreenMode(mode.Width, mode.Height, bits));
+ }
+ }
+ Format GetDisplayModeTrialPixelFormat(int bpp)
+ {
+ switch (bpp)
+ {
+ case 32:
+ return Format.X8R8G8B8;
+ case 24:
+ return Format.R8G8B8;
+ case 16:
+ return Format.R5G6B5;
+ case 15:
+ return Format.X1R5G5B5;
+ default:
+ throw new ArgumentException("Bits per pixel must be 32, 16, or 15.");
+ }
+ }
+ private void SelectBestDisplayMode(PresentParameters present, int bpp)
+ {
+ Format fmt = GetDisplayModeTrialPixelFormat(bpp);
+
+ DisplayModeCollection modes = mDirect3Dobject.Adapters[0].GetDisplayModes(fmt);
+
+ DisplayMode selected = new DisplayMode();
+ int diff = 0;
+
+ foreach (DisplayMode mode in modes)
+ {
+ if (mode.Width < present.BackBufferWidth)
+ continue;
+
+ if (mode.Height < present.BackBufferHeight)
+ continue;
+
+ int thisDiff = Math.Abs(present.BackBufferWidth - mode.Width)
+ + Math.Abs(present.BackBufferHeight - mode.Height);
+
+ int bits = 0;
+
+ switch (mode.Format)
+ {
+ case Format.A8B8G8R8:
+ case Format.X8B8G8R8:
+ thisDiff += 10;
+ goto case Format.X8R8G8B8;
+
+ case Format.X8R8G8B8:
+ case Format.A8R8G8B8:
+ bits = 32;
+ break;
+
+ case Format.R5G6B5:
+ case Format.X4R4G4B4:
+ case Format.X1R5G5B5:
+ bits = 16;
+ break;
+
+ default:
+ System.Diagnostics.Debug.Print("Unknown backbuffer format {0}.", mode.Format);
+ continue;
+ }
+
+ thisDiff += Math.Abs(bits - bpp);
+
+ // first mode by default, or any mode which is a better match.
+ if (selected.Height == 0 || thisDiff < diff)
+ {
+ selected = mode;
+ diff = thisDiff;
+ }
+
+ }
+
+
+ present.BackBufferFormat = selected.Format;
+ present.BackBufferWidth = selected.Width;
+ present.BackBufferHeight = selected.Height;
+ //present.FullScreenRefreshRateInHz = selected.RefreshRate;
+
+ }
+
+
+ #endregion
+
+ #region --- Drawing Helper Functions ---
+
+ #endregion
+
+ protected override void ProcessEvents()
+ {
+ System.Windows.Forms.Application.DoEvents();
+ }
+
+ internal event EventHandler VSyncChanged;
+ private void OnVSyncChanged()
+ {
+ if (VSyncChanged != null)
+ VSyncChanged(this, EventArgs.Empty);
+ }
+ public override bool VSync
+ {
+ get
+ {
+ return mVSync;
+ }
+ set
+ {
+ mVSync = value;
+
+ OnVSyncChanged();
+ }
+ }
+ public override Size MaxSurfaceSize
+ {
+ get { return mDevice.MaxSurfaceSize; }
+ }
+
+ internal int GetPixelPitch(Format format)
+ {
+ switch (format)
+ {
+ case Format.A8R8G8B8:
+ case Format.A8B8G8R8:
+ case Format.X8B8G8R8:
+ return 4;
+
+ case Format.R8G8B8:
+ return 3;
+
+ default:
+ throw new NotSupportedException("Format not supported.");
+ }
+ }
+ internal PixelFormat GetPixelFormat(Format format)
+ {
+ switch (format)
+ {
+ case Format.A8R8G8B8: return PixelFormat.BGRA8888;
+ case Format.A8B8G8R8: return PixelFormat.RGBA8888;
+ case Format.X8B8G8R8: return PixelFormat.RGBA8888; // TODO: fix this one
+ case Format.X8R8G8B8: return PixelFormat.BGRA8888; // TODO: fix this one
+
+ default:
+ throw new NotSupportedException("Format not supported.");
+
+ }
+ }
+ public override PixelFormat DefaultSurfaceFormat
+ {
+ get { return PixelFormat.RGBA8888; }
+ }
+
+ public override void FlushDrawBuffer()
+ {
+ mDevice.DrawBuffer.Flush();
+ }
+ public override void SetOrthoProjection(Rectangle region)
+ {
+ mDevice.SetOrthoProjection(region);
+ }
+ public override void DoLighting(LightManager lights)
+ {
+ FlushDrawBuffer();
+ mDevice.DoLighting(lights);
+ }
+
+ protected override void SavePixelBuffer(PixelBuffer pixelBuffer, string filename, ImageFileFormat format)
+ {
+ FormUtil.SavePixelBuffer(pixelBuffer, filename, format);
+ }
+
+ public override IDisplayCaps Caps
+ {
+ get { return this; }
+ }
+
+ protected override void HideCursor()
+ {
+ System.Windows.Forms.Cursor.Hide();
+ }
+ protected override void ShowCursor()
+ {
+ System.Windows.Forms.Cursor.Show();
+ }
+
+ #region --- IDisplayCaps Members ---
+
+ bool IDisplayCaps.SupportsScaling
+ {
+ get { return true; }
+ }
+
+ bool IDisplayCaps.SupportsRotation
+ {
+ get { return true; }
+ }
+
+ bool IDisplayCaps.SupportsColor
+ {
+ get { return true; }
+ }
+ bool IDisplayCaps.SupportsGradient
+ {
+ get { return true; }
+ }
+ bool IDisplayCaps.SupportsSurfaceAlpha
+ {
+ get { return true; }
+ }
+
+ bool IDisplayCaps.SupportsPixelAlpha
+ {
+ get { return true; }
+ }
+
+ bool IDisplayCaps.SupportsLighting
+ {
+ get { return true; }
+ }
+
+ int IDisplayCaps.MaxLights
+ {
+ get
+ {
+ Capabilities c = mDirect3Dobject.Adapters[0].GetCaps(DeviceType.Hardware);
+
+ return c.MaxActiveLights;
+ }
+ }
+
+ bool IDisplayCaps.IsHardwareAccelerated
+ {
+ get { return true; }
+ }
+ bool IDisplayCaps.Supports3D
+ {
+ get { return true; }
+ }
+
+ bool IDisplayCaps.SupportsFullScreen
+ {
+ get { return true; }
+ }
+ bool IDisplayCaps.SupportsFullScreenModeSwitching
+ {
+ get { return true; }
+ }
+ bool IDisplayCaps.SupportsShaders
+ {
+ get { return true; }
+ }
+
+ AgateLib.DisplayLib.Shaders.ShaderLanguage IDisplayCaps.ShaderLanguage
+ {
+ get { return AgateLib.DisplayLib.Shaders.ShaderLanguage.Hlsl; }
+ }
+
+ #endregion
+
+ bool IDisplayCaps.CanCreateBitmapFont
+ {
+ get { return true; }
+ }
+
+ #region --- 3D stuff ---
+
+ Matrix4 projection = Matrix4.Identity;
+ Matrix4 world = Matrix4.Identity;
+ Matrix4 view = Matrix4.Identity;
+
+ protected override VertexBufferImpl CreateVertexBuffer(
+ AgateLib.Geometry.VertexTypes.VertexLayout layout, int vertexCount)
+ {
+ return new SDX_VertexBuffer(this, layout, vertexCount);
+ }
+ protected override IndexBufferImpl CreateIndexBuffer(IndexBufferType type, int size)
+ {
+ return new SDX_IndexBuffer(this, type, size);
+ }
+
+ private Matrix TransformAgateMatrix(Matrix4 value)
+ {
+ Matrix retval = new Matrix();
+
+ retval.M11 = value[0, 0];
+ retval.M12 = value[1, 0];
+ retval.M13 = value[2, 0];
+ retval.M14 = value[3, 0];
+
+ retval.M21 = value[0, 1];
+ retval.M22 = value[1, 1];
+ retval.M23 = value[2, 1];
+ retval.M24 = value[3, 1];
+
+ retval.M31 = value[0, 2];
+ retval.M32 = value[1, 2];
+ retval.M33 = value[2, 2];
+ retval.M34 = value[3, 2];
+
+ retval.M41 = value[0, 3];
+ retval.M42 = value[1, 3];
+ retval.M43 = value[2, 3];
+ retval.M44 = value[3, 3];
+
+ return retval;
+ }
+ public override Matrix4 MatrixProjection
+ {
+ get
+ {
+ return projection;
+ }
+ set
+ {
+ //value = Matrix4.Projection(45, 800 / 600f, 1f, 1000f);
+ var x = SlimDX.Matrix.PerspectiveFovRH(
+ (float)(45 * Math.PI / 180), 800 / 600f, 1f, 1000f);
+
+ projection = value;
+ mDevice.Device.SetTransform(TransformState.Projection,
+ TransformAgateMatrix(value));
+ }
+ }
+
+ public override Matrix4 MatrixView
+ {
+ get
+ {
+ return view;
+ }
+ set
+ {
+ view = value;
+
+ mDevice.Device.SetTransform(TransformState.View,
+ TransformAgateMatrix(value));
+ }
+ }
+ public override Matrix4 MatrixWorld
+ {
+ get
+ {
+ return world;
+ }
+ set
+ {
+ world = value;
+
+ mDevice.Device.SetTransform(TransformState.World,
+ TransformAgateMatrix(value));
+ }
+ }
+
+ Matrix GetTotalTransform()
+ {
+ return TransformAgateMatrix(MatrixProjection * MatrixView * MatrixWorld);
+ }
+
+ HlslShaderProgram mShader;
+
+ public override AgateLib.DisplayLib.Shaders.ShaderProgram Shader
+ {
+ get
+ {
+ return mShader;
+ }
+ set
+ {
+ if (mShader == value)
+ return;
+
+ mShader = (HlslShaderProgram) value;
+
+ mDevice.Device.VertexShader = mShader.HlslVertexShader;
+ mDevice.Device.PixelShader = mShader.HlslPixelShader;
+
+ }
+ }
+ #endregion
+
+ #region --- IPlatformServices Members ---
+
+ protected override AgateLib.PlatformSpecific.IPlatformServices GetPlatformServices()
+ {
+ return this;
+ }
+ AgateLib.Utility.PlatformType AgateLib.PlatformSpecific.IPlatformServices.PlatformType
+ {
+ get { return AgateLib.Utility.PlatformType.Windows; }
+ }
+
+ #endregion
+ }
+}
\ No newline at end of file
Copied: branches/agate3d-3.2/Drivers/AgateSDX/SDX_DisplayWindow.cs (from rev 922, branches/agate3d-3.2/Drivers/AgateMDX/MDX1_DisplayWindow.cs)
===================================================================
--- branches/agate3d-3.2/Drivers/AgateSDX/SDX_DisplayWindow.cs (rev 0)
+++ branches/agate3d-3.2/Drivers/AgateSDX/SDX_DisplayWindow.cs 2009-05-11 06:04:11 UTC (rev 972)
@@ -0,0 +1,496 @@
+// 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 Drawing = System.Drawing;
+using System.Text;
+using System.Threading;
+using System.Windows.Forms;
+using Direct3D = SlimDX.Direct3D9;
+using SlimDX.Direct3D9;
+using SlimDX;
+using AgateLib;
+using AgateLib.DisplayLib;
+using AgateLib.Geometry;
+using AgateLib.ImplementationBase;
+using AgateLib.InputLib;
+using AgateLib.WinForms;
+
+namespace AgateMDX
+{
+ public class SDX_DisplayWindow : DisplayWindowImpl, SDX_IRenderTarget
+ {
+ Form frm;
+ Control mRenderTarget;
+ bool mIsClosed = false;
+ bool mIsFullscreen = false;
+
+ internal SwapChain mSwap;
+ internal Direct3D.Surface mBackBuffer;
+
+ int mChooseWidth;
+ int mChooseHeight;
+ int mChooseBitDepth = 32;
+ System.Drawing.Icon mIcon;
+ bool mChooseFullscreen = false;
+ bool mChooseResize = false;
+ WindowPosition mChoosePosition;
+ bool mHasFrame = true;
+ string mTitle = "";
+
+ SDX_Display mDisplay;
+
+ #region --- Creation / Destruction ---
+
+ public SDX_DisplayWindow(CreateWindowParams windowParams)
+ {
+ mChoosePosition = windowParams.WindowPosition;
+
+ if (windowParams.RenderToControl)
+ {
+ if (typeof(Control).IsAssignableFrom(windowParams.RenderTarget.GetType()) == false)
+ throw new ArgumentException("The specified render target does not derive from System.Windows.Forms.Control");
+
+ mRenderTarget = (Control)windowParams.RenderTarget;
+
+ mChooseFullscreen = false;
+ mChooseWidth = mRenderTarget.ClientSize.Width;
+ mChooseHeight = mRenderTarget.ClientSize.Height;
+
+ mDisplay = Display.Impl as SDX_Display;
+ mDisplay.Initialize(this);
+ mDisplay.VSyncChanged += new EventHandler(mDisplay_VSyncChanged);
+
+ AttachEvents();
+ CreateBackBuffer();
+ }
+ 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;
+
+ CreateWindow(mChooseFullscreen);
+
+ mDisplay = Display.Impl as SDX_Display;
+ mDisplay.Initialize(this);
+ mDisplay.VSyncChanged += new EventHandler(mDisplay_VSyncChanged);
+
+ AttachEvents();
+ CreateBackBuffer();
+ }
+ }
+
+ public SDX_DisplayWindow(System.Windows.Forms.Control renderTarget)
+ {
+
+ }
+
+ public override void Dispose()
+ {
+ if (frm != null && frm is frmFullScreen == false)
+ {
+ frm.Dispose();
+ }
+
+ frm = null;
+ mIsClosed = true;
+ }
+
+ #endregion
+
+ #region --- Event handlers ---
+
+ private void AttachEvents()
+ {
+ mRenderTarget.Resize += new EventHandler(frm_Resize);
+
+ mRenderTarget.MouseWheel += new MouseEventHandler(mRenderTarget_MouseWheel);
+ mRenderTarget.MouseMove += new System.Windows.Forms.MouseEventHandler(pct_MouseMove);
+ mRenderTarget.MouseDown += new System.Windows.Forms.MouseEventHandler(pct_MouseDown);
+ mRenderTarget.MouseUp += new System.Windows.Forms.MouseEventHandler(pct_MouseUp);
+ mRenderTarget.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(pct_MouseDoubleClick);
+
+ System.Windows.Forms.Form form;
+
+ if (mRenderTarget is System.Windows.Forms.Form)
+ form = mRenderTarget as System.Windo...
[truncated message content] |
|
From: <ka...@us...> - 2009-05-11 05:59:35
|
Revision: 971
http://agate.svn.sourceforge.net/agate/?rev=971&view=rev
Author: kanato
Date: 2009-05-11 05:59:26 +0000 (Mon, 11 May 2009)
Log Message:
-----------
Add DisplayTypeID.SlimDX
Modified Paths:
--------------
branches/agate3d-3.2/AgateLib/Drivers/TypeID.cs
Modified: branches/agate3d-3.2/AgateLib/Drivers/TypeID.cs
===================================================================
--- branches/agate3d-3.2/AgateLib/Drivers/TypeID.cs 2009-05-11 05:58:59 UTC (rev 970)
+++ branches/agate3d-3.2/AgateLib/Drivers/TypeID.cs 2009-05-11 05:59:26 UTC (rev 971)
@@ -50,6 +50,11 @@
Reference = 1,
/// <summary>
+ /// Driver Implementation using SlimDX.
+ /// </summary>
+ Direct3D9_SDX = 0x120,
+
+ /// <summary>
/// Driver Implementation using Managed DirectX 1.1.
/// </summary>
Direct3D_MDX_1_1 = 0x100,
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ka...@us...> - 2009-05-11 05:59:09
|
Revision: 970
http://agate.svn.sourceforge.net/agate/?rev=970&view=rev
Author: kanato
Date: 2009-05-11 05:58:59 +0000 (Mon, 11 May 2009)
Log Message:
-----------
Require that VertexBuffer.Write<T> be passed a struct.
Modified Paths:
--------------
branches/agate3d-3.2/AgateLib/DisplayLib/VertexBuffer.cs
branches/agate3d-3.2/AgateLib/ImplementationBase/VertexBufferImpl.cs
Modified: branches/agate3d-3.2/AgateLib/DisplayLib/VertexBuffer.cs
===================================================================
--- branches/agate3d-3.2/AgateLib/DisplayLib/VertexBuffer.cs 2009-05-11 05:58:24 UTC (rev 969)
+++ branches/agate3d-3.2/AgateLib/DisplayLib/VertexBuffer.cs 2009-05-11 05:58:59 UTC (rev 970)
@@ -26,7 +26,7 @@
impl = Display.Impl.CreateVertexBuffer(layout, vertexCount);
}
- public void WriteVertexData<T>(T[] data)
+ public void WriteVertexData<T>(T[] data) where T:struct
{
impl.Write(data);
}
Modified: branches/agate3d-3.2/AgateLib/ImplementationBase/VertexBufferImpl.cs
===================================================================
--- branches/agate3d-3.2/AgateLib/ImplementationBase/VertexBufferImpl.cs 2009-05-11 05:58:24 UTC (rev 969)
+++ branches/agate3d-3.2/AgateLib/ImplementationBase/VertexBufferImpl.cs 2009-05-11 05:58:59 UTC (rev 970)
@@ -14,7 +14,7 @@
Textures = new TextureList();
}
- public abstract void Write<T>(T[] vertices);
+ public abstract void Write<T>(T[] vertices) where T:struct;
public abstract int VertexCount { get; }
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ka...@us...> - 2009-05-11 05:58:34
|
Revision: 969
http://agate.svn.sourceforge.net/agate/?rev=969&view=rev
Author: kanato
Date: 2009-05-11 05:58:24 +0000 (Mon, 11 May 2009)
Log Message:
-----------
Remove unused TestPath function.
Modified Paths:
--------------
branches/agate3d-3.2/AgateLib/DisplayLib/Display.cs
Modified: branches/agate3d-3.2/AgateLib/DisplayLib/Display.cs
===================================================================
--- branches/agate3d-3.2/AgateLib/DisplayLib/Display.cs 2009-05-11 05:28:19 UTC (rev 968)
+++ branches/agate3d-3.2/AgateLib/DisplayLib/Display.cs 2009-05-11 05:58:24 UTC (rev 969)
@@ -152,20 +152,6 @@
DisposeDisplay();
}
- private static bool TestPath(string filename, out string fullPath)
- {
- if (File.Exists(filename))
- {
- fullPath = Path.GetFullPath(filename);
- return true;
- }
- else
- {
- fullPath = "";
- return false;
- }
- }
-
/// <summary>
/// Returns the PixelFormat of Surfaces which are created to be compatible
/// with the display mode. If you want to create a PixelBuffer which does
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ka...@us...> - 2009-05-11 05:28:34
|
Revision: 968
http://agate.svn.sourceforge.net/agate/?rev=968&view=rev
Author: kanato
Date: 2009-05-11 05:28:19 +0000 (Mon, 11 May 2009)
Log Message:
-----------
Change OTK priority.
Modified Paths:
--------------
branches/agate3d-3.2/Drivers/AgateOTK/Otk_Reporter.cs
Modified: branches/agate3d-3.2/Drivers/AgateOTK/Otk_Reporter.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateOTK/Otk_Reporter.cs 2009-05-10 05:23:37 UTC (rev 967)
+++ branches/agate3d-3.2/Drivers/AgateOTK/Otk_Reporter.cs 2009-05-11 05:28:19 UTC (rev 968)
@@ -32,7 +32,7 @@
opentk_version = GetOpenTKVersion(opentk_version);
yield return new AgateDriverInfo(
- DisplayTypeID.OpenGL, typeof(GL_Display), "OpenGL through OpenTK " + opentk_version, 1120);
+ DisplayTypeID.OpenGL, typeof(GL_Display), "OpenGL through OpenTK " + opentk_version, 200);
if (ReportOpenAL())
{
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ka...@us...> - 2009-05-10 05:23:38
|
Revision: 967
http://agate.svn.sourceforge.net/agate/?rev=967&view=rev
Author: kanato
Date: 2009-05-10 05:23:37 +0000 (Sun, 10 May 2009)
Log Message:
-----------
Update bumpmap shaders to GLSL version 1.30
Modified Paths:
--------------
branches/agate3d-3.2/Tests/Data/shaders/glsl/BumpMap_fragment.txt
branches/agate3d-3.2/Tests/Data/shaders/glsl/BumpMap_vertex.txt
Modified: branches/agate3d-3.2/Tests/Data/shaders/glsl/BumpMap_fragment.txt
===================================================================
--- branches/agate3d-3.2/Tests/Data/shaders/glsl/BumpMap_fragment.txt 2009-05-10 05:22:05 UTC (rev 966)
+++ branches/agate3d-3.2/Tests/Data/shaders/glsl/BumpMap_fragment.txt 2009-05-10 05:23:37 UTC (rev 967)
@@ -1,6 +1,10 @@
-varying vec4 diffuse,ambientGlobal, ambient;
-varying vec3 normal,lightDir,halfVector;
-varying float dist;
+#version 130
+
+precision highp float;
+
+in vec4 diffuse,ambientGlobal, ambient;
+in vec3 normal,lightDir,halfVector;
+in float dist;
uniform sampler2D texture0;
uniform sampler2D texture1;
@@ -35,6 +39,7 @@
NdotHV = max(dot(n,halfV),0.0);
color += att * gl_FrontMaterial.specular * gl_LightSource[0].specular *
pow(NdotHV,gl_FrontMaterial.shininess);
+
}
vec4 texcolor = texture2D(texture0,gl_TexCoord[0].st);
Modified: branches/agate3d-3.2/Tests/Data/shaders/glsl/BumpMap_vertex.txt
===================================================================
--- branches/agate3d-3.2/Tests/Data/shaders/glsl/BumpMap_vertex.txt 2009-05-10 05:22:05 UTC (rev 966)
+++ branches/agate3d-3.2/Tests/Data/shaders/glsl/BumpMap_vertex.txt 2009-05-10 05:23:37 UTC (rev 967)
@@ -1,11 +1,14 @@
+#version 130
-attribute vec3 tangent; //The inverse tangent to the geometry
-attribute vec3 bitangent; //The inverse binormal to the geometry
+precision highp float;
-varying vec4 diffuse,ambientGlobal,ambient;
-varying vec3 normal,lightDir,halfVector;
-varying float dist;
+in vec3 tangent; //The inverse tangent to the geometry
+in vec3 bitangent; //The inverse binormal to the geometry
+out vec4 diffuse,ambientGlobal,ambient;
+out vec3 normal,lightDir,halfVector;
+out float dist;
+
void main()
{
vec3 aux;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ka...@us...> - 2009-05-10 05:22:07
|
Revision: 966
http://agate.svn.sourceforge.net/agate/?rev=966&view=rev
Author: kanato
Date: 2009-05-10 05:22:05 +0000 (Sun, 10 May 2009)
Log Message:
-----------
Refactor GlslShaderCompiler removing ArbShaderCompiler to a separate class & file.
Fix code to initialize OpenGL 3.0 context instead of 2.1.
Modified Paths:
--------------
branches/agate3d-3.2/Drivers/AgateOTK/ArbShader.cs
branches/agate3d-3.2/Drivers/AgateOTK/GL_Display.cs
branches/agate3d-3.2/Drivers/AgateOTK/GL_DisplayControl.cs
branches/agate3d-3.2/Drivers/AgateOTK/GL_VertexBuffer.cs
branches/agate3d-3.2/Drivers/AgateOTK/GlslShader.cs
branches/agate3d-3.2/Drivers/AgateOTK/GlslShaderCompiler.cs
branches/agate3d-3.2/Drivers/AgateOTK/OpenTK.Utilities.dll
branches/agate3d-3.2/Drivers/AgateOTK/OpenTK.dll
Added Paths:
-----------
branches/agate3d-3.2/Drivers/AgateOTK/ArbShaderCompiler.cs
Modified: branches/agate3d-3.2/Drivers/AgateOTK/ArbShader.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateOTK/ArbShader.cs 2009-05-10 05:19:45 UTC (rev 965)
+++ branches/agate3d-3.2/Drivers/AgateOTK/ArbShader.cs 2009-05-10 05:22:05 UTC (rev 966)
@@ -56,5 +56,10 @@
public override void SetUniform(string name, AgateLib.Geometry.Matrix4 matrix)
{
}
+
+ public override void Render(RenderHandler handler, object obj)
+ {
+ throw new NotImplementedException();
+ }
}
}
Copied: branches/agate3d-3.2/Drivers/AgateOTK/ArbShaderCompiler.cs (from rev 923, branches/agate3d-3.2/Drivers/AgateOTK/GlslShaderCompiler.cs)
===================================================================
--- branches/agate3d-3.2/Drivers/AgateOTK/ArbShaderCompiler.cs (rev 0)
+++ branches/agate3d-3.2/Drivers/AgateOTK/ArbShaderCompiler.cs 2009-05-10 05:22:05 UTC (rev 966)
@@ -0,0 +1,75 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using AgateLib.DisplayLib.Shaders;
+using AgateLib.ImplementationBase;
+using OpenTK.Graphics;
+
+namespace AgateOTK
+{
+ class ArbShaderCompiler : ShaderCompilerImpl
+ {
+ public ArbShaderCompiler()
+ {
+ }
+
+ public override ShaderProgram 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 ShaderProgram 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 ShaderProgram CompileEffect(ShaderLanguage language, string effectSource)
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
Modified: branches/agate3d-3.2/Drivers/AgateOTK/GL_Display.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateOTK/GL_Display.cs 2009-05-10 05:19:45 UTC (rev 965)
+++ branches/agate3d-3.2/Drivers/AgateOTK/GL_Display.cs 2009-05-10 05:22:05 UTC (rev 966)
@@ -44,6 +44,7 @@
private bool mSupportsFramebuffer;
private bool mNonPowerOf2Textures;
private bool mSupportsShaders;
+ private decimal mGLVersion;
public bool NonPowerOf2Textures
{
@@ -399,20 +400,20 @@
GL.Hint(HintTarget.PerspectiveCorrectionHint, // Really Nice Perspective Calculations
HintMode.Nicest);
+ string vendor = GL.GetString(StringName.Vendor);
string versionString = GL.GetString(StringName.Version);
- double version = double.Parse(versionString.Substring(0, 3));
string ext = GL.GetString(StringName.Extensions);
+
+ mGLVersion = decimal.Parse(versionString.Substring(0, 3));
mSupportsShaders = false;
- // don't want stupid floating point comparision to improperly fail here.
- if (version >= 1.9999) // version 2
+ if (mGLVersion >= 2m)
{
mSupportsFramebuffer = true;
mNonPowerOf2Textures = true;
mSupportsShaders = true;
-
}
- else if (version >= 1.49999) // version 1.5
+ else if (mGLVersion >= 1.5m)
{
mSupportsFramebuffer = true;
mNonPowerOf2Textures = true;
@@ -483,7 +484,7 @@
GL.Enable(EnableCap.Lighting);
SetArray(array, lights.Ambient);
- GL.LightModelv(LightModelParameter.LightModelAmbient, array);
+ GL.LightModel(LightModelParameter.LightModelAmbient, array);
GL.Enable(EnableCap.ColorMaterial);
GL.ColorMaterial(MaterialFace.FrontAndBack,
@@ -509,13 +510,13 @@
GL.Enable(lightID);
SetArray(array, lights[i].Diffuse);
- GL.Lightv(lightName, LightParameter.Diffuse, array);
+ GL.Light(lightName, LightParameter.Diffuse, array);
SetArray(array, lights[i].Ambient);
- GL.Lightv(lightName, LightParameter.Ambient, array);
+ GL.Light(lightName, LightParameter.Ambient, array);
SetArray(array, lights[i].Position);
- GL.Lightv(lightName, LightParameter.Position, array);
+ GL.Light(lightName, LightParameter.Position, array);
GL.Light(lightName, LightParameter.ConstantAttenuation, lights[i].AttenuationConstant);
GL.Light(lightName, LightParameter.LinearAttenuation, lights[i].AttenuationLinear);
@@ -547,7 +548,10 @@
{
if (this.Caps.SupportsShaders)
{
- return new GlslShaderCompiler();
+ if (mGLVersion < 2.0m)
+ return new ArbShaderCompiler();
+ else
+ return new GlslShaderCompiler();
}
else
return base.CreateShaderCompiler();
Modified: branches/agate3d-3.2/Drivers/AgateOTK/GL_DisplayControl.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateOTK/GL_DisplayControl.cs 2009-05-10 05:19:45 UTC (rev 965)
+++ branches/agate3d-3.2/Drivers/AgateOTK/GL_DisplayControl.cs 2009-05-10 05:22:05 UTC (rev 966)
@@ -206,10 +206,10 @@
Debug.Print("AgateLib GraphicsMode: {0}", newMode);
- OpenTK.Platform.Utilities.CreateGraphicsContext(
- newMode,
- mRenderTarget,
- out mContext, out mWindowInfo);
+ mWindowInfo = OpenTK.Platform.Utilities.CreateWindowInfo(newMode, mRenderTarget);
+
+ mContext = OpenTK.Platform.Utilities.CreateGraphicsContext(
+ newMode, mWindowInfo, 3, 1, GraphicsContextFlags.Default);
}
Modified: branches/agate3d-3.2/Drivers/AgateOTK/GL_VertexBuffer.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateOTK/GL_VertexBuffer.cs 2009-05-10 05:19:45 UTC (rev 965)
+++ branches/agate3d-3.2/Drivers/AgateOTK/GL_VertexBuffer.cs 2009-05-10 05:22:05 UTC (rev 966)
@@ -247,5 +247,10 @@
return VertexLayout.SizeOf(d.DataType);
}
}
+
+ public override VertexLayout VertexLayout
+ {
+ get { return mLayout; }
+ }
}
}
Modified: branches/agate3d-3.2/Drivers/AgateOTK/GlslShader.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateOTK/GlslShader.cs 2009-05-10 05:19:45 UTC (rev 965)
+++ branches/agate3d-3.2/Drivers/AgateOTK/GlslShader.cs 2009-05-10 05:22:05 UTC (rev 966)
@@ -243,5 +243,10 @@
}
}
+
+ public override void Render(RenderHandler handler, object obj)
+ {
+ throw new NotImplementedException();
+ }
}
}
Modified: branches/agate3d-3.2/Drivers/AgateOTK/GlslShaderCompiler.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateOTK/GlslShaderCompiler.cs 2009-05-10 05:19:45 UTC (rev 965)
+++ branches/agate3d-3.2/Drivers/AgateOTK/GlslShaderCompiler.cs 2009-05-10 05:22:05 UTC (rev 966)
@@ -10,14 +10,8 @@
{
class GlslShaderCompiler : ShaderCompilerImpl
{
- bool arb = false;
-
public GlslShaderCompiler()
{
- double version = double.Parse(GL.GetString(StringName.Version).Substring(0, 3));
-
- if (version < 2.0)
- arb = true;
}
public override ShaderProgram CompileShader(ShaderLanguage language, string vertexShaderSource, string pixelShaderSource)
@@ -33,38 +27,27 @@
private ShaderProgram LinkPrograms(GlslVertexProgram vert, GlslFragmentProgram frag)
{
- if (arb)
- {
- int program = GL.Arb.CreateProgramObject();
+ int program = GL.CreateProgram();
- GL.Arb.AttachObject(program, vert.ShaderHandle);
- GL.Arb.AttachObject(program, frag.ShaderHandle);
+ GL.AttachShader(program, vert.ShaderHandle);
+ GL.AttachShader(program, frag.ShaderHandle);
- GL.Arb.LinkProgram(program);
+ GL.LinkProgram(program);
- return new ArbShader(program, vert, frag);
- }
- else
- {
- int program = GL.CreateProgram();
+ GL.ValidateProgram(program);
- GL.AttachShader(program, vert.ShaderHandle);
- GL.AttachShader(program, frag.ShaderHandle);
+ int status;
+ GL.GetProgram(program, ProgramParameter.ValidateStatus, out status);
- GL.LinkProgram(program);
+ if (status == 0)
+ {
+ string info;
+ GL.GetProgramInfoLog(program, out info);
- GL.ValidateProgram(program);
-
- //int status;
- //GL.GetProgram(program, ProgramParameter.ValidateStatus, out status);
-
- //if (status == 0)
- //{
- // throw new AgateLib.AgateException("Failed to validate GLSL shader program.");
- //}
-
- return new GlslShader(program, vert, frag);
+ throw new AgateLib.AgateException("Failed to validate GLSL shader program.\n{0}", info);
}
+
+ return new GlslShader(program, vert, frag);
}
private GlslVertexProgram CompileVertexProgram(string vertexShaderSource)
@@ -80,41 +63,30 @@
private int CompileShader(ShaderType type, string source)
{
int shaderHandle;
- if (arb)
- {
- if (type == ShaderType.VertexShader)
- shaderHandle = GL.Arb.CreateShaderObject((ArbShaderObjects)0x8B31);
- else
- shaderHandle = GL.Arb.CreateShaderObject((ArbShaderObjects)0x8B30);
- string[] src = new string[1] { source };
+ shaderHandle = GL.CreateShader(type);
- unsafe
- {
- GL.Arb.ShaderSource(shaderHandle, 1, src, (int*)IntPtr.Zero);
- }
- GL.Arb.CompileShader(shaderHandle);
- }
- else
- {
- shaderHandle = GL.CreateShader(type);
+ GL.ShaderSource(shaderHandle, source);
+ GL.CompileShader(shaderHandle);
- GL.ShaderSource(shaderHandle, source);
- GL.CompileShader(shaderHandle);
+ int status;
+ GL.GetShader(shaderHandle, ShaderParameter.CompileStatus, out status);
- int status;
- GL.GetShader(shaderHandle, ShaderParameter.CompileStatus, out status);
+ if (status == 0)
+ {
+ string info;
+ GL.GetShaderInfoLog(shaderHandle, out info);
- if (status == 0)
- {
- string info;
- GL.GetShaderInfoLog(shaderHandle, out info);
-
- throw new AgateLib.AgateException("Failed to compile {0} shader. {1}",
- type, info);
- }
+ throw new AgateLib.AgateException("Failed to compile {0} shader.\n{1}",
+ type, info);
}
+
return shaderHandle;
}
+
+ public override ShaderProgram CompileEffect(ShaderLanguage language, string effectSource)
+ {
+ throw new NotImplementedException();
+ }
}
}
Modified: branches/agate3d-3.2/Drivers/AgateOTK/OpenTK.Utilities.dll
===================================================================
(Binary files differ)
Modified: branches/agate3d-3.2/Drivers/AgateOTK/OpenTK.dll
===================================================================
(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-05-10 05:19:47
|
Revision: 965
http://agate.svn.sourceforge.net/agate/?rev=965&view=rev
Author: kanato
Date: 2009-05-10 05:19:45 +0000 (Sun, 10 May 2009)
Log Message:
-----------
Add stub for UniformState class.
Added Paths:
-----------
branches/agate3d-3.2/AgateLib/DisplayLib/Shaders/UniformState.cs
Added: branches/agate3d-3.2/AgateLib/DisplayLib/Shaders/UniformState.cs
===================================================================
--- branches/agate3d-3.2/AgateLib/DisplayLib/Shaders/UniformState.cs (rev 0)
+++ branches/agate3d-3.2/AgateLib/DisplayLib/Shaders/UniformState.cs 2009-05-10 05:19:45 UTC (rev 965)
@@ -0,0 +1,11 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace AgateLib.DisplayLib.Shaders
+{
+ public class UniformState
+ {
+ }
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ka...@us...> - 2009-05-10 05:00:14
|
Revision: 964
http://agate.svn.sourceforge.net/agate/?rev=964&view=rev
Author: kanato
Date: 2009-05-10 04:59:59 +0000 (Sun, 10 May 2009)
Log Message:
-----------
VertexBuffer: add method to retrieve VertexLayout.
Remove string-based attributes due to lack of support in Direct3D.
Modified Paths:
--------------
branches/agate3d-3.2/AgateLib/DisplayLib/VertexBuffer.cs
branches/agate3d-3.2/AgateLib/Geometry/VertexTypes/VertexLayout.cs
branches/agate3d-3.2/AgateLib/ImplementationBase/VertexBufferImpl.cs
Modified: branches/agate3d-3.2/AgateLib/DisplayLib/VertexBuffer.cs
===================================================================
--- branches/agate3d-3.2/AgateLib/DisplayLib/VertexBuffer.cs 2009-05-10 04:13:22 UTC (rev 963)
+++ branches/agate3d-3.2/AgateLib/DisplayLib/VertexBuffer.cs 2009-05-10 04:59:59 UTC (rev 964)
@@ -70,6 +70,11 @@
{
get { return impl.Textures; }
}
+
+ public VertexLayout VertexLayout
+ {
+ get { return impl.VertexLayout; }
+ }
}
public class TextureList
Modified: branches/agate3d-3.2/AgateLib/Geometry/VertexTypes/VertexLayout.cs
===================================================================
--- branches/agate3d-3.2/AgateLib/Geometry/VertexTypes/VertexLayout.cs 2009-05-10 04:13:22 UTC (rev 963)
+++ branches/agate3d-3.2/AgateLib/Geometry/VertexTypes/VertexLayout.cs 2009-05-10 04:59:59 UTC (rev 964)
@@ -32,10 +32,6 @@
{
return items.Any(x => x.ElementType == element);
}
- public bool ContainsElement(string attributeName)
- {
- return items.Any(x => x.ElementType == VertexElement.Attribute && x.AttributeString == attributeName);
- }
public int ElementByteIndex(VertexElement element)
{
int size = 0;
@@ -50,25 +46,7 @@
throw new AgateException("Could not find the element {0} in the vertex layout.", element);
}
- public int ElementByteIndex(string attributeName)
- {
- int size = 0;
-
- for (int i = 0; i < Count; i++)
- {
- if (this[i].ElementType == VertexElement.Attribute &&
- this[i].AttributeString == attributeName)
- {
- return size;
- }
-
- size += SizeOf(this[i].DataType);
- }
-
- throw new AgateException("Could not find the attribute {0} in the vertex layout.", attributeName);
- }
-
public static int SizeOf(VertexElementDataType vertexElementType)
{
switch (vertexElementType)
@@ -185,23 +163,17 @@
public class VertexElementDesc
{
VertexElement mDef;
- string mAttributeString;
public VertexElementDesc(VertexElementDataType type, VertexElement def)
{
- if (def == VertexElement.Attribute)
- throw new AgateException("Use the (VertexMemberType, string) overload instead.");
-
DataType = type;
ElementType = def;
}
- public VertexElementDesc(VertexElementDataType type, string attributeName)
+
+ public override string ToString()
{
- DataType = type;
- ElementType = VertexElement.Attribute;
- AttributeString = attributeName;
+ return ElementType.ToString();
}
-
public VertexElementDataType DataType { get; private set; }
public VertexElement ElementType
{
@@ -209,22 +181,9 @@
private set
{
mDef = value;
-
- if (mDef != VertexElement.Attribute)
- mAttributeString = null;
}
}
- public string AttributeString
- {
- get { return mAttributeString; }
- private set
- {
- mAttributeString = value;
- mDef = VertexElement.Attribute;
- }
- }
-
public int ItemSize
{
get { return VertexLayout.SizeOf(DataType); }
@@ -249,6 +208,5 @@
Texture1,
Texture2,
Texture3,
- Attribute,
}
}
Modified: branches/agate3d-3.2/AgateLib/ImplementationBase/VertexBufferImpl.cs
===================================================================
--- branches/agate3d-3.2/AgateLib/ImplementationBase/VertexBufferImpl.cs 2009-05-10 04:13:22 UTC (rev 963)
+++ branches/agate3d-3.2/AgateLib/ImplementationBase/VertexBufferImpl.cs 2009-05-10 04:59:59 UTC (rev 964)
@@ -3,6 +3,7 @@
using System.Text;
using AgateLib.DisplayLib;
using AgateLib.Geometry;
+using AgateLib.Geometry.VertexTypes;
namespace AgateLib.ImplementationBase
{
@@ -22,5 +23,7 @@
public abstract void Draw(int start, int count);
public abstract void DrawIndexed(IndexBuffer indexbuffer, int start, int count);
+
+ public abstract VertexLayout VertexLayout { get; }
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ka...@us...> - 2009-05-10 04:13:32
|
Revision: 963
http://agate.svn.sourceforge.net/agate/?rev=963&view=rev
Author: kanato
Date: 2009-05-10 04:13:22 +0000 (Sun, 10 May 2009)
Log Message:
-----------
HLSL compiler working now.
Modified Paths:
--------------
branches/agate3d-3.2/Drivers/AgateMDX/HlslCompiler.cs
branches/agate3d-3.2/Drivers/AgateMDX/HlslShaderProgram.cs
branches/agate3d-3.2/Drivers/AgateMDX/MDX1_Display.cs
branches/agate3d-3.2/Drivers/AgateMDX/MDX1_VertexBuffer.cs
branches/agate3d-3.2/Tests/Data/shaders/hlsl/PerPixelLighting_pixel.txt
branches/agate3d-3.2/Tests/Data/shaders/hlsl/PerPixelLighting_vertex.txt
Modified: branches/agate3d-3.2/Drivers/AgateMDX/HlslCompiler.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateMDX/HlslCompiler.cs 2009-05-09 22:06:59 UTC (rev 962)
+++ branches/agate3d-3.2/Drivers/AgateMDX/HlslCompiler.cs 2009-05-10 04:13:22 UTC (rev 963)
@@ -19,11 +19,15 @@
public override ShaderProgram CompileEffect(ShaderLanguage language, string effectSource)
{
- Direct3D.Effect effect = Direct3D.Effect.FromString(mDisplay.D3D_Device.Device,
- effectSource, null, null, Direct3D.ShaderFlags.None, null);
+ throw new NotImplementedException();
+ }
+ //public override ShaderProgram CompileEffect(ShaderLanguage language, string effectSource)
+ //{
+ // Direct3D.Effect effect = Direct3D.Effect.FromString(mDisplay.D3D_Device.Device,
+ // effectSource, null, null, Direct3D.ShaderFlags.None, null);
- return new HlslShaderProgram(effect);
- }
+ // return new HlslShaderProgram(effect);
+ //}
public override ShaderProgram CompileShader(ShaderLanguage language, string vertexShaderSource, string pixelShaderSource)
{
var vertexShaderStream = Direct3D.ShaderLoader.CompileShader(
@@ -38,9 +42,7 @@
var pixelShader = new Direct3D.PixelShader(mDisplay.D3D_Device.Device, pixelShaderStream);
- throw new NotImplementedException();
-
- //return new HlslShaderProgram();
+ return new HlslShaderProgram(vertexShader, pixelShader);
}
}
}
Modified: branches/agate3d-3.2/Drivers/AgateMDX/HlslShaderProgram.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateMDX/HlslShaderProgram.cs 2009-05-09 22:06:59 UTC (rev 962)
+++ branches/agate3d-3.2/Drivers/AgateMDX/HlslShaderProgram.cs 2009-05-10 04:13:22 UTC (rev 963)
@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
+using AgateLib.DisplayLib;
using AgateLib.DisplayLib.Shaders;
using Direct3D = Microsoft.DirectX.Direct3D;
@@ -9,11 +10,16 @@
{
class HlslShaderProgram : ShaderProgram
{
- Direct3D.Effect mEffect;
+ Direct3D.VertexShader mVertexShader;
+ Direct3D.PixelShader mPixelShader;
+ MDX1_Display mDisplay;
- public HlslShaderProgram(Direct3D.Effect effect)
+ public HlslShaderProgram(Direct3D.VertexShader vert, Direct3D.PixelShader pix)
{
- mEffect = effect;
+ mDisplay = (MDX1_Display)Display.Impl;
+
+ mVertexShader = vert;
+ mPixelShader = pix;
}
public override PixelShader PixelShader
{
@@ -22,17 +28,17 @@
public override void SetUniform(string name, AgateLib.Geometry.Matrix4 matrix)
{
- throw new NotImplementedException();
+
}
public override void SetUniform(string name, params int[] v)
{
- throw new NotImplementedException();
+
}
public override void SetUniform(string name, params float[] v)
{
- throw new NotImplementedException();
+
}
public override VertexShader VertexShader
@@ -40,18 +46,31 @@
get { throw new NotImplementedException(); }
}
+ public Direct3D.VertexShader HlslVertexShader
+ {
+ get { return mVertexShader; }
+ }
+ public Direct3D.PixelShader HlslPixelShader
+ {
+ get { return mPixelShader; }
+ }
+
public override void Render(RenderHandler handler, object obj)
{
- int passcount = mEffect.Begin(Microsoft.DirectX.Direct3D.FX.None);
+ mDisplay.D3D_Device.Device.VertexShader = mVertexShader;
+ mDisplay.D3D_Device.Device.PixelShader = mPixelShader;
- for (int i = 0; i < passcount; i++)
- {
- mEffect.BeginPass(i);
- handler(obj);
- mEffect.EndPass();
- }
+ handler(obj);
+ //int passcount = mEffect.Begin(Microsoft.DirectX.Direct3D.FX.None);
- mEffect.End();
+ //for (int i = 0; i < passcount; i++)
+ //{
+ // mEffect.BeginPass(i);
+ // handler(obj);
+ // mEffect.EndPass();
+ //}
+
+ //mEffect.End();
}
}
Modified: branches/agate3d-3.2/Drivers/AgateMDX/MDX1_Display.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateMDX/MDX1_Display.cs 2009-05-09 22:06:59 UTC (rev 962)
+++ branches/agate3d-3.2/Drivers/AgateMDX/MDX1_Display.cs 2009-05-10 04:13:22 UTC (rev 963)
@@ -792,12 +792,10 @@
{
mDevice.DrawBuffer.Flush();
}
-
public override void SetOrthoProjection(Rectangle region)
{
mDevice.SetOrthoProjection(region);
}
-
public override void DoLighting(LightManager lights)
{
FlushDrawBuffer();
@@ -996,6 +994,26 @@
return TransformAgateMatrix(MatrixProjection * MatrixView * MatrixWorld);
}
+ HlslShaderProgram mShader;
+
+ public override AgateLib.DisplayLib.Shaders.ShaderProgram Shader
+ {
+ get
+ {
+ return mShader;
+ }
+ set
+ {
+ if (mShader == value)
+ return;
+
+ mShader = (HlslShaderProgram) value;
+
+ mDevice.Device.VertexShader = mShader.HlslVertexShader;
+ mDevice.Device.PixelShader = mShader.HlslPixelShader;
+
+ }
+ }
#endregion
#region --- IPlatformServices Members ---
Modified: branches/agate3d-3.2/Drivers/AgateMDX/MDX1_VertexBuffer.cs
===================================================================
--- branches/agate3d-3.2/Drivers/AgateMDX/MDX1_VertexBuffer.cs 2009-05-09 22:06:59 UTC (rev 962)
+++ branches/agate3d-3.2/Drivers/AgateMDX/MDX1_VertexBuffer.cs 2009-05-10 04:13:22 UTC (rev 963)
@@ -44,6 +44,10 @@
Direct3D.Pool.Managed);
}
+ public override VertexLayout VertexLayout
+ {
+ get { return mLayout; }
+ }
private Direct3D.VertexFormats CreateVertexFormats(VertexLayout layout)
{
Direct3D.VertexFormats retval = Microsoft.DirectX.Direct3D.VertexFormats.None;
Modified: branches/agate3d-3.2/Tests/Data/shaders/hlsl/PerPixelLighting_pixel.txt
===================================================================
(Binary files differ)
Modified: branches/agate3d-3.2/Tests/Data/shaders/hlsl/PerPixelLighting_vertex.txt
===================================================================
--- branches/agate3d-3.2/Tests/Data/shaders/hlsl/PerPixelLighting_vertex.txt 2009-05-09 22:06:59 UTC (rev 962)
+++ branches/agate3d-3.2/Tests/Data/shaders/hlsl/PerPixelLighting_vertex.txt 2009-05-10 04:13:22 UTC (rev 963)
@@ -3,14 +3,15 @@
struct VS_INPUT
{
float3 position : POSITION;
- float4 color0 : COLOR0;
float2 texcoord0 : TEXCOORD0;
+ float3 normal : NORMAL;
+ float3 tangent : TANGENT;
+ float3 bitangent : BINORMAL;
};
-
+
struct VS_OUTPUT
{
float4 hposition : POSITION;
- float4 color0 : COLOR0;
float2 texcoord0 : TEXCOORD0;
};
@@ -24,7 +25,6 @@
1.0f );
OUT.hposition = mul( v, worldViewProj );
- OUT.color0 = IN.color0;
OUT.texcoord0 = IN.texcoord0;
return OUT;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|