Pixel Doubling Not Perfect :|

My 2D game is using pixel doubling to have retro visuals. I achieve pixel doubling using glCopyTexSubImage2D, but there seems to be an error somewhere. Below are two images, the image on the left is performing the doubling correctly, the slightly larger image on the right is performing the doubling incorrectly. It seems odd window sizes throw the doubling off.

Projection Setup
I setup my projection pretty standard, and it gets called every time the window is resized.


private void SetProjection()
{
    GL.Viewport(0, 0, this.ClientSize.Width, this.ClientSize.Height);
    GL.MatrixMode(MatrixMode.Projection);
    GL.LoadIdentity();
    GL.Ortho(0, this.ClientSize.Width, this.ClientSize.Height, 0, -1.0, 1.0);

    GL.MatrixMode(MatrixMode.Modelview);
    GL.LoadIdentity();

    double TheTranslate = 0.375;
    GL.Translate(TheTranslate, TheTranslate, 0.0);
}

Render Code
Basically, I render the scene at 1x to the top left of my window, then I render it upside down to texture using glCopyTexSubImage2D, and then I render that texture back to the window using a quad.


private int MyPixW { get { return (int)Math.Ceiling(this.ClientSize.Width / 2.0); } }
private int MyPixH { get { return (int)Math.Ceiling(this.ClientSize.Height / 2.0); } }


public void sDisplay()
{
    int TheW = MyPixW;
    int TheH = MyPixH;

    CheckContext();

    SetProjection();

    GL.BindTexture(TextureTarget.Texture2D, MyOffscreenTexture);
    GL.CopyTexSubImage2D(TextureTarget.Texture2D, 0, 0, 0, 0, TheH, TheW, TheH);
    sCheckError();

    GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
    GL.ClearColor(Color.Black);

    DrawOffscreenTexture();
    MyControl.SwapBuffers();

    GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
    GL.ClearColor(Color.Black);

    sCheckError();
}

private void DrawOffscreenTexture()
{
    int TheW = MyPixW;
    int TheH = MyPixH;

    double TheSourceLeftX = 0;
    double TheSourceRightX = TheW / (double)MyOffscreenTextureSize;
    double TheSourceTopY = TheH / (double)MyOffscreenTextureSize;
    double TheSourceBottomY = 0;

    double TheDestLeftX = 0;
    double TheDestRightX = 2 * TheW;
    double TheDestTopY = 0;
    double TheDestBottomY = 2 * TheH;

    /* Now draw the offscreen buffer onto the screen. */
    GL.Begin(BeginMode.Quads);
    GL.Color4(Color.White);

    /* Top Left. */
    GL.TexCoord2(TheSourceLeftX, TheSourceTopY);
    GL.Vertex2(TheDestLeftX, TheDestTopY);

    /* Top Right. */
    GL.TexCoord2(TheSourceRightX, TheSourceTopY);
    GL.Vertex2(TheDestRightX, TheDestTopY);

    /* Bottom Right, */
    GL.TexCoord2(TheSourceRightX, TheSourceBottomY);
    GL.Vertex2(TheDestRightX, TheDestBottomY);

    /* Bottom Left.*/
    GL.TexCoord2(TheSourceLeftX, TheSourceBottomY);
    GL.Vertex2(TheDestLeftX, TheDestBottomY);

    GL.End();
}

and I can’t figure out for the life of me what I’ve done wrong. I’ve sketched it out on paper a dozen times, and each time I conclude that it should be working perfect, but it’s not. :expressionless: