From 46025fd2c9a5faa027a6a0bbce66f62fe06d4839 Mon Sep 17 00:00:00 2001 From: "Joseph.Roy" Date: Mon, 20 Nov 2023 16:04:17 +0000 Subject: [PATCH] fix function name in .net code --- OpenGLRenderer/OpenGLRenderer.vcxproj | 2 +- OpenGLRenderer/main.cpp | 3 +-- OpenGLRenderer/main.h | 4 ++-- OpenGLTest/Form1.cs | 8 ++++++-- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/OpenGLRenderer/OpenGLRenderer.vcxproj b/OpenGLRenderer/OpenGLRenderer.vcxproj index 1f0123c..7f6cc98 100644 --- a/OpenGLRenderer/OpenGLRenderer.vcxproj +++ b/OpenGLRenderer/OpenGLRenderer.vcxproj @@ -113,7 +113,7 @@ Windows true - D:\App Files\Projects\OpenGLTest\OpenGLRenderer\include;%(AdditionalLibraryDirectories) + C:\git\OpenGLTest\OpenGLRenderer\include;%(AdditionalLibraryDirectories) opengl32.lib;glew32.lib;%(AdditionalDependencies) diff --git a/OpenGLRenderer/main.cpp b/OpenGLRenderer/main.cpp index 13bca07..4c37863 100644 --- a/OpenGLRenderer/main.cpp +++ b/OpenGLRenderer/main.cpp @@ -1,4 +1,3 @@ - #include "main.h" #include HGLRC hRC; @@ -95,7 +94,7 @@ DLL_API void RenderFrame() SwapBuffers(wglGetCurrentDC()); } -DLL_API void SetupViewport(unsigned int width, unsigned int height) +DLL_API void SetupViewport(int width, int height) { VIEWPORT_WIDTH = width; VIEWPORT_HEIGHT = height; diff --git a/OpenGLRenderer/main.h b/OpenGLRenderer/main.h index ded5ded..fa3bc1e 100644 --- a/OpenGLRenderer/main.h +++ b/OpenGLRenderer/main.h @@ -1,6 +1,6 @@ #pragma once -#define DLL_API __declspec(dllexport) +#define DLL_API extern "C" __declspec(dllexport) #include #include "include/headers/glew.h" @@ -12,6 +12,6 @@ extern "C" { DLL_API void InitializeOpenGL(HWND hWnd); DLL_API void RenderFrame(); - DLL_API void SetupViewport(unsigned int width, unsigned int height); + DLL_API void SetupViewport(int width, int height); //DLL_API void Cleanup(); } \ No newline at end of file diff --git a/OpenGLTest/Form1.cs b/OpenGLTest/Form1.cs index f7fd92a..dc8fbcd 100644 --- a/OpenGLTest/Form1.cs +++ b/OpenGLTest/Form1.cs @@ -19,12 +19,16 @@ namespace OpenGLTest public static extern uint RenderFrame(); [DllImport(DllPath, CallingConvention = CallingConvention.Cdecl)] - public static extern uint SetErrorCallback(GLErrorCallbackDelegate errorCallbackDelegate); + public static extern uint SetupViewport(int width, int height); + + [DllImport(DllPath, CallingConvention = CallingConvention.Cdecl)] + public static extern uint SetGLErrorCallback(GLErrorCallbackDelegate errorCallbackDelegate); public Form1() { InitializeComponent(); - SetErrorCallback(HandleError); + SetGLErrorCallback(HandleError); + SetupViewport(panel1.Width, panel1.Height); } private static void HandleError(uint errorCode, string errorMessage)