glTexImage2D Segfault related to width/height

↘锁芯ラ 提交于 2019-11-30 20:37:09

This odd number combined with an odd dimension probably produces a not-4-byte (or even 2-byte) aligned structure (and referencing outside of my exactly enough allocated buffer may be the cause of the error

This is likely the cause. Luckily you can set the alignment OpenGL uses reading pixel data. Right before calling glTexImage…(…) do

glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0);
glPixelStorei(GL_UNPACK_SKIP_ROWS, 0);

I've read this in the opengl forums:

width must be 2^m + 2(border) for some integer m.
height must be 2^n + 2(border) for some integer n. 

(source)

I found this which I believe it clarifies what's happening:

1. What should this extension be called?

  STATUS: RESOLVED

  RESOLUTION:  ARB_texture_non_power_of_two.  Conventional OpenGL
  textures are restricted to size dimensions that are powers of two.

from GL_ARB_texture_non_power_of_two

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!