|  | @@ -29,6 +29,33 @@
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  #define HF 0.5
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +#ifdef LA_USE_GLES
 | 
	
		
			
				|  |  | +void la_glUniform1f(int location, float v0){
 | 
	
		
			
				|  |  | +    glUniform1fv(location,1,&v0);
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  | +#endif
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +void tnsGet2DTextureSubImage(tnsTexture* t, int xoffset, int yoffset, uint32_t width, uint32_t height, int format, int type, size_t bufSize, void *pixels){
 | 
	
		
			
				|  |  | +    int texture=t->GLTexHandle;
 | 
	
		
			
				|  |  | +#ifdef LA_USE_GLES
 | 
	
		
			
				|  |  | +    int offscreen_framebuffer;
 | 
	
		
			
				|  |  | +    glGenFramebuffers(1, &offscreen_framebuffer);
 | 
	
		
			
				|  |  | +    glBindFramebuffer(GL_FRAMEBUFFER, offscreen_framebuffer);
 | 
	
		
			
				|  |  | +    glBindTexture(GL_TEXTURE_2D, texture);
 | 
	
		
			
				|  |  | +    glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
 | 
	
		
			
				|  |  | +    GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
 | 
	
		
			
				|  |  | +    if(status != GL_FRAMEBUFFER_COMPLETE) {
 | 
	
		
			
				|  |  | +        logPrint("Failed to make complete framebuffer object in la_glGetTextureSubImage()", status);
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +    glBindFramebuffer(GL_FRAMEBUFFER, offscreen_framebuffer);
 | 
	
		
			
				|  |  | +    glViewport(0, 0, t->Width, t->Height);
 | 
	
		
			
				|  |  | +    glReadPixels(0, 0, width, height, format, type, pixels);
 | 
	
		
			
				|  |  | +#else
 | 
	
		
			
				|  |  | +    glGetTextureSubImage(texture,0,xoffset,yoffset,0,width,height,1,format,type,bufSize,pixels);
 | 
	
		
			
				|  |  | +#endif
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  //  1  2
 | 
	
		
			
				|  |  |  // 7 9 11     13  14
 | 
	
		
			
				|  |  |  //  3  4
 | 
	
	
		
			
				|  | @@ -285,9 +312,13 @@ void tnsShaderMakeIndex(tnsShader *tns){
 | 
	
		
			
				|  |  |      tns->iUV = glGetAttribLocation(program, "vUV");
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      tns->iTexColor = glGetUniformLocation(program, "TexColor");
 | 
	
		
			
				|  |  | +    tns->iTexColorU = glGetUniformLocation(program, "TexColorUI");
 | 
	
		
			
				|  |  | +    tns->iTexColorMS = glGetUniformLocation(program, "TexColorMS");
 | 
	
		
			
				|  |  | +    if(tns->iTexColor>=0){glUniform1i(tns->iTexColor, 0);}
 | 
	
		
			
				|  |  | +    if(tns->iTexColorMS>=0){glUniform1i(tns->iTexColorMS, 1);}
 | 
	
		
			
				|  |  | +    if(tns->iTexColorU>=0){glUniform1i(tns->iTexColorU, 2);}
 | 
	
		
			
				|  |  |      tns->iTexNormal = glGetUniformLocation(program, "TexNormal");
 | 
	
		
			
				|  |  |      tns->iTexGPos = glGetUniformLocation(program, "TexGPos");
 | 
	
		
			
				|  |  | -    tns->iTexColorMS = glGetUniformLocation(program, "TexColorMS");
 | 
	
		
			
				|  |  |      tns->iMultiplyColor = glGetUniformLocation(program, "MultiplyColor");
 | 
	
		
			
				|  |  |      tns->iTextureMode = glGetUniformLocation(program, "TextureMode");
 | 
	
		
			
				|  |  |      tns->iColorMode = glGetUniformLocation(program, "ColorMode");
 | 
	
	
		
			
				|  | @@ -300,8 +331,6 @@ void tnsShaderMakeIndex(tnsShader *tns){
 | 
	
		
			
				|  |  |      tns->iComposing=glGetUniformLocation(program, "Composing");
 | 
	
		
			
				|  |  |      tns->iComposingGamma=glGetUniformLocation(program, "ComposingGamma");
 | 
	
		
			
				|  |  |      tns->iComposingBlackpoint=glGetUniformLocation(program, "ComposingBlackpoint");
 | 
	
		
			
				|  |  | -    if(tns->iTexColor>=0){glUniform1i(tns->iTexColor, 0);}
 | 
	
		
			
				|  |  | -    if(tns->iTexColorMS>=0){glUniform1i(tns->iTexColorMS, 1);}
 | 
	
		
			
				|  |  |      tns->iDoOffset = glGetUniformLocation(program, "DoOffset");
 | 
	
		
			
				|  |  |      tns->iUseHalftone = glGetUniformLocation(program, "UseHalftone");
 | 
	
		
			
				|  |  |      tns->iHalftoneSize = glGetUniformLocation(program, "HalftoneSize");
 | 
	
	
		
			
				|  | @@ -1740,12 +1769,17 @@ void tnsConfigure2DTexture(tnsTexture *t){
 | 
	
		
			
				|  |  |              t->GLTexBitsType==GL_DEPTH_COMPONENT24||t->GLTexBitsType==GL_DEPTH_COMPONENT32F;
 | 
	
		
			
				|  |  |          int format=isDepth?GL_DEPTH_COMPONENT:(t->GLTexBitsType==GL_R8?GL_RED:(t->GLTexBitsType==GL_RG8?GL_RG:(t->GLTexBitsType==GL_RGB8?GL_RGB:GL_RGBA)));
 | 
	
		
			
				|  |  |          int type=isDepth?GL_UNSIGNED_INT:GL_UNSIGNED_BYTE;
 | 
	
		
			
				|  |  | +        if(t->GLTexBitsType==GL_RGBA16UI){ format=GL_RGBA_INTEGER; type=GL_UNSIGNED_SHORT; t->IsUIntTexture=1; }
 | 
	
		
			
				|  |  | +        if(t->GLTexBitsType==GL_RGBA16F){ format=GL_RGBA; type=GL_FLOAT; }
 | 
	
		
			
				|  |  |          if(t->GLTexBitsType==GL_DEPTH_STENCIL){ format=GL_DEPTH_STENCIL; type=GL_UNSIGNED_INT_24_8; t->GLTexBitsType=GL_DEPTH24_STENCIL8; }
 | 
	
		
			
				|  |  |  #ifndef LAGUI_ANDROID
 | 
	
		
			
				|  |  |          if(isDepth){t->GLTexBitsType=GL_DEPTH_COMPONENT24; type=GL_UNSIGNED_INT;}
 | 
	
		
			
				|  |  |          if(t->Multisample) glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, t->Multisample, t->GLTexBitsType, t->Width, t->Height, GL_TRUE);
 | 
	
		
			
				|  |  |  #endif
 | 
	
		
			
				|  |  |          else{ glTexImage2D(GL_TEXTURE_2D, 0, t->GLTexBitsType, t->Width, t->Height, 0, format, type, 0);
 | 
	
		
			
				|  |  | +            if(t->IsUIntTexture){
 | 
	
		
			
				|  |  | +                glTexStorage2D(GL_TEXTURE_2D, 1,t->GLTexBitsType,t->Width, t->Height);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  |              int a=glGetError();
 | 
	
		
			
				|  |  |              glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
 | 
	
		
			
				|  |  |              glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
 | 
	
	
		
			
				|  | @@ -1839,6 +1873,7 @@ void tnsUseMaskTexture(tnsTexture *t){
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  void tnsUseTexture(tnsTexture *t){
 | 
	
		
			
				|  |  |      if(!t){T->StateTextureMode=0; return;}
 | 
	
		
			
				|  |  | +    if(t->IsUIntTexture){ T->StateTexColor = t; T->StateTextureMode=4; return; }
 | 
	
		
			
				|  |  |      if(t->GLTexType == GL_TEXTURE_2D){ T->StateTexColor = t; T->StateTextureMode=2; }
 | 
	
		
			
				|  |  |  #ifndef LAGUI_ANDROID
 | 
	
		
			
				|  |  |      else if(t->GLTexType == GL_TEXTURE_2D_MULTISAMPLE){ T->StateTexColor = t; T->StateTextureMode=3; }
 | 
	
	
		
			
				|  | @@ -1869,6 +1904,7 @@ void tnsActiveTexture(GLenum tex){
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  void tnsBindTexture(tnsTexture *t){
 | 
	
		
			
				|  |  |      if ((!t) || T->TexColor==t) return;
 | 
	
		
			
				|  |  | +    if(t->IsUIntTexture){ tnsActiveTexture(GL_TEXTURE2); glBindTexture(t->GLTexType, t->GLTexHandle); T->TexColor=t; return; }
 | 
	
		
			
				|  |  |      if(t->GLTexType == GL_TEXTURE_2D){ tnsActiveTexture(GL_TEXTURE0); glBindTexture(t->GLTexType, t->GLTexHandle); T->TexColor=t;}
 | 
	
		
			
				|  |  |  #ifndef LAGUI_ANDROID
 | 
	
		
			
				|  |  |      elif(t->GLTexType == GL_TEXTURE_2D_MULTISAMPLE){ tnsActiveTexture(GL_TEXTURE1); glBindTexture(t->GLTexType, t->GLTexHandle); T->TexColor=t;}
 | 
	
	
		
			
				|  | @@ -1883,6 +1919,7 @@ void tnsUnbindTexture(){
 | 
	
		
			
				|  |  |      if(T->TexRenderbuffer){ if(T->TexRenderbuffer->GLTexType == GL_RENDERBUFFER){ glBindRenderbufferEXT(GL_RENDERBUFFER, 0); T->TexRenderbuffer=0;}}
 | 
	
		
			
				|  |  |  #endif
 | 
	
		
			
				|  |  |      if(T->TexColor){
 | 
	
		
			
				|  |  | +        if(T->TexColor->IsUIntTexture){ tnsActiveTexture(GL_TEXTURE2); glBindTexture(T->TexColor->GLTexType, 0); T->TexColor=0; return; }
 | 
	
		
			
				|  |  |          if(T->TexColor->GLTexType == GL_TEXTURE_2D){tnsActiveTexture(GL_TEXTURE0);}
 | 
	
		
			
				|  |  |  #ifndef LAGUI_ANDROID
 | 
	
		
			
				|  |  |          else if(T->TexColor->GLTexType == GL_TEXTURE_2D_MULTISAMPLE){tnsActiveTexture(GL_TEXTURE1);}
 |