Add an option in mjrContext for mjr_readPixels output format.

PiperOrigin-RevId: 500342924
Change-Id: I43e8c6208db341e2bdbef10382b7293c35bdca65
This commit is contained in:
Saran Tunyasuvunakool
2023-01-07 00:10:03 -08:00
committed by Copybara-Service
parent e40775fab3
commit 1215067f5c
5 changed files with 11 additions and 1 deletions
+3
View File
@@ -1602,6 +1602,9 @@ void mjr_makeContext_offSize(const mjModel* m, mjrContext* con, int fontscale,
while ((err = glGetError())) {
mju_warning_i("OpenGL error 0x%x in or before mjr_makeContext", err);
}
// set default color pixel format for mjr_readPixels
con->readPixelFormat = GL_RGB;
}
+1 -1
View File
@@ -153,7 +153,7 @@ void mjr_readPixels(unsigned char* rgb, float* depth,
// read rgb and depth
if (rgb) {
glReadPixels(viewport.left, viewport.bottom, viewport.width, viewport.height,
GL_RGB, GL_UNSIGNED_BYTE, rgb);
con->readPixelFormat, GL_UNSIGNED_BYTE, rgb);
}
if (depth) {
glReadPixels(viewport.left, viewport.bottom, viewport.width, viewport.height,