|
@@ -343,10 +343,8 @@ void tnsShaderMakeIndex(tnsShader *tns){
|
|
|
tns->iTexColorU = glGetUniformLocation(program, "TexColorUI");
|
|
|
tns->iTexColorMS = glGetUniformLocation(program, "TexColorMS");
|
|
|
tns->iTexLut=glGetUniformLocation(program, "TexLut");
|
|
|
- if(tns->iTexColor>=0){glUniform1i(tns->iTexColor, 0);}
|
|
|
- if(tns->iTexColorMS>=0){glUniform1i(tns->iTexColorMS, 1);}
|
|
|
- if(tns->iTexColorU>=0){glUniform1i(tns->iTexColorU, 2);}
|
|
|
- if(tns->iTexLut>=0){glUniform1i(tns->iTexLut, 3);}
|
|
|
+ tns->iTexColor2 = glGetUniformLocation(program, "TexColor2");
|
|
|
+ tns->iTexColor2U = glGetUniformLocation(program, "TexColor2UI");
|
|
|
tns->iTexNormal = glGetUniformLocation(program, "TexNormal");
|
|
|
tns->iTexGPos = glGetUniformLocation(program, "TexGPos");
|
|
|
tns->iMultiplyColor = glGetUniformLocation(program, "MultiplyColor");
|
|
@@ -357,6 +355,8 @@ void tnsShaderMakeIndex(tnsShader *tns){
|
|
|
tns->iUseNormal = glGetUniformLocation(program, "UseNormal");
|
|
|
tns->iOutputColorSpace=glGetUniformLocation(program, "OutputColorSpace");
|
|
|
tns->iInputColorSpace=glGetUniformLocation(program, "InputColorSpace");
|
|
|
+ tns->iTexIsUI=glGetUniformLocation(program, "TexIsUI");
|
|
|
+ tns->iTex2IsUI=glGetUniformLocation(program, "Tex2IsUI");
|
|
|
tns->iUseLut=glGetUniformLocation(program, "UseLut");
|
|
|
tns->iShowStripes=glGetUniformLocation(program, "ShowStripes");
|
|
|
tns->iComposing=glGetUniformLocation(program, "Composing");
|
|
@@ -1691,7 +1691,7 @@ void tnsDrawBatchInitArrayStates(tnsBatch* batch){
|
|
|
}
|
|
|
}
|
|
|
if(cs->iUV>=0){ glDisableVertexAttribArray(cs->iUV); }
|
|
|
- tnsUniformUseTexture(cs, 0, 0);
|
|
|
+ tnsUniformUseTexture(cs,0,0,0,0);
|
|
|
}
|
|
|
int tnsDrawBatch(tnsBatch* batch, const char* OverrideCommand, real* OverrideUniformColor, int OverrideAsArray) {
|
|
|
if (!batch) return 0;
|
|
@@ -1921,21 +1921,26 @@ void tnsUseMaskTexture(tnsTexture *t){
|
|
|
if(!t){T->StateTextureMode=0; return;}
|
|
|
T->StateTexColor = t; T->StateTextureMode=1;
|
|
|
}
|
|
|
+#define TEX_MODE_IS_MIXING(T) \
|
|
|
+ (T->StateTextureMode>=5&&T->StateTextureMode<=100)
|
|
|
void tnsUseTexture(tnsTexture *t){
|
|
|
- if(!t){T->StateTextureMode=0; return;}
|
|
|
- if(t->IsUIntTexture){ T->StateTexColor = t; T->StateTextureMode=4; return; }
|
|
|
+ if(!t){ T->StateTextureMode=0; return; }
|
|
|
if(t->GLTexType == GL_TEXTURE_2D){
|
|
|
T->StateTexColor = t;
|
|
|
switch(t->ChromaCompression){
|
|
|
case TNS_CHROMA_COMPRESSION_YUYV: T->StateTextureMode = 101; break;
|
|
|
case TNS_CHROMA_COMPRESSION_UYVY: T->StateTextureMode = 102; break;
|
|
|
- default: T->StateTextureMode = 2;
|
|
|
+ default: T->StateTextureMode = TEX_MODE_IS_MIXING(T)?T->StateTextureMode:2;
|
|
|
}
|
|
|
}
|
|
|
#ifndef LAGUI_ANDROID
|
|
|
else if(t->GLTexType == GL_TEXTURE_2D_MULTISAMPLE){ T->StateTexColor = t; T->StateTextureMode=3; }
|
|
|
#endif
|
|
|
}
|
|
|
+void tnsUseTexture2(tnsTexture* t, int mixmode){
|
|
|
+ if(!t){ T->StateTextureMode=TEX_MODE_IS_MIXING(T)?2:0; return; }
|
|
|
+ if(t->GLTexType == GL_TEXTURE_2D){ T->StateTexColor2=t; T->StateTextureMode=5+mixmode; }
|
|
|
+}
|
|
|
void tnsUseNoTexture(){
|
|
|
tnsUseTexture(0);
|
|
|
}
|
|
@@ -1985,9 +1990,20 @@ void tnsUnbindTexture(){
|
|
|
glBindTexture(T->TexColor->GLTexType, 0); T->TexColor=0;
|
|
|
}
|
|
|
}
|
|
|
-void tnsUniformUseTexture(tnsShader* s, int mode, int sample){
|
|
|
+void tnsBindTexture2(tnsTexture *t){
|
|
|
+ if ((!t) || T->TexColor2==t) return;
|
|
|
+ if(t->GLTexType == GL_TEXTURE_2D){ tnsActiveTexture(GL_TEXTURE4); glBindTexture(t->GLTexType, t->GLTexHandle); T->TexColor2=t;}
|
|
|
+}
|
|
|
+void tnsUnbindTexture2(){
|
|
|
+ if(T->TexColor2){
|
|
|
+ tnsActiveTexture(GL_TEXTURE4); glBindTexture(T->TexColor->GLTexType, 0); T->TexColor=0;
|
|
|
+ }
|
|
|
+}
|
|
|
+void tnsUniformUseTexture(tnsShader* s, int mode, int sample, int TexIsUInt, int Tex2IsUInt){
|
|
|
if(s->StateTextureMode != mode){ s->StateTextureMode=mode; glUniform1i(s->iTextureMode,mode); }
|
|
|
if(mode==3 && s->StateSampleAmount != sample){ s->StateSampleAmount=sample, glUniform1i(s->iSampleAmount,sample); }
|
|
|
+ if(s->StateTexIsUI != TexIsUInt){ s->StateTexIsUI=TexIsUInt; glUniform1i(s->iTexIsUI,TexIsUInt); }
|
|
|
+ if(s->StateTex2IsUI != Tex2IsUInt){ s->StateTex2IsUI=Tex2IsUInt; glUniform1i(s->iTex2IsUI,TexIsUInt); }
|
|
|
}
|
|
|
void tnsUniformUseMultiplyColor(tnsShader* s, int enable){
|
|
|
int mode=enable?1:0;
|
|
@@ -2433,6 +2449,7 @@ void tnsPackAs(GLenum Mode){
|
|
|
c->Mode = Mode;
|
|
|
c->ReplaceShader = T->StateShader;
|
|
|
c->ColorTexture = T->StateTexColor;
|
|
|
+ c->ColorTexture2 = T->StateTexColor2;
|
|
|
c->TextureMode = T->StateTextureMode;
|
|
|
c->MultiplyColor = T->StateMultiplyColor;
|
|
|
c->LineWidth=T->StateLineWidth;
|
|
@@ -2533,10 +2550,13 @@ void tnsFlush(){
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if (c->TextureMode && c->ColorTexture && cs->iTexColor != -1){
|
|
|
- tnsBindTexture(c->ColorTexture); tnsUniformUseTexture(cs, c->TextureMode, c->ColorTexture->Multisample);
|
|
|
+ if (c->TextureMode && c->ColorTexture && cs->iTexColor!=-1){
|
|
|
+ tnsBindTexture(c->ColorTexture);
|
|
|
+ if(c->ColorTexture2) tnsBindTexture2(c->ColorTexture2);
|
|
|
+ tnsUniformUseTexture(cs, c->TextureMode, c->ColorTexture->Multisample,
|
|
|
+ c->ColorTexture?c->ColorTexture->IsUIntTexture:0, c->ColorTexture2?c->ColorTexture2->IsUIntTexture:0);
|
|
|
}else{
|
|
|
- tnsUniformUseTexture(cs, 0, 0); //tnsUnbindTexture();
|
|
|
+ tnsUniformUseTexture(cs,0,0,0,0); //tnsUnbindTexture();
|
|
|
}
|
|
|
|
|
|
if(cs->iMultiplyColor != -1){ tnsUniformUseMultiplyColor(cs, c->MultiplyColor); }
|
|
@@ -2753,12 +2773,12 @@ void tnsDrawToOffscreen(tnsOffscreen *toff, int HowMany, GLuint *AttachmentArray
|
|
|
T->IsOffscreen = 1;
|
|
|
T->BindedShader = 0;
|
|
|
}
|
|
|
-void tnsDrawToOffscreenOnlyBind(tnsOffscreen *toff, int HowMany, GLuint *AttachmentArray){
|
|
|
- if (!toff) return;
|
|
|
+void tnsDrawToOffscreenOnlyBind(tnsOffscreen *toff){
|
|
|
+ if (!toff){ glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); return; }
|
|
|
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, toff->FboHandle);
|
|
|
}
|
|
|
void tnsReadFromOffscreen(tnsOffscreen *toff){
|
|
|
- if (!toff) return;
|
|
|
+ if (!toff){ glBindFramebuffer(GL_READ_FRAMEBUFFER, 0); return; }
|
|
|
glBindFramebuffer(GL_READ_FRAMEBUFFER, toff->FboHandle);
|
|
|
}
|
|
|
void tnsDrawToScreen(){
|