diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2018-04-08 17:59:39 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2018-04-08 19:31:50 +0300 |
commit | 0b06e73258a00d5a44d48fa9d7ac6637a0ee8641 (patch) | |
tree | 22b8634ee6952f47bcd842f564d250bcb3e5ed86 /source | |
parent | 17aad5ad97472a745fd17dc0ff8ab304d2fa15d3 (diff) |
UI: Perf: Use GWN_draw_primitive for drawing triple buffers texture.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/windowmanager/intern/wm_draw.c | 33 |
1 files changed, 11 insertions, 22 deletions
diff --git a/source/blender/windowmanager/intern/wm_draw.c b/source/blender/windowmanager/intern/wm_draw.c index cfd3291293c..ed276aa690d 100644 --- a/source/blender/windowmanager/intern/wm_draw.c +++ b/source/blender/windowmanager/intern/wm_draw.c @@ -474,35 +474,24 @@ void wm_triple_draw_textures(wmWindow *win, wmDrawTriple *triple, float alpha) const float halfx = GLA_PIXEL_OFS / sizex; const float halfy = GLA_PIXEL_OFS / sizey; - Gwn_VertFormat *format = immVertexFormat(); - unsigned int texcoord = GWN_vertformat_attr_add(format, "texCoord", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - const int activeTex = 7; /* arbitrary */ glActiveTexture(GL_TEXTURE0 + activeTex); glBindTexture(GL_TEXTURE_2D, triple->bind); - immBindBuiltinProgram(GPU_SHADER_2D_IMAGE_ALPHA); - - immUniform1f("alpha", alpha); - immUniform1i("image", activeTex); - - immBegin(GWN_PRIM_TRI_FAN, 4); - - immAttrib2f(texcoord, halfx, halfy); - immVertex2f(pos, 0.0f, 0.0f); - - immAttrib2f(texcoord, ratiox + halfx, halfy); - immVertex2f(pos, sizex, 0.0f); + float x1 = halfx; + float x2 = ratiox + halfx; + float y1 = halfy; + float y2 = ratioy + halfy; - immAttrib2f(texcoord, ratiox + halfx, ratioy + halfy); - immVertex2f(pos, sizex, sizey); + GPUShader *shader = GPU_shader_get_builtin_shader(GPU_SHADER_2D_IMAGE_RECT_COLOR); + GPU_shader_bind(shader); - immAttrib2f(texcoord, halfx, ratioy + halfy); - immVertex2f(pos, 0.0f, sizey); + glUniform1i(GPU_shader_get_uniform(shader, "image"), activeTex); + glUniform4f(GPU_shader_get_uniform(shader, "rect_icon"), x1, y1, x2, y2); + glUniform4f(GPU_shader_get_uniform(shader, "rect_geom"), 0.0f, 0.0f, sizex, sizey); + glUniform4f(GPU_shader_get_builtin_uniform(shader, GWN_UNIFORM_COLOR), alpha, alpha, alpha, alpha); - immEnd(); - immUnbindProgram(); + GWN_draw_primitive(GWN_PRIM_TRI_STRIP, 4); glBindTexture(GL_TEXTURE_2D, 0); } |