iffyloop / EasyVst

Easy-to-use VST3 wrapper for hosting VST3 plugins without JUCE or other frameworks
Other
56 stars 6 forks source link

GLFW support #2

Closed mightgoyardstill closed 1 year ago

mightgoyardstill commented 1 year ago

Hi I'm wondering if you are planning on including cmake support for platform agnostics?

I'm quite new to coding and building projects/libraries so am a little confused on how to get this working on my end.. do i need to have the vst sdk downloaded and built correctly on my system or do i just need the public.sdk headers and cpp files?

iffyloop commented 1 year ago

Hi there; so sorry I couldn't respond to your issue earlier. I'm not planning to add CMake support anytime soon, as this repository is intended primarily as a convenience wrapper around the VST3 SDK and an example of how to use the SDK, not as its own library. You are correct that you download and build the SDK on your system, then include the appropriate headers and source files. Assuming you got it to work since you closed the issue, but if you need anything else then message me here and I'll get back to you when I have the opportunity.

mightgoyardstill commented 1 year ago

no worries! thanks for getting back to me :)

I've been trying to write my own implementation using yours as a point of reference apart from using GLFW instead of SDL2.

Was wondering why you chose SDL2 in the end? Was there a consideration for GLFW?

I looked at the other issue and have actually ran into a similar problem with NSView and unfortunately GLFW has no glfwGetCocoaView() type function (but strangely has a glfwGetCocoaWindow for NSWindow)

iffyloop commented 1 year ago

I just used SDL because it's commonly used in many applications. GLFW should work too but hasn't been tested. Is there a way to get an NSView from an NSWindow? Does NSWindow inherit NSView? Not very familiar with macOS native development yet...

mightgoyardstill commented 1 year ago

yeah there is a way to get NSView from NSWindow, I figured it out similar to how it was solved from the last issue! (its a little bit hacked together but it works for now!)

#import <Cocoa/Cocoa.h>
#import <CoreFoundation/CoreFoundation.h>

#import "platform.h"

void* platform::getNSView(GLFWwindow* window)
{
  NSWindow* nsWindow = glfwGetCocoaWindow(window);
  return (__bridge void*)([nsWindow contentView]);
}

and in platform.h:

#pragma once

#include <glfw3.h>
#define GLFW_EXPOSE_NATIVE_COCOA
#include <glfw3native.h>
#define GLFW_NATIVE_INCLUDE_NONE

class platform {
  public:
    static void* getNSView(GLFWwindow* wind);
};

my aim here is to create a platform class that handles different defines for the glfw3native.h file and then have one for mac, windows and linux and then in the part of the code where im attaching the view to glfw just have a #if preprocessor which acts according to

platform::getNSView(window) platform::getHWND(window) platform::getX11(window)

iffyloop commented 1 year ago

Great, happy to see it worked! Thank you so much for sharing your code above. I'll close this issue for now but if you want to share your platform class once it's done then feel free to comment again, or better yet make a PR with an example! No need to do that though if it creates more work for you.