From 5554777188225266e2295db3588f6cb17cae0c4d Mon Sep 17 00:00:00 2001 From: Yong He Date: Mon, 11 Jan 2021 09:11:52 -0800 Subject: 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 --- examples/hello-world/main.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'examples/hello-world/main.cpp') 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 loadShaderProgram(gfx::Renderer* renderer) +RefPtr 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 gRenderer; +Slang::ComPtr gRenderer; RefPtr gConstantBuffer; RefPtr 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; { -- cgit v1.2.3