1
\$\begingroup\$

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:

enter image description here

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:

enter image description here

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.

\$\endgroup\$
10
  • 1
    \$\begingroup\$ From what I recall, (255,0,255) is the default transparency color in XNA. Are you using rendertargets when drawing this? \$\endgroup\$
    – jgallant
    Commented Aug 8, 2016 at 9:52
  • 1
    \$\begingroup\$ Is the color transparent when you open it up in an image viewer program? The color, as far as I can tell, is magenta, which have a special meaning in some cases, often that it's transparent. First step would be to change the color slightly, from (255, 0, 255) to (254, 0, 255) perhaps, and see if that helps. \$\endgroup\$
    – William
    Commented Aug 8, 2016 at 9:52
  • \$\begingroup\$ @Jon yes, rendertargets are used. I edited the OP with the main draw code. It looks like you're right about default transparency too, which nonetheless boggles my mind. \$\endgroup\$
    – DrZ214
    Commented Aug 8, 2016 at 10:15
  • \$\begingroup\$ Yeah, I suspected as much. Basically do what Will has suggested, or change the default transparency color. I think there is also a way to force the transparency to be ignored, but I have no idea how to do it. \$\endgroup\$
    – jgallant
    Commented Aug 8, 2016 at 10:17
  • 1
    \$\begingroup\$ @DrZ214, Added an answer addressing your issue. I suddenly remembered that it was a setting on the content processor. :) \$\endgroup\$
    – William
    Commented Aug 8, 2016 at 10:41

1 Answer 1

3
\$\begingroup\$

What you're experiencing is the color key part from the XNA content processor. You can find the setting in the properties windows. What you want to do is disable color key entirely.

enter image description here

\$\endgroup\$
3
  • 1
    \$\begingroup\$ C l a s s i c . \$\endgroup\$
    – jgallant
    Commented Aug 8, 2016 at 10:44
  • \$\begingroup\$ This works too. I changed the dot back to pure magenta, set the Color Key Enabled to false, and rebuilt the xnb file. It works. However, it would be really dumb to have to do this for every picture file. Isn't there some way to make the color key disabled for every file, like change the default somewhere? BTW I forgot to mention I'm using VS 2010. \$\endgroup\$
    – DrZ214
    Commented Aug 8, 2016 at 11:24
  • \$\begingroup\$ BTW, if anyone else is searching for this, it's not a menu item under file or tools or something. It's a entry in the file itself. In the resource tree, right-click the picture file and "properties" should be the bottom entry of the popup menu. \$\endgroup\$
    – DrZ214
    Commented Aug 8, 2016 at 12:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .