- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
有人能找出这个代码部分的缺陷吗?我花了几个小时试图弄清楚它有什么问题。我基本上在基本的 directx 应用程序上恢复了巨大的滞后,有人能向我解释什么是错误的以及为什么会导致它吗.
#include <Windows.h>
#include <d3d9.h>
// Function Prototypes
LRESULT CALLBACK MsgProc(HWND Wnd,UINT message,WPARAM wParam,LPARAM lParam);
INT CreateAndRegisterWindow(HINSTANCE hInst);
INT initilizeD3D(HWND hWnd);
VOID Render();
//Globals
HWND GlobalWindowHandle;
LPDIRECT3D9 lpD3D9;
LPDIRECT3DDEVICE9 lpD3DDevice9;
const wchar_t ClassName[] = L"Tutorial";
//Entry Point
INT WINAPI WinMain(HINSTANCE hInst,HINSTANCE hPrevInst,LPSTR lpCmdLine,INT CmdShow)
{
// Register the window class
WNDCLASSEX wc =
{
sizeof( WNDCLASSEX ), CS_CLASSDC, MsgProc, 0L, 0L,
GetModuleHandle( NULL ), NULL, NULL, NULL, NULL,
L"D3D Tutorial", NULL
};
RegisterClassEx( &wc );
// Create the application's window
GlobalWindowHandle = CreateWindow( L"D3D Tutorial", L"D3D Tutorial 01: CreateDevice",
WS_OVERLAPPEDWINDOW, 100, 100, 300, 300,
NULL, NULL, wc.hInstance, NULL );
initilizeD3D(GlobalWindowHandle);
ShowWindow(GlobalWindowHandle,SW_SHOW);
UpdateWindow(GlobalWindowHandle);
MSG msg;
while(GetMessage(&msg,NULL,NULL,NULL))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
INT CreateAndRegisterWindow(HINSTANCE hInst)
{
WNDCLASSEX wcex;
ZeroMemory(&wcex, sizeof(wcex));
wcex.cbSize = sizeof(WNDCLASSEX);
wcex.hbrBackground = (HBRUSH)COLOR_WINDOW;
wcex.hCursor = LoadCursor(0,IDC_ARROW);
wcex.hInstance = hInst;
wcex.lpfnWndProc = (WNDPROC)MsgProc;
wcex.lpszClassName = ClassName;
if(FAILED(RegisterClassEx(&wcex)))
{
MessageBoxA(GetForegroundWindow(),"Failed to register class.","Error",MB_ICONERROR);
return EXIT_FAILURE;
}
GlobalWindowHandle = CreateWindow(ClassName,L"Tutorial",WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,CW_USEDEFAULT,300,350,NULL,NULL,0,NULL);
if(!GlobalWindowHandle)
MessageBoxA(GetForegroundWindow(),"Failed to create window.","Error",MB_ICONERROR);
return EXIT_SUCCESS;
}
LRESULT CALLBACK MsgProc(HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam)
{
switch(msg)
{
case WM_PAINT:
UpdateWindow(hWnd);
Render();
return 0;
case WM_DESTROY:
PostQuitMessage(EXIT_SUCCESS);
return 0;
}
return DefWindowProc(hWnd,msg,wParam,lParam);
}
INT initilizeD3D(HWND hWnd)
{
if(NULL==(lpD3D9 = Direct3DCreate9(D3D_SDK_VERSION)))
MessageBoxA(GetForegroundWindow(),"Failed to create direct3d device","Error",MB_ICONERROR);
D3DPRESENT_PARAMETERS d3dpp;
ZeroMemory(&d3dpp, sizeof(d3dpp));
d3dpp.Windowed = TRUE;
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dpp.BackBufferFormat = D3DFMT_UNKNOWN;
if(FAILED(lpD3D9->CreateDevice (D3DADAPTER_DEFAULT,D3DDEVTYPE_HAL,hWnd,D3DCREATE_SOFTWARE_VERTEXPROCESSING,&d3dpp,&lpD3DDevice9)))
return EXIT_FAILURE;
return EXIT_SUCCESS;
}
VOID Render()
{
if( NULL == lpD3DDevice9 )
return;
// Clear the backbuffer to a blue color
lpD3DDevice9->Clear( 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB( 0, 0, 255 ), 1.0f, 0 );
// Begin the scene
if( SUCCEEDED( lpD3DDevice9->BeginScene() ) )
{
// Rendering of scene objects can happen here
// End the scene
lpD3DDevice9->EndScene();
}
// Present the backbuffer contents to the display
lpD3DDevice9->Present( NULL, NULL, NULL, NULL );
}
最佳答案
UpdateWindow
导致 WM_PAINT
再次触发。
另请查看:https://gamedev.stackexchange.com/questions/12901/wm-paint-and-direct3d
关于c++ - 发现缺陷 c++ 代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9281041/
我的 slideToggle 在幻灯片切换的底部有点跳动。会不会是因为那里有一个按钮之类的。任何使它更平滑的方法。尝试使用缓动但不是很成功。有什么建议 点击视频设置自己看看 The site $(do
按照目前的情况,这个问题不适合我们的问答形式。我们希望答案得到事实、引用或专业知识的支持,但这个问题可能会引发辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visit the
概述: 我的 B 对象是一个 100 000 * 5000 的 2 GB 大矩阵 我的 A 对象较小 1000 * 5000 analyse_with_glm <- function(Y) { c
关闭。这个问题是opinion-based .它目前不接受答案。 想改善这个问题吗?更新问题,以便可以通过 editing this post 用事实和引文回答问题. 6年前关闭。 Improve t
我在从 SQL Server (2008R2) 数据库中的 NVARCHAR 字段检索加密数据时遇到了问题,对于某些记录,我的 C# .NET 应用程序中数据的字符串值与数据库记录中的数据字符串值不同
我从 main.cpp 中包含两个头文件,它们在匿名命名空间中具有以下定义:const string strToken = ("%");使用 g++ 4.9 版编译结果如下: In file incl
我正在测试的代码中出现信任边界冲突。该代码在 session 中添加表单,并且由于违反信任边界而存在缺陷 Inside Struts Action class execute method { Ed
这个问题没有与之相关的实际问题,它更多的是一个好奇的问题,想知道我是否过于字面意思;)。 所以我一直在努力尽可能多地理解 c++ 标准。今天,在深入研究标准时,我注意到了这一点 (ISO/IEC 14
在我的数据库中,我必须做一个Circular Reference(cycle)来获取我想要的数据,我不知道如何重新排序表来获取我想要的数据而不需要循环. 这是我的数据库的模式(或模型)——只有表名是英
我有一个代表一组数字的类。构造函数接受三个参数: startValue 、 endValue 和 stepSize 。 该类负责保存一个列表,其中包含考虑 stepSize 的开始值和结束值之间的所有
如何删除下图中标记的三个间隙? 此代码可在 http://jsfiddle.net/69zj6smo/ 获得- 调整渲染区域的大小以查看通常存在的一些线条。 让我感到困惑的是,我认为我总是创建这样的流
double 的位格式在第一位存储符号。 double的C#哈希算法是高低32位二进制异或。 因此,当您对 double A 及其负数 -A 进行哈希处理时,哈希值的唯一区别在于第一位。 要散列多个字
当我在 Action 中使用重定向时,afterAction 方法(在 controller.php 中)不起作用!我该如何解决这个问题? 注意:我不能使用 beforeAction 因为我在我的 A
毫无疑问,还有其他可能更好的方法可以做到这一点,但我正在努力了解这里发生了什么。 在下面的示例中,coverity 在第四行报告了 FORWARD_NULL 缺陷。 double? foo = nul
我们希望针对 Jenkins 中失败的构建自动在 Jira 中创建缺陷。如果您成功完成了此操作,可以与我分享吗? 最佳答案 您应该能够使用JIRA plugin来做到这一点,以及“JIRA:创建问题”
有人能解释一下为什么 VeraCode 似乎认为使用 name 作为公共(public)属性(property)是一个坏主意,并提出了一个好的缓解措施吗? 代码(JavaScript): var Ba
我认为这是 C++11 标准中的一个(次要)缺陷。在 [dcl.dcl] 中我们有: simple-declaration: decl-specifier-seqopt init-
我做了以下... private static IDbConnectionProvider CreateSqlConnectionProvider(DbConfig dbConfig) { r
我现在在运行我的 cakephp 应用程序时遇到了很多麻烦。 在将 vom lenny 升级为 squeeze(甚至尝试完全重新安装 sqeeze)之后,imagick 的速度非常慢,以至于它只是关闭
我收到来自 Veracode 的信任边界违规。我的代码是 userName= req.getParameter(Constant.USERNAME); session.setAttribute(Con
我是一名优秀的程序员,十分优秀!