Skip to content
This repository was archived by the owner on Sep 17, 2023. It is now read-only.

Commit 7f8fb23

Browse files
committed
20: remove Serializable
1 parent 1bbd0c8 commit 7f8fb23

32 files changed

+218
-76
lines changed

src/Generator.Bind/Settings.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
namespace Bind
1212
{
13-
[Serializable]
13+
1414
internal class Settings
1515
{
1616
public Settings()

src/OpenTK/0_MyExtension/ES20mini/Helper.cs

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ public static void BufferData(BufferTarget target, int byteLen, float[] points,
9090
}
9191
}
9292
}
93-
//public static void BufferData(BufferTarget.ArrayBuffer, Points.Length* sizeof(float), Points, BufferUsageHint.StaticDraw);
9493

9594
//-----------------------------------------------------------------
9695
#pragma warning disable 3019
@@ -372,6 +371,10 @@ public static void Viewport(Rectangle rectangle)
372371
{
373372
GL.Viewport(rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height);
374373
}
374+
375+
376+
377+
375378
//#if MINIMAL
376379
// public static void Viewport(OpenTK.Point location, OpenTK.Size size)
377380
// {
@@ -427,4 +430,61 @@ public delegate void DebugProcKhr(
427430
IntPtr userParam);
428431

429432
#pragma warning restore 1574 // XML comment cref attribute could not be resolved, compiler bug in Mono 3.4.0
433+
434+
435+
436+
partial class GL
437+
{
438+
public static void DrawArrays(BeginMode beginMode, int first, int count)
439+
{
440+
GL.DrawArrays((PrimitiveType)beginMode, first, count);
441+
}
442+
public static void DrawElements(BeginMode beginMode, int nelements, DrawElementsType type, int offset)
443+
{
444+
GL.DrawElements((PrimitiveType)beginMode, nelements, type, (IntPtr)offset);
445+
}
446+
public static int GenTexture()
447+
{
448+
GL.GenTextures(1, out int textureId);
449+
return textureId;
450+
}
451+
public static void DeleteTexture(int textureId)
452+
{
453+
unsafe
454+
{
455+
int* arr = stackalloc int[1];
456+
arr[0] = textureId;
457+
GL.DeleteTextures(1, arr);
458+
}
459+
}
460+
public static void VertexAttribPointer(int location, int size, VertexAttribPointerType type, bool normalize, int byteCount, float[] vertices)
461+
{
462+
unsafe
463+
{
464+
fixed (float* v_ptr = vertices)
465+
{
466+
GL.VertexAttribPointer(location,
467+
size, //float2
468+
type,
469+
normalize,
470+
byteCount, //total size
471+
(IntPtr)v_ptr);
472+
}
473+
}
474+
475+
}
476+
public static void DrawElements(BeginMode mode, int size, DrawElementsType elemType, ushort[] indices)
477+
{
478+
unsafe
479+
{
480+
fixed (ushort* v_ptr = indices)
481+
{
482+
GL.DrawElements((PrimitiveType)mode, size, elemType, (IntPtr)v_ptr);
483+
}
484+
}
485+
}
486+
}
430487
}
488+
489+
490+

src/OpenTK/0_MyExtension/ES30mini/Helper.cs

Lines changed: 43 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -366,20 +366,20 @@ public static void GetFloat(GetPName pname, out Matrix4 matrix)
366366
}
367367
}
368368

369-
public static void Viewport(Size size)
370-
{
371-
GL.Viewport(0, 0, size.Width, size.Height);
372-
}
373-
374-
public static void Viewport(Point location, Size size)
375-
{
376-
GL.Viewport(location.X, location.Y, size.Width, size.Height);
377-
}
378-
379-
public static void Viewport(Rectangle rectangle)
380-
{
381-
GL.Viewport(rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height);
382-
}
369+
//public static void Viewport(Size size)
370+
//{
371+
// GL.Viewport(0, 0, size.Width, size.Height);
372+
//}
373+
374+
//public static void Viewport(Point location, Size size)
375+
//{
376+
// GL.Viewport(location.X, location.Y, size.Width, size.Height);
377+
//}
378+
379+
//public static void Viewport(Rectangle rectangle)
380+
//{
381+
// GL.Viewport(rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height);
382+
//}
383383
//#if MINIMAL
384384
// public static void Viewport(OpenTK.Point location, OpenTK.Size size)
385385
// {
@@ -435,4 +435,33 @@ public delegate void DebugProcKhr(
435435
IntPtr userParam);
436436

