Add mjmodel support for textures with different number of channels.
PiperOrigin-RevId: 653974959 Change-Id: Ia280e0bdb21027646249f104f21bedee792ba7e5
This commit is contained in:
committed by
Copybara-Service
parent
70ac76bb4b
commit
e92af73cbf
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2505,9 +2505,10 @@ void mjCModel::CopyObjects(mjModel* m) {
|
||||
m->tex_height[i] = ptex->height;
|
||||
m->tex_width[i] = ptex->width;
|
||||
m->tex_adr[i] = data_adr;
|
||||
m->tex_nchannel[i] = 3;
|
||||
|
||||
// copy rgb data
|
||||
memcpy(m->tex_rgb + data_adr, ptex->rgb.data(), 3*ptex->width*ptex->height);
|
||||
memcpy(m->tex_data + data_adr, ptex->rgb.data(), 3*ptex->width*ptex->height);
|
||||
|
||||
// advance counter
|
||||
data_adr += 3*ptex->width*ptex->height;
|
||||
|
||||
Reference in New Issue
Block a user