コード例 #1
0
ファイル: GLsurface.cpp プロジェクト: Rexhunter99/enigma-dev
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();
}
コード例 #2
0
ファイル: GLcolors.cpp プロジェクト: JPierreS/enigma-dev
int merge_color(int c1,int c2,double amount)
{
	amount = amount > 1 ? 1 : (amount < 0 ? 0 : amount);
  return (unsigned char)(fabs(__GETR(c1)+(__GETR(c2)-__GETR(c1))*amount))
  |      (unsigned char)(fabs(__GETG(c1)+(__GETG(c2)-__GETG(c1))*amount))<<8
  |      (unsigned char)(fabs(__GETB(c1)+(__GETB(c2)-__GETB(c1))*amount))<<16;
}
コード例 #3
0
ファイル: GL3sprite.cpp プロジェクト: Mushsauce/enigma-dev
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);
}
コード例 #4
0
ファイル: GL3colors.cpp プロジェクト: Heathtech/enigma-dev
void draw_set_color(int color)
{
	if (enigma::currentcolor[0] == __GETR(color) && enigma::currentcolor[1] == __GETG(color) && enigma::currentcolor[2] == __GETB(color)) return;
	oglmgr->ColorFunc();
	enigma::currentcolor[0] = __GETR(color);
	enigma::currentcolor[1] = __GETG(color);
	enigma::currentcolor[2] = __GETB(color);
}
コード例 #5
0
void draw_background_tiled_ext(int back,double x,double y,double xscale,double yscale,int color,double alpha)
{
  get_background(bck2d,back);
  bind_texture(bck2d->texture);

  glPushAttrib(GL_CURRENT_BIT);
    glColor4ub(__GETR(color),__GETG(color),__GETB(color),char(alpha*255));
    const float tbx=bck2d->texbordx,tby=bck2d->texbordy, w=bck2d->width*xscale, h=bck2d->height*yscale;
    const int hortil= int (ceil(room_width/(bck2d->width*tbx))),
        vertil= int (ceil(room_height/(bck2d->height*tby)));
    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(tbx,0);
          glVertex2f((i+1)*w-x,c*h-y);
        glTexCoord2f(tbx,tby);
          glVertex2f((i+1)*w-x,(c+1)*h-y);
        glTexCoord2f(0,tby);
          glVertex2f(i*w-x,(c+1)*h-y);
      }
    }
    glEnd();
  glPopAttrib();
}
コード例 #6
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);
  bind_texture(bck2d->texture);
  
  glPushAttrib(GL_CURRENT_BIT);
  glColor4ub(__GETR(color),__GETG(color),__GETB(color),char(alpha*255));

  const float
    tbx = bck2d->texbordx,  tby = bck2d->texbordy,
    tbw = bck2d->width/tbx, tbh = bck2d->height/tby;

  glBegin(GL_QUADS);
    glTexCoord2f(left/tbw,top/tbh);
      glVertex2f(x,y);
    glTexCoord2f((left+width)/tbw,top/tbh);
      glVertex2f(x+width*xscale,y);
    glTexCoord2f((left+width)/tbw,(top+height)/tbh);
      glVertex2f(x+width*xscale,y+height*yscale);
    glTexCoord2f(left/tbw,(top+height)/tbh);
      glVertex2f(x,y+height*yscale);
  glEnd();

  glPopAttrib();
}
コード例 #7
0
void draw_background_ext(int back,double x,double y,double xscale,double yscale,double rot,int color,double alpha)
{
  get_background(bck2d,back);
  bind_texture(bck2d->texture);

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

    const float tbx=bck2d->texbordx,tby=bck2d->texbordy, w=bck2d->width*xscale, h=bck2d->height*yscale;
    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);
      glTexCoord2f(0,0);
        glVertex2f(ulcx,ulcy);
      glTexCoord2f(tbx,0);
        glVertex2f(ulcx + w*cos(rot), ulcy - w*sin(rot));
      glTexCoord2f(tbx,tby);
        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,tby);
        glVertex2f(ulcx,ulcy);
    glEnd();
  glPopAttrib();
}
コード例 #8
0
ファイル: GLbackground.cpp プロジェクト: DarkAceZ/enigma-dev
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();
}
コード例 #9
0
ファイル: GL3sprite.cpp プロジェクト: Mushsauce/enigma-dev
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);
}
コード例 #10
0
ファイル: GLsurface.cpp プロジェクト: Rexhunter99/enigma-dev
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();
}
コード例 #11
0
ファイル: GLsurface.cpp プロジェクト: Rexhunter99/enigma-dev
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();
}
コード例 #12
0
ファイル: GLEScolors.cpp プロジェクト: DarkAceZ/enigma-dev
void draw_set_color(int color)
{
	enigma::currentcolor[0] = __GETR(color);
	enigma::currentcolor[1] = __GETG(color);
	enigma::currentcolor[2] = __GETB(color);
	glColor4ub(enigma::currentcolor[0],enigma::currentcolor[1],enigma::currentcolor[2],enigma::currentcolor[3]);
}
コード例 #13
0
ファイル: GLd3d.cpp プロジェクト: Heathtech/enigma-dev
void d3d_set_fog_color(int color)
{
   GLfloat fog_color[3];
   fog_color[0] = __GETR(color);
   fog_color[1] = __GETG(color);
   fog_color[2] = __GETB(color);
   glFogfv(GL_FOG_COLOR, fog_color);
}
コード例 #14
0
ファイル: GLEScolors.cpp プロジェクト: DarkAceZ/enigma-dev
int color_get_hue(int c)
{
	int r = __GETR(c),g = __GETG(c),b = __GETB(c);
	int cmpmax = r>g ? (r>b?r:b) : (g>b?g:b);
	if(!cmpmax) return 0;

	double cmpdel = cmpmax - (r<g ? (r<b?r:b) : (g<b?g:b)); //Maximum difference
	double h = (r == cmpmax ? (g-b)/cmpdel : (g==cmpmax ? 2-(r-g)/cmpdel : 4+(r-g)/cmpdel));
	return int((h<0 ? h+6 : h) * 42.5); //42.5 = 60/360*255
}
コード例 #15
0
ファイル: DX9d3d.cpp プロジェクト: qwook/enigma-dev
    bool light_define_direction(int id, gs_scalar dx, gs_scalar dy, gs_scalar dz, int col)
    {
	    int ms;
        if (light_ind.find(id) != light_ind.end())
        {
            ms = (*light_ind.find(id)).second;
            multimap<int,posi>::iterator it = ind_pos.find(ms);
            if (it != ind_pos.end())
                ind_pos.erase(it);
            ind_pos.insert(pair<int,posi>(ms, posi(-dx, -dy, -dz, 0.0f)));
        }
        else
        {
            ms = light_ind.size();
            D3DCAPS9 caps;
			d3dmgr->GetDeviceCaps(&caps);
            if (ms >= caps.MaxActiveLights)
                return false;

            light_ind.insert(pair<int,int>(id, ms));
            ind_pos.insert(pair<int,posi>(ms, posi(-dx, -dy, -dz, 0.0f)));
        }
		
		D3DLIGHT9 light;    // create the light struct

		ZeroMemory(&light, sizeof(light));    // clear out the light struct for use
		light.Type = D3DLIGHT_DIRECTIONAL;    // make the light type 'directional light'
		light.Diffuse = D3DXCOLOR(__GETR(col), __GETR(col), __GETB(col), 1.0f);    // set the light's color
		light.Direction = D3DXVECTOR3(dx, dy, dz);

		d3dmgr->SetLight(ms, &light);    // send the light struct properties to nth light 
		
		D3DMATERIAL9 material;
		ZeroMemory(&material, sizeof(D3DMATERIAL9));
		material.Diffuse = D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f);
		material.Ambient = D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f);

		d3dmgr->SetMaterial(&material);
		
		light_update_positions();
        return true;
    }
