Exemple #1
0
void draw_background_part(int back,double left,double top,double width,double height,double x,double y)
{
    get_background(bck2d,back);
      texture_use(GmTextures[bck2d->texture]->gltex);

    glPushAttrib(GL_CURRENT_BIT);
    glColor4f(1,1,1,1);

    float tbw = bck2d->width/(float)bck2d->texbordx, tbh = bck2d->height/(float)bck2d->texbordy,
          tbx1 = left/tbw, tbx2 = tbx1 + width/tbw,
          tby1 = top/tbh, tby2 = tby1 + height/tbh;

    glBegin(GL_TRIANGLE_STRIP);
    glTexCoord2f(tbx1,tby1);
    glVertex2f(x,y);
    glTexCoord2f(tbx2,tby1);
    glVertex2f(x+width,y);
    glTexCoord2f(tbx1,tby2);
    glVertex2f(x,y+height);
    glTexCoord2f(tbx2,tby2);
    glVertex2f(x+width,y+height);
    glEnd();

    glPopAttrib();
}
Exemple #2
0
void draw_sprite_general(int spr, int subimg, gs_scalar left, gs_scalar top, gs_scalar width, gs_scalar height, gs_scalar x, gs_scalar y, gs_scalar xscale, gs_scalar yscale, double rot, int c1, int c2, int c3, int c4, gs_scalar a1, gs_scalar a2, gs_scalar a3, gs_scalar a4)
{
    get_spritev(spr2d,spr);
    const int usi = subimg >= 0 ? (subimg % spr2d->subcount) : int(((enigma::object_graphics*)enigma::instance_event_iterator->inst)->image_index) % spr2d->subcount;
    texture_use(GmTextures[spr2d->texturearray[usi]]->gltex);

    const gs_scalar
    tbw = spr2d->width/spr2d->texbordxarray[usi], tbh = spr2d->height/spr2d->texbordyarray[usi],
    w = width*xscale, h = height*yscale;

    rot *= M_PI/180;
    const gs_scalar wcosrot = w*cos(rot), wsinrot = w*sin(rot);

    const gs_scalar 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);

    const gs_scalar ulcx2 = ulcx + h * cos(3*M_PI/2 + rot),
    ulcy2 = ulcy - h * sin(3*M_PI/2 + rot);

    const gs_scalar data[4*8] = {
         ulcx,ulcy, left/tbw,top/tbh, __GETR(c1), __GETG(c1), __GETB(c1), a1,
         ulcx + wcosrot, ulcy - wsinrot, (left+width)/tbw,top/tbh, __GETR(c2), __GETG(c2), __GETB(c2), a2,
         ulcx2 + wcosrot, ulcy2 - wsinrot, (left+width)/tbw,(top+height)/tbh, __GETR(c3), __GETG(c3), __GETB(c3), a3,
         ulcx2,ulcy2, left/tbw,(top+height)/tbh, __GETR(c4), __GETG(c4), __GETB(c4), a4
    };
    plane2D_rotated(data);
}
Exemple #3
0
void draw_surface_general(int id, gs_scalar left, gs_scalar top, gs_scalar width, gs_scalar height, gs_scalar x, gs_scalar y, gs_scalar xscale, gs_scalar yscale, double rot, int c1, int c2, int c3, int c4, gs_scalar a1, gs_scalar a2, gs_scalar a3, gs_scalar a4)
{
  get_surface(surf,id);
  texture_use(surf->tex);

  glPushAttrib(GL_CURRENT_BIT);
    const gs_scalar tbw = surf->width, tbh = surf->height,
      w = width*xscale, h = height*yscale;

    rot *= M_PI/180;

    gs_scalar 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();
}
int draw_primitive_begin_texture(int dink,unsigned tex)
{
  texture_use(tex);
	GLenum kind = ptypes_by_id[ dink & 15 ];
	glBegin(kind);
  return 0;
}
Exemple #5
0
void draw_surface_tiled(int id, gs_scalar x, gs_scalar y)
{
  get_surface(surf,id);
  texture_use(surf->tex);

  glPushAttrib(GL_CURRENT_BIT);
    glColor4f(1,1,1,1);
    x=surf->width-fmod(x,surf->width);
    y=surf->height-fmod(y,surf->height);
    const int hortil= int (ceil(room_width/(surf->width))),
              vertil= int (ceil(room_height/(surf->height)));

    glBegin(GL_QUADS);
      for (int i=0; i<hortil; i++)
      {
        for (int c=0; c<vertil; c++)
        {
          glTexCoord2f(0,0);
            glVertex2f(i*surf->width-x,c*surf->height-y);
          glTexCoord2f(1,0);
            glVertex2f((i+1)*surf->width-x,c*surf->height-y);
          glTexCoord2f(1,1);
            glVertex2f((i+1)*surf->width-x,(c+1)*surf->height-y);
          glTexCoord2f(0,1);
            glVertex2f(i*surf->width-x,(c+1)*surf->height-y);
        }
      }
    glEnd();
  glPopAttrib();
}
Exemple #6
0
void draw_surface_ext(int id, gs_scalar x, gs_scalar y, gs_scalar xscale, gs_scalar yscale, double rot, int color, gs_scalar alpha)
{
  get_surface(surf,id);
  texture_use(surf->tex);

  glPushAttrib(GL_CURRENT_BIT);
    glColor4ub(__GETR(color),__GETG(color),__GETB(color),char(alpha*255));

    const gs_scalar w=surf->width*xscale, h=surf->height*yscale;
    rot *= M_PI/180;

    gs_scalar 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);
      glTexCoord2f(0,0);
        glVertex2f(ulcx,ulcy);
      glTexCoord2f(1,0);
        glVertex2f(ulcx + w*cos(rot), ulcy - w*sin(rot));
      glTexCoord2f(1,1);
        ulcx += h * cos(3*M_PI/2 + rot);
        ulcy -= h * sin(3*M_PI/2 + rot);
        glVertex2f(ulcx + w*cos(rot), ulcy - w*sin(rot));
      glTexCoord2f(0,1);
        glVertex2f(ulcx,ulcy);
    glEnd();
  glPopAttrib();
}
Exemple #7
0
void draw_surface_tiled_ext(int id, gs_scalar x, gs_scalar y, gs_scalar xscale, gs_scalar yscale, int color, gs_scalar alpha)
{
  get_surface(surf,id);
  texture_use(surf->tex);

  glPushAttrib(GL_CURRENT_BIT);
    glColor4ub(__GETR(color),__GETG(color),__GETB(color),char(alpha*255));
    const gs_scalar w=surf->width*xscale, h=surf->height*yscale;
    const int hortil= int (ceil(room_width/(surf->width))),
        vertil= int (ceil(room_height/(surf->height)));
    x=w-fmod(x,w);
    y=h-fmod(y,h);
    glBegin(GL_QUADS);
    for (int i=0; i<hortil; i++)
    {
      for (int c=0; c<vertil; c++)
      {
        glTexCoord2f(0,0);
          glVertex2f(i*w-x,c*h-y);
        glTexCoord2f(1,0);
          glVertex2f((i+1)*w-x,c*h-y);
        glTexCoord2f(1,1);
          glVertex2f((i+1)*w-x,(c+1)*h-y);
        glTexCoord2f(0,1);
          glVertex2f(i*w-x,(c+1)*h-y);
      }
    }
    glEnd();
  glPopAttrib();
}
Exemple #8
0
void draw_background_part_ext(int back,double left,double top,double width,double height,double x,double y,double xscale,double yscale,int color,double alpha)
{
    get_background(bck2d,back);
      texture_use(GmTextures[bck2d->texture]->gltex);

    glPushAttrib(GL_CURRENT_BIT);
    glColor4ub(__GETR(color),__GETG(color),__GETB(color),char(alpha*255));

    float tbw = bck2d->width/(float)bck2d->texbordx, tbh = bck2d->height/(float)bck2d->texbordy,
          xvert1 = x, xvert2 = xvert1 + width*xscale,
          yvert1 = y, yvert2 = yvert1 + height*yscale,
          tbx1 = left/tbw, tbx2 = tbx1 + width/tbw,
          tby1 = top/tbh, tby2 = tby1 + height/tbh;

    glBegin(GL_TRIANGLE_STRIP);
    glTexCoord2f(tbx1,tby1);
    glVertex2f(xvert1,yvert1);
    glTexCoord2f(tbx2,tby1);
    glVertex2f(xvert2,yvert1);
    glTexCoord2f(tbx1,tby2);
    glVertex2f(xvert1,yvert2);
    glTexCoord2f(tbx2,tby2);
    glVertex2f(xvert2,yvert2);
    glEnd();

    glPopAttrib();
}
Exemple #9
0
void draw_sprite_ext(int spr, int subimg, gs_scalar x, gs_scalar y, gs_scalar xscale, gs_scalar yscale, double rot, int blend, gs_scalar alpha)
{
    get_spritev(spr2d,spr);
    const int usi = subimg >= 0 ? (subimg % spr2d->subcount) : int(((enigma::object_graphics*)enigma::instance_event_iterator->inst)->image_index) % spr2d->subcount;
    texture_use(GmTextures[spr2d->texturearray[usi]]->gltex);

    rot *= M_PI/180;

    const gs_scalar w = spr2d->width*xscale, h = spr2d->height*yscale,
    tbx = spr2d->texbordxarray[usi], tby = spr2d->texbordyarray[usi],
    wsinrot = w*sin(rot), wcosrot = w*cos(rot);

    const gs_scalar ulcx = x - xscale * spr2d->xoffset * cos(rot) + yscale * spr2d->yoffset * cos(M_PI/2+rot),
    ulcy = y + xscale * spr2d->xoffset * sin(rot) - yscale * spr2d->yoffset * sin(M_PI/2+rot);
    const double mpr = 3*M_PI/2 + rot;
    const gs_scalar ulcx2 = ulcx + h * cos(mpr),
    ulcy2 = ulcy - h * sin(mpr);

    const gs_scalar r = __GETR(blend), g = __GETG(blend), b = __GETB(blend);
    const gs_scalar data[4*8] = {
         ulcx, ulcy, 0.0, 0.0, r, g, b, alpha,
         ulcx + wcosrot, ulcy - wsinrot, tbx, 0.0, r, g, b, alpha,
         ulcx2 + wcosrot, ulcy2 - wsinrot, tbx, tby, r, g, b, alpha,
         ulcx2, ulcy2, 0.0, tby, r, g, b, alpha
    };
    plane2D_rotated(data);
}
Exemple #10
0
void draw_sprite_tiled(int spr, int subimg, gs_scalar x, gs_scalar y)
{
    get_spritev(spr2d,spr);
    const int usi = subimg >= 0 ? (subimg % spr2d->subcount) : int(((enigma::object_graphics*)enigma::instance_event_iterator->inst)->image_index) % spr2d->subcount;
    texture_use(GmTextures[spr2d->texturearray[usi]]->gltex);

    const gs_scalar tbx  = spr2d->texbordxarray[usi], tby  = spr2d->texbordyarray[usi],
    xoff = fmod(spr2d->xoffset+x,spr2d->width)-spr2d->width, yoff = fmod(spr2d->yoffset+y,spr2d->height)-spr2d->height;

    const int hortil = int(ceil((view_enabled ? int(view_xview[view_current] + view_wview[view_current]) : room_width) / (spr2d->width*tbx))) + 1,
    vertil = int(ceil((view_enabled ? int(view_yview[view_current] + view_hview[view_current]) : room_height) / (spr2d->height*tby))) + 1;

    gs_scalar xvert1 = xoff, xvert2 = xvert1 + spr2d->width, yvert1, yvert2;
    for (int i=0; i<hortil; i++)
    {
        yvert1 = yoff; yvert2 = yvert1 + spr2d->height;
        for (int c=0; c<vertil; c++)
        {
            const gs_scalar data[4*8] = {
                 xvert1, yvert1, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0,
                 xvert2, yvert1, tbx, 0.0, 1.0, 1.0, 1.0, 1.0,
                 xvert2, yvert2, tbx, tby, 1.0, 1.0, 1.0, 1.0,
                 xvert1, yvert2, 0.0, tby, 1.0, 1.0, 1.0, 1.0
            };
            plane2D_rotated(data);

            yvert1 = yvert2;
            yvert2 += spr2d->height;
        }
        xvert1 = xvert2;
        xvert2 += spr2d->width;
    }
}
void d3d_primitive_end()
{
  if (prim_d3d_texture != -1) {
    texture_use(get_texture(prim_d3d_texture));
  }
  prim_d3d_texture = -1;
  d3d_model_draw(prim_d3d_model);
  d3d_model_clear(prim_d3d_model);
}
int draw_primitive_end()
{
  if (prim_draw_texture != -1) {
    texture_use(get_texture(prim_draw_texture));
  }
  prim_draw_texture = -1;
  d3d_model_draw(prim_draw_model);
  d3d_model_clear(prim_draw_model);
  return 0;
}
Exemple #13
0
void draw_background_tiled_area_ext(int back,double x,double y,double x1,double y1,double x2,double y2, double xscale, double yscale, int color, double alpha)
{
  get_background(bck2d,back);
    texture_use(GmTextures[bck2d->texture]->gltex);

  glPushAttrib(GL_CURRENT_BIT);
    glColor4ub(__GETR(color),__GETG(color),__GETB(color),char(alpha*255));

    const float tbx=bck2d->texbordx,tby=bck2d->texbordy;
    float sw,sh,i,j,jj,left,top,width,height,X,Y;
    sw = bck2d->width*xscale;
    sh = bck2d->height*yscale;

    i = x1-(fmod(x1,sw) - fmod(x,sw)) - sw*(fmod(x1,sw)<fmod(x,sw));
    j = y1-(fmod(y1,sh) - fmod(y,sh)) - sh*(fmod(y1,sh)<fmod(y,sh));
    jj = j;

    glBegin(GL_QUADS);
    for(i=i; i<=x2; i+=sw)
    {
      for(j=j; j<=y2; j+=sh)
      {
        if(i <= x1) left = x1-i;
        else left = 0;
        X = i+left;

        if(j <= y1) top = y1-j;
        else top = 0;
        Y = j+top;

        if(x2 <= i+sw) width = ((sw)-(i+sw-x2)+1)-left;
        else width = sw-left;

        if(y2 <= j+sh) height = ((sh)-(j+sh-y2)+1)-top;
        else height = sh-top;

        glTexCoord2f(left/sw*tbx,top/sh*tby);
          glVertex2f(X,Y);
        glTexCoord2f((left+width)/sw*tbx,top/sh*tby);
          glVertex2f(X+width,Y);
        glTexCoord2f((left+width)/sw*tbx,(top+height)/sh*tby);
          glVertex2f(X+width,Y+height);
        glTexCoord2f(left/sw*tbx,(top+height)/sh*tby);
          glVertex2f(X,Y+height);
      }
      j = jj;
    }
    glEnd();
  glPopAttrib();
}
Exemple #14
0
void draw_surface_tiled_area_ext(int id, gs_scalar x, gs_scalar y, gs_scalar x1, gs_scalar y1, gs_scalar x2, gs_scalar y2, gs_scalar xscale, gs_scalar yscale, int color, gs_scalar alpha)
{
  get_surface(surf,id);
  texture_use(surf->tex);

  glPushAttrib(GL_CURRENT_BIT);
    glColor4ub(__GETR(color),__GETG(color),__GETB(color),char(alpha*255));

    gs_scalar sw,sh,i,j,jj,left,top,width,height,X,Y;
    sw = surf->width*xscale;
    sh = surf->height*yscale;

    i = x1-(fmod(x1,sw) - fmod(x,sw)) - sw*(fmod(x1,sw)<fmod(x,sw));
    j = y1-(fmod(y1,sh) - fmod(y,sh)) - sh*(fmod(y1,sh)<fmod(y,sh));
    jj = j;

    glBegin(GL_QUADS);
    for(; i<=x2; i+=sw)
    {
      for(; j<=y2; j+=sh)
      {
        if(i <= x1) left = x1-i;
        else left = 0;
        X = i+left;

        if(j <= y1) top = y1-j;
        else top = 0;
        Y = j+top;

        if(x2 <= i+sw) width = ((sw)-(i+sw-x2)+1)-left;
        else width = sw-left;

        if(y2 <= j+sh) height = ((sh)-(j+sh-y2)+1)-top;
        else height = sh-top;

        glTexCoord2f(left/sw,top/sh);
          glVertex2f(X,Y);
        glTexCoord2f((left+width)/sw,top/sh);
          glVertex2f(X+width,Y);
        glTexCoord2f((left+width)/sw,(top+height)/sh);
          glVertex2f(X+width,Y+height);
        glTexCoord2f(left/sw,(top+height)/sh);
          glVertex2f(X,Y+height);
      }
      j = jj;
    }
    glEnd();
  glPopAttrib();
}
void draw_surface_tiled_area(int id,double x,double y,double x1,double y1,double x2,double y2)
{
  get_surface(surf,id);
  texture_use(surf->tex);

  glPushAttrib(GL_CURRENT_BIT);
    glColor4f(1,1,1,1);

    float sw,sh,i,j,jj,left,top,width,height,X,Y;
    sw = surf->width;
    sh = surf->height;

    i = x1-(fmod(x1,sw) - fmod(x,sw)) - sw*(fmod(x1,sw)<fmod(x,sw));
    j = y1-(fmod(y1,sh) - fmod(y,sh)) - sh*(fmod(y1,sh)<fmod(y,sh));
    jj = j;

    glBegin(GL_QUADS);
    for(i=i; i<=x2; i+=sw)
    {
      for(j=j; j<=y2; j+=sh)
      {
        if(i <= x1) left = x1-i;
        else left = 0;
        X = i+left;

        if(j <= y1) top = y1-j;
        else top = 0;
        Y = j+top;

        if(x2 <= i+sw) width = ((sw)-(i+sw-x2)+1)-left;
        else width = sw-left;

        if(y2 <= j+sh) height = ((sh)-(j+sh-y2)+1)-top;
        else height = sh-top;

        glTexCoord2f(left/sw,top/sh);
          glVertex2f(X,Y);
        glTexCoord2f((left+width)/sw,top/sh);
          glVertex2f(X+width,Y);
        glTexCoord2f((left+width)/sw,(top+height)/sh);
          glVertex2f(X+width,Y+height);
        glTexCoord2f(left/sw,(top+height)/sh);
          glVertex2f(X,Y+height);
      }
      j = jj;
    }
    glEnd();
  glPopAttrib();
}
Exemple #16
0
void draw_surface_stretched(int id, gs_scalar x, gs_scalar y, gs_scalar w, gs_scalar h)
{
  get_surface(surf,id);
  texture_use(surf->tex);
  glPushAttrib(GL_CURRENT_BIT);
  glColor4f(1,1,1,1);

  glBegin(GL_QUADS);
    glTexCoord2f(0,0);      glVertex2f(x,y);
    glTexCoord2f(1,0);      glVertex2f(x+w,y);
    glTexCoord2f(1,1);      glVertex2f(x+w,y+h);
    glTexCoord2f(0,1);      glVertex2f(x,y+h);
  glEnd();

  glPopAttrib();
}
Exemple #17
0
void draw_sprite_stretched(int spr, int subimg, gs_scalar x, gs_scalar y, gs_scalar width, gs_scalar height)
{
    get_spritev(spr2d,spr);
    const int usi = subimg >= 0 ? (subimg % spr2d->subcount) : int(((enigma::object_graphics*)enigma::instance_event_iterator->inst)->image_index) % spr2d->subcount;
    texture_use(GmTextures[spr2d->texturearray[usi]]->gltex);

    const gs_scalar tbx = spr2d->texbordxarray[usi], tby = spr2d->texbordyarray[usi],
                xvert1 = x-spr2d->xoffset, xvert2 = xvert1 + width,
                yvert1 = y-spr2d->yoffset, yvert2 = yvert1 + height;

    const gs_scalar data[4*8] = {
         xvert1, yvert1, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0,
         xvert2, yvert1, tbx, 0.0, 1.0, 1.0, 1.0, 1.0,
         xvert2, yvert2, tbx, tby, 1.0, 1.0, 1.0, 1.0,
         xvert1, yvert2, 0.0, tby, 1.0, 1.0, 1.0, 1.0
    };
    plane2D_rotated(data);
}
Exemple #18
0
void draw_surface(int id, gs_scalar x, gs_scalar y)
{
  get_surface(surf,id);
  texture_use(surf->tex);
  glPushAttrib(GL_CURRENT_BIT);
  glColor4f(1,1,1,1);
  int w=surf->width;
  int h=surf->height;

  glBegin(GL_QUADS);
  glTexCoord2f(0, 0);    glVertex2f(x,   y);
  glTexCoord2f(1, 0);    glVertex2f(x+w, y);
  glTexCoord2f(1, 1);    glVertex2f(x+w, y+h);
  glTexCoord2f(0, 1);    glVertex2f(x,   y+h);
  glEnd();

  glPopAttrib();
}
Exemple #19
0
void draw_sprite_part(int spr, int subimg, gs_scalar left, gs_scalar top, gs_scalar width, gs_scalar height, gs_scalar x, gs_scalar y)
{
    get_spritev(spr2d,spr);
    const int usi = subimg >= 0 ? (subimg % spr2d->subcount) : int(((enigma::object_graphics*)enigma::instance_event_iterator->inst)->image_index) % spr2d->subcount;
    texture_use(GmTextures[spr2d->texturearray[usi]]->gltex);

    const gs_scalar tbw = spr2d->width/(float)spr2d->texbordxarray[usi], tbh = spr2d->height/(float)spr2d->texbordyarray[usi],
          tbx1 = left/tbw, tbx2 = tbx1 + width/tbw,
          tby1 = top/tbh, tby2 = tby1 + height/tbh;

    const gs_scalar data[4*8] = {
         x, y, tbx1, tby1, 1.0, 1.0, 1.0, 1.0,
         x+width, y, tbx2, tby1, 1.0, 1.0, 1.0, 1.0,
         x+width, y+height, tbx2, tby2, 1.0, 1.0, 1.0, 1.0,
         x, y+height, tbx1, tby2, 1.0, 1.0, 1.0, 1.0
    };
    plane2D_rotated(data);
}
Exemple #20
0
void draw_background_tiled_ext(int back,double x,double y,double xscale,double yscale,int color,double alpha)
{
    get_background(bck2d,back);
      texture_use(GmTextures[bck2d->texture]->gltex);

    glPushAttrib(GL_CURRENT_BIT);
    glColor4ub(__GETR(color),__GETG(color),__GETB(color),char(alpha*255));

    const float
    tbx = bck2d->texbordx, tby = bck2d->texbordy,
    width_scaled = bck2d->width*xscale, height_scaled = bck2d->height*yscale;

    x = width_scaled-fmod(x,width_scaled);
    y = height_scaled-fmod(y,height_scaled);

    const int
    hortil = int(ceil(room_width/(width_scaled*tbx))) + 1,
    vertil = int(ceil(room_height/(height_scaled*tby))) + 1;

    glBegin(GL_QUADS);
    float xvert1 = -x, xvert2 = xvert1 + width_scaled, yvert1, yvert2;
    for (int i=0; i<hortil; i++)
    {
        yvert1 = -y; yvert2 = yvert1 + height_scaled;
        for (int c=0; c<vertil; c++)
        {
            glTexCoord2f(0,0);
            glVertex2f(xvert1,yvert1);
            glTexCoord2f(tbx,0);
            glVertex2f(xvert2,yvert1);
            glTexCoord2f(tbx,tby);
            glVertex2f(xvert2,yvert2);
            glTexCoord2f(0,tby);
            glVertex2f(xvert1,yvert2);
            yvert1 = yvert2;
            yvert2 += height_scaled;
        }
        xvert1 = xvert2;
        xvert2 += width_scaled;
    }
    glEnd();

    glPopAttrib();
}
Exemple #21
0
void draw_background_tiled(int back,double x,double y)
{
    get_background(bck2d,back);
      texture_use(GmTextures[bck2d->texture]->gltex);
    glPushAttrib(GL_CURRENT_BIT);
    glColor4f(1,1,1,1);

    x = bck2d->width-fmod(x,bck2d->width);
    y = bck2d->height-fmod(y,bck2d->height);

    const float
    tbx = bck2d->texbordx,tby=bck2d->texbordy;

    const int
    hortil = int (ceil(room_width/(bck2d->width*tbx))) + 1,
    vertil = int (ceil(room_height/(bck2d->height*tby))) + 1;

    glBegin(GL_QUADS);
    float xvert1 = -x, xvert2 = xvert1 + bck2d->width, yvert1, yvert2;
    for (int i=0; i<hortil; i++)
    {
        yvert1 = -y; yvert2 = yvert1 + bck2d->height;
        for (int c=0; c<vertil; c++)
        {
            glTexCoord2f(0,0);
            glVertex2f(xvert1,yvert1);
            glTexCoord2f(tbx,0);
            glVertex2f(xvert2,yvert1);
            glTexCoord2f(tbx,tby);
            glVertex2f(xvert2,yvert2);
            glTexCoord2f(0,tby);
            glVertex2f(xvert1,yvert2);
            yvert1 = yvert2;
            yvert2 += bck2d->height;
        }
        xvert1 = xvert2;
        xvert2 += bck2d->width;
    }
    glEnd();

    glPopAttrib();
}
Exemple #22
0
void draw_surface_stretched_ext(int id, gs_scalar x, gs_scalar y, gs_scalar width, gs_scalar height, int color, gs_scalar alpha)
{
  get_surface(surf,id);
  texture_use(surf->tex);

  glPushAttrib(GL_CURRENT_BIT);
    glColor4ub(__GETR(color),__GETG(color),__GETB(color),char(alpha*255));

    glBegin(GL_QUADS);
      glTexCoord2f(0,0);
        glVertex2f(x,y);
      glTexCoord2f(1,0);
        glVertex2f(x+width,y);
      glTexCoord2f(1,1);
        glVertex2f(x+width,y+height);
      glTexCoord2f(0,1);
        glVertex2f(x,y+height);
    glEnd();
  glPopAttrib();
}
void draw_surface_stretched_ext(int id,double x,double y,double w,double h,int color,double alpha)
{
  get_surface(surf,id);
  texture_use(surf->tex);

  glPushAttrib(GL_CURRENT_BIT);
    glColor4ub(__GETR(color),__GETG(color),__GETB(color),char(alpha*255));

    glBegin(GL_QUADS);
      glTexCoord2f(0,0);
        glVertex2f(x,y);
      glTexCoord2f(1,0);
        glVertex2f(x+w,y);
      glTexCoord2f(1,1);
        glVertex2f(x+w,y+h);
      glTexCoord2f(0,1);
        glVertex2f(x,y+h);
    glEnd();
  glPopAttrib();
}
Exemple #24
0
void draw_sprite_part_ext(int spr, int subimg, gs_scalar left, gs_scalar top, gs_scalar width, gs_scalar height, gs_scalar x, gs_scalar y, gs_scalar xscale, gs_scalar yscale, int blend, gs_scalar alpha)
{
    get_spritev(spr2d,spr);
    const int usi = subimg >= 0 ? (subimg % spr2d->subcount) : int(((enigma::object_graphics*)enigma::instance_event_iterator->inst)->image_index) % spr2d->subcount;
    texture_use(GmTextures[spr2d->texturearray[usi]]->gltex);

    const gs_scalar tbw = spr2d->width/(float)spr2d->texbordxarray[usi], tbh = spr2d->height/(float)spr2d->texbordyarray[usi],
          xvert1 = x, xvert2 = xvert1 + width*xscale,
          yvert1 = y, yvert2 = yvert1 + height*yscale,
          tbx1 = left/tbw, tbx2 = tbx1 + width/tbw,
          tby1 = top/tbh, tby2 = tby1 + height/tbh;

    const gs_scalar r = __GETR(blend), g = __GETG(blend), b = __GETB(blend);
    const gs_scalar data[4*8] = {
         xvert1,yvert1, tbx1,tby1, r, g, b, alpha,
         xvert2,yvert1, tbx2,tby1, r, g, b, alpha,
         xvert2,yvert2, tbx2,tby2, r, g, b, alpha,
         xvert1,yvert2, tbx1,tby2, r, g, b, alpha
    };
    plane2D_rotated(data);
}
/**
 * \brief Draw image to the screen.
 * \param[in] x x-coordinate.
 * \param[in] y y-coordinate.
 * \param[in] pic Image filename to draw.
 * \return
 * \note
 */
