Пример #1
0
    public virtual int DrawSurface(gxtkSurface surf, float x, float y)
    {
        if (_primType != 4 || _vertCount == MAX_VERTS || _primSurf != surf)
        {
            Flush();
            _primType = 4;
            _primSurf = surf;
        }

        float w = surf.Width();
        float h = surf.Height();
        float u0 = 0, u1 = 1, v0 = 0, v1 = 1;
        float x0 = x, x1 = x + w, x2 = x + w, x3 = x;
        float y0 = y, y1 = y, y2 = y + h, y3 = y + h;

        if (_tformed)
        {
            float tx0 = x0, tx1 = x1, tx2 = x2, tx3 = x3;
            x0 = tx0 * _ix + y0 * _jx + _tx; y0 = tx0 * _iy + y0 * _jy + _ty;
            x1 = tx1 * _ix + y1 * _jx + _tx; y1 = tx1 * _iy + y1 * _jy + _ty;
            x2 = tx2 * _ix + y2 * _jx + _tx; y2 = tx2 * _iy + y2 * _jy + _ty;
            x3 = tx3 * _ix + y3 * _jx + _tx; y3 = tx3 * _iy + y3 * _jy + _ty;
        }

        int i = _vertCount * 2, j = _vertCount;

        _verts[i + 0] = x0; _verts[i + 1] = y0; _texcs[i + 0] = u0; _texcs[i + 1] = v0; _colors[j + 0] = _color;
        _verts[i + 2] = x1; _verts[i + 3] = y1; _texcs[i + 2] = u1; _texcs[i + 3] = v0; _colors[j + 1] = _color;
        _verts[i + 4] = x2; _verts[i + 5] = y2; _texcs[i + 4] = u1; _texcs[i + 5] = v1; _colors[j + 2] = _color;
        _verts[i + 6] = x3; _verts[i + 7] = y3; _texcs[i + 6] = u0; _texcs[i + 7] = v1; _colors[j + 3] = _color;

        _vertCount += 4;

        return(0);
    }
Пример #2
0
    public virtual int DrawSurface2(gxtkSurface surf, float x, float y, int srcx, int srcy, int srcw, int srch)
    {
        if (primType != 4 || primCount == MAX_QUADS || surf.texture != primTex)
        {
            Flush();
            primType = 4;
            primTex  = surf.texture;
        }

        float w = surf.Width();
        float h = surf.Height();
        float u0 = srcx / w, u1 = (srcx + srcw) / w;
        float v0 = srcy / h, v1 = (srcy + srch) / h;
        float x0 = x, x1 = x + srcw, x2 = x + srcw, x3 = x;
        float y0 = y, y1 = y, y2 = y + srch, y3 = y + srch;

        if (tformed)
        {
            float tx0 = x0, tx1 = x1, tx2 = x2, tx3 = x3;
            x0 = tx0 * ix + y0 * jx + tx;
            y0 = tx0 * iy + y0 * jy + ty;
            x1 = tx1 * ix + y1 * jx + tx;
            y1 = tx1 * iy + y1 * jy + ty;
            x2 = tx2 * ix + y2 * jx + tx;
            y2 = tx2 * iy + y2 * jy + ty;
            x3 = tx3 * ix + y3 * jx + tx;
            y3 = tx3 * iy + y3 * jy + ty;
        }

        int vp = primCount++ *4;

        vertices[vp].Position.X          = x0; vertices[vp].Position.Y = y0;
        vertices[vp].TextureCoordinate.X = u0; vertices[vp].TextureCoordinate.Y = v0;
        vertices[vp].Color                   = color;
        vertices[vp + 1].Position.X          = x1; vertices[vp + 1].Position.Y = y1;
        vertices[vp + 1].TextureCoordinate.X = u1; vertices[vp + 1].TextureCoordinate.Y = v0;
        vertices[vp + 1].Color               = color;
        vertices[vp + 2].Position.X          = x2; vertices[vp + 2].Position.Y = y2;
        vertices[vp + 2].TextureCoordinate.X = u1; vertices[vp + 2].TextureCoordinate.Y = v1;
        vertices[vp + 2].Color               = color;
        vertices[vp + 3].Position.X          = x3; vertices[vp + 3].Position.Y = y3;
        vertices[vp + 3].TextureCoordinate.X = u0; vertices[vp + 3].TextureCoordinate.Y = v1;
        vertices[vp + 3].Color               = color;

        return(0);
    }
