在之前的博客中
如果我们要对输入的视频内容做一个锐化处理,或者其他特效,在shader中如何处理呢?
完整code如下,看到code就明白其中的道理了,还是很简单的。
// VideoPlayer.cpp : Defines the entry point for the console application.
//
#include <stdio.h>
#include <GLTools.h> // OpenGL toolkit
#include <GLShaderManager.h>
#ifdef __APPLE__
#include <glut/glut.h>
#else
#define FREEGLUT_STATIC
#include <GL/glut.h>
#endif
#include <GL/glew.h>
#include <GL/freeglut.h>
#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
#include <string.h>
//macro to write shader programs inline
#ifndef GLSL
#define GLSL(version, A) "#version " #version "\n" #A
#endif
//Select one of the Texture mode (Set '1'):
#define TEXTURE_DEFAULT 0
//Rotate the texture
#define TEXTURE_ROTATE 0
//Show half of the Texture
#define TEXTURE_HALF 1
const int screen_w = 640, screen_h = 480;
const int pixel_w = 640, pixel_h = 480;
//YUV 422 file
FILE *infile = NULL;
unsigned char buf[pixel_w*pixel_h * 2];
unsigned char *plane[3];
GLuint p;
GLuint id_y, id_u, id_v; // Texture id
GLuint textureUniformY, textureUniformU, textureUniformV;
GLShaderManager shaderManager;
GLBatch squareBatch;
GLBatch squareBatch_v2;
GLfloat blockSize = 0.2f;
GLfloat vVerts[] = {
-blockSize, -blockSize, 0.0f,
blockSize, -blockSize, 0.0f,
blockSize, blockSize, 0.0f,
-blockSize, blockSize, 0.0f };
GLfloat blockSize_v2 = 0.3f;
GLfloat vVerts_v2[] = {
-blockSize_v2, -blockSize_v2, 0.0f,
blockSize_v2, -blockSize_v2, 0.0f,
blockSize_v2, blockSize_v2, 0.0f,
-blockSize_v2, blockSize_v2, 0.0f };
void add_rect_roi()
{
GLfloat vRed[] = { 0.9f, 0.0f, 0.9f, 0.8f };
//glEnable(GL_DEPTH_TEST);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
//glBlendFunc(GL_ZERO, GL_ZERO);
shaderManager.UseStockShader(GLT_SHADER_IDENTITY, vRed);
squareBatch.Draw();
glDisable(GL_BLEND);
}
void test_line()
{
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glLineWidth(5);
//glBegin(GL_LINES);
glBegin(GL_LINE_STRIP);
//glBegi