Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Widgets|UI|libappfw: Draw GUI widgets with fewer draw calls
Most GUI widgets now get batched when drawing. Added a special-purpose “batch.guiwidget” shader for drawing GUI widgets.
- Loading branch information
Showing
46 changed files
with
928 additions
and
239 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
doomsday/apps/client/net.dengine.client.pack/renderer.pack/shaders/batch.dei
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
batch { | ||
# Shader for UI widgets. | ||
shader guiwidget { | ||
vertex = " | ||
uniform highp mat4 uMvpMatrix; | ||
uniform highp vec4 uColor[DENG_MAX_BATCH_UNIFORMS]; | ||
uniform highp float uSaturation[DENG_MAX_BATCH_UNIFORMS]; | ||
uniform highp vec4 uScissorRect[DENG_MAX_BATCH_UNIFORMS]; | ||
|
||
attribute highp vec4 aVertex; | ||
attribute highp vec2 aUV; | ||
attribute highp vec4 aColor; | ||
attribute highp float aIndex; // uColor | ||
|
||
varying highp vec2 vUV; | ||
varying highp vec4 vColor; | ||
varying highp vec4 vScissor; | ||
varying highp float vSaturation; | ||
|
||
void main(void) { | ||
gl_Position = uMvpMatrix * aVertex; | ||
vUV = aUV; | ||
|
||
int index = int(aIndex); | ||
vColor = aColor * uColor[index]; | ||
vScissor = uScissorRect[index]; | ||
vSaturation = uSaturation[index]; | ||
}" | ||
include.fragment <include/hsv.glsl> | ||
fragment = " | ||
uniform sampler2D uTex; | ||
|
||
varying highp vec2 vUV; | ||
varying highp vec4 vColor; | ||
varying highp vec4 vScissor; | ||
varying highp float vSaturation; | ||
|
||
void main(void) { | ||
// Check the scissor first. | ||
if (gl_FragCoord.x < vScissor.x || gl_FragCoord.x > vScissor.z || | ||
gl_FragCoord.y < vScissor.y || gl_FragCoord.y > vScissor.w) { | ||
discard; | ||
} | ||
gl_FragColor = texture2D(uTex, vUV); | ||
|
||
// Optionally adjust color saturation. | ||
if (vSaturation < 1.0) { | ||
highp vec4 hsv = rgbToHsv(gl_FragColor); | ||
hsv.y *= vSaturation; | ||
gl_FragColor = hsvToRgb(hsv); | ||
} | ||
|
||
// Final vertex color. | ||
gl_FragColor *= vColor; | ||
}" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
#include "framework/painter.h" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.