I've hook a game that uses OpenGL and I'm trying to draw text on the window but when drawn, it has a background that I do not want.

Currently i'm using:

void glPrint(HDC DC, COLORREF Colour, int X, int Y, const char* format, ...)
{
    if (format == NULL) return;
    char text[256];
    va_list ap;
    va_start(ap, format);
    vsprintf(text, format, ap);
    va_end(ap);

    //SelectObject(DC, GetStockObject(DEFAULT_GUI_FONT));
    SetBkMode(DC, TRANSPARENT);
    SetTextColor(DC, Colour);

    TextOut(DC, X, Y, text, strlen(text));
}

And I test it using:

GL_EXPORT __stdcall BOOL GLHook_wglSwapBuffers(HDC hdc)
{
    Commands();
    bool Result = (*optr_wglSwapBuffers) (hdc);
    if (LogCalls)
    {
        glPrint(hdc, RGB(255, 0, 0), 0, 0, "Testing..");
    }
    return Result;
}

Yet it still has a black background :S. I tried Opaque too but that just makes the background white. I'm not aware of any other methods of drawing text.

Also is there a way to make an overlay/canvas ontop of a window? So that if I draw on that canvas, that window will not have the drawing but rather the canvas will. Reason i want to do this is so that I can just press a button and it will overlay on my window then press it again and it will be hidden but not erased.

Yeah I know. The colour is set but the user. The colour is fine. It's the background that comes with the text that isn't fine.. The background is supposed to be transparent but instead it's black. So my text is red with a black background instead of a transparent background.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.