简体   繁体   English

在Google Tango上使用OpenGL ES 3.1

[英]Using OpenGL ES 3.1 on Google Tango

I'm trying to get a camera image from the tango api by calling "TangoService_connectTextureId". 我正在尝试通过调用“ TangoService_connectTextureId”从探戈api获取相机图像。

The problem is, there is no "GL_TEXTURE_EXTERNAL_OES" defined, so I'm not able to create an external texture object. 问题是,没有定义“ GL_TEXTURE_EXTERNAL_OES”,因此我无法创建外部纹理对象。 All the samples use ES 2 only but having this limitation is just stupid on such a device. 所有样本仅使用ES 2,但是在这种设备上具有这种局限性只是愚蠢的。

maybe it's my fault, so here is my setup: 也许是我的错,所以这是我的设置:

  • Visual Studio 2013 with Nsight Tegra extension. 带有Nsight Tegra扩展的Visual Studio 2013。
  • Includes: 包括:

     #include <GLES3/gl3.h> #include <GLES3/gl3ext.h> #include <GLES3/gl3platform.h> #include <EGL/egl.h> #include <EGL/eglext.h> 
  • I'm linking against: 我反对:

     tango_client_api GLESv3 EGL 
  • The texture to pass TangoService_connectTextureId to should be created like this (while using GL_TEXTURE_2D does not work because the image stays black): 传递TangoService_connectTextureId到的纹理应该这样创建(在使用GL_TEXTURE_2D时不起作用,因为图像保持黑色):

     glGenTextures(1, &texture_id_); glBindTexture(GL_TEXTURE_EXTERNAL_OES, texture_id_); glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glBindTexture(GL_TEXTURE_EXTERNAL_OES, 0); 

I found some hints and got it working: 我发现了一些提示并使其起作用:

https://www.khronos.org/registry/gles/ lists the headers to include. https://www.khronos.org/registry/gles/列出要包含的标题。

GLES 3.0 including gl2ext.h describes a hack to actually use the headers with API 19. 包含gl2ext.h的GLES 3.0描述了一种在API 19中实际使用标头的技巧。

so this works for me now: 所以现在对我有效:

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

for processing the image in the shader you can start with the following fragment program: 要在着色器中处理图像,可以从以下片段程序开始:

#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;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM