Giter Site home page Giter Site logo

Comments (11)

LukasBanana avatar LukasBanana commented on June 15, 2024

Can you share a code snippet? It's hard to tell what is going wrong by just looking at the summarized error messages. That looks like a syntax error so it should be easy to resolve.

from llgl.

kris3991 avatar kris3991 commented on June 15, 2024

OK. I was trying to create a custom surface using wxWidgets for LLGL in Xcode . As part of experimenting I decided to run the GLFW example shown in Part III Extensibility 7 Custom Surface Class. The error seems to pop up when we derive a class from LLGL::Surface. I am not facing any such issues in windows; While I am fairly confident there are no syntax errors, I will verify again. Does the xcode build require adding any Mac frameworks? Thanks for the response.

from llgl.

kris3991 avatar kris3991 commented on June 15, 2024

I had made a dumb mistake by loading headers improperly. Closing this issue. Thanks for taking the time.

from llgl.

kris3991 avatar kris3991 commented on June 15, 2024

Hi,

Rather than opening a new issue, I would like to seek some help again in a related issue. I was able to get everything up and running in windows but the following produces errors. I have taken away all of my source code with just headers and class declaration and issue persists. It's the same error as posted earlier.

#import <GLFW/glfw3.h>
#define GLFW_EXPOSE_NATIVE_COCOA
#import <GLFW/glfw3native.h>

//#import <Metal/Metal.h>
#import <QuartzCore/QuartzCore.h>
#import <simd/simd.h>

//#include "LLGL/Platform/MacOS/MacOSNativeHandle.h"
//#include <LLGL/LLGL.h>
//#include "LLGL/Platform/Platform.h"

#include <LLGL/LLGL.h>
#include <LLGL/Platform/NativeHandle.h>

//#include "LLGL/Platform/MacOS/MacOSNativeHandle.h"
//

//struct NativeHandle
//{
//    NSWindow* window;
//};
#include <LLGL/LLGL.h>

class CustomSurface : public LLGL::Surface {
//public:
//// Constructor and destructor
//CustomSurface(const LLGL::Extent2D& size, const std::string& title);
//~CustomSurface();
//// Interface implementation
//    bool GetNativeHandle(void* nativeHandle, std::size_t nativeHandleSize) const;
//LLGL::Extent2D GetContentSize() const override;
//bool AdaptForVideoMode(LLGL::VideoModeDescriptor& videoModeDesc) override; 
//void ResetPixelFormat() override;
//// Additional class functions
//void PollEvents();
//   
//
//private:
//GLFWwindow* CreateGLFWWindow();
//std::string title_;
//LLGL::Extent2D size_;
//GLFWwindow* wnd_ = nullptr; // GLFW window pointer
};

The problem seems to be created when NSWindow comes into play when i include "LLGL/Platform/MacOS/MacOSNativeHandle.h" for cast in
bool GetNativeHandle(void nativeHandle, std::size_t nativeHandleSize) const;*

For reference I am using:
https://www.glfw.org/docs/latest/group__native.html
and
https://github.com/glfw/glfw/blob/metal-guide/examples/metal.m

All help is appreciated.

from llgl.

LukasBanana avatar LukasBanana commented on June 15, 2024

the following produces errors

What kind of errors? Can you please post the error messages here?

If you inherit from Surface you have to implement the following pure virtual functions:

virtual bool GetNativeHandle(void* nativeHandle, std::size_t nativeHandleSize) const = 0;
virtual Extent2D GetContentSize() const = 0;
virtual bool AdaptForVideoMode(VideoModeDescriptor& videoModeDesc) = 0;
virtual void ResetPixelFormat() = 0;
virtual bool ProcessEvents() = 0;
virtual std::unique_ptr<Display> FindResidentDisplay() const = 0;

from llgl.

kris3991 avatar kris3991 commented on June 15, 2024

Hi,
I have done all that. I am getting the errors in the screenshot when I include LLGL/Platform/MacOS/MacOSNativeHandle.h and derive a surface from LLGL::Surface. I have created the body for virtual functions.

