gl: add stride parameter to texture upload
Allow to specify the stride when uploading data into a texture. Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
This commit is contained in:
parent
f091b2b763
commit
728f4a1b18
@ -133,7 +133,7 @@ static int kmscon_glyph_new(struct kmscon_glyph **out, kmscon_symbol_t key,
|
||||
}
|
||||
}
|
||||
|
||||
gl_tex_load(glyph->tex, bmap->width, bmap->rows, data);
|
||||
gl_tex_load(glyph->tex, bmap->width, 0, bmap->rows, data);
|
||||
free(data);
|
||||
|
||||
glyph->width = bmap->width;
|
||||
|
2
src/gl.h
2
src/gl.h
@ -73,7 +73,7 @@ float *gl_m4_stack_tip(struct gl_m4_stack *stack);
|
||||
|
||||
unsigned int gl_tex_new();
|
||||
void gl_tex_free(unsigned int tex);
|
||||
void gl_tex_load(unsigned int tex, unsigned int width,
|
||||
void gl_tex_load(unsigned int tex, unsigned int width, unsigned int stride,
|
||||
unsigned int height, void *buf);
|
||||
|
||||
/*
|
||||
|
@ -98,7 +98,7 @@ void gl_tex_free(unsigned int tex)
|
||||
glDeleteTextures(1, &tex);
|
||||
}
|
||||
|
||||
void gl_tex_load(unsigned int tex, unsigned int width,
|
||||
void gl_tex_load(unsigned int tex, unsigned int width, unsigned int stride,
|
||||
unsigned int height, void *buf)
|
||||
{
|
||||
if (!buf || !width || !height)
|
||||
@ -110,8 +110,10 @@ void gl_tex_load(unsigned int tex, unsigned int width,
|
||||
*/
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, tex);
|
||||
glPixelStorei(GL_UNPACK_ROW_LENGTH, stride);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_BGRA_EXT, width, height, 0,
|
||||
GL_BGRA_EXT, GL_UNSIGNED_BYTE, buf);
|
||||
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
|
||||
}
|
||||
|
||||
struct gl_shader {
|
||||
|
Loading…
x
Reference in New Issue
Block a user