Support bounded 720x1280 avatar shapes through GLES and production gates
This commit is contained in:
@@ -22,7 +22,8 @@ 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==14);
|
||||
assert(argc==16);
|
||||
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);
|
||||
EGLDisplay d=platform(EGL_PLATFORM_SURFACELESS_MESA,EGL_DEFAULT_DISPLAY,NULL);assert(d!=EGL_NO_DISPLAY);
|
||||
@@ -34,9 +35,10 @@ int main(int argc,char **v) {
|
||||
assert(eglMakeCurrent(d,surface,surface,c));
|
||||
GLuint vertex=shader(GL_VERTEX_SHADER,v[1]),fragment=shader(GL_FRAGMENT_SHADER,v[2]);GLuint p=glCreateProgram();glAttachShader(p,vertex);glAttachShader(p,fragment);glLinkProgram(p);
|
||||
GLint linked;glGetProgramiv(p,GL_LINK_STATUS,&linked);assert(linked);glUseProgram(p);
|
||||
GLuint ids[2];glGenTextures(2,ids);glActiveTexture(GL_TEXTURE0);texture(ids[0],480,848,v[3]);glUniform1i(glGetUniformLocation(p,"uBody"),0);
|
||||
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);
|
||||
float scale=fminf(w/480.f,h/848.f),mw=480*scale,mh=848*scale,left=(w-mw)/2,top=(h-mh)/2;
|
||||
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;
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user