Skip to content

Commit 84f0a71

Browse files
committed
replace std::cout with std::cerr
1 parent 426cafc commit 84f0a71

File tree

25 files changed

+182
-184
lines changed

25 files changed

+182
-184
lines changed

src/Cpp/1-getting-started/1-1-1-HelloGLFWWindow/Main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ int main(int argc, char* argv[])
66
{
77
if (!glfwInit())
88
{
9-
std::cout << "GLFW: Failed to initialize\n";
9+
std::cerr << "GLFW: Failed to initialize\n";
1010
return -1;
1111
}
1212

@@ -25,7 +25,7 @@ int main(int argc, char* argv[])
2525
nullptr);
2626
if (window == nullptr)
2727
{
28-
std::cout << "GLFW: Failed to create window\n";
28+
std::cerr << "GLFW: Failed to create window\n";
2929
glfwTerminate();
3030
return -1;
3131
}

src/Cpp/1-getting-started/1-1-1-HelloWin32Window/Main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ int main(int argc, char* argv[])
3939
windowClassInfo.hIconSm = LoadIcon(windowClassInfo.hInstance, IDI_APPLICATION);
4040
if (!RegisterClassEx(&windowClassInfo))
4141
{
42-
std::cout << "Failed to register window class\n";
42+
std::cerr << "Failed to register window class\n";
4343
return -1;
4444
}
4545
// Actually creates the window and returns a handle to it
@@ -58,7 +58,7 @@ int main(int argc, char* argv[])
5858
nullptr);
5959
if (windowHandle == nullptr)
6060
{
61-
std::cout << "Failed to create Win32 window\n";
61+
std::cerr << "Failed to create Win32 window\n";
6262
return -1;
6363
}
6464
ShowWindow(windowHandle, SW_NORMAL);

src/Cpp/1-getting-started/1-1-1-HelloWindow/Application.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ bool Application::Initialize()
4444
{
4545
if (!glfwInit())
4646
{
47-
std::cout << "GLFW: Failed to initialize\n";
47+
std::cerr << "GLFW: Failed to initialize\n";
4848
return false;
4949
}
5050

@@ -63,7 +63,7 @@ bool Application::Initialize()
6363
nullptr);
6464
if (_window == nullptr)
6565
{
66-
std::cout << "GLFW: Failed to create a window\n";
66+
std::cerr << "GLFW: Failed to create a window\n";
6767
Cleanup();
6868
return false;
6969
}

src/Cpp/1-getting-started/1-1-2-HelloD3D11-Raw/Main.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ bool CreateSwapchainResources()
3232
0,
3333
IID_PPV_ARGS(&backBuffer))))
3434
{
35-
std::cout << "D3D11: Failed to get Back Buffer from the SwapChain\n";
35+
std::cerr << "D3D11: Failed to get Back Buffer from the SwapChain\n";
3636
return false;
3737
}
3838

@@ -41,7 +41,7 @@ bool CreateSwapchainResources()
4141
nullptr,
4242
&g_RenderTarget)))
4343
{
44-
std::cout << "D3D11: Failed to create RTV from Back Buffer\n";
44+
std::cerr << "D3D11: Failed to create RTV from Back Buffer\n";
4545
return false;
4646
}
4747

@@ -71,7 +71,7 @@ void HandleResize(
7171
DXGI_FORMAT::DXGI_FORMAT_B8G8R8A8_UNORM,
7272
0)))
7373
{
74-
std::cout << "D3D11: Failed to recreate SwapChain buffers\n";
74+
std::cerr << "D3D11: Failed to recreate SwapChain buffers\n";
7575
return;
7676
}
7777

@@ -82,7 +82,7 @@ int main()
8282
{
8383
if (!glfwInit())
8484
{
85-
std::cout << "Unable to initialize GLFW\n";
85+
std::cerr << "Unable to initialize GLFW\n";
8686
return false;
8787
}
8888

@@ -102,7 +102,7 @@ int main()
102102

103103
if (window == nullptr)
104104
{
105-
std::cout << "GLFW: Failed to create window\n";
105+
std::cerr << "GLFW: Failed to create window\n";
106106
glfwTerminate();
107107
return false;
108108
}
@@ -116,7 +116,7 @@ int main()
116116
// This section initializes DirectX's devices and SwapChain
117117
if (FAILED(CreateDXGIFactory1(IID_PPV_ARGS(&g_DxgiFactory))))
118118
{
119-
std::cout << "DXGI: Failed to create factory\n";
119+
std::cerr << "DXGI: Failed to create factory\n";
120120
return false;
121121
}
122122

@@ -134,7 +134,7 @@ int main()
134134
nullptr,
135135
&g_DeviceContext)))
136136
{
137-
std::cout << "D3D11: Failed to create device and device context\n";
137+
std::cerr << "D3D11: Failed to create device and device context\n";
138138
return false;
139139
}
140140

