Is there a way to force SCNView to render a new frame on demand if there is no animation inside the scene? If the scene is static SCNView renders exactly once and then only after something changes.
Usually this makes sense, but I am working together with the Vuforia augmented reality framework which requires me to render a new frame every time it processed a new video frame from the camera. I worked around this issue by creating my own UIView with a CAEAGLLayer which renders the SceneKit content using an SCNRenderer. This works great, but I am curious if there is a way to do this with SCNView so I can avoid directly touching OpenGL ES.
Update
As of iOS 11.0 and macOS 10.13 the rendersContinuously property on SCNView is the preferred way to force the view to continuously render frames.
Previous answer
you can set its playing property to YES
You can increment the sceneTime like so:
sceneView.sceneTime += 1
It will then render a single frame.
As a UIView, you can use the same mechanism to request an update as you would any other UIView: [_sceneView setNeedsDisplay]; However, as pointed out, this shouldn't be used as the primary way to drive updates as it would not be synced with the display.
Related
In my ARKit application ARSCNView is initialized and attached to ViewController internally based on storyboard file structure. So in function viewDidLoad I have already initialized view.
But the problem is it uses default rendering API metal. But I would like to change it to OpenGL ES2. In Apple documentation I read that preferredRenderingAPI can be somehow changed in IB inspector. But I don't understand how. There are no any examples of how to do this?
Or maybe I still change it from the code, even though the view is initialized from IB?
Just open your Main.storyboard (or whatever you have) in Xcode and navigate to the node Scene View of type SCNView in there. The Attributes inspector should allow you to change the renderer (Rendering API).
I've just tested it but it looked like my project didn't work the same as with metal.
I am generating my levels in SpriteKit via code (in Swift), and its not working out entirely how I'd like. Is there a way to inspect the scene of the simulator at run time. E.g. So I can view how things are being placed outside the visible screen.
Thanks!
Believe me, level editor via code rarely is a good idea. There are exceptions but if you need static levels then you should find another way to defined it.
How can you see your entire scene?
AFAIK you con't with Xcode 7, however you can change how the scene is resize in order to show the full scene inside the view. Depending by the size of your level you can judge whether this is solutions fits your case.
Just open GameViewController.swift and change this
scene.scaleMode = AspectFill
into this
scene.scaleMode = .AspectFit
Now your scene will be compressed to fit the size of the screen. Of course don't forget to restore the original value once you are done.
My iOS application stops rendering in case if the GLKView drawableMultisample is GLKViewDrawableMultisample4X. Everything works fine with the GLKViewDrawableMultisampleNone but if I set it to GLKViewDrawableMultisample4X, so I get only blank pink screen.
I've checked it on the iOS Simulator / iOS 7.0.3
Is anybody know how to resolve this issue ? Is it may be related to the iOS simulator and may work good on the real device?
I was having exactly this issue. It's not clear if the cause is the same but, in my case I was triggering my render from a displayLink trigger - without any regard for the semantics of setNeedsDisplay, or how GLKit sets up the render buffer around the execution of the drawInRect method.
I was of the mindset that since I was using displayLink, I could run all my rendering directly off of that trigger - and since it all worked before I tried to set up anti-aliasing, i figured it couldn't be far wrong!
The problem only manifested when I set GLKViewDrawableMultisample4X, much like the OP's problem.
The solution...
Ensure the view is created with enableSetNeedsDisplay = NO
Have displayLink trigger a function that contains nothing more than the following:
- (void)render:(CADisplayLink*)displayLink {
// This function should *not* perform any rendering
// We only want to inform GLKit that we're ready to render
GLKView * view = [self.window.subviews objectAtIndex:0];
// Tell GLKit that we're ready to draw
[view display];
// GLKit will ensure the buffers are setup before
// calling drawInRect
}
Move all rendering into drawInRect. GLKit will ensure the buffers are setup before drawInRect is called.
In iOS 7 it is quite easy to create a screen shot using the new snapshotViewAfterScreenUpdates UIView method.
I would like to create a screen recording using this (perhaps a different method is better). The finial outcome should be an an animated gif - or something that can be exported and viewed in a media player.
Any suggested method to do this?
I'm making a dictionary app, which allows user find a word definition by touch the word in screen, and there will be a magnifier on screen and follow user's finger. I have implement it by take a screenshot of view and assign the image to maginifer image view, which is a UIImageView, however, in order to take a screenshot, the method [self.layer renderInContext:c]; cost too much time, is there any other way to do it ?maybe openGL will help?
after profiling my app with instruments->core animation, it is only 9 fps showing magnifier, but it will 30 fps if showing the system default magnifier in a UITextView, I don't know why the system is so fast
You can use exact same view in magnifier view, and change position to visible words.
There are new methods in iOS 7 that are highly optimized :
– snapshotViewAfterScreenUpdates:
– resizableSnapshotViewFromRect:afterScreenUpdates:withCapInsets:
– drawViewHierarchyInRect:afterScreenUpdates:
However they are not available in previous versions.