Add uniform Yangmi framing candidate for code37

This commit is contained in:
zenord
2026-10-14 21:16:22 +08:00
parent 99a03e0487
commit 5c4ea077ee
15 changed files with 169 additions and 21 deletions
+4 -2
View File
@@ -22,7 +22,7 @@ static void texture(GLuint id,int w,int h,const char *path) {
glTexImage2D(GL_TEXTURE_2D,0,GL_RGBA,w,h,0,GL_RGBA,GL_UNSIGNED_BYTE,data);free(data);
}
int main(int argc,char **v) {
assert(argc==16);
assert(argc==16 || argc==18);
int bw=atoi(v[14]),bh=atoi(v[15]);assert(bw>0&&bh>0);
int pw=atoi(v[6]),ph=atoi(v[7]),w=atoi(v[11]),h=atoi(v[12]);float x=atof(v[8]),y=atof(v[9]),opacity=atof(v[10]);
PFNEGLGETPLATFORMDISPLAYEXTPROC platform=(void*)eglGetProcAddress("eglGetPlatformDisplayEXT");assert(platform);
@@ -38,7 +38,9 @@ int main(int argc,char **v) {
GLuint ids[2];glGenTextures(2,ids);glActiveTexture(GL_TEXTURE0);texture(ids[0],bw,bh,v[3]);glUniform1i(glGetUniformLocation(p,"uBody"),0);
glActiveTexture(GL_TEXTURE1);texture(ids[1],pw,ph,v[4]);glUniform1i(glGetUniformLocation(p,"uPatch"),1);
glUniform2f(glGetUniformLocation(p,"uBodySize"),bw,bh);
float scale=fminf((float)w/bw,(float)h/bh),mw=bw*scale,mh=bh*scale,left=(w-mw)/2,top=(h-mh)/2;
float zoom=argc==18?atof(v[16]):1,centerY=argc==18?atof(v[17]):.5f;
assert(isfinite(zoom)&&zoom>=1&&zoom<=2&&isfinite(centerY)&&centerY>=.4f&&centerY<=.6f);
float scale=fminf((float)w/bw,(float)h/bh)*zoom,mw=bw*scale,mh=bh*scale,left=(w-mw)/2,top=h/2.f-mh*centerY;
GLfloat pos[]={left/w*2-1,1-(top+mh)/h*2,(left+mw)/w*2-1,1-(top+mh)/h*2,left/w*2-1,1-top/h*2,(left+mw)/w*2-1,1-top/h*2};
GLfloat uv[]={0,0,1,0,0,1,1,1};
GLint a=glGetAttribLocation(p,"aPosition"),b=glGetAttribLocation(p,"aUv");glVertexAttribPointer(a,2,GL_FLOAT,GL_FALSE,0,pos);glEnableVertexAttribArray(a);glVertexAttribPointer(b,2,GL_FLOAT,GL_FALSE,0,uv);glEnableVertexAttribArray(b);