437437
#pragma warning restore 1574 // XML comment cref attribute could not be resolved, compiler bug in Mono 3.4.0
438+
439+
440+
partial class GL
441+
{
442+
public static void DrawArrays(BeginMode beginMode, int first, int count)
443+
{
444+
GL.DrawArrays((PrimitiveType)beginMode, first, count);
445+
}
446+
public static void DrawElements(BeginMode beginMode, int nelements, DrawElementsType type, IntPtr offset)
447+
{
448+
GL.DrawElements((PrimitiveType)beginMode, nelements, type, offset);
449+
}
450+
public static int GenTexture()
451+
{
452+
GL.GenTextures(1, out int textureId);
453+
return textureId;
454+
}
455+
public static void DeleteTexture(int textureId)
456+
{
457+
unsafe
458+
{
459+
int* arr = stackalloc int[1];
460+
arr[0] = textureId;
461+
GL.DeleteTextures(1, arr);
462+
}
463+
}
464+
}
465+
466+
438467
}

src/OpenTK/Graphics/Color4.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ namespace OpenTK.Graphics
3333
/// <summary>
3434
/// Represents a color with 4 floating-point components (R, G, B, A).
3535
/// </summary>
36-
[Serializable]
36+
3737
public struct Color4 : IEquatable<Color4>
3838
{
3939
/// <summary>

src/OpenTK/Graphics/GraphicsContext.cs

Lines changed: 63 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -146,14 +146,14 @@ public GraphicsContext(GraphicsMode mode, IWindowInfo window, IGraphicsContext s
146146
useAngle = true;
147147
}
148148

149-
Debug.Print("Creating GraphicsContext.");
149+
Debug.WriteLine("Creating GraphicsContext.");
150150
try
151151
{
152-
Debug.Indent();
153-
Debug.Print("GraphicsMode: {0}", mode);
154-
Debug.Print("IWindowInfo: {0}", window);
155-
Debug.Print("GraphicsContextFlags: {0}", flags);
156-
Debug.Print("Requested version: {0}.{1}", major, minor);
152+
Debug.WriteLine("");
153+
Debug.WriteLine($"GraphicsMode: {mode}");
154+
Debug.WriteLine($"IWindowInfo: {window}");
155+
Debug.WriteLine($"GraphicsContextFlags: {flags}");
156+
Debug.WriteLine($"Requested version: {major}.{minor}");
157157

158158
// Todo: Add a DummyFactory implementing IPlatformFactory.
159159
if (designMode)
@@ -193,7 +193,7 @@ public GraphicsContext(GraphicsMode mode, IWindowInfo window, IGraphicsContext s
193193
}
194194
finally
195195
{
196-
Debug.Unindent();
196+
197197
}
198198
}
199199
}
@@ -319,8 +319,8 @@ private static void AddContext(IGraphicsContextInternal context)
319319
}
320320
else
321321
{
322-
Debug.Print("A GraphicsContext with handle {0} already exists.", ctx);
323-
Debug.Print("Did you forget to call Dispose()?");
322+
Debug.WriteLine($"A GraphicsContext with handle {ctx} already exists.");
323+
Debug.WriteLine("Did you forget to call Dispose()?");
324324
available_contexts[ctx] = (IGraphicsContext)context;
325325
}
326326
}
@@ -334,7 +334,8 @@ private static void RemoveContext(IGraphicsContextInternal context)
334334
}
335335
else
336336
{
337-
Debug.Print("Tried to remove non-existent GraphicsContext handle {0}. Call Dispose() to avoid this error.", ctx);
337+
Debug.WriteLine("");
338+
Debug.WriteLine($"Tried to remove non-existent GraphicsContext handle {ctx}. Call Dispose() to avoid this error.");
338339
}
339340
}
340341

