Skip to content
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

Issue with UI TTF Rendering #54

Open
fellonemarco opened this issue Jul 24, 2022 · 1 comment
Open

Issue with UI TTF Rendering #54

fellonemarco opened this issue Jul 24, 2022 · 1 comment

Comments

@fellonemarco
Copy link

Everything seems to work fine, build and run is ok but the writings are a horrible rendering artifact made by retorts lines in columns. What could be the issue? Maybe something about compatibility? I'm testing on the latest Ubuntu with a Radeon GPU.

@Sioniras
Copy link

Sioniras commented Sep 6, 2023

This sounds like the problem I also encountered, and I found that the implementation of Texture::CreateFromSurface is not completely correct - it works when I boot into Windows, but not in Ubuntu.

The problem is here:
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, mWidth, mHeight, 0, GL_BGRA, GL_UNSIGNED_BYTE, surface->pixels);
where:
mWidth = surface->w;

The pixel data in the rendered surface is in fact NOT surface->w * surface->h pixels, as might be expected, but instead you should use:

mWidth = surface->pitch/4;

The explanation (as I understand it) is that the rendered surface is padded by some bytes in order to reach a "nice" width (seems to be a factor of 16 or something like that), so each row in the pixel data may in fact be longer than "surface->w". And since surface->pitch is defined as number of bytes per row, it should be divided by the number of bytes per pixel (4 channels, i.e. RGBA).

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