Files
raylib-cpp/examples/textures/textures_image_loading.cpp
2019-01-16 02:40:47 -05:00

50 lines
1.7 KiB
C++

/*******************************************************************************************
*
* raylib [textures] example - Image loading and texture creation
*
* NOTE: Images are loaded in CPU memory (RAM); textures are loaded in GPU memory (VRAM)
*
* This example has been created using raylib 1.3 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
*
* Copyright (c) 2015 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
#include "raylib/raylib.hpp"
int main()
{
// Initialization
//--------------------------------------------------------------------------------------
int screenWidth = 800;
int screenHeight = 450;
raylib::Window w(screenWidth, screenHeight, "raylib [textures] example - image loading");
raylib::Texture2D texture("resources/raylib_logo.png");
// Main game loop
while (!w.ShouldClose()) // Detect window close button or ESC key
{
// Update
//----------------------------------------------------------------------------------
// TODO: Update your variables here
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(RAYWHITE);
texture.Draw(screenWidth/2 - texture.width()/2, screenHeight/2 - texture.height()/2, WHITE);
DrawText("this IS a texture loaded from an image!", 300, 370, 10, GRAY);
EndDrawing();
//----------------------------------------------------------------------------------
}
return 0;
}