コード例 #16
0
ファイル: GLbackground.cpp プロジェクト: DarkAceZ/enigma-dev
void draw_background_general(int back,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)
{
  get_background(bck2d,back);
  texture_use(GmTextures[bck2d->texture]->gltex);

  glPushAttrib(GL_CURRENT_BIT);
    const float
      tbx = bck2d->texbordx,  tby = bck2d->texbordy,
      tbw = bck2d->width/tbx, tbh = bck2d->height/tby,
      w = width*xscale, h = height*yscale;

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

    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 + wcosrot), (ulcy - wsinrot));

      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 + wcosrot), (ulcy - wsinrot));

      glColor4ub(__GETR(c4),__GETG(c4),__GETB(c4),char(a4*255));
      glTexCoord2f(left/tbw,(top+height)/tbh);
        glVertex2f(ulcx,ulcy);
    glEnd();
  glPopAttrib();
}
コード例 #17
0
ファイル: GLbackground.cpp プロジェクト: DarkAceZ/enigma-dev
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();
}
コード例 #18
0
ファイル: DX9d3d.cpp プロジェクト: qwook/enigma-dev
    bool light_define_point(int id, gs_scalar x, gs_scalar y, gs_scalar z, double range, int col)
    {
	    if (range <= 0.0) {
            return false;
        }
        int ms;
        if (light_ind.find(id) != light_ind.end())
        {
            ms = (*light_ind.find(id)).second;
            multimap<int,posi>::iterator it = ind_pos.find(ms);
            if (it != ind_pos.end())
                ind_pos.erase(it);
            ind_pos.insert(pair<int,posi>(ms, posi(x, y, z, 1)));
        }
        else
        {
            ms = light_ind.size();
            D3DCAPS9 caps;
			d3dmgr->GetDeviceCaps(&caps);
            if (ms >= caps.MaxActiveLights)
                return false;

            light_ind.insert(pair<int,int>(id, ms));
            ind_pos.insert(pair<int,posi>(ms, posi(x, y, z, 1)));
        }
		D3DLIGHT9 light;    // create the light struct

		ZeroMemory(&light, sizeof(light));    // clear out the light struct for use
		light.Type = D3DLIGHT_POINT;    // make the light type 'directional light'
		light.Diffuse = D3DXCOLOR(__GETR(col), __GETG(col), __GETB(col), 1.0f);    // set the light's color
		light.Position = D3DXVECTOR3(x, y, z);
		light.Range = range;
		light.Attenuation0 = 1.0f;    // no constant inverse attenuation
		light.Attenuation1 = 0.0f;    // only .125 inverse attenuation
		light.Attenuation2 = 0.0f;    // no square inverse attenuation
	    //light.Phi = D3DXToRadian(360.0f);    // set the outer cone to 360 degrees
		//light.Theta = D3DXToRadian(360.0f);    // set the inner cone to 360 degrees
		light.Falloff = 1.0f;    // use the typical falloff
	
		d3dmgr->SetLight(ms, &light);    // send the light struct properties to nth light 
		
		D3DMATERIAL9 material;
		ZeroMemory(&material, sizeof(D3DMATERIAL9));
		material.Diffuse = D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f);
		material.Ambient = D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f);

		d3dmgr->SetMaterial(&material);
	
		return true;
    }
