Jump to content

Why is my camera not clearing?


L B
 Share

Recommended Posts

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. :D

Link to comment
Share on other sites

There is no point "before "World.Current = background" and after the background "World.Render()"".

I tried putting Buffer.Clear(BufferType.Depth) at any point in the render loop: No use.

I also set the SkyCam's clear mode to Depth.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...