////////////////////////////////////////////////////////////// // // File: WinMainApp.cpp // Author :hsg (c) All Rights Reserved // System: // 功能:启动应用程序入口 类 // ////////////////////////////////////////////////////////////// #pragma once #include "WinMainApp.h" #include "d3dFrameWork.h" #include "d3dFrameWork_cube.h" #include "d3dFrameWork_teapot.h" #include "d3dFrameWork_triangle.h" #include "d3dFrameWork_d3dxcreate.h" #include "d3dFrameWork_colorTriangle.h" //全局变量 d3dFrameWork* DxFW; //指针 //入口点 int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nShowCmd) { //初始化框架类 //第1节 //DxFW=new d3dFrameWork(); //第2节 (无) //第3节 //DxFW=new d3dFrameWork_cube(); //DxFW=new d3dFrameWork_teapot(); //DxFW=new d3dFrameWork_triangle(); DxFW=new d3dFrameWork_d3dxcreate(); //第4节 //DxFW=new d3dFrameWork_colorTriangle(); // 提示用户选择运行模式 bool windowed=true; //窗体模式 if (::MessageBox(0,"Would You Like To Run In Fullscreen Mode?", "Start FullScreen?",MB_YESNO|MB_ICONQUESTION)==IDNO) { //窗体模式 windowed=true; } else { //全屏模式 windowed=false; } int Width=640; //窗体大小 int Height=480; DxFW->Width =Width; DxFW->Height =Height; ::MessageBox(0,"开始初始化InitD3D()","提示",0); if(!d3d::InitD3D(hInstance,Width,Height,windowed,D3DDEVTYPE_HAL,&DxFW->Device)) { ::MessageBox(0,"InitD3D()-失败",0,0); return 0; } //启动操作 if(!DxFW->Setup()) { ::MessageBox(0,"Setup()-失败",0,0); return 0; } //进行消息循环 MSG msg; ::ZeroMemory(&msg,sizeof(MSG)); static float lastTime=(float)timeGetTime(); while(msg.message !=WM_QUIT) { //不是退出系统消息 if(::PeekMessage(&msg,0,0,0,PM_REMOVE)) { ::TranslateMessage(&msg); ::DispatchMessage(&msg); } else { float currTime=(float)timeGetTime(); float timeDelta=(currTime-lastTime)*0.001f; DxFW->Display(timeDelta); lastTime=currTime; } } //退出操作 DxFW->Cleanup(); return 0; }
转载于:https://www.cnblogs.com/sqlite3/archive/2009/07/22/2566960.html