[DEV] new button shader system ==> must be reworked
This commit is contained in:
parent
b0b619da82
commit
1b7163e79c
53
share/theme/default/widgetButton.frag
Normal file
53
share/theme/default/widgetButton.frag
Normal file
@ -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;
|
||||
}
|
||||
}
|
||||
|
2
share/theme/default/widgetButton.prog
Normal file
2
share/theme/default/widgetButton.prog
Normal file
@ -0,0 +1,2 @@
|
||||
widgetButton.vert
|
||||
widgetButton.frag
|
17
share/theme/default/widgetButton.vert
Normal file
17
share/theme/default/widgetButton.vert
Normal file
@ -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;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user