




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、实验四实验报告课程:全屏幕窗口的创建班级:2010级远程教育班专业:教育技术学(远程教育方向)实验人:XXX学号:实验时间:实验室:数字媒体实验室指导老师:XXX一、实验目的1.熟悉窗口基本创建;2.学会对窗口模式改为全屏模式;3.熟悉全屏窗口的创建;二、实验任务1.创建全屏窗口模式;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(该函数初始化和准备使用的装置)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(创建一个类使用此信息和信息从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(这个函数用来渲染一帧)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. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 流动货摊社会媒体营销策略考核试卷
- 生物质能源在城乡一体化能源规划中的应用考核试卷
- 宽带接入技术考核试卷
- 电容器在铁路信号系统中的信号放大技术考核试卷
- 皮革服装设计与消费者需求分析考核试卷
- 灯具的博物馆与展览照明设计考核试卷
- 文化展览创意实践探讨考核试卷
- 医疗设备租赁设备租赁合同范本考核试卷
- 2025届福建省惠安一中等三校中学高考模拟考试(二)数学试题
- 2025二月份深基坑水平支撑拆除劳务安全协议
- 2024年河北高中学业合格性考试历史试题(含答案)
- 专题26 实验与探究 十年(2015 2024)高考生物真题分类汇编(全国) (解析版)
- 胃癌患者的营养及饮食护理
- 有限空间安全技术交底
- 2024年第三届浙江技能大赛(电工赛项)理论考试题库(含答案)
- 2024年度-工程造价培训课件全新
- 高标准农田跟踪审计、工程中间计量、变更价格调整及竣工结算审核项目投标方案(技术方案)
- 竣工结算审计服务投标方案(技术方案)
- 2023-2024学年江苏省徐州市铜山区高二(下)期中数学试卷(含答案)
- 多塔作业安全专项方案
- 第八章+机械能守恒定律+单元教学设计及案例分析+课件-+物理人教版(2019)必修第二册
评论
0/150
提交评论