[Problem solved !
I canno't answer with the response because i have less than 10 reputations. I have to wait 8 hours.]
Currently, i'm trying to display 3 viewports.
1st : This viewport is the entire screen (with camera1 transformation, like zoom)
viewportDefault = GraphicsDevice.Viewport;
2nd : This viewport is over the 1st viewport, but only width:400 height:200 at left bottom of the screen (with camera2 transformation)
viewport2 = new Viewport(0, 520, 400, 200);
3rd : This viewport is over the others, the entire screen, fond Color.Transparant. Just to display some text all over the screen, for me. (without camera transformation)
viewportDevStrings = viewportDefault;
Here is my code :
protected override void LoadContent()
{
//viewports
viewportDefault = GraphicsDevice.Viewport;
viewport2 = new Viewport(0, 520, 400, 200);
viewportDevStrings = viewportDefault;
}
protected override void Draw(GameTime gameTime)
{
GraphicsDevice.Viewport = viewportDefault;
DrawScene(camera1.transformation);
if(ThisIsABool)
{
GraphicsDevice.Viewport = viewport2;
DrawScene(camera2.transformation);
}
GraphicsDevice.Viewport = viewportDevStrings;
DrawStrings();
}
The problem is, when ThisIsABool == true, viewport2 is the entire screen...
When i look the "Watch added", here they are :
viewportDefault {X:0 Y:0 Width:1280 Height:720 MinDepth:0 MaxDepth:1}
viewport1 {X:0 Y:520 Width:400 Height:200 MinDepth:0 MaxDepth:1}
viewportDevStrings {X:0 Y:0 Width:1280 Height:720 MinDepth:0 MaxDepth:1}
Do you have some suggestions ? :( Hope you can help...
--------------------------EDIT---------------------------
public void DrawScene(Matrix transform)
{
DrawScene1(transform);
DrawScene2(transform);
DrawScene3();
}
public void DrawScene1(Matrix transform)
{
spriteBatch.Begin(
SpriteSortMode.Deferred,
BlendState.AlphaBlend,
SamplerState.LinearClamp,
null,
null,
null,
transform
);
GraphicsDevice.Clear(Color.Black);
map_background1.Draw(spriteBatch);
map_background2.Draw(spriteBatch);
map_background3.Draw(spriteBatch);
spriteBatch.End();
}
public void DrawScene2(Matrix transform)
{
spriteBatch.Begin(
SpriteSortMode.Deferred,
BlendState.AlphaBlend,
SamplerState.LinearClamp,
null,
null,
null,
transform
);
character.Draw(spriteBatch);
door.Draw(spriteBatch);
monster.Draw(spriteBatch);
spriteBatch.End();
}
public void DrawScene3()
{
BlendState blendState = new BlendState();
blendState.ColorSourceBlend = Blend.DestinationColor;
blendState.ColorDestinationBlend = Blend.SourceColor;
spriteBatch.Begin(
SpriteSortMode.Immediate,
blendState,
SamplerState.LinearClamp,
null,
null,
null
);
spriteBatch.Draw(RenderTargetForShadows, Vector2.Zero, Color.White);
spriteBatch.End();
}
DrawScenecode. I am thinking that you may have something wrong in your spritebatch.begin method – Jastill Jan 31 at 23:53