Add an option in mjrContext for mjr_readPixels output format.
PiperOrigin-RevId: 500342924 Change-Id: I43e8c6208db341e2bdbef10382b7293c35bdca65
This commit is contained in:
committed by
Copybara-Service
parent
e40775fab3
commit
1215067f5c
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -2282,6 +2282,7 @@ public unsafe struct mjrContext_ {
|
||||
public int windowStereo;
|
||||
public int windowDoublebuffer;
|
||||
public int currentBuffer;
|
||||
public int readPixelFormat;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
|
||||
Reference in New Issue
Block a user