My C# code is drawing all the colored dots except the magenta one. Here's the code:
scr_draw_dot((Int16)(mmbxo-20), (Int16)(mmbyo+20), 2, 0, A);
scr_draw_dot((Int16)(mmbxo-20), (Int16)(mmbyo+22), 2, 1, A);
scr_draw_dot((Int16)(mmbxo-20), (Int16)(mmbyo+24), 2, 2, A);
scr_draw_dot((Int16)(mmbxo-20), (Int16)(mmbyo+26), 2, 3, A);
scr_draw_dot((Int16)(mmbxo-20), (Int16)(mmbyo+28), 2, 4, A);
scr_draw_dot((Int16)(mmbxo-20), (Int16)(mmbyo+30), 2, 5, A);
scr_draw_dot((Int16)(mmbxo-20), (Int16)(mmbyo+32), 2, 6, A);
scr_draw_dot((Int16)(mmbxo-20), (Int16)(mmbyo+34), 2, 7, A);
scr_draw_dot((Int16)(mmbxo-20), (Int16)(mmbyo+36), 2, 8, A);
scr_draw_dot((Int16)(mmbxo-20), (Int16)(mmbyo+38), 2, 9, A); // this is the only one not showing up
scr_draw_dot((Int16)(mmbxo-20), (Int16)(mmbyo+40), 2, 10, A);
scr_draw_dot((Int16)(mmbxo-20), (Int16)(mmbyo+42), 2, 11, A);
The scr_draw_dot code:
public void scr_draw_dot(Int16 xx, Int16 yy, byte ds, byte cn, float A)
{
for (byte j = 0; j < ds; j += 1)
{
for (byte i = 0; i < ds; i += 1)
{
// TODO: major weird bug here, not drawing the pink dot (cn == 9)
oGcn.TG.scr_dpp(oGcn.TG.Tiles_Dots, (Int16)(xx+i), (Int16)(yy+j), cn, 0, 1, 1, Color.White*A);
}
}
}
and the scr_dpp code from TG:
public void scr_dpp(Texture2D pic, Int16 xx, Int16 yy, Int16 sx, Int16 sy, Int16 sw, Int16 sh, Color C) // draw pic partial
{
if (pic == null)
return;
// this draws a piece of a picture taken from the source (s) xywh and drawn at xx yy
SB.Draw(pic, new Vector2(xx, yy), new Rectangle(sx, sy, sw, sh), C);
}
The pic used (Tiles_Dots) is a little unusual. It's a 13x1 PNG file that holds 13 colored dots. The tenth dot (index 9) is magenta. Here's a screenshot:
I already checked the PNG for transparent alpha in the magenta dot and did not find it. What on Earth could be causing this bug?
Some more info: originally XNA 4.0, but actually using MonoGame now with DirectX 10 targetting .Net 4.0. I still use XNA to compile the .XNB files such as that Tiles_Dots. This is a 100% 2D game, not 3D, and I use the scr_dpp (draw pic partial) everywhere to draw pieces or frames from a grid of animations. Never had a problem with it until now.
Screen shot of what's being drawn:
I blew up the minimap so you can see the pink dot is missing. BTW, that orange dot on the checkered minimap represents the orange chess piece, and there are supposed to be pink dots for the pink chess pieces too. The first code block earlier was drawing a vertical line of dots for testing purposes.
EDIT: here's the draw code, which indeed switches rendertargets:
protected override void Draw(GameTime dt)
{
GraphicsDevice.SetRenderTarget(RENTAR); // change rendertarget BEFORE SB.begin
if (GGG.GameState == GCN.GSType.Level)
{
SB.Begin();
GraphicsDevice.DepthStencilState = new DepthStencilState() { DepthBufferEnable = true };
GraphicsDevice.Clear(Color.Transparent);
GGG.scr_draw_levelshadows();
SB.End();
}
GraphicsDevice.SetRenderTarget(null); // change rendertarget NOT INSIDE SB.begin SB.end
SB.Begin();
GraphicsDevice.Clear(Color.White);
GGG.scr_draw();
if (GGG.GameState == GCN.GSType.Level)
{
float A = (float)GGG.show_shadows_i/GCN.i_show_max;
scr_drt(RENTAR, new Rectangle(0*GGG.bxo, 0*GGG.byo, 800, 600), Color.White*(A*0.1875f));
GGG.scr_draw_level2();
}
// do tooltips
if (GGG.tttxt != "")
{
scr_dtt((Int16)(GGG.MS.X), (Int16)(GGG.MS.Y-(Int16)(Math.Round(fnt_CM8.MeasureString(GGG.tttxt).Y + 2))), GGG.tttxt, Color.White);
GGG.tttxt = "";
}
SB.End();
base.Draw(dt);
}
The reason for switching rendertargets is to draw the shadows as one giant black mass which is then adjusted alpha, which is then drawn back onto the screen. Otherwise the shadows would blend like a ven diagram with a darker region in the intersections, which is not how it should look in real life.