glkit

How do I convert this OpenGL pointer math to Swift?

这一生的挚爱 提交于 2019-12-03 16:08:50
I’m following this tutorial about OpenGL / GLKit for iOS but trying to implement it in Swift. It’s going fine until I get to this part: - (void)render { // 1 self.effect.texture2d0.name = self.textureInfo.name; self.effect.texture2d0.enabled = YES; // 2 [self.effect prepareToDraw]; // 3 glEnableVertexAttribArray(GLKVertexAttribPosition); glEnableVertexAttribArray(GLKVertexAttribTexCoord0); //---------------- This is where things break down... long offset = (long)&_quad; glVertexAttribPointer(GLKVertexAttribPosition, 2, GL_FLOAT, GL_FALSE, sizeof(TexturedVertex), (void *) (offset + offsetof

GLKView set drawable properties

人盡茶涼 提交于 2019-12-03 09:25:50
I'm trying to port Apples GLPaint example to use GLKit. Using a UIView, its possible to return the CAEAGLLayer of the view and set the drawableProperties to include kEAGLDrawablePropertyRetainedBacking. This has the effect of retaining the drawable contents after presenting the render buffer, as expected. Removing this property results in flickering after the draw call with part of the drawable content seemingly being drawn to different buffers. The problem is this is exactly the issue I am now having in my GLKView, but there doesn't seem to be a way to set the drawable properties. Returning a

Nesting GLKView into UIViewController

老子叫甜甜 提交于 2019-12-03 08:11:09
I'm trying to use GLKView in UIViewController, my code looks like this CustomViewController.h #import <UIKit/UIKit.h> #import <GLKit/GLKit.h> @interface CustomViewController : UIViewController { NSString * name; } @property NSString * name; CustomViewController.m #import "CustomViewController.h" @interface CustomViewController () @end @implementation CustomViewController @synthesize name; - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; if (self) { // Custom initialization } return self; } -

Arcball Rotation with Quaternions (using iOS GLKit)

纵饮孤独 提交于 2019-12-02 21:23:15
I'm looking for a simple implementation for arcball rotation on 3D models with quaternions, specifically using GLKit on iOS . So far, I have examined the following sources: Arcball rotation with GLKit How to rotate a 3D object with touches using OpenGL I've also been trying to understand source code and maths from here and here . I can rotate my object but it keeps jumping around at certain angles, so I fear gimbal lock is at play. I'm using gesture recognizers to control the rotations (pan gestures affect roll and yaw, rotate gestures affect pitch). I'm attaching my code for the quaternion

Unmodified iOS7 Apple GLPaint example blending issue

你离开我真会死。 提交于 2019-12-01 12:31:31
In Apple's GLPaint example, the user can draw with semi-transparent brush over a surface and change colours. However, as of iOS7, for some odd reason it is not possible to draw something that completely goes over its background: In the first image, we see "Shake me" written with green and a red blob that was drawn multiple times over it. Yet, the writing bellow is still barely visible. The second image was desaturated to make the defect more obvious. The OpenGL blending function Apple is using is: glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); What I expect it to do is to blend the newer semi

Replace particular color of image in iOS

随声附和 提交于 2019-12-01 04:48:21
I want to replace the particular color of an image with other user selected color. While replacing color of image, I want to maintain the gradient effect of that original color. for example see the attached images. I have tried to do so with CoreGraphics & I got success to replace color. But the replacing color do not maintain the gradient effect of the original color in the image. Can someone help me on this? Is the CoreGraphics is right way to do this? Thanks in advance. After some struggling almost with the same problem (but with NSImage), made a category for replacing colors in NSImage

Replace particular color of image in iOS

混江龙づ霸主 提交于 2019-12-01 02:27:08
问题 I want to replace the particular color of an image with other user selected color. While replacing color of image, I want to maintain the gradient effect of that original color. for example see the attached images. I have tried to do so with CoreGraphics & I got success to replace color. But the replacing color do not maintain the gradient effect of the original color in the image. Can someone help me on this? Is the CoreGraphics is right way to do this? Thanks in advance. 回答1: After some

Create CVPixelBuffer from YUV with IOSurface backed

谁说胖子不能爱 提交于 2019-11-30 11:09:46
问题 So I am getting raw YUV data in 3 separate arrays from a network callback (voip app). From what I understand you cannot create IOSurface backed pixel buffers with CVPixelBufferCreateWithPlanarBytes according to here Important: You cannot use CVPixelBufferCreateWithBytes() or CVPixelBufferCreateWithPlanarBytes() with kCVPixelBufferIOSurfacePropertiesKey. Calling CVPixelBufferCreateWithBytes() or CVPixelBufferCreateWithPlanarBytes() will result in CVPixelBuffers that are not IOSurface-backed So

opengles display human face in iphone

一世执手 提交于 2019-11-30 10:12:16
I need to make a human 2D face to 3D face. I used this link to load an ".obj" file and map the textures. This example is only for cube and pyramid. I loaded a human face ".obj" file. This loads the .obj file and can get the human face properly as below. But my problem here is I need to display different human faces without changing the ".obj" file. just by texture mapping. But the texture is not getting mapped properly, as the obj file is of different model. I just tried changing the ".png" file which is used as texture and the below is the result, where the texture is mapped but not exactly

Convert GLKMatrix4 and CATransform3D

删除回忆录丶 提交于 2019-11-30 05:44:44
问题 Is there a way to cast from CATransform3D to GLKMatrix4, or do I always need to manually convert them from value to value? I guess casting would be faster. 回答1: Unfortunately there is not as of now. There's most likely a hidden API call that Apple uses to convert via CALayers and OpenGL, but for now the following is your best bet. I would just make a utility class that would contain this in it. - (GLKMatrix4)matrixFrom3DTransformation:(CATransform3D)transform { GLKMatrix4 matrix =