Jump to content
  • Advertisement
Sign in to follow this  
ICUP

How to load a mesh in two or more windows?

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

Can meshes not be loaded once and drawn in two viewports? How can meshes be shown in two or more viewports? I'm able to get a mesh drawn in one window, but if it tries to draw in a second, I get this error:

"Both a vertex shader and pixel shader must be set on the device before any draw operations may be performed."

If I only draw in one viewport, it works fine and the meshes show up.

Share this post


Link to post
Share on other sites
Advertisement
For multiple viewports you should have a single device, whereas you appear to be creating one per viewport. You can choose what to render to by using the various parameters to Present().

Share this post


Link to post
Share on other sites
Thanks Steve.

I'm new to C# and XNA (come from a C++, SDL background). Can you give me a little more detail on how to use it? I'm looking at the msdn documentation right now and I'm not sure how to use one of the three overloaded methods.

Share this post


Link to post
Share on other sites
If you're going to be working with XNA, you should take a look at the XNA Winforms sample:

http://create.msdn.c...nforms_series_1

As Steve said, it's generally a good idea to have a "one device, multiple window" setup. So all your content (models, textures, etc - anything associated with the device) exist in one context. Its then a matter of drawing your geometry and presenting it to the appropriate window.

An example: You have a model editor with four views, each view is its own control that you're rendering to (and they're attached to a Form). You'll be drawing the same geometry four times, and each time presenting to a different view. An alternative way would be using a single window, and each time you render the scene, you're rendering to only a section of the window (the area of the surface you're rendering to doesn't actually have to be the whole surface, here's an XNA tutorial illustrating what I mean).

Now using XNA to render to different windows can get a little hairy (which is why I referred to the start of the Winform XNA tutorials). The graphics device also owns the "swapchain" (back/front buffer sequence) so it's going to be a shared resource between your windows which can be a problem for windows with different sizes. The XNA winforms example deals with this by resizing the backbuffer to the current largest window size, and each time you're presenting you're only using a subset of the backbuffer.

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!