コード例 #19
0
ファイル: GLsurface.cpp プロジェクト: Rexhunter99/enigma-dev
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();
}
コード例 #20
0
ファイル: GLbackground.cpp プロジェクト: DarkAceZ/enigma-dev
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();
}
コード例 #21
0
ファイル: DX11screen.cpp プロジェクト: qwook/enigma-dev
void screen_redraw()
{
	float color[4];
	
	int clearcolor = ((int)background_color) & 0x00FFFFFF;
	// Setup the color to clear the buffer to.
	color[0] = __GETR(clearcolor);
	color[1] = __GETG(clearcolor);
	color[2] = __GETB(clearcolor);
	color[3] = 1;

	// Clear the back buffer.
	m_deviceContext->ClearRenderTargetView(m_renderTargetView, color);
    
	// Clear the depth buffer.
	m_deviceContext->ClearDepthStencilView(m_depthStencilView, D3D11_CLEAR_DEPTH, 1.0f, 0);
	
	screen_refresh();
}
コード例 #22
0
ファイル: GL3sprite.cpp プロジェクト: Mushsauce/enigma-dev
void draw_sprite_stretched_ext(int spr, int subimg, gs_scalar x, gs_scalar y, gs_scalar width, gs_scalar height, 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 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 r = __GETR(blend), g = __GETG(blend), b = __GETB(blend);
    const gs_scalar data[4*8] = {
         xvert1, yvert1, 0.0, 0.0, r, g, b, alpha,
         xvert2, yvert1, tbx, 0.0, r, g, b, alpha,
         xvert2, yvert2, tbx, tby, r, g, b, alpha,
         xvert1, yvert2, 0.0, tby, r, g, b, alpha
    };
    plane2D_rotated(data);
}
コード例 #23
0
ファイル: GLEScurves.cpp プロジェクト: DarkAceZ/enigma-dev
//The following function is used in other drawing functions for all splines
//it takes 4 points. Two control points which are at the beggining and the end, and the two points which it actually draws through
//in the middle
void draw_spline_part(float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4, int c1, int c2, float a1, float a2)
{
    int col;
    float x, y, al, t = 0, det = 1/(float)pr_curve_detail;
    for (int i=0; i<=pr_curve_detail; i++){

        al = a1 + (a2-a1)*t;

        col = merge_color(c1, c2, t);

        float t2 = t * t, t3 = t2 * t;
        x = 0.5 * ( ( 2.0 * x2 ) + ( -x1 + x3 ) * t + ( 2.0 * x1 - 5.0 * x2 + 4 * x3 - x4 ) * t2 +
        ( -x1 + 3.0 * x2 - 3.0 * x3 + x4 ) * t3 );
        y = 0.5 * ( ( 2.0 * y2 ) + ( -y1 + y3 ) * t + ( 2.0 * y1 - 5.0 * y2 + 4 * y3 - y4 ) * t2 +
        ( -y1 + 3.0 * y2 - 3.0 * y3 + y4 ) * t3 );
        glColor4f(__GETR(col),__GETG(col),__GETB(col),al);
     //   glVertex2f(x, y);
        t += det;
    }
}
コード例 #24
0
ファイル: GLsurface.cpp プロジェクト: Rexhunter99/enigma-dev
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();
}
コード例 #25
0
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();
}
コード例 #26
0
ファイル: GL3sprite.cpp プロジェクト: Mushsauce/enigma-dev
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);
}
コード例 #27
0
ファイル: GLbackground.cpp プロジェクト: DarkAceZ/enigma-dev
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();
}
コード例 #28
0
ファイル: GLsurface.cpp プロジェクト: Rexhunter99/enigma-dev
void draw_surface_part_ext(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, 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 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*xscale,y);
    glTexCoord2f((left+width)/tbw,(top+height)/tbh);
      glVertex2f(x+width*xscale,y+height*yscale);
    glTexCoord2f(left/tbw,(top+height)/tbh);
      glVertex2f(x,y+height*yscale);
  glEnd();

  glPopAttrib();
}
コード例 #29
0
  void particle_system::draw_particlesystem()
  {
    // TODO: Handle different particle shapes.
    // TODO: Draw the particle system either from oldest to youngest or reverse.

    const std::list<particle_instance>::iterator end = pi_list.end();
    for (std::list<particle_instance>::iterator it = pi_list.begin(); it != end; it++)
    {
      particle_type* pt = it->pt;
      // TODO: Use default shape if particle type not alive.
      if (pt->is_particle_sprite) {
        particle_sprite* ps = pt->part_sprite;
        bind_texture(ps->texture);

        glPushAttrib(GL_CURRENT_BIT); // Push 1.

        int color = it->color; // TODO: Alpha can be set.
        glColor4ub(__GETR(color),__GETG(color),__GETB(color),255);
        const float tbx = 1, tby = 1,
          xvert1 = it->x - ps->width/2, xvert2 = it->x + ps->width/2,
          yvert1 = it->y - ps->height/2, yvert2 = it->y + ps->height/2;

        glBegin(GL_QUADS);
        glTexCoord2f(0,0);
        glVertex2f(xvert1,yvert1);
        glTexCoord2f(tbx,0);
        glVertex2f(xvert2,yvert1);
        glTexCoord2f(tbx,tby);
        glVertex2f(xvert2,yvert2);
        glTexCoord2f(0,tby);
        glVertex2f(xvert1,yvert2);
        glEnd();

	glPopAttrib(); // Pop 1.
      }
    }
  }
