glkit

OpenGL scene coordinates to screen coordinates

给你一囗甜甜゛ 提交于 2019-12-07 02:27:26
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 = GLKMatrix4MultiplyVector3(modelview, coor); GLKVector3 ndcCoor = GLKMatrix4MultiplyVector3(projetion,eyeCoor); CGPoint p =

Updating OpenGL ES Touch Detection (Ray Tracing) for iPad Retina?

北城余情 提交于 2019-12-06 15:12:20
问题 I have the below code which I am using for ray tracing. The code works successfully on non-retina iPads, however does not function on the retina iPads. The touch is detected, however the converted point is off to the left and below where it should be. Can anyone suggest how I can update the below to accommodate the retina screen ? - (void)handleTap: (UITapGestureRecognizer *)recognizer { CGPoint tapLoc = [recognizer locationInView:self.view]; bool testResult; GLint viewport[4]; glGetIntegerv

iOS: Questions about camera information within GLKMatrix4MakeLookAt result

☆樱花仙子☆ 提交于 2019-12-06 05:11:11
The iOS 5 documentation reveals that GLKMatrix4MakeLookAt operates the same as gluLookAt . The definition is provided here: static __inline__ GLKMatrix4 GLKMatrix4MakeLookAt(float eyeX, float eyeY, float eyeZ, float centerX, float centerY, float centerZ, float upX, float upY, float upZ) { GLKVector3 ev = { eyeX, eyeY, eyeZ }; GLKVector3 cv = { centerX, centerY, centerZ }; GLKVector3 uv = { upX, upY, upZ }; GLKVector3 n = GLKVector3Normalize(GLKVector3Add(ev, GLKVector3Negate(cv))); GLKVector3 u = GLKVector3Normalize(GLKVector3CrossProduct(uv, n)); GLKVector3 v = GLKVector3CrossProduct(n, u);

Multithreading GLKView drawing

限于喜欢 提交于 2019-12-05 23:38:20
问题 My main view controller contains many sub-views. One such subview is a GLKView linked up to a GLKViewController . The GLKViewController seems to be the one in charge of updating the GLKView 's display, and something automagical is calling that update function on the main thread. One of my other views in this main view controller is a UITableView . When the user is interacting with the table view, the GLKView stops updating. I'll admit, I am pretty new to OGL ES programming, so I'm not sure

Difference between glkView:drawInRect: and glkViewControllerUpdate:? OpenGL ES 2 - iOS

我只是一个虾纸丫 提交于 2019-12-05 12:21:39
What should be the difference, purpose wise, between these two methods in my render loop? Apple has this to say.... About update() The view controller calls its delegate’s glkViewControllerUpdate: method. Your delegate should update frame data that does not involve rendering the results to the screen. About drawInRect: the GLKView object makes its OpenGL ES context the current context and binds its framebuffer as the target for OpenGL ES rendering commands. Your delegate method should then draw the view’s contents. So basically, when I create a GLKView in my view controller, that controller

How do I convert this OpenGL pointer math to Swift?

早过忘川 提交于 2019-12-05 00:35:33
问题 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

Texture mapping in GLKit is not working only in devices

孤街醉人 提交于 2019-12-04 21:29:40
问题 I used the code in this link to map textures of human faces. This code uses GLKIT to render the images. Code works fine in simulator but the same code if I run in device its not working. The below are the screen shots of the images where it works in device and not in my ipad. Code I used to Load Texture: - (void)loadTexture:(UIImage *)textureImage { glGenTextures(1, &_texture); glBindTexture(GL_TEXTURE_2D, _texture); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);

Updating OpenGL ES Touch Detection (Ray Tracing) for iPad Retina?

旧街凉风 提交于 2019-12-04 20:51:28
I have the below code which I am using for ray tracing. The code works successfully on non-retina iPads, however does not function on the retina iPads. The touch is detected, however the converted point is off to the left and below where it should be. Can anyone suggest how I can update the below to accommodate the retina screen ? - (void)handleTap: (UITapGestureRecognizer *)recognizer { CGPoint tapLoc = [recognizer locationInView:self.view]; bool testResult; GLint viewport[4]; glGetIntegerv(GL_VIEWPORT, viewport); float uiKitOffset = 113; //Need to factor in the height of the nav bar + the

Using GLKView with a UIViewController

拜拜、爱过 提交于 2019-12-04 16:40:17
I wanted to use OpenGL to do some simple Image processing, so I started off with GLKView . Since I don't need to refresh the view every few seconds, I didn't use the GLKViewController and instead used a normal UIViewController subclass. My question is that do I simply make the viewController's view as a GLKView or do I add the GLKView as a subview of the view controller's view. Since I'm adding a UISlider to the view as well, I think the latter seems better, but I'm not sure. I also need to call setNeedsDisplay on the GLKView on certain occasions. For your rendering, you should really be using

GLKTextureLoader fails when loading a certain texture the first time, but succeeds the second time

左心房为你撑大大i 提交于 2019-12-04 03:23:35
I'm making an iPhone application with OpenGL ES 2.0 using the GLKit. I'm using GLKTextureLoader to load textures synchronously. The problem is that for a certain texture, it fails to load it the first time. It gives this error: The operation couldn’t be completed. (GLKTextureLoaderErrorDomain error 8.) For this error code, the apple documentation says the following: GLKTextureLoaderErrorUncompressedTextureUpload An uncompressed texture could not be uploaded. Available in iOS 5.0 and later. Declared in GLKTextureLoader.h. (not very much). Could I be trying to load the texture while the opengl