GLKit:为 Swift 格式化 Objective-C GLKit 参数

GLKit: Format Objective-C GLKit parameters for Swift

场景

我正在构建一个应用程序来处理视频帧的色度值。我正在使用来自另一个项目的 Objective-C 代码并将其翻译成 Swift。但是我遇到了一段奇怪的代码,我想将其翻译成 Swift,如果我能弄清楚它的含义的话。方法如下:

- (void)updateUniformValues
{
   // Precalculate the mvpMatrix
   GLKMatrix4 modelViewProjectionMatrix = GLKMatrix4Multiply(
      self.transform.projectionMatrix, 
      self.transform.modelviewMatrix);
   glUniformMatrix4fv(uniforms[GMVPMatrix], 1, 0, 
      modelViewProjectionMatrix.m);

   // Texture samplers
   const GLint samplerIDs[1] = {self.texture2d0.name};
   glUniform1iv(uniforms[GSamplers2D], 1, 
      samplerIDs); 
}

note: self.texture2d0 is of type GLKEffectPropertyTexture

有问题的行是 const GLint samplerIDs[1] = {self.texture2d0.name};。在 Swift 中编程之前,我已经在 Objective-C 中编码多年,但我以前从未见过这样的东西。所以它是一个 Glint 类型的常量,但是从没有 return 语句的 self.texture2d0 块中分配了一个值? [1] 让我觉得它应该是 Array。好迷茫。

问题

这条线在做什么?我如何将其翻译成 Swift?

它是一个 samplerIDsGLintconst 数组,有一个非常量成员 self.texture2d0.name.

这类似于:

let samplerIDs = [self.texture2d0.name]