Merge pull request #256 from raysan5/develop

Integrate develop branch
This commit is contained in:
Ray 2017-04-04 12:17:08 +02:00 • committed by GitHub
commit 407746193d
324 changed files with 1385708 additions and 1380752 deletions

View file

@ -4,7 +4,7 @@
* *
* NOTE: This example requires OpenAL Soft library installed * NOTE: This example requires OpenAL Soft library installed
* *
* 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) * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
* *
* Copyright (c) 2015 Ramon Santamaria (@raysan5) * Copyright (c) 2015 Ramon Santamaria (@raysan5)
@ -25,6 +25,9 @@ int screenHeight = 450;
int framesCounter = 0; int framesCounter = 0;
float timePlayed = 0.0f; float timePlayed = 0.0f;
static bool pause = false;
Music music;
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Module Functions Declaration // Module Functions Declaration
@ -42,7 +45,9 @@ int main()
InitAudioDevice(); // Initialize audio device InitAudioDevice(); // Initialize audio device
PlayMusicStream(0, "resources/audio/guitar_noodling.ogg"); // Play music stream music = LoadMusicStream("resources/audio/guitar_noodling.ogg");
PlayMusicStream(music);
#if defined(PLATFORM_WEB) #if defined(PLATFORM_WEB)
emscripten_set_main_loop(UpdateDrawFrame, 0, 1); emscripten_set_main_loop(UpdateDrawFrame, 0, 1);
@ -59,6 +64,8 @@ int main()
// De-Initialization // De-Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
UnloadMusicStream(music); // Unload music stream buffers from RAM
CloseAudioDevice(); // Close audio device (music streaming is automatically stopped) CloseAudioDevice(); // Close audio device (music streaming is automatically stopped)
CloseWindow(); // Close window and OpenGL context CloseWindow(); // Close window and OpenGL context
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
@ -73,33 +80,26 @@ void UpdateDrawFrame(void)
{ {
// Update // Update
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
framesCounter++; UpdateMusicStream(music); // Update music buffer with new stream data
// Testing music fading from one file to another // Restart music playing (stop and play)
/* if (IsKeyPressed(KEY_SPACE))
if (framesCounter > 600) // Wait for 10 seconds (600 frames) {
{ StopMusicStream(music);
volume -= 0.01; // Decrement music volume level PlayMusicStream(music);
}
// When music volume level equal or lower than 0,
// restore volume level and init another music file
if (volume <= 0)
{
volume = 1.0;
framesCounter = 0;
PlayMusicStream(1, "resources/audio/another_file.ogg");
}
SetMusicVolume(volume);
}
*/
if (IsWindowMinimized()) PauseMusicStream(0); // Pause/Resume music playing
else ResumeMusicStream(0); if (IsKeyPressed(KEY_P))
{
timePlayed = GetMusicTimePlayed(0)/GetMusicTimeLength(0)*100*4; // We scale by 4 to fit 400 pixels pause = !pause;
if (pause) PauseMusicStream(music);
else ResumeMusicStream(music);
}
UpdateMusicStream(0); // Update music buffer with new stream data // Get timePlayed scaled to bar dimensions (400 pixels)
timePlayed = GetMusicTimePlayed(music)/GetMusicTimeLength(music)*400;
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Draw // Draw
@ -108,11 +108,14 @@ void UpdateDrawFrame(void)
ClearBackground(RAYWHITE); ClearBackground(RAYWHITE);
DrawText("MUSIC SHOULD BE PLAYING!", 255, 200, 20, LIGHTGRAY); DrawText("MUSIC SHOULD BE PLAYING!", 255, 150, 20, LIGHTGRAY);
DrawRectangle(200, 250, 400, 12, LIGHTGRAY); DrawRectangle(200, 200, 400, 12, LIGHTGRAY);
DrawRectangle(200, 250, (int)timePlayed, 12, MAROON); DrawRectangle(200, 200, (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(); EndDrawing();
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,114 @@
/*******************************************************************************************
*
* 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 22050
#define MAX_SAMPLES_PER_UPDATE 4096
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: 16bit-short, channels: 1-mono)
AudioStream stream = InitAudioStream(22050, 16, 1);
// Generate samples data from sine wave
short *data = (short *)malloc(sizeof(short)*MAX_SAMPLES);
// TODO: Review data generation, it seems data is discontinued for loop,
// for that reason, there is a clip everytime audio stream is looped...
for (int i = 0; i < MAX_SAMPLES; i++)
{
data[i] = (short)(sinf(((2*PI*(float)i)/2)*DEG2RAD)*32000);
}
PlayAudioStream(stream); // Start processing stream buffer (no data loaded currently)
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
// NOTE: Every update we check if stream data has been already consumed and we update
// buffer with new data from the generated samples, we upload data at a rate (MAX_SAMPLES_PER_UPDATE),
// but notice that at some point we update < MAX_SAMPLES_PER_UPDATE data...
if (IsAudioBufferProcessed(stream))
{
int numSamples = 0;
if (samplesLeft >= MAX_SAMPLES_PER_UPDATE) numSamples = MAX_SAMPLES_PER_UPDATE;
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, proportional values)
for (int i = 0; i < GetScreenWidth(); i++)
{
position.x = i;
position.y = 250 + 50*data[i]/32000;
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;
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -24,7 +24,7 @@ int screenWidth = 800;
int screenHeight = 450; int screenHeight = 450;
// Define the camera to look into our 3d world (position, target, up vector) // Define the camera to look into our 3d world (position, target, up vector)
Camera camera = {{ 0.0f, 10.0f, 10.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 60.0f }; Camera camera = {{ 4.0f, 2.0f, 4.0f }, { 0.0f, 1.8f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 60.0f };
// Generates some random columns // Generates some random columns
float heights[MAX_COLUMNS]; float heights[MAX_COLUMNS];
@ -56,9 +56,8 @@ int main()
colors[i] = (Color){ GetRandomValue(20, 255), GetRandomValue(10, 55), 30, 255 }; colors[i] = (Color){ GetRandomValue(20, 255), GetRandomValue(10, 55), 30, 255 };
} }
SetCameraMode(CAMERA_FIRST_PERSON); // Set a first person camera mode SetCameraMode(camera, CAMERA_FIRST_PERSON); // Set a first person camera mode
SetCameraFovy(camera.fovy); // Set internal camera field-of-view Y
#if defined(PLATFORM_WEB) #if defined(PLATFORM_WEB)
emscripten_set_main_loop(UpdateDrawFrame, 0, 1); emscripten_set_main_loop(UpdateDrawFrame, 0, 1);
#else #else
@ -88,7 +87,7 @@ void UpdateDrawFrame(void)
{ {
// Update // Update
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
UpdateCameraPlayer(&camera, &playerPosition); // Update camera and player position UpdateCamera(&camera); // Update camera and player position
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Draw // Draw

File diff suppressed because one or more lines are too long

View file

@ -2,7 +2,7 @@
* *
* raylib [core] example - Initialize 3d camera free (adapted for HTML5 platform) * raylib [core] example - Initialize 3d camera free (adapted for HTML5 platform)
* *
* 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) * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
* *
* Copyright (c) 2015 Ramon Santamaria (@raysan5) * Copyright (c) 2015 Ramon Santamaria (@raysan5)
@ -41,16 +41,12 @@ int main()
InitWindow(screenWidth, screenHeight, "raylib [core] example - 3d camera free"); InitWindow(screenWidth, screenHeight, "raylib [core] example - 3d camera free");
// Define the camera to look into our 3d world // Define the camera to look into our 3d world
Camera camera; camera.position = (Vector3){ 10.0f, 10.0f, 10.0f }; // Camera position
camera.position = (Vector3){ 0.0f, 10.0f, 10.0f }; // Camera position
camera.target = (Vector3){ 0.0f, 0.0f, 0.0f }; // Camera looking at point camera.target = (Vector3){ 0.0f, 0.0f, 0.0f }; // Camera looking at point
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target) camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target)
camera.fovy = 45.0f; // Camera field-of-view Y camera.fovy = 45.0f; // Camera field-of-view Y
SetCameraMode(CAMERA_FREE); // Set a free camera mode SetCameraMode(camera, CAMERA_FREE); // Set a free camera mode
SetCameraPosition(camera.position); // Set internal camera position to match our camera position
SetCameraTarget(camera.target); // Set internal camera target to match our camera target
SetCameraFovy(camera.fovy); // Set internal camera field-of-view Y
#if defined(PLATFORM_WEB) #if defined(PLATFORM_WEB)
emscripten_set_main_loop(UpdateDrawFrame, 0, 1); emscripten_set_main_loop(UpdateDrawFrame, 0, 1);

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -45,14 +45,12 @@ int main()
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
InitWindow(screenWidth, screenHeight, "raylib [core] example - 3d picking"); InitWindow(screenWidth, screenHeight, "raylib [core] example - 3d picking");
camera.position = (Vector3){ 0.0f, 10.0f, 10.0f }; // Camera position camera.position = (Vector3){ 10.0f, 10.0f, 10.0f }; // Camera position
camera.target = (Vector3){ 0.0f, 0.0f, 0.0f }; // Camera looking at point camera.target = (Vector3){ 0.0f, 0.0f, 0.0f }; // Camera looking at point
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target) camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target)
camera.fovy = 45.0f; // Camera field-of-view Y camera.fovy = 45.0f; // Camera field-of-view Y
SetCameraMode(CAMERA_FREE); // Set a free camera mode SetCameraMode(camera, CAMERA_FREE); // Set a free camera mode
SetCameraPosition(camera.position); // Set internal camera position to match our camera position
SetCameraFovy(camera.fovy); // Set internal camera field-of-view Y
#if defined(PLATFORM_WEB) #if defined(PLATFORM_WEB)
emscripten_set_main_loop(UpdateDrawFrame, 0, 1); emscripten_set_main_loop(UpdateDrawFrame, 0, 1);

File diff suppressed because one or more lines are too long

View file

@ -25,7 +25,6 @@
int screenWidth = 800; int screenWidth = 800;
int screenHeight = 450; int screenHeight = 450;
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Module Functions Declaration // Module Functions Declaration
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

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