A few more noob questions -

Mikey0727

Newcomer
Joined
Mar 26, 2005
Messages
5
Hi,

My project uses directX to render several MDI child forms. In the activate event of each child form is:

Code:
parameters = new PresentParameters();
parameters.SwapEffect = SwapEffect.Discard;
parameters.AutoDepthStencilFormat = DepthFormat.D16;
parameters.EnableAutoDepthStencil = true;
parameters.Windowed = true;
video = new Device(0,DeviceType.Hardware, this,CreateFlags.SoftwareVertexProcessing,parameters);

In the OnPaint Event of each form is the render loop. A few questions -

1. Is there a better way to switch between rendering forms other than creating a new device each time.

2. With this setup, sometimes when I press the close box on one of the child forms the program takes extremely long o shut down the form. Is there something I should be doing in the Closing code to exit properly?

3. My render loop looks like this:

Code:
node = Mesh.Sphere(this.video,0.1f,15,15);

video.BeginScene();

node.DrawSubset(0);
video.Transform.World = Matrix.Translation(0.5f,0.5f,0.0f);
node.DrawSubset(0);
		
video.EndScene();
video.Present();
this.Invalidate();

For some reason, the first node is drawing, the world is moving , but the second node does not appear. Is there something I need to do to the mesh to make it draw a second time?

Thanks -
 
1: A device is tied to a window, so not really. What you can do is keep resetting the device into a new window everytime you switch to it.
2: You should be disposing of the device and any meshes, resources, etc.
3: The object that is actually appearing is the second sphere. It happens because everytime you finish drawing your scene matrices get reset, so you are not setting any world matrix for your first object so it follows the next matrix you set.

Ask if you need help with any of this :D.
 
mutant said:
1: A device is tied to a window, so not really. What you can do is keep resetting the device into a new window everytime you switch to it.
2: You should be disposing of the device and any meshes, resources, etc.
3: The object that is actually appearing is the second sphere. It happens because everytime you finish drawing your scene matrices get reset, so you are not setting any world matrix for your first object so it follows the next matrix you set.

Ask if you need help with any of this :D.

OK, im a little confused on number 3 - If the second sphere is the one drawing, then how come when I just draw 1 sphere with no translation, the sphere ends up in the middle of the screen? I read TPG's tutorial on transforms and things, but i guess Im missing it. Also, how can the first object follow the next matrix, if it should already be drawn into the buffer? Please shed some more light on this 1, I guess I missed the boat -

Thanks
 
1)When you set the World transform it is just like setting any other variable. You set it to that particular translation and it stays that way unless you set it to something else. So after the very first frame processes the World transform is set to (.5,.5,.5), so in the second frame it is STILL set to that so the first node is being drawn exactly where the second one is.

2) Don't allocate stuff in your render loop.
 
Back
Top