|
|
@ -48,11 +48,11 @@ int main(void) |
|
|
|
Color colors[10] = { 0 }; |
|
|
|
for (int i = 0; i < 10; i++) colors[i] = (Color){ GetRandomValue(100, 250), GetRandomValue(50, 150), GetRandomValue(10, 100), 255 }; |
|
|
|
|
|
|
|
SetTargetFPS(60); // Set our game to run at 60 frames-per-second |
|
|
|
SetTargetFPS(60); // Set our game to run at 60 frames-per-second |
|
|
|
//-------------------------------------------------------------------------------------- |
|
|
|
|
|
|
|
// Main game loop |
|
|
|
while (!WindowShouldClose()) // Detect window close button or ESC key |
|
|
|
while (!WindowShouldClose()) // Detect window close button or ESC key |
|
|
|
{ |
|
|
|
// Update |
|
|
|
//---------------------------------------------------------------------------------- |
|
|
@ -79,37 +79,33 @@ int main(void) |
|
|
|
|
|
|
|
// Draw |
|
|
|
//---------------------------------------------------------------------------------- |
|
|
|
BeginDrawing(); |
|
|
|
ClearBackground(BLACK); |
|
|
|
|
|
|
|
// Draw everything in the render texture, note this will not be rendered on screen, yet |
|
|
|
BeginTextureMode(target); |
|
|
|
|
|
|
|
ClearBackground(RAYWHITE); // Clear render texture background color |
|
|
|
|
|
|
|
for (int i = 0; i < 10; i++) DrawRectangle(0, (gameScreenHeight/10)*i, gameScreenWidth, gameScreenHeight/10, colors[i]); |
|
|
|
// Draw everything in the render texture, note this will not be rendered on screen, yet |
|
|
|
BeginTextureMode(target); |
|
|
|
ClearBackground(RAYWHITE); // Clear render texture background color |
|
|
|
|
|
|
|
DrawText("If executed inside a window,\nyou can resize the window,\nand see the screen scaling!", 10, 25, 20, WHITE); |
|
|
|
for (int i = 0; i < 10; i++) DrawRectangle(0, (gameScreenHeight/10)*i, gameScreenWidth, gameScreenHeight/10, colors[i]); |
|
|
|
|
|
|
|
DrawText(TextFormat("Default Mouse: [%i , %i]", (int)mouse.x, (int)mouse.y), 350, 25, 20, GREEN); |
|
|
|
DrawText(TextFormat("Virtual Mouse: [%i , %i]", (int)virtualMouse.x, (int)virtualMouse.y), 350, 55, 20, YELLOW); |
|
|
|
|
|
|
|
EndTextureMode(); |
|
|
|
DrawText("If executed inside a window,\nyou can resize the window,\nand see the screen scaling!", 10, 25, 20, WHITE); |
|
|
|
DrawText(TextFormat("Default Mouse: [%i , %i]", (int)mouse.x, (int)mouse.y), 350, 25, 20, GREEN); |
|
|
|
DrawText(TextFormat("Virtual Mouse: [%i , %i]", (int)virtualMouse.x, (int)virtualMouse.y), 350, 55, 20, YELLOW); |
|
|
|
EndTextureMode(); |
|
|
|
|
|
|
|
BeginDrawing(); |
|
|
|
ClearBackground(BLACK); // Clear screen background |
|
|
|
|
|
|
|
// Draw RenderTexture2D to window, properly scaled |
|
|
|
// Draw render texture to screen, properly scaled |
|
|
|
DrawTexturePro(target.texture, (Rectangle){ 0.0f, 0.0f, (float)target.texture.width, (float)-target.texture.height }, |
|
|
|
(Rectangle){ (GetScreenWidth() - ((float)gameScreenWidth*scale))*0.5f, (GetScreenHeight() - ((float)gameScreenHeight*scale))*0.5f, |
|
|
|
(float)gameScreenWidth*scale, (float)gameScreenHeight*scale }, (Vector2){ 0, 0 }, 0.0f, WHITE); |
|
|
|
|
|
|
|
EndDrawing(); |
|
|
|
//-------------------------------------------------------------------------------------- |
|
|
|
} |
|
|
|
|
|
|
|
// De-Initialization |
|
|
|
//-------------------------------------------------------------------------------------- |
|
|
|
UnloadRenderTexture(target); // Unload render texture |
|
|
|
UnloadRenderTexture(target); // Unload render texture |
|
|
|
|
|
|
|
CloseWindow(); // Close window and OpenGL context |
|
|
|
CloseWindow(); // Close window and OpenGL context |
|
|
|
//-------------------------------------------------------------------------------------- |
|
|
|
|
|
|
|
return 0; |
|
|
|