grey00
grey00

Reputation: 479

Why does opengl only render correctly if texture sizes are powers of 2?

When I load a texture using slick-util and render it using lwjgl's opengl, it is highly distorted unless the length and width of the texture are both powers of 2. Why is this?

Upvotes: 0

Views: 191

Answers (1)

datenwolf
datenwolf

Reputation: 162164

My guess would be, that your unpack alignment is set improperly. The default alignment is 4 bytes. And power of 2 sized images usually fullfill that requirement.

Try what happens if you add a call glPixelStorei(GL_UNPACK_ALIGNMENT, 1) right before calling glTexImage or glTexSubImage.

Upvotes: 1

Related Questions