mirror of
https://github.com/raysan5/raylib.git
synced 2025-12-25 10:22:33 -05:00
Add small code example for drawing a flipped texture
@ -97,9 +97,17 @@ DrawText(text, textStartX, textStartY, fontSize, LIGHTGRAY);
|
||||
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.
|
||||
To flip the texture, simply pass a source rectangle with a negative width or height.
|
||||
|
||||
```c
|
||||
Rectangle source = (Rectangle) { 0, 0, -texture.width, texture.height };
|
||||
|
||||
DrawTextureRec(texture, source, (Vector2) { 0, 0 }, WHITE);
|
||||
```
|
||||
|
||||
The above code will draw a texture flipped in the X axis.
|
||||
|
||||
# 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.
|
||||
All textures in OpenGL by default have the origin in the lower-left corner, while the screen origin is in the upper left. 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 vertically when drawing, see the above paragraph for how to do this.
|
||||
|
||||
Reference in New Issue
Block a user