Sign in to follow this  
coordz

TEXTURE MIN FILTER default as NEAREST MIPMAP LINEAR - why?

Recommended Posts

coordz    130
I was debugging my app and was surprised to find all the textures I created had GL_TEXTURE MIN FILTER defaulting to GL_NEAREST MIPMAP LINEAR rather than GL_NEAREST or GL_LINEAR as I had expected. I checked the spec and this is the defined behaviour..... but why? I was having problems with textures not appearing and, as I found out, this was due to me not having specified all the mip levels as changing GL_TEXTURE MIN FILTER to GL_LINEAR fixed things. Has anyone any insight into why the spec decided to be how it is when it forces mipmapping to be used as default which involves extra complexity? Not a problem as such but it has me wondering.....

Share this post


Link to post
Share on other sites
ndhb    246
You're not the only one and will probably not be the last one :)

It is one of those common OpenGL texture pitfalls that many beginners wastes time on. I've never seen an explanation why the default filtering is not the one least likely to cause problems (i.e. GL_NEAREST). Although mipmapping is a good thing for both performance and image quality I don't think it should be default - especially not when automatic mipmap generation from the base level defaults to false.

Share this post


Link to post
Share on other sites
V-man    813
Because then people would complain why mipmapping is not working and we'd have to explain to them that the default is GL_NEAREST or GL_LINEAR.

Newcomers need to just read the documentation.

Also, why rely on default state when you don't have to.

Share this post


Link to post
Share on other sites
coordz    130
Quote:
Original post by V-manAlso, why rely on default state when you don't have to.


Because initializing *everything* is tedious. I wouldn't want to set all the hundreds of OGL state variables... would you? ;)

Share this post


Link to post
Share on other sites
V-man    813
Well, the numbers of states is much less than 100. I don't know the exact number but it is around 30.
I can understand if you are new and don't know which state would be causing problems. It even happens to experienced people, that's why we develop wrapper classes.

Share this post


Link to post
Share on other sites
Brother Bob    10344
Quote:
Original post by V-man
Well, the numbers of states is much less than 100. I don't know the exact number but it is around 30.
I can understand if you are new and don't know which state would be causing problems. It even happens to experienced people, that's why we develop wrapper classes.

If you believe the number of states are around 30, then I strongly suggest you download the latest API specification and check out the state table at the end. Starting at page 269 (in the 2.1 specification), you have 35 pages of tables with states, their initial values and how to query them, and which it sounds like you suggest we set manually. And those pages lists only what's in the core. There are more states in extensions that are not listed in those tables.

edit: That list contains implementation limits also. They aren't states, but excluding them you are still left with a lot.

Share this post


Link to post
Share on other sites
Yann L    1802
Quote:
Original post by V-man
Also, why rely on default state when you don't have to.

Why not ? Default state is well documented in the official specs, and there's no reason to not rely on it.

Now, the defaults for texture filtering are somewhat weird, but this is not a reason to manually duplicate initialization for everything.

Share this post


Link to post
Share on other sites
V-man    813
Quote:
Original post by Yann L
Now, the defaults for texture filtering are somewhat weird, but this is not a reason to manually duplicate initialization for everything.


Why not? It is better to have a wrapper class that deal with texture and it can setup explicitly all the texture states.

wrap, min filtre, mag filter, mipmap generation, anisotropy, base level, border color

Anything else?

Share this post


Link to post
Share on other sites
coordz    130
I quite like it that wrapper classes have come up because that is what I'm currently implementing :) Now I can have GL_NEAREST as default all the time :-D

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this