版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
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. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 盛虹集团秋招题库及答案
- 2023年广西英华国际职业学院单招综合素质考试题库附答案解析
- 2025年北京戏曲艺术职业学院单招职业倾向性考试题库附答案解析
- 2024年青岛恒星科技学院单招职业适应性测试题库附答案解析
- 2023年淮南师范学院单招职业适应性考试模拟测试卷附答案解析
- 圣农控股集团秋招面试题目及答案
- 2024年三亚航空旅游职业学院单招职业倾向性测试模拟测试卷附答案解析
- 2025年伊春职业学院单招职业技能考试题库附答案解析
- 2023年江西工商职业技术学院单招职业技能测试模拟测试卷附答案解析
- 2024年浙江省杭州市单招职业倾向性考试模拟测试卷附答案解析
- 2025中原农业保险股份有限公司招聘67人笔试备考重点试题及答案解析
- 2025中原农业保险股份有限公司招聘67人备考考试试题及答案解析
- 2025年违纪违法典型案例个人学习心得体会
- 2025年度河北省机关事业单位技术工人晋升高级工考试练习题附正确答案
- GB/T 17981-2025空气调节系统经济运行
- 2025 年高职酒店管理与数字化运营(智能服务)试题及答案
- 《公司治理》期末考试复习题库(含答案)
- 药物临床试验质量管理规范(GCP)培训班考核试卷及答案
- 快递行业末端配送流程分析
- 四川专升本《军事理论》核心知识点考试复习题库(附答案)
- 加油站安全生产责任制考核记录
评论
0/150
提交评论