Skip to content

Instantly share code, notes, and snippets.

@robertleeplummerjr
Created February 24, 2019 22:06
Show Gist options
  • Save robertleeplummerjr/1760f7c9c9332106a0b6592a82a5cf69 to your computer and use it in GitHub Desktop.
Save robertleeplummerjr/1760f7c9c9332106a0b6592a82a5cf69 to your computer and use it in GitHub Desktop.
static GLubyte* toPixels(int width, int height) {
GLubyte bytes[width * height * 4];
(reinterpret_cast<PFNGLREADPIXELSPROC>(eglGetProcAddress("glReadPixels")))(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, bytes);
std::ofstream file;
file.open("test-google-angle.ppm");
file << "P3\n";
file << "# gl.ppm\n";
file << width;
file << " ";
file << height;
file << "\n255\n";
int max = width * height * 4;
for (int i = 0; i < max; i += 4) {
file << reinterpret_cast<const char*>(bytes[i]);
file << " ";
file << reinterpret_cast<const char*>(bytes[i + 1]);
file << " ";
file << reinterpret_cast<const char*>(bytes[i + 2]);
file << " ";
}
file.close();
return bytes;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment