Allow drawing while resizing
This commit is contained in:
parent
bec27a6ebc
commit
947535d996
3 changed files with 94 additions and 0 deletions
|
|
@ -392,6 +392,8 @@ CORE = \
|
|||
core/core_loading_thread \
|
||||
core/core_quat_conversion \
|
||||
core/core_window_flags \
|
||||
core/core_resize_drawing \
|
||||
core/core_resize_placeholder \
|
||||
core/core_split_screen \
|
||||
core/core_smooth_pixelperfect \
|
||||
core/core_custom_frame_control
|
||||
|
|
|
|||
40
examples/core/core_resize_drawing.c
Normal file
40
examples/core/core_resize_drawing.c
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
/*******************************************************************************************
|
||||
*
|
||||
* raylib [core] example - window redraws while resizing
|
||||
*
|
||||
* This example has been created using raylib 4.0 (www.raylib.com)
|
||||
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
||||
*
|
||||
* Example contributed by Efejjota (@efejjota) and reviewed by Ramon Santamaria (@raysan5)
|
||||
*
|
||||
* Copyright (c) 2022 Efejjota (@efejjota) and Ramon Santamaria (@raysan5)
|
||||
*
|
||||
********************************************************************************************/
|
||||
|
||||
#include "raylib.h"
|
||||
|
||||
void draw()
|
||||
{
|
||||
BeginDrawing();
|
||||
ClearBackground(RAYWHITE);
|
||||
DrawText("Congrats! Your window redraws while resizing!", GetScreenWidth()/2.5-150, GetScreenHeight()/2, 20, LIGHTGRAY);
|
||||
EndDrawing();
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
const int screenWidth = 800;
|
||||
const int screenHeight = 450;
|
||||
|
||||
SetConfigFlags(FLAG_WINDOW_RESIZABLE); // Allow resizing the windows
|
||||
SetResizeCallback(draw); // Set the function to call while resizing
|
||||
InitWindow(screenWidth, screenHeight, "raylib [core] example - basic window");
|
||||
SetTargetFPS(60);
|
||||
|
||||
while (!WindowShouldClose())
|
||||
{
|
||||
draw(); // Write drawing code in a function so we can use as callback while resizing
|
||||
}
|
||||
CloseWindow();
|
||||
return 0;
|
||||
}
|
||||
43
examples/core/core_resize_placeholder.c
Normal file
43
examples/core/core_resize_placeholder.c
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
/*******************************************************************************************
|
||||
*
|
||||
* raylib [core] example - window shows placeholder while resizing
|
||||
*
|
||||
* This example has been created using raylib 4.0 (www.raylib.com)
|
||||
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
||||
*
|
||||
* Example contributed by Efejjota (@efejjota) and reviewed by Ramon Santamaria (@raysan5)
|
||||
*
|
||||
* Copyright (c) 2022 Efejjota (@efejjota) and Ramon Santamaria (@raysan5)
|
||||
*
|
||||
********************************************************************************************/
|
||||
|
||||
#include "raylib.h"
|
||||
|
||||
void draw()
|
||||
{
|
||||
BeginDrawing();
|
||||
ClearBackground(RAYWHITE);
|
||||
DrawText("Resizing", GetScreenWidth()/2.5, GetScreenHeight()/2.5, 30, LIGHTGRAY);
|
||||
EndDrawing();
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
const int screenWidth = 800;
|
||||
const int screenHeight = 450;
|
||||
|
||||
SetConfigFlags(FLAG_WINDOW_RESIZABLE); // Allow resizing the windows
|
||||
SetResizeCallback(draw); // Set the function to call while resizing
|
||||
InitWindow(screenWidth, screenHeight, "raylib [core] example - basic window");
|
||||
SetTargetFPS(60);
|
||||
|
||||
while (!WindowShouldClose())
|
||||
{
|
||||
BeginDrawing();
|
||||
ClearBackground(RAYWHITE);
|
||||
DrawText("Congrats! You created your first window!", GetScreenWidth()/2.5-100, GetScreenHeight()/2, 20, LIGHTGRAY);
|
||||
EndDrawing();
|
||||
}
|
||||
CloseWindow();
|
||||
return 0;
|
||||
}
|
||||
Loading…
Reference in a new issue