Badspot
02-05-2015 18:29:27
So, I'm following the basic tutorial on how to embed an MOGRE into Windows.Forms (on OGRE page). I could compile the code without any problems and I checked if anything was right. But when running the application, It doesn't work and I receive a SEHException, locating here:
(MogreConfigFile.cpp)

My code in OgreForm.cs:
My code in Program.cs:
I've tried re-installing everything, even compiled MOGRE by my own and it still doesn't work. Some help would be nice. Thanks in Advance,
Badspot.
(MogreConfigFile.cpp)
My code in OgreForm.cs:
using Mogre;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Chuckya64_ULT
{
public partial class OgreForm : Form
{
Root mRoot;
RenderWindow mWindow;
public OgreForm()
{
InitializeComponent();
this.Size = new Size(800, 600);
Disposed += new EventHandler(OgreForm_Disposed);
Resize += new EventHandler(OgreForm_Resize);
}
void OgreForm_Resize(object sender, EventArgs e)
{
mWindow.WindowMovedOrResized();
}
void OgreForm_Disposed(object sender, EventArgs e)
{
mRoot.Dispose();
mRoot = null;
}
public void Go()
{
Show();
while (mRoot != null && mRoot.RenderOneFrame())
Application.DoEvents();
}
public void Init()
{
// Create root object
mRoot = new Root();
// Define Resources
ConfigFile cf = new ConfigFile();
cf.Load("resources.cfg", "\t:=", true);
ConfigFile.SectionIterator seci = cf.GetSectionIterator();
String secName, typeName, archName;
while (seci.MoveNext())
{
secName = seci.CurrentKey;
ConfigFile.SettingsMultiMap settings = seci.Current;
foreach (KeyValuePair<string, string> pair in settings)
{
typeName = pair.Key;
archName = pair.Value;
ResourceGroupManager.Singleton.AddResourceLocation(archName, typeName, secName);
}
}
// Setup RenderSystem
RenderSystem rs = mRoot.GetRenderSystemByName("Direct3D9 Rendering Subsystem");
// or use "OpenGL Rendering Subsystem"
mRoot.RenderSystem = rs;
rs.SetConfigOption("Full Screen", "No");
rs.SetConfigOption("Video Mode", "800 x 600 @ 32-bit colour");
// Create Render Window
mRoot.Initialise(false, "Main Ogre Window");
NameValuePairList misc = new NameValuePairList();
misc["externalWindowHandle"] = Handle.ToString();
mWindow = mRoot.CreateRenderWindow("Main RenderWindow", 800, 600, false, misc);
// Init resources
TextureManager.Singleton.DefaultNumMipmaps = 5;
ResourceGroupManager.Singleton.InitialiseAllResourceGroups();
// Create a Simple Scene
SceneManager mgr = mRoot.CreateSceneManager(SceneType.ST_GENERIC);
Camera cam = mgr.CreateCamera("Camera");
cam.AutoAspectRatio = true;
mWindow.AddViewport(cam);
Entity ent = mgr.CreateEntity("ninja", "ninja.mesh");
mgr.RootSceneNode.CreateChildSceneNode().AttachObject(ent);
cam.Position = new Vector3(0, 200, -400);
cam.LookAt(ent.BoundingBox.Center);
}
}
}
My code in Program.cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using Mogre;
namespace Chuckya64_ULT
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
OgreForm form = new OgreForm();
form.Init();
form.Go();
}
}
}
I've tried re-installing everything, even compiled MOGRE by my own and it still doesn't work. Some help would be nice. Thanks in Advance,
Badspot.