全屏幕窗口的创建实验报告

上传人:nu****n 文档编号:157440775 上传时间:2022-09-29 格式:DOC 页数:8 大小:36.52KB
返回 下载 相关 举报
全屏幕窗口的创建实验报告_第1页
第1页 / 共8页
全屏幕窗口的创建实验报告_第2页
第2页 / 共8页
全屏幕窗口的创建实验报告_第3页
第3页 / 共8页
点击查看更多>>
资源描述
实验四实验报告课程:全屏幕窗口的创建班级:2010级远程教育班专业:教育技术学(远程教育方向)实验人:XXX学号:实验时间:实验室:数字媒体实验室指导老师:XXX一、实验目的1.熟悉窗口基本创建;2.学会对窗口模式改为全屏模式;3.熟悉全屏窗口的创建;二、实验任务1.创建全屏窗口模式;三、 实验过程1. 源代码为:#include #include #include / define the screen resolution(定义屏幕分辨率)#define SCREEN_WIDTH 800#define SCREEN_HEIGHT 600/ include the Direct3D Library 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 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 hPrevInstance, 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_OVERLAPPEDWINDOW为窗口模式/ 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_HEIGHT, / 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)break;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 DefWindowProc (hWnd, message, wParam, lParam);/ this function initializes and prepares Direct3D for use(该函数初始化和准备使用的装置)void initD3D(HWND hWnd)d3d = Direct3DCreate9(D3D_SDK_VERSION); / create the Direct3D interfaceD3DPRESENT_PARAMETERS d3dpp; / create a struct to hold various device information把TRUE改为FALSEZeroMemory(&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 back 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(创建一个类使用此信息和信息从d3dpp stuct)d3d-CreateDevice(D3DADAPTER_DEFAULT,D3DDEVTYPE_HAL,hWnd,D3DCREATE_SOFTWARE_VERTEXPROCESSING,&d3dpp,&d3ddev);/ this is the function used to render a single frame(这个函数用来渲染一帧)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-Release(); / close and release the 3D deviced3d-Release(); / close and release Direct3D2. 运行结果为:四、实验总结之前已经对d3d窗口的创建有所熟悉,其实,全屏窗口的创建只是在d3d窗口的基础上,改一些代码就可以啦。学会窗口的创建是学习动画制作的基础,所以有必要把其弄懂,有助于以后的学习。
展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 管理文书 > 工作总结


copyright@ 2023-2025  zhuangpeitu.com 装配图网版权所有   联系电话:18123376007

备案号:ICP2024067431-1 川公网安备51140202000466号


本站为文档C2C交易模式,即用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知装配图网,我们立即给予删除!