@@ -161,7 +161,7 @@ int main()
161161
nullptr,
162162
&g_SwapChain)))
163163
{
164-
std::cout << "DXGI: Failed to create swapchain\n";
164+
std::cerr << "DXGI: Failed to create swapchain\n";
165165
return false;
166166
}
167167

src/Cpp/1-getting-started/1-1-2-HelloD3D11/HelloD3D11Application.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ bool HelloD3D11Application::Initialize()
4141
// This section initializes DirectX's devices and SwapChain
4242
if (FAILED(CreateDXGIFactory1(IID_PPV_ARGS(&_dxgiFactory))))
4343
{
44-
std::cout << "DXGI: Failed to create factory\n";
44+
std::cerr << "DXGI: Failed to create factory\n";
4545
return false;
4646
}
4747

@@ -59,7 +59,7 @@ bool HelloD3D11Application::Initialize()
5959
nullptr,
6060
&_deviceContext)))
6161
{
62-
std::cout << "D3D11: Failed to create device and device Context\n";
62+
std::cerr << "D3D11: Failed to create device and device Context\n";
6363
return false;
6464
}
6565

@@ -86,7 +86,7 @@ bool HelloD3D11Application::Initialize()
8686
nullptr,
8787
&_swapChain)))
8888
{
89-
std::cout << "DXGI: Failed to create swapchain\n";
89+
std::cerr << "DXGI: Failed to create swapchain\n";
9090
return false;
9191
}
9292

@@ -110,7 +110,7 @@ bool HelloD3D11Application::CreateSwapchainResources()
110110
0,
111111
IID_PPV_ARGS(&backBuffer))))
112112
{
113-
std::cout << "D3D11: Failed to get back buffer from the swapchain\n";
113+
std::cerr << "D3D11: Failed to get back buffer from the swapchain\n";
114114
return false;
115115
}
116116

@@ -119,7 +119,7 @@ bool HelloD3D11Application::CreateSwapchainResources()
119119
nullptr,
120120
&_renderTarget)))
121121
{
122-
std::cout << "D3D11: Failed to create rendertarget view from back buffer\n";
122+
std::cerr << "D3D11: Failed to create rendertarget view from back buffer\n";
123123
return false;
124124
}
125125

@@ -147,7 +147,7 @@ void HelloD3D11Application::OnResize(
147147
DXGI_FORMAT::DXGI_FORMAT_B8G8R8A8_UNORM,
148148
0)))
149149
{
150-
std::cout << "D3D11: Failed to recreate swapchain buffers\n";
150+
std::cerr << "D3D11: Failed to recreate swapchain buffers\n";
151151
return;
152152
}
153153

src/Cpp/1-getting-started/1-1-3-HelloTriangle/HelloTriangleApplication.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ bool HelloTriangleApplication::Initialize()
5555
// This section initializes DirectX's devices and SwapChain
5656
if (FAILED(CreateDXGIFactory1(IID_PPV_ARGS(&_dxgiFactory))))
5757
{
58-
std::cout << "DXGI: Failed to create factory\n";
58+
std::cerr << "DXGI: Failed to create factory\n";
5959
return false;
6060
}
6161

@@ -73,7 +73,7 @@ bool HelloTriangleApplication::Initialize()
7373
nullptr,
7474
&_deviceContext)))
7575
{
76-
std::cout << "D3D11: Failed to create Device and Device Context\n";
76+
std::cerr << "D3D11: Failed to create Device and Device Context\n";
7777
return false;
7878
}
7979

@@ -100,7 +100,7 @@ bool HelloTriangleApplication::Initialize()
100100
nullptr,
101101
&_swapChain)))
102102
{
103-
std::cout << "DXGI: Failed to create SwapChain\n";
103+
std::cerr << "DXGI: Failed to create SwapChain\n";
104104
return false;
105105
}
106106

