Skip to content

Commit

Permalink
Update to version 0.3 (#4)
Browse files Browse the repository at this point in the history
- Switch to using explorer command verbs for adding to the context menu.
- Fix issue with packing to a glb from a special folder (e.g., Downloads) where it would open the destination folder in a new explorer window.
- Add a Windows Application Packaging Project to enable submission to the Windows Store.
- Add icons to context menu items.
  • Loading branch information
bghgary authored Dec 23, 2021
1 parent 69e00a3 commit cc577a5
Show file tree
Hide file tree
Showing 71 changed files with 1,585 additions and 847 deletions.
11 changes: 4 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
.vs
bin
obj
*.user
/Source/packages
/Source/Setup/Debug
/Source/Setup/Release
.vs
Build
*.aps
*.user
Binary file modified Figures/Pack1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Figures/Pack2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Figures/Unpack1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Figures/Unpack2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Figures/Unpack3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@
Microsoft Windows shell extensions that pack .gltf to .glb and unpack .glb to .gltf

# Installing
1. Download the latest installer `glTF-Shell-Extensions.msi` from [Releases](https://github.com/bghgary/glTF-Shell-Extensions/releases).
2. Unblock the installer file to avoid security warnings.
3. Double-click the installer file.
This tool is distributed through the Windows Store. Install the latest version [here](https://www.microsoft.com/store/apps/9NPGVJ9N57MV).

# Usage
## Packing `.gltf` to `.glb`

Right-click on a `.gltf` file and select `Pack to Binary glTF...`.
Right-click on a `.gltf` file and select `Pack to Binary glTF`.

![](/Figures/Pack1.png)

Expand All @@ -19,7 +17,7 @@ Select a name for the new `.glb` file.

## Unpacking `.glb` to `.gltf`

Right-click on a `.glb` file and select `Unpack to glTF...`.
Right-click on a `.glb` file and select `Unpack to glTF`.

![](/Figures/Unpack1.png)

Expand Down
Binary file added Source/Assets/App.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Source/Assets/Logo.ico
Binary file not shown.
14 changes: 14 additions & 0 deletions Source/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<Project>
<PropertyGroup>
<BuildDir>$([MSBuild]::NormalizeDirectory($(MSBuildThisFileDirectory)..))Build\$(MSBuildProjectName)\</BuildDir>

<BaseIntermediateOutputPath>$(BuildDir)obj\</BaseIntermediateOutputPath>
<IntermediateOutputPath>$(BaseIntermediateOutputPath)$(Configuration)\$(Platform)\</IntermediateOutputPath>
<OutputPath>$(BuildDir)bin\$(Configuration)\$(Platform)\</OutputPath>

<IntDir>$(IntermediateOutputPath)</IntDir>
<OutDir>$(OutputPath)</OutDir>

<PlatformSpecificBundleArtifactsListDir>$(BuildDir)BundleArtifacts\</PlatformSpecificBundleArtifactsListDir>
</PropertyGroup>
</Project>
100 changes: 100 additions & 0 deletions Source/ExplorerCommand/ClassFactory.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
#pragma once

#include <Windows.h>
#include <new>

template <typename T>
class ClassFactory : public IClassFactory
{
public:
static HRESULT CreateInstance(REFIID riid, void** ppv)
{
*ppv = nullptr;

ClassFactory* pClassFactory = new(std::nothrow) ClassFactory();
if (pClassFactory == nullptr)
{
return E_OUTOFMEMORY;
}

HRESULT hr = pClassFactory->QueryInterface(riid, ppv);
pClassFactory->Release();
return hr;
}

ClassFactory()
{
DllAddRef();
}

// IUnknown

IFACEMETHODIMP QueryInterface(REFIID riid, void** ppv)
{
IUnknown* punk = nullptr;

if (riid == __uuidof(IUnknown) || riid == __uuidof(IClassFactory))
{
punk = static_cast<IClassFactory*>(this);
}

*ppv = punk;

if (punk == nullptr)
{
return E_NOINTERFACE;
}

punk->AddRef();
return S_OK;
}

IFACEMETHODIMP_(ULONG) AddRef()
{
return InterlockedIncrement(&m_ref);
}

IFACEMETHODIMP_(ULONG) Release()
{
LONG cRef = InterlockedDecrement(&m_ref);
if (cRef == 0)
{
delete this;
}
return cRef;
}

// IClassFactory

IFACEMETHODIMP CreateInstance(IUnknown* punkOuter, REFIID riid, void** ppv)
{
if (punkOuter != nullptr)
{
return CLASS_E_NOAGGREGATION;
}

return T::CreateInstance(riid, ppv);
}

IFACEMETHODIMP LockServer(BOOL fLock)
{
if (fLock)
{
DllAddRef();
}
else
{
DllRelease();
}

return S_OK;
}

private:
~ClassFactory()
{
DllRelease();
}

LONG m_ref{1};
};
44 changes: 44 additions & 0 deletions Source/ExplorerCommand/Dll.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#include "Dll.h"
#include "ClassFactory.h"
#include "ExplorerCommand.h"

namespace
{
long g_refModule = 0;
}

void DllAddRef()
{
InterlockedIncrement(&g_refModule);
}

void DllRelease()
{
InterlockedDecrement(&g_refModule);
}

STDAPI_(BOOL) DllMain(HINSTANCE hInstance, DWORD dwReason, void*)
{
if (dwReason == DLL_PROCESS_ATTACH)
{
DisableThreadLibraryCalls(hInstance);
}

return TRUE;
}

STDAPI DllCanUnloadNow()
{
// Only allow the DLL to be unloaded after all outstanding references have been released
return (g_refModule == 0) ? S_OK : S_FALSE;
}

STDAPI DllGetClassObject(REFCLSID clsid, REFIID riid, void **ppv)
{
if (clsid == __uuidof(ExplorerCommand))
{
return ClassFactory<ExplorerCommand>::CreateInstance(riid, ppv);
}

return CLASS_E_CLASSNOTAVAILABLE;
}
3 changes: 3 additions & 0 deletions Source/ExplorerCommand/Dll.def
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
EXPORTS
DllCanUnloadNow PRIVATE
DllGetClassObject PRIVATE
6 changes: 6 additions & 0 deletions Source/ExplorerCommand/Dll.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#pragma once

#include <Windows.h>

void DllAddRef();
void DllRelease();
Loading

0 comments on commit cc577a5

Please sign in to comment.