全屏幕窗口的創(chuàng)建實驗報告_第1頁
全屏幕窗口的創(chuàng)建實驗報告_第2頁
全屏幕窗口的創(chuàng)建實驗報告_第3頁
全屏幕窗口的創(chuàng)建實驗報告_第4頁
全屏幕窗口的創(chuàng)建實驗報告_第5頁
已閱讀5頁,還剩3頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領

文檔簡介

1、實驗四實驗報告課程:全屏幕窗口的創(chuàng)建班級:2010級遠程教育班專業(yè):教育技術學(遠程教育方向)實驗人:XXX學號:實驗時間:實驗室:數(shù)字媒體實驗室指導老師:XXX一、實驗目的1.熟悉窗口基本創(chuàng)建;2.學會對窗口模式改為全屏模式;3.熟悉全屏窗口的創(chuàng)建;二、實驗任務1.創(chuàng)建全屏窗口模式;3、 實驗過程1. 源代碼為:#include #include #include / define the screen resolution(定義屏幕分辨率)#define SCREEN_WIDTH 800#define SCREEN_HEIGHT 600/ include the Direct3D Libr

2、ary file#pragma comment (lib, d3d9.lib)/ global declarationsLPDIRECT3D9 d3d; / the pointer to our Direct3D interfaceLPDIRECT3DDEVICE9 d3ddev; / the pointer to the device class/ function prototypesvoid initD3D(HWND hWnd); / sets up and initializes Direct3D(建立和初始化裝置)void render_frame(void); / renders

3、a single framevoid cleanD3D(void); / closes Direct3D and releases memory/ the WindowProc function prototypeLRESULT CALLBACK WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);/ the entry point for any Windows program(入口點的任何窗口程序)int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevIn

4、stance, LPSTR lpCmdLine, int nCmdShow)HWND hWnd;WNDCLASSEX wc;ZeroMemory(&wc, sizeof(WNDCLASSEX);wc.cbSize = sizeof(WNDCLASSEX);wc.style = CS_HREDRAW | CS_VREDRAW;wc.lpfnWndProc = WindowProc;wc.hInstance = hInstance;wc.hCursor = LoadCursor(NULL, IDC_ARROW);WS_EX_TOPMOST | WS_POPUP為全屏模式,WS_OVERLAPPED

5、WINDOW為窗口模式/ wc.hbrBackground = (HBRUSH)COLOR_WINDOW; / not needed any morewc.lpszClassName = LWindowClass;RegisterClassEx(&wc);hWnd = CreateWindowEx(NULL,LWindowClass,LOur Direct3D Program,WS_EX_TOPMOST | WS_POPUP, / 全屏模式的代碼0, 0, / the starting x and y positions should be 0SCREEN_WIDTH, SCREEN_HEIG

6、HT, / set the window to 640 x 480(設置窗口為)NULL,NULL,hInstance,NULL);ShowWindow(hWnd, nCmdShow);/ set up and initialize Direct3DinitD3D(hWnd);/ enter the main loop:MSG msg;while(TRUE)while(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)TranslateMessage(&msg);DispatchMessage(&msg);if(msg.message = WM_QUIT)brea

7、k;render_frame();/ clean up DirectX and COMcleanD3D();return msg.wParam;/ this is the main message handler for the program(這是主要的消息處理程序)LRESULT CALLBACK WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)switch(message)case WM_DESTROY:PostQuitMessage(0);return 0; break;return DefWindowP

8、roc (hWnd, message, wParam, lParam);/ this function initializes and prepares Direct3D for use(該函數(shù)初始化和準備使用的裝置)void initD3D(HWND hWnd)d3d = Direct3DCreate9(D3D_SDK_VERSION); / create the Direct3D interfaceD3DPRESENT_PARAMETERS d3dpp; / create a struct to hold various device information把TRUE改為FALSEZero

9、Memory(&d3dpp, sizeof(d3dpp); / clear out the struct for used3dpp.Windowed = FALSE; / program fullscreen, not windowedd3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; / discard old framesd3dpp.hDeviceWindow = hWnd; / set the window to be used by Direct3Dd3dpp.BackBufferFormat = D3DFMT_X8R8G8B8; / set the b

10、ack buffer format to 32-bitd3dpp.BackBufferWidth = SCREEN_WIDTH; / set the width of the bufferd3dpp.BackBufferHeight = SCREEN_HEIGHT; / set the height of the buffer/ create a device class using this information and the info from the d3dpp stuct(創(chuàng)建一個類使用此信息和信息從d3dpp stuct)d3d-CreateDevice(D3DADAPTER_D

11、EFAULT,D3DDEVTYPE_HAL,hWnd,D3DCREATE_SOFTWARE_VERTEXPROCESSING,&d3dpp,&d3ddev);/ this is the function used to render a single frame(這個函數(shù)用來渲染一幀)void render_frame(void)/ clear the window to a deep blued3ddev-Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0, 40, 100), 1.0f, 0);d3ddev-BeginScene(); / begins the 3D scene/ do 3D rendering on the back buffer hered3ddev-EndScene(); / ends the 3D scened3ddev-Present(NULL, NULL, NULL, NULL); / displays the created frame on the screen/ this is the function that cleans up Direct3D and COM(這是功能,清理裝置和組件)void cleanD3D(void)d3ddev-Re

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經權益所有人同意不得將文件中的內容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
  • 6. 下載文件中如有侵權或不適當內容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論