WebGL和两个图像大小的力量 [英] WebGL and the power of two image size
问题描述
我想使用WebGL制作一个Flickr照片流的3D画廊。看起来WebGL只允许使用尺寸为2的幂的方形图像作为纹理。我需要能够显示任何比例和尺寸的图像。我可以看到,如果我将图像数据复制到另一个最近的方形尺寸的图像中,然后使用纹理坐标使其显示正确。问题是,如果我错了,请纠正我,我不能在JavaScript中进行图像处理,并且需要运行ASP.NET,Java或类似的服务器才能在WebGL获取之前为我处理在它上面。
I want to use WebGL to make a little 3D gallery of Flickr photo streams. It looks like WebGL only allows square images that's dimensions are a power of two to be used as textures. I need to be able to display images of any proportion and dimension. I can see that if I copy the image data into another image that is the nearest square dimension and then use texture coordinates to make it display right. The problem is, and correct me if I am wrong, that I can't do that image manipulation in JavaScript and would need a server running ASP.NET, Java or something like that to do the processing for me before WebGL could get its hands on it.
有没有办法在WebGL和JavaScript中使用任意大小的图像而不需要服务器充当中间人图像处理器?
Is there a way of using arbitrarily sized images in WebGL and JavaScript without the need for a server to act as a middle man image processor?
推荐答案
我对npot纹理(FF& chrome)没有问题,只要你执行:
I have no problem with npot textures (FF & chrome) provided that you execute:
texParameteri(TEXTURE_2D, TEXTURE_MAG_FILTER, LINEAR);
texParameteri(TEXTURE_2D, TEXTURE_MIN_FILTER, LINEAR);
texParameteri(TEXTURE_2D, TEXTURE_WRAP_S, CLAMP_TO_EDGE);
texParameteri(TEXTURE_2D, TEXTURE_WRAP_T, CLAMP_TO_EDGE);
这篇关于WebGL和两个图像大小的力量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!