im trying to do the following: reduce a 1024x1024 texture (GL_TEXTURE_2D) to 1x1 (get the average value of the image).
for this i use 2 pbuffers, alternatively using one of them as texture source and the other as rendering target, reducing the resolution in each step to half of the original. the mipmapping itself is done by a small cg program that will calculate the average of 4 image pixels and write that to the color buffer (pbuffer).
after i call wglMakeCurrent(pbuffer…) the textures from my ‘main’ device context are not available (so i can render stuff to the pbuffer, but without textures). is there a way of sharing textures across device/rendering contexts?
i also have to load the cg-porgram for each pbuffer separately, which makes everything pretty slow (>1000ms, compared to SGIS_auto_mipmap_generation: 30ms), although the program itself is pretty simple. so is there a way of sharing a cg-program across device/rendering contexts?
half4 mipmap(half4 color: COLOR,
uniform sampler2D image,
uniform half scale,
uniform half halfsizeX,
uniform half halfsizeY): COLOR
//ignore pixels outside mipmap bounds
if((texcoord.x > scalehalfsizeX) || (texcoord.y > scalehalfsizeY))
//average of 4 pixels
bl = h4tex2D(image, texcoord);
br = h4tex2D(image, texcoord + scalehalf2(halfsizeX, 0));
tl = h4tex2D(image, texcoord + scalehalf2(0 ,halfsizeY));
tr = h4tex2D(image, texcoord + scale*half2(halfsizeX,halfsizeY));
return ((bl+br+tl+tr)/4); }