我想在Swift中通过OpenGL显示RGB纹理,
在Objective-C中运行正常,我尝试将代码移植到Swift语言中,
我真的不明白如何通过自定义结构将值传递给Swift中的着色器,
任何人都可以提供有关如何在Swift中通过OpenGL显示RGB纹理的简单教程?
我的着色器:
顶点:
precision highp float;
attribute vec2 positionCoords;
attribute vec2 textureCoords;
uniform mat4 modelViewProjectionMatrix;
varying vec2 v_texcoord;
void main()
{
gl_Position = modelViewProjectionMatrix * vec4(positionCoords, 0.0, 1.0);
v_texcoord = textureCoords.xy;
}
分段:
precision highp float;
varying vec2 v_texcoord;
uniform sampler2D s_texture;
void main()
{
gl_FragColor = texture2D(s_texture, v_texcoord);
}
问题解决了,
使用glvertexarray绑定顶点缓冲区数据
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句