Merge pull request #36 from dougbinks/master
Reset pixel storage settings after load texture.
This commit is contained in:
commit
2d11c2ee8a
@ -447,6 +447,8 @@ static int glnvg__renderCreateTexture(void* uptr, int type, int w, int h, const
|
||||
{
|
||||
struct GLNVGcontext* gl = (struct GLNVGcontext*)uptr;
|
||||
struct GLNVGtexture* tex = glnvg__allocTexture(gl);
|
||||
int align,length,pixels,rows;
|
||||
|
||||
if (tex == NULL) return 0;
|
||||
glGenTextures(1, &tex->tex);
|
||||
tex->width = w;
|
||||
@ -454,6 +456,11 @@ static int glnvg__renderCreateTexture(void* uptr, int type, int w, int h, const
|
||||
tex->type = type;
|
||||
glBindTexture(GL_TEXTURE_2D, tex->tex);
|
||||
|
||||
glGetIntegerv(GL_UNPACK_ALIGNMENT,&align);
|
||||
glGetIntegerv(GL_UNPACK_ROW_LENGTH,&length);
|
||||
glGetIntegerv(GL_UNPACK_SKIP_PIXELS,&pixels);
|
||||
glGetIntegerv(GL_UNPACK_SKIP_ROWS,&rows);
|
||||
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT,1);
|
||||
glPixelStorei(GL_UNPACK_ROW_LENGTH, tex->width);
|
||||
glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0);
|
||||
@ -471,12 +478,18 @@ static int glnvg__renderCreateTexture(void* uptr, int type, int w, int h, const
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT,align);
|
||||
glPixelStorei(GL_UNPACK_ROW_LENGTH,length);
|
||||
glPixelStorei(GL_UNPACK_SKIP_PIXELS,pixels);
|
||||
glPixelStorei(GL_UNPACK_SKIP_ROWS,rows);
|
||||
|
||||
if (glnvg__checkError("create tex"))
|
||||
return 0;
|
||||
|
||||
return tex->id;
|
||||
}
|
||||
|
||||
|
||||
static int glnvg__renderDeleteTexture(void* uptr, int image)
|
||||
{
|
||||
struct GLNVGcontext* gl = (struct GLNVGcontext*)uptr;
|
||||
@ -487,10 +500,16 @@ static int glnvg__renderUpdateTexture(void* uptr, int image, int x, int y, int w
|
||||
{
|
||||
struct GLNVGcontext* gl = (struct GLNVGcontext*)uptr;
|
||||
struct GLNVGtexture* tex = glnvg__findTexture(gl, image);
|
||||
int align,length,pixels,rows;
|
||||
|
||||
if (tex == NULL) return 0;
|
||||
glBindTexture(GL_TEXTURE_2D, tex->tex);
|
||||
|
||||
glGetIntegerv(GL_UNPACK_ALIGNMENT,&align);
|
||||
glGetIntegerv(GL_UNPACK_ROW_LENGTH,&length);
|
||||
glGetIntegerv(GL_UNPACK_SKIP_PIXELS,&pixels);
|
||||
glGetIntegerv(GL_UNPACK_SKIP_ROWS,&rows);
|
||||
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT,1);
|
||||
glPixelStorei(GL_UNPACK_ROW_LENGTH, tex->width);
|
||||
glPixelStorei(GL_UNPACK_SKIP_PIXELS, x);
|
||||
@ -501,6 +520,11 @@ static int glnvg__renderUpdateTexture(void* uptr, int image, int x, int y, int w
|
||||
else
|
||||
glTexSubImage2D(GL_TEXTURE_2D, 0, x,y, w,h, GL_RED, GL_UNSIGNED_BYTE, data);
|
||||
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT,align);
|
||||
glPixelStorei(GL_UNPACK_ROW_LENGTH,length);
|
||||
glPixelStorei(GL_UNPACK_SKIP_PIXELS,pixels);
|
||||
glPixelStorei(GL_UNPACK_SKIP_ROWS,rows);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user