-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial commit of the Visual Studio solution.
- Loading branch information
Showing
28 changed files
with
3,344 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 17 | ||
VisualStudioVersion = 17.4.33213.308 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WPFUI", "WPFUI\WPFUI.csproj", "{8103A8E5-EB91-42C0-88BC-D87297DD808C}" | ||
EndProject | ||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MandelbrotExplorerLib", "MandelbrotExplorerLib\MandelbrotExplorerLib.vcxproj", "{A0B96902-3CFB-4C48-B496-E9EC24D469DD}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Debug|x64 = Debug|x64 | ||
Debug|x86 = Debug|x86 | ||
Release|Any CPU = Release|Any CPU | ||
Release|x64 = Release|x64 | ||
Release|x86 = Release|x86 | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{8103A8E5-EB91-42C0-88BC-D87297DD808C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{8103A8E5-EB91-42C0-88BC-D87297DD808C}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{8103A8E5-EB91-42C0-88BC-D87297DD808C}.Debug|x64.ActiveCfg = Debug|Any CPU | ||
{8103A8E5-EB91-42C0-88BC-D87297DD808C}.Debug|x64.Build.0 = Debug|Any CPU | ||
{8103A8E5-EB91-42C0-88BC-D87297DD808C}.Debug|x86.ActiveCfg = Debug|Any CPU | ||
{8103A8E5-EB91-42C0-88BC-D87297DD808C}.Debug|x86.Build.0 = Debug|Any CPU | ||
{8103A8E5-EB91-42C0-88BC-D87297DD808C}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{8103A8E5-EB91-42C0-88BC-D87297DD808C}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{8103A8E5-EB91-42C0-88BC-D87297DD808C}.Release|x64.ActiveCfg = Release|Any CPU | ||
{8103A8E5-EB91-42C0-88BC-D87297DD808C}.Release|x64.Build.0 = Release|Any CPU | ||
{8103A8E5-EB91-42C0-88BC-D87297DD808C}.Release|x86.ActiveCfg = Release|Any CPU | ||
{8103A8E5-EB91-42C0-88BC-D87297DD808C}.Release|x86.Build.0 = Release|Any CPU | ||
{A0B96902-3CFB-4C48-B496-E9EC24D469DD}.Debug|Any CPU.ActiveCfg = Debug|x64 | ||
{A0B96902-3CFB-4C48-B496-E9EC24D469DD}.Debug|Any CPU.Build.0 = Debug|x64 | ||
{A0B96902-3CFB-4C48-B496-E9EC24D469DD}.Debug|x64.ActiveCfg = Debug|x64 | ||
{A0B96902-3CFB-4C48-B496-E9EC24D469DD}.Debug|x64.Build.0 = Debug|x64 | ||
{A0B96902-3CFB-4C48-B496-E9EC24D469DD}.Debug|x86.ActiveCfg = Debug|Win32 | ||
{A0B96902-3CFB-4C48-B496-E9EC24D469DD}.Debug|x86.Build.0 = Debug|Win32 | ||
{A0B96902-3CFB-4C48-B496-E9EC24D469DD}.Release|Any CPU.ActiveCfg = Release|x64 | ||
{A0B96902-3CFB-4C48-B496-E9EC24D469DD}.Release|Any CPU.Build.0 = Release|x64 | ||
{A0B96902-3CFB-4C48-B496-E9EC24D469DD}.Release|x64.ActiveCfg = Release|x64 | ||
{A0B96902-3CFB-4C48-B496-E9EC24D469DD}.Release|x64.Build.0 = Release|x64 | ||
{A0B96902-3CFB-4C48-B496-E9EC24D469DD}.Release|x86.ActiveCfg = Release|Win32 | ||
{A0B96902-3CFB-4C48-B496-E9EC24D469DD}.Release|x86.Build.0 = Release|Win32 | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {F94DACB9-7456-4AB7-B0E2-1662E7155AFD} | ||
EndGlobalSection | ||
EndGlobal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#include "pch.h" | ||
|
||
using namespace System; | ||
using namespace System::Reflection; | ||
using namespace System::Runtime::CompilerServices; | ||
using namespace System::Runtime::InteropServices; | ||
using namespace System::Security::Permissions; | ||
|
||
[assembly:AssemblyTitleAttribute(L"MandelbrotExplorerLib")]; | ||
[assembly:AssemblyDescriptionAttribute(L"")]; | ||
[assembly:AssemblyConfigurationAttribute(L"")]; | ||
[assembly:AssemblyCompanyAttribute(L"")]; | ||
[assembly:AssemblyProductAttribute(L"MandelbrotExplorerLib")]; | ||
[assembly:AssemblyCopyrightAttribute(L"Copyright (c) 2023")]; | ||
[assembly:AssemblyTrademarkAttribute(L"")]; | ||
[assembly:AssemblyCultureAttribute(L"")]; | ||
|
||
[assembly:AssemblyVersionAttribute(L"1.0.*")]; | ||
|
||
[assembly:ComVisible(false)]; |
109 changes: 109 additions & 0 deletions
109
MandelbrotExplorer/MandelbrotExplorerLib/MandelbrotExplorerLib.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
#include "pch.h" | ||
#include "MandelbrotExplorerLib.h" | ||
#include <vector> | ||
#include <glm/glm.hpp> | ||
#include <string> | ||
#include "mandelbrot_parameters.h" | ||
|
||
namespace MandelbrotExplorerLib | ||
{ | ||
using msclr::interop::marshal_as; | ||
|
||
MandelbrotRenderer::MandelbrotRenderer(System::IntPtr hinstance, System::IntPtr hwnd, bool debug) | ||
{ | ||
try | ||
{ | ||
_native_renderer = new vulkan_renderer((HINSTANCE)hinstance.ToPointer(), (HWND)hwnd.ToPointer(), debug); | ||
_native_renderer->load_fragment_shader(mandelbrot_parameter_info::MANDELBROT_FRAGMENT_SHADER, sizeof(mandelbrot_parameter_info)); | ||
} | ||
catch (const std::runtime_error& err) | ||
{ | ||
throw gcnew System::Exception(marshal_as<System::String^>(err.what())); | ||
} | ||
} | ||
|
||
MandelbrotRenderer::~MandelbrotRenderer() | ||
{ | ||
if (!_disposed) | ||
{ | ||
_native_renderer->dispose(); | ||
_cachedMessages = GetDebugMessages(); | ||
delete _native_renderer; | ||
_disposed = true; | ||
} | ||
} | ||
|
||
array<DebugMessage^>^ MandelbrotRenderer::GetDebugMessages() | ||
{ | ||
if (_disposed) | ||
return _cachedMessages; | ||
|
||
const std::vector<debug_message>& nativeMessages = _native_renderer->debug_messages(); | ||
int size = nativeMessages.size(); | ||
array<DebugMessage^>^ managedMessages = gcnew array<DebugMessage^>(size); | ||
|
||
for (int i = 0; i < size; i++) | ||
{ | ||
const debug_message& nativeMessage = nativeMessages[i]; | ||
DebugMessage^ managedMessage = gcnew DebugMessage(); | ||
|
||
managedMessage->Text = marshal_as<System::String^>(nativeMessage.text); | ||
managedMessage->Type = (DebugMessageType)nativeMessage.type; | ||
managedMessage->Severity = (DebugMessageSeverity)nativeMessage.severity; | ||
|
||
managedMessages[i] = managedMessage; | ||
} | ||
|
||
return managedMessages; | ||
} | ||
|
||
void MandelbrotRenderer::RefreshSurface() | ||
{ | ||
_native_renderer->refresh_surface(); | ||
} | ||
|
||
System::ValueTuple<System::UInt32, System::UInt32> MandelbrotRenderer::GetSurfaceExtent() | ||
{ | ||
VkExtent2D extent = _native_renderer->surface_extent(); | ||
return System::ValueTuple<System::UInt32, System::UInt32>(extent.width, extent.height); | ||
} | ||
|
||
void MandelbrotRenderer::Draw() | ||
{ | ||
mandelbrot_parameter_info info; | ||
|
||
info.top = this->Top; | ||
info.left = this->Left; | ||
info.right = this->Right; | ||
info.bottom = this->Bottom; | ||
|
||
VkExtent2D extent = _native_renderer->surface_extent(); | ||
info.surface_width = (float)extent.width; | ||
info.surface_height = (float)extent.height; | ||
|
||
info.bailout_radius = this->BailoutRadius; | ||
info.max_iterations = this->MaxIterations; | ||
info.fill_color = this->FillColor; | ||
info.gradient_period_factor = this->GradientPeriodFactor; | ||
|
||
int length = mandelbrot_parameter_info::GRADIENT_CAPACITY; | ||
length = std::min(length, this->Gradient->Length); | ||
|
||
info.gradient_length = length; | ||
|
||
for (int i = 0; i < length; i++) | ||
info.gradient[i] = this->Gradient[i]; | ||
|
||
for (int i = length; i < mandelbrot_parameter_info::GRADIENT_CAPACITY; i++) | ||
info.gradient[i] = 0x00FF00; | ||
|
||
try | ||
{ | ||
_native_renderer->draw_frame(&info); | ||
} | ||
catch (const std::runtime_error& err) | ||
{ | ||
throw gcnew System::Exception(marshal_as<System::String^>(err.what())); | ||
} | ||
} | ||
} |
69 changes: 69 additions & 0 deletions
69
MandelbrotExplorer/MandelbrotExplorerLib/MandelbrotExplorerLib.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
#pragma once | ||
#include "mandelbrot_native.h" | ||
|
||
using namespace System; | ||
using namespace System::Collections::Generic; | ||
using namespace System::Drawing; | ||
|
||
namespace MandelbrotExplorerLib | ||
{ | ||
public enum class DebugMessageSeverity : System::UInt32 | ||
{ | ||
Verbose = 0x00000001, | ||
Info = 0x00000010, | ||
Warning = 0x00000100, | ||
Error = 0x00001000 | ||
}; | ||
|
||
public enum class DebugMessageType : System::UInt32 | ||
{ | ||
General = 0x00000001, | ||
Validation = 0x00000002, | ||
Performance = 0x00000004, | ||
DeviceAddressBinding = 0x00000008 | ||
}; | ||
|
||
public ref class DebugMessage | ||
{ | ||
public: | ||
property String^ Text; | ||
property DebugMessageSeverity Severity; | ||
property DebugMessageType Type; | ||
}; | ||
|
||
public ref class MandelbrotRenderer : System::IDisposable | ||
{ | ||
|
||
public: | ||
|
||
MandelbrotRenderer(System::IntPtr hinstance, System::IntPtr hwnd) | ||
: MandelbrotRenderer(hinstance, hwnd, false) | ||
{ | ||
} | ||
|
||
MandelbrotRenderer(System::IntPtr hinstance, System::IntPtr hwnd, bool debug); | ||
~MandelbrotRenderer(); | ||
|
||
void RefreshSurface(); | ||
System::ValueTuple<System::UInt32, System::UInt32> GetSurfaceExtent(); | ||
void Draw(); | ||
|
||
array<DebugMessage^>^ GetDebugMessages(); | ||
|
||
property float Top; | ||
property float Left; | ||
property float Right; | ||
property float Bottom; | ||
property float BailoutRadius; | ||
property System::UInt32 MaxIterations; | ||
property System::UInt32 FillColor; | ||
property float GradientPeriodFactor; | ||
property array<System::UInt32>^ Gradient; | ||
|
||
private: | ||
|
||
bool _disposed = false; | ||
vulkan_renderer* _native_renderer = nullptr; | ||
array<DebugMessage^>^ _cachedMessages = nullptr; | ||
}; | ||
} |
Oops, something went wrong.