@@ -154,7 +154,7 @@ bool HelloTriangleApplication::Load()
154154
vertexShaderBlob->GetBufferSize(),
155155
&_vertexLayout)))
156156
{
157-
std::cout << "D3D11: Failed to create default vertex input layout\n";
157+
std::cerr << "D3D11: Failed to create default vertex input layout\n";
158158
return false;
159159
}
160160

@@ -176,7 +176,7 @@ bool HelloTriangleApplication::Load()
176176
&resourceData,
177177
&_triangleVertices)))
178178
{
179-
std::cout << "D3D11: Failed to create triangle vertex buffer\n";
179+
std::cerr << "D3D11: Failed to create triangle vertex buffer\n";
180180
return false;
181181
}
182182

@@ -204,10 +204,10 @@ bool HelloTriangleApplication::CompileShader(
204204
&tempShaderBlob,
205205
&errorBlob)))
206206
{
207-
std::cout << "D3D11: Failed to read shader from file\n";
207+
std::cerr << "D3D11: Failed to read shader from file\n";
208208
if (errorBlob != nullptr)
209209
{
210-
std::cout << "D3D11: With message: " << static_cast<const char*>(errorBlob->GetBufferPointer()) << "\n";
210+
std::cerr << "D3D11: With message: " << static_cast<const char*>(errorBlob->GetBufferPointer()) << "\n";
211211
}
212212

213213
return false;
@@ -233,7 +233,7 @@ HelloTriangleApplication::ComPtr<ID3D11VertexShader> HelloTriangleApplication::C
233233
nullptr,
234234
&vertexShader)))
235235
{
236-
std::cout << "D3D11: Failed to compile vertex shader\n";
236+
std::cerr << "D3D11: Failed to compile vertex shader\n";
237237
return nullptr;
238238
}
239239

@@ -255,7 +255,7 @@ HelloTriangleApplication::ComPtr<ID3D11PixelShader> HelloTriangleApplication::Cr
255255
nullptr,
256256
&pixelShader)))
257257
{
258-
std::cout << "D3D11: Failed to compile pixel shader\n";
258+
std::cerr << "D3D11: Failed to compile pixel shader\n";
259259
return nullptr;
260260
}
261261

@@ -269,7 +269,7 @@ bool HelloTriangleApplication::CreateSwapchainResources()
269269
0,
270270
IID_PPV_ARGS(&backBuffer))))
271271
{
272-
std::cout << "D3D11: Failed to get Back Buffer from the SwapChain\n";
272+
std::cerr << "D3D11: Failed to get Back Buffer from the SwapChain\n";
273273
return false;
274274
}
275275

@@ -278,7 +278,7 @@ bool HelloTriangleApplication::CreateSwapchainResources()
278278
nullptr,
279279
&_renderTarget)))
280280
{
281-
std::cout << "D3D11: Failed to create RTV from Back Buffer\n";
281+
std::cerr << "D3D11: Failed to create RTV from Back Buffer\n";
282282
return false;
283283
}
284284

@@ -306,7 +306,7 @@ void HelloTriangleApplication::OnResize(
306306
DXGI_FORMAT::DXGI_FORMAT_B8G8R8A8_UNORM,
307307
0)))
308308
{
309-
std::cout << "D3D11: Failed to recreate SwapChain buffers\n";
309+
std::cerr << "D3D11: Failed to recreate SwapChain buffers\n";
310310
return;
311311
}
312312

src/Cpp/1-getting-started/1-2-2-DebugLayer/DebugLayerApplication.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ bool DebugLayerApplication::Initialize()
4949
// This section initializes DirectX's devices and SwapChain
5050
if (FAILED(CreateDXGIFactory1(IID_PPV_ARGS(&_dxgiFactory))))
5151
{
52-
std::cout << "DXGI: Failed to create factory\n";
52+
std::cerr << "DXGI: Failed to create factory\n";
5353
return false;
5454
}
5555

@@ -71,13 +71,13 @@ bool DebugLayerApplication::Initialize()
7171
nullptr,
7272
&deviceContext)))
7373
{
74-
std::cout << "D3D11: Failed to create device and device context\n";
74+
std::cerr << "D3D11: Failed to create device and device context\n";
7575
return false;
7676
}
7777

