summaryrefslogtreecommitdiffstats
path: root/examples/hello-world/main.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2021-01-11 09:11:52 -0800
committerGitHub <noreply@github.com>2021-01-11 09:11:52 -0800
commit5554777188225266e2295db3588f6cb17cae0c4d (patch)
tree9d15992cd24d752cde1047745cf75a25e841f494 /examples/hello-world/main.cpp
parente24c5a6cb9c3347477b83abe084a09ae8f9fde0a (diff)
Make `gfx::Renderer` a COM interface. (#1653)
* Make `gfx::Renderer` a COM interface. This is a first step towards making the `gfx` library expose a COM compatible DLL interface. Remaining classes will come as separate PRs. * Fixup project files * Fix calling conventions * Make gfx::create*Renderer() functions increase ref count by 1 * Make renderer createFunc return via out parameter
Diffstat (limited to 'examples/hello-world/main.cpp')
-rw-r--r--examples/hello-world/main.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/examples/hello-world/main.cpp b/examples/hello-world/main.cpp
index 9618b8c4d..da35f3f0a 100644
--- a/examples/hello-world/main.cpp
+++ b/examples/hello-world/main.cpp
@@ -35,6 +35,8 @@
#include "gfx/render.h"
#include "gfx/d3d11/render-d3d11.h"
#include "tools/graphics-app-framework/window.h"
+#include "slang-com-ptr.h"
+
using namespace gfx;
// For the purposes of a small example, we will define the vertex data for a
@@ -70,7 +72,7 @@ struct HelloWorld
// Slang API. This function is representative of code that a user
// might write to integrate Slang into their renderer/engine.
//
-RefPtr<gfx::ShaderProgram> loadShaderProgram(gfx::Renderer* renderer)
+RefPtr<gfx::ShaderProgram> loadShaderProgram(gfx::IRenderer* renderer)
{
// First, we need to create a "session" for interacting with the Slang
// compiler. This scopes all of our application's interactions
@@ -227,7 +229,7 @@ int gWindowHeight = 768;
//
gfx::ApplicationContext* gAppContext;
gfx::Window* gWindow;
-RefPtr<gfx::Renderer> gRenderer;
+Slang::ComPtr<gfx::IRenderer> gRenderer;
RefPtr<gfx::BufferResource> gConstantBuffer;
RefPtr<gfx::PipelineLayout> gPipelineLayout;
@@ -257,8 +259,8 @@ Result initialize()
// A future version of this example may support multiple
// platforms/APIs.
//
- gRenderer = createD3D11Renderer();
- Renderer::Desc rendererDesc;
+ createD3D11Renderer(gRenderer.writeRef());
+ IRenderer::Desc rendererDesc;
rendererDesc.width = gWindowWidth;
rendererDesc.height = gWindowHeight;
{