Jump to content
  • Advertisement
Sign in to follow this  
jor1980

Problem using panel control to render c#

This topic is 2919 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, i am trying to use a panel control to render my scene when i used a form to render i made the next to avoid watch the form blinking

this.SetStyle(ControlStyles.AllPaintingInWmPaint |
ControlStyles.Opaque, true);



now that i am using a panel control to render, my panel is blinking and i can´t see my scene, i think that panel controls doesn´t have Setstyle method to make the same i did when i used a form so i don´t know how to solve this problem

Share this post


Link to post
Share on other sites
Advertisement
Yes you are right, now that i am trying to use that method in this way:

panel1.Setstyle

and i get this error:

it can´t get access to the protected member 'System.Windows.Forms.Control.Setstyle(System.Windows.Forms.Controlstyles, bool)'
using a certificate of the type 'System.Windows.Forms.Panel'; the certificate must be of the type 'MyTestProject.Form1' or derived from it.



What must i do?

Share this post


Link to post
Share on other sites
I have created a derived class from panel like this:


public class RenderPanel : System.Windows.Forms.Panel
{

}



Is it right? Now i would like to know if i can set the setstyle method infot this class or i must do it after i create an instance of this class?

Share this post


Link to post
Share on other sites
what api? xna? directx?

i have used xna to render to a c# panel before and had the blinking you are refering to as well. I derived a class from it and override the OnPaint and OnPaintBackground and just did nothing in both of the classes. not even call the base class methods and it fixed my problem.

Share this post


Link to post
Share on other sites
i have made this:


public class RenderPanel : System.Windows.Forms.Panel
{
public RenderPanel():base()
{
base.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.Opaque, true);
}
}





And my renderloop function is this:

Here is the function:


public void PaintLoop(Control miObjeto)
{
myDevice.SetRenderState(RenderState.CullMode, true);
myDevice.SetRenderState(RenderState.FillMode, FillMode.Solid);
myDevice.SetRenderState(RenderState.Lighting, false);

myDevice.Clear(ClearFlags.Target | ClearFlags.ZBuffer, new Color4(Color.Gray), 1, 0);
myDevice.MultiplyTransform(TransformState.Projection,Matrix.PerspectiveFovLH(3.1415F/4,miObjeto.Width/miObjeto.Height,1.0F,500000F));
myDevice.MultiplyTransform(TransformState.View,Matrix.LookAtLH(new Vector3(0,170,70),new Vector3(0,170,0),new Vector3(0,1,0)));


myDevice.BeginScene();

myDevice.VertexFormat = VertexFormat.Position | VertexFormat.Texture1|VertexFormat.Diffuse;

for (int i = 0; i < slimdxMeshList.Count; i++)
{
slimdxMeshList.DrawSubset(0);
}

myDevice.EndScene();
myDevice.Present();

miObjeto.Invalidate();
}





Now my only doubt is that when i create the renderpanel into my form i have to made this:

renderPanel = new RenderPanel();
renderPanel.Parent = this;


Are there anyway to make into my renderpanel class definition has as Parent the form into which a new renderpanel instance is created?

[Edited by - jor1980 on October 24, 2010 12:22:50 PM]

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.

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!