*/}}
1
0

2 کامیت‌ها d9c25e0c0f ... eb2ed31b6c

نویسنده SHA1 پیام تاریخ
  YimingWu eb2ed31b6c GLes compatibility 10 ماه پیش
  YimingWu e27357ba1a gles integer texture shader stuff 10 ماه پیش
4فایلهای تغییر یافته به همراه51 افزوده شده و 4 حذف شده
  1. 7 2
      la_data.c
  2. 1 0
      la_tns.h
  3. 31 2
      la_tns_kernel.c
  4. 12 0
      resources/la_tns_shaders.cpp

+ 7 - 2
la_data.c

@@ -3913,7 +3913,7 @@ void laRefreshUDFResourcesIn(char* rootpath){
     int NumFiles=-1;
     int len = strlen(rootpath);
     if (len && rootpath[len - 1] != LA_PATH_SEP) strcat(rootpath, LA_PATH_SEPSTR);
-#ifdef __linux__
+#if defined(__linux__) || defined(LAGUI_ANDROID)
     struct dirent **NameList=0;
     NumFiles=scandir(rootpath,&NameList,0,alphasort);
 
@@ -3979,11 +3979,16 @@ void laRefreshUDFRegistries(){
     char LookupM[PATH_MAX];
     for(laResourceFolder* rf = MAIN.ResourceFolders.pFirst;rf;rf=rf->Item.pNext){
 #ifdef LAGUI_ANDROID
+        sprintf(LookupM,"%s",SSTR(rf->Path));
+        laRefreshUDFResourcesIn(LookupM);
+        sprintf(LookupM,"%s/%s",MAIN.ExternalDataPath,SSTR(rf->Path));
+        laRefreshUDFResourcesIn(LookupM);
         sprintf(LookupM,"%s/%s",MAIN.InternalDataPath,SSTR(rf->Path));
+        laRefreshUDFResourcesIn(LookupM);
 #else
         realpath(SSTR(rf->Path), LookupM);
-#endif
         laRefreshUDFResourcesIn(LookupM);
+#endif
     }
 }
 

+ 1 - 0
la_tns.h

@@ -1417,6 +1417,7 @@ void tnsDraw2DTextureArg(tnsTexture *t,
                          real LPadding, real RPadding, real TPadding, real BPadding);
 
 void tnsGet2DTextureSubImage(tnsTexture* t, int xoffset, int yoffset, uint32_t width, uint32_t height, int format, int type, size_t bufSize, void *pixels);
+void tnsClearTextureImage(tnsTexture* t, int tex_format, int tex_bits_type);
 
 int tnsTextureMemorySize(tnsTexture *t, int mem);
 

+ 31 - 2
la_tns_kernel.c

@@ -49,11 +49,34 @@ void tnsGet2DTextureSubImage(tnsTexture* t, int xoffset, int yoffset, uint32_t w
     }
     glBindFramebuffer(GL_FRAMEBUFFER, offscreen_framebuffer);
     glViewport(0, 0, t->Width, t->Height);
-    glReadPixels(0, 0, width, height, format, type, pixels);
+    glReadPixels(xoffset, yoffset, width, height, format, type, pixels);
+    glBindFramebuffer(GL_FRAMEBUFFER, 0);
+    glDeleteFramebuffers(1, &offscreen_framebuffer);
 #else
     glGetTextureSubImage(texture,0,xoffset,yoffset,0,width,height,1,format,type,bufSize,pixels);
 #endif
 }
+void tnsClearTextureImage(tnsTexture* t, int tex_format, int tex_bits_type){
+    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);
+    glClearColor(0,0,0,0); glClear(GL_COLOR_BUFFER_BIT);
+    glBindFramebuffer(GL_FRAMEBUFFER, 0);
+    glDeleteFramebuffers(1, &offscreen_framebuffer);
+#else
+    glClearTexImage(t->GLTexHandle,0,tex_format,tex_bits_type,0);
+#endif
+}
 
 
 //  1  2
@@ -388,7 +411,13 @@ char* tnsEnsureShaderCommoms(char* Content, char* Library, char* Material){
     c=strSub(c1,"#with LA_SHADER_LIB_FXAA",LA_SHADER_LIB_FXAA); free(c1);
     c1=strSub(c,"#with TNS_SHADER_MATERIAL",Material?Material:""); free(c);
     c=strSub(c1,"#with TNS_SHADER_LIBRARY",Library?Library:""); free(c1);
-    return c;
+#ifdef LA_USE_GLES
+    const char uint_texture_selection[] = "#define GLES_UINT_TEXTURE";
+#else
+    const char uint_texture_selection[] = "";
+#endif
+    c1=strSub(c,"#with TNS_GLES_UINT_TEXTURE",uint_texture_selection); free(c);
+    return c1;
 }
 int tnsNewVertexShader(char *Content){
     int status = 0;

+ 12 - 0
resources/la_tns_shaders.cpp

@@ -701,6 +701,7 @@ layout(location = 2) out vec3 outGPos;
 
 #with TNS_SHADER_COLOR_COMMON
 #with TNS_SHADER_LIBRARY
+#with TNS_GLES_UINT_TEXTURE
 
 vec3 ConvertColorSpace(vec3 color){
     if(InputColorSpace!=OutputColorSpace){
@@ -726,6 +727,13 @@ vec3 ConvertColorSpace(vec3 color){
     }
     return color;
 }
+
+#ifdef GLES_UINT_TEXTURE
+vec4 cunpack(uint d){
+    return vec4(float(d&0xFFu)/255.,float((d>>8u)&0xFFu)/255.,float((d>>16u)&0xFFu)/255.,float((d>>24u)&0xFFu)/255.);
+}
+#endif
+
 void main(){
     vec4 color=vec4(1,0,1,1);
     if(TextureMode==0){ color = fColor; if(UseHalftone>0.) color.a=HalftoneSingle(color.a,htsize,rad(7.),0.); }
@@ -740,7 +748,11 @@ void main(){
         color/=float(SampleAmount);
         if(MultiplyColor!=0){color*=fColor;}
     }else if(TextureMode==4){
+#ifdef GLES_UINT_TEXTURE
+		color=cunpack(texture(TexColorUI,fUV.st).r);
+#else
 		color=vec4(texture(TexColorUI,fUV.st))/vec4(65535.);
+#endif
         if(MultiplyColor!=0){color*=fColor;}
 	}else if(TextureMode==101){ // YUYV
 		ivec2 tsize = textureSize(TexColor,0);