c++ OpenGL显示YUV数据

#include <jni.h>
#include <GLES2/gl2.h>
#include <string.h>
#include "openglNative.h"
#include <android/log.h>
#include <EGL/egl.h>

#define LOG_TAG "OPENGL"
#define LOGI(...) __android_log_print(ANDROID_LOG_DEBUG, LOG_TAG,__VA_ARGS__)

GLuint program;
GLuint vertexShader;
GLuint pixelShader;
GLint _positionHandle = -1, _coordHandle = -1;

int _width = 0;
int _height = 0;

const GLchar *VERTEX_SHADER = "attribute vec4 vPosition;\n"
        "attribute vec2 a_texCoord;\n"
        "varying vec2 tc;\n"
        "void main() {\n"
        "gl_Position = vPosition;\n"
        "tc = a_texCoord;\n"
        "}\n";

const GLchar *FRAGMENT_SHADER = "precision mediump float;\n"
        "uniform sampler2D tex_y;\n"
        "uniform sampler2D tex_u;\n"
        "uniform sampler2D tex_v;\n"
        "varying vec2 tc;\n"
        "void main() {\n"
        "vec4 c = vec4((texture2D(tex_y, tc).r - 16./255.) * 1.164);\n"
        "vec4 U = vec4(texture2D(tex_u, tc).r - 128./255.);\n"
        "vec4 V = vec4(texture2D(tex_v, tc).r - 128./255.);\n"
        "c += V * vec4(1.596, -0.813, 0, 0);\n"
        "c += U * vec4(0, -0.392, 2.017, 0);\n"
        "c.a = 1.0;\n"
        "gl_FragColor = c;\n"
        "}\n";

GLuint _frameBuffer;
GLuint _renderBuffer;

GLenum _textureI = GL_TEXTURE0;
GLenum _textureII = GL_TEXTURE1;
GLenum _textureIII = GL_TEXTURE2;
GLenum _tIindex = 0;
GLenum _tIIindex = 1;
GLenum _tIIIindex = 2;

GLint _yhandle = -1, _uhandle = -1, _vhandle &#
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值