PART ONE
codes.cpp
#include <iostream>
#include <GL/freeglut.h>
using namespace std;
void grab(GLint w, GLint h)
{
GLubyte* image;
GLint dataLength = w * 4 * h; //四通道
image = (GLubyte*)malloc(dataLength);// 分配CPU内存
if (image == 0) {
exit(0);
}
else {
//将GPU缓存数据四通道解包存到CPU内存
glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
glReadPixels(0, 0, w, h, GL_BGR_EXT, GL_UNSIGNED_BY