зеркало из https://github.com/xamarin/ios-samples.git
GLCameraRipple sample ported to 64-bits
This commit is contained in:
Родитель
b360902052
Коммит
9ea5500175
|
@ -1,6 +1,6 @@
|
|||
using System;
|
||||
using MonoTouch.Foundation;
|
||||
using MonoTouch.UIKit;
|
||||
using Foundation;
|
||||
using UIKit;
|
||||
|
||||
namespace GLCameraRipple
|
||||
{
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
<MtouchI18n>
|
||||
</MtouchI18n>
|
||||
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
|
||||
<MtouchExtraArgs>--registrar:static --nofastsim --override-abi x86_64</MtouchExtraArgs>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhoneSimulator' ">
|
||||
<DebugType>none</DebugType>
|
||||
|
@ -65,8 +66,12 @@
|
|||
<Reference Include="System" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="OpenTK-1.0" />
|
||||
<Reference Include="monotouch" />
|
||||
<Reference Include="Xamarin.iOS">
|
||||
<HintPath>\Developer\MonoTouch\usr\lib\mono\Xamarin.iOS\Xamarin.iOS.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="OpenTK" >
|
||||
<HintPath>\Developer\MonoTouch\usr\lib\mono\Xamarin.iOS\OpenTK-1.0.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Info.plist" />
|
||||
|
@ -108,4 +113,4 @@
|
|||
<ITunesArtwork Include="Resources\iTunesArtwork.png" />
|
||||
<ITunesArtwork Include="Resources\iTunesArtwork%402x.png" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
</Project>
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
using System;
|
||||
using System.Drawing;
|
||||
using CoreGraphics;
|
||||
using System.Runtime.InteropServices;
|
||||
using MonoTouch.CoreFoundation;
|
||||
using CoreFoundation;
|
||||
|
||||
namespace GLCameraRipple
|
||||
{
|
||||
public class RippleModel
|
||||
{
|
||||
Size screenSize;
|
||||
CGSize screenSize;
|
||||
int poolHeight, poolWidth;
|
||||
int touchRadius, meshFactor;
|
||||
|
||||
|
@ -28,17 +28,17 @@ namespace GLCameraRipple
|
|||
unsafe float *rippleTexCoords;
|
||||
unsafe ushort *rippleIndicies;
|
||||
|
||||
public RippleModel (Size screenSize, int meshFactor, int touchRadius, Size textureSize)
|
||||
public RippleModel (CGSize screenSize, int meshFactor, int touchRadius, CGSize textureSize)
|
||||
{
|
||||
Console.WriteLine ("New RippleModel");
|
||||
this.screenSize = screenSize;
|
||||
this.meshFactor = meshFactor;
|
||||
this.touchRadius = touchRadius;
|
||||
poolWidth = screenSize.Width/meshFactor;
|
||||
poolHeight = screenSize.Height/meshFactor;
|
||||
poolWidth = (int)screenSize.Width/meshFactor;
|
||||
poolHeight = (int)screenSize.Height/meshFactor;
|
||||
|
||||
if ((float)screenSize.Height/screenSize.Width < (float)textureSize.Width/textureSize.Height){
|
||||
texCoordFactorS = (float)(textureSize.Height*screenSize.Height)/(screenSize.Width*textureSize.Width);
|
||||
texCoordFactorS = (float)((textureSize.Height*screenSize.Height)/(screenSize.Width*textureSize.Width));
|
||||
texCoordOffsetS = (1 - texCoordFactorS)/2f;
|
||||
|
||||
texCoordFactorT = 1;
|
||||
|
@ -47,7 +47,7 @@ namespace GLCameraRipple
|
|||
texCoordFactorS = 1;
|
||||
texCoordOffsetS = 0;
|
||||
|
||||
texCoordFactorT = (float)(screenSize.Width*textureSize.Width)/(textureSize.Height*screenSize.Height);
|
||||
texCoordFactorT = (float)((screenSize.Width*textureSize.Width)/(textureSize.Height*screenSize.Height));
|
||||
texCoordOffsetT = (1 - texCoordFactorT)/2f;
|
||||
}
|
||||
|
||||
|
@ -223,7 +223,7 @@ namespace GLCameraRipple
|
|||
rippleDest = tmp;
|
||||
}
|
||||
|
||||
public void InitiateRippleAtLocation (PointF location)
|
||||
public void InitiateRippleAtLocation (CGPoint location)
|
||||
{
|
||||
int xIndex = (int)((location.X / screenSize.Width) * poolWidth);
|
||||
int yIndex = (int) ((location.Y / screenSize.Height) * poolHeight);
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using CoreGraphics;
|
||||
using OpenTK.Graphics;
|
||||
using OpenTK.Graphics.ES20;
|
||||
using MonoTouch.GLKit;
|
||||
using MonoTouch.OpenGLES;
|
||||
using MonoTouch.Foundation;
|
||||
using MonoTouch.CoreFoundation;
|
||||
using MonoTouch.CoreMedia;
|
||||
using MonoTouch.UIKit;
|
||||
using MonoTouch.AVFoundation;
|
||||
using MonoTouch.CoreVideo;
|
||||
using GLKit;
|
||||
using OpenGLES;
|
||||
using Foundation;
|
||||
using CoreFoundation;
|
||||
using CoreMedia;
|
||||
using UIKit;
|
||||
using AVFoundation;
|
||||
using CoreVideo;
|
||||
|
||||
namespace GLCameraRipple
|
||||
{
|
||||
|
@ -22,7 +22,7 @@ namespace GLCameraRipple
|
|||
GLKView glkView;
|
||||
RippleModel ripple;
|
||||
int meshFactor;
|
||||
Size size;
|
||||
CGSize size;
|
||||
|
||||
//
|
||||
// OpenGL components
|
||||
|
@ -148,10 +148,11 @@ namespace GLCameraRipple
|
|||
// Create the output device
|
||||
var dataOutput = new AVCaptureVideoDataOutput () {
|
||||
AlwaysDiscardsLateVideoFrames = true,
|
||||
|
||||
|
||||
// YUV 420, use "BiPlanar" to split the Y and UV planes in two separate blocks of
|
||||
// memory, then we can index 0 to get the Y and 1 for the UV planes in the frame decoding
|
||||
VideoSettings = new AVVideoSettings (CVPixelFormatType.CV420YpCbCr8BiPlanarFullRange)
|
||||
//VideoSettings = new AVVideoSettings (CVPixelFormatType.CV420YpCbCr8BiPlanarFullRange)
|
||||
};
|
||||
|
||||
dataOutputDelegate = new DataOutputDelegate (this);
|
||||
|
@ -160,7 +161,7 @@ namespace GLCameraRipple
|
|||
// This dispatches the video frames into the main thread, because the OpenGL
|
||||
// code is accessing the data synchronously.
|
||||
//
|
||||
dataOutput.SetSampleBufferDelegateAndQueue (dataOutputDelegate, DispatchQueue.MainQueue);
|
||||
dataOutput.SetSampleBufferDelegateQueue (dataOutputDelegate, DispatchQueue.MainQueue);
|
||||
session.AddOutput (dataOutput);
|
||||
session.CommitConfiguration ();
|
||||
session.StartRunning ();
|
||||
|
@ -266,7 +267,7 @@ namespace GLCameraRipple
|
|||
|
||||
void SetupRipple (int width, int height)
|
||||
{
|
||||
ripple = new RippleModel (size, meshFactor, 5, new Size (width, height));
|
||||
ripple = new RippleModel (size, meshFactor, 5, new CGSize (width, height));
|
||||
SetupBuffers ();
|
||||
}
|
||||
|
||||
|
@ -289,12 +290,12 @@ namespace GLCameraRipple
|
|||
container.videoTextureCache.Flush (CVOptionFlags.None);
|
||||
}
|
||||
|
||||
public override void DidOutputSampleBuffer (AVCaptureOutput captureOutput, MonoTouch.CoreMedia.CMSampleBuffer sampleBuffer, AVCaptureConnection connection)
|
||||
public override void DidOutputSampleBuffer (AVCaptureOutput captureOutput, CoreMedia.CMSampleBuffer sampleBuffer, AVCaptureConnection connection)
|
||||
{
|
||||
try {
|
||||
using (var pixelBuffer = sampleBuffer.GetImageBuffer () as CVPixelBuffer){
|
||||
int width = pixelBuffer.Width;
|
||||
int height = pixelBuffer.Height;
|
||||
int width = (int)pixelBuffer.Width;
|
||||
int height = (int)pixelBuffer.Height;
|
||||
|
||||
if (container.ripple == null || width != textureWidth || height != textureHeight){
|
||||
textureWidth = width;
|
||||
|
|
Загрузка…
Ссылка в новой задаче