コード例 #30
0
ファイル: GL3sprite.cpp プロジェクト: Mushsauce/enigma-dev
void draw_sprite_tiled_ext(int spr, int subimg, 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
    tbx  = spr2d->texbordxarray[usi], tby  = spr2d->texbordyarray[usi],
    width_scaled = spr2d->width*xscale, height_scaled = spr2d->height*yscale,
    xoff = fmod(spr2d->xoffset*xscale+x,width_scaled)-width_scaled, yoff = fmod(spr2d->yoffset*yscale+y,height_scaled)-height_scaled;


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

    gs_scalar xvert1 = xoff, xvert2 = xvert1 + width_scaled, yvert1, yvert2;
    const gs_scalar r = __GETR(blend), g = __GETG(blend), b = __GETB(blend);
    for (int i=0; i<hortil; i++)
    {
        yvert1 = yoff; yvert2 = yvert1 + height_scaled;
        for (int c=0; c<vertil; c++)
        {
            const gs_scalar data[4*8] = {
                 xvert1, yvert1, 0.0, 0.0, r, g, b, alpha,
                 xvert2, yvert1, tbx, 0.0, r, g, b, alpha,
                 xvert2, yvert2, tbx, tby, r, g, b, alpha,
                 xvert1, yvert2, 0.0, tby, r, g, b, alpha
            };
            plane2D_rotated(data);
            yvert1 = yvert2;
            yvert2 += height_scaled;
       }
       xvert1 = xvert2;
       xvert2 += width_scaled;
    }
}