游戏开发论坛

 找回密码
 立即注册
搜索
查看: 1409|回复: 0

关于剪切板求助(编译通过了,可一运行就primarysurface Blt error)

[复制链接]

3

主题

7

帖子

7

积分

新手上路

Rank: 1

积分
7
发表于 2004-5-19 16:18:00 | 显示全部楼层 |阅读模式
//////////////////////////////////
//游戏初始化
//////////////////////////////////
int GameInit(void)
{
        //DirectDraw处始化
        MyDirectDrawInit();
        //剪切序列
        RECT rect_list[3] = {{10,10,50,50}, {100,100,200,200},
                    {300,300, 400, 400}};
        //建立剪切区
        if (FAILED(lpDDclip = CreatDDClipper(lpDDback,3,rect_list)))
        {MessageBox(NULL,TEXT("primary surface Blt error!"),                TEXT("primary surface Blt error!Wrong!"),MB_OK);
                return(0);
        }       
        return 0;
}
/////////////////////////////////////////////
//DirectDraw剪切板
/////////////////////////////////////////////
LPDIRECTDRAWCLIPPER CreatDDClipper(LPDIRECTDRAWSURFACE7 lpDDraw,
                                         int Clipnumber,
                                         LPRECT clipsqe)
{
        int index;
        LPDIRECTDRAWCLIPPER lpDDtempclip; //Directdraw剪切板
        LPRGNDATA clipregion;            //剪切区域序列
                                   
        //创建剪切板
        if (FAILED(lpDDraw7->CreateClipper(0,&lpDDtempclip,NULL)))
        {
                MessageBox(NULL,TEXT("DirectDraw Create clipper error!"),
                        TEXT("Wrong!"),MB_OK);
                return(NULL);
        }
       
        //定义剪切区
        clipregion = (LPRGNDATA)malloc(sizeof(RGNDATAHEADER)+Clipnumber*sizeof(RECT));
        memcpy(clipregion->Buffer, clipsqe, sizeof(RECT)*Clipnumber);

        clipregion->rdh.dwSize          = sizeof(RGNDATAHEADER);
        clipregion->rdh.iType           = RDH_RECTANGLES;
        clipregion->rdh.nCount          = Clipnumber;
        clipregion->rdh.nRgnSize        = Clipnumber*sizeof(RECT);
        clipregion->rdh.rcBound.left    =  80000;
        clipregion->rdh.rcBound.top     =  80000;
        clipregion->rdh.rcBound.right   = -80000;
        clipregion->rdh.rcBound.bottom  = -80000;


        for (index=0; index<Clipnumber; index++)
    {
                if (clipsqe[index].left < clipregion->rdh.rcBound.left)
                        clipregion->rdh.rcBound.left = clipsqe[index].left;

                if (clipsqe[index].right > clipregion->rdh.rcBound.right)
                        clipregion->rdh.rcBound.right = clipsqe[index].right;

                if (clipsqe[index].top < clipregion->rdh.rcBound.top)
                        clipregion->rdh.rcBound.top = clipsqe[index].top;

                if (clipsqe[index].bottom > clipregion->rdh.rcBound.bottom)
                        clipregion->rdh.rcBound.bottom = clipsqe[index].bottom;
    }
       
        if (FAILED(lpDDtempclip->SetClipList(clipregion, 0)))
        {
                free(clipregion);
                return(NULL);
        }

        if (FAILED(lpDDraw->SetClipper(lpDDtempclip)))
        {
                free(clipregion);
                return(NULL);
        }

        free(clipregion);
        return(lpDDtempclip);
}
应该是CreatDDClipper这个函数的问题,可我解决不了,大侠们多指点
[em7] [em7] [em7]
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

作品发布|文章投稿|广告合作|关于本站|游戏开发论坛 ( 闽ICP备17032699号-3 )

GMT+8, 2025-7-1 01:05

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表