DirectX建立Windows視窗

2021-09-24 20:22:31 字數 3882 閱讀 8345

過程:

winmain

視窗類 -> 註冊視窗類

建立視窗 -> 顯示和更新視窗

訊息迴圈 -> 視窗過程

#include #define window_class "ugpdx"

#define window_title "demo window"

lresult winapi msgproc(hwnd hwnd, uint msg, wparam wparam, lparam lparam)

return defwindowproc(hwnd,msg,wparam,lparam);

}int winapi winmain ( hinstance hinst, hinstance previnst,

lptstr cmdline, int show )

; registerclas***(&wc);

100,100,640,480,getdesktopwindow(),null,hinst,null);

showwindow( hwnd,sw_showdefault );

updatewindow( hwnd );

msg msg;

zeromemory(&msg,sizeof(msg));

while(msg.message != wm_quit) }

unregisterclass(window_class,hinst);

}

建立direct3d視窗

d3d物件  -> idirect3d9

d3d裝置物件 -> idirect3ddevice9

clear()

beginscene()

endscene()

present()//顯示

#include #include #pragma comment(lib,"d3d9.lib")

#pragma comment(lib,"d3dx9.lib")

#define window_class "ugpdx"

#define window_title "demo window"

lpdirect3d9 gd3d = null;

lpdirect3ddevice9 gd3ddevice = null;

bool initialized3d(hwnd hwnd);

void renderscene();

void shutdown();

lresult winapi msgproc(hwnd hwnd, uint msg, wparam wparam, lparam lparam)

return defwindowproc(hwnd,msg,wparam,lparam);

}int winapi winmain ( hinstance hinst, hinstance previnst,

lptstr cmdline, int show )

; registerclas***(&wc);

100,100,640,480,getdesktopwindow(),null,hinst,null);

if(initialized3d(hwnd))

else

}} shutdown();

unregisterclass(window_class,hinst);

} bool initialized3d(hwnd hwnd)

//建立d3d裝置物件

d3dpresent_parameters d3***;

zeromemory(&d3***,sizeof(d3***));

d3***.windowed = true;

d3***.backbufferformat = displaymode.format;

d3***.swapeffect = d3dswapeffect_discard;

if(failed(gd3d->createdevice(d3dadapter_default,d3ddevtype_hal,hwnd,

d3dcreate_hardware_vertexprocessing,&d3***,&gd3ddevice)))

return true;

}void shutdown()

void renderscene()

d3d模版

#include #include #include #pragma comment(lib,"d3d9.lib")

#pragma comment(lib,"d3dx9.lib")

#define window_class "ugpdx"

#define window_title "demo window"

#define window_width 640

#define window_height 480

bool initialized3d(hwnd hwnd, bool fullscreen);

bool initializeobjects();

void renderscene();

void shutdown();

lpdirect3d9 gd3d = null;

lpdirect3ddevice9 gd3ddevice = null;

d3dxmatrix g_projection; //投影變換

d3dxmatrix g_viewmatrix; //檢視變換

d3dxmatrix g_worldmatrix; //世界變換

lresult winapi msgproc(hwnd hwnd, uint msg, wparam wparam, lparam lparam)

return defwindowproc(hwnd,msg,wparam,lparam);

}int winapi winmain ( hinstance hinst, hinstance previnst,

lptstr cmdline, int show )

; registerclas***(&wc);

100,100,640,480,getdesktopwindow(),null,hinst,null);

if(initialized3d(hwnd,false))//false表示不是全屏

else

}} shutdown();

unregisterclass(window_class,hinst);

return 0;

} bool initialized3d(hwnd hwnd,bool fullscreen)

//建立d3d裝置物件

d3dpresent_parameters d3***;

zeromemory(&d3***,sizeof(d3***));

if(fullscreen)

else

d3***.windowed = true;

d3***.backbufferformat = displaymode.format;

d3***.swapeffect = d3dswapeffect_discard;

if(failed(gd3d->createdevice(d3dadapter_default,d3ddevtype_hal,hwnd,

d3dcreate_hardware_vertexprocessing,&d3***,&gd3ddevice)))

if(!initializeobjects())

return false;

return true;

}bool initializeobjects()

void renderscene()

void shutdown()

window服務建立

第一步 建立服務 第二步 在service1.cs檢視中 右鍵 選擇 新增安裝程式 這裡要注意幾個細節 設定上面的屬性 這兩個分別有屬性,具體網上查使用方式 3 例項 編寫 主要下面幾個方法 protected override void onstart string args protected ...

window建立軟硬鏈結

硬鏈結指向的是節點,軟鏈結指向的是路徑 最初的檔名與所有的硬鏈結地位是對等的,比如為檔案a建立硬鏈結b c d。那麼a b c d之間只要有乙個檔案未刪除,這個檔案就可通過未刪除的名稱訪問。你也可以認為每個檔案都可認為至少有乙個硬鏈結,就是說a也是乙個硬鏈結。不允許給目錄建立硬鏈結 軟鏈結特性上類似...

建立SVN的Window服務

在cmd中執行這樣的 新增windown 服務 sc create svnserve binpath svnserve.exe的完整路徑 service root 剛才建立的倉庫的路徑 displayname subversion depend tcpip start auto obj nt aut...