7878
if (FAILED(_device.As(&_debug)))
7979
{
80-
std::cout << "D3D11: Failed to get the debug layer from the device\n";
80+
std::cerr << "D3D11: Failed to get the debug layer from the device\n";
8181
return false;
8282
}
8383

@@ -106,7 +106,7 @@ bool DebugLayerApplication::Initialize()
106106
nullptr,
107107
&_swapChain)))
108108
{
109-
std::cout << "DXGI: Failed to create swapchain\n";
109+
std::cerr << "DXGI: Failed to create swapchain\n";
110110
return false;
111111
}
112112

@@ -142,7 +142,7 @@ bool DebugLayerApplication::Load()
142142
&resourceData,
143143
&_triangleVertices)))
144144
{
145-
std::cout << "D3D11: Failed to create triangle vertex buffer\n";
145+
std::cerr << "D3D11: Failed to create triangle vertex buffer\n";
146146
return false;
147147
}
148148

@@ -156,7 +156,7 @@ bool DebugLayerApplication::CreateSwapchainResources()
156156
0,
157157
IID_PPV_ARGS(&backBuffer))))
158158
{
159-
std::cout << "D3D11: Failed to get back buffer from swapchain\n";
159+
std::cerr << "D3D11: Failed to get back buffer from swapchain\n";
160160
return false;
161161
}
162162

@@ -165,7 +165,7 @@ bool DebugLayerApplication::CreateSwapchainResources()
165165
nullptr,
166166
&_renderTarget)))
167167
{
168-
std::cout << "D3D11: Failed to create rendertarget view from back buffer\n";
168+
std::cerr << "D3D11: Failed to create rendertarget view from back buffer\n";
169169
return false;
170170
}
171171

@@ -193,7 +193,7 @@ void DebugLayerApplication::OnResize(
193193
DXGI_FORMAT::DXGI_FORMAT_B8G8R8A8_UNORM,
194194
0)))
195195
{
196-
std::cout << "D3D11: Failed to recreate swapchain buffers\n";
196+
std::cerr << "D3D11: Failed to recreate swapchain buffers\n";
197197
return;
198198
}
199199

src/Cpp/1-getting-started/1-2-2-DebugLayer/ShaderCollection.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ WRL::ComPtr<ID3D11VertexShader> ShaderCollection::CreateVertexShader(ID3D11Devic
7171
nullptr,
7272
&vertexShader)))
7373
{
74-
std::cout << "D3D11: Failed to compile vertex shader\n";
74+
std::cerr << "D3D11: Failed to compile vertex shader\n";
7575
return nullptr;
7676
}
7777

@@ -93,7 +93,7 @@ WRL::ComPtr<ID3D11PixelShader> ShaderCollection::CreatePixelShader(ID3D11Device*
9393
nullptr,
9494
&pixelShader)))
9595
{
96-
std::cout << "D3D11: Failed to compile pixel shader\n";
96+
std::cerr << "D3D11: Failed to compile pixel shader\n";
9797
return nullptr;
9898
}
9999

@@ -110,7 +110,7 @@ bool ShaderCollection::CreateInputLayout(ID3D11Device* device, const VertexType
110110
vertexBlob->GetBufferSize(),
111111
&inputLayout)))
112112
{
113-
std::cout << "D3D11: Failed to create the input layout";
113+
std::cerr << "D3D11: Failed to create the input layout";
114114
return false;
115115
}
116116
return true;
@@ -133,10 +133,10 @@ bool ShaderCollection::CompileShader(const std::wstring& filePath, const std::st
133133
&tempShaderBlob,
134134
&errorBlob)))
135135
{
136-
std::cout << "D3D11: Failed to read shader from file\n";
136+
std::cerr << "D3D11: Failed to read shader from file\n";
137137
if (errorBlob != nullptr)
138138
{
139-
std::cout << "D3D11: With message: " << static_cast<const char*>(errorBlob->GetBufferPointer()) << "\n";
139+
std::cerr << "D3D11: With message: " << static_cast<const char*>(errorBlob->GetBufferPointer()) << "\n";
140140
}
141141

142142
return false;

0 commit comments

Comments
 (0)