Jump to content
  • Advertisement
Sign in to follow this  
JaggedSac

Binding Managed DirectX device to a Panel

This topic is 4119 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am creatint an animal simulation system that displays a terrain and the animals on it. I have tested the terrain builder with a form that the device renders to a panel. Everything works perfect. I try putting the methods into my main form and all the panel displays is the ccleared background. I know that it is entering the Paint event method but I have no idea why it isnt displaying my terrain. Here is what I think is the relevant code. If more is needed I will gladly post. static void Main() { using(SimulationForm simForm = new SimulationForm()) { simForm.InitializeDevice(); simForm.InitializeLighting(); simForm.InitializeCamera(); simForm.InitializeTerrain(); Application.Run(simForm); } } private void InitializeDevice() { PresentParameters presentParams = new PresentParameters(); presentParams.Windowed = true; presentParams.SwapEffect = SwapEffect.Discard; presentParams.AutoDepthStencilFormat = DepthFormat.D16; presentParams.EnableAutoDepthStencil = true; device = new Device(0, DeviceType.Hardware, this.dxPanel, CreateFlags.HardwareVertexProcessing, presentParams); } private void dxPanel_Paint(object sender, System.Windows.Forms.PaintEventArgs e) { device.Transform.Projection = Matrix.PerspectiveFovLH((float)Math.PI / 4, xPanel.Width / dxPanel.Height, 1f, 10000f); device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.CornflowerBlue, 1.0f, 0); device.BeginScene(); device.Transform.World = Matrix.Scaling(1,1,1);(I just have this in here for terrain modification) tg.RenderTerrain(); device.Transform.World = Matrix.Identity;(I am not sure if DirectX resets world matrix everytime) device.EndScene(); device.Present(); this.Invalidate(); }

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!