11package br .nullexcept .mux .core .texel ;
22
33import br .nullexcept .mux .graphics .Color ;
4- import br .nullexcept .mux .lang .Function ;
5- import br .nullexcept .mux .lang .Function2 ;
6- import br .nullexcept .mux .view .View ;
74import org .lwjgl .BufferUtils ;
85
96import java .nio .FloatBuffer ;
10- import java .util .List ;
117
128import static br .nullexcept .mux .hardware .GLES .*;
139
@@ -56,9 +52,9 @@ public static void drawTexture(float x, float y, float width, float height, GLTe
5652 drawTexture (x , y , width , height , GLShaderList .TEXTURE , texture .getTexture ());
5753 }
5854
59- public static void drawViewLayers (float [][] vertices , int [] textures , View [] views ){
55+ public static void drawViewLayers (float [][] vertices , int [] textures , float [] alphas ){
6056 glEnable (GL_BLEND );
61- glBlendFunc ( GL_ONE , GL_ONE_MINUS_SRC_ALPHA );
57+ glBlendFuncSeparate ( GL_ONE , GL_ONE_MINUS_SRC_ALPHA , GL_ONE , GL_ONE_MINUS_SRC_ALPHA );
6258 GLProgram program = GLShaderList .VIEW ;
6359
6460 program .bind ();
@@ -68,15 +64,11 @@ public static void drawViewLayers(float[][] vertices, int[] textures, View[] vie
6864 int uTexture = program .uniform (GLProgram .UNIFORM_TEXTURE );
6965 int uAlpha = program .uniform ("alpha" );
7066 int uTime = program .uniform ("time" );
71- int uMode = program .uniform ("mode" );
72- int uSize = program .uniform ("size" );
73- int uElevation = program .uniform ("elevation" );
74- int uShadowColor = program .uniform ("shadowColor" );
7567
7668 glEnableVertexAttribArray (vPosition );
7769 glEnableVertexAttribArray (vTextureCoords );
7870
79- Function2 < Integer , Integer > draw = ( i , mode ) -> {
71+ for ( int i = 0 ; i < vertices . length ; i ++) {
8072 bufferRect .put (vertices [i ]);
8173 bufferRect .position (0 );
8274
@@ -85,27 +77,10 @@ public static void drawViewLayers(float[][] vertices, int[] textures, View[] vie
8577 glVertexAttribPointer (vTextureCoords , 2 , GL_FLOAT , false , 0 , bufferUV );
8678
8779 glUniform1i (uTexture , GL_TEXTURE_2D );
88- glUniform1i (uMode , mode );
89- glUniform1f (uElevation , views [i ].getElevation ());
90- glUniform1f (uAlpha , views [i ].getAlpha ());
91- glUniform4f (uShadowColor ,
92- Color .red (views [i ].getShadowColor ()) / 255.0f ,
93- Color .green (views [i ].getShadowColor ()) / 255.0f ,
94- Color .blue (views [i ].getShadowColor ()) / 255.0f ,
95- Color .alpha (views [i ].getShadowColor ()) / 255.0f
96- );
97-
98- glUniform2f (uSize , views [i ].getWidth (), views [i ].getHeight ());
80+ glUniform1f (uAlpha , alphas [i ]);
9981 glUniform1f (uTime , (System .currentTimeMillis () & 1000 )/1000.0f );
10082 glDrawArrays (GL_TRIANGLE_STRIP , 0 , 4 );
10183 glDisable (GL_DEPTH_TEST );
102- };
103-
104- for (int i = 0 ; i < views .length ; i ++) {
105- if (views [i ].getElevation () > 0.001f ) {
106- draw .run (i , 1 ); // Draw shadow
107- }
108- draw .run (i , 0 );
10984 }
11085
11186 program .unbind ();
0 commit comments