@@ -600,7 +601,7 @@ private void Dispose(bool manual)
600601
// This is also known to crash GLX implementations.
601602
if (manual)
602603
{
603-
Debug.Print("Disposing context {0}.", (this as IGraphicsContextInternal).Context.ToString());
604+
Debug.WriteLine($"Disposing context {(this as IGraphicsContextInternal).Context.ToString()}.");
604605
if (implementation != null)
605606
{
606607
implementation.Dispose();
@@ -623,5 +624,56 @@ private void Dispose(bool manual)
623624
{
624625
Dispose(false);
625626
}
627+
628+
629+
630+
//////////////////////////////////////////////////////////////////////////////////////////////////
631+
/// <summary>
632+
/// TODO: for used with glfw context
633+
/// </summary>
634+
/// <param name="handle"></param>
635+
/// <returns></returns>
636+
public static GraphicsContext CreateExternalContext(Platform.External.ExternalGraphicsContext externalGfxContext)
637+
{
638+
return new GraphicsContext(externalGfxContext);
639+
}
640+
readonly bool IsExternal;
641+
GraphicsContext(OpenTK.Platform.External.ExternalGraphicsContext externalGraphicsContext)
642+
{
643+
implementation = externalGraphicsContext;
644+
lock (SyncRoot)
645+
{
646+
IsExternal = true;
647+
//if (handle == ContextHandle.Zero)
648+
//{
649+
// implementation = new OpenTK.Platform.Dummy.DummyGLContext(handle);
650+
//}
651+
//else if (available_contexts.ContainsKey(handle))
652+
//{
653+
// throw new GraphicsContextException("Context already exists.");
654+
//}
655+
//else
656+
//{
657+
// switch ((flags & GraphicsContextFlags.Embedded) == GraphicsContextFlags.Embedded)
658+
// {
659+
// case false: implementation = Factory.Default.CreateGLContext(handle, window, shareContext, direct_rendering, major, minor, flags); break;
660+
// case true: implementation = Factory.Embedded.CreateGLContext(handle, window, shareContext, direct_rendering, major, minor, flags); break;
661+
// }
662+
//}
663+
664+
available_contexts.Add((implementation as IGraphicsContextInternal).Context, this);
665+
(this as IGraphicsContextInternal).LoadAll();
666+
667+
668+
GetCurrentContextDelegate temp = externalGraphicsContext.CreateCurrentContextDel();
669+
if (temp != null)
670+
{
671+
GetCurrentContext = temp;
672+
}
673+
674+
675+
}
676+
}
677+
///////////////////////////////////////////////////////////////////////////////////////////////////////////
626678
}
627679
}

src/OpenTK/Graphics/GraphicsContextBase.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,8 @@ public void Dispose()
101101
~GraphicsContextBase()
102102
{
103103
Dispose(false);
104-
Debug.Print("[Warning] {0}:{1} leaked. Did you forget to call Dispose()?",
105-
GetType().FullName, Handle);
104+
Debug.WriteLine($"[Warning] {GetType().FullName}:{ Handle} leaked. Did you forget to call Dispose()?");
105+
106106
}
107107
#endif
108108

src/OpenTK/Math/BezierCurve.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ namespace OpenTK
1414
/// <summary>
1515
/// Represents a bezier curve with as many points as you want.
1616
/// </summary>
17-
[Serializable]
17+
1818
public struct BezierCurve
1919
{
2020
private List<Vector2> points;

src/OpenTK/Math/BezierCurveCubic.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ namespace OpenTK
1313
/// <summary>
1414
/// Represents a cubic bezier curve with two anchor and two control points.
1515
/// </summary>
16-
[Serializable]
16+
1717
public struct BezierCurveCubic
1818
{
1919
/// <summary>

src/OpenTK/Math/BezierCurveQuadric.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ namespace OpenTK
1313
/// <summary>
1414
/// Represents a quadric bezier curve with two anchor and one control point.
1515
/// </summary>
16-
[Serializable]
16+
1717
public struct BezierCurveQuadric
1818
{
1919
/// <summary>

src/OpenTK/Math/Half.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ namespace OpenTK
7373
/// but must not lead to GL interruption or termination. Providing a denormalized number or negative zero to GL must yield
7474
/// predictable results.
7575
/// </remarks>
76-
[Serializable, StructLayout(LayoutKind.Sequential)]
77-
public struct Half : ISerializable, IComparable<Half>, IFormattable, IEquatable<Half>
76+
[StructLayout(LayoutKind.Sequential)]
77+
public struct Half : IComparable<Half>, IFormattable, IEquatable<Half>
7878
{
7979
private UInt16 bits;
8080

0 commit comments

Comments
 (0)