I'm working on C# and trying to get a skybox to work. I followed the rather old PDF tutorial which seemed rather logical.
I have a cube and a skybox behind it (well, ideally).
At the moment, I get either the cube or the skybox, depending on which world is initialized last.
The 2 following examples are the same, except that in the first one, the Main world gets created before the Sky world, and in the second one, the Sky world gets created before the Main world. Thing being: The last world created is what I get on screen.
Examples:
1. With this code, I only get the skybox:
public static void Main()
{
//Initialize
FileSystem.AbstractPath = @"C:\Program Files\LE2.3";
Graphics.Initialize(1440, 900);
//Main
World world = new World();
Camera cam = new Camera();
cam.ClearMode = CameraClearMode.Depth;
Buffer lightBuffer = new Buffer(1440, 900, (int)BufferType.Color | (int)BufferType.Depth | (int)BufferType.Normal);
Mesh.CreateCube().Position = new Vector3(0, 0, 5);
//Sky
World background = new World();
Mesh skybox = Mesh.CreateCube();
Camera skycam = new Camera();
skybox.Flip();
skybox.Material = Material.Load("abstract::Sky01.mat");
while (!Keyboard.KeyHit(Key.Escape))
{
Timing.Update();
World.Update(Timing.Speed);
Buffer.Current = lightBuffer;
skycam.Rotation = cam.Rotation;
World.Current = background;
World.Render();
World.Current = world;
World.Render();
Buffer.Current = Buffer.Back;
Light.Render(lightBuffer);
Graphics.Flip();
}
Engine.Terminate();
}
2. With this code, I only get the cube:
public static void Main()
{
//Initialize
FileSystem.AbstractPath = @"C:\Program Files\LE2.3";
Graphics.Initialize(1440, 900);
//Sky
World background = new World();
Mesh skybox = Mesh.CreateCube();
Camera skycam = new Camera();
skybox.Flip();
skybox.Material = Material.Load("abstract::Sky01.mat");
//Main
World world = new World();
Camera cam = new Camera();
cam.ClearMode = CameraClearMode.Depth;
Buffer lightBuffer = new Buffer(1440, 900, (int)BufferType.Color | (int)BufferType.Depth | (int)BufferType.Normal);
Mesh.CreateCube().Position = new Vector3(0, 0, 5);
while (!Keyboard.KeyHit(Key.Escape))
{
Timing.Update();
World.Update(Timing.Speed);
Buffer.Current = lightBuffer;
skycam.Rotation = cam.Rotation;
World.Current = background;
World.Render();
World.Current = world;
World.Render();
Buffer.Current = Buffer.Back;
Light.Render(lightBuffer);
Graphics.Flip();
}
Engine.Terminate();
}
Now questions on what my problem is:
1. Am I missing something obvious?
2. If not, is there a problem in this code?
3. If not, where do you think the problem is in my wrapper? (I doubt it is)
4. If not, where is the problem in Leadwerks?
5. If not, let's pray together?
Thanks a lot in advance. I know you're not used to C#, but it's more than understandable to anyone who can read.