{"id":107,"date":"2009-11-05T23:00:40","date_gmt":"2009-11-05T15:00:40","guid":{"rendered":"http:\/\/hgc43160.chinaw3.com\/?p=107"},"modified":"2009-11-05T23:00:40","modified_gmt":"2009-11-05T15:00:40","slug":"directdraw7%e5%88%9d%e5%a7%8b%e5%8c%96","status":"publish","type":"post","link":"http:\/\/www.hyzgame.com\/?p=107","title":{"rendered":"DirectDraw7\u521d\u59cb\u5316"},"content":{"rendered":"<p style=\"text-align: left;\">\/\/&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br \/>\n#include &lt;windows.h&gt;<br \/>\n#include &lt;ddraw.h&gt;<br \/>\n#include &lt;io.h&gt;<br \/>\n#include &lt;fcntl.h&gt;<br \/>\n#include &lt;sys\/stat.h&gt;<br \/>\n#pragma hdrstop<\/p>\n<p>\/\/&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<\/p>\n<p>#pragma argsused<\/p>\n<p>#define GAMENAME\u00a0\u00a0\u00a0 &#8220;DirectDraw 7 \u7a97\u53e3\u793a\u4f8b&#8221;<br \/>\n#define ScreenWidth 640<br \/>\n#define ScreenHigh\u00a0 480<br \/>\n#define ScreenColor 32<br \/>\n#define WINDOWSTYLE WS_VISIBLE|WS_THICKFRAME|WS_SYSMENU|WS_MINIMIZEBOX<\/p>\n<p>IDirectDraw\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 *_DirectDraw=NULL;<br \/>\nIDirectDraw7\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 *DirectDraw;<br \/>\nIDirectDrawSurface7 *PrimarySurface;<br \/>\nDDSURFACEDESC2\u00a0\u00a0\u00a0\u00a0\u00a0 ddsd;<\/p>\n<p>bool InitDirectDraw(HWND hwnd)<br \/>\n{<br \/>\nif(DirectDrawCreate(NULL,&amp;_DirectDraw,NULL)!=DD_OK)return(false);<br \/>\nif(_DirectDraw-&gt;QueryInterface(IID_IDirectDraw7,(void **)&amp;DirectDraw)!=DD_OK)<br \/>\n{<br \/>\n_DirectDraw-&gt;Release();<br \/>\nreturn(false);<br \/>\n}<\/p>\n<p>if(DirectDraw-&gt;SetCooperativeLevel(hwnd,DDSCL_EXCLUSIVE|DDSCL_FULLSCREEN)!=DD_OK)<br \/>\n{<br \/>\nDirectDraw-&gt;Release();<br \/>\n_DirectDraw-&gt;Release();<br \/>\nreturn(false);<br \/>\n}<\/p>\n<p>if(DirectDraw-&gt;SetDisplayMode(ScreenWidth,ScreenHigh,ScreenColor,0,0)!=DD_OK)<br \/>\n{<br \/>\nDirectDraw-&gt;Release();<br \/>\n_DirectDraw-&gt;Release();<br \/>\nreturn(false);<br \/>\n}<\/p>\n<p>memset(&amp;ddsd,0,sizeof(DDSURFACEDESC2));<\/p>\n<p>ddsd.dwSize\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 =sizeof(DDSURFACEDESC2);<br \/>\nddsd.dwFlags\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 =DDSD_CAPS;<br \/>\nddsd.ddsCaps.dwCaps\u00a0\u00a0\u00a0\u00a0 =DDSCAPS_PRIMARYSURFACE;<\/p>\n<p>if(DirectDraw-&gt;CreateSurface(&amp;ddsd,&amp;PrimarySurface,NULL)!=DD_OK)<br \/>\n{<br \/>\nDirectDraw-&gt;Release();<br \/>\n_DirectDraw-&gt;Release();<br \/>\nreturn(false);<br \/>\n}<\/p>\n<p>return(true);<br \/>\n}<\/p>\n<p>void CloseDirectDraw()<br \/>\n{<br \/>\nPrimarySurface-&gt;Release();<br \/>\nDirectDraw-&gt;Release();<br \/>\n_DirectDraw-&gt;Release();<br \/>\n}<\/p>\n<p>HWND InitWindow(HINSTANCE hinstance)<br \/>\n{<br \/>\nHWND hwnd;<br \/>\nWNDCLASSEX wc;<\/p>\n<p>wc.cbSize=sizeof(WNDCLASSEX);<br \/>\nwc.style=0;<br \/>\nwc.lpfnWndProc=(WNDPROC)DefWindowProc;<br \/>\nwc.cbClsExtra=0;<br \/>\nwc.cbWndExtra=0;<br \/>\nwc.hInstance=hinstance;<br \/>\nwc.hIcon=LoadIcon(NULL,NULL);<br \/>\nwc.hCursor=LoadCursor(NULL,IDC_ARROW);<br \/>\nwc.hbrBackground=(HBRUSH)COLOR_BACKGROUND;<br \/>\nwc.lpszMenuName=0;<br \/>\nwc.lpszClassName=&#8221;\u7edd\u60c5\u521b\u4f5c\u7fa4&#8221;;<br \/>\nwc.hIconSm=LoadIcon(hinstance,IDI_APPLICATION);<\/p>\n<p>RegisterClassEx(&amp;wc);<br \/>\nhwnd=CreateWindowEx(NULL,&#8221;\u7edd\u60c5\u521b\u4f5c\u7fa4&#8221;,GAMENAME,WINDOWSTYLE,0,0,ScreenWidth,ScreenHigh,0,0,hinstance,0);<\/p>\n<p>ShowWindow(hwnd,SW_SHOWNORMAL);<br \/>\nUpdateWindow(hwnd);<\/p>\n<p>return(hwnd);<br \/>\n}<\/p>\n<p>WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)<br \/>\n{<br \/>\nHWND hwnd;<\/p>\n<p>hwnd=InitWindow(hInstance);<br \/>\nInitDirectDraw(hwnd);<\/p>\n<p>\/\/&#8230;&#8230;&#8230;&#8230;.<\/p>\n<p>CloseDirectDraw();<br \/>\nreturn(0);<br \/>\n}<br \/>\n\/\/&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\/\/&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#038;#82 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[],"class_list":["post-107","post","type-post","status-publish","format-standard","hentry","category-2d"],"_links":{"self":[{"href":"http:\/\/www.hyzgame.com\/index.php?rest_route=\/wp\/v2\/posts\/107","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.hyzgame.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.hyzgame.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.hyzgame.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.hyzgame.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=107"}],"version-history":[{"count":1,"href":"http:\/\/www.hyzgame.com\/index.php?rest_route=\/wp\/v2\/posts\/107\/revisions"}],"predecessor-version":[{"id":108,"href":"http:\/\/www.hyzgame.com\/index.php?rest_route=\/wp\/v2\/posts\/107\/revisions\/108"}],"wp:attachment":[{"href":"http:\/\/www.hyzgame.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=107"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.hyzgame.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=107"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.hyzgame.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=107"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}