What is the difference between BeginTextureMode() and DrawTexture in raylib?

  Kiến thức lập trình

Beginner here. I’ve noticed two approaches to drawing new textures to the screen in raylib, firstly using DrawTexture directly in the drawing stage:

BeginDrawing();
   DrawTexture(texture, posX, posY, WHITE);
EndDrawing();

And another by drawing your Texture2D to a RenderTexture2D before drawing the RenderTexture2D later:

BeginTextureMode(target);
   DrawTexture(texture, posX, posY, WHITE);
EndTextureMode();

BeginDrawing();
     DrawTextureRec(target.texture, (Rectangle) { 0, 0, (float)target.texture.width, (float)-target.texture.height }, (Vector2) { 0, 0 }, WHITE);
EndDrawing();

I’ve been using both approaches interchangeably without any though put behind it. What is the difference between the two? And how does each one affect performance?

LEAVE A COMMENT