- mongodb - 在 MongoDB mapreduce 中,如何展平值对象?
- javascript - 对象传播与 Object.assign
- html - 输入类型 ="submit"Vs 按钮标签它们可以互换吗?
- sql - 使用 MongoDB 而不是 MS SQL Server 的优缺点
我不知道这意味着什么。但这是假设发生的代码。
//=======================================================================================
// d3dApp.cpp by Frank Luna (C) 2008 All Rights Reserved.
//=======================================================================================
#include "d3dApp.h"
#include <stream>
LRESULT CALLBACK
MainWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
static D3DApp* app = 0;
switch( msg )
{
case WM_CREATE:
{
// Get the 'this' pointer we passed to CreateWindow via the lpParam parameter.
CREATESTRUCT* cs = (CREATESTRUCT*)lParam;
app = (D3DApp*)cs->lpCreateParams;
return 0;
}
}
// Don't start processing messages until after WM_CREATE.
if( app )
return app->msgProc(msg, wParam, lParam);
else
return DefWindowProc(hwnd, msg, wParam, lParam);
}
D3DApp::D3DApp(HINSTANCE hInstance)
{
mhAppInst = hInstance;
mhMainWnd = 0;
mAppPaused = false;
mMinimized = false;
mMaximized = false;
mResizing = false;
mFrameStats = L"";
md3dDevice = 0;
mSwapChain = 0;
mDepthStencilBuffer = 0;
mRenderTargetView = 0;
mDepthStencilView = 0;
mFont = 0;
mMainWndCaption = L"D3D10 Application";
md3dDriverType = D3D10_DRIVER_TYPE_HARDWARE;
mClearColor = D3DXCOLOR(0.0f, 0.0f, 1.0f, 1.0f);
mClientWidth = 800;
mClientHeight = 600;
}
D3DApp::~D3DApp()
{
ReleaseCOM(mRenderTargetView);
ReleaseCOM(mDepthStencilView);
ReleaseCOM(mSwapChain);
ReleaseCOM(mDepthStencilBuffer);
ReleaseCOM(md3dDevice);
ReleaseCOM(mFont);
}
HINSTANCE D3DApp::getAppInst()
{
return mhAppInst;
}
HWND D3DApp::getMainWnd()
{
return mhMainWnd;
}
int D3DApp::run()
{
MSG msg = {0};
mTimer.reset();
while(msg.message != WM_QUIT)
{
// If there are Window messages then process them.
if(PeekMessage( &msg, 0, 0, 0, PM_REMOVE ))
{
TranslateMessage( &msg );
DispatchMessage( &msg );
}
// Otherwise, do animation/game stuff.
else
{
mTimer.tick();
if( !mAppPaused )
updateScene(mTimer.getDeltaTime());
else
Sleep(50);
drawScene();
}
}
return (int)msg.wParam;
}
void D3DApp::initApp()
{
initMainWindow();
initDirect3D();
D3DX10_FONT_DESC fontDesc;
fontDesc.Height = 24;
fontDesc.Width = 0;
fontDesc.Weight = 0;
fontDesc.MipLevels = 1;
fontDesc.Italic = false;
fontDesc.CharSet = DEFAULT_CHARSET;
fontDesc.OutputPrecision = OUT_DEFAULT_PRECIS;
fontDesc.Quality = DEFAULT_QUALITY;
fontDesc.PitchAndFamily = DEFAULT_PITCH | FF_DONTCARE;
wcscpy(fontDesc.FaceName, L"Times New Roman");
D3DX10CreateFontIndirect(md3dDevice, &fontDesc, &mFont);
}
void D3DApp::onResize()
{
// Release the old views, as they hold references to the buffers we
// will be destroying. Also release the old depth/stencil buffer.
ReleaseCOM(mRenderTargetView);
ReleaseCOM(mDepthStencilView);
ReleaseCOM(mDepthStencilBuffer);
// Resize the swap chain and recreate the render target view.
HR(mSwapChain->ResizeBuffers(1, mClientWidth, mClientHeight, DXGI_FORMAT_R8G8B8A8_UNORM, 0));
ID3D10Texture2D* backBuffer;
HR(mSwapChain->GetBuffer(0, __uuidof(ID3D10Texture2D), reinterpret_cast<void**>(&backBuffer)));
HR(md3dDevice->CreateRenderTargetView(backBuffer, 0, &mRenderTargetView));
ReleaseCOM(backBuffer);
// Create the depth/stencil buffer and view.
D3D10_TEXTURE2D_DESC depthStencilDesc;
depthStencilDesc.Width = mClientWidth;
depthStencilDesc.Height = mClientHeight;
depthStencilDesc.MipLevels = 1;
depthStencilDesc.ArraySize = 1;
depthStencilDesc.Format = DXGI_FORMAT_D24_UNORM_S8_UINT;
depthStencilDesc.SampleDesc.Count = 1; // multisampling must match
depthStencilDesc.SampleDesc.Quality = 0; // swap chain values.
depthStencilDesc.Usage = D3D10_USAGE_DEFAULT;
depthStencilDesc.BindFlags = D3D10_BIND_DEPTH_STENCIL;
depthStencilDesc.CPUAccessFlags = 0;
depthStencilDesc.MiscFlags = 0;
HR(md3dDevice->CreateTexture2D(&depthStencilDesc, 0, &mDepthStencilBuffer));
HR(md3dDevice->CreateDepthStencilView(mDepthStencilBuffer, 0, &mDepthStencilView));
// Bind the render target view and depth/stencil view to the pipeline.
md3dDevice->OMSetRenderTargets(1, &mRenderTargetView, mDepthStencilView);
// Set the viewport transform.
D3D10_VIEWPORT vp;
vp.TopLeftX = 0;
vp.TopLeftY = 0;
vp.Width = mClientWidth;
vp.Height = mClientHeight;
vp.MinDepth = 0.0f;
vp.MaxDepth = 1.0f;
md3dDevice->RSSetViewports(1, &vp);
}
void D3DApp::updateScene(float dt)
{
// Code computes the average frames per second, and also the
// average time it takes to render one frame.
static int frameCnt = 0;
static float t_base = 0.0f;
frameCnt++;
// Compute averages over one second period.
if( (mTimer.getGameTime() - t_base) >= 1.0f )
{
float fps = (float)frameCnt; // fps = frameCnt / 1
float mspf = 1000.0f / fps;
std::wostringstream outs;
outs.precision(6);
outs << L"FPS: " << fps << L"\n"
<< "Milliseconds: Per Frame: " << mspf;
mFrameStats = outs.str();
// Reset for next average.
frameCnt = 0;
t_base += 1.0f;
}
}
void D3DApp::drawScene()
{
md3dDevice->ClearRenderTargetView(mRenderTargetView, mClearColor);
md3dDevice->ClearDepthStencilView(mDepthStencilView, D3D10_CLEAR_DEPTH|D3D10_CLEAR_STENCIL, 1.0f, 0);
}
LRESULT D3DApp::msgProc(UINT msg, WPARAM wParam, LPARAM lParam)
{
switch( msg )
{
// WM_ACTIVATE is sent when the window is activated or deactivated.
// We pause the game when the window is deactivated and unpause it
// when it becomes active.
case WM_ACTIVATE:
if( LOWORD(wParam) == WA_INACTIVE )
{
mAppPaused = true;
mTimer.stop();
}
else
{
mAppPaused = false;
mTimer.start();
}
return 0;
// WM_SIZE is sent when the user resizes the window.
case WM_SIZE:
// Save the new client area dimensions.
mClientWidth = LOWORD(lParam);
mClientHeight = HIWORD(lParam);
if( md3dDevice )
{
if( wParam == SIZE_MINIMIZED )
{
mAppPaused = true;
mMinimized = true;
mMaximized = false;
}
else if( wParam == SIZE_MAXIMIZED )
{
mAppPaused = false;
mMinimized = false;
mMaximized = true;
onResize();
}
else if( wParam == SIZE_RESTORED )
{
// Restoring from minimized state?
if( mMinimized )
{
mAppPaused = false;
mMinimized = false;
onResize();
}
// Restoring from maximized state?
else if( mMaximized )
{
mAppPaused = false;
mMaximized = false;
onResize();
}
else if( mResizing )
{
// If user is dragging the resize bars, we do not resize
// the buffers here because as the user continuously
// drags the resize bars, a stream of WM_SIZE messages are
// sent to the window, and it would be pointless (and slow)
// to resize for each WM_SIZE message received from dragging
// the resize bars. So instead, we reset after the user is
// done resizing the window and releases the resize bars, which
// sends a WM_EXITSIZEMOVE message.
}
else // API call such as SetWindowPos or mSwapChain->SetFullscreenState.
{
onResize();
}
}
}
return 0;
// WM_EXITSIZEMOVE is sent when the user grabs the resize bars.
case WM_ENTERSIZEMOVE:
mAppPaused = true;
mResizing = true;
mTimer.stop();
return 0;
// WM_EXITSIZEMOVE is sent when the user releases the resize bars.
// Here we reset everything based on the new window dimensions.
case WM_EXITSIZEMOVE:
mAppPaused = false;
mResizing = false;
mTimer.start();
onResize();
return 0;
// WM_DESTROY is sent when the window is being destroyed.
case WM_DESTROY:
PostQuitMessage(0);
return 0;
// The WM_MENUCHAR message is sent when a menu is active and the user presses
// a key that does not correspond to any mnemonic or accelerator key.
case WM_MENUCHAR:
// Don't beep when we alt-enter.
return MAKELRESULT(0, MNC_CLOSE);
// Catch this message so to prevent the window from becoming too small.
case WM_GETMINMAXINFO:
((MINMAXINFO*)lParam)->ptMinTrackSize.x = 200;
((MINMAXINFO*)lParam)->ptMinTrackSize.y = 200;
return 0;
}
return DefWindowProc(mhMainWnd, msg, wParam, lParam);
}
void D3DApp::initMainWindow()
{
WNDCLASS wc;
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc = MainWndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = mhAppInst;
wc.hIcon = LoadIcon(0, IDI_APPLICATION);
wc.hCursor = LoadCursor(0, IDC_ARROW);
wc.hbrBackground = (HBRUSH)GetStockObject(NULL_BRUSH);
wc.lpszMenuName = 0;
wc.lpszClassName = L"D3DWndClassName";
if( !RegisterClass(&wc) )
{
MessageBox(0, L"RegisterClass FAILED", 0, 0);
PostQuitMessage(0);
}
// Compute window rectangle dimensions based on requested client area dimensions.
RECT R = { 0, 0, mClientWidth, mClientHeight };
AdjustWindowRect(&R, WS_OVERLAPPEDWINDOW, false);
int width = R.right - R.left;
int height = R.bottom - R.top;
mhMainWnd = CreateWindow(L"D3DWndClassName", mMainWndCaption.c_str(),
WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, width, height, 0, 0, mhAppInst, this);
if( !mhMainWnd )
{
MessageBox(0, L"CreateWindow FAILED", 0, 0);
PostQuitMessage(0);
}
ShowWindow(mhMainWnd, SW_SHOW);
UpdateWindow(mhMainWnd);
}
void D3DApp::initDirect3D()
{
// Fill out a DXGI_SWAP_CHAIN_DESC to describe our swap chain.
DXGI_SWAP_CHAIN_DESC sd;
sd.BufferDesc.Width = mClientWidth;
sd.BufferDesc.Height = mClientHeight;
sd.BufferDesc.RefreshRate.Numerator = 60;
sd.BufferDesc.RefreshRate.Denominator = 1;
sd.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
sd.BufferDesc.ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED;
sd.BufferDesc.Scaling = DXGI_MODE_SCALING_UNSPECIFIED;
// No multisampling.
sd.SampleDesc.Count = 1;
sd.SampleDesc.Quality = 0;
sd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
sd.BufferCount = 1;
sd.OutputWindow = mhMainWnd;
sd.Windowed = true;
sd.SwapEffect = DXGI_SWAP_EFFECT_DISCARD;
sd.Flags = 0;
// Create the device.
UINT createDeviceFlags = 0;
#if defined(DEBUG) || defined(_DEBUG)
createDeviceFlags |= D3D10_CREATE_DEVICE_DEBUG;
#endif
HR( D3D10CreateDeviceAndSwapChain(
0, //default adapter
md3dDriverType,
0, // no software device
createDeviceFlags,
D3D10_SDK_VERSION,
&sd,
&mSwapChain,
&md3dDevice) );
// The remaining steps that need to be carried out for d3d creation
// also need to be executed every time the window is resized. So
// just call the onResize method here to avoid code duplication.
onResize();
}
最佳答案
一些没有包含保护的包含文件包含自身(直接或间接)。
使用/showIncludes(IDE 项目选项中的“Configuration Properties/C/C++/Advanced/Show Includes”)来获得帮助。
关于c++ - fatal error C1014 : too many include files : depth = 1024,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2582521/
使用Suitecrm 7.9.1 每当我尝试创建销售线索时(即提交创建销售线索表格后),我都会遇到以下错误。 每当我尝试导入csv文件时,都会遇到相同的错误。仅在实时服务器上发生此错误 Fatal e
Closed. This question is not reproducible or was caused by typos。它当前不接受答案。 想改善这个问题吗?更新问题,以便将其作为on-to
我想在QNX上运行GoogleTestLibrary吗? 但是我收到此错误消息? ldd:FATAL: Could not load library libgtest.so.0 首先,我使用make命
尝试编译代码时,IDE 中显示的 fatal error 和非 fatal error 之间的主要区别是什么? 在这两种情况下,编译器都会显示一条错误消息,并且不会编译程序。 fatal error
当一个人试图编译代码时,在 IDE 中显示的 fatal error 和非 fatal error 之间的主要区别是什么? 在这两种情况下,编译器都会显示一条错误消息,并且程序不会被编译。 fatal
这个程序发出app: 2015/10/24 11:28:15 example.go:22: open some-crazy-non-existent-file: no such file or dir
因此,我正在从事一个项目,但是由于不断收到错误和警告,所以我遇到了一个问题。我对PHP还是很陌生,所以要保持柔和。使用PHP 5.5可以正常运行该程序。但是,当我在PHP 5.6中运行该程序时,会收到
在 WiX 安装程序中 - 如何自定义或覆盖 fatal error 对话框 ()?我想显示详细的错误消息而不是默认设置失败消息。 选项: 是否可以在 WiX 中调整 fatal error 对话框的
我正在尝试通过 Android 工具 > 重命名应用程序包 在 eclipse 中重命名我的 android 应用程序包。它正在生成错误说 A Fatal error occurred while p
我正在使用 Ubuntu 13.10 x64,我正在做一些开发人员正在使用 Windows 的项目,我最近将 git config core.eol 更改为“lf”和 core .autocrlf 为
嗯..世界上的每个服务都可以连接到我的动物园管理员,除了 kafka。下面是我在 server.properties 文件中的连接字符串 zk.connect=1.dzk.syd.druid.neo.
我正在 Java EE 7 中尝试一些东西,我已经构建了一个示例应用程序,可以在此处找到 https://github.com/kenparker/moviplex7.git . 在此过程中,我了解到
我正在尝试使用 bitbucket 中的 ssh 克隆我的存储库,但是每当我克隆存储库时,我都会得到: Connection to bitbucket.org closed by remote hos
该代码包括从一系列数字创建一个数组,以及第三个参数,其中它指示数字的步长,如果它的步长为 2,例如它来自 [1,3, 5] 代码工作正常,除非我以负数作为参数传递 step,例如NumberRange
我正在尝试在我的 ubuntu 中运行一个简单的 git pull 命令。直到几天前,它还可以完美地工作。不是它显示致命:无法访问“https://xxxxxx@bitbucket.org/repon
我知道已经有人问过类似的问题。 但是,我认为我的问题是由于我之前犯的一个错误,因此有所不同:让我解释一下。 一切都如我所愿顺利进行: git add . 我本地存储库中的所有文件。 git commi
我在尝试执行 Jenkins 作业时看到错误。 git 版本 1.8.3.1 Jenkins 2.46.2.1-滚动 我尝试将 git 升级到更高版本,但仍然通过关注 How to install l
Image of the output in the browser 我正在离线处理一个项目。我有一个名为 index.php 的文件。 现在我想在可以编辑的浏览器 sp 中启动。 但是当我尝试通过
我正在AWS的Linux机器上运行RServer Studio。 我尝试安装ModelMetrics的依赖项caret,并收到此错误: auc_.cpp:2:10: fatal error: omp.
我似乎没有重复发帖,所以这是详细信息... 当我使用 XOM(XML 对象模型,Java 库)中的非静态方法 Builder.build() 解析文档时,在 Eclipse 控制台中我得到: [Fat
我是一名优秀的程序员,十分优秀!