Add project files.
This commit is contained in:
parent
50641ea8e3
commit
973740f6fd
|
@ -0,0 +1,141 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="main.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="main.h" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>16.0</VCProjectVersion>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<ProjectGuid>{033e12b0-0dd7-4437-a5b6-e2e2306c93cb}</ProjectGuid>
|
||||
<RootNamespace>OpenGLRenderer</RootNamespace>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalLibraryDirectories>D:\App Files\Projects\OpenGLTest\OpenGLRenderer\include;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<AdditionalDependencies>opengl32.lib;glew32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<NoEntryPoint>
|
||||
</NoEntryPoint>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
|
@ -0,0 +1,27 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Resource Files">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="main.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="main.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,104 @@
|
|||
|
||||
#include "main.h"
|
||||
#include <iostream>
|
||||
HGLRC hRC;
|
||||
|
||||
// Declare a global callback variable
|
||||
ErrorCallback glErrorCallback = nullptr;
|
||||
|
||||
bool _HAS_VIEWPORT_BEEN_SETUP = false;
|
||||
unsigned int VIEWPORT_WIDTH = 0;
|
||||
unsigned int VIEWPORT_HEIGHT = 0;
|
||||
|
||||
// Function to set the error callback
|
||||
DLL_API void SetGLErrorCallback(ErrorCallback callback)
|
||||
{
|
||||
glErrorCallback = callback;
|
||||
}
|
||||
|
||||
DLL_API void InitializeOpenGL(HWND hWnd)
|
||||
{
|
||||
HDC hdc = GetDC(hWnd);
|
||||
|
||||
// Set pixel format
|
||||
PIXELFORMATDESCRIPTOR pfd;
|
||||
ZeroMemory(&pfd, sizeof(pfd));
|
||||
pfd.nSize = sizeof(pfd);
|
||||
pfd.nVersion = 1;
|
||||
pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;
|
||||
pfd.iPixelType = PFD_TYPE_RGBA;
|
||||
pfd.cColorBits = 32;
|
||||
pfd.cDepthBits = 24;
|
||||
pfd.cStencilBits = 8;
|
||||
|
||||
int pixelFormat = ChoosePixelFormat(hdc, &pfd);
|
||||
SetPixelFormat(hdc, pixelFormat, &pfd);
|
||||
|
||||
hRC = wglCreateContext(hdc);
|
||||
wglMakeCurrent(hdc, hRC);
|
||||
|
||||
GLenum err = glewInit();
|
||||
if (err != GLEW_OK) {
|
||||
// Handle GLEW initialization error
|
||||
|
||||
if (glErrorCallback)
|
||||
{
|
||||
const char* errorMessage = reinterpret_cast<const char*>(glewGetErrorString(err));
|
||||
glErrorCallback(err, errorMessage);
|
||||
}
|
||||
|
||||
wglMakeCurrent(NULL, NULL);
|
||||
wglDeleteContext(hRC);
|
||||
ReleaseDC(hWnd, hdc);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
DLL_API void RenderFrame()
|
||||
{
|
||||
if (!_HAS_VIEWPORT_BEEN_SETUP)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
|
||||
glViewport(0, 0, VIEWPORT_WIDTH, VIEWPORT_HEIGHT);
|
||||
|
||||
// Set up vertex data
|
||||
float vertices[] = {
|
||||
0.0f, 0.5f, 0.0f,
|
||||
0.5f, -0.5f, 0.0f,
|
||||
-0.5f, -0.5f, 0.0f
|
||||
};
|
||||
|
||||
unsigned int vao;
|
||||
glGenVertexArrays(1, &vao);
|
||||
glBindVertexArray(vao);
|
||||
|
||||
unsigned int vbo;
|
||||
glGenBuffers(1, &vbo);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, vbo);
|
||||
|
||||
glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);
|
||||
|
||||
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 2 * sizeof(float), (void*)0);
|
||||
|
||||
glDrawArrays(GL_TRIANGLES, 0, 3);
|
||||
|
||||
glDeleteBuffers(1, &vbo);
|
||||
glDeleteVertexArrays(1, &vao);
|
||||
|
||||
SwapBuffers(wglGetCurrentDC());
|
||||
}
|
||||
|
||||
DLL_API void SetupViewport(unsigned int width, unsigned int height)
|
||||
{
|
||||
VIEWPORT_WIDTH = width;
|
||||
VIEWPORT_HEIGHT = height;
|
||||
|
||||
_HAS_VIEWPORT_BEEN_SETUP = true;
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
#pragma once
|
||||
|
||||
#define DLL_API __declspec(dllexport)
|
||||
|
||||
#include <windows.h>
|
||||
#include "include/headers/glew.h"
|
||||
#include <functional>
|
||||
|
||||
extern "C" {
|
||||
typedef void (*ErrorCallback)(unsigned int errorCode, const char* errorMessage);
|
||||
|
||||
DLL_API void SetGLErrorCallback(ErrorCallback callback);
|
||||
|
||||
DLL_API void InitializeOpenGL(HWND hWnd);
|
||||
DLL_API void RenderFrame();
|
||||
DLL_API void SetupViewport(unsigned int width, unsigned int height);
|
||||
//DLL_API void Cleanup();
|
||||
}
|
|
@ -0,0 +1,71 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.5.33424.131
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenGLTest", "OpenGLTest\OpenGLTest.csproj", "{43FD799C-9B91-4014-BC0F-E324046070E7}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OpenGLRenderer", "OpenGLRenderer\OpenGLRenderer.vcxproj", "{033E12B0-0DD7-4437-A5B6-E2E2306C93CB}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Debug|ARM = Debug|ARM
|
||||
Debug|ARM64 = Debug|ARM64
|
||||
Debug|x64 = Debug|x64
|
||||
Debug|x86 = Debug|x86
|
||||
Release|Any CPU = Release|Any CPU
|
||||
Release|ARM = Release|ARM
|
||||
Release|ARM64 = Release|ARM64
|
||||
Release|x64 = Release|x64
|
||||
Release|x86 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{43FD799C-9B91-4014-BC0F-E324046070E7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{43FD799C-9B91-4014-BC0F-E324046070E7}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{43FD799C-9B91-4014-BC0F-E324046070E7}.Debug|ARM.ActiveCfg = Debug|Any CPU
|
||||
{43FD799C-9B91-4014-BC0F-E324046070E7}.Debug|ARM.Build.0 = Debug|Any CPU
|
||||
{43FD799C-9B91-4014-BC0F-E324046070E7}.Debug|ARM64.ActiveCfg = Debug|Any CPU
|
||||
{43FD799C-9B91-4014-BC0F-E324046070E7}.Debug|ARM64.Build.0 = Debug|Any CPU
|
||||
{43FD799C-9B91-4014-BC0F-E324046070E7}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{43FD799C-9B91-4014-BC0F-E324046070E7}.Debug|x64.Build.0 = Debug|x64
|
||||
{43FD799C-9B91-4014-BC0F-E324046070E7}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{43FD799C-9B91-4014-BC0F-E324046070E7}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{43FD799C-9B91-4014-BC0F-E324046070E7}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{43FD799C-9B91-4014-BC0F-E324046070E7}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{43FD799C-9B91-4014-BC0F-E324046070E7}.Release|ARM.ActiveCfg = Release|Any CPU
|
||||
{43FD799C-9B91-4014-BC0F-E324046070E7}.Release|ARM.Build.0 = Release|Any CPU
|
||||
{43FD799C-9B91-4014-BC0F-E324046070E7}.Release|ARM64.ActiveCfg = Release|Any CPU
|
||||
{43FD799C-9B91-4014-BC0F-E324046070E7}.Release|ARM64.Build.0 = Release|Any CPU
|
||||
{43FD799C-9B91-4014-BC0F-E324046070E7}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{43FD799C-9B91-4014-BC0F-E324046070E7}.Release|x64.Build.0 = Release|Any CPU
|
||||
{43FD799C-9B91-4014-BC0F-E324046070E7}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{43FD799C-9B91-4014-BC0F-E324046070E7}.Release|x86.Build.0 = Release|Any CPU
|
||||
{033E12B0-0DD7-4437-A5B6-E2E2306C93CB}.Debug|Any CPU.ActiveCfg = Debug|x64
|
||||
{033E12B0-0DD7-4437-A5B6-E2E2306C93CB}.Debug|Any CPU.Build.0 = Debug|x64
|
||||
{033E12B0-0DD7-4437-A5B6-E2E2306C93CB}.Debug|ARM.ActiveCfg = Debug|x64
|
||||
{033E12B0-0DD7-4437-A5B6-E2E2306C93CB}.Debug|ARM.Build.0 = Debug|x64
|
||||
{033E12B0-0DD7-4437-A5B6-E2E2306C93CB}.Debug|ARM64.ActiveCfg = Debug|x64
|
||||
{033E12B0-0DD7-4437-A5B6-E2E2306C93CB}.Debug|ARM64.Build.0 = Debug|x64
|
||||
{033E12B0-0DD7-4437-A5B6-E2E2306C93CB}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{033E12B0-0DD7-4437-A5B6-E2E2306C93CB}.Debug|x64.Build.0 = Debug|x64
|
||||
{033E12B0-0DD7-4437-A5B6-E2E2306C93CB}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{033E12B0-0DD7-4437-A5B6-E2E2306C93CB}.Debug|x86.Build.0 = Debug|Win32
|
||||
{033E12B0-0DD7-4437-A5B6-E2E2306C93CB}.Release|Any CPU.ActiveCfg = Release|x64
|
||||
{033E12B0-0DD7-4437-A5B6-E2E2306C93CB}.Release|Any CPU.Build.0 = Release|x64
|
||||
{033E12B0-0DD7-4437-A5B6-E2E2306C93CB}.Release|ARM.ActiveCfg = Release|x64
|
||||
{033E12B0-0DD7-4437-A5B6-E2E2306C93CB}.Release|ARM.Build.0 = Release|x64
|
||||
{033E12B0-0DD7-4437-A5B6-E2E2306C93CB}.Release|ARM64.ActiveCfg = Release|x64
|
||||
{033E12B0-0DD7-4437-A5B6-E2E2306C93CB}.Release|ARM64.Build.0 = Release|x64
|
||||
{033E12B0-0DD7-4437-A5B6-E2E2306C93CB}.Release|x64.ActiveCfg = Release|x64
|
||||
{033E12B0-0DD7-4437-A5B6-E2E2306C93CB}.Release|x64.Build.0 = Release|x64
|
||||
{033E12B0-0DD7-4437-A5B6-E2E2306C93CB}.Release|x86.ActiveCfg = Release|Win32
|
||||
{033E12B0-0DD7-4437-A5B6-E2E2306C93CB}.Release|x86.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {41A9725F-FFE1-466A-B275-10914F7CE111}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
|
@ -0,0 +1,69 @@
|
|||
namespace OpenGLTest
|
||||
{
|
||||
partial class Form1
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
panel1=new Panel();
|
||||
button1=new Button();
|
||||
SuspendLayout();
|
||||
//
|
||||
// panel1
|
||||
//
|
||||
panel1.Location=new Point(12, 12);
|
||||
panel1.Name="panel1";
|
||||
panel1.Size=new Size(1362, 796);
|
||||
panel1.TabIndex=0;
|
||||
//
|
||||
// button1
|
||||
//
|
||||
button1.Location=new Point(1380, 12);
|
||||
button1.Name="button1";
|
||||
button1.Size=new Size(112, 34);
|
||||
button1.TabIndex=1;
|
||||
button1.Text="button1";
|
||||
button1.UseVisualStyleBackColor=true;
|
||||
button1.Click+=button1_Click;
|
||||
//
|
||||
// Form1
|
||||
//
|
||||
AutoScaleDimensions=new SizeF(10F, 25F);
|
||||
AutoScaleMode=AutoScaleMode.Font;
|
||||
ClientSize=new Size(1601, 870);
|
||||
Controls.Add(button1);
|
||||
Controls.Add(panel1);
|
||||
Name="Form1";
|
||||
Text="Form1";
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Panel panel1;
|
||||
private Button button1;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
using System.Diagnostics;
|
||||
using System.Numerics;
|
||||
using System.Reflection.Metadata;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace OpenGLTest
|
||||
{
|
||||
public partial class Form1 : Form
|
||||
{
|
||||
const string DllPath = "OpenGLRenderer.dll"; // Name of your C++ DLL
|
||||
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
public delegate void GLErrorCallbackDelegate(uint errorCode, [MarshalAs(UnmanagedType.LPStr)] string errorMessage);
|
||||
|
||||
[DllImport(DllPath, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern uint InitializeOpenGL(nint hWND);
|
||||
|
||||
[DllImport(DllPath, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern uint RenderFrame();
|
||||
|
||||
[DllImport(DllPath, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern uint SetErrorCallback(GLErrorCallbackDelegate errorCallbackDelegate);
|
||||
|
||||
public Form1()
|
||||
{
|
||||
InitializeComponent();
|
||||
SetErrorCallback(HandleError);
|
||||
}
|
||||
|
||||
private static void HandleError(uint errorCode, string errorMessage)
|
||||
{
|
||||
Console.WriteLine($"Error: {errorMessage}");
|
||||
// Handle the error as needed in your application
|
||||
}
|
||||
|
||||
private void button1_Click(object sender, EventArgs e)
|
||||
{
|
||||
nint handle = panel1.Handle;
|
||||
|
||||
uint error;
|
||||
error = InitializeOpenGL(panel1.Handle);
|
||||
RenderFrame();
|
||||
this.Invalidate();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
<root>
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
|
@ -0,0 +1,15 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>net7.0-windows</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<Target Name="PreBuild" BeforeTargets="PreBuildEvent">
|
||||
<Exec Command="xcopy "$(SolutionDir)$(Platform)\$(Configuration)\YourCppDll.dll" "$(TargetDir)" /Y" />
|
||||
</Target>
|
||||
|
||||
</Project>
|
|
@ -0,0 +1,14 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>net7.0-windows</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Platforms>AnyCPU;x64</Platforms>
|
||||
<RunPostBuildEvent>Always</RunPostBuildEvent>
|
||||
<BaseOutputPath></BaseOutputPath>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
|
@ -0,0 +1,17 @@
|
|||
namespace OpenGLTest
|
||||
{
|
||||
internal static class Program
|
||||
{
|
||||
/// <summary>
|
||||
/// The main entry point for the application.
|
||||
/// </summary>
|
||||
[STAThread]
|
||||
static void Main()
|
||||
{
|
||||
// To customize application configuration such as set high DPI settings or default font,
|
||||
// see https://aka.ms/applicationconfiguration.
|
||||
ApplicationConfiguration.Initialize();
|
||||
Application.Run(new Form1());
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue