在 Google Tango 上使用 OpenGL ES 3.1

Using OpenGL ES 3.1 on Google Tango

我正在尝试通过调用 "TangoService_connectTextureId" 从探戈 api 获取相机图像。

问题是,没有 "GL_TEXTURE_EXTERNAL_OES" 定义,所以我无法创建外部纹理对象。所有样本都只使用 ES 2,但在这样的设备上有这个限制是愚蠢的。

也许是我的错,所以这是我的设置:

我找到了一些提示并开始工作:

https://www.khronos.org/registry/gles/ 列出要包含的 headers。

GLES 3.0 including gl2ext.h 描述了实际使用 headers 和 API 19.

的技巧

现在这对我有用了:

#include <GLES3/gl3.h>
#define __gl2_h_                 // what the f***   
#include <GLES2/gl2ext.h>
#include <GLES3/gl3platform.h>

要在着色器中处理图像,您可以从以下片段程序开始:

#version 300 es
#extension GL_OES_EGL_image_external : require
precision highp float;

// input
uniform samplerExternalOES InputTexture;
in vec2 v_TexCoord;

// output
layout(location = 0) out vec4 OutputColor;

void main()
{
    vec2 flippedCoord = vec2(v_TexCoord.x, 1.0 - v_TexCoord.y);
    OutputColor = texture2D(InputTexture, flippedCoord);
    OutputColor.a = 1.0;
}