ENIGMA Forums

Contributing to ENIGMA => Function Peer Review => Topic started by: TheExDeus on September 09, 2010, 02:11:31 PM

Title: GML: draw_sprite_stretched_ext
Post by: TheExDeus on September 09, 2010, 02:11:31 PM
If I understand the point of this section correctly, then we can add function code here? If so, then I will start by implementing simple, but missing additions.

edit: Removed unneeded glColor4f function.

Function: draw_sprite_stretched_ext(int sprite,int subimg,double x,double y,double w,double h,int color,double alpha)

GSSprite.h:
Code: [Select]
int draw_sprite_stretched_ext(int sprite,int subimg,double x,double y,double w,double h,int color,double alpha);
GSSprite.cpp:
Code: [Select]
int draw_sprite_stretched_ext(int spr,int subimg,double x,double y,double w,double h, int blend, double alpha)
{
    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);

    glBegin(GL_QUADS);
    glColor4ub(__GETR(blend),__GETG(blend),__GETB(blend),char(alpha*255)); //Implement "blend" parameter
      glTexCoord2f(spr2d->texbordx,0);
        glVertex2f(x-spr2d->xoffset,y-spr2d->yoffset);
      glTexCoord2f(0,0);
        glVertex2f(x+w-spr2d->xoffset,y-spr2d->yoffset);
      glTexCoord2f(0,spr2d->texbordy);
        glVertex2f(x+w-spr2d->xoffset,y+h-spr2d->yoffset);
      glTexCoord2f(spr2d->texbordx,spr2d->texbordy);
        glVertex2f(x-spr2d->xoffset,y+h-spr2d->yoffset);
    glEnd();
    glPopAttrib();
    return 0;
}

If this is how should these topics look like, then I will do others too.
Title: Re: draw_sprite_stretched_ext
Post by: Josh @ Dreamland on September 09, 2010, 05:01:02 PM
That's just how it looks.
Seems to be like the others, so if you've tested that and it works, I'll add it now.
Title: Re: draw_sprite_stretched_ext
Post by: TheExDeus on September 10, 2010, 04:20:25 AM
Yes, it works. I will make others now.
Title: Re: GML: draw_sprite_stretched_ext
Post by: Josh @ Dreamland on October 16, 2010, 01:34:54 PM
Integrated for next revision.