Results 1 to 5 of 5

Thread: Texture Filters Issue

  1. #1
    Junior Member Newbie
    Join Date
    Apr 2015
    Posts
    5

    Texture Filters Issue

    Hi folks,

    Making an Android app. Whenever I set GL10.GL_TEXTURE_MIN_FILTER to GL_LINEAR_MIPMAP_NEAREST and GL_TEXTURE_MAG_FILTER to GL_LINEAR my textures disappear and only a white cube is generated in it's place. Same if I don't set them and use the default values. But if both are either GL_LINEAR or GL_NEAREST (or a combination of the two) it works fine.

    This is my code...any advice? Below works, but not if I change GL10.GL_TEXTURE_MIN_FILTER to GL_LINEAR_MIPMAP_NEAREST. (Note: I tried both methods shown below of loading the bitmap with the same results)

    Code :
        public void loadTexture(GL10 gl, Context context) {
            gl.glGenTextures(1, textureIDs, 0); 
     
     //     final BitmapFactory.Options options = new BitmapFactory.Options();
     //     options.inScaled = false;          
     //     final Bitmap bitmap = BitmapFactory.decodeResource(context.getResources(), R.drawable.myTexture, options);
     
            InputStream is = context.getResources().openRawResource(R.drawable.myTexture);
            Bitmap bitmap;
            try {
                bitmap = BitmapFactory.decodeStream(is);
            } finally {
                try {
                    is.close();
                } catch(IOException e) {
                }
            }
     
            gl.glBindTexture(GL10.GL_TEXTURE_2D, textureIDs[0]);   
     
            gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER, GL10.GL_LINEAR);
            gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MAG_FILTER, GL10.GL_LINEAR);
     
     
            GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, bitmap, 0);
     
     
            bitmap.recycle();
        }

  2. #2
    Senior Member OpenGL Lord
    Join Date
    Mar 2015
    Posts
    6,675
    GL_LINEAR_MIPMAP_NEAREST is only appropriate for a texture if it has mipmaps. If it doesn't have mipmaps, you shouldn't use mipmap filtering, and your texture doesn't use mipmaps.

  3. #3
    Junior Member Newbie
    Join Date
    Apr 2015
    Posts
    5
    Ahh...Ok. Thank you! I haven't touched openGl in 10+ years (since school) so I have to go back and remind myself of few topics...including mipmaps apparently

    I've read the difference of Linear vs Nearest, but I'm trying to understand the affects better. Is one less pixelated but better performance?

  4. #4
    Senior Member OpenGL Lord
    Join Date
    Mar 2015
    Posts
    6,675
    Quote Originally Posted by MSmith View Post
    I've read the difference of Linear vs Nearest, but I'm trying to understand the affects better. Is one less pixelated but better performance?
    You should not use NEAREST because you think it will help in performance. Most, if not all, rendering hardware is designed around LINEAR filtering, so using NEAREST will generally buy you nothing. You should use NEAREST because you want what it provides in terms of texture sampling (ie: exact texel values with no blending between neighboring texels).

  5. #5
    Senior Member Regular Contributor
    Join Date
    Mar 2015
    Posts
    296
    Quote Originally Posted by Alfonse Reinheart View Post
    You should not use NEAREST because you think it will help in performance. Most, if not all, rendering hardware is designed around LINEAR filtering, so using NEAREST will generally buy you nothing. You should use NEAREST because you want what it provides in terms of texture sampling (ie: exact texel values with no blending between neighboring texels).
    it's not you should not or should. that depends on the goal you will precess. different algorithm results in different effect. texture mapping is a complex work, need differnt ways to do. then you can get a perfect effect.

Similar Threads

  1. confused about texture filters
    By hazelwood in forum OpenGL: Basic Coding
    Replies: 5
    Last Post: 12-08-2005, 09:08 PM
  2. Own texture Filters
    By Ahvolon[ F-Bytes ] in forum OpenGL: Advanced Coding
    Replies: 3
    Last Post: 12-24-2003, 04:55 AM
  3. filters
    By blender in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 09-01-2002, 06:57 AM
  4. OGL2.0 : programmable texture filters
    By Olive in forum OpenGL: General
    Replies: 23
    Last Post: 03-11-2002, 10:17 AM
  5. Texture filters
    By KRONOS in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 08-01-2000, 02:41 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean