Add "How can I draw a texture flipped?" and "Why is my render texture upside down?" paragraphs.

master
Peter0x44 há 3 anos
ascendente
cometimento
5aa82e8795
1 ficheiros alterados com 12 adições e 0 eliminações
  1. +12
    -0
      Frequently-asked-Questions--Common-Questions.md

+ 12
- 0
Frequently-asked-Questions--Common-Questions.md

@ -91,3 +91,15 @@ int textStartY = screenCenterY - fontSize / 2;
DrawText(text, textStartX, textStartY, fontSize, LIGHTGRAY);
```
`MeasureText` only measures the width of text, but takes fewer arguments. It is often acceptable to just use the font size as the total text height, but for some fonts, this may not be accurate. `MeasureTextEx` will measure both height and width of text, but does take more arguments. For this reason it is used less often.
# How can I draw a texture flipped?
Drawing a texture flipped requires the use of either `DrawTextureRec`, or `DrawTexturePro` functions.
Every single texture drawing function calls `DrawTexturePro` to do its work, but only these two expose the parameters necessary to flip a texture (the source rectangle).
To flip the texture, simply pass a source rectangle with a negative width and height.
# Why is my render texture upside down?
All textures in OpenGL by default have the origin in the lower-left corner. When you load a normal texture, raylib flips the image data for you, however this cannot be done with a render texture.
The solution is to flip your texture when drawing, see the above paragraph for how to do this.

Carregando…
Cancelar
Guardar