Skip to content

Issue with UI TTF Rendering #54

Open

Description

@fellonemarco

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.

Activity

  1. Sioniras commented on Sep 6, 2023

    @Sioniras

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions