@@ -30,6 +30,8 @@ use crate::{
3030} ;
3131use azul_css:: { AzString , StringVec , U8Vec , ColorU , ColorF } ;
3232
33+ pub const GL_RESTART_INDEX : u32 = core:: u32:: MAX ;
34+
3335/// Passing *const c_void is not easily possible when generating APIs,
3436/// so this wrapper struct is for easier API generation
3537#[ repr( C ) ]
@@ -665,33 +667,29 @@ static SVG_VERTEX_SHADER: &[u8] = b"#version 150
665667 #define attribute in
666668#endif
667669
668- precision mediump float;
669-
670670uniform vec2 vBboxSize;
671- uniform mat4 vTransformMatrix;
672671
673- in vec2 vAttrXY;
674- out vec4 vPosition;
672+ attribute vec2 vAttrXY;
675673
676674void main() {
677- vPosition = vec4(vAttrXY / vBboxSize - vec2(1.0), 1.0, 1.0) * vTransformMatrix;
675+ gl_Position = vec4(vAttrXY / vBboxSize - vec2(1.0), 1.0, 1.0);
676+ gl_PointSize = 1.0;
678677}" ;
679678
680679static SVG_FRAGMENT_SHADER : & [ u8 ] = b"#version 150
681680
682- #if __VERSION__ != 100
683- #define varying in
684- #endif
685-
686- precision mediump float;
681+ precision highp float;
687682
688683uniform vec4 fDrawColor;
689684
690- in vec4 vPosition;
691- out vec4 fOutColor;
685+ #if __VERSION__ == 100
686+ #define oFragColor gl_FragColor
687+ #else
688+ out vec4 oFragColor;
689+ #endif
692690
693691void main() {
694- fOutColor = fDrawColor;
692+ oFragColor = fDrawColor;
695693}" ;
696694
697695impl GlContextPtr {
@@ -1894,6 +1892,8 @@ impl GlShader {
18941892 let mut current_framebuffers = [ 0_i32 ] ;
18951893 let mut current_renderbuffers = [ 0_i32 ] ;
18961894 let mut current_texture_2d = [ 0_i32 ] ;
1895+ let mut current_blend_enabled = [ 0_u8 ] ;
1896+ let mut current_primitive_restart_fixed_index_enabled = [ 0_u8 ] ;
18971897
18981898 gl_context. get_boolean_v ( gl:: MULTISAMPLE , ( & mut current_multisample[ ..] ) . into ( ) ) ;
18991899 gl_context. get_integer_v ( gl:: ARRAY_BUFFER_BINDING , ( & mut current_vertex_buffer[ ..] ) . into ( ) ) ;
@@ -1903,6 +1903,8 @@ impl GlShader {
19031903 gl_context. get_integer_v ( gl:: RENDERBUFFER , ( & mut current_renderbuffers[ ..] ) . into ( ) ) ;
19041904 gl_context. get_integer_v ( gl:: FRAMEBUFFER , ( & mut current_framebuffers[ ..] ) . into ( ) ) ;
19051905 gl_context. get_integer_v ( gl:: TEXTURE_2D , ( & mut current_texture_2d[ ..] ) . into ( ) ) ;
1906+ gl_context. get_boolean_v ( gl:: BLEND , ( & mut current_blend_enabled[ ..] ) . into ( ) ) ;
1907+ gl_context. get_boolean_v ( gl:: PRIMITIVE_RESTART_FIXED_INDEX , ( & mut current_primitive_restart_fixed_index_enabled[ ..] ) . into ( ) ) ;
19061908
19071909 // 1. Create the framebuffer
19081910 let framebuffers = gl_context. gen_framebuffers ( 1 ) ;
@@ -1952,8 +1954,11 @@ impl GlShader {
19521954 }
19531955
19541956 gl_context. viewport ( 0 , 0 , texture_size. width as i32 , texture_size. height as i32 ) ;
1955- gl_context. use_program ( shader_program_id) ;
1957+ gl_context. enable ( gl:: BLEND ) ;
1958+ gl_context. enable ( gl:: PRIMITIVE_RESTART_FIXED_INDEX ) ;
19561959 gl_context. disable ( gl:: MULTISAMPLE ) ;
1960+ gl_context. blend_func ( gl:: SRC_ALPHA , gl:: ONE_MINUS_SRC_ALPHA ) ; // TODO: enable / disable
1961+ gl_context. use_program ( shader_program_id) ;
19571962
19581963 // Avoid multiple calls to get_uniform_location by caching the uniform locations
19591964 let mut uniform_locations: BTreeMap < AzString , i32 > = BTreeMap :: new ( ) ;
@@ -1998,6 +2003,12 @@ impl GlShader {
19982003 if u32:: from ( current_multisample[ 0 ] ) == gl:: TRUE {
19992004 gl_context. enable ( gl:: MULTISAMPLE ) ;
20002005 }
2006+ if u32:: from ( current_blend_enabled[ 0 ] ) == gl:: FALSE {
2007+ gl_context. disable ( gl:: BLEND ) ;
2008+ }
2009+ if u32:: from ( current_primitive_restart_fixed_index_enabled[ 0 ] ) == gl:: FALSE {
2010+ gl_context. disable ( gl:: PRIMITIVE_RESTART_FIXED_INDEX ) ;
2011+ }
20012012 gl_context. bind_framebuffer ( gl:: FRAMEBUFFER , current_framebuffers[ 0 ] as u32 ) ;
20022013 gl_context. bind_texture ( gl:: TEXTURE_2D , current_texture_2d[ 0 ] as u32 ) ;
20032014 gl_context. bind_buffer ( gl:: RENDERBUFFER , current_renderbuffers[ 0 ] as u32 ) ;
0 commit comments