Jump to content
  • Advertisement
Sign in to follow this  
billconan

can i create a device with picturebox? (c#)

This topic is 4786 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

hi guys, can i render my scene into a picturebox? i tried with this code, but it doesn't work. device = new Microsoft.DirectX.Direct3D.Device(0,Microsoft.DirectX.Direct3D.DeviceType.Hardware,this.PictureBox, CreateFlags.SoftwareVertexProcessing, presentParams); it works perfectly with winform. i don't know why? thanks

Share this post


Link to post
Share on other sites
Advertisement
What did you set in your PresentParameters class? If you set the DeviceWindow to null, it uses the focus window, so you probably should set that as well.

Share this post


Link to post
Share on other sites
What sometimes happens is that as a parameter you need to explicity pass the handle of the control as an argument to the device constructor.


device = new Microsoft.DirectX.Direct3D.Device(0,Microsoft.DirectX.Direct3D.DeviceType.Hardware,PictureBox.Handle,CreateFlags.SoftwareVertexProcessing,presentParams);



PS: Rendering to a Panel control is what most people use.

I hope this helps,
Take care.

Share this post


Link to post
Share on other sites
look did u load the initialization of the pcturebox { InitializeComponents } maybe u have forgotten to do this and the error u are having is because u didnot create an instance from the picturebox . hope this will help

Share this post


Link to post
Share on other sites
this is the code which doesn't work. i use picturebox because i've heard that only form and picturebox can hold the directx device. guess i should change it to panel now.

PresentParameters presentParams = new PresentParameters();
presentParams.Windowed=true;
presentParams.DeviceWindow=this.mainForm.devicePictureBox;
presentParams.SwapEffect = SwapEffect.Discard;
presentParams.EnableAutoDepthStencil = true;
presentParams.AutoDepthStencilFormat = DepthFormat.D16;
device = new Microsoft.DirectX.Direct3D.Device(0,Microsoft.DirectX.Direct3D.DeviceType.Hardware,this.mainForm.devicePictureBox.Handle,
CreateFlags.SoftwareVertexProcessing, presentParams); //Create a device



[Edited by - billconan on November 6, 2005 4:22:23 AM]

Share this post


Link to post
Share on other sites
hi guys, i changed it to panel, it seems working, but still weird, cause the model of the scene is missing, and i get only the background rendered.

Share this post


Link to post
Share on other sites
It's generally a good idea to work with a nice depth/stencil format such as D24S8
This caters for a Depth buffer of 24 bits and a stencil buffer of 8 bits. Also you might want to disable lighting if you don't have any lights in your scene.

i.e.
Device.RenderState.Lighting = false;

I hope this helps.
Take care.

Share this post


Link to post
Share on other sites
hi thanks
some screenshots, i changed the depth to d24s8, still the same.

this is the scene that i rendered with form:


and this is the current scene with the panel:



my scene has a light.


PresentParameters presentParams = new PresentParameters();
presentParams.Windowed=true;
presentParams.DeviceWindow=this.mainForm.devicePanel;
presentParams.SwapEffect = SwapEffect.Discard;
presentParams.EnableAutoDepthStencil = true;
presentParams.AutoDepthStencilFormat = DepthFormat.D24S8;
device = new Microsoft.DirectX.Direct3D.Device(0,Microsoft.DirectX.Direct3D.DeviceType.Hardware,this.mainForm.devicePanel,
CreateFlags.SoftwareVertexProcessing, presentParams); //Create a device

Share this post


Link to post
Share on other sites
i made it! i changed the this.mainForm.devicePanel to this.mainForm.devicePanel.Handle and it works! thanks guys!
the quality is kinda low now, the lines became wider and rendering result is coarse. :(

Share this post


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

  • Advertisement
×

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!