Added conditional compilation and the necessary classes to compile OpenTK without referencing System.Drawing.dll. To build without System.Drawing, add "MINIMAL" to the conditional compilation symbols. Note that this is an experimental feature that will result in a source- and binary-incompatible dll.

This commit is contained in:
the_fiddler 2011-12-08 00:03:14 +00:00
parent 02bfac7d59
commit 7bcbfc7072
22 changed files with 2194 additions and 37 deletions

View file

@ -28,7 +28,9 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
#if !MINIMAL
using System.Drawing; using System.Drawing;
#endif
namespace OpenTK namespace OpenTK
{ {

View file

@ -10,7 +10,9 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
using System.Diagnostics; using System.Diagnostics;
#if !MINIMAL
using System.Drawing; using System.Drawing;
#endif
namespace OpenTK namespace OpenTK
{ {

View file

@ -29,7 +29,9 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.Diagnostics; using System.Diagnostics;
#if !MINIMAL
using System.Drawing; using System.Drawing;
#endif
using System.Threading; using System.Threading;
using OpenTK.Graphics; using OpenTK.Graphics;
using OpenTK.Input; using OpenTK.Input;

View file

@ -27,6 +27,9 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
#if !MINIMAL
using System.Drawing;
#endif
using System.Text; using System.Text;
using System.Xml.Serialization; using System.Xml.Serialization;
@ -99,7 +102,7 @@ namespace OpenTK.Graphics
/// </summary> /// </summary>
/// <param name="color">The System.Drawing.Color containing the component values.</param> /// <param name="color">The System.Drawing.Color containing the component values.</param>
[Obsolete("Use new Color4(r, g, b, a) instead.")] [Obsolete("Use new Color4(r, g, b, a) instead.")]
public Color4(System.Drawing.Color color) public Color4(Color color)
: this(color.R, color.G, color.B, color.A) : this(color.R, color.G, color.B, color.A)
{ } { }
@ -150,7 +153,7 @@ namespace OpenTK.Graphics
/// </summary> /// </summary>
/// <param name="color">The System.Drawing.Color to convert.</param> /// <param name="color">The System.Drawing.Color to convert.</param>
/// <returns>A new Color4 structure containing the converted components.</returns> /// <returns>A new Color4 structure containing the converted components.</returns>
public static implicit operator Color4(System.Drawing.Color color) public static implicit operator Color4(Color color)
{ {
return new Color4(color.R, color.G, color.B, color.A); return new Color4(color.R, color.G, color.B, color.A);
} }
@ -160,9 +163,9 @@ namespace OpenTK.Graphics
/// </summary> /// </summary>
/// <param name="color">The Color4 to convert.</param> /// <param name="color">The Color4 to convert.</param>
/// <returns>A new System.Drawing.Color structure containing the converted components.</returns> /// <returns>A new System.Drawing.Color structure containing the converted components.</returns>
public static explicit operator System.Drawing.Color(Color4 color) public static explicit operator Color(Color4 color)
{ {
return System.Drawing.Color.FromArgb( return Color.FromArgb(
(int)(color.A * Byte.MaxValue), (int)(color.A * Byte.MaxValue),
(int)(color.R * Byte.MaxValue), (int)(color.R * Byte.MaxValue),
(int)(color.G * Byte.MaxValue), (int)(color.G * Byte.MaxValue),

View file

@ -27,6 +27,9 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
#if !MINIMAL
using System.Drawing;
#endif
using System.Text; using System.Text;
namespace OpenTK.Graphics.ES20 namespace OpenTK.Graphics.ES20
@ -63,7 +66,7 @@ namespace OpenTK.Graphics.ES20
#region public static void ClearColor() overloads #region public static void ClearColor() overloads
public static void ClearColor(System.Drawing.Color color) public static void ClearColor(Color color)
{ {
GL.ClearColor(color.R / 255.0f, color.G / 255.0f, color.B / 255.0f, color.A / 255.0f); GL.ClearColor(color.R / 255.0f, color.G / 255.0f, color.B / 255.0f, color.A / 255.0f);
} }
@ -77,7 +80,7 @@ namespace OpenTK.Graphics.ES20
#region public static void BlendColor() overloads #region public static void BlendColor() overloads
public static void BlendColor(System.Drawing.Color color) public static void BlendColor(Color color)
{ {
GL.BlendColor(color.R / 255.0f, color.G / 255.0f, color.B / 255.0f, color.A / 255.0f); GL.BlendColor(color.R / 255.0f, color.G / 255.0f, color.B / 255.0f, color.A / 255.0f);
} }
@ -399,17 +402,17 @@ namespace OpenTK.Graphics.ES20
#region Viewport #region Viewport
public static void Viewport(System.Drawing.Size size) public static void Viewport(Size size)
{ {
GL.Viewport(0, 0, size.Width, size.Height); GL.Viewport(0, 0, size.Width, size.Height);
} }
public static void Viewport(System.Drawing.Point location, System.Drawing.Size size) public static void Viewport(Point location, Size size)
{ {
GL.Viewport(location.X, location.Y, size.Width, size.Height); GL.Viewport(location.X, location.Y, size.Width, size.Height);
} }
public static void Viewport(System.Drawing.Rectangle rectangle) public static void Viewport(Rectangle rectangle)
{ {
GL.Viewport(rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height); GL.Viewport(rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height);
} }

View file

@ -10,6 +10,9 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
#if !MINIMAL
using System.Drawing;
#endif
using System.Text; using System.Text;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Reflection; using System.Reflection;
@ -103,12 +106,12 @@ namespace OpenTK.Graphics.OpenGL
#region public static void Color[34]() overloads #region public static void Color[34]() overloads
public static void Color3(System.Drawing.Color color) public static void Color3(Color color)
{ {
GL.Color3(color.R, color.G, color.B); GL.Color3(color.R, color.G, color.B);
} }
public static void Color4(System.Drawing.Color color) public static void Color4(Color color)
{ {
GL.Color4(color.R, color.G, color.B, color.A); GL.Color4(color.R, color.G, color.B, color.A);
} }
@ -132,7 +135,7 @@ namespace OpenTK.Graphics.OpenGL
#region public static void ClearColor() overloads #region public static void ClearColor() overloads
public static void ClearColor(System.Drawing.Color color) public static void ClearColor(Color color)
{ {
GL.ClearColor(color.R / 255.0f, color.G / 255.0f, color.B / 255.0f, color.A / 255.0f); GL.ClearColor(color.R / 255.0f, color.G / 255.0f, color.B / 255.0f, color.A / 255.0f);
} }
@ -146,7 +149,7 @@ namespace OpenTK.Graphics.OpenGL
#region public static void BlendColor() overloads #region public static void BlendColor() overloads
public static void BlendColor(System.Drawing.Color color) public static void BlendColor(Color color)
{ {
GL.BlendColor(color.R / 255.0f, color.G / 255.0f, color.B / 255.0f, color.A / 255.0f); GL.BlendColor(color.R / 255.0f, color.G / 255.0f, color.B / 255.0f, color.A / 255.0f);
} }
@ -720,24 +723,24 @@ namespace OpenTK.Graphics.OpenGL
#region Rect #region Rect
public static void Rect(System.Drawing.RectangleF rect) public static void Rect(RectangleF rect)
{ {
GL.Rect(rect.Left, rect.Top, rect.Right, rect.Bottom); GL.Rect(rect.Left, rect.Top, rect.Right, rect.Bottom);
} }
public static void Rect(System.Drawing.Rectangle rect) public static void Rect(Rectangle rect)
{ {
GL.Rect(rect.Left, rect.Top, rect.Right, rect.Bottom); GL.Rect(rect.Left, rect.Top, rect.Right, rect.Bottom);
} }
[CLSCompliant(false)] [CLSCompliant(false)]
public static void Rect(ref System.Drawing.RectangleF rect) public static void Rect(ref RectangleF rect)
{ {
GL.Rect(rect.Left, rect.Top, rect.Right, rect.Bottom); GL.Rect(rect.Left, rect.Top, rect.Right, rect.Bottom);
} }
[CLSCompliant(false)] [CLSCompliant(false)]
public static void Rect(ref System.Drawing.Rectangle rect) public static void Rect(ref Rectangle rect)
{ {
GL.Rect(rect.Left, rect.Top, rect.Right, rect.Bottom); GL.Rect(rect.Left, rect.Top, rect.Right, rect.Bottom);
} }
@ -901,17 +904,17 @@ namespace OpenTK.Graphics.OpenGL
#region Viewport #region Viewport
public static void Viewport(System.Drawing.Size size) public static void Viewport(Size size)
{ {
GL.Viewport(0, 0, size.Width, size.Height); GL.Viewport(0, 0, size.Width, size.Height);
} }
public static void Viewport(System.Drawing.Point location, System.Drawing.Size size) public static void Viewport(Point location, Size size)
{ {
GL.Viewport(location.X, location.Y, size.Width, size.Height); GL.Viewport(location.X, location.Y, size.Width, size.Height);
} }
public static void Viewport(System.Drawing.Rectangle rectangle) public static void Viewport(Rectangle rectangle)
{ {
GL.Viewport(rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height); GL.Viewport(rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height);
} }
@ -930,7 +933,7 @@ namespace OpenTK.Graphics.OpenGL
#region TexEnv #region TexEnv
public static void TexEnv(TextureEnvTarget target, TextureEnvParameter pname, System.Drawing.Color color) public static void TexEnv(TextureEnvTarget target, TextureEnvParameter pname, Color color)
{ {
Color4 c = new Color4(color.R, color.G, color.B, color.A); Color4 c = new Color4(color.R, color.G, color.B, color.A);
unsafe unsafe

View file

@ -27,10 +27,12 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text;
using System.Drawing;
using OpenTK.Platform;
using System.ComponentModel; using System.ComponentModel;
#if !MINIMAL
using System.Drawing;
#endif
using System.Text;
using OpenTK.Platform;
namespace OpenTK namespace OpenTK
{ {

View file

@ -29,9 +29,12 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.ComponentModel; using System.ComponentModel;
#if !MINIMAL
using System.Drawing;
#endif
using System.Text;
namespace OpenTK.Input namespace OpenTK.Input
{ {

File diff suppressed because it is too large Load diff

View file

@ -27,7 +27,9 @@
using System; using System;
using System.ComponentModel; using System.ComponentModel;
#if !MINIMAL
using System.Drawing; using System.Drawing;
#endif
using OpenTK.Graphics; using OpenTK.Graphics;
using OpenTK.Input; using OpenTK.Input;
using OpenTK.Platform; using OpenTK.Platform;

View file

@ -8,11 +8,13 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
#if !MINIMAL
using System.Drawing;
#endif
using System.Text; using System.Text;
using OpenTK.Input; using OpenTK.Input;
using OpenTK.Graphics; using OpenTK.Graphics;
using System.Drawing;
namespace OpenTK.Platform namespace OpenTK.Platform
{ {

View file

@ -31,7 +31,10 @@
using System; using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Diagnostics; using System.Diagnostics;
#if !MINIMAL
using System.Drawing; using System.Drawing;
#endif
using EventTime = System.Double; using EventTime = System.Double;

View file

@ -31,7 +31,9 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.Diagnostics; using System.Diagnostics;
#if !MINIMAL
using System.Drawing; using System.Drawing;
#endif
using System.Text; using System.Text;
namespace OpenTK.Platform.MacOS namespace OpenTK.Platform.MacOS
@ -752,7 +754,11 @@ namespace OpenTK.Platform.MacOS
int index; int index;
bitmap = new Bitmap(128, 128); bitmap = new Bitmap(128, 128);
#if MINIMAL
using (global::Graphics g = global::Graphics.FromImage(bitmap))
#else
using (System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(bitmap)) using (System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(bitmap))
#endif
{ {
g.DrawImage(icon.ToBitmap(), 0, 0, 128, 128); g.DrawImage(icon.ToBitmap(), 0, 0, 128, 128);
} }

View file

@ -28,7 +28,9 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
#if !MINIMAL
using System.Drawing; using System.Drawing;
#endif
using OpenTK.Platform.MacOS.Carbon; using OpenTK.Platform.MacOS.Carbon;
namespace OpenTK.Platform.MacOS namespace OpenTK.Platform.MacOS

View file

@ -8,7 +8,9 @@
#region --- Using Directives --- #region --- Using Directives ---
using System; using System;
#if !MINIMAL
using System.Drawing; using System.Drawing;
#endif
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Text; using System.Text;
using System.Security; using System.Security;

View file

@ -28,7 +28,9 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
#if !MINIMAL
using System.Drawing; using System.Drawing;
#endif
using System.Threading; using System.Threading;
using System.Text; using System.Text;

View file

@ -33,7 +33,9 @@ using OpenTK.Graphics;
using OpenTK.Input; using OpenTK.Input;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
#if !MINIMAL
using System.Drawing; using System.Drawing;
#endif
namespace OpenTK.Platform.Windows namespace OpenTK.Platform.Windows
{ {

View file

@ -8,6 +8,10 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
#if !MINIMAL
using System.Drawing;
using System.Drawing.Imaging;
#endif
using System.Text; using System.Text;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
@ -594,15 +598,15 @@ namespace OpenTK.Platform.X11
(byte)(argb & 0xFF)); (byte)(argb & 0xFF));
} }
} }
public static IntPtr CreatePixmapFromImage(Display display, System.Drawing.Bitmap image) public static IntPtr CreatePixmapFromImage(Display display, Bitmap image)
{ {
int width = image.Width; int width = image.Width;
int height = image.Height; int height = image.Height;
int size = width * height; int size = width * height;
System.Drawing.Imaging.BitmapData data = image.LockBits(new System.Drawing.Rectangle(0, 0, width, height), BitmapData data = image.LockBits(new Rectangle(0, 0, width, height),
System.Drawing.Imaging.ImageLockMode.ReadOnly, ImageLockMode.ReadOnly,
System.Drawing.Imaging.PixelFormat.Format32bppArgb); PixelFormat.Format32bppArgb);
IntPtr ximage = XCreateImage(display, CopyFromParent, 24, ImageFormat.ZPixmap, IntPtr ximage = XCreateImage(display, CopyFromParent, 24, ImageFormat.ZPixmap,
0, data.Scan0, (uint)width, (uint)height, 32, 0); 0, data.Scan0, (uint)width, (uint)height, 32, 0);
@ -618,7 +622,7 @@ namespace OpenTK.Platform.X11
return pixmap; return pixmap;
} }
public static IntPtr CreateMaskFromImage(Display display, System.Drawing.Bitmap image) public static IntPtr CreateMaskFromImage(Display display, Bitmap image)
{ {
int width = image.Width; int width = image.Width;
int height = image.Height; int height = image.Height;

View file

@ -29,7 +29,9 @@
using System; using System;
using System.ComponentModel; using System.ComponentModel;
using System.Collections; using System.Collections;
#if !MINIMAL
using System.Drawing; using System.Drawing;
#endif
using System.Diagnostics; using System.Diagnostics;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;

View file

@ -28,7 +28,9 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
#if !MINIMAL
using System.Drawing; using System.Drawing;
#endif
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
namespace OpenTK.Platform.X11 namespace OpenTK.Platform.X11

View file

@ -29,12 +29,14 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.Diagnostics; using System.Diagnostics;
#if !MINIMAL
using System.Drawing;
#endif
using System.Reflection; using System.Reflection;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Text; using System.Text;
using OpenTK.Graphics; using OpenTK.Graphics;
using OpenTK.Input; using OpenTK.Input;
using System.Drawing;
namespace OpenTK.Platform.X11 namespace OpenTK.Platform.X11
{ {
@ -1083,7 +1085,7 @@ namespace OpenTK.Platform.X11
else else
{ {
// Set _NET_WM_ICON // Set _NET_WM_ICON
System.Drawing.Bitmap bitmap = value.ToBitmap(); Bitmap bitmap = value.ToBitmap();
int size = bitmap.Width * bitmap.Height + 2; int size = bitmap.Width * bitmap.Height + 2;
IntPtr[] data = new IntPtr[size]; IntPtr[] data = new IntPtr[size];
int index = 0; int index = 0;

View file

@ -6,12 +6,14 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
#if !MINIMAL
using System.Drawing;
#endif
using System.Text; using System.Text;
using System.Diagnostics; using System.Diagnostics;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using OpenTK.Input; using OpenTK.Input;
using System.Drawing;
namespace OpenTK.Platform.X11 namespace OpenTK.Platform.X11
{ {