actually add vendor folder
@@ -0,0 +1,62 @@
|
||||
# Get the sources together
|
||||
set(example_dirs audio core models shaders shapes text textures)
|
||||
set(example_sources)
|
||||
set(example_resources)
|
||||
|
||||
# C++
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||
|
||||
# raylib
|
||||
find_package(raylib QUIET)
|
||||
if (NOT raylib_FOUND)
|
||||
include(FetchContent)
|
||||
FetchContent_Declare(
|
||||
raylib
|
||||
GIT_REPOSITORY https://github.com/raysan5/raylib.git
|
||||
GIT_TAG ae50bfa2cc569c0f8d5bc4315d39db64005b1b08
|
||||
GIT_SHALLOW 1
|
||||
)
|
||||
FetchContent_GetProperties(raylib)
|
||||
if (NOT raylib_POPULATED) # Have we downloaded raylib yet?
|
||||
set(FETCHCONTENT_QUIET NO)
|
||||
FetchContent_Populate(raylib)
|
||||
set(BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
|
||||
set(BUILD_GAMES OFF CACHE BOOL "" FORCE)
|
||||
add_subdirectory(${raylib_SOURCE_DIR} ${raylib_BINARY_DIR})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Find all examples
|
||||
foreach(example_dir ${example_dirs})
|
||||
file(GLOB sources ${example_dir}/*.cpp)
|
||||
list(APPEND example_sources ${sources})
|
||||
|
||||
# Any any resources
|
||||
file(GLOB resources ${example_dir}/resources/*)
|
||||
list(APPEND example_resources ${resources})
|
||||
endforeach()
|
||||
|
||||
# Compile all examples
|
||||
foreach(example_source ${example_sources})
|
||||
# Create the basename for the example
|
||||
get_filename_component(example_name ${example_source} NAME)
|
||||
string(REPLACE ".cpp" "${OUTPUT_EXT}" example_name ${example_name})
|
||||
|
||||
# Setup the example
|
||||
add_executable(${example_name} ${example_source})
|
||||
|
||||
# Link raylib and raylib-cpp
|
||||
target_link_libraries(${example_name} PUBLIC raylib_cpp raylib)
|
||||
|
||||
string(REGEX MATCH ".*/.*/" resources_dir ${example_source})
|
||||
string(APPEND resources_dir "resources")
|
||||
endforeach()
|
||||
|
||||
# Multiple Files Example
|
||||
add_executable("multiple" multiple/main.cpp multiple/Player.cpp)
|
||||
target_link_libraries("multiple" PUBLIC raylib_cpp raylib)
|
||||
|
||||
# Copy all the resources
|
||||
file(COPY ${example_resources} DESTINATION "resources/")
|
||||
@@ -0,0 +1,83 @@
|
||||
/*******************************************************************************************
|
||||
*
|
||||
* raylib [audio] example - Music playing (streaming)
|
||||
*
|
||||
* 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-cpp.hpp"
|
||||
|
||||
int main() {
|
||||
// Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
const int screenWidth = 800;
|
||||
const int screenHeight = 450;
|
||||
|
||||
raylib::Window window(screenWidth, screenHeight, "raylib [audio] example - music playing (streaming)");
|
||||
|
||||
raylib::AudioDevice audio; // Initialize audio device
|
||||
|
||||
raylib::Music music("resources/target.ogg");
|
||||
|
||||
music.Play();
|
||||
|
||||
float timePlayed = 0.0f;
|
||||
bool pause = false;
|
||||
|
||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
// Main game loop
|
||||
while (!window.ShouldClose()) { // Detect window close button or ESC key
|
||||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
music.Update(); // Update music buffer with new stream data
|
||||
|
||||
// Restart music playing (stop and play)
|
||||
if (IsKeyPressed(KEY_SPACE)) {
|
||||
music.Stop();
|
||||
music.Play();
|
||||
}
|
||||
|
||||
// Pause/Resume music playing
|
||||
if (IsKeyPressed(KEY_P)) {
|
||||
pause = !pause;
|
||||
|
||||
if (pause) {
|
||||
music.Pause();
|
||||
} else {
|
||||
music.Resume();
|
||||
}
|
||||
}
|
||||
|
||||
// Get timePlayed scaled to bar dimensions (400 pixels)
|
||||
timePlayed = music.GetTimePlayed() / music.GetTimeLength() * 400;
|
||||
|
||||
if (timePlayed > 400) music.Stop();
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
//----------------------------------------------------------------------------------
|
||||
BeginDrawing();
|
||||
{
|
||||
window.ClearBackground(RAYWHITE);
|
||||
|
||||
DrawText("MUSIC SHOULD BE PLAYING!", 255, 150, 20, LIGHTGRAY);
|
||||
|
||||
DrawRectangle(200, 200, 400, 12, LIGHTGRAY);
|
||||
DrawRectangle(200, 200, static_cast<int>(timePlayed), 12, MAROON);
|
||||
DrawRectangleLines(200, 200, 400, 12, GRAY);
|
||||
|
||||
DrawText("PRESS SPACE TO RESTART MUSIC", 215, 250, 20, LIGHTGRAY);
|
||||
DrawText("PRESS P TO PAUSE/RESUME MUSIC", 208, 280, 20, LIGHTGRAY);
|
||||
}
|
||||
EndDrawing();
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
/*******************************************************************************************
|
||||
*
|
||||
* raylib [audio] example - Sound loading and playing
|
||||
*
|
||||
* This example has been created using raylib 1.0 (www.raylib.com)
|
||||
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
||||
*
|
||||
* Copyright (c) 2014 Ramon Santamaria (@raysan5)
|
||||
*
|
||||
********************************************************************************************/
|
||||
|
||||
#include "raylib-cpp.hpp"
|
||||
|
||||
int main() {
|
||||
// Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
const int screenWidth = 800;
|
||||
const int screenHeight = 450;
|
||||
|
||||
raylib::Window window(screenWidth, screenHeight, "raylib [audio] example - sound loading and playing");
|
||||
|
||||
raylib::AudioDevice audiodevice; // Initialize audio device
|
||||
|
||||
raylib::Sound fxWav("resources/sound.wav"); // Load WAV audio file
|
||||
raylib::Sound fxOgg("resources/target.ogg"); // Load OGG audio file
|
||||
|
||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
// Main game loop
|
||||
while (!window.ShouldClose()) { // Detect window close button or ESC key
|
||||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
if (IsKeyPressed(KEY_SPACE)) fxWav.Play(); // Play WAV sound
|
||||
if (IsKeyPressed(KEY_ENTER)) fxOgg.Play(); // Play OGG sound
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
//----------------------------------------------------------------------------------
|
||||
BeginDrawing();
|
||||
{
|
||||
window.ClearBackground(RAYWHITE);
|
||||
|
||||
DrawText("Press SPACE to PLAY the WAV sound!", 200, 180, 20, LIGHTGRAY);
|
||||
DrawText("Press ENTER to PLAY the OGG sound!", 200, 220, 20, LIGHTGRAY);
|
||||
}
|
||||
EndDrawing();
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
| resource | author | licence | notes |
|
||||
| :------------------- | :---------: | :------ | :---- |
|
||||
| country.mp3 | [@emegeme](https://github.com/emegeme) | [CC0](https://creativecommons.org/publicdomain/zero/1.0/) | Originally created for "DART that TARGET" game |
|
||||
| target.ogg | [@emegeme](https://github.com/emegeme) | [CC0](https://creativecommons.org/publicdomain/zero/1.0/) | Originally created for "DART that TARGET" game |
|
||||
| target.flac | [@emegeme](https://github.com/emegeme) | [CC0](https://creativecommons.org/publicdomain/zero/1.0/) | Originally created for "DART that TARGET" game |
|
||||
| coin.wav | [@raysan5](https://github.com/raysan5) | [CC0](https://creativecommons.org/publicdomain/zero/1.0/) | Created using [rFXGen](https://raylibtech.itch.io/rfxgen) |
|
||||
| sound.wav | [@raysan5](https://github.com/raysan5) | [CC0](https://creativecommons.org/publicdomain/zero/1.0/) | Created using [rFXGen](https://raylibtech.itch.io/rfxgen) |
|
||||
| spring.wav | [@raysan5](https://github.com/raysan5) | [CC0](https://creativecommons.org/publicdomain/zero/1.0/) | Created using [rFXGen](https://raylibtech.itch.io/rfxgen) |
|
||||
| weird.wav | [@raysan5](https://github.com/raysan5) | [CC0](https://creativecommons.org/publicdomain/zero/1.0/) | Created using [rFXGen](https://raylibtech.itch.io/rfxgen) |
|
||||
| mini1111.xm | [tPORt](https://modarchive.org/index.php?request=view_by_moduleid&query=51891) | [Mod Archive Distribution license](https://modarchive.org/index.php?terms-upload) | - |
|
||||
@@ -0,0 +1,54 @@
|
||||
/*******************************************************************************************
|
||||
*
|
||||
* raylib [core] example - Basic window
|
||||
*
|
||||
* Welcome to raylib!
|
||||
*
|
||||
* To test examples, just press F6 and execute raylib_compile_execute script
|
||||
* Note that compiled executable is placed in the same folder as .c file
|
||||
*
|
||||
* You can find all basic examples on C:\raylib\raylib\examples folder or
|
||||
* raylib official webpage: www.raylib.com
|
||||
*
|
||||
* Enjoy using raylib. :)
|
||||
*
|
||||
* This example has been created using raylib 1.0 (www.raylib.com)
|
||||
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
||||
*
|
||||
* Copyright (c) 2014 Ramon Santamaria (@raysan5)
|
||||
*
|
||||
********************************************************************************************/
|
||||
|
||||
#include "raylib-cpp.hpp"
|
||||
|
||||
int main() {
|
||||
// Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
int screenWidth = 800;
|
||||
int screenHeight = 450;
|
||||
raylib::Color textColor = raylib::Color::LightGray();
|
||||
raylib::Window window(screenWidth, screenHeight, "raylib [core] example - basic window");
|
||||
|
||||
SetTargetFPS(60);
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
// Main game loop
|
||||
while (!window.ShouldClose()) { // Detect window close button or ESC key
|
||||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
// Update your variables here
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
//----------------------------------------------------------------------------------
|
||||
BeginDrawing();
|
||||
{
|
||||
window.ClearBackground(RAYWHITE);
|
||||
textColor.DrawText("Congrats! You created your first window!", 190, 200, 20);
|
||||
}
|
||||
EndDrawing();
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
/*******************************************************************************************
|
||||
*
|
||||
* raylib-cpp [core] example - Basic window (adapted for HTML5 platform)
|
||||
*
|
||||
* This example is prepared to compile for PLATFORM_WEB, PLATFORM_DESKTOP and PLATFORM_RPI
|
||||
* As you will notice, code structure is slightly diferent to the other examples...
|
||||
* To compile it for PLATFORM_WEB just uncomment #define PLATFORM_WEB at beginning
|
||||
*
|
||||
* 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-cpp.hpp"
|
||||
|
||||
#if defined(PLATFORM_WEB)
|
||||
#include <emscripten/emscripten.h>
|
||||
#endif
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Global Variables Definition
|
||||
//----------------------------------------------------------------------------------
|
||||
int screenWidth = 800;
|
||||
int screenHeight = 450;
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Module Functions Declaration
|
||||
//----------------------------------------------------------------------------------
|
||||
void UpdateDrawFrame(void); // Update and Draw one frame
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Main Enry Point
|
||||
//----------------------------------------------------------------------------------
|
||||
int main()
|
||||
{
|
||||
// Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
raylib::Window window(screenWidth, screenHeight, "raylib-cpp [core] example - basic window");
|
||||
|
||||
#if defined(PLATFORM_WEB)
|
||||
emscripten_set_main_loop(UpdateDrawFrame, 0, 1);
|
||||
#else
|
||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
// Main game loop
|
||||
while (!window.ShouldClose()) // Detect window close button or ESC key
|
||||
{
|
||||
UpdateDrawFrame();
|
||||
}
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Module Functions Definition
|
||||
//----------------------------------------------------------------------------------
|
||||
void UpdateDrawFrame(void)
|
||||
{
|
||||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
// TODO: Update your variables here
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
//----------------------------------------------------------------------------------
|
||||
BeginDrawing();
|
||||
|
||||
ClearBackground(RAYWHITE);
|
||||
|
||||
raylib::DrawText("Congrats! You created your first raylib-cpp window!", 190, 200, 20, LIGHTGRAY);
|
||||
|
||||
EndDrawing();
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
/*******************************************************************************************
|
||||
*
|
||||
* raylib [core] example - Windows drop files
|
||||
*
|
||||
* This example only works on platforms that support drag & drop (Windows, Linux, OSX, Html5?)
|
||||
*
|
||||
* This example has been created using raylib-cpp (www.raylib.com)
|
||||
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
||||
*
|
||||
* Copyright (c) 2020 Rob Loach (@RobLoach)
|
||||
*
|
||||
********************************************************************************************/
|
||||
|
||||
#include "raylib-cpp.hpp"
|
||||
|
||||
int main() {
|
||||
// Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
const int screenWidth = 800;
|
||||
const int screenHeight = 450;
|
||||
|
||||
raylib::Window window(screenWidth, screenHeight, "raylib [core] example - drop files");
|
||||
|
||||
std::vector<std::string> droppedFiles;
|
||||
|
||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
// Main game loop
|
||||
while (!window.ShouldClose()) { // Detect window close button or ESC key
|
||||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
if (IsFileDropped()) {
|
||||
droppedFiles = raylib::LoadDroppedFiles();
|
||||
}
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
//----------------------------------------------------------------------------------
|
||||
BeginDrawing();
|
||||
{
|
||||
window.ClearBackground(RAYWHITE);
|
||||
|
||||
// Check if there are files to process.
|
||||
if (droppedFiles.empty()) {
|
||||
raylib::DrawText("Drop your files to this window!", 100, 40, 20, DARKGRAY);
|
||||
} else {
|
||||
raylib::DrawText("Dropped files:", 100, 40, 20, DARKGRAY);
|
||||
|
||||
// Iterate through all the dropped files.
|
||||
for (int i = 0; i < droppedFiles.size(); i++) {
|
||||
if (i % 2 == 0)
|
||||
DrawRectangle(0, 85 + 40*i, screenWidth, 40, Fade(LIGHTGRAY, 0.5f));
|
||||
else
|
||||
DrawRectangle(0, 85 + 40*i, screenWidth, 40, Fade(LIGHTGRAY, 0.3f));
|
||||
|
||||
// Display the path to the dropped file.
|
||||
raylib::DrawText(droppedFiles[i].c_str(), 120, 100 + 40 * i, 10, GRAY);
|
||||
}
|
||||
|
||||
raylib::DrawText("Drop new files...", 100, 110 + 40 * droppedFiles.size(), 20, DARKGRAY);
|
||||
}
|
||||
}
|
||||
EndDrawing();
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
/*******************************************************************************************
|
||||
*
|
||||
* raylib [core] example - Mouse input
|
||||
*
|
||||
* This example has been created using raylib 1.0 (www.raylib.com)
|
||||
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
||||
*
|
||||
* Copyright (c) 2014 Ramon Santamaria (@raysan5)
|
||||
*
|
||||
********************************************************************************************/
|
||||
|
||||
#include "raylib-cpp.hpp"
|
||||
|
||||
int main() {
|
||||
// Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
const int screenWidth = 800;
|
||||
const int screenHeight = 450;
|
||||
|
||||
raylib::Window window(screenWidth, screenHeight, "raylib [core] example - mouse input");
|
||||
|
||||
raylib::Vector2 ballPosition(-100.0f, -100.0f);
|
||||
raylib::Color ballColor = raylib::Color::DarkBlue();
|
||||
raylib::Color textColor = raylib::Color::DarkGray();
|
||||
|
||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||
//---------------------------------------------------------------------------------------
|
||||
|
||||
// Main game loop
|
||||
while (!window.ShouldClose()) { // Detect window close button or ESC key
|
||||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
ballPosition = GetMousePosition();
|
||||
|
||||
if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) ballColor = MAROON;
|
||||
else if (IsMouseButtonPressed(MOUSE_MIDDLE_BUTTON)) ballColor = LIME;
|
||||
else if (IsMouseButtonPressed(MOUSE_RIGHT_BUTTON)) ballColor = DARKBLUE;
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
//----------------------------------------------------------------------------------
|
||||
BeginDrawing();
|
||||
{
|
||||
window.ClearBackground(RAYWHITE);
|
||||
|
||||
ballPosition.DrawCircle(40, ballColor);
|
||||
|
||||
textColor.DrawText("move ball with mouse and click mouse button to change color", 10, 10, 20);
|
||||
}
|
||||
EndDrawing();
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,150 @@
|
||||
/*******************************************************************************
|
||||
*
|
||||
* raylib example - loading thread
|
||||
*
|
||||
* This example has been created using raylib-cpp (www.raylib.com)
|
||||
* raylib is licensed under an unmodified zlib/libpng license
|
||||
* (View raylib.h for details)
|
||||
*
|
||||
* Copyright (c) 2014-2019 Ramon Santamaria (@raysan5)
|
||||
* Copyright (c) 2021 Paul Keir (University of the West of Scotland)
|
||||
*
|
||||
*******************************************************************************/
|
||||
|
||||
#include <thread> // C++11 standard library threads
|
||||
#include <atomic> // C++ atomic data types
|
||||
#include <chrono> // For: chrono::steady_clock::now()
|
||||
#include <system_error> // May be thrown by thread c'tor
|
||||
|
||||
#include "raylib-cpp.hpp"
|
||||
|
||||
// Using C++ std::atomic_bool (aka. std::atomic<bool>) for synchronization.
|
||||
// n.b. A plain built-in type can't be used for inter-thread synchronization
|
||||
std::atomic_bool dataLoaded{false};
|
||||
static void LoadDataThread(); // Loading data thread function declaration
|
||||
static int dataProgress = 0; // Data progress accumulator
|
||||
|
||||
int main(void)
|
||||
{
|
||||
// Initialization
|
||||
//--------------------------------------------------------------------------
|
||||
const int screenWidth = 800;
|
||||
const int screenHeight = 450;
|
||||
|
||||
raylib::Window window(screenWidth, screenHeight,
|
||||
"raylib [core] example - loading thread");
|
||||
|
||||
std::thread threadId; // Loading data thread id
|
||||
|
||||
enum { STATE_WAITING, STATE_LOADING, STATE_FINISHED } state = STATE_WAITING;
|
||||
int framesCounter = 0;
|
||||
|
||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
// Main game loop
|
||||
while (!window.ShouldClose()) { // Detect window close button or ESC key
|
||||
// Update
|
||||
//----------------------------------------------------------------------
|
||||
switch (state)
|
||||
{
|
||||
case STATE_WAITING:
|
||||
if (IsKeyPressed(KEY_ENTER))
|
||||
{
|
||||
try {
|
||||
threadId = std::thread(LoadDataThread);
|
||||
TraceLog(LOG_INFO,
|
||||
"Loading thread initialized successfully");
|
||||
} catch (std::system_error e) {
|
||||
TraceLog(LOG_ERROR, "Error: %s", e.what());
|
||||
}
|
||||
|
||||
state = STATE_LOADING;
|
||||
}
|
||||
break;
|
||||
|
||||
case STATE_LOADING:
|
||||
framesCounter++;
|
||||
if (dataLoaded.load())
|
||||
{
|
||||
framesCounter = 0;
|
||||
state = STATE_FINISHED;
|
||||
}
|
||||
break;
|
||||
|
||||
case STATE_FINISHED:
|
||||
if (IsKeyPressed(KEY_ENTER))
|
||||
{
|
||||
// Reset everything to launch again
|
||||
dataLoaded = false;
|
||||
dataProgress = 0;
|
||||
state = STATE_WAITING;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
//----------------------------------------------------------------------
|
||||
BeginDrawing();
|
||||
{
|
||||
|
||||
window.ClearBackground(RAYWHITE);
|
||||
|
||||
switch (state)
|
||||
{
|
||||
case STATE_WAITING:
|
||||
raylib::DrawText("PRESS ENTER to START LOADING DATA",
|
||||
150, 170, 20, DARKGRAY);
|
||||
break;
|
||||
|
||||
case STATE_LOADING:
|
||||
DrawRectangle(150, 200, dataProgress, 60, SKYBLUE);
|
||||
if ((framesCounter/15)%2)
|
||||
raylib::DrawText("LOADING DATA...", 240, 210, 40, DARKBLUE);
|
||||
break;
|
||||
|
||||
case STATE_FINISHED:
|
||||
DrawRectangle(150, 200, 500, 60, LIME);
|
||||
raylib::DrawText("DATA LOADED!", 250, 210, 40, GREEN);
|
||||
break;
|
||||
}
|
||||
|
||||
DrawRectangleLines(150, 200, 500, 60, DARKGRAY);
|
||||
}
|
||||
|
||||
EndDrawing();
|
||||
//----------------------------------------------------------------------
|
||||
}
|
||||
|
||||
if (threadId.joinable()) // The user might quit without creating a thread.
|
||||
threadId.join(); // Good etiquette, but may take a second.
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Loading data thread function definition
|
||||
static void LoadDataThread()
|
||||
{
|
||||
using namespace std::chrono;
|
||||
int timeCounter = 0; // Time counted in ms
|
||||
|
||||
auto prevTime = steady_clock::now();
|
||||
|
||||
// We simulate data loading with a time counter for 5 seconds
|
||||
while (timeCounter < 5000)
|
||||
{
|
||||
auto currentTime = steady_clock::now() - prevTime;
|
||||
timeCounter = duration_cast<milliseconds>(currentTime).count();
|
||||
|
||||
// We accumulate time over a global variable to be used in
|
||||
// main thread as a progress bar
|
||||
dataProgress = timeCounter/10;
|
||||
}
|
||||
|
||||
// When data has finished loading, we set global variable
|
||||
dataLoaded = true;
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
/*******************************************************************************************
|
||||
*
|
||||
* raylib [core] example - Generate random values
|
||||
*
|
||||
* This example has been created using raylib 1.1 (www.raylib.com)
|
||||
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
||||
*
|
||||
* Copyright (c) 2014 Ramon Santamaria (@raysan5)
|
||||
*
|
||||
********************************************************************************************/
|
||||
|
||||
#include "raylib-cpp.hpp"
|
||||
|
||||
int main() {
|
||||
// Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
const int screenWidth = 800;
|
||||
const int screenHeight = 450;
|
||||
|
||||
raylib::Window window(screenWidth, screenHeight, "raylib [core] example - generate random values");
|
||||
|
||||
int framesCounter = 0; // Variable used to count frames
|
||||
|
||||
int randValue = GetRandomValue(-8, 5); // Get a random integer number between -8 and 5 (both included)
|
||||
|
||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
// Main game loop
|
||||
while (!window.ShouldClose()) { // Detect window close button or ESC key
|
||||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
framesCounter++;
|
||||
|
||||
// Every two seconds (120 frames) a new random value is generated
|
||||
if (((framesCounter / 120) % 2) == 1) {
|
||||
randValue = GetRandomValue(-8, 5);
|
||||
framesCounter = 0;
|
||||
}
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
//----------------------------------------------------------------------------------
|
||||
BeginDrawing();
|
||||
{
|
||||
window.ClearBackground(RAYWHITE);
|
||||
|
||||
raylib::DrawText("Every 2 seconds a new random value is generated:", 130, 100, 20, MAROON);
|
||||
|
||||
raylib::DrawText(TextFormat("%i", randValue), 360, 180, 80, LIGHTGRAY);
|
||||
}
|
||||
EndDrawing();
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
/*******************************************************************************************
|
||||
*
|
||||
* raylib [core] example - window scale letterbox (and virtual mouse)
|
||||
*
|
||||
* Example originally created with raylib 2.5, last time updated with raylib 4.0
|
||||
*
|
||||
* Example contributed by Anata (@anatagawa) and reviewed by Ramon Santamaria (@raysan5)
|
||||
*
|
||||
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
|
||||
* BSD-like license that allows static linking with closed source software
|
||||
*
|
||||
* Copyright (c) 2019-2023 Anata (@anatagawa) and Ramon Santamaria (@raysan5)
|
||||
*
|
||||
********************************************************************************************/
|
||||
|
||||
#include "raylib-cpp.hpp"
|
||||
|
||||
#include "raymath.hpp" // Required for: Vector2Clamp()
|
||||
|
||||
#define MAX(a, b) ((a)>(b)? (a) : (b))
|
||||
#define MIN(a, b) ((a)<(b)? (a) : (b))
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
// Program main entry point
|
||||
//------------------------------------------------------------------------------------
|
||||
int main(void)
|
||||
{
|
||||
const int windowWidth = 800;
|
||||
const int windowHeight = 450;
|
||||
|
||||
// Enable config flags for resizable window and vertical synchro
|
||||
raylib::Window window(windowWidth, windowHeight,
|
||||
"raylib [core] example - window scale letterbox",
|
||||
FLAG_WINDOW_RESIZABLE | FLAG_VSYNC_HINT);
|
||||
window.SetMinSize(320, 240);
|
||||
|
||||
int gameScreenWidth = 640;
|
||||
int gameScreenHeight = 480;
|
||||
|
||||
// Render texture initialization, used to hold the rendering result so we can easily resize it
|
||||
raylib::RenderTexture2D target(gameScreenWidth, gameScreenHeight);
|
||||
target.GetTexture().SetFilter(TEXTURE_FILTER_BILINEAR); // Texture scale filter to use
|
||||
|
||||
raylib::Color colors[10] = { 0 };
|
||||
for (int i = 0; i < 10; i++) {
|
||||
colors[i] = raylib::Color((unsigned char)GetRandomValue(100, 250), (unsigned char)GetRandomValue(50, 150), (unsigned char)GetRandomValue(10, 100), 255);
|
||||
}
|
||||
|
||||
window.SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
// Main game loop
|
||||
while (!window.ShouldClose()) // Detect window close button or ESC key
|
||||
{
|
||||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
// Compute required framebuffer scaling
|
||||
float scale = MIN((float)GetScreenWidth()/gameScreenWidth, (float)GetScreenHeight()/gameScreenHeight);
|
||||
|
||||
if (IsKeyPressed(KEY_SPACE))
|
||||
{
|
||||
// Recalculate random colors for the bars
|
||||
for (int i = 0; i < 10; i++) colors[i] = (Color){ (unsigned char)GetRandomValue(100, 250), (unsigned char)GetRandomValue(50, 150), (unsigned char)GetRandomValue(10, 100), 255 };
|
||||
}
|
||||
|
||||
// Update virtual mouse (clamped mouse value behind game screen)
|
||||
raylib::Vector2 mouse = raylib::Mouse::GetPosition();
|
||||
raylib::Vector2 virtualMouse(
|
||||
(mouse.x - (GetScreenWidth() - (gameScreenWidth*scale))*0.5f)/scale,
|
||||
(mouse.y - (GetScreenHeight() - (gameScreenHeight*scale))*0.5f)/scale
|
||||
);
|
||||
virtualMouse = virtualMouse.Clamp(raylib::Vector2::Zero(), raylib::Vector2(gameScreenWidth, gameScreenHeight));
|
||||
|
||||
// Apply the same transformation as the virtual mouse to the real mouse (i.e. to work with raygui)
|
||||
//SetMouseOffset(-(GetScreenWidth() - (gameScreenWidth*scale))*0.5f, -(GetScreenHeight() - (gameScreenHeight*scale))*0.5f);
|
||||
//SetMouseScale(1/scale, 1/scale);
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
//----------------------------------------------------------------------------------
|
||||
// Draw everything in the render texture, note this will not be rendered on screen, yet
|
||||
target.BeginMode();
|
||||
ClearBackground(RAYWHITE); // Clear render texture background color
|
||||
|
||||
for (int i = 0; i < 10; i++) DrawRectangle(0, (gameScreenHeight/10)*i, gameScreenWidth, gameScreenHeight/10, colors[i]);
|
||||
|
||||
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);
|
||||
target.EndMode();
|
||||
|
||||
BeginDrawing();
|
||||
ClearBackground(BLACK); // Clear screen background
|
||||
|
||||
// Draw render texture to screen, properly scaled
|
||||
target.GetTexture().Draw(raylib::Rectangle(0.0f, 0.0f, target.texture.width, -target.texture.height),
|
||||
raylib::Rectangle(
|
||||
(GetScreenWidth() - (gameScreenWidth*scale))*0.5f,
|
||||
(GetScreenHeight() - (gameScreenHeight*scale))*0.5f,
|
||||
gameScreenWidth*scale, gameScreenHeight*scale
|
||||
),
|
||||
raylib::Vector2::Zero(), 0.0f, WHITE);
|
||||
EndDrawing();
|
||||
//--------------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
/*******************************************************************************************
|
||||
*
|
||||
* raylib [core] example - World to screen
|
||||
*
|
||||
* 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-cpp.hpp"
|
||||
|
||||
int main() {
|
||||
// Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
const int screenWidth = 800;
|
||||
const int screenHeight = 450;
|
||||
|
||||
raylib::Window window(screenWidth, screenHeight, "raylib [core] example - 3d camera free");
|
||||
|
||||
// Define the camera to look into our 3d world
|
||||
raylib::Camera camera(
|
||||
raylib::Vector3(10.0f, 10.0f, 10.0f),
|
||||
raylib::Vector3(),
|
||||
raylib::Vector3(0.0f, 1.0f, 0.0f),
|
||||
45.0f,
|
||||
CAMERA_PERSPECTIVE);
|
||||
|
||||
Vector3 cubePosition;
|
||||
Vector2 cubeScreenPosition;
|
||||
|
||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
// Main game loop
|
||||
while (!window.ShouldClose()) { // Detect window close button or ESC key
|
||||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
camera.Update(CAMERA_THIRD_PERSON); // Update camera
|
||||
|
||||
// Calculate cube screen space position (with a little offset to be in top)
|
||||
cubeScreenPosition = GetWorldToScreen(Vector3{cubePosition.x, cubePosition.y + 2.5f, cubePosition.z}, camera);
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
//----------------------------------------------------------------------------------
|
||||
BeginDrawing();
|
||||
{
|
||||
window.ClearBackground(RAYWHITE);
|
||||
|
||||
camera.BeginMode();
|
||||
{
|
||||
DrawCube(cubePosition, 2.0f, 2.0f, 2.0f, RED);
|
||||
DrawCubeWires(cubePosition, 2.0f, 2.0f, 2.0f, MAROON);
|
||||
|
||||
DrawGrid(10, 1.0f);
|
||||
}
|
||||
camera.EndMode();
|
||||
|
||||
raylib::DrawText("Enemy: 100 / 100",
|
||||
cubeScreenPosition.x - MeasureText("Enemy: 100/100", 20) / 2,
|
||||
cubeScreenPosition.y, 20,
|
||||
BLACK);
|
||||
raylib::DrawText("Text is always on top of the cube",
|
||||
(screenWidth - MeasureText("Text is always on top of the cube", 20)) / 2,
|
||||
25, 20, GRAY);
|
||||
}
|
||||
EndDrawing();
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
| resource | author | licence | notes |
|
||||
| :------------ | :---------: | :------ | :---- |
|
||||
| ps3.png | [@raysan5](https://github.com/raysan5) | [CC0](https://creativecommons.org/publicdomain/zero/1.0/) | - |
|
||||
| xbox.png | [@raysan5](https://github.com/raysan5) | [CC0](https://creativecommons.org/publicdomain/zero/1.0/) | - |
|
||||
@@ -0,0 +1,57 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>raylib-cpp [core] example - basic window</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
|
||||
<meta name="title" content="raylib-cpp [core] example - basic window">
|
||||
<meta name="description" content="raylib is a simple and easy-to-use library to enjoy videogames programming. This a small example of what you can do.">
|
||||
<meta name="viewport" content="width=device-width">
|
||||
<style>
|
||||
body {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
background-color: black;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
body canvas {
|
||||
object-fit: contain;
|
||||
max-height: 100%;
|
||||
max-width: 100%;
|
||||
}
|
||||
</style>
|
||||
<script type='text/javascript' src="https://cdn.jsdelivr.net/gh/eligrey/FileSaver.js/dist/FileSaver.min.js"> </script>
|
||||
<script type='text/javascript'>
|
||||
function saveFileFromMEMFSToDisk(memoryFSname, localFSname) {
|
||||
var isSafari = false;
|
||||
var data = FS.readFile(memoryFSname);
|
||||
var blob;
|
||||
if (isSafari) blob = new Blob([data.buffer], { type: "application/octet-stream" });
|
||||
else blob = new Blob([data.buffer], { type: "application/octet-binary" });
|
||||
saveAs(blob, localFSname);
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<canvas id="canvas" width="800" height="450"></canvas>
|
||||
|
||||
<script>
|
||||
var Module = {
|
||||
print: console.log,
|
||||
printErr: console.error,
|
||||
canvas: (function() {
|
||||
return document.getElementById('canvas');
|
||||
})()
|
||||
}
|
||||
</script>
|
||||
<script type="text/javascript" src="../core_basic_window_web.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,52 @@
|
||||
#version 100
|
||||
|
||||
precision mediump float;
|
||||
|
||||
// Input vertex attributes (from vertex shader)
|
||||
varying vec2 fragTexCoord;
|
||||
varying vec4 fragColor;
|
||||
|
||||
// Input uniform values
|
||||
uniform sampler2D texture0;
|
||||
uniform vec4 colDiffuse;
|
||||
|
||||
// NOTE: Add here your custom variables
|
||||
uniform vec2 leftLensCenter;
|
||||
uniform vec2 rightLensCenter;
|
||||
uniform vec2 leftScreenCenter;
|
||||
uniform vec2 rightScreenCenter;
|
||||
uniform vec2 scale;
|
||||
uniform vec2 scaleIn;
|
||||
uniform vec4 hmdWarpParam;
|
||||
uniform vec4 chromaAbParam;
|
||||
|
||||
void main()
|
||||
{
|
||||
// Compute lens distortion
|
||||
vec2 lensCenter = fragTexCoord.x < 0.5? leftLensCenter : rightLensCenter;
|
||||
vec2 screenCenter = fragTexCoord.x < 0.5? leftScreenCenter : rightScreenCenter;
|
||||
vec2 theta = (fragTexCoord - lensCenter)*scaleIn;
|
||||
float rSq = theta.x*theta.x + theta.y*theta.y;
|
||||
vec2 theta1 = theta*(hmdWarpParam.x + hmdWarpParam.y*rSq + hmdWarpParam.z*rSq*rSq + hmdWarpParam.w*rSq*rSq*rSq);
|
||||
vec2 thetaBlue = theta1*(chromaAbParam.z + chromaAbParam.w*rSq);
|
||||
vec2 tcBlue = lensCenter + scale*thetaBlue;
|
||||
|
||||
if (any(bvec2(clamp(tcBlue, screenCenter - vec2(0.25, 0.5), screenCenter + vec2(0.25, 0.5)) - tcBlue)))
|
||||
{
|
||||
// Set black fragment for everything outside the lens border
|
||||
gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Compute color chroma aberration
|
||||
float blue = texture2D(texture0, tcBlue).b;
|
||||
vec2 tcGreen = lensCenter + scale*theta1;
|
||||
float green = texture2D(texture0, tcGreen).g;
|
||||
|
||||
vec2 thetaRed = theta1*(chromaAbParam.x + chromaAbParam.y*rSq);
|
||||
vec2 tcRed = lensCenter + scale*thetaRed;
|
||||
|
||||
float red = texture2D(texture0, tcRed).r;
|
||||
gl_FragColor = vec4(red, green, blue, 1.0);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
#version 330
|
||||
|
||||
// Input vertex attributes (from vertex shader)
|
||||
in vec2 fragTexCoord;
|
||||
in vec4 fragColor;
|
||||
|
||||
// Input uniform values
|
||||
uniform sampler2D texture0;
|
||||
uniform vec4 colDiffuse;
|
||||
|
||||
// Output fragment color
|
||||
out vec4 finalColor;
|
||||
|
||||
// NOTE: Add here your custom variables
|
||||
uniform vec2 leftLensCenter = vec2(0.288, 0.5);
|
||||
uniform vec2 rightLensCenter = vec2(0.712, 0.5);
|
||||
uniform vec2 leftScreenCenter = vec2(0.25, 0.5);
|
||||
uniform vec2 rightScreenCenter = vec2(0.75, 0.5);
|
||||
uniform vec2 scale = vec2(0.25, 0.45);
|
||||
uniform vec2 scaleIn = vec2(4, 2.2222);
|
||||
uniform vec4 hmdWarpParam = vec4(1, 0.22, 0.24, 0);
|
||||
uniform vec4 chromaAbParam = vec4(0.996, -0.004, 1.014, 0.0);
|
||||
|
||||
void main()
|
||||
{
|
||||
// Compute lens distortion
|
||||
vec2 lensCenter = fragTexCoord.x < 0.5? leftLensCenter : rightLensCenter;
|
||||
vec2 screenCenter = fragTexCoord.x < 0.5? leftScreenCenter : rightScreenCenter;
|
||||
vec2 theta = (fragTexCoord - lensCenter)*scaleIn;
|
||||
float rSq = theta.x*theta.x + theta.y*theta.y;
|
||||
vec2 theta1 = theta*(hmdWarpParam.x + hmdWarpParam.y*rSq + hmdWarpParam.z*rSq*rSq + hmdWarpParam.w*rSq*rSq*rSq);
|
||||
vec2 thetaBlue = theta1*(chromaAbParam.z + chromaAbParam.w*rSq);
|
||||
vec2 tcBlue = lensCenter + scale*thetaBlue;
|
||||
|
||||
if (any(bvec2(clamp(tcBlue, screenCenter - vec2(0.25, 0.5), screenCenter + vec2(0.25, 0.5)) - tcBlue)))
|
||||
{
|
||||
// Set black fragment for everything outside the lens border
|
||||
finalColor = vec4(0.0, 0.0, 0.0, 1.0);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Compute color chroma aberration
|
||||
float blue = texture(texture0, tcBlue).b;
|
||||
vec2 tcGreen = lensCenter + scale*theta1;
|
||||
float green = texture(texture0, tcGreen).g;
|
||||
|
||||
vec2 thetaRed = theta1*(chromaAbParam.x + chromaAbParam.y*rSq);
|
||||
vec2 tcRed = lensCenter + scale*thetaRed;
|
||||
|
||||
float red = texture(texture0, tcRed).r;
|
||||
finalColor = vec4(red, green, blue, 1.0);
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 19 KiB |
|
After Width: | Height: | Size: 16 KiB |
@@ -0,0 +1,63 @@
|
||||
/*******************************************************************************************
|
||||
*
|
||||
* raylib [models] example - Drawing billboards
|
||||
*
|
||||
* 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-cpp.hpp"
|
||||
|
||||
int main() {
|
||||
// Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
const int screenWidth = 800;
|
||||
const int screenHeight = 450;
|
||||
|
||||
raylib::Window window(screenWidth, screenHeight, "raylib [models] example - drawing billboards");
|
||||
|
||||
// Define the camera to look into our 3d world
|
||||
raylib::Camera camera(
|
||||
raylib::Vector3(5.0f, 4.0f, 5.0f),
|
||||
raylib::Vector3(0.0f, 2.0f, 0.0f),
|
||||
raylib::Vector3(0.0f, 1.0f, 0.0f),
|
||||
45.0f,
|
||||
CAMERA_PERSPECTIVE);
|
||||
|
||||
raylib::Texture2D bill("resources/billboard.png"); // Our texture billboard
|
||||
raylib::Vector3 billPosition(0.0f, 2.0f, 0.0f); // Position where draw billboard
|
||||
|
||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
// Main game loop
|
||||
while (!window.ShouldClose()) { // Detect window close button or ESC key
|
||||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
camera.Update(CAMERA_ORBITAL); // Update camera
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
//----------------------------------------------------------------------------------
|
||||
BeginDrawing();
|
||||
{
|
||||
window.ClearBackground(RAYWHITE);
|
||||
|
||||
camera.BeginMode();
|
||||
{
|
||||
DrawGrid(10, 1.0f); // Draw a grid
|
||||
bill.DrawBillboard(camera, billPosition, 2.0f);
|
||||
}
|
||||
camera.EndMode();
|
||||
|
||||
DrawFPS(10, 10);
|
||||
}
|
||||
EndDrawing();
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
/*******************************************************************************************
|
||||
*
|
||||
* raylib [models] example - first person maze
|
||||
*
|
||||
* This example has been created using raylib 2.5 (www.raylib.com)
|
||||
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
||||
*
|
||||
* Copyright (c) 2019 Ramon Santamaria (@raysan5)
|
||||
*
|
||||
********************************************************************************************/
|
||||
|
||||
#include "raylib-cpp.hpp"
|
||||
|
||||
int main(void)
|
||||
{
|
||||
// Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
const int screenWidth = 800;
|
||||
const int screenHeight = 450;
|
||||
|
||||
raylib::Window window(screenWidth, screenHeight, "raylib [models] example - first person maze");
|
||||
|
||||
// Define the camera to look into our 3d world
|
||||
raylib::Camera camera({ 0.2f, 0.4f, 0.2f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f);
|
||||
|
||||
raylib::Image imMap("resources/cubicmap.png"); // Load cubicmap image (RAM)
|
||||
raylib::Texture cubicmap(imMap); // Convert image to texture to display (VRAM)
|
||||
raylib::MeshUnmanaged mesh = raylib::MeshUnmanaged::Cubicmap(imMap, Vector3{ 1.0f, 1.0f, 1.0f }); // Use MeshUnmanaged, Mesh will be handled by Model
|
||||
raylib::Model model(mesh);
|
||||
|
||||
// NOTE: By default each cube is mapped to one part of texture atlas
|
||||
raylib::Texture texture("resources/cubicmap_atlas.png"); // Load map texture
|
||||
model.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = texture; // Set map diffuse texture
|
||||
|
||||
// Get map image data to be used for collision detection
|
||||
Color *mapPixels = imMap.LoadColors();
|
||||
|
||||
imMap.Unload(); // Unload image from RAM
|
||||
|
||||
raylib::Vector3 mapPosition(-16.0f, 0.0f, -8.0f); // Set model position
|
||||
raylib::Vector3 playerPosition(camera.position); // Set player position
|
||||
|
||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
// Main game loop
|
||||
while (!window.ShouldClose()) { // Detect window close button or ESC key
|
||||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
raylib::Vector3 oldCamPos(camera.position); // Store old camera position
|
||||
|
||||
camera.Update(CAMERA_FIRST_PERSON); // Update camera
|
||||
|
||||
// Check player collision (we simplify to 2D collision detection)
|
||||
raylib::Vector2 playerPos(camera.position.x, camera.position.z);
|
||||
float playerRadius = 0.1f; // Collision radius (player is modelled as a cilinder for collision)
|
||||
|
||||
int playerCellX = static_cast<int>(playerPos.x - mapPosition.x + 0.5f);
|
||||
int playerCellY = static_cast<int>(playerPos.y - mapPosition.z + 0.5f);
|
||||
|
||||
// Out-of-limits security check
|
||||
if (playerCellX < 0) playerCellX = 0;
|
||||
else if (playerCellX >= cubicmap.width) playerCellX = cubicmap.width - 1;
|
||||
|
||||
if (playerCellY < 0) playerCellY = 0;
|
||||
else if (playerCellY >= cubicmap.height) playerCellY = cubicmap.height - 1;
|
||||
|
||||
// Check map collisions using image data and player position
|
||||
// TODO: Improvement: Just check player surrounding cells for collision
|
||||
for (int y = 0; y < cubicmap.height; y++)
|
||||
{
|
||||
for (int x = 0; x < cubicmap.width; x++)
|
||||
{
|
||||
if ((mapPixels[y*cubicmap.width + x].r == 255) && // Collision: white pixel, only check R channel
|
||||
(playerPos.CheckCollisionCircle(playerRadius,
|
||||
Rectangle{ mapPosition.x - 0.5f + x*1.0f, mapPosition.z - 0.5f + y*1.0f, 1.0f, 1.0f })))
|
||||
{
|
||||
// Collision detected, reset camera position
|
||||
camera.position = oldCamPos;
|
||||
}
|
||||
}
|
||||
}
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
//----------------------------------------------------------------------------------
|
||||
BeginDrawing();
|
||||
{
|
||||
window.ClearBackground(RAYWHITE);
|
||||
|
||||
camera.BeginMode();
|
||||
{
|
||||
model.Draw(mapPosition); // Draw maze map
|
||||
// playerPosition.DrawCube((Vector3){ 0.2f, 0.4f, 0.2f }, RED); // Draw player
|
||||
}
|
||||
camera.EndMode();
|
||||
|
||||
cubicmap.Draw(Vector2{ static_cast<float>(GetScreenWidth() - cubicmap.width*4 - 20), 20 }, 0.0f, 4.0f, WHITE);
|
||||
DrawRectangleLines(GetScreenWidth() - cubicmap.width*4 - 20, 20, cubicmap.width*4, cubicmap.height*4, GREEN);
|
||||
|
||||
// Draw player position radar
|
||||
DrawRectangle(GetScreenWidth() - cubicmap.width*4 - 20 + playerCellX*4, 20 + playerCellY*4, 4, 4, RED);
|
||||
|
||||
DrawFPS(10, 10);
|
||||
}
|
||||
EndDrawing();
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
// De-Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
UnloadImageColors(mapPixels); // Unload color array
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
After Width: | Height: | Size: 22 KiB |
|
After Width: | Height: | Size: 164 B |
|
After Width: | Height: | Size: 36 KiB |
@@ -0,0 +1,31 @@
|
||||
#include "Player.hpp"
|
||||
#include "raylib-cpp.hpp"
|
||||
|
||||
Player::Player() {
|
||||
position = Rectangle{
|
||||
GetScreenWidth() / 2.0f - 50,
|
||||
GetScreenHeight() / 2.0f - 50,
|
||||
100,
|
||||
100
|
||||
};
|
||||
speed = 3;
|
||||
}
|
||||
|
||||
void Player::Draw() {
|
||||
position.Draw(RED);
|
||||
}
|
||||
|
||||
void Player::Update() {
|
||||
if (IsKeyDown(KEY_UP)) {
|
||||
position.y -= speed;
|
||||
}
|
||||
if (IsKeyDown(KEY_DOWN)) {
|
||||
position.y += speed;
|
||||
}
|
||||
if (IsKeyDown(KEY_RIGHT)) {
|
||||
position.x += speed;
|
||||
}
|
||||
if (IsKeyDown(KEY_LEFT)) {
|
||||
position.x -= speed;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
#include "raylib-cpp.hpp"
|
||||
|
||||
class Player {
|
||||
public:
|
||||
Player();
|
||||
raylib::Rectangle position;
|
||||
int speed;
|
||||
void Draw();
|
||||
void Update();
|
||||
};
|
||||
@@ -0,0 +1,3 @@
|
||||
# Multiple Files Example
|
||||
|
||||
This provides an example of including raylib-cpp.hpp in multiple files.
|
||||
@@ -0,0 +1,39 @@
|
||||
/*******************************************************************************************
|
||||
*
|
||||
* raylib-cpp [multiple] example - Includes raylib-cpp.hpp from multiple sources.
|
||||
*
|
||||
* Welcome to raylib!
|
||||
*
|
||||
* To test examples, just press F6 and execute raylib_compile_execute script
|
||||
* Note that compiled executable is placed in the same folder as .c file
|
||||
*
|
||||
* You can find all basic examples on C:\raylib\raylib\examples folder or
|
||||
* raylib official webpage: www.raylib.com
|
||||
*
|
||||
* Enjoy using raylib. :)
|
||||
*
|
||||
* This example has been created using raylib-cpp
|
||||
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
||||
*
|
||||
* Copyright (c) 2021 Rob Loach (https://robloach.net)
|
||||
*
|
||||
********************************************************************************************/
|
||||
|
||||
#include "Player.hpp"
|
||||
#include "raylib-cpp.hpp"
|
||||
|
||||
int main() {
|
||||
raylib::Window window(640, 480, "raylib-cpp [multiple] example");
|
||||
SetTargetFPS(60);
|
||||
|
||||
Player player;
|
||||
while (!window.ShouldClose()) {
|
||||
window.BeginDrawing();
|
||||
{
|
||||
window.ClearBackground(SKYBLUE);
|
||||
player.Update();
|
||||
player.Draw();
|
||||
}
|
||||
window.EndDrawing();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
#version 100
|
||||
|
||||
precision mediump float;
|
||||
|
||||
// Input vertex attributes (from vertex shader)
|
||||
varying vec2 fragTexCoord;
|
||||
varying vec4 fragColor;
|
||||
|
||||
// Input uniform values
|
||||
uniform sampler2D texture0;
|
||||
uniform vec4 colDiffuse;
|
||||
|
||||
uniform float secondes;
|
||||
|
||||
uniform vec2 size;
|
||||
|
||||
uniform float freqX;
|
||||
uniform float freqY;
|
||||
uniform float ampX;
|
||||
uniform float ampY;
|
||||
uniform float speedX;
|
||||
uniform float speedY;
|
||||
|
||||
void main() {
|
||||
float pixelWidth = 1.0 / size.x;
|
||||
float pixelHeight = 1.0 / size.y;
|
||||
float aspect = pixelHeight / pixelWidth;
|
||||
float boxLeft = 0.0;
|
||||
float boxTop = 0.0;
|
||||
|
||||
vec2 p = fragTexCoord;
|
||||
p.x += cos((fragTexCoord.y - boxTop) * freqX / ( pixelWidth * 750.0) + (secondes * speedX)) * ampX * pixelWidth;
|
||||
p.y += sin((fragTexCoord.x - boxLeft) * freqY * aspect / ( pixelHeight * 750.0) + (secondes * speedY)) * ampY * pixelHeight;
|
||||
|
||||
gl_FragColor = texture2D(texture0, p)*colDiffuse*fragColor;
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
#version 330
|
||||
|
||||
// Input vertex attributes (from vertex shader)
|
||||
in vec2 fragTexCoord;
|
||||
in vec4 fragColor;
|
||||
|
||||
// Input uniform values
|
||||
uniform sampler2D texture0;
|
||||
uniform vec4 colDiffuse;
|
||||
|
||||
// Output fragment color
|
||||
out vec4 finalColor;
|
||||
|
||||
uniform float secondes;
|
||||
|
||||
uniform vec2 size;
|
||||
|
||||
uniform float freqX;
|
||||
uniform float freqY;
|
||||
uniform float ampX;
|
||||
uniform float ampY;
|
||||
uniform float speedX;
|
||||
uniform float speedY;
|
||||
|
||||
void main() {
|
||||
float pixelWidth = 1.0 / size.x;
|
||||
float pixelHeight = 1.0 / size.y;
|
||||
float aspect = pixelHeight / pixelWidth;
|
||||
float boxLeft = 0.0;
|
||||
float boxTop = 0.0;
|
||||
|
||||
vec2 p = fragTexCoord;
|
||||
p.x += cos((fragTexCoord.y - boxTop) * freqX / ( pixelWidth * 750.0) + (secondes * speedX)) * ampX * pixelWidth;
|
||||
p.y += sin((fragTexCoord.x - boxLeft) * freqY * aspect / ( pixelHeight * 750.0) + (secondes * speedY)) * ampY * pixelHeight;
|
||||
|
||||
finalColor = texture(texture0, p)*colDiffuse*fragColor;
|
||||
}
|
||||
|
After Width: | Height: | Size: 22 KiB |
@@ -0,0 +1,102 @@
|
||||
/*******************************************************************************************
|
||||
*
|
||||
* raylib [shaders] example - Texture Waves
|
||||
*
|
||||
* NOTE: This example requires raylib OpenGL 3.3 or ES2 versions for shaders support,
|
||||
* OpenGL 1.1 does not support shaders, recompile raylib to OpenGL 3.3 version.
|
||||
*
|
||||
* NOTE: Shaders used in this example are #version 330 (OpenGL 3.3), to test this example
|
||||
* on OpenGL ES 2.0 platforms (Android, Raspberry Pi, HTML5), use #version 100 shaders
|
||||
* raylib comes with shaders ready for both versions, check raylib/shaders install folder
|
||||
*
|
||||
* This example has been created using raylib 2.5 (www.raylib.com)
|
||||
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
||||
*
|
||||
* Example contributed by Anata (@anatagawa) and reviewed by Ramon Santamaria (@raysan5)
|
||||
*
|
||||
* Copyright (c) 2019 Anata (@anatagawa) and Ramon Santamaria (@raysan5)
|
||||
*
|
||||
********************************************************************************************/
|
||||
|
||||
#include "raylib-cpp.hpp"
|
||||
|
||||
#if defined(PLATFORM_DESKTOP)
|
||||
#define GLSL_VERSION 330
|
||||
#else // PLATFORM_RPI, PLATFORM_ANDROID, PLATFORM_WEB
|
||||
#define GLSL_VERSION 100
|
||||
#endif
|
||||
|
||||
int main(void)
|
||||
{
|
||||
// Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
const int screenWidth = 800;
|
||||
const int screenHeight = 450;
|
||||
|
||||
raylib::Window window(screenWidth, screenHeight, "raylib-cpp [shaders] example - texture waves");
|
||||
|
||||
// Load texture texture to apply shaders
|
||||
raylib::Texture2D texture("resources/space.png");
|
||||
|
||||
// Load shader and setup location points and values
|
||||
raylib::Shader shader(0, TextFormat("resources/shaders/glsl%i/wave.fs", GLSL_VERSION));
|
||||
|
||||
int secondsLoc = shader.GetLocation("secondes");
|
||||
int freqXLoc = shader.GetLocation("freqX");
|
||||
int freqYLoc = shader.GetLocation("freqY");
|
||||
int ampXLoc = shader.GetLocation("ampX");
|
||||
int ampYLoc = shader.GetLocation("ampY");
|
||||
int speedXLoc = shader.GetLocation("speedX");
|
||||
int speedYLoc = shader.GetLocation("speedY");
|
||||
|
||||
// Shader uniform values that can be updated at any time
|
||||
float freqX = 25.0f;
|
||||
float freqY = 25.0f;
|
||||
float ampX = 5.0f;
|
||||
float ampY = 5.0f;
|
||||
float speedX = 8.0f;
|
||||
float speedY = 8.0f;
|
||||
|
||||
float screenSize[2] = { (float)window.GetWidth(), (float)window.GetHeight() };
|
||||
shader.SetValue(shader.GetLocation("size"), &screenSize, SHADER_UNIFORM_VEC2);
|
||||
shader.SetValue(freqXLoc, &freqX, SHADER_UNIFORM_FLOAT);
|
||||
shader.SetValue(freqYLoc, &freqY, SHADER_UNIFORM_FLOAT);
|
||||
shader.SetValue(ampXLoc, &X, SHADER_UNIFORM_FLOAT);
|
||||
shader.SetValue(ampYLoc, &Y, SHADER_UNIFORM_FLOAT);
|
||||
shader.SetValue(speedXLoc, &speedX, SHADER_UNIFORM_FLOAT);
|
||||
shader.SetValue(speedYLoc, &speedY, SHADER_UNIFORM_FLOAT);
|
||||
|
||||
float seconds = 0.0f;
|
||||
|
||||
window.SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||
// -------------------------------------------------------------------------------------------------------------
|
||||
|
||||
// Main game loop
|
||||
while (!window.ShouldClose()) // Detect window close button or ESC key
|
||||
{
|
||||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
seconds += GetFrameTime();
|
||||
|
||||
shader.SetValue(secondsLoc, &seconds, SHADER_UNIFORM_FLOAT);
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
//----------------------------------------------------------------------------------
|
||||
BeginDrawing();
|
||||
|
||||
ClearBackground(RAYWHITE);
|
||||
|
||||
shader.BeginMode();
|
||||
|
||||
texture.Draw(0, 0, WHITE);
|
||||
texture.Draw(texture.GetWidth(), 0, WHITE);
|
||||
|
||||
EndShaderMode();
|
||||
|
||||
EndDrawing();
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
After Width: | Height: | Size: 2.6 KiB |
@@ -0,0 +1,102 @@
|
||||
/*******************************************************************************************
|
||||
*
|
||||
* raylib [shapes] example - collision area
|
||||
*
|
||||
* This example has been created using raylib 2.5 (www.raylib.com)
|
||||
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
||||
*
|
||||
* Copyright (c) 2013-2019 Ramon Santamaria (@raysan5)
|
||||
*
|
||||
********************************************************************************************/
|
||||
|
||||
#include "raylib-cpp.hpp"
|
||||
|
||||
#include <cmath> // NOLINT
|
||||
|
||||
int main(void)
|
||||
{
|
||||
// Initialization
|
||||
//---------------------------------------------------------
|
||||
const int screenWidth = 800;
|
||||
const int screenHeight = 450;
|
||||
|
||||
raylib::Window window(screenWidth, screenHeight, "raylib [shapes] example - collision area");
|
||||
|
||||
// Box A: Moving box
|
||||
raylib::Rectangle boxA(10, GetScreenHeight()/2 - 50, 200, 100);
|
||||
int boxASpeedX = 4;
|
||||
|
||||
// Box B: Mouse moved box
|
||||
raylib::Rectangle boxB(GetScreenWidth()/2 - 30, GetScreenHeight()/2 - 30, 60, 60);
|
||||
|
||||
raylib::Rectangle boxCollision(0); // Collision rectangle
|
||||
|
||||
int screenUpperLimit = 40; // Top menu limits
|
||||
|
||||
bool pause = false; // Movement pause
|
||||
bool collision = false; // Collision detection
|
||||
|
||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||
//----------------------------------------------------------
|
||||
|
||||
// Main game loop
|
||||
while (!window.ShouldClose()) { // Detect window close button or ESC key
|
||||
// Update
|
||||
//-----------------------------------------------------
|
||||
// Move box if not paused
|
||||
if (!pause) boxA.x += boxASpeedX;
|
||||
|
||||
// Bounce box on x screen limits
|
||||
if (((boxA.x + boxA.width) >= GetScreenWidth()) || (boxA.x <= 0)) boxASpeedX *= -1;
|
||||
|
||||
// Update player-controlled-box (box02)
|
||||
boxB.x = GetMouseX() - boxB.width/2;
|
||||
boxB.y = GetMouseY() - boxB.height/2;
|
||||
|
||||
// Make sure Box B does not go out of move area limits
|
||||
if ((boxB.x + boxB.width) >= GetScreenWidth()) boxB.x = GetScreenWidth() - boxB.width;
|
||||
else if (boxB.x <= 0) boxB.x = 0;
|
||||
|
||||
if ((boxB.y + boxB.height) >= GetScreenHeight()) boxB.y = GetScreenHeight() - boxB.height;
|
||||
else if (boxB.y <= screenUpperLimit) boxB.y = screenUpperLimit;
|
||||
|
||||
// Check boxes collision
|
||||
collision = boxA.CheckCollision(boxB);
|
||||
|
||||
// Get collision rectangle (only on collision)
|
||||
if (collision) boxCollision = boxA.GetCollision(boxB);
|
||||
|
||||
// Pause Box A movement
|
||||
if (IsKeyPressed(KEY_SPACE)) pause = !pause;
|
||||
//-----------------------------------------------------
|
||||
|
||||
// Draw
|
||||
//-----------------------------------------------------
|
||||
BeginDrawing();
|
||||
|
||||
window.ClearBackground(RAYWHITE);
|
||||
|
||||
DrawRectangle(0, 0, screenWidth, screenUpperLimit, collision? RED : BLACK);
|
||||
|
||||
boxA.Draw(GOLD);
|
||||
boxB.Draw(BLUE);
|
||||
|
||||
if (collision) {
|
||||
// Draw collision area
|
||||
boxCollision.Draw(LIME);
|
||||
|
||||
// Draw collision message
|
||||
raylib::DrawText("COLLISION!", GetScreenWidth()/2 - MeasureText("COLLISION!", 20)/2, screenUpperLimit/2 - 10, 20, BLACK);
|
||||
|
||||
// Draw collision area
|
||||
raylib::DrawText(TextFormat("Collision Area: %i", (int)boxCollision.width*(int)boxCollision.height), GetScreenWidth()/2 - 100, screenUpperLimit + 10, 20, BLACK);
|
||||
}
|
||||
|
||||
DrawFPS(10, 10);
|
||||
|
||||
EndDrawing();
|
||||
//-----------------------------------------------------
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
/*******************************************************************************************
|
||||
*
|
||||
* raylib [shapes] example - Draw raylib logo using basic shapes
|
||||
*
|
||||
* This example has been created using raylib 1.0 (www.raylib.com)
|
||||
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
||||
*
|
||||
* Copyright (c) 2014 Ramon Santamaria (@raysan5)
|
||||
*
|
||||
********************************************************************************************/
|
||||
|
||||
#include "raylib-cpp.hpp"
|
||||
|
||||
int main() {
|
||||
// Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
const int screenWidth = 800;
|
||||
const int screenHeight = 450;
|
||||
|
||||
raylib::Window window(screenWidth, screenHeight, "raylib [shapes] example - raylib logo using shapes");
|
||||
raylib::Color foreground(0, 68, 130);
|
||||
raylib::Color background = RAYWHITE;
|
||||
|
||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
// Main game loop
|
||||
while (!window.ShouldClose()) { // Detect window close button or ESC key
|
||||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
// Update your variables here
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
//----------------------------------------------------------------------------------
|
||||
BeginDrawing();
|
||||
{
|
||||
window.ClearBackground(background);
|
||||
|
||||
foreground.DrawRectangle(screenWidth/2 - 128, screenHeight/2 - 128, 256, 256);
|
||||
background.DrawRectangle(screenWidth/2 - 112, screenHeight/2 - 112, 224, 224);
|
||||
foreground.DrawText("raylib", screenWidth/2 - 44, screenHeight/2 + 24, 50);
|
||||
foreground.DrawText("cpp", screenWidth/2 - 74, screenHeight/2 + 54, 50);
|
||||
|
||||
DrawText("this is NOT a texture!", 350, 370, 10, GRAY);
|
||||
}
|
||||
EndDrawing();
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
All fonts used in examples are provided under a free and permissive license.
|
||||
Check individual licenses for details:
|
||||
|
||||
- [Alpha Beta] by Brian Kent (AEnigma) - https://www.dafont.com/es/alpha-beta.font
|
||||
- [Setback] by Brian Kent (AEnigma) - https://www.dafont.com/es/setback.font
|
||||
- [Jupiter Crash] by Brian Kent (AEnigma) - https://www.dafont.com/es/jupiter-crash.font
|
||||
- [Alagard] by Hewett Tsoi - https://www.dafont.com/es/alagard.font
|
||||
- [Romulus] by Hewett Tsoi - https://www.dafont.com/es/romulus.font
|
||||
- [Mecha] by Captain Falcon - https://www.dafont.com/es/mecha-cf.font
|
||||
- [PixelPlay] by Aleksander Shevchuk - https://www.dafont.com/es/pixelplay.font
|
||||
- [PixAntiqua] by Gerhard Großmann - https://www.dafont.com/es/pixantiqua.font
|
||||
- [Kaiserzeit Gotisch] by Dieter Steffmann - https://www.dafont.com/es/kaiserzeit-gotisch.font
|
||||
- [Noto CJK] by Google Fonts - https://www.google.com/get/noto/help/cjk/
|
||||
- [Anonymous Pro] by Mark Simonson - https://fonts.google.com/specimen/Anonymous+Pro
|
||||
- [DejaVu] by DejaVu Fonts - https://dejavu-fonts.github.io/
|
||||
- [Symbola] by George Douros - https://fontlibrary.org/en/font/symbola
|
||||
|
After Width: | Height: | Size: 44 KiB |
|
After Width: | Height: | Size: 28 KiB |
|
After Width: | Height: | Size: 32 KiB |
|
After Width: | Height: | Size: 3.5 KiB |
|
After Width: | Height: | Size: 2.4 KiB |
|
After Width: | Height: | Size: 2.9 KiB |
|
After Width: | Height: | Size: 2.3 KiB |
|
After Width: | Height: | Size: 2.7 KiB |
|
After Width: | Height: | Size: 2.8 KiB |
|
After Width: | Height: | Size: 2.6 KiB |
|
After Width: | Height: | Size: 2.5 KiB |
@@ -0,0 +1,188 @@
|
||||
info face="PixAntiqua" size=32 bold=0 italic=0 charset="" unicode=1 stretchH=100 smooth=1 aa=1 padding=2,2,2,2 spacing=2,2 outline=0
|
||||
common lineHeight=32 base=27 scaleW=512 scaleH=512 pages=1 packed=0 alphaChnl=0 redChnl=4 greenChnl=4 blueChnl=4
|
||||
page id=0 file="pixantiqua.png"
|
||||
chars count=184
|
||||
char id=32 x=9 y=304 width=7 height=36 xoffset=-3 yoffset=-2 xadvance=8 page=0 chnl=15
|
||||
char id=33 x=391 y=266 width=11 height=36 xoffset=-3 yoffset=-2 xadvance=8 page=0 chnl=15
|
||||
char id=34 x=240 y=266 width=14 height=36 xoffset=-3 yoffset=-2 xadvance=11 page=0 chnl=15
|
||||
char id=35 x=468 y=38 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15
|
||||
char id=36 x=152 y=76 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
|
||||
char id=37 x=176 y=76 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
|
||||
char id=38 x=303 y=0 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15
|
||||
char id=39 x=495 y=266 width=8 height=36 xoffset=-3 yoffset=-2 xadvance=5 page=0 chnl=15
|
||||
char id=40 x=256 y=266 width=14 height=36 xoffset=-3 yoffset=-2 xadvance=11 page=0 chnl=15
|
||||
char id=199 x=432 y=152 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
|
||||
char id=200 x=126 y=228 width=19 height=36 xoffset=-3 yoffset=-2 xadvance=16 page=0 chnl=15
|
||||
char id=201 x=147 y=228 width=19 height=36 xoffset=-3 yoffset=-2 xadvance=16 page=0 chnl=15
|
||||
char id=202 x=288 y=190 width=19 height=36 xoffset=-3 yoffset=-2 xadvance=16 page=0 chnl=15
|
||||
char id=203 x=189 y=228 width=19 height=36 xoffset=-3 yoffset=-2 xadvance=16 page=0 chnl=15
|
||||
char id=204 x=468 y=228 width=16 height=36 xoffset=-3 yoffset=-2 xadvance=13 page=0 chnl=15
|
||||
char id=205 x=486 y=228 width=16 height=36 xoffset=-3 yoffset=-2 xadvance=13 page=0 chnl=15
|
||||
char id=206 x=0 y=266 width=16 height=36 xoffset=-3 yoffset=-2 xadvance=13 page=0 chnl=15
|
||||
char id=207 x=72 y=266 width=16 height=36 xoffset=-3 yoffset=-2 xadvance=13 page=0 chnl=15
|
||||
char id=208 x=329 y=0 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15
|
||||
char id=209 x=277 y=0 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15
|
||||
char id=210 x=182 y=38 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15
|
||||
char id=211 x=26 y=76 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15
|
||||
char id=41 x=272 y=266 width=14 height=36 xoffset=-3 yoffset=-2 xadvance=11 page=0 chnl=15
|
||||
char id=42 x=288 y=266 width=14 height=36 xoffset=-3 yoffset=-2 xadvance=11 page=0 chnl=15
|
||||
char id=43 x=414 y=190 width=19 height=36 xoffset=-3 yoffset=-2 xadvance=16 page=0 chnl=15
|
||||
char id=44 x=378 y=266 width=11 height=36 xoffset=-3 yoffset=-2 xadvance=8 page=0 chnl=15
|
||||
char id=45 x=414 y=228 width=16 height=36 xoffset=-3 yoffset=-2 xadvance=13 page=0 chnl=15
|
||||
char id=46 x=443 y=266 width=11 height=36 xoffset=-3 yoffset=-2 xadvance=8 page=0 chnl=15
|
||||
char id=47 x=392 y=76 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
|
||||
char id=48 x=485 y=0 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15
|
||||
char id=49 x=450 y=228 width=16 height=36 xoffset=-3 yoffset=-2 xadvance=13 page=0 chnl=15
|
||||
char id=50 x=21 y=228 width=19 height=36 xoffset=-3 yoffset=-2 xadvance=16 page=0 chnl=15
|
||||
char id=51 x=42 y=228 width=19 height=36 xoffset=-3 yoffset=-2 xadvance=16 page=0 chnl=15
|
||||
char id=59 x=456 y=266 width=11 height=36 xoffset=-3 yoffset=-2 xadvance=8 page=0 chnl=15
|
||||
char id=60 x=168 y=228 width=19 height=36 xoffset=-3 yoffset=-2 xadvance=16 page=0 chnl=15
|
||||
char id=61 x=309 y=190 width=19 height=36 xoffset=-3 yoffset=-2 xadvance=16 page=0 chnl=15
|
||||
char id=62 x=336 y=228 width=19 height=36 xoffset=-3 yoffset=-2 xadvance=16 page=0 chnl=15
|
||||
char id=63 x=315 y=228 width=19 height=36 xoffset=-3 yoffset=-2 xadvance=16 page=0 chnl=15
|
||||
char id=64 x=364 y=38 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15
|
||||
char id=65 x=390 y=38 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15
|
||||
char id=66 x=120 y=114 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
|
||||
char id=67 x=144 y=114 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
|
||||
char id=68 x=168 y=114 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
|
||||
char id=69 x=294 y=228 width=19 height=36 xoffset=-3 yoffset=-2 xadvance=16 page=0 chnl=15
|
||||
char id=52 x=488 y=76 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
|
||||
char id=53 x=63 y=228 width=19 height=36 xoffset=-3 yoffset=-2 xadvance=16 page=0 chnl=15
|
||||
char id=54 x=24 y=114 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
|
||||
char id=55 x=48 y=114 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
|
||||
char id=56 x=72 y=114 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
|
||||
char id=57 x=96 y=114 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
|
||||
char id=58 x=404 y=266 width=11 height=36 xoffset=-3 yoffset=-2 xadvance=8 page=0 chnl=15
|
||||
char id=70 x=252 y=228 width=19 height=36 xoffset=-3 yoffset=-2 xadvance=16 page=0 chnl=15
|
||||
char id=71 x=192 y=114 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
|
||||
char id=72 x=78 y=76 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15
|
||||
char id=78 x=78 y=38 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15
|
||||
char id=79 x=355 y=0 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15
|
||||
char id=80 x=264 y=114 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
|
||||
char id=81 x=381 y=0 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15
|
||||
char id=82 x=288 y=114 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
|
||||
char id=83 x=312 y=114 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
|
||||
char id=91 x=144 y=266 width=14 height=36 xoffset=-3 yoffset=-2 xadvance=11 page=0 chnl=15
|
||||
char id=92 x=108 y=266 width=16 height=36 xoffset=-3 yoffset=-2 xadvance=13 page=0 chnl=15
|
||||
char id=93 x=304 y=266 width=14 height=36 xoffset=-3 yoffset=-2 xadvance=11 page=0 chnl=15
|
||||
char id=94 x=34 y=0 width=32 height=36 xoffset=-3 yoffset=-2 xadvance=29 page=0 chnl=15
|
||||
char id=95 x=231 y=228 width=19 height=36 xoffset=-3 yoffset=-2 xadvance=16 page=0 chnl=15
|
||||
char id=96 x=442 y=38 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15
|
||||
char id=97 x=408 y=114 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
|
||||
char id=98 x=432 y=114 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
|
||||
char id=99 x=210 y=228 width=19 height=36 xoffset=-3 yoffset=-2 xadvance=16 page=0 chnl=15
|
||||
char id=84 x=336 y=114 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
|
||||
char id=85 x=360 y=114 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
|
||||
char id=86 x=0 y=38 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15
|
||||
char id=87 x=68 y=0 width=30 height=36 xoffset=-3 yoffset=-2 xadvance=27 page=0 chnl=15
|
||||
char id=88 x=26 y=38 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15
|
||||
char id=89 x=384 y=114 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
|
||||
char id=90 x=84 y=228 width=19 height=36 xoffset=-3 yoffset=-2 xadvance=16 page=0 chnl=15
|
||||
char id=100 x=456 y=114 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
|
||||
char id=101 x=480 y=114 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
|
||||
char id=102 x=54 y=266 width=16 height=36 xoffset=-3 yoffset=-2 xadvance=13 page=0 chnl=15
|
||||
char id=103 x=0 y=152 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
|
||||
char id=104 x=24 y=152 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
|
||||
char id=105 x=469 y=266 width=11 height=36 xoffset=-3 yoffset=-2 xadvance=8 page=0 chnl=15
|
||||
char id=106 x=18 y=266 width=16 height=36 xoffset=-8 yoffset=-2 xadvance=8 page=0 chnl=15
|
||||
char id=107 x=48 y=152 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
|
||||
char id=108 x=417 y=266 width=11 height=36 xoffset=-3 yoffset=-2 xadvance=8 page=0 chnl=15
|
||||
char id=109 x=161 y=0 width=27 height=36 xoffset=-3 yoffset=-2 xadvance=24 page=0 chnl=15
|
||||
char id=110 x=72 y=152 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
|
||||
char id=111 x=96 y=152 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
|
||||
char id=117 x=192 y=152 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
|
||||
char id=118 x=216 y=152 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
|
||||
char id=119 x=248 y=0 width=27 height=36 xoffset=-3 yoffset=-2 xadvance=24 page=0 chnl=15
|
||||
char id=120 x=240 y=152 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
|
||||
char id=121 x=264 y=152 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
|
||||
char id=122 x=288 y=152 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
|
||||
char id=123 x=432 y=228 width=16 height=36 xoffset=-3 yoffset=-2 xadvance=13 page=0 chnl=15
|
||||
char id=124 x=365 y=266 width=11 height=36 xoffset=-3 yoffset=-2 xadvance=8 page=0 chnl=15
|
||||
char id=125 x=378 y=228 width=16 height=36 xoffset=-3 yoffset=-2 xadvance=13 page=0 chnl=15
|
||||
char id=126 x=393 y=190 width=19 height=36 xoffset=-3 yoffset=-2 xadvance=16 page=0 chnl=15
|
||||
char id=127 x=132 y=0 width=27 height=36 xoffset=-3 yoffset=-2 xadvance=24 page=0 chnl=15
|
||||
char id=160 x=0 y=304 width=7 height=36 xoffset=-3 yoffset=-2 xadvance=8 page=0 chnl=15
|
||||
char id=161 x=352 y=266 width=11 height=36 xoffset=-3 yoffset=-2 xadvance=8 page=0 chnl=15
|
||||
char id=162 x=351 y=190 width=19 height=36 xoffset=-3 yoffset=-2 xadvance=16 page=0 chnl=15
|
||||
char id=163 x=336 y=152 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
|
||||
char id=165 x=360 y=152 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
|
||||
char id=167 x=384 y=152 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
|
||||
char id=169 x=433 y=0 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15
|
||||
char id=170 x=224 y=266 width=14 height=36 xoffset=-3 yoffset=-2 xadvance=11 page=0 chnl=15
|
||||
char id=171 x=105 y=228 width=19 height=36 xoffset=-3 yoffset=-2 xadvance=16 page=0 chnl=15
|
||||
char id=172 x=0 y=0 width=32 height=36 xoffset=-3 yoffset=-2 xadvance=29 page=0 chnl=15
|
||||
char id=173 x=494 y=38 width=16 height=36 xoffset=-3 yoffset=-2 xadvance=13 page=0 chnl=15
|
||||
char id=174 x=52 y=76 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15
|
||||
char id=175 x=52 y=38 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15
|
||||
char id=176 x=126 y=266 width=16 height=36 xoffset=-3 yoffset=-2 xadvance=13 page=0 chnl=15
|
||||
char id=177 x=435 y=190 width=19 height=36 xoffset=-3 yoffset=-2 xadvance=16 page=0 chnl=15
|
||||
char id=178 x=320 y=266 width=14 height=36 xoffset=-3 yoffset=-2 xadvance=11 page=0 chnl=15
|
||||
char id=179 x=336 y=266 width=14 height=36 xoffset=-3 yoffset=-2 xadvance=11 page=0 chnl=15
|
||||
char id=181 x=459 y=0 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15
|
||||
char id=112 x=120 y=152 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
|
||||
char id=113 x=144 y=152 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
|
||||
char id=114 x=396 y=228 width=16 height=36 xoffset=-3 yoffset=-2 xadvance=13 page=0 chnl=15
|
||||
char id=115 x=168 y=152 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
|
||||
char id=116 x=36 y=266 width=16 height=36 xoffset=-3 yoffset=-2 xadvance=13 page=0 chnl=15
|
||||
char id=182 x=408 y=152 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
|
||||
char id=183 x=498 y=190 width=11 height=36 xoffset=-3 yoffset=-2 xadvance=8 page=0 chnl=15
|
||||
char id=185 x=192 y=266 width=14 height=36 xoffset=-3 yoffset=-2 xadvance=11 page=0 chnl=15
|
||||
char id=186 x=208 y=266 width=14 height=36 xoffset=-3 yoffset=-2 xadvance=11 page=0 chnl=15
|
||||
char id=187 x=477 y=190 width=19 height=36 xoffset=-3 yoffset=-2 xadvance=16 page=0 chnl=15
|
||||
char id=191 x=456 y=190 width=19 height=36 xoffset=-3 yoffset=-2 xadvance=16 page=0 chnl=15
|
||||
char id=192 x=407 y=0 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15
|
||||
char id=193 x=234 y=38 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15
|
||||
char id=194 x=416 y=38 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15
|
||||
char id=195 x=156 y=38 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15
|
||||
char id=196 x=130 y=38 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15
|
||||
char id=197 x=104 y=38 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15
|
||||
char id=198 x=190 y=0 width=27 height=36 xoffset=-3 yoffset=-2 xadvance=24 page=0 chnl=15
|
||||
char id=212 x=0 y=76 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15
|
||||
char id=213 x=338 y=38 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15
|
||||
char id=214 x=312 y=38 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15
|
||||
char id=215 x=357 y=228 width=19 height=36 xoffset=-3 yoffset=-2 xadvance=16 page=0 chnl=15
|
||||
char id=216 x=286 y=38 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15
|
||||
char id=217 x=456 y=152 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
|
||||
char id=218 x=480 y=152 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
|
||||
char id=219 x=0 y=190 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
|
||||
char id=220 x=24 y=190 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
|
||||
char id=221 x=48 y=190 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
|
||||
char id=222 x=260 y=38 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15
|
||||
char id=223 x=72 y=190 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
|
||||
char id=224 x=96 y=190 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
|
||||
char id=225 x=120 y=190 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
|
||||
char id=226 x=144 y=190 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
|
||||
char id=227 x=168 y=190 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
|
||||
char id=228 x=192 y=190 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
|
||||
char id=229 x=216 y=190 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
|
||||
char id=230 x=219 y=0 width=27 height=36 xoffset=-3 yoffset=-2 xadvance=24 page=0 chnl=15
|
||||
char id=231 x=372 y=190 width=19 height=36 xoffset=-3 yoffset=-2 xadvance=16 page=0 chnl=15
|
||||
char id=73 x=90 y=266 width=16 height=36 xoffset=-3 yoffset=-2 xadvance=13 page=0 chnl=15
|
||||
char id=74 x=216 y=114 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
|
||||
char id=75 x=240 y=114 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
|
||||
char id=76 x=273 y=228 width=19 height=36 xoffset=-3 yoffset=-2 xadvance=16 page=0 chnl=15
|
||||
char id=77 x=100 y=0 width=30 height=36 xoffset=-3 yoffset=-2 xadvance=27 page=0 chnl=15
|
||||
char id=232 x=312 y=152 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
|
||||
char id=233 x=240 y=190 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
|
||||
char id=234 x=264 y=190 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
|
||||
char id=235 x=104 y=76 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
|
||||
char id=236 x=430 y=266 width=11 height=36 xoffset=-3 yoffset=-2 xadvance=8 page=0 chnl=15
|
||||
char id=237 x=482 y=266 width=11 height=36 xoffset=-3 yoffset=-2 xadvance=8 page=0 chnl=15
|
||||
char id=238 x=160 y=266 width=14 height=36 xoffset=-3 yoffset=-2 xadvance=11 page=0 chnl=15
|
||||
char id=239 x=176 y=266 width=14 height=36 xoffset=-3 yoffset=-2 xadvance=8 page=0 chnl=15
|
||||
char id=240 x=128 y=76 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
|
||||
char id=241 x=200 y=76 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
|
||||
char id=242 x=224 y=76 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
|
||||
char id=243 x=248 y=76 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
|
||||
char id=244 x=272 y=76 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
|
||||
char id=245 x=296 y=76 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
|
||||
char id=246 x=320 y=76 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
|
||||
char id=247 x=330 y=190 width=19 height=36 xoffset=-3 yoffset=-2 xadvance=16 page=0 chnl=15
|
||||
char id=248 x=208 y=38 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15
|
||||
char id=249 x=344 y=76 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
|
||||
char id=250 x=368 y=76 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
|
||||
char id=251 x=416 y=76 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
|
||||
char id=252 x=440 y=76 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
|
||||
char id=253 x=464 y=76 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
|
||||
char id=254 x=0 y=228 width=19 height=36 xoffset=-3 yoffset=-2 xadvance=16 page=0 chnl=15
|
||||
char id=255 x=0 y=114 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
|
||||
|
After Width: | Height: | Size: 4.4 KiB |
@@ -0,0 +1,114 @@
|
||||
/*******************************************************************************************
|
||||
*
|
||||
* raylib [text] example - Font filters
|
||||
*
|
||||
* After font loading, font texture atlas filter could be configured for a softer
|
||||
* display of the font when scaling it to different sizes, that way, it's not required
|
||||
* to generate multiple fonts at multiple sizes (as long as the scaling is not very different)
|
||||
*
|
||||
* This example has been created using raylib 1.3.0 (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-cpp.hpp"
|
||||
|
||||
int main(void)
|
||||
{
|
||||
// Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
const int screenWidth = 800;
|
||||
const int screenHeight = 450;
|
||||
|
||||
raylib::Window window(screenWidth, screenHeight, "raylib [text] example - font filters");
|
||||
|
||||
// TTF Font loading with custom generation parameters
|
||||
raylib::Font font("resources/KAISG.ttf", 96);
|
||||
|
||||
// Generate mipmap levels to use trilinear filtering
|
||||
// NOTE: On 2D drawing it won't be noticeable, it looks like FILTER_BILINEAR
|
||||
font.GetTexture().GenMipmaps();
|
||||
|
||||
raylib::Text msg("Loaded Font", font.GetBaseSize(), BLACK, font);
|
||||
|
||||
Vector2 fontPosition = { 40.0f, screenHeight/2.0f - 80.0f };
|
||||
Vector2 textSize = { 0.0f, 0.0f };
|
||||
|
||||
// Setup texture scaling filter
|
||||
font.GetTexture().SetFilter(TEXTURE_FILTER_POINT);
|
||||
int currentFontFilter = 0; // TEXTURE_FILTER_POINT
|
||||
|
||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
// Main game loop
|
||||
while (!WindowShouldClose()) // Detect window close button or ESC key
|
||||
{
|
||||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
msg.fontSize += GetMouseWheelMove() * 4.0f;
|
||||
|
||||
// Choose font texture filter method
|
||||
if (IsKeyPressed(KEY_ONE))
|
||||
{
|
||||
font.GetTexture().SetFilter(TEXTURE_FILTER_POINT);
|
||||
currentFontFilter = 0;
|
||||
}
|
||||
else if (IsKeyPressed(KEY_TWO))
|
||||
{
|
||||
font.GetTexture().SetFilter(TEXTURE_FILTER_BILINEAR);
|
||||
currentFontFilter = 1;
|
||||
}
|
||||
else if (IsKeyPressed(KEY_THREE))
|
||||
{
|
||||
// NOTE: Trilinear filter won't be noticed on 2D drawing
|
||||
font.GetTexture().SetFilter(TEXTURE_FILTER_TRILINEAR);
|
||||
currentFontFilter = 2;
|
||||
}
|
||||
|
||||
textSize = msg.MeasureEx();
|
||||
|
||||
if (IsKeyDown(KEY_LEFT)) fontPosition.x -= 10;
|
||||
else if (IsKeyDown(KEY_RIGHT)) fontPosition.x += 10;
|
||||
|
||||
// Load a dropped TTF file dynamically (at current fontSize)
|
||||
for (const auto& file : raylib::LoadDroppedFiles()) {
|
||||
if (raylib::IsFileExtension(file, ".ttf")) {
|
||||
msg.font = font = raylib::Font(file, font.GetBaseSize());
|
||||
}
|
||||
}
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
//----------------------------------------------------------------------------------
|
||||
BeginDrawing();
|
||||
|
||||
ClearBackground(RAYWHITE);
|
||||
|
||||
DrawText("Use mouse wheel to change font size", 20, 20, 10, GRAY);
|
||||
DrawText("Use KEY_RIGHT and KEY_LEFT to move text", 20, 40, 10, GRAY);
|
||||
DrawText("Use 1, 2, 3 to change texture filter", 20, 60, 10, GRAY);
|
||||
DrawText("Drop a new TTF font for dynamic loading", 20, 80, 10, DARKGRAY);
|
||||
|
||||
msg.Draw(fontPosition);
|
||||
|
||||
// TODO: It seems texSize measurement is not accurate due to chars offsets...
|
||||
//DrawRectangleLines(fontPosition.x, fontPosition.y, textSize.x, textSize.y, RED);
|
||||
|
||||
DrawRectangle(0, screenHeight - 80, screenWidth, 80, LIGHTGRAY);
|
||||
DrawText(TextFormat("Font size: %02.02f", msg.GetFontSize()), 20, screenHeight - 50, 10, DARKGRAY);
|
||||
DrawText(TextFormat("Text size: [%02.02f, %02.02f]", textSize.x, textSize.y), 20, screenHeight - 30, 10, DARKGRAY);
|
||||
DrawText("CURRENT TEXTURE FILTER:", 250, 400, 20, GRAY);
|
||||
|
||||
if (currentFontFilter == 0) DrawText("POINT", 570, 400, 20, BLACK);
|
||||
else if (currentFontFilter == 1) DrawText("BILINEAR", 570, 400, 20, BLACK);
|
||||
else if (currentFontFilter == 2) DrawText("TRILINEAR", 570, 400, 20, BLACK);
|
||||
|
||||
EndDrawing();
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
/*******************************************************************************************
|
||||
*
|
||||
* raylib [text] example - Font loading
|
||||
*
|
||||
* raylib can load fonts from multiple file formats:
|
||||
*
|
||||
* - TTF/OTF > Sprite font atlas is generated on loading, user can configure
|
||||
* some of the generation parameters (size, characters to include)
|
||||
* - BMFonts > Angel code font fileformat, sprite font image must be provided
|
||||
* together with the .fnt file, font generation cna not be configured
|
||||
* - XNA Spritefont > Sprite font image, following XNA Spritefont conventions,
|
||||
* Characters in image must follow some spacing and order rules
|
||||
*
|
||||
* This example has been created using raylib 2.6 (www.raylib.com)
|
||||
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
||||
*
|
||||
* Copyright (c) 2016-2019 Ramon Santamaria (@raysan5)
|
||||
*
|
||||
********************************************************************************************/
|
||||
|
||||
#include <string>
|
||||
#include "raylib-cpp.hpp"
|
||||
|
||||
int main() {
|
||||
// Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
const int screenWidth = 800;
|
||||
const int screenHeight = 450;
|
||||
|
||||
raylib::Window window(screenWidth, screenHeight, "raylib [text] example - font loading");
|
||||
|
||||
// Define characters to draw
|
||||
// NOTE: raylib supports UTF-8 encoding, following list is actually codified as UTF8 internally
|
||||
std::string msg = "!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHI\nJKLMNOPQRSTUVWXYZ[]^_`abcdefghijklmn\nopqrstuvwxyz{|}~¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓ\nÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷\nøùúûüýþÿ";
|
||||
|
||||
// NOTE: Textures/Fonts MUST be loaded after Window initialization (OpenGL context is required)
|
||||
|
||||
// BMFont (AngelCode) : Font data and image atlas have been generated using external program
|
||||
raylib::Font fontBm("resources/pixantiqua.fnt");
|
||||
|
||||
// TTF font : Font data and atlas are generated directly from TTF
|
||||
// NOTE: We define a font base size of 32 pixels tall and up-to 250 characters
|
||||
raylib::Font fontTtf("resources/pixantiqua.ttf", 32, 0, 250);
|
||||
|
||||
bool useTtf = false;
|
||||
|
||||
window.SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
// Main game loop
|
||||
while (!window.ShouldClose()) { // Detect window close button or ESC key
|
||||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
if (IsKeyDown(KEY_SPACE)) useTtf = true;
|
||||
else useTtf = false;
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
//----------------------------------------------------------------------------------
|
||||
window.BeginDrawing();
|
||||
{
|
||||
|
||||
window.ClearBackground(RAYWHITE);
|
||||
|
||||
raylib::DrawText("Hold SPACE to use TTF generated font", 20, 20, 20, LIGHTGRAY);
|
||||
|
||||
if (!useTtf)
|
||||
{
|
||||
fontBm.DrawText(msg, Vector2{ 20.0f, 100.0f }, fontBm.baseSize, 2, MAROON);
|
||||
raylib::DrawText("Using BMFont (Angelcode) imported", 20, GetScreenHeight() - 30, 20, GRAY);
|
||||
}
|
||||
else
|
||||
{
|
||||
fontTtf.DrawText(msg, Vector2{ 20.0f, 100.0f }, fontTtf.baseSize, 2, LIME);
|
||||
raylib::DrawText("Using TTF font generated", 20, GetScreenHeight() - 30, 20, GRAY);
|
||||
}
|
||||
}
|
||||
window.EndDrawing();
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
/*******************************************************************************************
|
||||
*
|
||||
* raylib [text] example - Font loading and usage
|
||||
*
|
||||
* This example has been created using raylib 1.0 (www.raylib.com)
|
||||
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
||||
*
|
||||
* Copyright (c) 2014 Ramon Santamaria (@raysan5)
|
||||
*
|
||||
********************************************************************************************/
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "raylib-cpp.hpp"
|
||||
|
||||
int main(void)
|
||||
{
|
||||
// Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
const int screenWidth = 800;
|
||||
const int screenHeight = 450;
|
||||
|
||||
raylib::Window window(screenWidth, screenHeight, "raylib [text] example - sprite fonts usage");
|
||||
|
||||
std::string msg1 = "THIS IS A custom SPRITE FONT...";
|
||||
std::string msg2 = "...and this is ANOTHER CUSTOM font...";
|
||||
std::string msg3 = "...and a THIRD one! GREAT! :D";
|
||||
|
||||
// NOTE: Textures/Fonts MUST be loaded after Window initialization (OpenGL context is required)
|
||||
raylib::Font font1("resources/custom_mecha.png"); // Font loading
|
||||
raylib::Font font2("resources/custom_alagard.png"); // Font loading
|
||||
raylib::Font font3("resources/custom_jupiter_crash.png"); // Font loading
|
||||
|
||||
raylib::Vector2 fontPosition1(screenWidth/2 - MeasureTextEx(font1, msg1.c_str(), font1.baseSize, -3).x/2,
|
||||
screenHeight/2 - font1.baseSize/2 - 80);
|
||||
|
||||
raylib::Vector2 fontPosition2(screenWidth/2 - MeasureTextEx(font2, msg2.c_str(), font2.baseSize, -2).x/2,
|
||||
screenHeight/2 - font2.baseSize/2 - 10);
|
||||
|
||||
raylib::Vector2 fontPosition3(screenWidth/2 - MeasureTextEx(font3, msg3.c_str(), font3.baseSize, 2).x/2,
|
||||
screenHeight/2 - font3.baseSize/2 + 50);
|
||||
|
||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
// Main game loop
|
||||
while (!window.ShouldClose()) { // Detect window close button or ESC key
|
||||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
// TODO: Update variables here...
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
//----------------------------------------------------------------------------------
|
||||
BeginDrawing();
|
||||
{
|
||||
window.ClearBackground(RAYWHITE);
|
||||
|
||||
font1.DrawText(msg1, fontPosition1, font1.baseSize, -3);
|
||||
font2.DrawText(msg2, fontPosition2, font2.baseSize, -2);
|
||||
font3.DrawText(msg3, fontPosition3, font3.baseSize, 2);
|
||||
}
|
||||
EndDrawing();
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
/*******************************************************************************************
|
||||
*
|
||||
* raylib [text] example - raylib font loading and usage
|
||||
*
|
||||
* NOTE: raylib is distributed with some free to use fonts (even for commercial pourposes!)
|
||||
* To view details and credits for those fonts, check raylib license file
|
||||
*
|
||||
* This example has been created using raylib 1.7 (www.raylib.com)
|
||||
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
||||
*
|
||||
* Copyright (c) 2017 Ramon Santamaria (@raysan5)
|
||||
*
|
||||
********************************************************************************************/
|
||||
|
||||
#include <vector>
|
||||
#include <array>
|
||||
|
||||
#include "raylib-cpp.hpp"
|
||||
|
||||
#define MAX_FONTS 8
|
||||
|
||||
int main() {
|
||||
// Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
int screenWidth = 800;
|
||||
int screenHeight = 450;
|
||||
|
||||
raylib::Window window(screenWidth, screenHeight, "raylib [text] example - raylib fonts");
|
||||
raylib::Color textColor = DARKGRAY;
|
||||
|
||||
// NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required)
|
||||
std::array<raylib::Font, MAX_FONTS> fonts = {
|
||||
raylib::Font("resources/fonts/alagard.png"),
|
||||
raylib::Font("resources/fonts/pixelplay.png"),
|
||||
raylib::Font("resources/fonts/mecha.png"),
|
||||
raylib::Font("resources/fonts/setback.png"),
|
||||
raylib::Font("resources/fonts/romulus.png"),
|
||||
raylib::Font("resources/fonts/pixantiqua.png"),
|
||||
raylib::Font("resources/fonts/alpha_beta.png"),
|
||||
raylib::Font("resources/fonts/jupiter_crash.png")
|
||||
};
|
||||
|
||||
std::array<std::string, MAX_FONTS> messages = {
|
||||
"ALAGARD FONT designed by Hewett Tsoi",
|
||||
"PIXELPLAY FONT designed by Aleksander Shevchuk",
|
||||
"MECHA FONT designed by Captain Falcon",
|
||||
"SETBACK FONT designed by Brian Kent (AEnigma)",
|
||||
"ROMULUS FONT designed by Hewett Tsoi",
|
||||
"PIXANTIQUA FONT designed by Gerhard Grossmann",
|
||||
"ALPHA_BETA FONT designed by Brian Kent (AEnigma)",
|
||||
"JUPITER_CRASH FONT designed by Brian Kent (AEnigma)"
|
||||
};
|
||||
|
||||
std::array<int, MAX_FONTS> spacings = { 2, 4, 8, 4, 3, 4, 4, 1 };
|
||||
|
||||
std::array<raylib::Vector2, MAX_FONTS> positions;
|
||||
|
||||
for (int i = 0; i < fonts.size(); i++)
|
||||
{
|
||||
auto size = fonts[i].MeasureText(messages[i], fonts[i].baseSize * 2, spacings[i]);
|
||||
positions[i].x = screenWidth/2 - size.x/2;
|
||||
positions[i].y = 60 + fonts[i].baseSize + 45*i;
|
||||
}
|
||||
|
||||
// Small Y position corrections
|
||||
positions[3].y += 8;
|
||||
positions[4].y += 2;
|
||||
positions[7].y -= 8;
|
||||
|
||||
std::array<raylib::Color, MAX_FONTS> colors = { MAROON, ORANGE, DARKGREEN, DARKBLUE, DARKPURPLE, LIME, GOLD, RED };
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
// Main game loop
|
||||
while (!window.ShouldClose()) { // Detect window close button or ESC key
|
||||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
// Update your variables here
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
//----------------------------------------------------------------------------------
|
||||
BeginDrawing();
|
||||
{
|
||||
window.ClearBackground(RAYWHITE);
|
||||
|
||||
textColor.DrawText("free fonts included with raylib", 250, 20, 20);
|
||||
textColor.DrawLine(220, 50, 590, 50);
|
||||
|
||||
for (int i = 0; i < fonts.size(); i++)
|
||||
{
|
||||
fonts[i].DrawText(messages[i], positions[i], fonts[i].baseSize*2, spacings[i], colors[i]);
|
||||
}
|
||||
}
|
||||
EndDrawing();
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
Art used in examples is provided under a free and permissive license.
|
||||
Check individual licenses for details:
|
||||
|
||||
- [Jupiter Crash] font by Brian Kent (AEnigma) - https://www.dafont.com/es/jupiter-crash.font
|
||||
- [Kaiserzeit Gotisch] font by Dieter Steffmann - https://www.dafont.com/es/kaiserzeit-gotisch.font
|
||||
- [Scarfy spritesheet](scarfy.png) by [Eiden Marsal](https://www.artstation.com/artist/marshall_z), licensed as [Creative Commons Attribution-NonCommercial 3.0](https://creativecommons.org/licenses/by-nc/3.0/legalcode)
|
||||
- [Fudesumi image](fudesumi.png) by [Eiden Marsal](https://www.artstation.com/artist/marshall_z), licensed as [Creative Commons Attribution-NonCommercial 3.0](https://creativecommons.org/licenses/by-nc/3.0/legalcode)
|
||||
- [Cyberpunk Street Environment](https://ansimuz.itch.io/cyberpunk-street-environment) by Luis Zuno ([@ansimuz](https://twitter.com/ansimuz)), licensed as [CC-BY-3.0](http://creativecommons.org/licenses/by/3.0/)
|
||||
|
After Width: | Height: | Size: 23 KiB |
|
After Width: | Height: | Size: 379 KiB |
|
After Width: | Height: | Size: 28 KiB |
|
After Width: | Height: | Size: 7.6 KiB |
|
After Width: | Height: | Size: 18 KiB |
|
After Width: | Height: | Size: 7.6 KiB |
|
After Width: | Height: | Size: 811 KiB |
|
After Width: | Height: | Size: 217 KiB |
|
After Width: | Height: | Size: 5.8 KiB |
|
After Width: | Height: | Size: 288 KiB |
|
After Width: | Height: | Size: 7.2 KiB |
|
After Width: | Height: | Size: 3.6 KiB |
|
After Width: | Height: | Size: 10 KiB |
|
After Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 7.4 KiB |
|
After Width: | Height: | Size: 496 B |
@@ -0,0 +1,109 @@
|
||||
/*******************************************************************************************
|
||||
*
|
||||
* raylib [textures] example - Bunnymark
|
||||
*
|
||||
* This example has been created using raylib 1.6 (www.raylib.com)
|
||||
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
||||
*
|
||||
* Copyright (c) 2014-2019 Ramon Santamaria (@raysan5)
|
||||
*
|
||||
********************************************************************************************/
|
||||
|
||||
#include <list>
|
||||
|
||||
#include "raylib-cpp.hpp"
|
||||
|
||||
// This is the maximum amount of elements (quads) per batch
|
||||
// NOTE: This value is defined in [rlgl] module and can be changed there
|
||||
#define MAX_BATCH_ELEMENTS 8192
|
||||
|
||||
class Bunny {
|
||||
public:
|
||||
Bunny() {
|
||||
position = GetMousePosition();
|
||||
speed.x = static_cast<float>(GetRandomValue(-250, 250)) / 60.0f;
|
||||
speed.y = static_cast<float>(GetRandomValue(-250, 250)) / 60.0f;
|
||||
color = raylib::Color(
|
||||
GetRandomValue(50, 240),
|
||||
GetRandomValue(80, 240),
|
||||
GetRandomValue(100, 240));
|
||||
}
|
||||
|
||||
void Update(const raylib::Texture2D& texBunny) {
|
||||
position.x += speed.x;
|
||||
position.y += speed.y;
|
||||
|
||||
if (((position.x + texBunny.width/2) > GetScreenWidth()) ||
|
||||
((position.x + texBunny.width/2) < 0)) speed.x *= -1;
|
||||
if (((position.y + texBunny.height/2) > GetScreenHeight()) ||
|
||||
((position.y + texBunny.height/2 - 40) < 0)) speed.y *= -1;
|
||||
}
|
||||
|
||||
Vector2 position;
|
||||
Vector2 speed;
|
||||
Color color;
|
||||
};
|
||||
|
||||
int main(void)
|
||||
{
|
||||
// Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
const int screenWidth = 800;
|
||||
const int screenHeight = 450;
|
||||
|
||||
raylib::Window window(screenWidth, screenHeight, "raylib [textures] example - bunnymark");
|
||||
|
||||
// Load bunny texture
|
||||
raylib::Texture2D texBunny("resources/wabbit_alpha.png");
|
||||
|
||||
std::list<Bunny> bunnies;
|
||||
|
||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
// Main game loop
|
||||
while (!window.ShouldClose()) { // Detect window close button or ESC key
|
||||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
if (IsMouseButtonDown(MOUSE_LEFT_BUTTON)) {
|
||||
// Create more bunnies
|
||||
for (int i = 0; i < 100; i++) {
|
||||
bunnies.emplace_back();
|
||||
}
|
||||
}
|
||||
|
||||
// Update bunnies
|
||||
|
||||
for (Bunny& bunny: bunnies) {
|
||||
bunny.Update(texBunny);
|
||||
}
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
//----------------------------------------------------------------------------------
|
||||
BeginDrawing();
|
||||
{
|
||||
window.ClearBackground(RAYWHITE);
|
||||
|
||||
for (Bunny& bunny : bunnies) {
|
||||
// NOTE: When internal batch buffer limit is reached (MAX_BATCH_ELEMENTS),
|
||||
// a draw call is launched and buffer starts being filled again;
|
||||
// before issuing a draw call, updated vertex data from internal CPU buffer is send to GPU...
|
||||
// Process of sending data is costly and it could happen that GPU data has not been completely
|
||||
// processed for drawing while new data is tried to be sent (updating current in-use buffers)
|
||||
// it could generates a stall and consequently a frame drop, limiting the number of drawn bunnies
|
||||
texBunny.Draw(bunny.position, bunny.color);
|
||||
}
|
||||
|
||||
DrawRectangle(0, 0, screenWidth, 40, BLACK);
|
||||
raylib::DrawText(TextFormat("bunnies: %i", bunnies.size()), 120, 10, 20, GREEN);
|
||||
raylib::DrawText(TextFormat("batched draw calls: %i", 1 + bunnies.size()/MAX_BATCH_ELEMENTS), 320, 10, 20, MAROON);
|
||||
|
||||
DrawFPS(10, 10);
|
||||
}
|
||||
EndDrawing();
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
/*******************************************************************************************
|
||||
*
|
||||
* raylib [textures] example - Image loading and drawing on it
|
||||
*
|
||||
* NOTE: Images are loaded in CPU memory (RAM); textures are loaded in GPU memory (VRAM)
|
||||
*
|
||||
* This example has been created using raylib 1.4 (www.raylib.com)
|
||||
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
||||
*
|
||||
* Copyright (c) 2016 Ramon Santamaria (@raysan5)
|
||||
*
|
||||
********************************************************************************************/
|
||||
|
||||
#include "raylib-cpp.hpp"
|
||||
|
||||
int main(void) {
|
||||
// Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
const int screenWidth = 800;
|
||||
const int screenHeight = 450;
|
||||
|
||||
raylib::Window window(screenWidth, screenHeight, "raylib [textures] example - image drawing");
|
||||
raylib::Color darkGray = DARKGRAY;
|
||||
|
||||
// NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required)
|
||||
raylib::Image cat("resources/cat.png"); // Load image in CPU memory (RAM)
|
||||
cat.Crop(raylib::Rectangle(100, 10, 280, 380)) // Crop an image piece
|
||||
.FlipHorizontal() // Flip cropped image horizontally
|
||||
.Resize(150, 200); // Resize flipped-cropped image
|
||||
|
||||
raylib::Image parrots("resources/parrots.png"); // Load image in CPU memory (RAM)
|
||||
|
||||
// Draw one image over the other with a scaling of 1.5f
|
||||
parrots
|
||||
.Draw(cat,
|
||||
raylib::Rectangle(0, 0, cat.GetWidth(), cat.GetHeight()),
|
||||
raylib::Rectangle(30, 40, cat.GetWidth() * 1.5f, cat.GetHeight() * 1.5f));
|
||||
parrots.Crop(raylib::Rectangle(0, 50, parrots.GetWidth(), parrots.GetHeight() - 100)); // Crop resulting image
|
||||
|
||||
// Load custom font for frawing on image
|
||||
raylib::Font font("resources/custom_jupiter_crash.png");
|
||||
|
||||
// Draw over image using custom font
|
||||
parrots.DrawText(font, "PARROTS & CAT", raylib::Vector2(300, 230), font.baseSize, -2);
|
||||
|
||||
raylib::Texture2D texture(parrots); // Image converted to texture, uploaded to GPU memory (VRAM)
|
||||
|
||||
SetTargetFPS(60);
|
||||
//---------------------------------------------------------------------------------------
|
||||
|
||||
// Main game loop
|
||||
while (!window.ShouldClose()) { // Detect window close button or ESC key
|
||||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
// Update your variables here
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
//----------------------------------------------------------------------------------
|
||||
BeginDrawing();
|
||||
{
|
||||
window.ClearBackground(RAYWHITE);
|
||||
|
||||
texture.Draw(screenWidth / 2 - texture.width / 2,
|
||||
screenHeight / 2 - texture.height / 2 - 40);
|
||||
darkGray.DrawRectangleLines(screenWidth / 2 - texture.width / 2,
|
||||
screenHeight / 2 - texture.height / 2 - 40,
|
||||
texture.width, texture.height);
|
||||
|
||||
darkGray.DrawText("We are drawing only one texture from various images composed!",
|
||||
240, 350, 10);
|
||||
darkGray.DrawText("Source images have been cropped, scaled, flipped and copied one over the other.",
|
||||
190, 370, 10);
|
||||
}
|
||||
EndDrawing();
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
/*******************************************************************************************
|
||||
*
|
||||
* 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-cpp.hpp"
|
||||
|
||||
int main() {
|
||||
// Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
int screenWidth = 800;
|
||||
int screenHeight = 450;
|
||||
|
||||
raylib::Window window(screenWidth, screenHeight, "raylib [textures] example - image loading");
|
||||
raylib::Texture texture("resources/raylib_logo.png");
|
||||
raylib::Color textColor = raylib::Color::LightGray();
|
||||
|
||||
// Main game loop
|
||||
while (!window.ShouldClose()) { // Detect window close button or ESC key
|
||||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
// Update your variables here
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
//----------------------------------------------------------------------------------
|
||||
BeginDrawing();
|
||||
{
|
||||
window.ClearBackground(raylib::Color::RayWhite());
|
||||
|
||||
texture.Draw(screenWidth / 2 - texture.GetWidth() / 2, screenHeight / 2 - texture.GetHeight() / 2);
|
||||
|
||||
textColor.DrawText("this IS a texture loaded from an image!", 300, 370, 10);
|
||||
}
|
||||
EndDrawing();
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||