游戏开发论坛

 找回密码
 立即注册
搜索
查看: 2734|回复: 2

DirectDraw,??! ??????surfaceMemory??Surface????

[复制链接]

1

主题

2

帖子

0

积分

新手上路

Rank: 1

积分
0
发表于 2011-6-5 07:33:00 | 显示全部楼层 |阅读模式
????:
LPDIRECTDRAW lpDDraw;
struct
{
        int Width;
        int Height;
        int PixelPerLine; //
        LPVOID ScreenColorBits_Ptr;//
        RECT ScreenRect;//
} Context_Screen_Ptr;

void CreateSurfaceFromContextScreen (LPDIRECTDRAWSURFACE * lplpDDSurface)
{
        *lplpDDSurface= NULL;

        DDSURFACEDESC DDSurfaceDesc_temp;
        DDRAW_INIT_STRUCT( DDSurfaceDesc_temp);
        DDSurfaceDesc_temp.dwFlags|= DDSD_HEIGHT;
        DDSurfaceDesc_temp.dwFlags|= DDSD_WIDTH;
        DDSurfaceDesc_temp.dwFlags|= DDSD_PITCH;
        DDSurfaceDesc_temp.dwFlags|= DDSD_LPSURFACE;
        DDSurfaceDesc_temp.dwFlags|= DDSD_CAPS;

        DDSurfaceDesc_temp.dwHeight= Context_Screen_Ptr->Height;
        DDSurfaceDesc_temp.dwWidth= Context_Screen_Ptr->Width;
        DDSurfaceDesc_temp.lPitch= Context_Screen_Ptr-&gtixelPerLine;//??????8?bits
        DDSurfaceDesc_temp.lpSurface= Context_Screen_Ptr->ScreenColorBits_Ptr;
        DDSurfaceDesc_temp.ddsCaps.dwCaps= DDSCAPS_OFFSCREENPLAIN| DDSCAPS_SYSTEMMEMORY;

        if (DD_OK==lpDDraw->CreateSurface ( &DDSurfaceDesc_temp, lplpDDSurface, NULL))
           {  //??CreateSurface??//
                return NULL;
        }
           //....
}
???????????????lpDDraw???????DDraw??????8bits?????????????????????, DDSCL_FULLSCREEN| DDSCL_ALLOWMODEX| DDSCL_EXCLUSIVE| DDSCL_ALLOWREBOOT
??Context_Screen_Ptr?????:
Context_Screen_Ptr->Widtd= 0x00000280  
Context_Screen_Ptr->Height= 0x000001E0  
Context_Screen_Ptr->PixelPerLine= 0x00000280
Context_Screen_Ptr->ScreenColorBits_Ptr= 0xA3E85A0 //??????????surface???

??????CreateSurface???????????, Error 80070057: One or more of the parameters passed to the method are incorrect?
??????drirectdraw?????????????????????????????????????????????

16

主题

280

帖子

280

积分

中级会员

Rank: 3Rank: 3

积分
280
QQ
发表于 2011-6-5 10:17:00 | 显示全部楼层

Re:DirectDraw,??! ??????surfaceMemory??Surface???

// For this example, g_lpDD is a valid IDirectDraw7 interface pointer.

#define WIDTH  64 // in pixels
#define HEIGHT 64
#define DEPTH  3  // in bytes (3bytes == 24 bits)

    HRESULT hr;
    LPVOID  lpSurface  = NULL;
    HLOCAL  hMemHandle = NULL;
    DDSURFACEDESC2 ddsd2;
    LPDIRECTDRAWSURFACE7 lpDDS;

    // Allocate memory for a 64 by 64, 24-bit per pixel buffer.
    // REMEMBER: The application is responsible for freeing this
    //           buffer when it is no longer needed.
    if (lpSurface = malloc((size_t)WIDTH*HEIGHT*DEPTH))
        ZeroMemory(lpSurface, (DWORD)WIDTH*HEIGHT*DEPTH);
    else
        return DDERR_OUTOFMEMORY;

    // Initialize the surface description.
    ZeroMemory(&ddsd2, sizeof(DDSURFACEDESC2));
    ZeroMemory(&ddsd2.ddpfPixelFormat, sizeof(DDPIXELFORMAT));
    ddsd2.dwSize = sizeof(ddsd2);
    ddsd2.dwFlags = DDSD_WIDTH | DDSD_HEIGHT | DDSD_LPSURFACE |
                    DDSD_PITCH | DDSD_PIXELFORMAT | DDSD_CAPS;
    ddsd2.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN |
                           DDSCAPS_SYSTEMMEMORY;
    ddsd2.dwWidth = WIDTH;
    ddsd2.dwHeight= HEIGHT;
    ddsd2.lPitch  = (LONG)DEPTH * WIDTH;
    ddsd2.lpSurface = lpSurface;

    // Set up the pixel format for 24-bit RGB (8-8-8).
    ddsd2.ddpfPixelFormat.dwSize = sizeof(DDPIXELFORMAT);
    ddsd2.ddpfPixelFormat.dwFlags= DDPF_RGB;
    ddsd2.ddpfPixelFormat.dwRGBBitCount = (DWORD)DEPTH*8;
    ddsd2.ddpfPixelFormat.dwRBitMask    = 0x00FF0000;
    ddsd2.ddpfPixelFormat.dwGBitMask    = 0x0000FF00;
    ddsd2.ddpfPixelFormat.dwBBitMask    = 0x000000FF;

    // Create the surface
    hr = g_lpDD->CreateSurface(&ddsd2, &lpDDS, NULL);
    return hr;


sdk?????

1

主题

2

帖子

0

积分

新手上路

Rank: 1

积分
0
 楼主| 发表于 2011-6-6 05:38:00 | 显示全部楼层

Re:DirectDraw,??! ??????surfaceMemory??Surface???

????????Direct SDK???????????????TV??????????????????????????
??????????lpSurfaceMem??????????????????surface,???????????surfaceMem?????surface????????????????????????????????????????????????????
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2025-8-7 22:29

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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