Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable mipmaps in OpenGL

Tags:

mipmaps

opengl

I am making 2D sprite engine in OpenGL and I want to disable mipmaps, as I do not need them.

When I call:

glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, internal->internal_w, internal->internal_h, 0, GL_RGBA, GL_UNSIGNED_BYTE, internal->data);
RenderWithThisTexture();

I got white rect, but when I call:

gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGBA, internal->internal_w, internal->internal_h, GL_RGBA, GL_UNSIGNED_BYTE, internal->data);
RenderWithThisTexture();

I got the properly textured rect

I figured out that this may be because of enabled mipmaps, but sadly I can't find any info how I can disable them.

I want to stick with OpenGL 1.1 (not OGL 2.0 or above code)

like image 253
PiotrK Avatar asked Nov 09 '11 11:11

PiotrK


People also ask

Does mipmapping improve performance?

Increased performance – Mipmapping increases cache efficiency as full-size textures will not be needed as often, and the lower resolution mipmaps will fit more easily in the texture cache. This means texture data doesn't have to be fetched as often, reducing bandwidth usage and increasing application performance.

Does Minecraft use Mipmaps?

Mipmaps are pre-calculated groups of images that make up a main texture, intended to increase rendering speed and animation performance. They are used in the iOS version of Minecraft, as of Update 0.8.

What does generate Mipmaps do?

Mipmaps. Mipmaps are lists of progressively smaller versions of an image, used to optimise performance on real-time 3D engines. Objects that are far away from the Camera use smaller Texture versions.

Is higher mipmap better?

A high-resolution mipmap image is used for objects that are close to the user. Lower-resolution images are used as the object appears farther away. Mipmapping improves the quality of rendered textures at the expense of using more memory.


1 Answers

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);

This should be the default. Make sure you are not changing it to MIPMAP somewhere.

like image 180
Piotr Praszmo Avatar answered Oct 14 '22 19:10

Piotr Praszmo