我试图完成YV12到RGB转换提到在这个岗位与GLSL着色器.
我的应用程序从磁盘加载原始YV12帧并尝试使用GLSL着色器执行转换.但是,生成的图像会垂直翻转并出现一些颜色问题.我认为问题可能是图像被读取为char(1字节)的数组,然后转换为GLushort(2字节)的数组.你怎么看?
这是原始YUV框架的样子:

这是我得到的输出:

我正在分享以下应用程序的源代码:
#include <assert.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <GL/glew.h>
#include <GL/glut.h>
#include <GL/glu.h>
#include <iostream>
#include <fstream>
#ifndef SEEK_SET
# define SEEK_SET 0
#endif
static GLfloat Xrot = 0, Yrot = 0, Zrot = 0;
static GLint ImgWidth, ImgHeight;
static GLushort *ImageYUV = NULL;
static void DrawObject(void)
{
glBegin(GL_QUADS);
glTexCoord2f(0, 0);
glVertex2f(-1.0, -1.0);
glTexCoord2f(ImgWidth, 0);
glVertex2f(1.0, -1.0);
glTexCoord2f(ImgWidth, ImgHeight);
glVertex2f(1.0, 1.0);
glTexCoord2f(0, …Run Code Online (Sandbox Code Playgroud)