Joined: Apr 2008
Posts: 1860
|
Description:This function was already present in Enigma, but it was just copied draw_sprite_part code, and so didn't feature scale or rotation. This function does, so every argument is used. This function also has 3 more arguments then the original, so its possible to change alpha for every corner, not only color. I don't know if this is needed (for example, for compatibility with GM), and so if dev's think it doesn't suit it, then they can remove those arguments. Function: draw_sprite_general(int spr,int subimg,double left,double top,double width,double height,double x,double y,double xscale,double yscale,double rot,int c1,int c2,int c3,int c4,double a1, double a2, double a3, double a4) Code:
int draw_sprite_general(int spr,int subimg,double left,double top,double width,double height,double x,double y,double xscale,double yscale,double rot,int c1,int c2,int c3,int c4,double a1, double a2, double a3, double a4) { enigma::sprite *spr2d=enigma::spritestructarray[spr]; if (!spr2d) return -1;
glPushAttrib(GL_CURRENT_BIT); if (enigma::cur_bou_tha_noo_sho_eve_cha_eve != spr2d->texturearray[subimg % spr2d->subcount]) { glBindTexture(GL_TEXTURE_2D,spr2d->texturearray[subimg % spr2d->subcount]); enigma::cur_bou_tha_noo_sho_eve_cha_eve=spr2d->texturearray[subimg % spr2d->subcount]; }
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_CLAMP); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_CLAMP);
const float tbx=spr2d->texbordx,tby=spr2d->texbordy, w=width*xscale, h=height*yscale, tbw=spr2d->width/tbx,tbh=spr2d->height/tby;
rot *= M_PI/180;
float ulcx = x + xscale * cos(M_PI+rot) + yscale * cos(M_PI/2+rot), ulcy = y - yscale * sin(M_PI+rot) - yscale * sin(M_PI/2+rot);
glBegin(GL_QUADS); glColor4ub(__GETR(c1),__GETG(c1),__GETB(c1),char(a1*255)); glTexCoord2f(left/tbw,top/tbh); glVertex2f(ulcx,ulcy);
glColor4ub(__GETR(c2),__GETG(c2),__GETB(c2),char(a2*255)); glTexCoord2f((left+width)/tbw,top/tbh); glVertex2f((ulcx + w*cos(rot)), (ulcy - w*sin(rot)));
ulcx += h * cos(3*M_PI/2 + rot); ulcy -= h * sin(3*M_PI/2 + rot); glColor4ub(__GETR(c3),__GETG(c3),__GETB(c3),char(a3*255)); glTexCoord2f((left+width)/tbw,(top+height)/tbh); glVertex2f((ulcx + w*cos(rot)), (ulcy - w*sin(rot)));
glColor4ub(__GETR(c4),__GETG(c4),__GETB(c4),char(a4*255)); glTexCoord2f(left/tbw,(top+height)/tbh); glVertex2f(ulcx,ulcy); glEnd(); glPopAttrib(); return 0; }
|