Jump to content

[SOLVED] iOS trouble with setImageTextureFlags


photo

Recommended Posts

Posted

Hi,

 

I have a function who can set new image for my materials, when I set my image I call

setImageTextureFlags(_did, MATERIAL_WRAP_CLAMP_X | MATERIAL_WRAP_CLAMP_Y | MATERIAL_WRAP_CLAMP_Z);

 

This code work well on OSX but when I try on iOS if i call my function twice, the result give me a black texture.
Seems it's not possible to call twice this function on iOS, any idea why ?

void Tile::setMaterial(int quality) {
    
    string filepath = TMP_PATH+""+quality+"_"+_id+".jpg";
    if (is_file(filepath) == 1 && _quality != quality) {
        
        _mat.setImageTextureName(_did,filepath);
        
        if (_quality == HIGH) // Fix for iOS otherwise I have a black texture
            _mat.setImageTextureFlags(_did, MATERIAL_WRAP_CLAMP_X | MATERIAL_WRAP_CLAMP_Y | MATERIAL_WRAP_CLAMP_Z);
        
        _quality = quality;
    }
}
Posted

Hi Anthony,

 

That might be because of non-power of two textures. Also, take notice that NPOT textures cannot have 'repeat' wrap mode on iOS unless you're using GLES 3.0.

Posted

Hi unclebob,

 

The texture are POT, the first texture load will be 16 or 32  and the second will be 256 or 512

  • 1 month later...
Posted

Hey Anthony,

 

I'm just curious if you managed to solve this or still have that problem. I also notice that you're using clamp_z so I have a bunch of new question. Are you using 3d textures here?

 

Could you also specify which material you're using in this sample so I'll be able to look at its shader and see what's happening?

Posted

Hi unclebob,

I managed my trouble for solve it, I just change my code I am not using _mat.setImageTextureName but _mat.setImageTextureImage: 

void Tile::setMaterial(int quality) {
    
    if (quality) {
 
        string filepath = TILE_LOCAL_PATH(getIdEnv(), getOrigRes(), getSubdiv(), getPos(), getId());
        
        if (is_file(filepath) == 1) {
            
            Image img = new Image();
            int res = img.load(filepath);
            if (res == 1) {
                _mat.setImageTextureImage(_did,img,1);
            } else {
                ERROR("Tile::setMaterial : Can't load texture '%s'\n",img);
            }
            delete img;

            _mat.setImageTextureFlags(_did, MATERIAL_WRAP_CLAMP_X | MATERIAL_WRAP_CLAMP_Y | MATERIAL_WRAP_CLAMP_Z);
            
        }
    }
}
×
×
  • Create New...