OpenGL code optimization
Using gluBuild2DMipmaps and an appropriate minification filter can help too, and still let you have the full-size texture when viewed close-up.
- Alex Diener
- Alex Diener
That didnt seems to work before, im probably doing it wrong but can you do it with textures that have alpha channels?
Sir, e^iπ + 1 = 0, hence God exists; reply!
You can, but you should know about texture halos and premultiplication first. A skim through this thread should explain it: http://www.idevgames.com/forum/showthread.php?t=7560
When you tried it before, what parameter did you use for GL_TEXTURE_MIN_FILTER?
- Alex Diener
When you tried it before, what parameter did you use for GL_TEXTURE_MIN_FILTER?
- Alex Diener
GL_LINEAR for MIN and MAX
Halos arent a problem but premultiplication sounds like a good idea, will that speed things up at all.
(does it count as premultiplying if Im loading pngs with alpha channels?)
Halos arent a problem but premultiplication sounds like a good idea, will that speed things up at all.
(does it count as premultiplying if Im loading pngs with alpha channels?)
Sir, e^iπ + 1 = 0, hence God exists; reply!
Premultiplication won't make a difference in speed. It's mostly just useful for eliminating halos. When you load a PNG, unless it's already premultiplied or you do it yourself, it won't be. If you were using premultiplied alpha, you'd want to set your blend func to GL_ONE, GL_ONE_MINUS_SRC_ALPHA.
When you use GL_LINEAR as your minification filter, it'll take the full-size texture and scale it, ignoring any mipmaps that are available. To get it to use mipmaps, you'll want to use one of GL_LINEAR_MIPMAP_NEAREST, GL_LINEAR_MIPMAP_LINEAR, GL_NEAREST_MIPMAP_LINEAR, or GL_NEAREST_MIPMAP_NEAREST. I find that GL_LINEAR_MIPMAP_NEAREST generally gives me the best quality | speed ratio, but you may want GL_LINEAR_MIPMAP_LINEAR for the nicest possible results. Any one of those, however, is likely to be significantly faster than GL_LINEAR.
- Alex Diener
When you use GL_LINEAR as your minification filter, it'll take the full-size texture and scale it, ignoring any mipmaps that are available. To get it to use mipmaps, you'll want to use one of GL_LINEAR_MIPMAP_NEAREST, GL_LINEAR_MIPMAP_LINEAR, GL_NEAREST_MIPMAP_LINEAR, or GL_NEAREST_MIPMAP_NEAREST. I find that GL_LINEAR_MIPMAP_NEAREST generally gives me the best quality | speed ratio, but you may want GL_LINEAR_MIPMAP_LINEAR for the nicest possible results. Any one of those, however, is likely to be significantly faster than GL_LINEAR.
- Alex Diener
Ahhh, i see thats very clever.
Im confused about Nearest though, I dont want to use a 128x128 texture for a 150x150 quad when I could use the 256x256 texture.
What I mean is I want to always use a texture of a higher resolution than the quads, how could I do that?
Im confused about Nearest though, I dont want to use a 128x128 texture for a 150x150 quad when I could use the 256x256 texture.
What I mean is I want to always use a texture of a higher resolution than the quads, how could I do that?
Sir, e^iπ + 1 = 0, hence God exists; reply!
I'm not entirely sure how MIPMAP_NEAREST works myself, but looking at the man page for glTexParameter, it seems that would indeed be the behavior it would give you. It doesn't look like there's a way to have it always use the next largest mipmap level, but GL_LINEAR_MIPMAP_LINEAR should work OK for you. Give it a try and see if it gives you the intended effect.
- Alex Diener
- Alex Diener
You can bias the LOD parameter to force a larger/smaller mipmap level to be chosen, with the EXT_texture_lod_bias extension.
Ill look that up, thanks
Sir, e^iπ + 1 = 0, hence God exists; reply!
Possibly Related Threads...
| Thread: | Author | Replies: | Views: | Last Post | |
| Simple ray-face intersect optimization | NYGhost | 8 | 4,649 |
Aug 17, 2007 12:01 PM Last Post: NYGhost |
|
| NEED HELP! OpenGL code for my exam doesn't work | mr02077 | 2 | 2,402 |
Feb 9, 2007 05:44 PM Last Post: stevejohnson |
|
| SDL/OpenGL Initialization Code | Nick | 15 | 6,558 |
Sep 7, 2005 07:28 AM Last Post: Nick |
|
| OpenGL Source Code Generator | Leisure Suit Lurie | 2 | 3,262 |
Jul 5, 2005 11:55 AM Last Post: Cochrane |
|
| bus error with opengl code | mnorton | 2 | 3,216 |
Jan 21, 2005 02:53 PM Last Post: ThemsAllTook |
|

