question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Fix MarshallAs issue with raylib structs

See original GitHub issue

There are issues getting unmanaged arrays with a fixed size to work in C#. I have had errors with using LoadShader throwing error “Method’s type signature is not PInvoke compatible”.

I am not sure what I am doing wrong. Here are the structs using MarshallAs currently and the array from C.

  • Mesh unsigned int vboId[7];
  • Shader int locs[MAX_SHADER_LOCATIONS];
  • Material MaterialMap maps[MAX_MATERIAL_MAPS];

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
ChrisDillcommented, Oct 12, 2018

Update, after looking at the different options it seems you cannot Marshall fixed size arrays without using the fixed keyword. This requires this library and any that use it to be compiled as unsafe. For now it will use this instead.

I will keep this issue open for now in case a better solution is found in the future.

0reactions
ChrisDillcommented, Jun 10, 2019

At the moment it is compiled as unsafe. I may keep it like that. I have tested using Span properties that use the IntPtr for mesh vertices, texcoords etc. Not sure if I prefer that.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Marshalling C struct with fixed size array into C# - ...
Im trying to Marshall a C struct into C# like so [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] public struct Shader { public ...
Read more >
Help with structs? : r/raylib
I'm trying to wrap rayLib for OpenXTalk. The help I have said: struct Color; [ 4 bytes] - // RGBA values, 4 char,...
Read more >
js game engine - OSCHINA - 中文开源技术交流社区
sge2d, SDL Game Engine 是一个平台无关的 2D 游戏C++编程框架。 2011-02-27 06:43:19. 3k.
Read more >
Ray
Hey! Just released a new side project: #raylib parser! A small C program to parse raylib.h and extract structs/enums/functions data.
Read more >
How to create a club on zwift
Keep reading to see how it works! Create Your Own Meetup Event. STCC has set up a club account to use for Zwift...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found