Add mjmodel support for textures with different number of channels.

PiperOrigin-RevId: 653974959
Change-Id: Ia280e0bdb21027646249f104f21bedee792ba7e5
This commit is contained in:
Tom Erez
2024-07-19 05:21:16 -07:00
committed by Copybara-Service
parent 70ac76bb4b
commit e92af73cbf
11 changed files with 43 additions and 24 deletions
+3 -3
View File
@@ -1382,7 +1382,7 @@ void mjr_uploadTexture(const mjModel* m, const mjrContext* con, int texid) {
// assign data
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, m->tex_width[texid], m->tex_height[texid], 0,
GL_RGB, GL_UNSIGNED_BYTE, m->tex_rgb + m->tex_adr[texid]);
GL_RGB, GL_UNSIGNED_BYTE, m->tex_data + m->tex_adr[texid]);
// generate mipmaps
glGenerateMipmap(GL_TEXTURE_2D);
@@ -1416,7 +1416,7 @@ void mjr_uploadTexture(const mjModel* m, const mjrContext* con, int texid) {
if (m->tex_width[texid] == m->tex_height[texid]) {
for (int i=0; i < 6; i++) {
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X+i, 0, GL_RGB, w, w, 0,
GL_RGB, GL_UNSIGNED_BYTE, m->tex_rgb + m->tex_adr[texid]);
GL_RGB, GL_UNSIGNED_BYTE, m->tex_data + m->tex_adr[texid]);
}
}
@@ -1424,7 +1424,7 @@ void mjr_uploadTexture(const mjModel* m, const mjrContext* con, int texid) {
else {
for (int i=0; i < 6; i++) {
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X+i, 0, GL_RGB, w, w, 0,
GL_RGB, GL_UNSIGNED_BYTE, m->tex_rgb + m->tex_adr[texid] + i*3*w*w);
GL_RGB, GL_UNSIGNED_BYTE, m->tex_data + m->tex_adr[texid] + i*3*w*w);
}
}