Skip to main content
GameDev.net gamedev.net
🔒 Locked

GDI TextOut Problem...

Started by Daishim Jul 16, 2003 at 2:44 PM 3 replies 1k views
Original Post
Daishim
Daishim
I have a console that I'm adding into my RPG and I can get the console to AlphaBlend itself in the WinGDI to the surface, but I can't get it to use the normal BitBlt function. Well, the BitBlt function will blit the background from the buffer, but not the text. The code is the following.
void VIDEO::DrawConsole()
{
	COLORREF ColorInfo;
	int BlitConsolePosition = 0;
	int ConsoleMessageCount = Game->GetConsole()->GetMessageCount();

	if(Game->GetConsole()->GetHasChanged())
	{
		if(!BitBlt(hdcConsoleBufferImage, 0, 0, MAINWINDOWWIDTH, MAINWINDOWHEIGHT, hdcConsoleBackgroundImage, 0, 0, SRCCOPY))
		{
			MessageBox(hMainWindow, "Failure to blit ConsoleBackgroundImage to buffer!", "Video Error.", MB_OK | MB_ICONEXCLAMATION);
	
			PostQuitMessage(0);

		}

		ColorInfo = RGB(255, 255, 255);

		SetTextColor(hdcConsoleBufferImage, ColorInfo);

		SetBkMode(hdcConsoleBufferImage, TRANSPARENT);

		for(int i = 0; i <= ConsoleMessageCount; i++)
		{
			TextOut(hdcConsoleBufferImage, 0, BlitConsolePosition, Game->GetConsole()->GetMessage(i), strlen(Game->GetConsole()->GetMessage(i)));

			BlitConsolePosition += SPACEBETWEENLINES;

		}

		Game->GetConsole()->VisualUpdated();

	}

	if(Game->GetUseAlphaBlending())
	{
		BLENDFUNCTION BlendData;

		BlendData.AlphaFormat = NULL;
		BlendData.BlendFlags = NULL;
		BlendData.BlendOp = AC_SRC_OVER;
		BlendData.SourceConstantAlpha = 255;

		if(!(AlphaBlend(hdcBufferImage, 0, 0, MAINWINDOWWIDTH, 100, hdcConsoleBufferImage, 0, 0, MAINWINDOWWIDTH, 100, BlendData)))
		{
			MessageBox(hMainWindow, "Failure to blend console to buffer!", "Video Error.", MB_OK | MB_ICONEXCLAMATION);

			PostQuitMessage(0);

		}

	}
	else
	{
		if(!BitBlt(hdcBufferImage, 0, 0, MAINWINDOWWIDTH, 100, hdcConsoleBackgroundImage, 0, 0, SRCCOPY))
		{
			MessageBox(hMainWindow, "Failure to blit ConsoleBackgroundImage!", "Video Error.", MB_OK | MB_ICONEXCLAMATION);

			PostQuitMessage(0);

		}

	}

}
 
The AlphaBlend works perfectly fine, but the BitBlt function when I turn AlphaBlend off and use the BitBlt function, the text doesn't appear. Any ideas? [edited by - Daishi on July 16, 2003 3:45:18 PM]

I know only that which I know, but I do not know what I know.
Daishim
Daishim
Nevermind... I solved my own problem. Don''t I feel like a retard.

I know only that which I know, but I do not know what I know.
JY
JY
We''ve all been there
"Absorb what is useful, reject what is useless, and add what is specifically your own." - Lee Jun Fan
vrihai
vrihai
How the heck did you get AlphaBlend to work? I was never able to use it back in the days I was messing with GDI. Are you using 32-bit bitmaps? Or maybe it works just on NT systems.
Daishim
Daishim
I tried using it before and I never got it to work either. But it seems to work now, after a last ditch effort a couple weeks ago. I''m not sure what I did differently or if I even did and that it only does work on NT systems. But it works well and is pretty cool.

I know only that which I know, but I do not know what I know.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.