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 ;
47import org .lwjgl .BufferUtils ;
58
69import java .nio .FloatBuffer ;
10+ import java .util .List ;
711
812import static br .nullexcept .mux .hardware .GLES .*;
913
@@ -52,9 +56,9 @@ public static void drawTexture(float x, float y, float width, float height, GLTe
5256 drawTexture (x , y , width , height , GLShaderList .TEXTURE , texture .getTexture ());
5357 }
5458
55- public static void drawViewLayers (float [][] vertices , int [] textures , float [] alphas ){
59+ public static void drawViewLayers (float [][] vertices , int [] textures , View [] views ){
5660 glEnable (GL_BLEND );
57- glBlendFuncSeparate ( GL_ONE , GL_ONE_MINUS_SRC_ALPHA , GL_ONE , GL_ONE_MINUS_SRC_ALPHA );
61+ glBlendFunc ( GL_ONE , GL_ONE_MINUS_SRC_ALPHA );
5862 GLProgram program = GLShaderList .VIEW ;
5963
6064 program .bind ();
@@ -64,11 +68,15 @@ public static void drawViewLayers(float[][] vertices, int[] textures, float[] al
6468 int uTexture = program .uniform (GLProgram .UNIFORM_TEXTURE );
6569 int uAlpha = program .uniform ("alpha" );
6670 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" );
6775
6876 glEnableVertexAttribArray (vPosition );
6977 glEnableVertexAttribArray (vTextureCoords );
7078
71- for ( int i = 0 ; i < vertices . length ; i ++) {
79+ Function2 < Integer , Integer > draw = ( i , mode ) -> {
7280 bufferRect .put (vertices [i ]);
7381 bufferRect .position (0 );
7482
@@ -77,10 +85,27 @@ public static void drawViewLayers(float[][] vertices, int[] textures, float[] al
7785 glVertexAttribPointer (vTextureCoords , 2 , GL_FLOAT , false , 0 , bufferUV );
7886
7987 glUniform1i (uTexture , GL_TEXTURE_2D );
80- glUniform1f (uAlpha , alphas [i ]);
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 ());
8199 glUniform1f (uTime , (System .currentTimeMillis () & 1000 )/1000.0f );
82100 glDrawArrays (GL_TRIANGLE_STRIP , 0 , 4 );
83101 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 );
84109 }
85110
86111 program .unbind ();
0 commit comments