DrawText() raylib
To draw text using the DrawText()
function in the raylib library, you can follow the syntax:
void DrawText(const char *text, int posX, int posY, int fontSize, Color color);
This function allows you to display text on the screen at a specified position (posX
, posY
) with a specified font size (fontSize
) and color (color
). The text
parameter is a string that contains the text you want to display.
Here is an example of how you can use the DrawText()
function:
#include <raylib.h>
int main(void)
{
const int screenWidth = 800;
const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "Drawing Text Example");
SetTargetFPS(60);
while (!WindowShouldClose())
{
BeginDrawing();
ClearBackground(RAYWHITE);
DrawText("Hello, World!", 100, 200, 20, BLACK);
EndDrawing();
}
CloseWindow();
return 0;
}
This example initializes a window, sets the target FPS to 60, and enters a while loop that clears the screen, draws the text "Hello, World!" at position (100, 200) with a font size of 20 and color black, and then ends the drawing.
Note: Ensure that you have the raylib library properly installed and linked before compiling and running the code.
I hope this example helps! Let me know if you have any further questions.