Using this as reference:
auto handle = reinterpret_castLLGL::NativeHandle*(nativeHandle);
handle->window = glfwGetWin32Window(wnd_);

like
handle->window = glfwGetCocoaWindow(wnd_);

and so on.

So I am assuming I have redefinition happening somewhere with relation to NSWindow*. I don't think these errors are related to abstract classes.
I can post the function definitions if required.

from llgl.

kris3991 avatar kris3991 commented on June 15, 2024

llglGlfw.h:

#define GLFW_INCLUDE_NONE
#import <GLFW/glfw3.h>
#define GLFW_EXPOSE_NATIVE_COCOA
#import <GLFW/glfw3native.h>

//#import <Metal/Metal.h>
#import <QuartzCore/QuartzCore.h>
#import <simd/simd.h>

//#include "LLGL/Platform/MacOS/MacOSNativeHandle.h"
//#include <LLGL/LLGL.h>
//#include "LLGL/Platform/Platform.h"

#include <LLGL/LLGL.h>
#include <LLGL/Utility.h>
//#include <LLGL/Platform/NativeHandle.h>

//#include "LLGL/Platform/MacOS/MacOSNativeHandle.h"
//

//struct NativeHandle
//{
//    NSWindow* window;
//};
#include <LLGL/LLGL.h>

class CustomSurface : public LLGL::Surface {
public:
//// Constructor and destructor
CustomSurface(const LLGL::Extent2D& size, const std::string& title);
~CustomSurface();
//// Interface implementation
    bool GetNativeHandle(void* nativeHandle, std::size_t nativeHandleSize) const;
LLGL::Extent2D GetContentSize() const override;
bool AdaptForVideoMode(LLGL::VideoModeDescriptor& videoModeDesc) override;
void ResetPixelFormat() override;
//// Additional class functions
bool ProcessEvents();
    std::unique_ptr<LLGL::Display> FindResidentDisplay() const;
//
//
//private:
GLFWwindow* CreateGLFWWindow();
std::string title_;
LLGL::Extent2D size_;
GLFWwindow* wnd_ = nullptr; // GLFW window pointer
};

llglGlfw.cpp:

//
#include "llglGlfw.h"



CustomSurface::CustomSurface(const LLGL::Extent2D& size, const std::string& title) : title_ { title },
size_ { size },
wnd_ { CreateGLFWWindow() }
{ }


CustomSurface::~CustomSurface() {
// Destroy GLFW window
glfwDestroyWindow(wnd_); }



GLFWwindow* CustomSurface::CreateGLFWWindow() {
// Create GLFW window with class members
auto wnd = glfwCreateWindow(size_.width, size_.height, title_.c_str(), nullptr, nullptr);
    if (!wnd)
throw std::runtime_error("failed to create GLFW window"); return wnd;
}

void CustomSurface::ResetPixelFormat() {
// Destroy and recreate GLFW window
glfwDestroyWindow(wnd_);
wnd_ = CreateGLFWWindow();
}

bool CustomSurface::GetNativeHandle(void* nativeHandle, std::size_t nativeHandleSize) const
{
    //To get this to work i obviously added "LLGL/Platform/MacOS/MacOSNativeHandle.h" since that introduced errors, i tried with metal/metal.h and declared struct NativeHandle above
    //I removed the frameworks i have added and tried again.
//    auto handle = reinterpret_cast<LLGL::NativeHandle*>(nativeHandle);
//    handle->window = glfwGetCocoaWindow(wnd_);
    return true;
}

//Extent2D GetContentSize() const
LLGL::Extent2D CustomSurface::GetContentSize() const {
// Actually the client-area size of the window must be returned, // but for this example the entire window size is sufficient.
    return size_;
}

bool CustomSurface::AdaptForVideoMode(LLGL::VideoModeDescriptor& videoModeDesc) {
// Resize GLFW window for the new video mode resolution.
size_ = videoModeDesc.resolution;
glfwSetWindowSize(wnd_, size_.width, size_.height);
    return true;
}


bool CustomSurface::ProcessEvents() {
// Poll events from GLFW windowing system
glfwPollEvents ();
// Return true until the user pressed the close button
return !glfwWindowShouldClose(wnd_); }


std::unique_ptr<LLGL::Display> FindResidentDisplay() const
{
    // i havent added the body here but i assume i should use
    //glfwGetCocoaMonitor
    //returning null for time being
    //please advice is this is wrong
    return nullptr;
}

int main(int argc, char* argv[])
{
    return 0;
}

//I can build successfully if i remove LLGL::NativeHandle* and the header LLGL/Platform/MacOS/MacOSNativeHandle.h so i am confused why the struct is causing issue within LLGL::Surface definition.

from llgl.

LukasBanana avatar LukasBanana commented on June 15, 2024

The screenshot shows error messages for wxWidgetsSource.cpp and it's hard to tell what exactly is going wrong without seeing the source line these errors refer to. Can you at least expand the error messages or show the full compiler report? Xcode uses clang by default and that compiler usually provides very helpful errors with line markers.

Besides that, can you try change this line from #include to #import, perhaps this is indeed a bug in LLGL as I have used it mostly on Windows:

from llgl.

kris3991 avatar kris3991 commented on June 15, 2024

Hi, I have tried changing it to #import and it did not help. Here are the list of errors from Xcode. Sorry for not posting it earlier.

