Merge pull request #262 from raysan5/develop

Integrate develop branch
This commit is contained in:
Ray
2017-04-20 00:21:38 +02:00
committed by GitHub
613 changed files with 399169 additions and 485140 deletions

5
.gitignore vendored
View File

@@ -42,6 +42,7 @@ Thumbs.db
*.sbr
*.sdf
obj/
[Rr]elease/
[Rr]elease.win32/
_ReSharper*/
[Tt]est[Rr]esult*
@@ -109,3 +110,7 @@ project/vs2015/*.opendb
!project/vs2015/external/openal_soft/lib/win64/OpenAL32.dll
!project/vs2015/external/lua/lib/win32/lua53.dll
# Web examples
docs/examples/web/*.html
docs/examples/web/*/*.html
!docs/examples/web/loader.html

View File

@@ -20,109 +20,54 @@ $(document).ready(function() {
'core_3d_camera_first_person',
'core_2d_camera',
'core_world_screen',
'core_oculus_rift',
'core_vr_simulator',
'shapes_logo_raylib',
'shapes_basic_shapes',
'shapes_colors_palette',
'shapes_logo_raylib_anim',
'shapes_lines_bezier',
'textures_logo_raylib',
'textures_image_loading',
'textures_rectangle',
'textures_srcrec_dstrec',
'textures_to_image',
'textures_raw_data',
'textures_formats_loading',
'textures_particles_trail_blending',
'textures_image_processing',
'textures_image_drawing',
'text_sprite_fonts',
'text_bmfont_ttf',
'text_rbmf_fonts',
'text_raylib_fonts',
'text_format_text',
'text_font_select',
'text_writing_anim',
'text_ttf_loading',
'text_bmfont_unordered',
'text_input_box',
'models_geometric_shapes',
'models_box_collisions',
'models_billboard',
'models_obj_loading',
'models_heightmap',
'models_cubicmap',
'models_mesh_picking',
'shaders_model_shader',
'shaders_shapes_textures',
'shaders_custom_uniform',
'shaders_postprocessing',
'shaders_standard_lighting',
'audio_sound_loading',
'audio_music_stream',
'audio_module_playing',
'audio_raw_stream'];
var exampleDesc = [
'basic window',
'input keys',
'input mouse',
'mouse wheel',
'input gamepad',
'random values',
'color select',
'drop files',
'storage values',
'gestures detection',
'3d mode',
'3d picking',
'3d camera free',
'3d camera first person',
'2d camera',
'world screen',
'oculus rift',
'logo raylib shapes',
'basic shapes',
'colors palette',
'logo raylib anim',
'logo raylib texture',
'image loading',
'texture rectangle',
'src-dest. rectangles',
'texture to image',
'raw data loading',
'textures formats loading',
'particles trail blending',
'image processing',
'image drawing',
'sprite fonts',
'bmfonts ttf',
'rbmf fonts',
'text formatting',
'font selection',
'writing animation',
'ttf loading',
'bmfont unordered',
'geometric shapes',
'box collisions',
'billboard drawing',
'obj loading',
'heightmap loading',
'cubesmap loading',
'model shader',
'shapes textures shader',
'custom uniform in shaders',
'postprocessing shaders',
'standard lighting',
'sound loading',
'music streaming',
'module playing',
'raw stream'];
for (var i = 0; i < exampleName.length; i++)
{
var filterType = exampleName[i].substring(0, exampleName[i].indexOf("_"));
var exampleBase = exampleName[i].slice(exampleName[i].indexOf('_') + 1);
var exampleDesc = exampleBase.replace('_', ' ');
$('#container').append(
'<div class="mix f' + filterType + '">' +
'<a class="fancybox fancybox.iframe" href="examples/web/loader.html?name=' + exampleName[i] + '" title="' + exampleDesc[i] + '">' +
'<img width="400" height="225" src="../examples/img/' + exampleName[i] + '.png"><div class="extext"><p>' + exampleDesc[i] + '</p></div></a>' +
'<a class="fancybox fancybox.iframe" href="examples/web/' + filterType + '/' + 'loader.html?name=' + exampleName[i] + '" title="' + exampleDesc + '">' +
'<img width="400" height="225" src="../examples/web/' + filterType + '/' + exampleName[i] + '.png"><div class="extext"><p>' + exampleDesc + '</p></div></a>' +
'</div>');
$('#container a .extext').hide();

View File

@@ -16,7 +16,6 @@ $(document).ready(function() {
'sample_tetris',
'sample_gold_fever',
'sample_doom',
'game_raylib_features',
'game_drturtle',
'game_just_do',
'game_skully_escape',
@@ -42,7 +41,6 @@ $(document).ready(function() {
'tetris',
'gold fever',
'doom',
'raylib Features DEMO',
'Dr Turtle & Mr Gamera',
'JUST DO',
'Skully Escape',
@@ -83,8 +81,6 @@ $(document).ready(function() {
*/
}
if (exampleName[i] == 'game_koala_seasons') linkTag = '<a target="_blank" href="http://www.koalaseasons.com" title="' + exampleDesc[i] + '">';
$('#container').append(
'<div class="mix f' + filterType + '">' + linkTag +
'<img width="400" height="225" src="../games/img/' + exampleName[i] + '.png"><div class="extext"><p>' + exampleDesc[i] + '</p></div></a>' +

Binary file not shown.

Before

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 173 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 54 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 403 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 95 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 125 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 252 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 139 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 232 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 108 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 246 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 123 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 85 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 107 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 46 KiB

View File

@@ -52,7 +52,7 @@ int main()
circles[i].color = colors[GetRandomValue(0, 13)];
}
Music xm = LoadMusicStream("resources/audio/mini1111.xm");
Music xm = LoadMusicStream("resources/mini1111.xm");
PlayMusicStream(xm);
@@ -86,7 +86,7 @@ int main()
}
// Get timePlayed scaled to bar dimensions
timePlayed = (GetMusicTimePlayed(xm)/GetMusicTimeLength(xm)*(screenWidth - 40))*2;
timePlayed = GetMusicTimePlayed(xm)/GetMusicTimeLength(xm)*(screenWidth - 40);
// Color circles animation
for (int i = MAX_CIRCLES - 1; (i >= 0) && !pause; i--)
@@ -112,7 +112,7 @@ int main()
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(WHITE);
ClearBackground(RAYWHITE);
for (int i = MAX_CIRCLES - 1; i >= 0; i--)
{

View File

@@ -24,7 +24,7 @@ int main()
InitAudioDevice(); // Initialize audio device
Music music = LoadMusicStream("resources/audio/guitar_noodling.ogg");
Music music = LoadMusicStream("resources/guitar_noodling.ogg");
PlayMusicStream(music);
@@ -58,7 +58,7 @@ int main()
}
// Get timePlayed scaled to bar dimensions (400 pixels)
timePlayed = GetMusicTimePlayed(music)/GetMusicTimeLength(music)*100*4;
timePlayed = GetMusicTimePlayed(music)/GetMusicTimeLength(music)*400;
//----------------------------------------------------------------------------------
// Draw

View File

@@ -24,8 +24,8 @@ int main()
InitAudioDevice(); // Initialize audio device
Sound fxWav = LoadSound("resources/audio/weird.wav"); // Load WAV audio file
Sound fxOgg = LoadSound("resources/audio/tanatana.ogg"); // Load OGG audio file
Sound fxWav = LoadSound("resources/sound.wav"); // Load WAV audio file
Sound fxOgg = LoadSound("resources/tanatana.ogg"); // Load OGG audio file
SetTargetFPS(60);
//--------------------------------------------------------------------------------------

View File

@@ -1,111 +0,0 @@
/*******************************************************************************************
*
* raylib [audio] example - Raw audio streaming
*
* NOTE: This example requires OpenAL Soft library installed
*
* 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) 2015 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
#include "raylib.h"
#include <stdlib.h> // Required for: malloc(), free()
#include <math.h> // Required for: sinf()
#define MAX_SAMPLES 20000
int main()
{
// Initialization
//--------------------------------------------------------------------------------------
int screenWidth = 800;
int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [audio] example - raw audio streaming");
InitAudioDevice(); // Initialize audio device
// Init raw audio stream (sample rate: 22050, sample size: 32bit-float, channels: 1-mono)
AudioStream stream = InitAudioStream(22050, 32, 1);
// Fill audio stream with some samples (sine wave)
float *data = (float *)malloc(sizeof(float)*MAX_SAMPLES);
for (int i = 0; i < MAX_SAMPLES; i++)
{
data[i] = sinf(((2*PI*(float)i)/2)*DEG2RAD);
}
// NOTE: The generated MAX_SAMPLES do not fit to close a perfect loop
// for that reason, there is a clip everytime audio stream is looped
PlayAudioStream(stream);
int totalSamples = MAX_SAMPLES;
int samplesLeft = totalSamples;
Vector2 position = { 0, 0 };
SetTargetFPS(30); // Set our game to run at 30 frames-per-second
//--------------------------------------------------------------------------------------
// Main game loop
while (!WindowShouldClose()) // Detect window close button or ESC key
{
// Update
//----------------------------------------------------------------------------------
// Refill audio stream if required
if (IsAudioBufferProcessed(stream))
{
int numSamples = 0;
if (samplesLeft >= 4096) numSamples = 4096;
else numSamples = samplesLeft;
UpdateAudioStream(stream, data + (totalSamples - samplesLeft), numSamples);
samplesLeft -= numSamples;
// Reset samples feeding (loop audio)
if (samplesLeft <= 0) samplesLeft = totalSamples;
}
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(RAYWHITE);
DrawText("SINE WAVE SHOULD BE PLAYING!", 240, 140, 20, LIGHTGRAY);
// NOTE: Draw a part of the sine wave (only screen width)
for (int i = 0; i < GetScreenWidth(); i++)
{
position.x = i;
position.y = 250 + 50*data[i];
DrawPixelV(position, RED);
}
EndDrawing();
//----------------------------------------------------------------------------------
}
// De-Initialization
//--------------------------------------------------------------------------------------
free(data); // Unload sine wave data
CloseAudioStream(stream); // Close raw audio stream and delete buffers from RAM
CloseAudioDevice(); // Close audio device (music streaming is automatically stopped)
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
return 0;
}

View File

@@ -4,8 +4,8 @@
*
* NOTE: This example requires a Gamepad connected to the system
* raylib is configured to work with the following gamepads:
* Xbox 360 Controller (Xbox 360, Xbox One)
* PLAYSTATION(R)3 Controller
* - Xbox 360 Controller (Xbox 360, Xbox One)
* - PLAYSTATION(R)3 Controller
* Check raylib.h for buttons configuration
*
* This example has been created using raylib 1.6 (www.raylib.com)

View File

@@ -1,14 +1,11 @@
/*******************************************************************************************
*
* raylib [core] example - Oculus Rift CV1
* raylib [core] example - VR Simulator (Oculus Rift CV1 parameters)
*
* Compile example using:
* gcc -o $(NAME_PART).exe $(FILE_NAME) -L. -L..\src\external\OculusSDK\LibOVR -lLibOVRRT32_1 -lraylib -lglfw3 -lopengl32 -lgdi32 -std=c99
*
* This example has been created using raylib 1.5 (www.raylib.com)
* 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) 2016 Ramon Santamaria (@raysan5)
* Copyright (c) 2017 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
@@ -23,10 +20,9 @@ int main()
// NOTE: screenWidth/screenHeight should match VR device aspect ratio
InitWindow(screenWidth, screenHeight, "raylib [core] example - oculus rift");
// NOTE: If device is not available, it fallbacks to default device (simulator)
InitVrDevice(HMD_OCULUS_RIFT_CV1); // Init VR device (Oculus Rift CV1)
InitWindow(screenWidth, screenHeight, "raylib [core] example - vr simulator");
InitVrSimulator(HMD_OCULUS_RIFT_CV1); // Init VR simulator (Oculus Rift CV1 parameters)
// Define the camera to look into our 3d world
Camera camera;
@@ -47,10 +43,9 @@ int main()
{
// Update
//----------------------------------------------------------------------------------
if (IsVrSimulator()) UpdateCamera(&camera); // Update camera (simulator mode)
else if (IsVrDeviceReady()) UpdateVrTracking(&camera); // Update camera with device tracking data
if (IsKeyPressed(KEY_SPACE)) ToggleVrMode(); // Toggle VR mode
UpdateCamera(&camera); // Update camera (simulator mode)
if (IsKeyPressed(KEY_SPACE)) ToggleVrMode(); // Toggle VR mode
//----------------------------------------------------------------------------------
// Draw
@@ -58,15 +53,19 @@ int main()
BeginDrawing();
ClearBackground(RAYWHITE);
BeginVrDrawing();
Begin3dMode(camera);
Begin3dMode(camera);
DrawCube(cubePosition, 2.0f, 2.0f, 2.0f, RED);
DrawCubeWires(cubePosition, 2.0f, 2.0f, 2.0f, MAROON);
DrawCube(cubePosition, 2.0f, 2.0f, 2.0f, RED);
DrawCubeWires(cubePosition, 2.0f, 2.0f, 2.0f, MAROON);
DrawGrid(40, 1.0f);
DrawGrid(40, 1.0f);
End3dMode();
End3dMode();
EndVrDrawing();
DrawFPS(10, 10);
@@ -76,10 +75,10 @@ int main()
// De-Initialization
//--------------------------------------------------------------------------------------
CloseVrDevice(); // Close VR device
CloseVrSimulator(); // Close VR simulator
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
return 0;
}
}

View File

@@ -1,6 +1,6 @@
/*******************************************************************************************
*
* raylib [models] example - Ray picking in 3d mode, ground plane, triangle, mesh
* raylib [models] example - Mesh picking in 3d mode, ground plane, triangle, mesh
*
* 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)
@@ -11,11 +11,9 @@
********************************************************************************************/
#include "raylib.h"
#include "../src/raymath.h"
#include <stdio.h>
#include <float.h>
#include "raymath.h"
#define FLT_MAX 3.40282347E+38F // Maximum value of a float, defined in <float.h>
int main()
{
@@ -24,23 +22,23 @@ int main()
int screenWidth = 800;
int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [models] example - 3d ray picking");
InitWindow(screenWidth, screenHeight, "raylib [models] example - mesh picking");
// Define the camera to look into our 3d world
Camera camera;
camera.position = (Vector3){ 10.0f, 8.0f, 10.0f }; // Camera position
camera.position = (Vector3){ 10.0f, 8.0f, 10.0f }; // Camera position
camera.target = (Vector3){ 0.0f, 2.3f, 0.0f }; // Camera looking at point
camera.up = (Vector3){ 0.0f, 1.6f, 0.0f }; // Camera up vector (rotation towards target)
camera.fovy = 45.0f; // Camera field-of-view Y
Ray ray; // Picking line ray
Ray ray; // Picking ray
Model tower = LoadModel("resources/model/lowpoly-tower.obj"); // Load OBJ model
Texture2D texture = LoadTexture("resources/model/lowpoly-tower.png"); // Load model texture
tower.material.texDiffuse = texture; // Set model diffuse texture
Model tower = LoadModel("resources/tower.obj"); // Load OBJ model
Texture2D texture = LoadTexture("resources/tower.png"); // Load model texture
tower.material.texDiffuse = texture; // Set model diffuse texture
Vector3 towerPos = { 0.0f, 0.0f, 0.0f }; // Set model position
BoundingBox towerBBox = CalculateBoundingBox( tower.mesh );
Vector3 towerPos = { 0.0f, 0.0f, 0.0f }; // Set model position
BoundingBox towerBBox = CalculateBoundingBox(tower.mesh);
bool hitMeshBBox = false;
bool hitTriangle = false;
@@ -91,7 +89,7 @@ int main()
cursorColor = PURPLE;
hitObjectName = "Triangle";
bary = Barycenter(nearestHit.hitPosition, ta, tb, tc);
bary = VectorBarycenter(nearestHit.hitPosition, ta, tb, tc);
hitTriangle = true;
}
else hitTriangle = false;
@@ -138,15 +136,15 @@ int main()
// If we hit something, draw the cursor at the hit point
if (nearestHit.hit)
{
DrawCube(nearestHit.hitPosition, 0.5, 0.5, 0.5, cursorColor);
DrawCubeWires(nearestHit.hitPosition, 0.5, 0.5, 0.5, YELLOW);
DrawCube(nearestHit.hitPosition, 0.3, 0.3, 0.3, cursorColor);
DrawCubeWires(nearestHit.hitPosition, 0.3, 0.3, 0.3, RED);
Vector3 normalEnd;
normalEnd.x = nearestHit.hitPosition.x + nearestHit.hitNormal.x;
normalEnd.y = nearestHit.hitPosition.y + nearestHit.hitNormal.y;
normalEnd.z = nearestHit.hitPosition.z + nearestHit.hitNormal.z;
DrawLine3D(nearestHit.hitPosition, normalEnd, YELLOW);
DrawLine3D(nearestHit.hitPosition, normalEnd, RED);
}
DrawRay(ray, MAROON);
@@ -187,7 +185,10 @@ int main()
// De-Initialization
//--------------------------------------------------------------------------------------
CloseWindow(); // Close window and OpenGL context
UnloadModel(tower); // Unload model
UnloadTexture(texture); // Unload texture
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
return 0;

View File

@@ -2,17 +2,22 @@
*
* Physac - Physics demo
*
* NOTE: Physac requires multi-threading, when InitPhysics() a second thread is created to manage physics calculations.
* The file pthreadGC2.dll is required to run the program; you can find it in 'src\external'
* NOTE 1: Physac requires multi-threading, when InitPhysics() a second thread is created to manage physics calculations.
* NOTE 2: Physac requires static C library linkage to avoid dependency on MinGW DLL (-static -lpthread)
*
* Copyright (c) 2016 Victor Fisac
* Use the following line to compile:
*
* gcc -o $(NAME_PART).exe $(FILE_NAME) -s $(RAYLIB_DIR)\raylib\raylib_icon -static -lraylib -lpthread
* -lglfw3 -lopengl32 -lgdi32 -lopenal32 -lwinmm -std=c99 -Wl,--subsystem,windows -Wl,-allow-multiple-definition
*
* Copyright (c) 2017 Victor Fisac
*
********************************************************************************************/
#include "raylib.h"
#define PHYSAC_IMPLEMENTATION
#include "..\src\physac.h"
#include "physac.h"
int main()
{
@@ -114,9 +119,10 @@ int main()
// De-Initialization
//--------------------------------------------------------------------------------------
ClosePhysics(); // Unitialize physics
ClosePhysics(); // Uninitialize physics
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
return 0;
}

View File

@@ -2,17 +2,22 @@
*
* Physac - Physics friction
*
* NOTE: Physac requires multi-threading, when InitPhysics() a second thread is created to manage physics calculations.
* The file pthreadGC2.dll is required to run the program; you can find it in 'src\external'
* NOTE 1: Physac requires multi-threading, when InitPhysics() a second thread is created to manage physics calculations.
* NOTE 2: Physac requires static C library linkage to avoid dependency on MinGW DLL (-static -lpthread)
*
* Copyright (c) 2016 Victor Fisac
* Use the following line to compile:
*
* gcc -o $(NAME_PART).exe $(FILE_NAME) -s $(RAYLIB_DIR)\raylib\raylib_icon -static -lraylib -lpthread
* -lglfw3 -lopengl32 -lgdi32 -lopenal32 -lwinmm -std=c99 -Wl,--subsystem,windows -Wl,-allow-multiple-definition
*
* Copyright (c) 2017 Victor Fisac
*
********************************************************************************************/
#include "raylib.h"
#define PHYSAC_IMPLEMENTATION
#include "..\src\physac.h"
#include "physac.h"
int main()
{
@@ -128,9 +133,11 @@ int main()
// De-Initialization
//--------------------------------------------------------------------------------------
ClosePhysics(); // Unitialize physics
ClosePhysics(); // Uninitialize physics
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
return 0;
}

View File

@@ -2,19 +2,24 @@
*
* Physac - Physics movement
*
* NOTE: Physac requires multi-threading, when InitPhysics() a second thread is created to manage physics calculations.
* The file pthreadGC2.dll is required to run the program; you can find it in 'src\external'
* NOTE 1: Physac requires multi-threading, when InitPhysics() a second thread is created to manage physics calculations.
* NOTE 2: Physac requires static C library linkage to avoid dependency on MinGW DLL (-static -lpthread)
*
* Copyright (c) 2016 Victor Fisac
* Use the following line to compile:
*
* gcc -o $(NAME_PART).exe $(FILE_NAME) -s $(RAYLIB_DIR)\raylib\raylib_icon -static -lraylib -lpthread
* -lglfw3 -lopengl32 -lgdi32 -lopenal32 -lwinmm -std=c99 -Wl,--subsystem,windows -Wl,-allow-multiple-definition
*
* Copyright (c) 2017 Victor Fisac
*
********************************************************************************************/
#include "raylib.h"
#define PHYSAC_IMPLEMENTATION
#include "..\src\physac.h"
#include "physac.h"
#define VELOCITY 0.5f
#define VELOCITY 0.5f
int main()
{
@@ -114,9 +119,11 @@ int main()
// De-Initialization
//--------------------------------------------------------------------------------------
ClosePhysics(); // Unitialize physics
ClosePhysics(); // Uninitialize physics
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
return 0;
}

View File

@@ -2,17 +2,22 @@
*
* Physac - Physics restitution
*
* NOTE: Physac requires multi-threading, when InitPhysics() a second thread is created to manage physics calculations.
* The file pthreadGC2.dll is required to run the program; you can find it in 'src\external'
* NOTE 1: Physac requires multi-threading, when InitPhysics() a second thread is created to manage physics calculations.
* NOTE 2: Physac requires static C library linkage to avoid dependency on MinGW DLL (-static -lpthread)
*
* Copyright (c) 2016 Victor Fisac
* Use the following line to compile:
*
* gcc -o $(NAME_PART).exe $(FILE_NAME) -s $(RAYLIB_DIR)\raylib\raylib_icon -static -lraylib -lpthread
* -lglfw3 -lopengl32 -lgdi32 -lopenal32 -lwinmm -std=c99 -Wl,--subsystem,windows -Wl,-allow-multiple-definition
*
* Copyright (c) 2017 Victor Fisac
*
********************************************************************************************/
#include "raylib.h"
#define PHYSAC_IMPLEMENTATION
#include "..\src\physac.h"
#include "physac.h"
int main()
{
@@ -107,9 +112,11 @@ int main()
// De-Initialization
//--------------------------------------------------------------------------------------
ClosePhysics(); // Unitialize physics
ClosePhysics(); // Uninitialize physics
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
return 0;
}

View File

@@ -2,17 +2,22 @@
*
* Physac - Body shatter
*
* NOTE: Physac requires multi-threading, when InitPhysics() a second thread is created to manage physics calculations.
* The file pthreadGC2.dll is required to run the program; you can find it in 'src\external'
* NOTE 1: Physac requires multi-threading, when InitPhysics() a second thread is created to manage physics calculations.
* NOTE 2: Physac requires static C library linkage to avoid dependency on MinGW DLL (-static -lpthread)
*
* Copyright (c) 2016 Victor Fisac
* Use the following line to compile:
*
* gcc -o $(NAME_PART).exe $(FILE_NAME) -s $(RAYLIB_DIR)\raylib\raylib_icon -static -lraylib -lpthread
* -lglfw3 -lopengl32 -lgdi32 -lopenal32 -lwinmm -std=c99 -Wl,--subsystem,windows -Wl,-allow-multiple-definition
*
* Copyright (c) 2017 Victor Fisac
*
********************************************************************************************/
#include "raylib.h"
#define PHYSAC_IMPLEMENTATION
#include "..\src\physac.h"
#include "physac.h"
int main()
{
@@ -99,9 +104,11 @@ int main()
// De-Initialization
//--------------------------------------------------------------------------------------
ClosePhysics(); // Unitialize physics
ClosePhysics(); // Uninitialize physics
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
return 0;
}

View File

@@ -9,7 +9,7 @@
* 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 1.3 (www.raylib.com)
* 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) 2015 Ramon Santamaria (@raysan5)
@@ -18,9 +18,6 @@
#include "raylib.h"
#include <stdio.h>
#include <stdlib.h>
int main()
{
// Initialization
@@ -30,14 +27,12 @@ int main()
InitWindow(screenWidth, screenHeight, "raylib [shaders] example - shapes and texture shaders");
Texture2D sonic = LoadTexture("resources/texture_formats/sonic.png");
Texture2D fudesumi = LoadTexture("resources/fudesumi.png");
// NOTE: Using GLSL 330 shader version, on OpenGL ES 2.0 use GLSL 100 shader version
Shader shader = LoadShader("resources/shaders/glsl330/base.vs",
"resources/shaders/glsl330/grayscale.fs");
// Shader usage is also different than models/postprocessing, shader is just activated when required
SetTargetFPS(60);
//--------------------------------------------------------------------------------------
@@ -91,21 +86,23 @@ int main()
// Activate our custom shader to be applied on next shapes/textures drawings
BeginShaderMode(shader);
DrawTexture(sonic, 380, -10, WHITE); // Using custom shader
DrawTexture(fudesumi, 500, -30, WHITE); // Using custom shader
// Activate our default shader for next drawings
EndShaderMode();
DrawText("(c) Fudesumi sprite by Eiden Marsal", 380, screenHeight - 20, 10, GRAY);
EndDrawing();
//----------------------------------------------------------------------------------
}
// De-Initialization
//--------------------------------------------------------------------------------------
UnloadShader(shader); // Unload shader
UnloadTexture(sonic); // Unload texture
UnloadShader(shader); // Unload shader
UnloadTexture(fudesumi); // Unload texture
CloseWindow(); // Close window and OpenGL context
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
return 0;

View File

@@ -1,120 +0,0 @@
/*******************************************************************************************
*
* raylib [shaders] example - Standard lighting (materials and lights)
*
* 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 1.3 (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.h"
int main()
{
// Initialization
//--------------------------------------------------------------------------------------
int screenWidth = 800;
int screenHeight = 450;
SetConfigFlags(FLAG_MSAA_4X_HINT); // Enable Multi Sampling Anti Aliasing 4x (if available)
InitWindow(screenWidth, screenHeight, "raylib [shaders] example - model shader");
// Define the camera to look into our 3d world
Camera camera = {{ 4.0f, 4.0f, 4.0f }, { 0.0f, 1.5f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f };
Vector3 position = { 0.0f, 0.0f, 0.0f }; // Set model position
Model dwarf = LoadModel("resources/model/dwarf.obj"); // Load OBJ model
Material material = LoadStandardMaterial();
material.texDiffuse = LoadTexture("resources/model/dwarf_diffuse.png"); // Load model diffuse texture
material.texNormal = LoadTexture("resources/model/dwarf_normal.png"); // Load model normal texture
material.texSpecular = LoadTexture("resources/model/dwarf_specular.png"); // Load model specular texture
material.colDiffuse = WHITE;
material.colAmbient = (Color){0, 0, 10, 255};
material.colSpecular = WHITE;
material.glossiness = 50.0f;
dwarf.material = material; // Apply material to model
Light spotLight = CreateLight(LIGHT_SPOT, (Vector3){3.0f, 5.0f, 2.0f}, (Color){255, 255, 255, 255});
spotLight->target = (Vector3){0.0f, 0.0f, 0.0f};
spotLight->intensity = 2.0f;
spotLight->diffuse = (Color){255, 100, 100, 255};
spotLight->coneAngle = 60.0f;
Light dirLight = CreateLight(LIGHT_DIRECTIONAL, (Vector3){0.0f, -3.0f, -3.0f}, (Color){255, 255, 255, 255});
dirLight->target = (Vector3){1.0f, -2.0f, -2.0f};
dirLight->intensity = 2.0f;
dirLight->diffuse = (Color){100, 255, 100, 255};
Light pointLight = CreateLight(LIGHT_POINT, (Vector3){0.0f, 4.0f, 5.0f}, (Color){255, 255, 255, 255});
pointLight->intensity = 2.0f;
pointLight->diffuse = (Color){100, 100, 255, 255};
pointLight->radius = 3.0f;
// Setup orbital camera
SetCameraMode(camera, CAMERA_ORBITAL); // Set an orbital camera mode
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
//----------------------------------------------------------------------------------
UpdateCamera(&camera); // Update camera
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(RAYWHITE);
Begin3dMode(camera);
DrawModel(dwarf, position, 2.0f, WHITE); // Draw 3d model with texture
DrawLight(spotLight); // Draw spot light
DrawLight(dirLight); // Draw directional light
DrawLight(pointLight); // Draw point light
DrawGrid(10, 1.0f); // Draw a grid
End3dMode();
DrawText("(c) Dwarf 3D model by David Moreno", screenWidth - 200, screenHeight - 20, 10, GRAY);
DrawFPS(10, 10);
EndDrawing();
//----------------------------------------------------------------------------------
}
// De-Initialization
//--------------------------------------------------------------------------------------
UnloadMaterial(material); // Unload material and assigned textures
UnloadModel(dwarf); // Unload model
// Destroy all created lights
DestroyLight(pointLight);
DestroyLight(dirLight);
DestroyLight(spotLight);
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
return 0;
}

View File

@@ -0,0 +1,59 @@
/*******************************************************************************************
*
* raylib [shapes] example - Cubic-bezier lines
*
* 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 "raylib.h"
int main()
{
// Initialization
//--------------------------------------------------------------------------------------
int screenWidth = 800;
int screenHeight = 450;
SetConfigFlags(FLAG_MSAA_4X_HINT);
InitWindow(screenWidth, screenHeight, "raylib [shapes] example - cubic-bezier lines");
Vector2 start = { 0, 0 };
Vector2 end = { screenWidth, screenHeight };
SetTargetFPS(60);
//--------------------------------------------------------------------------------------
// Main game loop
while (!WindowShouldClose()) // Detect window close button or ESC key
{
// Update
//----------------------------------------------------------------------------------
if (IsMouseButtonDown(MOUSE_LEFT_BUTTON)) start = GetMousePosition();
else if (IsMouseButtonDown(MOUSE_RIGHT_BUTTON)) end = GetMousePosition();
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(RAYWHITE);
DrawText("USE MOUSE LEFT-RIGHT CLICK to DEFINE LINE START and END POINTS", 15, 20, 20, GRAY);
DrawLineBezier(start, end, 2.0f, RED);
EndDrawing();
//----------------------------------------------------------------------------------
}
// De-Initialization
//--------------------------------------------------------------------------------------
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
return 0;
}

View File

@@ -24,13 +24,13 @@ int main()
const char msgTtf[64] = "THIS SPRITE FONT has been GENERATED from a TTF";
// NOTE: Textures/Fonts MUST be loaded after Window initialization (OpenGL context is required)
SpriteFont fontBm = LoadSpriteFont("resources/fonts/bmfont.fnt"); // BMFont (AngelCode)
SpriteFont fontTtf = LoadSpriteFont("resources/fonts/pixantiqua.ttf"); // TTF font
SpriteFont fontBm = LoadSpriteFont("resources/bmfont.fnt"); // BMFont (AngelCode)
SpriteFont fontTtf = LoadSpriteFont("resources/pixantiqua.ttf"); // TTF font
Vector2 fontPosition;
fontPosition.x = screenWidth/2 - MeasureTextEx(fontBm, msgBm, fontBm.size, 0).x/2;
fontPosition.y = screenHeight/2 - fontBm.size/2 - 80;
fontPosition.x = screenWidth/2 - MeasureTextEx(fontBm, msgBm, fontBm.baseSize, 0).x/2;
fontPosition.y = screenHeight/2 - fontBm.baseSize/2 - 80;
SetTargetFPS(60);
//--------------------------------------------------------------------------------------
@@ -49,8 +49,8 @@ int main()
ClearBackground(RAYWHITE);
DrawTextEx(fontBm, msgBm, fontPosition, fontBm.size, 0, MAROON);
DrawTextEx(fontTtf, msgTtf, (Vector2){ 75.0f, 240.0f }, fontTtf.size*0.8f, 2, LIME);
DrawTextEx(fontBm, msgBm, fontPosition, fontBm.baseSize, 0, MAROON);
DrawTextEx(fontTtf, msgTtf, (Vector2){ 75.0f, 240.0f }, fontTtf.baseSize*0.8f, 2, LIME);
EndDrawing();
//----------------------------------------------------------------------------------

View File

@@ -25,7 +25,7 @@ int main()
const char msg[256] = "ASCII extended characters:\n¡¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆ\nÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæ\nçèéêëìíîïðñòóôõö÷øùúûüýþÿ";
// NOTE: Loaded font has an unordered list of characters (chars in the range 32..255)
SpriteFont font = LoadSpriteFont("resources/fonts/pixantiqua.fnt"); // BMFont (AngelCode)
SpriteFont font = LoadSpriteFont("resources/pixantiqua.fnt"); // BMFont (AngelCode)
SetTargetFPS(60);
//--------------------------------------------------------------------------------------
@@ -45,10 +45,10 @@ int main()
ClearBackground(RAYWHITE);
DrawText("Font name: PixAntiqua", 40, 50, 20, GRAY);
DrawText(FormatText("Font base size: %i", font.size), 40, 80, 20, GRAY);
DrawText(FormatText("Font chars number: %i", font.numChars), 40, 110, 20, GRAY);
DrawText(FormatText("Font base size: %i", font.baseSize), 40, 80, 20, GRAY);
DrawText(FormatText("Font chars number: %i", font.charsCount), 40, 110, 20, GRAY);
DrawTextEx(font, msg, (Vector2){ 40, 180 }, font.size, 0, MAROON);
DrawTextEx(font, msg, (Vector2){ 40, 180 }, font.baseSize, 0, MAROON);
EndDrawing();
//----------------------------------------------------------------------------------

View File

@@ -0,0 +1,116 @@
/*******************************************************************************************
*
* raylib [text] example - Input Box
*
* 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 "raylib.h"
#define MAX_INPUT_CHARS 9
int main()
{
// Initialization
//--------------------------------------------------------------------------------------
int screenWidth = 800;
int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [text] example - input box");
char name[MAX_INPUT_CHARS + 1] = "\0"; // NOTE: One extra space required for line ending char '\0'
int letterCount = 0;
Rectangle textBox = { screenWidth/2 - 100, 180, 225, 50 };
bool mouseOnText = false;
int framesCounter = 0;
SetTargetFPS(60);
//--------------------------------------------------------------------------------------
// Main game loop
while (!WindowShouldClose()) // Detect window close button or ESC key
{
// Update
//----------------------------------------------------------------------------------
if (CheckCollisionPointRec(GetMousePosition(), textBox)) mouseOnText = true;
else mouseOnText = false;
if (mouseOnText)
{
int key = GetKeyPressed();
// NOTE: Only allow keys in range [32..125]
if ((key >= 32) && (key <= 125) && (letterCount < MAX_INPUT_CHARS))
{
name[letterCount] = (char)key;
letterCount++;
}
if (key == KEY_BACKSPACE)
{
letterCount--;
name[letterCount] = '\0';
if (letterCount < 0) letterCount = 0;
}
}
if (mouseOnText) framesCounter++;
else framesCounter = 0;
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(RAYWHITE);
DrawText("PLACE MOUSE OVER INPUT BOX!", 240, 140, 20, GRAY);
DrawRectangleRec(textBox, LIGHTGRAY);
if (mouseOnText) DrawRectangleLines(textBox.x, textBox.y, textBox.width, textBox.height, RED);
else DrawRectangleLines(textBox.x, textBox.y, textBox.width, textBox.height, DARKGRAY);
DrawText(name, textBox.x + 5, textBox.y + 8, 40, MAROON);
DrawText(FormatText("INPUT CHARS: %i/%i", letterCount, MAX_INPUT_CHARS), 315, 250, 20, DARKGRAY);
if (mouseOnText)
{
if (letterCount < MAX_INPUT_CHARS)
{
// Draw blinking underscore char
if (((framesCounter/20)%2) == 0) DrawText("_", textBox.x + 8 + MeasureText(name, 40), textBox.y + 12, 40, MAROON);
}
else DrawText("Press BACKSPACE to delete chars...", 230, 300, 20, GRAY);
}
EndDrawing();
//----------------------------------------------------------------------------------
}
// De-Initialization
//--------------------------------------------------------------------------------------
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
return 0;
}
// Check if any key is pressed
// NOTE: We limit keys check to keys between 32 (KEY_SPACE) and 126
bool IsAnyKeyPressed()
{
bool keyPressed = false;
int key = GetKeyPressed();
if ((key >= 32) && (key <= 126)) keyPressed = true;
return keyPressed;
}

View File

@@ -1,19 +1,21 @@
/*******************************************************************************************
*
* raylib [text] example - raylib bitmap font (rbmf) loading and usage
* 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.3 (www.raylib.com)
* 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) 2015 Ramon Santamaria (@raysan5)
* Copyright (c) 2017 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
#include "raylib.h"
#define MAX_FONTS 8
int main()
{
// Initialization
@@ -21,21 +23,21 @@ int main()
int screenWidth = 800;
int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [text] example - rBMF fonts");
InitWindow(screenWidth, screenHeight, "raylib [text] example - raylib fonts");
// NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required)
SpriteFont fonts[8];
SpriteFont fonts[MAX_FONTS];
fonts[0] = LoadSpriteFont("resources/fonts/alagard.rbmf"); // rBMF font loading
fonts[1] = LoadSpriteFont("resources/fonts/pixelplay.rbmf"); // rBMF font loading
fonts[2] = LoadSpriteFont("resources/fonts/mecha.rbmf"); // rBMF font loading
fonts[3] = LoadSpriteFont("resources/fonts/setback.rbmf"); // rBMF font loading
fonts[4] = LoadSpriteFont("resources/fonts/romulus.rbmf"); // rBMF font loading
fonts[5] = LoadSpriteFont("resources/fonts/pixantiqua.rbmf"); // rBMF font loading
fonts[6] = LoadSpriteFont("resources/fonts/alpha_beta.rbmf"); // rBMF font loading
fonts[7] = LoadSpriteFont("resources/fonts/jupiter_crash.rbmf"); // rBMF font loading
fonts[0] = LoadSpriteFont("resources/fonts/alagard.png");
fonts[1] = LoadSpriteFont("resources/fonts/pixelplay.png");
fonts[2] = LoadSpriteFont("resources/fonts/mecha.png");
fonts[3] = LoadSpriteFont("resources/fonts/setback.png");
fonts[4] = LoadSpriteFont("resources/fonts/romulus.png");
fonts[5] = LoadSpriteFont("resources/fonts/pixantiqua.png");
fonts[6] = LoadSpriteFont("resources/fonts/alpha_beta.png");
fonts[7] = LoadSpriteFont("resources/fonts/jupiter_crash.png");
const char *messages[8] = { "ALAGARD FONT designed by Hewett Tsoi",
const char *messages[MAX_FONTS] = { "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)",
@@ -44,17 +46,22 @@ int main()
"ALPHA_BETA FONT designed by Brian Kent (AEnigma)",
"JUPITER_CRASH FONT designed by Brian Kent (AEnigma)" };
const int spacings[8] = { 2, 4, 8, 4, 3, 4, 4, 1 };
const int spacings[MAX_FONTS] = { 2, 4, 8, 4, 3, 4, 4, 1 };
Vector2 positions[8];
Vector2 positions[MAX_FONTS];
for (int i = 0; i < 8; i++)
for (int i = 0; i < MAX_FONTS; i++)
{
positions[i].x = screenWidth/2 - MeasureTextEx(fonts[i], messages[i], fonts[i].baseSize*2, spacings[i]).x/2;
positions[i].y = 60 + fonts[i].baseSize + 50*i;
positions[i].y = 60 + fonts[i].baseSize + 45*i;
}
Color colors[8] = { MAROON, ORANGE, DARKGREEN, DARKBLUE, DARKPURPLE, LIME, GOLD };
// Small Y position corrections
positions[3].y += 8;
positions[4].y += 2;
positions[7].y -= 8;
Color colors[MAX_FONTS] = { MAROON, ORANGE, DARKGREEN, DARKBLUE, DARKPURPLE, LIME, GOLD, RED };
//--------------------------------------------------------------------------------------
// Main game loop
@@ -74,7 +81,7 @@ int main()
DrawText("free fonts included with raylib", 250, 20, 20, DARKGRAY);
DrawLine(220, 50, 590, 50, DARKGRAY);
for (int i = 0; i < 8; i++)
for (int i = 0; i < MAX_FONTS; i++)
{
DrawTextEx(fonts[i], messages[i], positions[i], fonts[i].baseSize*2, spacings[i], colors[i]);
}
@@ -85,10 +92,9 @@ int main()
// De-Initialization
//--------------------------------------------------------------------------------------
for (int i = 0; i < 8; i++)
{
UnloadSpriteFont(fonts[i]); // SpriteFont unloading
}
// SpriteFonts unloading
for (int i = 0; i < MAX_FONTS; i++) UnloadSpriteFont(fonts[i]);
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------

View File

@@ -25,20 +25,20 @@ int main()
const char msg3[50] = "...and a THIRD one! GREAT! :D";
// NOTE: Textures/Fonts MUST be loaded after Window initialization (OpenGL context is required)
SpriteFont font1 = LoadSpriteFont("resources/fonts/custom_mecha.png"); // SpriteFont loading
SpriteFont font2 = LoadSpriteFont("resources/fonts/custom_alagard.png"); // SpriteFont loading
SpriteFont font3 = LoadSpriteFont("resources/fonts/custom_jupiter_crash.png"); // SpriteFont loading
SpriteFont font1 = LoadSpriteFont("resources/custom_mecha.png"); // SpriteFont loading
SpriteFont font2 = LoadSpriteFont("resources/custom_alagard.png"); // SpriteFont loading
SpriteFont font3 = LoadSpriteFont("resources/custom_jupiter_crash.png"); // SpriteFont loading
Vector2 fontPosition1, fontPosition2, fontPosition3;
fontPosition1.x = screenWidth/2 - MeasureTextEx(font1, msg1, font1.size, -3).x/2;
fontPosition1.y = screenHeight/2 - font1.size/2 - 80;
fontPosition1.x = screenWidth/2 - MeasureTextEx(font1, msg1, font1.baseSize, -3).x/2;
fontPosition1.y = screenHeight/2 - font1.baseSize/2 - 80;
fontPosition2.x = screenWidth/2 - MeasureTextEx(font2, msg2, font2.size, -2).x/2;
fontPosition2.y = screenHeight/2 - font2.size/2 - 10;
fontPosition2.x = screenWidth/2 - MeasureTextEx(font2, msg2, font2.baseSize, -2).x/2;
fontPosition2.y = screenHeight/2 - font2.baseSize/2 - 10;
fontPosition3.x = screenWidth/2 - MeasureTextEx(font3, msg3, font3.size, 2).x/2;
fontPosition3.y = screenHeight/2 - font3.size/2 + 50;
fontPosition3.x = screenWidth/2 - MeasureTextEx(font3, msg3, font3.baseSize, 2).x/2;
fontPosition3.y = screenHeight/2 - font3.baseSize/2 + 50;
//--------------------------------------------------------------------------------------
@@ -56,9 +56,9 @@ int main()
ClearBackground(RAYWHITE);
DrawTextEx(font1, msg1, fontPosition1, font1.size, -3, WHITE);
DrawTextEx(font2, msg2, fontPosition2, font2.size, -2, WHITE);
DrawTextEx(font3, msg3, fontPosition3, font3.size, 2, WHITE);
DrawTextEx(font1, msg1, fontPosition1, font1.baseSize, -3, WHITE);
DrawTextEx(font2, msg2, fontPosition2, font2.baseSize, -2, WHITE);
DrawTextEx(font3, msg3, fontPosition3, font3.baseSize, 2, WHITE);
EndDrawing();
//----------------------------------------------------------------------------------

View File

@@ -25,13 +25,13 @@ int main()
// NOTE: Textures/Fonts MUST be loaded after Window initialization (OpenGL context is required)
// TTF SpriteFont loading with custom generation parameters
SpriteFont font = LoadSpriteFontTTF("resources/fonts/KAISG.ttf", 96, 0, 0);
SpriteFont font = LoadSpriteFontTTF("resources/KAISG.ttf", 96, 0, 0);
// Generate mipmap levels to use trilinear filtering
// NOTE: On 2D drawing it won't be noticeable, it looks like FILTER_BILINEAR
GenTextureMipmaps(&font.texture);
float fontSize = font.size;
float fontSize = font.baseSize;
Vector2 fontPosition = { 40, screenHeight/2 + 50 };
Vector2 textSize;

View File

@@ -1,158 +0,0 @@
/*******************************************************************************************
*
* raylib [text] example - Font selector
*
* 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.h"
int main()
{
// Initialization
//--------------------------------------------------------------------------------------
int screenWidth = 800;
int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [text] example - font selector");
// NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required)
SpriteFont fonts[8]; // SpriteFont array
fonts[0] = LoadSpriteFont("resources/fonts/alagard.rbmf"); // SpriteFont loading
fonts[1] = LoadSpriteFont("resources/fonts/pixelplay.rbmf"); // SpriteFont loading
fonts[2] = LoadSpriteFont("resources/fonts/mecha.rbmf"); // SpriteFont loading
fonts[3] = LoadSpriteFont("resources/fonts/setback.rbmf"); // SpriteFont loading
fonts[4] = LoadSpriteFont("resources/fonts/romulus.rbmf"); // SpriteFont loading
fonts[5] = LoadSpriteFont("resources/fonts/pixantiqua.rbmf"); // SpriteFont loading
fonts[6] = LoadSpriteFont("resources/fonts/alpha_beta.rbmf"); // SpriteFont loading
fonts[7] = LoadSpriteFont("resources/fonts/jupiter_crash.rbmf"); // SpriteFont loading
int currentFont = 0; // Selected font
Color colors[8] = { MAROON, ORANGE, DARKGREEN, DARKBLUE, DARKPURPLE, LIME, GOLD, RED };
const char fontNames[8][20] = { "[0] Alagard", "[1] PixelPlay", "[2] MECHA", "[3] Setback",
"[4] Romulus", "[5] PixAntiqua", "[6] Alpha Beta", "[7] Jupiter Crash" };
const char text[50] = "THIS is THE FONT you SELECTED!"; // Main text
Vector2 textSize = MeasureTextEx(fonts[currentFont], text, fonts[currentFont].size*3, 1);
Vector2 mousePoint;
Color btnNextOutColor = DARKBLUE; // Button color (outside line)
Color btnNextInColor = SKYBLUE; // Button color (inside)
int framesCounter = 0; // Useful to count frames button is 'active' = clicked
int positionY = 180; // Text selector and button Y position
Rectangle btnNextRec = { 673, positionY, 109, 44 }; // Button rectangle (useful for collision)
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
//----------------------------------------------------------------------------------
// Keyboard-based font selection (easy)
if (IsKeyPressed(KEY_RIGHT))
{
if (currentFont < 7) currentFont++;
}
if (IsKeyPressed(KEY_LEFT))
{
if (currentFont > 0) currentFont--;
}
if (IsKeyPressed('0')) currentFont = 0;
else if (IsKeyPressed('1')) currentFont = 1;
else if (IsKeyPressed('2')) currentFont = 2;
else if (IsKeyPressed('3')) currentFont = 3;
else if (IsKeyPressed('4')) currentFont = 4;
else if (IsKeyPressed('5')) currentFont = 5;
else if (IsKeyPressed('6')) currentFont = 6;
else if (IsKeyPressed('7')) currentFont = 7;
// Mouse-based font selection (NEXT button logic)
mousePoint = GetMousePosition();
if (CheckCollisionPointRec(mousePoint, btnNextRec))
{
// Mouse hover button logic
if (framesCounter == 0)
{
btnNextOutColor = DARKPURPLE;
btnNextInColor = PURPLE;
}
if (IsMouseButtonDown(MOUSE_LEFT_BUTTON))
{
framesCounter = 20; // Frames button is 'active'
btnNextOutColor = MAROON;
btnNextInColor = RED;
}
}
else
{
// Mouse not hover button
btnNextOutColor = DARKBLUE;
btnNextInColor = SKYBLUE;
}
if (framesCounter > 0) framesCounter--;
if (framesCounter == 1) // We change font on frame 1
{
currentFont++;
if (currentFont > 7) currentFont = 0;
}
// Text measurement for better positioning on screen
textSize = MeasureTextEx(fonts[currentFont], text, fonts[currentFont].size*3, 1);
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(RAYWHITE);
DrawText("font selector - use arroys, button or numbers", 160, 80, 20, DARKGRAY);
DrawLine(120, 120, 680, 120, DARKGRAY);
DrawRectangle(18, positionY, 644, 44, DARKGRAY);
DrawRectangle(20, positionY + 2, 640, 40, LIGHTGRAY);
DrawText(fontNames[currentFont], 30, positionY + 13, 20, BLACK);
DrawText("< >", 610, positionY + 8, 30, BLACK);
DrawRectangleRec(btnNextRec, btnNextOutColor);
DrawRectangle(675, positionY + 2, 105, 40, btnNextInColor);
DrawText("NEXT", 700, positionY + 13, 20, btnNextOutColor);
DrawTextEx(fonts[currentFont], text, (Vector2){ screenWidth/2 - textSize.x/2,
260 + (70 - textSize.y)/2 }, fonts[currentFont].size*3,
1, colors[currentFont]);
EndDrawing();
//----------------------------------------------------------------------------------
}
// De-Initialization
//--------------------------------------------------------------------------------------
for (int i = 0; i < 8; i++) UnloadSpriteFont(fonts[i]); // SpriteFont(s) unloading
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
return 0;
}

View File

@@ -1,11 +1,11 @@
/*******************************************************************************************
*
* raylib example - particles trail blending
* raylib example - particles blending
*
* This example has been created using raylib 1.3 (www.raylib.com)
* 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) 2015 Ramon Santamaria (@raysan5)
* Copyright (c) 2017 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
@@ -30,7 +30,7 @@ int main()
int screenWidth = 800;
int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [textures] example - particles trail blending");
InitWindow(screenWidth, screenHeight, "raylib [textures] example - particles blending");
// Particles pool, reuse them!
Particle mouseTail[MAX_PARTICLES];

View File

@@ -27,9 +27,9 @@ int main()
// NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required)
// Load RAW image data (512x512, 32bit RGBA, no file header)
Image sonicRaw = LoadImageRaw("resources/texture_formats/sonic_R8G8B8A8.raw", 512, 512, UNCOMPRESSED_R8G8B8A8, 0);
Texture2D sonic = LoadTextureFromImage(sonicRaw); // Upload CPU (RAM) image to GPU (VRAM)
UnloadImage(sonicRaw); // Unload CPU (RAM) image data
Image fudesumiRaw = LoadImageRaw("resources/fudesumi.raw", 384, 512, UNCOMPRESSED_R8G8B8A8, 0);
Texture2D fudesumi = LoadTextureFromImage(fudesumiRaw); // Upload CPU (RAM) image to GPU (VRAM)
UnloadImage(fudesumiRaw); // Unload CPU (RAM) image data
// Generate a checked texture by code (1024x1024 pixels)
int width = 1024;
@@ -42,8 +42,8 @@ int main()
{
for (int x = 0; x < width; x++)
{
if (((x/32+y/32)/1)%2 == 0) pixels[y*height + x] = DARKBLUE;
else pixels[y*height + x] = SKYBLUE;
if (((x/32+y/32)/1)%2 == 0) pixels[y*height + x] = ORANGE;
else pixels[y*height + x] = GOLD;
}
}
@@ -70,12 +70,14 @@ int main()
ClearBackground(RAYWHITE);
DrawTexture(checked, screenWidth/2 - checked.width/2, screenHeight/2 - checked.height/2, Fade(WHITE, 0.3f));
DrawTexture(sonic, 330, -20, WHITE);
DrawTexture(checked, screenWidth/2 - checked.width/2, screenHeight/2 - checked.height/2, Fade(WHITE, 0.5f));
DrawTexture(fudesumi, 430, -30, WHITE);
DrawText("CHECKED TEXTURE ", 84, 100, 30, DARKBLUE);
DrawText("GENERATED by CODE", 72, 164, 30, DARKBLUE);
DrawText("and RAW IMAGE LOADING", 46, 226, 30, DARKBLUE);
DrawText("CHECKED TEXTURE ", 84, 100, 30, BROWN);
DrawText("GENERATED by CODE", 72, 164, 30, BROWN);
DrawText("and RAW IMAGE LOADING", 46, 226, 30, BROWN);
DrawText("(c) Fudesumi sprite by Eiden Marsal", 310, screenHeight - 20, 10, BROWN);
EndDrawing();
//----------------------------------------------------------------------------------
@@ -83,7 +85,7 @@ int main()
// De-Initialization
//--------------------------------------------------------------------------------------
UnloadTexture(sonic); // Texture unloading
UnloadTexture(fudesumi); // Texture unloading
UnloadTexture(checked); // Texture unloading
CloseWindow(); // Close window and OpenGL context

Some files were not shown because too many files have changed in this diff Show More