#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 &#
c++ OpenGL显示YUV数据
最新推荐文章于 2024-05-15 00:44:34 发布