In file included from /Volumes/work/widgetsLLGL/GLFW/callingWxWidgets/callingWxWidgets/llglGlfw.cpp:2:
In file included from /Volumes/work/widgetsLLGL/GLFW/callingWxWidgets/callingWxWidgets/llglGlfw.h:10:
In file included from ../../LLGL/include/LLGL/Platform/MacOS/MacOSNativeHandle.h:12:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/Cocoa.framework/Headers/Cocoa.h:12:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:8:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:9:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/usr/include/objc/NSObjCRuntime.h:9:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/usr/include/objc/objc.h:46:29: error: typedef redefinition with different types ('struct objc_object *' vs 'void *')
typedef struct objc_object id;
^
In file included from /Volumes/work/widgetsLLGL/GLFW/callingWxWidgets/callingWxWidgets/llglGlfw.cpp:2:
In file included from /Volumes/work/widgetsLLGL/GLFW/callingWxWidgets/callingWxWidgets/llglGlfw.h:4:
../glfw/3.3.4/include/GLFW/glfw3native.h:98:17: note: previous definition is here
typedef void
id;
^
In file included from /Volumes/work/widgetsLLGL/GLFW/callingWxWidgets/callingWxWidgets/llglGlfw.cpp:2:
In file included from /Volumes/work/widgetsLLGL/GLFW/callingWxWidgets/callingWxWidgets/llglGlfw.h:10:
In file included from ../../LLGL/include/LLGL/Platform/MacOS/MacOSNativeHandle.h:12:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/Cocoa.framework/Headers/Cocoa.h:12:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:8:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:492:1: error: expected unqualified-id
@Class NSString, Protocol;
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:494:9: error: unknown type name 'NSString'
typedef NSString * NSExceptionName NS_EXTENSIBLE_STRING_ENUM;
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:495:9: error: unknown type name 'NSString'
typedef NSString * NSRunLoopMode NS_EXTENSIBLE_STRING_ENUM;
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:497:19: error: unknown type name 'NSString'
FOUNDATION_EXPORT NSString *NSStringFromSelector(SEL aSelector);
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:498:44: error: unknown type name 'NSString'
FOUNDATION_EXPORT SEL NSSelectorFromString(NSString *aSelectorName);
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:500:19: error: unknown type name 'NSString'
FOUNDATION_EXPORT NSString *NSStringFromClass(Class aClass);
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:501:53: error: unknown type name 'NSString'
FOUNDATION_EXPORT Class _Nullable NSClassFromString(NSString *aClassName);
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:503:19: error: unknown type name 'NSString'
FOUNDATION_EXPORT NSString *NSStringFromProtocol(Protocol *proto) API_AVAILABLE(macos(10.5), ios(2.0), watchos(2.0), tvos(9.0));
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:503:50: error: unknown type name 'Protocol'
FOUNDATION_EXPORT NSString *NSStringFromProtocol(Protocol *proto) API_AVAILABLE(macos(10.5), ios(2.0), watchos(2.0), tvos(9.0));
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:504:19: error: unknown type name 'Protocol'
FOUNDATION_EXPORT Protocol * _Nullable NSProtocolFromString(NSString *namestr) API_AVAILABLE(macos(10.5), ios(2.0), watchos(2.0), tvos(9.0));
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:504:61: error: unknown type name 'NSString'
FOUNDATION_EXPORT Protocol * _Nullable NSProtocolFromString(NSString *namestr) API_AVAILABLE(macos(10.5), ios(2.0), watchos(2.0), tvos(9.0));
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:508:30: error: unknown type name 'NSString'
FOUNDATION_EXPORT void NSLog(NSString *format, ...) NS_FORMAT_FUNCTION(1,2) NS_NO_TAIL_CALL;
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:508:53: error: format argument not an NSString
FOUNDATION_EXPORT void NSLog(NSString *format, ...) NS_FORMAT_FUNCTION(1,2) NS_NO_TAIL_CALL;
~~~~~~~~~~~~~~~~ ^ ~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:94:49: note: expanded from macro 'NS_FORMAT_FUNCTION'
#define NS_FORMAT_FUNCTION(F,A) attribute((format(NSString, F, A)))
^ ~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:509:31: error: unknown type name 'NSString'
FOUNDATION_EXPORT void NSLogv(NSString *format, va_list args) NS_FORMAT_FUNCTION(1,0) NS_NO_TAIL_CALL;
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:509:63: error: format argument not an NSString
FOUNDATION_EXPORT void NSLogv(NSString *format, va_list args) NS_FORMAT_FUNCTION(1,0) NS_NO_TAIL_CALL;
~~~~~~~~~~~~~~~~ ^ ~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:94:49: note: expanded from macro 'NS_FORMAT_FUNCTION'
#define NS_FORMAT_FUNCTION(F,A) attribute((format(NSString, F, A)))
^ ~
In file included from /Volumes/work/widgetsLLGL/GLFW/callingWxWidgets/callingWxWidgets/llglGlfw.cpp:2:
In file included from /Volumes/work/widgetsLLGL/GLFW/callingWxWidgets/callingWxWidgets/llglGlfw.h:10:
In file included from ../../LLGL/include/LLGL/Platform/MacOS/MacOSNativeHandle.h:12:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/Cocoa.framework/Headers/Cocoa.h:12:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:10:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSArray.h:5:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObject.h:8:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSZone.h:9:1: error: expected unqualified-id
@Class NSString;
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSZone.h:19:63: error: unknown type name 'NSString'
FOUNDATION_EXPORT void NSSetZoneName(NSZone * _Nullable zone, NSString *name)NS_SWIFT_UNAVAILABLE("Zone-based memory management is unavailable");
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSZone.h:20:19: error: unknown type name 'NSString'
FOUNDATION_EXPORT NSString *NSZoneName(NSZone * _Nullable zone) NS_SWIFT_UNAVAILABLE("Zone-based memory management is unavailable");
^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
340 warnings and 20 errors generated.

Build failed 24/08/21, 10:29 PM 2.8 seconds

from llgl.

LukasBanana avatar LukasBanana commented on June 15, 2024

It looks like your source code you posted resides in a C++ file named llglGlfw.cpp. This won't enable Objective-C code in Xcode. So that would explain why you see so many errors regarding qualifier IDs such as @Class NSString;. That's simply something the C++ standard does not define, but Objective-C or Objective-C++ do.

Just rename your source file to something with the .mm ending to make it an Objective-C++ file and Xcode should enable those language features automatically.

You can see the same filename convention in the MacOS platform folder:
https://github.com/LukasBanana/LLGL/tree/master/sources/Platform/MacOS

from llgl.

kris3991 avatar kris3991 commented on June 15, 2024

Thanks for the help. That fixed the issue.

from llgl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.