-Due to spam, wiki editing has been restricted to the dev team only. Sorry for any inconvenience-
Resizeable Render Target
From IrrlichtSharp
In this tutorial we will learn how to use ILS to render to a resizeable window without the risk of distortion. This would be useful for a windowed map editor or just about any other windowed application using 3D graphics.
We will assume that the reader...
- knows how to program in C#
- has downloaded all necessary assemblies
- knows how to initialize and use the rudimentary functions of the ILS Engine
- has a sense of humor
- you'll need it
- trust me
First, create a new class that is derived from the Microsoft.Windows.Form class. Either do it manually or use the Visual Studio Project Template "Windows Application". I don't want to hear any grumbling about Microsoft or Windows. (You're coding in C# for crying out loud!)
For fields you will need:
IlsDevice device bool windowResized = false; // Notifies the rendering loop that we need to resize
You will need to utilize your form's "Resize", "Move", and "Shown" events. The Resize and Move events should set
windowResized = true
and the Shown event should run the rendering loop.
The rendering loop should look something like this...
VideoDriver driver = device.VideoDriver;
SceneManager smgr = device.SceneManager;
if (driver == null) return;
do
{
windowResized = false;
while (device.Run() && windowResized == false)
{
if (device.IsWindowActive())
{
driver.BeginScene(Color.Blue);
smgr.SceneManager.DrawAll();
driver.EndScene();
}
}
driver.OnResize(ClientSize);
smgr.ActiveCamera.ChangeAspectRatio();
} while (windowResized);
And there you have it. Thought this would be hard did you? You should be just about ready to design your own MMORPG... or not.
Submitted by:
Valnarus 16:07, 24 Oct 07 (CST)
