Created
February 24, 2019 22:06
-
-
Save robertleeplummerjr/1760f7c9c9332106a0b6592a82a5cf69 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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