2013年11月22日星期五(T3DLIB1剩余---1)

本文详细介绍了T3DLIB图形库中的基本绘制功能,包括等待垂直同步、绘制矩形、水平线和垂直线的方法。这些功能对于实现高效的图形渲染至关重要。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

现在进行T3DLIB的残余。

 

#define  SCREEN_DARKNESS                        0

#define  SCREEN_WHITENESS                       1

#define  SCREEN_SWIPE_X                         2

#define  SCREEN_SWIPE_Y                         3

#define  SCREEN_DISOLVE                         4

#define  SCREEN_SCRUNCH                         5

#define  SCREEN_BLUENESS                        6

#define  SCREEN_REDNESS                         7

#define  SCREEN_GREENNESS                       8

 

 

 

int DDRAW_Interface::DDraw_Wait_For_Vsync()

{

    m_lpdd->WaitForVerticalBlank( DDWAITVB_BLOCKBEGIN, 0 );

    return ( 1 );

}

 

//绘制矩形

int ddraw_math::Draw_Rectangle(int x1, int y1, int x2, int y2, int color, LPDIRECTDRAWSURFACE7 lpdds)

{

    DDBLTFX                   ddbltfx;

    RECT                  fill_area;

 

    DDRAW_INIT_STRUCT( ddbltfx );

    ddbltfx.dwFillColor                             = color;

 

    fill_area.top                                   = y1;

    fill_area.left                                  = x1;

    fill_area.bottom                            = y2;

    fill_area.right                                 = x2;

 

    lpdds->Blt( & fill_area, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, & ddbltfx );

 

    return ( 1 );

   

}

//水平线绘制

void ddraw_math::HLine(int x1, int x2, int y, int color, UCHAR *vbuffer, int lpitch)

{

    int temp;

    if( y > m_max_clip_y || y < m_min_clip_y )

         return;

 

    if( x1 > x2 )

    {

         temp                                   = x1;

         x1                                          = x2;

         x2                                          = temp;

    }

 

    if( x1 > m_max_clip_x || x2 < m_min_clip_x )

         return ;

 

    x1                                              = ( ( x1 < m_min_clip_x ) ? m_min_clip_x : x1 );

    x2                                              = ( ( x2 > m_max_clip_x ) ? m_max_clip_x : x2 );

 

    memset( ( UCHAR * ) ( vbuffer + ( y * lpitch ) + x1 ), ( UCHAR ) color, x2 - x1 + 1 );

 

}

//16位水平线绘制,转换格式+内联汇编

void ddraw_math::HLine16(int x1, int x2, int y, int color, UCHAR *vbuffer, int lpitch)

{

    int               temp;

    USHORT       *   vbuffer2                  = ( USHORT * ) vbuffer;

    lpitch                                          = lpitch >> 1;

 

    if( y > m_max_clip_y || y < m_min_clip_y )

         return;

 

    if( x1 > x2 )

    {

         temp                                   = x1;

         x1                                          = x2;

         x2                                          = temp;

    }

 

    if( x1 > m_max_clip_x || x2 < m_min_clip_x )

         return ;

 

    x1                                              = ( ( x1 < m_min_clip_x ) ? m_min_clip_x : x1 );

    x2                                              = ( ( x2 > m_max_clip_x ) ? m_max_clip_x : x2 );

 

    Mem_Set_WORD( ( vbuffer2 + ( y * lpitch ) + x1 ), color, x2 - x1 + 1 );

 

}

//垂直线绘制

 

void ddraw_math::VLine(int y1, int y2, int x, int color, UCHAR *vbuffer, int lpitch)

{

    UCHAR        *        start_offset;

    int                   index;

    int                   temp;

 

    if( x > m_max_clip_x || x < m_min_clip_x )

         return;

 

    if( y1 > y2 )

    {

         temp                                   = y1;

         y1                                          = y2;

         y2                                          = temp;

    }

 

    if( y1 > m_max_clip_y || y2 < m_min_clip_y )

         return ;

 

    y1                                              = ( ( y1 < m_min_clip_y ) ? m_min_clip_y : y1 );

    y2                                              = ( ( y2 > m_max_clip_y ) ? m_max_clip_y : y2 );

 

    start_offset                                = vbuffer + ( y1 * lpitch ) + x;

 

    for( int index = 0; index <= y2 - y1; index++ )

    {

         * start_offset                              = ( UCHAR ) color;

         start_offset                           += lpitch;

    }

}

//16位垂直线绘制

void ddraw_math::VLine16(int y1, int y2, int x, int color, UCHAR *vbuffer, int lpitch)

{

    USHORT       *        start_offset;

    int                   index;

    int                   temp;

    lpitch                                          = lpitch >> 1;

 

    if( x > m_max_clip_x || x < m_min_clip_x )

         return;

 

    if( y1 > y2 )

    {

         temp                                   = y1;

         y1                                          = y2;

         y2                                          = temp;

    }

 

    if( y1 > m_max_clip_y || y2 < m_min_clip_y )

         return ;

 

    y1                                              = ( ( y1 < m_min_clip_y ) ? m_min_clip_y : y1 );

    y2                                              = ( ( y2 > m_max_clip_y ) ? m_max_clip_y : y2 );

 

    start_offset                                = ( USHORT * )vbuffer + ( y1 * lpitch ) + x;

 

    for( int index = 0; index <= y2 - y1; index++ )

    {

         * start_offset                              = ( UCHAR ) color;

         start_offset                           += lpitch;

    }

}

先进行到这里

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值