开发者

OpenGL applying filters to textures with slick.util textures

I am learing openGL using lwjgl. I am trying to see the effects of different filters on textures. to load the textures i am using SlickUtil.TextureLoader to load the textures and only the first 2 texture filter options work and the others result in a blank texture. if anyone knows what i am doing wrong or how to manually apply filters after a texture has been loaded please say so;

Texture[] textures = new Texture[6];
textures[0] = TextureLoader.getTexture("BMP", new FileInputStream("src/Textures/Glass.bmp"), GL_NEAREST);
textures[1] = TextureLoader.getTexture("BMP", new FileInputStream("src/Textures/Glass.bmp"), GL_LINEAR);
textures[2] = TextureLoader.getTexture("BMP", new FileInputStream("src/Textures/Glass.bmp"), GL_NEAREST_MIPMAP_NEAREST);
textures[3] = TextureLoader.getTexture("BMP", new FileInputStream("src/Textures/Glass.bmp"), GL_LINEAR_MIPMAP_NEAREST);
textures[4] = TextureLoader.getTexture("BMP", new FileInputStream("src/Textures/Glass.bmp"), GL_NEAREST_MIPMAP_LINEAR);
textures[5] = TextureLoader.getTexture("BMP", new FileInputStream("开发者_运维技巧src/Textures/Glass.bmp"), GL_LINEAR_MIPMAP_LINEAR);


The *MIPMAP* filters require a complete mipmap chain, and it's pretty obvious that the texture loader isn't creating the mipmap chain. Mipmaps can be loaded from a file, or generated by OpenGL using glGenerateMipmap().

The usual symptom of a incomplete mipmap chain and a mipmap filter, is that the texture looks completely white (or black).

For LWJGL, you can use glGenerateMipmap (GL30, OpenGL 3.0) or glGenerateMipmapEXT (GL_EXT_framebuffer_object extension).

To use it, just bind the texture with glBindTexture, and call glGenerateMipmap with the correct texture target (the same as glBindTexture).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