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

Commit b428d75

Browse files
committed
21
1 parent 7f8fb23 commit b428d75

File tree

8 files changed

+186
-86
lines changed

8 files changed

+186
-86
lines changed

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

Lines changed: 56 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -457,21 +457,55 @@ public static void DeleteTexture(int textureId)
457457
GL.DeleteTextures(1, arr);
458458
}
459459
}
460-
public static void VertexAttribPointer(int location, int size, VertexAttribPointerType type, bool normalize, int byteCount, float[] vertices)
460+
461+
//-------------
462+
public static void VertexAttribPointer(int location,
463+
int size, VertexAttribPointerType
464+
type, bool normalize,
465+
int byteCount, byte[] vertices)
461466
{
462467
unsafe
463468
{
464-
fixed (float* v_ptr = vertices)
469+
fixed (byte* v_ptr = vertices)
465470
{
466471
GL.VertexAttribPointer(location,
467-
size, //float2
472+
size,
468473
type,
469474
normalize,
470475
byteCount, //total size
471476
(IntPtr)v_ptr);
472477
}
473478
}
479+
}
474480

481+
public static void VertexAttribPointer(Int32 index, Int32 size,
482+
OpenTK.Graphics.ES20.VertexAttribPointerType type,
483+
bool normalized,
484+
Int32 stride,
485+
float[] arr)
486+
{
487+
unsafe
488+
{
489+
fixed (float* v_ptr = arr)
490+
{
491+
GL.VertexAttribPointer(index,
492+
size,
493+
type,
494+
normalized,
495+
stride, //total size
496+
(IntPtr)v_ptr);
497+
}
498+
}
499+
}
500+
public static void DrawElements(OpenTK.Graphics.ES20.PrimitiveType mode, Int32 count, OpenTK.Graphics.ES20.DrawElementsType type, byte[] indices)
501+
{
502+
unsafe
503+
{
504+
fixed (byte* v_ptr = indices)
505+
{
506+
GL.DrawElements(mode, count, type, (IntPtr)v_ptr);
507+
}
508+
}
475509
}
476510
public static void DrawElements(BeginMode mode, int size, DrawElementsType elemType, ushort[] indices)
477511
{
@@ -482,7 +516,25 @@ public static void DrawElements(BeginMode mode, int size, DrawElementsType elemT
482516
GL.DrawElements((PrimitiveType)mode, size, elemType, (IntPtr)v_ptr);
483517
}
484518
}
485-
}
519+
}
520+
public static void TexImage2D(TextureTarget textureTarget, int level, PixelInternalFormat format,
521+
int width, int height, int b, PixelFormat pixelFormat, PixelType pxtype, byte[] buffer)
522+
{
523+
unsafe
524+
{
525+
fixed (byte* buffer_ptr = buffer)
526+
{
527+
GL.TexImage2D(
528+
(TextureTarget2d)textureTarget,
529+
level,
530+
(TextureComponentCount)format,
531+
width, height, b, pixelFormat, pxtype,
532+
(System.IntPtr)buffer_ptr);
533+
}
534+
}
535+
536+
}
537+
486538
}
487539
}
488540

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
//autogen 2018-10-12 05:21:19Z
2+
23
namespace OpenTK.Graphics.ES30
34
{
45
using System;

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

Lines changed: 61 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -278,19 +278,19 @@ public static void GetProgramInfoLog(Int32 program, out string info)
278278
}
279279
}
280280

281-
[CLSCompliant(false)]
281+
282282
public static void VertexAttrib2(Int32 index, ref Vector2 v)
283283
{
284284
GL.VertexAttrib2(index, v.X, v.Y);
285285
}
286286

287-
[CLSCompliant(false)]
287+
288288
public static void VertexAttrib3(Int32 index, ref Vector3 v)
289289
{
290290
GL.VertexAttrib3(index, v.X, v.Y, v.Z);
291291
}
292292

293-
[CLSCompliant(false)]
293+
294294
public static void VertexAttrib4(Int32 index, ref Vector4 v)
295295
{
296296
GL.VertexAttrib4(index, v.X, v.Y, v.Z, v.W);
@@ -316,7 +316,7 @@ public static void VertexAttribPointer(int index, int size, VertexAttribPointerT
316316
VertexAttribPointer(index, size, type, normalized, stride, (IntPtr)offset);
317317
}
318318

319-
[CLSCompliant(false)]
319+
320320
public static void VertexAttribPointer(uint index, int size, VertexAttribPointerType type, bool normalized, int stride, int offset)
321321
{
322322
VertexAttribPointer(index, size, type, normalized, stride, (IntPtr)offset);
@@ -380,17 +380,17 @@ public static void GetFloat(GetPName pname, out Matrix4 matrix)
380380
//{
381381
// GL.Viewport(rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height);
382382
//}
383-
//#if MINIMAL
384-
// public static void Viewport(OpenTK.Point location, OpenTK.Size size)
385-
// {
386-
// GL.Viewport(location.X, location.Y, size.Width, size.Height);
387-
// }
388-
389-
// public static void Viewport(OpenTK.Rectangle rectangle)
390-
// {
391-
// GL.Viewport(rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height);
392-
// }
393-
//#endif
383+
//#if MINIMAL
384+
// public static void Viewport(OpenTK.Point location, OpenTK.Size size)
385+
// {
386+
// GL.Viewport(location.X, location.Y, size.Width, size.Height);
387+
// }
388+
389+
// public static void Viewport(OpenTK.Rectangle rectangle)
390+
// {
391+
// GL.Viewport(rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height);
392+
// }
393+
//#endif
394394

395395
#pragma warning restore 3019
396396
#pragma warning restore 1591
@@ -437,15 +437,16 @@ public delegate void DebugProcKhr(
437437
#pragma warning restore 1574 // XML comment cref attribute could not be resolved, compiler bug in Mono 3.4.0
438438

439439

440+
440441
partial class GL
441442
{
442443
public static void DrawArrays(BeginMode beginMode, int first, int count)
443444
{
444445
GL.DrawArrays((PrimitiveType)beginMode, first, count);
445446
}
446-
public static void DrawElements(BeginMode beginMode, int nelements, DrawElementsType type, IntPtr offset)
447+
public static void DrawElements(BeginMode beginMode, int nelements, DrawElementsType type, int offset)
447448
{
448-
GL.DrawElements((PrimitiveType)beginMode, nelements, type, offset);
449+
GL.DrawElements((PrimitiveType)beginMode, nelements, type, (IntPtr)offset);
449450
}
450451
public static int GenTexture()
451452
{
@@ -461,7 +462,49 @@ public static void DeleteTexture(int textureId)
461462
GL.DeleteTextures(1, arr);
462463
}
463464
}
464-
}
465+
public static void VertexAttribPointer(int location, int size, VertexAttribPointerType type, bool normalize, int byteCount, float[] vertices)
466+
{
467+
unsafe
468+
{
469+
fixed (float* v_ptr = vertices)
470+
{
471+
GL.VertexAttribPointer(location,
472+
size, //float2
473+
type,
474+
normalize,
475+
byteCount, //total size
476+
(IntPtr)v_ptr);
477+
}
478+
}
479+
480+
}
481+
public static void DrawElements(BeginMode mode, int size, DrawElementsType elemType, ushort[] indices)
482+
{
483+
unsafe
484+
{
485+
fixed (ushort* v_ptr = indices)
486+
{
487+
GL.DrawElements((PrimitiveType)mode, size, elemType, (IntPtr)v_ptr);
488+
}
489+
}
490+
}
491+
public static void TexImage2D(TextureTarget textureTarget, int level, PixelInternalFormat format,
492+
int width, int height, int border, PixelFormat pixelFormat, PixelType pxtype, byte[] buffer)
493+
{
494+
unsafe
495+
{
496+
fixed (byte* buffer_ptr = buffer)
497+
{
498+
GL.TexImage2D((TextureTarget2d)textureTarget,
499+
level, (TextureComponentCount)format,
500+
width, height,
501+
border, pixelFormat,
502+
pxtype, (System.IntPtr)buffer_ptr);
503+
}
504+
}
505+
506+
}
465507

508+
}
466509

467510
}

src/OpenTK/Math/Half.cs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
5757
using System;
5858
using System.IO;
5959
using System.Runtime.InteropServices;
60-
using System.Runtime.Serialization;
60+
6161

6262
namespace OpenTK
6363
{
@@ -384,21 +384,21 @@ public static implicit operator double(Half h)
384384
/// <summary>Smallest positive e for which half (1.0 + e) != half (1.0)</summary>
385385
public static readonly Single Epsilon = 0.00097656f;
386386

387-
/// <summary>Constructor used by ISerializable to deserialize the object.</summary>
388-
/// <param name="info"></param>
389-
/// <param name="context"></param>
390-
public Half(SerializationInfo info, StreamingContext context)
391-
{
392-
this.bits = (ushort)info.GetValue("bits", typeof(ushort));
393-
}
394-
395-
/// <summary>Used by ISerialize to serialize the object.</summary>
396-
/// <param name="info"></param>
397-
/// <param name="context"></param>
398-
public void GetObjectData(SerializationInfo info, StreamingContext context)
399-
{
400-
info.AddValue("bits", this.bits);
401-
}
387+
///// <summary>Constructor used by ISerializable to deserialize the object.</summary>
388+
///// <param name="info"></param>
389+
///// <param name="context"></param>
390+
//public Half(SerializationInfo info, StreamingContext context)
391+
//{
392+
// this.bits = (ushort)info.GetValue("bits", typeof(ushort));
393+
//}
394+
395+
///// <summary>Used by ISerialize to serialize the object.</summary>
396+
///// <param name="info"></param>
397+
///// <param name="context"></param>
398+
//public void GetObjectData(SerializationInfo info, StreamingContext context)
399+
//{
400+
// info.AddValue("bits", this.bits);
401+
//}
402402

403403
/// <summary>Updates the Half by reading from a Stream.</summary>
404404
/// <param name="bin">A BinaryReader instance associated with an open Stream.</param>

src/OpenTK/Math/Vector2h.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2323
using System;
2424
using System.IO;
2525
using System.Runtime.InteropServices;
26-
using System.Runtime.Serialization;
26+
2727

2828

2929
namespace OpenTK

src/OpenTK/Math/Vector3h.cs

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2323
using System;
2424
using System.IO;
2525
using System.Runtime.InteropServices;
26-
using System.Runtime.Serialization;
26+
2727

2828

2929
namespace OpenTK
@@ -330,25 +330,25 @@ public static explicit operator Vector3d(Vector3h h3)
330330
/// <summary>The size in bytes for an instance of the Half3 struct is 6.</summary>
331331
public static readonly int SizeInBytes = 6;
332332

333-
/// <summary>Constructor used by ISerializable to deserialize the object.</summary>
334-
/// <param name="info"></param>
335-
/// <param name="context"></param>
336-
public Vector3h(SerializationInfo info, StreamingContext context)
337-
{
338-
this.X = (Half)info.GetValue("X", typeof(Half));
339-
this.Y = (Half)info.GetValue("Y", typeof(Half));
340-
this.Z = (Half)info.GetValue("Z", typeof(Half));
341-
}
342-
343-
/// <summary>Used by ISerialize to serialize the object.</summary>
344-
/// <param name="info"></param>
345-
/// <param name="context"></param>
346-
public void GetObjectData(SerializationInfo info, StreamingContext context)
347-
{
348-
info.AddValue("X", this.X);
349-
info.AddValue("Y", this.Y);
350-
info.AddValue("Z", this.Z);
351-
}
333+
///// <summary>Constructor used by ISerializable to deserialize the object.</summary>
334+
///// <param name="info"></param>
335+
///// <param name="context"></param>
336+
//public Vector3h(SerializationInfo info, StreamingContext context)
337+
//{
338+
// this.X = (Half)info.GetValue("X", typeof(Half));
339+
// this.Y = (Half)info.GetValue("Y", typeof(Half));
340+
// this.Z = (Half)info.GetValue("Z", typeof(Half));
341+
//}
342+
343+
///// <summary>Used by ISerialize to serialize the object.</summary>
344+
///// <param name="info"></param>
345+
///// <param name="context"></param>
346+
//public void GetObjectData(SerializationInfo info, StreamingContext context)
347+
//{
348+
// info.AddValue("X", this.X);
349+
// info.AddValue("Y", this.Y);
350+
// info.AddValue("Z", this.Z);
351+
//}
352352

353353
/// <summary>Updates the X,Y and Z components of this instance by reading from a Stream.</summary>
354354
/// <param name="bin">A BinaryReader instance associated with an open Stream.</param>

src/OpenTK/Math/Vector4.cs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ namespace OpenTK
3030
/// <remarks>
3131
/// The Vector4 structure is suitable for interoperation with unmanaged code requiring four consecutive floats.
3232
/// </remarks>
33-
33+
3434
[StructLayout(LayoutKind.Sequential)]
3535
public struct Vector4 : IEquatable<Vector4>
3636
{
@@ -170,8 +170,10 @@ public Vector4(Vector4 v)
170170
/// <summary>
171171
/// Gets or sets the value at the index of the Vector.
172172
/// </summary>
173-
public float this[int index] {
174-
get{
173+
public float this[int index]
174+
{
175+
get
176+
{
175177
if (index == 0)
176178
{
177179
return X;
@@ -189,7 +191,9 @@ public float this[int index] {
189191
return W;
190192
}
191193
throw new IndexOutOfRangeException("You tried to access this vector at index: " + index);
192-
} set{
194+
}
195+
set
196+
{
193197
if (index == 0)
194198
{
195199
X = value;
@@ -1426,7 +1430,7 @@ public static void Transform(ref Matrix4 mat, ref Vector4 vec, out Vector4 resul
14261430
/// <param name="v">The instance.</param>
14271431
/// <returns>A pointer to the first element of v.</returns>
14281432
[CLSCompliant(false)]
1429-
unsafe public static explicit operator float*(Vector4 v)
1433+
unsafe public static explicit operator float* (Vector4 v)
14301434
{
14311435
return &v.X;
14321436
}

0 commit comments

Comments
 (0)