rt我试图这样做,但不成功,我使用blt画的
晚上把我的代码写出来
thank u
晚上把我的代码写出来
thank u
解决方案 »
- CreateFile打开文件老出错
- wince下隐藏滚动条
- 关于__try __except中的GetExceptionCode和GetExceptionInformation宏?
- 在Edit上输入汉字,如何得到它的32字节的点阵数据!
- 如何得到自己的版本信息?
- 急问,有关ComboBox
- 怎样在edit中添加中文支持?
- CoCreateInstanceEx()函数创建COM+实例时的问题!
- VC和matlab混合编程 matcom 的问题
- 如何在程序中查询access数据中的表的情况,类似sql server 的sysobjects
- wav转换问题
- 我注册了一个本窗口的热键,为什么到了其它窗口里仍然有效呢?
下面是代码,高手帮忙了……
LPDIRECTDRAW7 lpdd = NULL; // directdraw object
LPDIRECTDRAWSURFACE7 lpddsprimary = NULL; // dd primary surface
LPDIRECTDRAWSURFACE7 lpddsback = NULL; // dd back surface
LPDIRECTDRAWPALETTE lpddpal = NULL; // pointer to dd palette
DDSURFACEDESC2 ddsd; // dd surface description data structure
DDBLTFX ddbltfx; // blitter effects
PALETTEENTRY palette[256]; // color paletteBall_Position ball_position;// This function sets up directdraw, surfaces and the palette. // create IDirectDraw interface 7.0 object and test for error
DirectDrawCreateEx(NULL, (void **)&lpdd, IID_IDirectDraw7, NULL); // set cooperation to full screen
lpdd->SetCooperativeLevel(main_window_handle,
DDSCL_FULLSCREEN | DDSCL_ALLOWMODEX |
DDSCL_EXCLUSIVE | DDSCL_ALLOWREBOOT); // set display mode to 640x480x8
lpdd->SetDisplayMode(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BPP,0,0); // clear ddsd and set size
memset(&ddsd, 0, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd); // enable valid fields
ddsd.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT; // set the backbuffer count field to 1
ddsd.dwBackBufferCount = 1; // request a complex, flippable surface
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_COMPLEX | DDSCAPS_FLIP; // create the primary surface
lpdd->CreateSurface(&ddsd, &lpddsprimary, NULL); // set caps to backbuffer surface
ddsd.ddsCaps.dwCaps = DDSCAPS_BACKBUFFER; // get the attached back buffer surface
lpddsprimary->GetAttachedSurface(&ddsd.ddsCaps, &lpddsback); // set palette entries
palette[0].peRed = 0; // black
palette[0].peGreen = 0;
palette[0].peBlue = 0;
palette[0].peFlags = PC_NOCOLLAPSE; palette[1].peRed = 255; // red
palette[1].peGreen = 0;
palette[1].peBlue = 0;
palette[1].peFlags = PC_NOCOLLAPSE; palette[2].peRed = 0; // blue
palette[2].peGreen = 255;
palette[2].peBlue = 0;
palette[2].peFlags = PC_NOCOLLAPSE; palette[3].peRed = 0; // green
palette[3].peGreen = 0;
palette[3].peBlue = 255;
palette[3].peFlags = PC_NOCOLLAPSE; palette[4].peRed = 31; // light green
palette[4].peGreen = 188;
palette[4].peBlue = 40;
palette[4].peFlags = PC_NOCOLLAPSE; palette[5].peRed = 255; // white
palette[5].peGreen = 255;
palette[5].peBlue = 255;
palette[5].peFlags = PC_NOCOLLAPSE; // create the palette object
lpdd->CreatePalette(DDPCAPS_8BIT | DDPCAPS_ALLOW256 |
DDPCAPS_INITIALIZE,
palette,&lpddpal, NULL); // attach the palette to the primary surface
lpddsprimary->SetPalette(lpddpal);
RECT dest_rect; // rectangle coordinates dest_rect.left = bp.x;
dest_rect.top = bp.y;
dest_rect.right = bp.x + bp.side;
dest_rect.bottom = bp.y + bp.side; // fillcolor = white
ddbltfx.dwFillColor = 5; // blit the rectangle
lpddsback->Blt(&dest_rect, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &ddbltfx);