Skip to content

[rlgl] Flickering when using blend mode and lots of text #4942

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
4 tasks done
parzivail opened this issue May 16, 2025 · 2 comments
Closed
4 tasks done

[rlgl] Flickering when using blend mode and lots of text #4942

parzivail opened this issue May 16, 2025 · 2 comments

Comments

@parzivail
Copy link
Contributor

  • I tested it on latest raylib version from master branch
  • I checked there is no similar issue already reported
  • I checked the documentation on the wiki
  • My code has no errors or misuse of raylib

Issue description

When drawing large amounts of text, flickering is encountered if I attempt to draw a shape with a blend mode, specifically subtraction. This doesn't happen when there is no blend mode applied. It also seems variable based on the amount of text present.

Environment

  • Windows 10
  • raylib-quickstart @ d218555489baaa696b06aad352e34714265c7879
    • raylib @ 8c99a50 (5.6-dev)
    • DESKTOP (GLFW)
  • NVIDIA RTX 4000 SFF Ada Generation, driver 573.06, GL 3.3, GLSL 3.30
    • I was unable to reproduce this on an Intel iGPU
  • Compiled with default flags using mingw32-make provided by w64devkit

Issue Screenshot

See attached video.

video.mp4

Code Example

Source used in video:

#include "raylib.h"

int main ()
{
	InitWindow(800, 600, "PT65");

	int refreshRate = GetMonitorRefreshRate(GetCurrentMonitor());
	SetTargetFPS(refreshRate);

	Font defaultFont = GetFontDefault();

	int rows = 1;
	
	while (!WindowShouldClose())
	{
		BeginDrawing();

		ClearBackground(BLACK);

		if (IsKeyPressed(KEY_W) && rows < 100)
			rows++;
		if (IsKeyPressed(KEY_S) && rows > 1)
			rows--;

		DrawTextEx(defaultFont, TextFormat("rows: %i", rows), (Vector2){ 0, 0 }, defaultFont.baseSize, 1, WHITE);

		for (int row = 0; row < rows; row++)
		{
			// 80 chars
			DrawTextEx(defaultFont, "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@", (Vector2){ 0, 16 * (row + 2) }, defaultFont.baseSize, 1, WHITE);
		}

		BeginBlendMode(BLEND_SUBTRACT_COLORS);
		DrawRectangle(50, 50, 50, 50, WHITE);
		EndBlendMode();
		
		EndDrawing();
	}

	CloseWindow();
	return 0;
}
@raysan5
Copy link
Owner

raysan5 commented May 21, 2025

@parzivail I'm afraid this is out of the realm of raylib and probably related to GPU drivers. I reviewed the rlSetBlendMode() call, where blending is set and it only flushes the current batch to start a new one, I can't see anything that can potentially casue those glitches on raylib code.

Could you try this example on another OS or another GPU to verify the assumption?

EDIT: Re-read the issue more carefully:

I was unable to reproduce this on an Intel iGPU

Yeap, that verifies that this issue is GPU-drivers dependant.

@parzivail
Copy link
Contributor Author

Yes, unfortunately I spent some more time testing this and found that it works fine on Iris Xe, and also on an RTX 2080 Super, with driver versions 566.03 and 576.52. However, it's broken on a different RTX 3000 Ada Generation laptop GPU, so it's definitely configuration-dependent. I'll have to wait for a driver patch then.

Interestingly, some of those drivers also leak memory.

Thank you for taking a look!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants