Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions src/OpenGLES/EAGLContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ namespace XamCore.OpenGLES
{
public partial class EAGLContext
{
public enum PresentationMode {
AtTime = 0,
AfterMinimumDuration = 1,
}

[DllImport (Constants.OpenGLESLibrary)]
public extern static void EAGLGetVersion (out nuint major, out nuint minor);

Expand All @@ -15,6 +20,27 @@ public EAGLContext ()
{
}
#endif

[iOS (10,0)]
[TV (10,0)]
public virtual bool PresentRenderBuffer (nuint target, double presentationTime)
{
return _PresentRenderbufferAtTime (target, presentationTime);
}

[iOS (10,3)]
[TV (10,2)]
public virtual bool PresentRenderBuffer (nuint target, double presentationTime, PresentationMode mode)
{
switch (mode) {
case PresentationMode.AtTime:
return _PresentRenderbufferAtTime (target, presentationTime);
case PresentationMode.AfterMinimumDuration:
return _PresentRenderbufferAfterMinimumDuration (target, presentationTime);
default:
throw new ArgumentOutOfRangeException ($"Unknown presentation mode: {mode}", nameof (mode));
}
}
}
}

9 changes: 6 additions & 3 deletions src/opengles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,13 @@ interface EAGLContext {
[Export ("presentRenderbuffer:")]
bool PresentRenderBuffer (nuint target);

[iOS (10,0)]
[TV (10,0)]
[Internal]
[Export ("presentRenderbuffer:atTime:")]
bool PresentRenderBuffer (nuint target, double presentationTime);
bool _PresentRenderbufferAtTime (nuint target, double presentationTime);

[Internal]
[Export ("presentRenderbuffer:afterMinimumDuration:")]
bool _PresentRenderbufferAfterMinimumDuration (nuint target, double duration);

[Since (7,1)]
[Export ("multiThreaded")]
Expand Down
43 changes: 43 additions & 0 deletions tests/monotouch-test/OpenGLES/EAGLContext.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
//
// EAGLContext Unit Tests
//
// Authors:
// Vincent Dondain <vidondai@microsoft.com>
//
// Copyright 2017 Microsoft
//

#if !__WATCHOS__

using System;
#if XAMCORE_2_0
using Foundation;
using OpenGLES;
#else
using MonoTouch.Foundation;
using MonoTouch.OpenGLES;
#endif
using OpenTK.Graphics.ES20;
using NUnit.Framework;

namespace MonoTouchFixtures.OpenGLES
{

[TestFixture]
// we want the test to be available if we use the linker
[Preserve (AllMembers = true)]
public class EAGLContextTest
{
[Test]
public void PresentRenderBufferTest ()
{
var obj = new EAGLContext (EAGLRenderingAPI.OpenGLES2);

Asserts.AreEqual (true, obj.PresentRenderBuffer ((int)RenderbufferTarget.Renderbuffer, 0), "PresentRenderBuffer");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to add an overload that takes a RenderbufferTarget as the target instead of nuint (so that you don't have to cast)? Or are there many possible enums?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rolfbjarne I see that there are other enums being used:

OpenTK.Graphics.ES11.All.RenderbufferOes
OpenTK.Graphics.ES20.All.Renderbuffer
OpenTK.Graphics.ES20.RenderbufferTarget.Renderbuffer
OpenTK.Graphics.ES30.All.Renderbuffer
OpenTK.Graphics.ES30.RenderbufferTarget.Renderbuffer

All of the same value: 36161

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, that would become messy if we added overloads for every one of those, so I guess typing it as nuint is good enough.

Asserts.AreEqual (true, obj.PresentRenderBuffer ((int)RenderbufferTarget.Renderbuffer, 0, EAGLContext.PresentationMode.AtTime), "PresentRenderBufferAtTime");
Asserts.AreEqual (true, obj.PresentRenderBuffer ((int)RenderbufferTarget.Renderbuffer, 0, EAGLContext.PresentationMode.AfterMinimumDuration), "PresentRenderBufferAfterMinimumDuration");
}
}
}

#endif // !__WATCHOS__
3 changes: 3 additions & 0 deletions tests/monotouch-test/monotouch-test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@
<Reference Include="System.Core" />
<Reference Include="monotouch" />
<Reference Include="MonoTouch.NUnitLite" />
<Reference Include="OpenTK-1.0" />
</ItemGroup>
<ItemGroup>
<None Include="Info.plist" />
Expand Down Expand Up @@ -576,6 +577,7 @@
<Compile Include="Metal\HeapDescriptorTest.cs" />
<Compile Include="PassKit\LabeledValueTest.cs" />
<Compile Include="AVFoundation\PlayerItemVideoOutputTest.cs" />
<Compile Include="OpenGLES\EAGLContext.cs" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.MonoTouch.CSharp.targets" />
<ItemGroup>
Expand Down Expand Up @@ -639,6 +641,7 @@
<Folder Include="Messages\" />
<Folder Include="CloudKit\" />
<Folder Include="Intents\" />
<Folder Include="OpenGLES\" />
</ItemGroup>
<ItemGroup>
<Content Include="AudioToolbox\1.caf" />
Expand Down