版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、实验四实验报告课程:全屏幕窗口的创建班级:2010级远程教育班专业:教育技术学(远程教育方向)实验人:XXX学号:实验时间:实验室:数字媒体实验室指导老师:XXX一、实验目的1.熟悉窗口基本创建;2.学会对窗口模式改为全屏模式;3.熟悉全屏窗口的创建;二、实验任务1.创建全屏窗口模式;3、 实验过程1. 源代码为:#include <windows.h>#include <windowsx.h>#include <d3d9.h>/ define the screen resolution(定义屏幕分辨率)#define SCREEN_WIDTH 800#de
2、fine 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 init
3、ializes 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(入口点的任何窗
4、口程序)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 = LoadCu
5、rsor(NULL, IDC_ARROW);WS_EX_TOPMOST | WS_POPUP为全屏模式,WS_OVERLAPPEDWINDOW为窗口模式/ wc.hbrBackground = (HBRUSH)COLOR_WINDOW; / not needed any morewc.lpszClassName = L"WindowClass"RegisterClassEx(&wc);hWnd = CreateWindowEx(NULL,L"WindowClass",L"Our Direct3D Program",WS_EX_
6、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(Peek
7、Message(&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
8、 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); / crea
9、te 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.S = D3DS; / discard old framesd3dpp.hDeviceWindow
10、= 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 i
11、nformation 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
12、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(); /
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2026重庆市血液中心非在编采血护士招聘1人模拟试卷含答案详解(基础题)
- 2026年安徽农业大学茶业学院管理助理招聘考前冲刺密卷及参考答案详解(黄金题型)
- 2026年河南省事业单位招聘联考开封市龙亭区考察笔试题库附参考答案详解(典型题)
- 2026四川大学校聘非事业编制岗位招聘14人笔试题库附完整答案详解(名师系列)
- 2026河北石家庄市艺术学校招聘兼职教师16人笔试题库附参考答案详解【典型题】
- 中地国际工程有限公司2027届土建技术员(海外岗)招聘10人模拟试卷及参考答案详解【培优A卷】
- 2026云南楚雄州永仁县教育系统选调校医1人笔试题库【原创题】附答案详解
- 中地国际工程有限公司2027届土建技术员(海外岗)招聘10人笔试题库【名师系列】附答案详解
- 2026江西南昌安义县工投商业管理有限公司第二批招聘工作人员1人模拟试卷【综合卷】附答案详解
- 2026(第四期)广东顺德人资企业管理有限公司招聘14人笔试题库附参考答案详解(精练)
- 2025年茂名港集团有限公司招聘笔试真题
- 2026安徽师范大学专职辅导员招聘3人(第二批)笔试参考题库及答案详解
- 2026年车险查勘定损人员上岗考核试卷及答案
- 成都教科附属2026初一入学语文分班考试真题含答案
- 2026书记员面试题目及答案
- 2026-2027北师大版七(上)数学第一章 丰富的图形世界 单元测试卷
- 2026中煤华利新疆炭素科技有限公司招聘16人笔试历年典型考点题库附带答案详解
- 中国骨科大手术vte预防指南(2025版)
- 肺癌病人营养支持护理
- 2026年江苏省安全员C1证(机械类)考试真题(含答案解析)
- 2026中医养生精益化管理课件
评论
0/150
提交评论