MSDN说(扩展窗口样式):
WS_EX_NOREDIRECTIONBITMAP:窗口不会渲染到重定向表面.这适用于没有可见内容或使用表面以外的机制来提供视觉效果的窗口.
在这种情况下,"窗口呈现到重定向表面"与"除表面之外的机制"是什么意思?以下哪一项:GDI,D3D9,D3D11,D3D12算作前者vs后者?我刚刚使用Direct3D绘图时是否应该使用这种扩展窗口样式?
我今天决定尝试使用Visual Studio 2012 Express.首先要写的是"Hello world!" 然而,应用程序,我无法使它工作.我创建了一个Windows控制台应用程序项目,编写了标准代码,导致运行时错误.
这是我的代码:
#include <iostream>
using namespace std;
int main()
{
cout << "Hello world!" << endl;
system("pause");
return 0;
}
Run Code Online (Sandbox Code Playgroud)
看起来有些东西坏了(也许我错过了什么?).它在第7行遇到运行时错误:
http://img443.imageshack.us/img443/7497/coutbroken.png
有什么帮助吗?:)
我想迭代一个整数的所有可能值。此代码不起作用,因为终止条件永远不会变为假:
for (uint32_t i = 0; i <= 0xFFFFFFFF; i++)
std::cout << i << std::endl;
Run Code Online (Sandbox Code Playgroud)
我想出了这个:
auto loopBody = [](uint32_t value)
{
std::cout << value << std::endl;
};
uint32_t last = 0xFFFFFFFF;
for (uint32_t i = 0; i < last; i++)
loopBody(i);
loopBody(last);
Run Code Online (Sandbox Code Playgroud)
不过,它相当丑陋。有没有更漂亮的方法来做到这一点?
我正在做一个Sdl游戏,它是2D射手.我正在使用SDL导入曲面和OpenGL在屏幕上绘制它们(这样做是因为它比SDL更快地工作).我有两个线程正在运行,一个用于处理东西和渲染,另一个用于输入.基本上,处理一个占我CPU的1-2%,而输入循环需要25%(在四核上,所以它是1个全核).我尝试在每个之前做SDL_Delay(1)while (SDL_PollEvent(&keyevent)),它的工作原理!整个过程将CPU负载降低至3%.然而,这是一个令人讨厌的副作用.整个程序的输入是残疾人:它不检测所有按下的键,例如,以使角色移动,有时需要长达扑键盘为它作出反应的3秒.
我也试过用解决它SDL_PeepEvent()和SDL_WaitEvent(),但是,它是造成相同的(很长!)延迟.
事件循环代码:
void GameWorld::Movement()
{
SDL_Event keyevent;
bool x1, x2, y1, y2, z1, z2, z3, m; // Booleans to determine the
x1 = x2 = y1 = y2 = z1 = z2 = z3 = m = 0; // movement direction
SDL_EnableKeyRepeat(0, 0);
while (1)
{
while (SDL_PollEvent(&keyevent))
{
switch(keyevent.type)
{
case SDL_KEYDOWN:
switch(keyevent.key.keysym.sym)
{
case SDLK_LEFT:
x1 = 1;
x2 = 0;
break;
case SDLK_RIGHT:
x1 = 0;
x2 = 1; …Run Code Online (Sandbox Code Playgroud) 我正在将我的代码从 D3D11 移植到 D3D12,并且我试图在 D3D12 上获得显示器的刷新率。我使用刷新率进行精确的动画计时(这是一个硬性要求)。此代码适用于 D3D11:
HRESULT GetRefreshRate(IUnknown* device, IDXGISwapChain* swapChain, double* outRefreshRate)
{
Microsoft::WRL::ComPtr<IDXGIOutput> dxgiOutput;
HRESULT hr = swapChain->GetContainingOutput(&dxgiOutput);
if (FAILED(hr))
return hr;
Microsoft::WRL::ComPtr<IDXGIOutput1> dxgiOutput1;
hr = dxgiOutput.As(&dxgiOutput1);
if (FAILED(hr))
return hr;
DXGI_MODE_DESC1 emptyMode = {};
DXGI_MODE_DESC1 modeDescription;
hr = dxgiOutput1->FindClosestMatchingMode1(&emptyMode, &modeDescription, device);
if (SUCCEEDED(hr))
*outRefreshRate = (double)modeDescription.RefreshRate.Numerator / (double)modeDescription.RefreshRate.Denominator;
return hr;
}
Run Code Online (Sandbox Code Playgroud)
不幸的是,ID3D12Device 没有实现 IDXGIDevice 接口,因此 FindClosestMatchingMode1 失败并出现以下错误:
DXGI ERROR: IDXGIOutput::FindClosestMatchingMode: pConcernedDevice doesn't support the IDXGIDevice interface [ MISCELLANEOUS ERROR #69: ]
Run Code Online (Sandbox Code Playgroud)
使用 D3D12 时有没有办法获取 IDXGIDevice?或者,如何确定 D3D12 …
假设我有这个:
template <typename CharType>
class StringView
{
private:
const CharType* m_String;
size_t m_Length;
public:
template <typename CharTraits, typename StringAlloc>
inline StringView(const std::basic_string<CharType, CharTraits, StringAlloc>& str) :
m_String(str.c_str()), m_Length(str.length())
{
}
inline const CharType* Str() const
{
return m_String;
}
};
Run Code Online (Sandbox Code Playgroud)
有没有办法防止临时施工std::string?那是:
std::string GetStr()
{
return "hello";
}
int main()
{
std::string helloString = "hello";
StringView<char> str1 = helloString; // This is ok
StringView<char> str2 = GetStr(); // I want this to be a compiler error
std::cout << str1.Str() …Run Code Online (Sandbox Code Playgroud)