*/}}
Bladeren bron

GLes compatibility

YimingWu 3 maanden geleden
bovenliggende
commit
eb2ed31b6c
3 gewijzigde bestanden met toevoegingen van 32 en 3 verwijderingen
  1. 7 2
      la_data.c
  2. 1 0
      la_tns.h
  3. 24 1
      la_tns_kernel.c

+ 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);
 

+ 24 - 1
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