Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
//--------------------------------------------------------------------------------------
// File: D3DVisualization.fx
// Originally from DirectX SDK - Tutorial 4 sample
// Copyright (c) Microsoft Corporation. All rights reserved.
//--------------------------------------------------------------------------------------

//--------------------------------------------------------------------------------------
// Constant Buffer Variables
//--------------------------------------------------------------------------------------
cbuffer ConstantBuffer : register(b0)
{
matrix World;
matrix View;
matrix Projection;
}

//--------------------------------------------------------------------------------------
struct VS_OUTPUT
{
float4 Pos : SV_POSITION;
float4 Color : COLOR0;
};

//--------------------------------------------------------------------------------------
// Vertex Shader
//--------------------------------------------------------------------------------------
VS_OUTPUT VS(float4 Pos : POSITION, float4 Color : COLOR)
{
VS_OUTPUT output = (VS_OUTPUT)0;
output.Pos = mul(Pos, World);
output.Pos = mul(output.Pos, View);
output.Pos = mul(output.Pos, Projection);
output.Color = Color;
return output;
}


//--------------------------------------------------------------------------------------
// Pixel Shader
//--------------------------------------------------------------------------------------
float4 PS(VS_OUTPUT input) : SV_Target
{
return input.Color;
}
131 changes: 131 additions & 0 deletions samples/D3D11Image net core 3.1/D3D11Visualization/D3DVisualization.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
//------------------------------------------------------------------------------
// <copyright file="D3DVizualization.h" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------

#pragma once

#include <windows.h>
#include <d3d11.h>

#ifdef DIRECTX_SDK // requires DirectX SDK June 2010
#include <xnamath.h>
#define DirectX_NS // DirectX SDK requires a blank namespace for several types
#else // Windows SDK
#include <DirectXMath.h>
#include <DirectXPackedVector.h>
#define DirectX_NS DirectX // Windows SDK requires a DirectX namespace for several types
#endif

#include "OrbitCamera.h"
#include "DX11Utils.h"
#include "resource.h"


extern "C" {
__declspec(dllexport) HRESULT __cdecl Init();
}

extern "C" {
__declspec(dllexport) void __cdecl Cleanup();
}

extern "C" {
__declspec(dllexport) HRESULT __cdecl Render(void * pResource, bool isNewSurface);
}

extern "C" {
__declspec(dllexport) HRESULT __cdecl SetCameraRadius(float r);
}

extern "C" {
__declspec(dllexport) HRESULT __cdecl SetCameraTheta(float theta);
}

extern "C" {
__declspec(dllexport) HRESULT __cdecl SetCameraPhi(float phi);
}

class CCube
{

public:
/// <summary>
/// Constructor
/// </summary>
CCube();

/// <summary>
/// Destructor
/// </summary>
~CCube();

/// <summary>
/// Create Direct3D device and swap chain
/// </summary>
/// <returns>S_OK for success, or failure code</returns>
HRESULT InitDevice();

/// <summary>
/// Renders a frame
/// </summary>
/// <returns>S_OK for success, or failure code</returns>
HRESULT Render(void * pResource, bool isNewSurface);


/// <summary>
/// Method for retrieving the camera
/// </summary>
/// <returns>Pointer to the camera</returns>
CCamera* GetCamera();

// Special function definitions to ensure alignment between c# and c++
void* operator new(size_t size)
{
return _aligned_malloc(size, 16);
}

void operator delete(void *p)
{
_aligned_free(p);
}

private:

HRESULT InitRenderTarget(void * pResource);
void SetUpViewport();

// 3d camera
CCamera m_camera;

HINSTANCE m_hInst;
D3D_DRIVER_TYPE m_driverType;
D3D_FEATURE_LEVEL m_featureLevel;

ID3D11Device* m_pd3dDevice;
ID3D11DeviceContext* m_pImmediateContext;
IDXGISwapChain* m_pSwapChain = NULL;
ID3D11RenderTargetView* m_pRenderTargetView = NULL;
ID3D11InputLayout* m_pVertexLayout;
ID3D11Buffer* m_pVertexBuffer;
ID3D11Buffer* m_pIndexBuffer = NULL;
ID3D11Buffer* m_pConstantBuffer = NULL;

DirectX_NS::XMMATRIX m_World;
DirectX_NS::XMMATRIX m_View;
DirectX_NS::XMMATRIX m_Projection;

ID3D11VertexShader* m_pVertexShader;
ID3D11PixelShader* m_pPixelShader;

// Initial window resolution
UINT m_Width;
UINT m_Height;

/// <summary>
/// Compile and set layout for shaders
/// </summary>
/// <returns>S_OK for success, or failure code</returns>
HRESULT LoadShaders();
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
//------------------------------------------------------------------------------
// <copyright file="D3DVisualization.rc" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------

//Microsoft Visual C++ generated resource script.
//
#include "resource.h"

#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#define APSTUDIO_HIDDEN_SYMBOLS
#include "windows.h"
#undef APSTUDIO_HIDDEN_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS

#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
LANGUAGE 9, 1
#pragma code_page(1252)


/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//

#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE
BEGIN
"resource.h\0"
END

2 TEXTINCLUDE
BEGIN
"#define APSTUDIO_HIDDEN_SYMBOLS\r\n"
"#include ""windows.h""\r\n"
"#undef APSTUDIO_HIDDEN_SYMBOLS\r\n"
"\0"
END

3 TEXTINCLUDE
BEGIN
"\r\n"
"\0"
END

#endif // APSTUDIO_INVOKED

#endif
/////////////////////////////////////////////////////////////////////////////



#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//


/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED
Loading