Пример #3
0
 public c_Image p_Init(gxtkSurface t_surf,int t_nframes,int t_iflags)
 {
     bb_std_lang.pushErr();
     bb_std_lang.errInfo="C:/MonkeyXPro82b/modules/mojo/graphics.monkey<143>";
     if((m_surface)!=null){
         bb_std_lang.errInfo="C:/MonkeyXPro82b/modules/mojo/graphics.monkey<143>";
         bb_std_lang.Error("Image already initialized");
     }
     bb_std_lang.errInfo="C:/MonkeyXPro82b/modules/mojo/graphics.monkey<144>";
     m_surface=t_surf;
     bb_std_lang.errInfo="C:/MonkeyXPro82b/modules/mojo/graphics.monkey<146>";
     m_width=m_surface.Width()/t_nframes;
     bb_std_lang.errInfo="C:/MonkeyXPro82b/modules/mojo/graphics.monkey<147>";
     m_height=m_surface.Height();
     bb_std_lang.errInfo="C:/MonkeyXPro82b/modules/mojo/graphics.monkey<149>";
     m_frames=new c_Frame[t_nframes];
     bb_std_lang.errInfo="C:/MonkeyXPro82b/modules/mojo/graphics.monkey<150>";
     for(int t_i=0;t_i<t_nframes;t_i=t_i+1){
         bb_std_lang.errInfo="C:/MonkeyXPro82b/modules/mojo/graphics.monkey<151>";
         m_frames[t_i]=(new c_Frame()).m_Frame_new(t_i*m_width,0);
     }
     bb_std_lang.errInfo="C:/MonkeyXPro82b/modules/mojo/graphics.monkey<154>";
     p_ApplyFlags(t_iflags);
     bb_std_lang.errInfo="C:/MonkeyXPro82b/modules/mojo/graphics.monkey<155>";
     bb_std_lang.popErr();
     return this;
 }
Пример #4
0
    public virtual int DrawSurface2( gxtkSurface surf,float x,float y,int srcx,int srcy,int srcw,int srch )
    {
        if( primType!=4 || primCount==MAX_QUADS || surf.texture!=primTex ){
            Flush();
            primType=4;
            primTex=surf.texture;
        }

        float w=surf.Width();
        float h=surf.Height();
        float u0=srcx/w,u1=(srcx+srcw)/w;
        float v0=srcy/h,v1=(srcy+srch)/h;
        float x0=x,x1=x+srcw,x2=x+srcw,x3=x;
        float y0=y,y1=y,y2=y+srch,y3=y+srch;

        if( tformed ){
            float tx0=x0,tx1=x1,tx2=x2,tx3=x3;
            x0=tx0 * ix + y0 * jx + tx;
            y0=tx0 * iy + y0 * jy + ty;
            x1=tx1 * ix + y1 * jx + tx;
            y1=tx1 * iy + y1 * jy + ty;
            x2=tx2 * ix + y2 * jx + tx;
            y2=tx2 * iy + y2 * jy + ty;
            x3=tx3 * ix + y3 * jx + tx;
            y3=tx3 * iy + y3 * jy + ty;
        }

        int vp=primCount++*4;

        vertices[vp  ].Position.X=x0;vertices[vp  ].Position.Y=y0;
        vertices[vp  ].TextureCoordinate.X=u0;vertices[vp  ].TextureCoordinate.Y=v0;
        vertices[vp  ].Color=color;
        vertices[vp+1].Position.X=x1;vertices[vp+1].Position.Y=y1;
        vertices[vp+1].TextureCoordinate.X=u1;vertices[vp+1].TextureCoordinate.Y=v0;
        vertices[vp+1 ].Color=color;
        vertices[vp+2].Position.X=x2;vertices[vp+2].Position.Y=y2;
        vertices[vp+2].TextureCoordinate.X=u1;vertices[vp+2].TextureCoordinate.Y=v1;
        vertices[vp+2].Color=color;
        vertices[vp+3].Position.X=x3;vertices[vp+3].Position.Y=y3;
        vertices[vp+3].TextureCoordinate.X=u0;vertices[vp+3].TextureCoordinate.Y=v1;
        vertices[vp+3].Color=color;

        return 0;
    }