another question - I setup my texture like this ( I load it from a RAW file into a PNMImage and the make a texture with it).
PT(Texture) make_tex(BYTE *pBuf, int texSize, bool bWrap, int nChan)
{
PNMImage* pImage = new PNMImage(texSize, texSize, nChan);
for (int y = 0; y < texSize; ++y)
{
for (int x = 0; x < texSize; ++x)
{
int index = (y * (texSize * nChan)) + (x * nChan);
if(nChan == 1)
{
pImage->set_xel_val(x, y, pBuf[index]);
}
if(nChan > 1)
{
pImage->set_red_val(x, y, pBuf[index + 0]);
pImage->set_green_val(x, y, pBuf[index + 1]);
pImage->set_blue_val(x, y, pBuf[index + 2]);
if(nChan == 4)
{
pImage->set_alpha_val(x, y, pBuf[index + 3]);
}
}
}
}
PT(Texture) newTex = new Texture();
newTex->load(*pImage);
newTex->set_magfilter(Texture::FT_linear);
newTex->set_minfilter(Texture::FT_linear_mipmap_linear);
newTex->set_wrap_u(bWrap ? Texture::WM_repeat : Texture::WM_clamp);
newTex->set_wrap_v(bWrap ? Texture::WM_repeat : Texture::WM_clamp);
newTex->set_wrap_w(bWrap ? Texture::WM_repeat : Texture::WM_clamp);
delete pImage;
pImage = NULL;
return newTex;
}
but it reports only 1 mipmap has been generated.
the corrisponding OpenGL code generates several mipmap levels itself like this
glGenTextures(1, &WaterReflDMID[l]);
glBindTexture(GL_TEXTURE_2D, WaterReflDMID[l]);
// if (GL.SGIS_generate_mipmap) glTexParameteri(GL_TEXTURE_2D,GL_GENERATE_MIPMAP_SGIS, GL_TRUE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
// do some calculations here for pBuf2...
//....
//....
// Load 2x downscaled - save memory 4x times
if (k > 0)
{
glTexImage2D(GL_TEXTURE_2D, k-1, GL_RGBA_FLOAT32_ATI, SZ, SZ, 0, GL_RGBA, GL_FLOAT, pBuf2);
}
the last part here is the key -
glTexImage2D(GL_TEXTURE_2D, k-1, GL_RGBA_FLOAT32_ATI, SZ, SZ, 0, GL_RGBA, GL_FLOAT, pBuf2);
I suspect this is the reason why I get those weird artefacts (squares) on my water.
Can I force Panda somehow to allow me do the same thing ?
This part is (as far as I can tell) the only thing that is different from my code and the OpenGL code I am trying to port into Panda.