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 BUFFER()
{
glClearColor(1, 0, 0, 0);
glClear(GL_COLOR_BUFFER_BIT);
initGreen();
glDrawPixels(width, height, GL_RGBA, GL_UNSIGNED_BYTE, green);
glFlush();
}
int main(int argc, char** argv)
{
glutInit(&argc, argv);
glutCreateWindow("glDrawPixels");
glutDisplayFunc(BUFFER);
glutMainLoop();
return 0;
}
PA

本文探讨了OpenGL中的glDrawPixels()函数,通过代码分析展示了该函数如何在BUFFER上绘制,指出BUFFER大小会根据视口调整,但写入的颜色数据不变。重点解析了GLubyte像素类型和缓冲区交互过程。
最低0.47元/天 解锁文章
2110

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



