Can't load libOgre.dll in C#
Posted: Mon Feb 22, 2021 6:33 pm
Ogre Version: 1.12.11
Operating System: Windows 10 Pro x64
Render System: DX11 I guess
I did with success the example made at https://github.com/OGRECave/ogre/tree/m ... les/Csharp
But now I want to do it in my own project. So I've created a WPF project in C# and when I try to run the example it throws me an error saying it couldn't load libOgre.dll at var app = new Example();
I'm running in x64 debug mode in Visual Studio Community
Should I include more than Ogre.dll reference in my project or any other files? I'm pretty new to Ogre and I wanted to create an application with a 3D preview powered by Ogre inside my main window
This is the whole code, I just copypasted it from the example:
Operating System: Windows 10 Pro x64
Render System: DX11 I guess
I did with success the example made at https://github.com/OGRECave/ogre/tree/m ... les/Csharp
But now I want to do it in my own project. So I've created a WPF project in C# and when I try to run the example it throws me an error saying it couldn't load libOgre.dll at var app = new Example();
I'm running in x64 debug mode in Visual Studio Community
Should I include more than Ogre.dll reference in my project or any other files? I'm pretty new to Ogre and I wanted to create an application with a 3D preview powered by Ogre inside my main window
This is the whole code, I just copypasted it from the example:
Code: Select all
using System.Windows;
using org.ogre;
namespace TesteWPFOgre
{
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void Button_Click(object sender, RoutedEventArgs e)
{
var app = new Example();
app.initApp();
app.getRoot().startRendering();
app.closeApp();
}
}
public class KeyListener : InputListener
{
org.ogre.ApplicationContext ctx;
public KeyListener(org.ogre.ApplicationContext ctx)
{
this.ctx = ctx;
}
public override bool keyPressed(KeyboardEvent evt)
{
if (evt.keysym.sym == 27)
ctx.getRoot().queueEndRendering();
return true;
}
}
public class Example : org.ogre.ApplicationContext
{
InputListener listener;
public Example()
{
listener = new KeyListener(this);
}
public override void setup()
{
base.setup();
addInputListener(listener);
var root = getRoot();
var scnMgr = root.createSceneManager();
var shadergen = ShaderGenerator.getSingleton();
shadergen.addSceneManager(scnMgr); // must be done before we do anything with the scene
scnMgr.setAmbientLight(new ColourValue(.1f, .1f, .1f));
var light = scnMgr.createLight("MainLight");
var lightnode = scnMgr.getRootSceneNode().createChildSceneNode();
lightnode.setPosition(0f, 10f, 15f);
lightnode.attachObject(light);
var cam = scnMgr.createCamera("myCam");
cam.setAutoAspectRatio(true);
cam.setNearClipDistance(5);
var camnode = scnMgr.getRootSceneNode().createChildSceneNode();
camnode.attachObject(cam);
var camman = new CameraMan(camnode);
camman.setStyle(CameraStyle.CS_ORBIT);
camman.setYawPitchDist(new Radian(0), new Radian(0.3f), 15f);
addInputListener(camman);
var vp = getRenderWindow().addViewport(cam);
vp.setBackgroundColour(new ColourValue(.1f, .1f, .1f));
var ent = scnMgr.createEntity("Sinbad.mesh");
var node = scnMgr.getRootSceneNode().createChildSceneNode();
node.attachObject(ent);
}
}
}