diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2006-08-27 17:29:00 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2006-08-27 17:29:00 +0400 |
commit | b39f4b788dc9c5ccc9430b02852cbc1cbe56eca1 (patch) | |
tree | 7a1c91c3d4235db02b231ab5f504b31c2c0e4f15 /source/blender/src/drawmesh.c | |
parent | 84205fe0e0bfc524b8fd9ba09aedbf98b0b9457b (diff) |
Texturepaint now supports all the imagepaint brush settings, with the
exception of the clone tool.
One level undo for image- and texturepaint, only storing those tiles
that changed.
Test to improve texturepaint performance using glTexSubImage2D, only
enabled with 2^n sized textures and mipmapping off. Painting a 2048x2048
texture is then pretty smooth here, as long as the geometry is not too
complex.
Diffstat (limited to 'source/blender/src/drawmesh.c')
-rw-r--r-- | source/blender/src/drawmesh.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/source/blender/src/drawmesh.c b/source/blender/src/drawmesh.c index 2ff671d33fa..d3556f82243 100644 --- a/source/blender/src/drawmesh.c +++ b/source/blender/src/drawmesh.c @@ -430,6 +430,34 @@ int set_tpage(TFace *tface) return 1; } +void update_realtime_image(Image *ima, int x, int y, int w, int h) +{ + if (ima->repbind || fDoMipMap || !ima->bindcode || !ima->ibuf || + (!is_pow2(ima->ibuf->x) || !is_pow2(ima->ibuf->y)) || + (w == 0) || (h == 0)) { + /* these special cases require full reload still */ + free_realtime_image(ima); + } + else { + int row_length = glaGetOneInteger(GL_UNPACK_ROW_LENGTH); + int skip_pixels = glaGetOneInteger(GL_UNPACK_SKIP_PIXELS); + int skip_rows = glaGetOneInteger(GL_UNPACK_SKIP_ROWS); + + glBindTexture(GL_TEXTURE_2D, ima->bindcode); + + glPixelStorei(GL_UNPACK_ROW_LENGTH, ima->ibuf->x); + glPixelStorei(GL_UNPACK_SKIP_PIXELS, x); + glPixelStorei(GL_UNPACK_SKIP_ROWS, y); + + glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, w, h, GL_RGBA, + GL_UNSIGNED_BYTE, ima->ibuf->rect); + + glPixelStorei(GL_UNPACK_ROW_LENGTH, row_length); + glPixelStorei(GL_UNPACK_SKIP_PIXELS, skip_pixels); + glPixelStorei(GL_UNPACK_SKIP_ROWS, skip_rows); + } +} + void free_realtime_image(Image *ima) { if(ima->bindcode) { |