PART ONE




codes.cpp
#include <iostream>
#include <GL/freeglut.h>
using namespace std;
#define width 150
#define height 150
GLubyte green[height][width][4];
void initGreen()
{
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
green[y][x][0] = 0;
green[y][x][1] = 255;
green[y][x][2] = 0;
green[y][x][3] = 255;
}
}
}
void grab(GLint w, GLint h)
{
GLubyte* image;
GLint dataLength = w * 4 * h; //

本文分析了OpenGL的glReadPixels()函数,指出其抓取的并非屏幕显示内容,而是缓冲区的viewport。内容指出glReadPixels()的结果会随窗口变化,并详细说明如何将抓取的图像保存为bmp文件。
最低0.47元/天 解锁文章
1046

被折叠的 条评论
为什么被折叠?



