Historique des modifications - Message

Message #11795

Sujet: Changer la coloration de la texture d'une skybox


Type Date Auteur Contenu
Création du message 10-05-2017 11:02:23 Magun
tu doit crée une nouvelle texture (irrlicht met en cache quand tu fait getTexture et donc c'est la même que u modifi je suppose)
donc tu utilise rendered.push_back(driver->addTexture(skybox[0]-> getSize(), "skybox_left", skybox[0]-> getColorFormat()))

il te suffi de lock les deux texture, un memcpy de l'original vers la copie, et tu fait ton operation sur les pixel ou les deux a la fois wink

Code c++ :


for(int i = 0; i<skybox.size(); ++i)
{
    irr::core::stringc name = "skybox_";
    name += i;
    rendered.push_back(driver->addTexture(skybox[0]-> getSize(), name.c_str(), skybox[0]-> getColorFormat()))
}

// puis

for(int i = 0; i<skybox.size(); ++i)
{
      irr::video::SColor color;
      unsigned char *src = (unsigned char*) skybox[i]->lock(ETLM_READ_ONLY);
      unsigned char *dst = (unsigned char*) rendered[i]->lock(ETLM_WRITE_ONLY);
     
      u32 pitch = skybox[i]->getPitch();
      u32 bytes = video::IImage::getBitsPerPixelFromFormat(skybox[i]->getColorFormat()) / 8;

      for(unsigned x = 0; x<skybox[i]->getSize().Width; ++x)
      {
          for(unsigned y = 0; y<skybox[i]->getSize().Height; ++y)
          {
              unsigned char *in = src + (y * pitch) + (x * bytes);
              unsigned char *out = dst + (y * pitch) + (x * bytes);

              color.setData(in, skybox[i]->getColorFormat());

              // bla bla bla

              color.getData(out, skybox[i]->getColorFormat());
          }
      }

      rendered[i]->unlock();
      skybox[i]->unlock();
}

Retour

Options Liens officiels Caractéristiques Statistiques Communauté
Préférences cookies
Corrections
irrlicht
irrklang
irredit
irrxml
Propulsé par Django
xhtml 1.0
css 2.1
884 membres
1440 sujets
11337 messages
Dernier membre inscrit: Saidov17
113 invités en ligne
membre en ligne: -
RSS Feed