Thomas233
04-10-2009 15:54:33
Hi,
i`m getting a lot of access violations at runtime under certain circumstances. I`m initializing the engine as described in the Mogre/Ogre tutorials but when using i Viewport i`m getting an acess violation after rendering is started. Here`s some code:
First BaseEngine.StartupEngine() is called (using a default render configuration). Then BaseEngine.StartRendering() gets called and about 2-3 seconds after the window is rendered I get an access violation (where the inner exception is NULL). I only get this if I initialize a viewport (look at InitView()). If only a camera is initialized the window is rendered properly without any exception.
I`m using latest Mogre 1.6.2 binaries (debug) from this forum and Visual Studio 2008 SP2 (C++, C# etc.).
Anyone has an idea what`s wrong here ?
Thanks !
Thomas
i`m getting a lot of access violations at runtime under certain circumstances. I`m initializing the engine as described in the Mogre/Ogre tutorials but when using i Viewport i`m getting an acess violation after rendering is started. Here`s some code:
public partial class BaseEngine
{
public RenderTarget RootRenderTarget
{
//get { return Root.Singleton.AutoCreatedWindow; }
get; set;
}
public List<AttachableComponent> RenderComponents
{
get { return components; }
}
public SceneManager SceneManager
{
get; set;
}
public Camera MainCamera
{
//get { return this.SceneManager.GetCamera(EngineConfig.DefaultCameraName); }
get; set;
}
public Viewport MainViewPort
{
//get { return this.RootRenderTarget.GetViewport(0); }
get; set;
}
protected void StartupEngine(RenderConfiguration config)
{
InitCredentials(config);
InitConfig();
RootRenderTarget = Root.Singleton.Initialise(true);
InitListeners();
InitInput();
InitScene();
InitView();
}
protected void InitCredentials(RenderConfiguration config)
{
new Root();
RenderSystem renderSystem = null;
foreach (RenderSystem rs in Root.Singleton.GetAvailableRenderers())
{
if (config.RenderSystem.Equals(rs.Name))
renderSystem = rs;
}
if (renderSystem == null)
throw new GameEngineInitializationError("Rendering subsystem not found: " + config.RenderSystem);
Root.Singleton.RenderSystem = renderSystem; //default: DirectX 9
Root.Singleton.RenderSystem.SetConfigOption("Full Screen", config.FullScreen.ToString()); //default: false
Root.Singleton.RenderSystem.SetConfigOption("Video Mode", String.Format("{0} x {1} @ {2}-bit colour", new object[] { config.ResolutionWidth, config.ResolutionHeight, config.BitDepth })); //default: 640x480@32
}
protected void InitInput()
{
//
}
protected void InitScene()
{
SceneManager = Root.Singleton.CreateSceneManager(SceneType.ST_EXTERIOR_CLOSE,EngineConfig.DefaultSceneManagerName);
SceneManager.AmbientLight = new ColourValue(0, 0, 0);
}
protected void InitConfig()
{
ConfigFile configFile = new ConfigFile();
configFile.Load(EngineConfig.ResourcesConfigFile, "\t:=", true);
LoadResourcesConfig(EngineConfig.ResourcesConfigFile); // adds resource locations
}
protected void InitView()
{
MainCamera= SceneManager.CreateCamera(EngineConfig.DefaultCameraName);
MainCamera.Position = new Vector3(EngineConfig.CameraStartPosX, EngineConfig.CameraStartPosY, EngineConfig.CameraStartPosZ);
MainCamera.LookAt(new Vector3(EngineConfig.CameraStartPosX + 1, EngineConfig.CameraStartPosY - 1, EngineConfig.CameraStartPosZ + 1));
// Access violation if Viewport gets intialized !!!
MainViewPort = RootRenderTarget.AddViewport(MainCamera);
MainViewPort.BackgroundColour = new ColourValue(1, 1, 1);
MainCamera.AspectRatio = ((float)MainViewPort.ActualWidth) / ((float)MainViewPort.ActualHeight);
}
protected void InitListeners()
{
Root.Singleton.FrameStarted += FrameStarted;
}
public void StartRendering()
{
ResourceGroupManager.Singleton.InitialiseAllResourceGroups();
Root.Singleton.StartRendering(); //access violation here !!!
}
}
First BaseEngine.StartupEngine() is called (using a default render configuration). Then BaseEngine.StartRendering() gets called and about 2-3 seconds after the window is rendered I get an access violation (where the inner exception is NULL). I only get this if I initialize a viewport (look at InitView()). If only a camera is initialized the window is rendered properly without any exception.
I`m using latest Mogre 1.6.2 binaries (debug) from this forum and Visual Studio 2008 SP2 (C++, C# etc.).
Anyone has an idea what`s wrong here ?
Thanks !
Thomas