From 1b7163e79c6f3b9bb77cf87ed2f4963fc2dbe661 Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Sun, 4 Nov 2012 19:04:59 +0100 Subject: [PATCH] [DEV] new button shader system ==> must be reworked --- share/theme/default/widgetButton.frag | 53 +++++++++++++++++++++++++++ share/theme/default/widgetButton.prog | 2 + share/theme/default/widgetButton.vert | 17 +++++++++ 3 files changed, 72 insertions(+) create mode 100644 share/theme/default/widgetButton.frag create mode 100644 share/theme/default/widgetButton.prog create mode 100644 share/theme/default/widgetButton.vert diff --git a/share/theme/default/widgetButton.frag b/share/theme/default/widgetButton.frag new file mode 100644 index 00000000..19ccd797 --- /dev/null +++ b/share/theme/default/widgetButton.frag @@ -0,0 +1,53 @@ +#ifdef GL_ES +precision mediump float; +precision mediump int; +#endif + +uniform float EW_sizeBorder; +uniform float EW_sizePadding; +uniform vec2 EW_size; +uniform vec4 EW_posText; +uniform int EW_state; +/* +struct displayProperty { + vec4 colorBackGround; + vec4 colorForeGround; + vec4 colorBorder; + float sizeBorder; + vec2 sizePaddingOut; + vec2 sizePaddingIn; + +}; +uniform displayProperty EW_buttonProperty; +*/ +// transmit from the vertex shader +varying vec2 v_position; // interpolated position ... +// internal static define +vec4 S_colorBg = vec4(0.0); +vec4 S_colorFg = vec4(0.5,0.5,0.5,0.8); +vec4 S_colorBorder = vec4(0.0,0.0,0.0,1.0); + + +void main(void) { + float specialBorder = EW_sizeBorder+EW_sizePadding; + vec2 endStart = EW_size - vec2(EW_sizePadding) - vec2(EW_sizeBorder); + vec2 endStop = EW_size - vec2(EW_sizePadding); + if( v_position.x> EW_sizePadding + && v_position.y> EW_sizePadding + && v_position.x<= endStop.x + && v_position.y<= endStop.y + ) { + if( v_position.x<= specialBorder + || v_position.y<= specialBorder + || v_position.x> endStart.x + || v_position.y> endStart.y + ) { + gl_FragColor = S_colorBorder; + } else { + gl_FragColor = S_colorFg; + } + } else { + gl_FragColor = S_colorBg; + } +} + diff --git a/share/theme/default/widgetButton.prog b/share/theme/default/widgetButton.prog new file mode 100644 index 00000000..a6c7b7f8 --- /dev/null +++ b/share/theme/default/widgetButton.prog @@ -0,0 +1,2 @@ +widgetButton.vert +widgetButton.frag \ No newline at end of file diff --git a/share/theme/default/widgetButton.vert b/share/theme/default/widgetButton.vert new file mode 100644 index 00000000..1b0652d7 --- /dev/null +++ b/share/theme/default/widgetButton.vert @@ -0,0 +1,17 @@ +#ifdef GL_ES +precision mediump float; +precision mediump int; +#endif + +// Input : +attribute vec2 EW_coord2d; +uniform mat4 EW_MatrixTransformation; + +// output : +varying vec2 v_position; // This will be passed into the fragment shader. + +void main(void) { + gl_Position = EW_MatrixTransformation * vec4(EW_coord2d, 0.0, 1.0); + // transmit position of the curent element (intermolated ...) + v_position = EW_coord2d; +}