*/}}
Selaa lähdekoodia

Use 444 for default panel fbo on gles

YimingWu 3 kuukautta sitten
vanhempi
commit
a6fbe1c77c
3 muutettua tiedostoa jossa 22 lisäystä ja 9 poistoa
  1. 6 0
      la_interface.h
  2. 1 1
      la_kernel.c
  3. 15 8
      la_tns_kernel.c

+ 6 - 0
la_interface.h

@@ -1040,6 +1040,12 @@ STRUCTURE(laCanvasTemplate){
 #define LA_CANVAS_DISPLAY_SOLID 0
 #define LA_CANVAS_DISPLAY_MATERIAL 1
 
+#ifdef LAGUI_ANDROID
+#define LA_PANEL_DEFAULT_GL_FORMAT GL_RGBA4
+#else
+#define LA_PANEL_DEFAULT_GL_FORMAT GL_RGBA
+#endif
+
 void la_CanvasDefaultOverlay(laUiItem* ui, int h);
 void la_CanvasDrawOverlay(laUiItem *ui, int h);
 void la_CanvasInit(laUiItem *ui);

+ 1 - 1
la_kernel.c

@@ -2552,7 +2552,7 @@ void la_PanelDrawToWindow(laPanel *p, laWindow *w){
 void la_PanelDrawToOffsceen(laPanel *p, laUiList *uil){
     if (p->OffScr){ tnsEnsureOffscreenStatus(p->OffScr, p->W,p->H); }
     else{
-        int GLFormat=(p->PanelTemplate&&p->PanelTemplate->DefaultGLFormat)?p->PanelTemplate->DefaultGLFormat:GL_RGBA8;
+        int GLFormat=(p->PanelTemplate&&p->PanelTemplate->DefaultGLFormat)?p->PanelTemplate->DefaultGLFormat:LA_PANEL_DEFAULT_GL_FORMAT;
         p->OffScr = tnsCreate2DOffscreen(GLFormat, p->W, p->H, MAIN.PanelMultisample, 0,0);
     }
     tnsDrawToOffscreen(p->OffScr, 1, 0);

+ 15 - 8
la_tns_kernel.c

@@ -1801,19 +1801,25 @@ 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_RGBA4){ format=GL_RGB; type=GL_UNSIGNED_SHORT_4_4_4_4; printf("ye\n"); }
         if(t->GLTexBitsType==GL_RGBA16UI){ format=GL_RGBA_INTEGER; type=GL_UNSIGNED_SHORT; t->IsUIntTexture=1; }
-        if(t->GLTexBitsType==GL_RGBA32UI){ format=GL_RGBA_INTEGER; type=GL_UNSIGNED_INT; t->IsUIntTexture=1; }
-        if(t->GLTexBitsType==GL_R32UI){ format=GL_RED_INTEGER; type=GL_UNSIGNED_INT; 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; }
+        elif(t->GLTexBitsType==GL_RGBA32UI){ format=GL_RGBA_INTEGER; type=GL_UNSIGNED_INT; t->IsUIntTexture=1; }
+        elif(t->GLTexBitsType==GL_R32UI){ format=GL_RED_INTEGER; type=GL_UNSIGNED_INT; t->IsUIntTexture=1; }
+        elif(t->GLTexBitsType==GL_RGBA16F){ format=GL_RGBA; type=GL_FLOAT; }
+        elif(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);
+        t->Multisample=0;
 #endif
-        else{ glTexImage2D(GL_TEXTURE_2D, 0, t->GLTexBitsType, t->Width, t->Height, 0, format, type, 0);
+        if(t->Multisample){
+#ifndef LAGUI_ANDROID
+            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);
             }
+            //if(t->GLTexBitsType==GL_RGBA4){ glTexStorage2D(GL_TEXTURE_2D,0,GL_RGBA4,t->Width,t->Height); }
             int a=glGetError();
             int clamp = GL_CLAMP_TO_EDGE;
             glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, clamp);
@@ -2722,9 +2728,10 @@ void tnsDelete2DOffscreen(tnsOffscreen *o){
 
 void tnsDrawToOffscreen(tnsOffscreen *toff, int HowMany, GLuint *AttachmentArray){
     if (!toff) return;
-    glBindFramebuffer(GL_DRAW_FRAMEBUFFER, toff->FboHandle);
+    glBindFramebuffer(GL_DRAW_FRAMEBUFFER, toff->FboHandle); glClear(0);
     if(AttachmentArray==TNS_ATTACHMENT_ARRAY_NONE){glDrawBuffer(GL_NONE);}
     else glDrawBuffers((HowMany ? HowMany : 1), (AttachmentArray ? AttachmentArray : TNS_ATTACHMENT_ARRAY));
+    glClear(0);
     T->IsOffscreen = 1;
     T->BindedShader = 0;
 }
@@ -2737,7 +2744,7 @@ void tnsReadFromOffscreen(tnsOffscreen *toff){
     glBindFramebuffer(GL_READ_FRAMEBUFFER, toff->FboHandle);
 }
 void tnsDrawToScreen(){
-    glBindFramebuffer(GL_FRAMEBUFFER, 0);
+    glBindFramebuffer(GL_FRAMEBUFFER, 0); glClear(0);
     //glDrawBuffer(GL_BACK); printf("%d\n", glGetError());
     T->IsOffscreen = 0;
     T->BindedShader = 0;