diff options
author | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2018-07-11 12:43:56 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2018-07-17 17:46:09 +0300 |
commit | 644fadf2f0131f8ecd73da6c994ec8a8d4b0a7d1 (patch) | |
tree | 91860a43b1d538802608a2aa7316828606e7cd99 /source/blender/draw/intern/draw_cache.c | |
parent | 7b3a18f0aa3ed9612aca602878a8ebdf2f1250f9 (diff) |
Render: add "OpenGL" render engine.
This is intended for quick renders for previsualization, animation previews
or sequencer previews. It provides the same settings as found in the 3D view
Shading popover in solid display mode, but in the scene render properties.
The "Workbench" engine was removed, and this name no longer appears in the
user interface, it's purely an internal name. We might come up with a better
name for this OpenGL engine still, but it's good to be consistent with the
OpenGL Render operator name since this has a similar purpose.
Diffstat (limited to 'source/blender/draw/intern/draw_cache.c')
-rw-r--r-- | source/blender/draw/intern/draw_cache.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/source/blender/draw/intern/draw_cache.c b/source/blender/draw/intern/draw_cache.c index 707aadbc229..d23b9e693ce 100644 --- a/source/blender/draw/intern/draw_cache.c +++ b/source/blender/draw/intern/draw_cache.c @@ -51,6 +51,7 @@ static struct DRWShapeCache { Gwn_Batch *drw_cursor; Gwn_Batch *drw_cursor_only_circle; Gwn_Batch *drw_fullscreen_quad; + Gwn_Batch *drw_fullscreen_quad_texcoord; Gwn_Batch *drw_quad; Gwn_Batch *drw_sphere; Gwn_Batch *drw_screenspace_circle; @@ -287,6 +288,35 @@ Gwn_Batch *DRW_cache_fullscreen_quad_get(void) return SHC.drw_fullscreen_quad; } +Gwn_Batch *DRW_cache_fullscreen_quad_texcoord_get(void) +{ + if (!SHC.drw_fullscreen_quad_texcoord) { + /* Use a triangle instead of a real quad */ + /* https://www.slideshare.net/DevCentralAMD/vertex-shader-tricks-bill-bilodeau - slide 14 */ + float pos[3][2] = {{-1.0f, -1.0f}, { 3.0f, -1.0f}, {-1.0f, 3.0f}}; + float texCoord[3][2] = {{ 0.0f, 0.0f}, { 2.0f, 0.0f}, { 0.0f, 2.0f}}; + + /* Position Only 2D format */ + static Gwn_VertFormat format = { 0 }; + static struct { uint pos, texCoord; } attr_id; + if (format.attr_len == 0) { + attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + attr_id.texCoord = GWN_vertformat_attr_add(&format, "texCoord", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + } + + Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); + GWN_vertbuf_data_alloc(vbo, 3); + + for (int i = 0; i < 3; ++i) { + GWN_vertbuf_attr_set(vbo, attr_id.pos, i, pos[i]); + GWN_vertbuf_attr_set(vbo, attr_id.texCoord, i, texCoord[i]); + } + + SHC.drw_fullscreen_quad_texcoord = GWN_batch_create_ex(GWN_PRIM_TRIS, vbo, NULL, GWN_BATCH_OWNS_VBO); + } + return SHC.drw_fullscreen_quad_texcoord; +} + /* Just a regular quad with 4 vertices. */ Gwn_Batch *DRW_cache_quad_get(void) { |