所以,我试图将我的openGLES 1.0代码移植到OpenGLES 2.0(GLKit)。基本概念是你可以在3D空间中走动。
我正在努力的是根据我的相机位置移动一个物体(控制线连接等)
- (void)glkView:(GLKView *)view drawInRect:(CGRect)rect {
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
self.baseEffect.transform.modelviewMatrix = GLKMatrix4MakeLookAt(eye[0], eye[1], eye[2],center[0], center[1], center[2], 0.0, 1, 0.0);
[self.baseEffect prepareToDraw];
self.cube.effect.transform.modelviewMatrix = self.baseEffect.transform.modelviewMatrix;
self.cube.effect.transform.projectionMatrix = self.baseEffect.transform.projectionMatrix;
// Used to scale stuff based on screen res
static float roation = 0;
self.cube.rotation = GLKVector3Make(0, roation, 0);
[self.cube drawWithRotationWithRenderMode:RenderTexture];
[self handleTouches];
}
我所困扰的是基于相机的立方体渲染(我相信我需要像setIdentyM
- (void)drawWithRotationWithRenderMode:(RenderMode)renderMode
{
[EAGLContext setCurrentContext:APP_DELEGATE.context];
float alpha = 1;
float doNotRender = NO;
GLKMatrix4 current = GLKMatrix4Identity;
current = GLKMatrix4Translate(current, position.x, position.y, position.z);
current = GLKMatrix4Scale(current, scale.x, scale.y, scale.z);
self.effect.transform.modelviewMatrix = current;
答案 0 :(得分:0)
这就是baseEffect在使用之前不是init的问题:(