Jump to content

View more

Image of the Day

Boxes as reward for our ranking mode. ヾ(☆▽☆)
#indiedev #gamedev #gameart #screenshotsaturday https://t.co/ALF1InmM7K
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.

Sign up now

render 3D primitive

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 granberg   Members   


Posted 28 August 2011 - 05:45 AM

Hi guys!I have been render two 3D graphics on my project,but I hope they can display together with the 2D sprite together,but unfortunately if I write spriteBatch.Begin(SpriteBlendMode.AlphaBlend); // start drawing 2D images

spriteBatch.Draw(rockTexture, rockPosition, null, Color.White,
rockRotation, rockCenter, 1.0f, SpriteEffects.None, 0.0f);
spriteBatch.Draw(shipTexture, shipPosition, null, Color.White,
shipRotation, shipCenter, 1.0f, SpriteEffects.None, 0.0f);

thease instruction to Draw function,the 3D primitive can not be displayed why?have you can fix the problem?

#2 NEXUSKill   Members   


Posted 01 September 2011 - 11:28 AM

The sprite batch changes a few settings of the graphics device to put its 2d graphics on the screen, when you move on to rendering 3d content those settings prevent them from being properly rendered.

To render 3d content you use shaders, and to use a shader you have to manually set the necessary settings and parameters of the graphics device for it to work, the SpriteBatch instead is not a shader, it uses a shader inside, but abstracts you from all those settings.
If you use 3d graphics only, many settings will be in a default state that you do not need to change for 3d content, however the sprite batch changes them and does not restore them to their original state unless you tell it to, if I'm not wrong this is done by setting the following parameter on the begin call of the SpriteBatch


By default this is set to None, which does not restore original settings after the end call. If you are only going to render 2d though, you want it set to none, changing render states is expensive and should be done as less as possible.

Game making is godlike

LinkedIn profile: http://ar.linkedin.com/pub/andres-ricardo-chamarra/2a/28a/272

#3 granberg   Members   


Posted 07 September 2011 - 11:28 AM

Is it mean change it as spriteBatch.Begin(SaveStateMode.SaveState); correct?but the compiler say no,because some unusefull parameter within the begin call.

#4 dAND3h   Members   


Posted 05 April 2012 - 06:43 PM

Normally when you cant see things being drawn, it is to do with the depth buffer. Without the depth buffer enabled, components will be drawn in the order they were added to the component list and not their order in 3d space. I cant say for sure, because I don't know how you coded it, but just try enabling the depth buffer before you draw the primitives.
So, inside the draw method, set :
GraphicsDevice.DepthStencilState = DepthStencilState.Default;

And if your not already, you should draw any 2d sprites AFTER you draw your 3d models/primitives. So put the spriteBatch.Draw() after the call to base.Draw() in your draw method.

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.