void R_Draw_Pic (int x, int y, const char *pic)
{
    Texture *tex = texture_get_picture(pic);

    if (!tex) {
        return;
    }

    texture_use(tex->id);

    glBegin (GL_QUADS);
        glTexCoord2f (0.0, 0.0);
        glVertex2i (x, y);
        glTexCoord2f (1.0, 0.0);
        glVertex2i (x + tex->width, y);
        glTexCoord2f (1.0, 1.0);
        glVertex2i (x + tex->width, y + tex->height);
        glTexCoord2f (0.0, 1.0);
        glVertex2i (x, y + tex->height);
    glEnd();
}
Exemple #26
0
void draw_background_stretched(int back, double x, double y, double w, double h)
{
  get_background(bck2d,back);
    texture_use(GmTextures[bck2d->texture]->gltex);

  glPushAttrib(GL_CURRENT_BIT);
  glColor4f(1,1,1,1);

  const float tbx=bck2d->texbordx,tby=bck2d->texbordy;
  glBegin(GL_QUADS);
    glTexCoord2f(0,0);
      glVertex2f(x,y);
    glTexCoord2f(tbx,0);
      glVertex2f(x+w,y);
    glTexCoord2f(tbx,tby);
      glVertex2f(x+w,y+h);
    glTexCoord2f(0,tby);
      glVertex2f(x,y+h);
  glEnd();

  glPopAttrib();
}
Exemple #27
0
void draw_background(int back, double x, double y)
{
  get_background(bck2d,back);
    texture_use(GmTextures[bck2d->texture]->gltex);
// see backgroundstruct and spritestruct are storing the gluint to the texture, and when
  glPushAttrib(GL_CURRENT_BIT);
  glColor4f(1,1,1,1);

  const float tbx=bck2d->texbordx,tby=bck2d->texbordy;
  glBegin(GL_QUADS);
    glTexCoord2f(0,0);
      glVertex2f(x,y);
    glTexCoord2f(tbx,0);
      glVertex2f(x+bck2d->width,y);
    glTexCoord2f(tbx,tby);
      glVertex2f(x+bck2d->width,y+bck2d->height);
    glTexCoord2f(0,tby);
      glVertex2f(x,y+bck2d->height);
  glEnd();

  glPopAttrib();
}
Exemple #28
0
void draw_surface_part(int id, gs_scalar left, gs_scalar top, gs_scalar width, gs_scalar height, gs_scalar x, gs_scalar y)
{
  get_surface(surf,id);
  texture_use(surf->tex);

  glPushAttrib(GL_CURRENT_BIT);
  glColor4f(1,1,1,1);

  const gs_scalar tbw=surf->width,tbh=surf->height;
  glBegin(GL_QUADS);
    glTexCoord2f(left/tbw,top/tbh);
      glVertex2f(x,y);
    glTexCoord2f((left+width)/tbw,top/tbh);
      glVertex2f(x+width,y);
    glTexCoord2f((left+width)/tbw,(top+height)/tbh);
      glVertex2f(x+width,y+height);
    glTexCoord2f(left/tbw,(top+height)/tbh);
      glVertex2f(x,y+height);
  glEnd();

  glPopAttrib();
}
Exemple #29
0
void draw_background_stretched_ext(int back,double x,double y,double w,double h,int color,double alpha)
{
  get_background(bck2d,back);
    texture_use(GmTextures[bck2d->texture]->gltex);

  glPushAttrib(GL_CURRENT_BIT);
    glColor4ub(__GETR(color),__GETG(color),__GETB(color),char(alpha*255));

    const float tbx=bck2d->texbordx, tby=bck2d->texbordy;

    glBegin(GL_QUADS);
      glTexCoord2f(0,0);
        glVertex2f(x,y);
      glTexCoord2f(tbx,0);
        glVertex2f(x+w,y);
      glTexCoord2f(tbx,tby);
        glVertex2f(x+w,y+h);
      glTexCoord2f(0,tby);
        glVertex2f(x,y+h);
    glEnd();
  glPopAttrib();
}
void draw_surface_part(int id,double left,double top,double width,double height,double x,double y)
{
  get_surface(surf,id);
  texture_use(surf->tex);

  glPushAttrib(GL_CURRENT_BIT);
  glColor4f(1,1,1,1);

  const float tbw=surf->width,tbh=surf->height;
  glBegin(GL_QUADS);
    glTexCoord2f(left/tbw,top/tbh);
      glVertex2f(x,y);
    glTexCoord2f((left+width)/tbw,top/tbh);
      glVertex2f(x+width,y);
    glTexCoord2f((left+width)/tbw,(top+height)/tbh);
      glVertex2f(x+width,y+height);
    glTexCoord2f(left/tbw,(top+height)/tbh);
      glVertex2f(x,y+height);
  glEnd();

  glPopAttrib();
}