glkit

OpenGL scene coordinates to screen coordinates

 ̄綄美尐妖づ 提交于 2019-12-23 02:51:09
问题 I'm having trouble converting my OpenGL scene coordiates to my screen coordinates. I thought I needed to multiply my coordinates with the modelview matrix then with the projection matrix to get the ndc. But i'm getting weird coordinates. Here is my piece of code GLKVector3 coor = GLKVector3Make(point.x, point.y, 0); GLKMatrix4 modelview = GLKMatrix4MakeWithArray(glProjectionMatrix); GLKMatrix4 projetion = GLKMatrix4MakeWithArray(modelViewMatrix.data); GLKVector3 eyeCoor =

GLKView set drawable properties

≯℡__Kan透↙ 提交于 2019-12-21 03:23:13
问题 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

iOS OpenGL ES screen rotation while background apps bar visible

大城市里の小女人 提交于 2019-12-20 23:29:06
问题 My app uses GLKit to render 3D scene with OpenGL ES . All works fine, except one thing. When I launch my app in iPad and display background apps bar (with double "Home" button click) and then change device's orientation, scene is updated wrongly (last rendered image is simply stretched to fill new rectangle). I found the reason. When background apps bar appears, GLKViewController's paused is set to YES automatically (application delegate receives -applicationWillResignActive: ) and no

How is GLKit's GLKMatrix “Column Major”?

馋奶兔 提交于 2019-12-20 10:30:48
问题 Premise A When talking about "Column Major" matrices in linear memory, columns are specified one after another, such that the first 4 entries in memory correspond to the first column in the matrix. "Row Major" matrices, on the other hand, are understood to specify rows one after another, such that the first 4 entries in memory specify the first row of the matrix. A GLKMatrix4 looks like this: union _GLKMatrix4 { struct { float m00, m01, m02, m03; float m10, m11, m12, m13; float m20, m21, m22,

GLKit masking or blending 2 textures both from jpegs no alphas

三世轮回 提交于 2019-12-13 06:06:22
问题 I am using GLKit, and at 24 fps I need to take a CGImageRef (no alpha layer) and apply another CGImageRef (no alpha layer) as a mask to it (black and white image) and render the result as a GLKit texture. At first I tried this approach: CGImageRef actualMask = CGImageMaskCreate(CGImageGetWidth(maskRef), CGImageGetHeight(maskRef), CGImageGetBitsPerComponent(maskRef), CGImageGetBitsPerPixel(maskRef), CGImageGetBytesPerRow(maskRef), CGImageGetDataProvider(maskRef), NULL, false); CGImageRef

Using GLKit and OpenGL-ES, How To Draw Two Triangles, One Textured, Another Solid

空扰寡人 提交于 2019-12-13 03:43:42
问题 I'm new to OpenGL-ES and have started working my way through Buck's Learning OpenGL ES for iOS book. Chapter 2 covers drawing triangles with a solid color, and chapter 3 moves on to use textures. As a personal learning exercise, I'm trying to alter the sample code to draw two triangles; one with the texture, the other solid. Seems like a very basic exercise, but one that - as an OpenGL-ES beginner - is proving tricky. So far I've tried a combination of things. First, I prepare to draw with

GLKTextureLoader textureWithContentsOfFile: fails for the first time

断了今生、忘了曾经 提交于 2019-12-13 02:54:15
问题 I am using GLKTextureLoader to load image textures into a sprite. When I run the following code and load two sprites... NSString *pathToImage = [NSString stringWithFormat:@"%@/defaultProject/images/%@", [Util applicationDocumentsDirectory], fileName]; NSLog(@"path: %@", pathToImage); self.textureInfo = [GLKTextureLoader textureWithContentsOfFile:pathToImage options:options error:&error]; if (self.textureInfo == nil) { NSLog(@"Error loading file: %@", [error localizedDescription]); return; } .

GCD and for loops

戏子无情 提交于 2019-12-13 02:39:24
问题 I was wondering what is the difference between using a for loop, and using the dispatch_apply function of GCD and couldn't find an answer in the documentation nor in questions here. Also, will using the GCD function in a runtime situation as a GLKit render/update method will produce better results? 回答1: Also, will using the GCD function in a runtime situation as a GLKit render/update method will produce better results? The only way to answer that question is to try it and measure the

GLKit vs. Metal perspective matrix difference

坚强是说给别人听的谎言 提交于 2019-12-12 08:55:56
问题 I'm reading a Metal tutorial on raywenderlich.com, where it introduces a pure Swift float4x4 helper class. 99% it's just wrapper around GLKit functions, except one function which really puzzles me: static func makePerspectiveViewAngle(_ fovyRadians: Float, aspectRatio: Float, nearZ: Float, farZ: Float) -> float4x4 { var q = unsafeBitCast(GLKMatrix4MakePerspective(fovyRadians, aspectRatio, nearZ, farZ), to: float4x4.self) let zs = farZ / (nearZ - farZ) q[2][2] = zs q[3][2] = zs * nearZ return

Load a two texture for a single image at a regular interval of time - GLkit openglES

懵懂的女人 提交于 2019-12-12 01:29:30
问题 I used the below code to load the texture on a object. - (void)ldText:(UIImage *)Image { glGenTextures(1, &texture); glBindTexture(GL_TEXTURE_2D, texture); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); CGImageRef cgImage = Image.CGImage; float Width = CGImageGetWidth(cgImage); float Height = CGImageGetHeight(cgImage); CFDataRef data = CGDataProviderCopyData(CGImageGetDataProvider(cgImage)); glTexImage2D(GL