简体   繁体   中英

Using OpenGL ES 3.1 on Google Tango

I'm trying to get a camera image from the tango api by calling "TangoService_connectTextureId".

The problem is, there is no "GL_TEXTURE_EXTERNAL_OES" defined, so I'm not able to create an external texture object. All the samples use ES 2 only but having this limitation is just stupid on such a device.

maybe it's my fault, so here is my setup:

  • Visual Studio 2013 with Nsight Tegra extension.
  • 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):

     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.

GLES 3.0 including gl2ext.h describes a hack to actually use the headers with 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;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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