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
@@ -1303,6 +1303,9 @@ struct mjrContext_ { // custom OpenGL context
// framebuffer
int currentBuffer; // currently active framebuffer: mjFB_WINDOW or mjFB_OFFSCREEN
// pixel output format
int readPixelFormat; // default color pixel format for mjr_readPixels
};
typedef struct mjrContext_ mjrContext;
typedef enum mjtButton_ { // mouse button
+3
View File
@@ -149,6 +149,9 @@ struct mjrContext_ { // custom OpenGL context
// framebuffer
int currentBuffer; // currently active framebuffer: mjFB_WINDOW or mjFB_OFFSCREEN
// pixel output format
int readPixelFormat; // default color pixel format for mjr_readPixels
};
typedef struct mjrContext_ mjrContext;
+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,
+1
View File
@@ -2282,6 +2282,7 @@ public unsafe struct mjrContext_ {
public int windowStereo;
public int windowDoublebuffer;
public int currentBuffer;
public int readPixelFormat;
}
[StructLayout(LayoutKind.Sequential)]