10 コミット

作成者 SHA1 メッセージ 日付
  Ray 78a06990c7
Merge pull request #5041 from PanicTitan/master 1週間前
  Ray 82b80a6998 Review formatting, avoid variable 1週間前
  Ray 71b302846a Review formatting, avoid variable 1週間前
  Ray 8823aba9df Update rprand.h 1週間前
  Ray 6b9a685bae
Merge pull request #5048 from veins1/patch-4 1週間前
  Ray 14582a9f06
Merge pull request #5047 from RomainPlmg/#5009-fix-colorreplace-alpha 1週間前
  veins1 0405de794a
Fix for music stopping too early 2週間前
  veins1 d03ac97eff
GetMusicTimePlayed fix for music shorter than buffer size 2週間前
  Romain Plumaugat 34af70866c [rtextures] Fix ImageColorReplace() alpha issue #5009 2週間前
  PanicTitan 9e908e4a76
Update core_custom_frame_control.c to work properly on web 2週間前
4個のファイルの変更60行の追加41行の削除
分割表示
  1. +7
    -1
      examples/core/core_custom_frame_control.c
  2. +21
    -21
      src/external/rprand.h
  3. +22
    -18
      src/raudio.c
  4. +10
    -1
      src/rtextures.c

+ 7
- 1
examples/core/core_custom_frame_control.c ファイルの表示

@ -61,7 +61,9 @@ int main(void)
{
// Update
//----------------------------------------------------------------------------------
PollInputEvents(); // Poll input events (SUPPORT_CUSTOM_FRAME_CONTROL)
#ifndef PLATFORM_WEB // NOTE: On non web platforms the PollInputEvents just works before the inputs checks
PollInputEvents(); // Poll input events (SUPPORT_CUSTOM_FRAME_CONTROL)
#endif
if (IsKeyPressed(KEY_SPACE)) pause = !pause;
@ -76,6 +78,10 @@ int main(void)
if (position >= GetScreenWidth()) position = 0;
timeCounter += deltaTime; // We count time (seconds)
}
#ifdef PLATFORM_WEB // NOTE: On web platform for some reason the PollInputEvents only works after the inputs check, so just call it after check all your inputs (on web)
PollInputEvents(); // Poll input events (SUPPORT_CUSTOM_FRAME_CONTROL)
#endif
//----------------------------------------------------------------------------------
// Draw

+ 21
- 21
src/external/rprand.h ファイルの表示

@ -15,15 +15,15 @@
* - Support 64 bits generation
*
* ADDITIONAL NOTES:
* This library implements two pseudo-random number generation algorithms:
* This library implements two pseudo-random number generation algorithms:
*
* - Xoshiro128** : https://prng.di.unimi.it/xoshiro128starstar.c
* - SplitMix64 : https://prng.di.unimi.it/splitmix64.c
*
* SplitMix64 is used to initialize the Xoshiro128** state, from a provided seed
*
* It's suggested to use SplitMix64 to initialize the state of the generators starting from
* a 64-bit seed, as research has shown that initialization must be performed with a generator
* It's suggested to use SplitMix64 to initialize the state of the generators starting from
* a 64-bit seed, as research has shown that initialization must be performed with a generator
* radically different in nature from the one initialized to avoid correlation on similar seeds.
*
* CONFIGURATION:
@ -31,7 +31,7 @@
* Generates the implementation of the library into the included file.
* If not defined, the library is in header only mode and can be included in other headers
* or source files without problems. But only ONE file should hold the implementation.
*
*
* DEPENDENCIES: none
*
* VERSIONS HISTORY:
@ -153,7 +153,7 @@ static uint32_t rprand_state[4] = { // Xoshiro128** state, initializ
0x218b21e5,
0xaa91febd,
0x976414d4
};
};
//----------------------------------------------------------------------------------
// Module internal functions declaration
@ -190,8 +190,8 @@ int rprand_get_value(int min, int max)
int *rprand_load_sequence(unsigned int count, int min, int max)
{
int *sequence = NULL;
if (count > (unsigned int)(abs(max - min) + 1))
if (count > (unsigned int)(abs(max - min) + 1))
{
RPRAND_LOG("WARNING: Sequence count required is greater than range provided\n");
//count = (max - min);
@ -244,26 +244,26 @@ static inline uint32_t rprand_rotate_left(const uint32_t x, int k)
}
// Xoshiro128** generator info:
//
//
// Written in 2018 by David Blackman and Sebastiano Vigna (vigna@acm.org)
//
//
// To the extent possible under law, the author has dedicated all copyright
// and related and neighboring rights to this software to the public domain
// worldwide. This software is distributed without any warranty.
//
//
// See <http://creativecommons.org/publicdomain/zero/1.0/>.
//
//
// This is xoshiro128** 1.1, one of our 32-bit all-purpose, rock-solid
// generators. It has excellent speed, a state size (128 bits) that is
// large enough for mild parallelism, and it passes all tests we are aware
// of.
//
//
// Note that version 1.0 had mistakenly s[0] instead of s[1] as state
// word passed to the scrambler.
//
//
// For generating just single-precision (i.e., 32-bit) floating-point
// numbers, xoshiro128+ is even faster.
//
//
// The state must be seeded so that it is not everywhere zero.
//
uint32_t rprand_xoshiro(void)
@ -275,29 +275,29 @@ uint32_t rprand_xoshiro(void)
rprand_state[3] ^= rprand_state[1];
rprand_state[1] ^= rprand_state[2];
rprand_state[0] ^= rprand_state[3];
rprand_state[2] ^= t;
rprand_state[3] = rprand_rotate_left(rprand_state[3], 11);
return result;
}
// SplitMix64 generator info:
//
//
// Written in 2015 by Sebastiano Vigna (vigna@acm.org)
//
//
// To the extent possible under law, the author has dedicated all copyright
// and related and neighboring rights to this software to the public domain
// worldwide. This software is distributed without any warranty.
//
//
// See <http://creativecommons.org/publicdomain/zero/1.0/>.
//
//
//
// This is a fixed-increment version of Java 8's SplittableRandom generator
// See http://dx.doi.org/10.1145/2714064.2660195 and
// http://docs.oracle.com/javase/8/docs/api/java/util/SplittableRandom.html
//
//
// It is a very fast generator passing BigCrush, and it can be useful if
// for some reason you absolutely want 64 bits of state.
uint64_t rprand_splitmix64()

+ 22
- 18
src/raudio.c ファイルの表示

@ -1891,14 +1891,28 @@ void UpdateMusicStream(Music music)
// Check both sub-buffers to check if they require refilling
for (int i = 0; i < 2; i++)
{
if (!music.stream.buffer->isSubBufferProcessed[i]) continue; // No refilling required, move to next sub-buffer
unsigned int framesLeft = music.frameCount - music.stream.buffer->framesProcessed; // Frames left to be processed
unsigned int framesToStream = 0; // Total frames to be streamed
if ((framesLeft >= subBufferSizeInFrames) || music.looping) framesToStream = subBufferSizeInFrames;
else framesToStream = framesLeft;
if (framesToStream == 0)
{
// Check if both buffers have been processed
if (music.stream.buffer->isSubBufferProcessed[0] && music.stream.buffer->isSubBufferProcessed[1])
{
ma_mutex_unlock(&AUDIO.System.lock);
StopMusicStream(music);
return;
}
ma_mutex_unlock(&AUDIO.System.lock);
return;
}
if (!music.stream.buffer->isSubBufferProcessed[i]) continue; // No refilling required, move to next sub-buffer
int frameCountStillNeeded = framesToStream;
int frameCountReadTotal = 0;
@ -2011,19 +2025,6 @@ void UpdateMusicStream(Music music)
}
UpdateAudioStreamInLockedState(music.stream, AUDIO.System.pcmBuffer, framesToStream);
music.stream.buffer->framesProcessed = music.stream.buffer->framesProcessed%music.frameCount;
if (framesLeft <= subBufferSizeInFrames)
{
if (!music.looping)
{
ma_mutex_unlock(&AUDIO.System.lock);
// Streaming is ending, we filled latest frames from input
StopMusicStream(music);
return;
}
}
}
ma_mutex_unlock(&AUDIO.System.lock);
@ -2086,8 +2087,12 @@ float GetMusicTimePlayed(Music music)
int subBufferSize = (int)music.stream.buffer->sizeInFrames/2;
int framesInFirstBuffer = music.stream.buffer->isSubBufferProcessed[0]? 0 : subBufferSize;
int framesInSecondBuffer = music.stream.buffer->isSubBufferProcessed[1]? 0 : subBufferSize;
int framesInBuffers = framesInFirstBuffer + framesInSecondBuffer;
if (framesInBuffers > music.frameCount) {
if (!music.looping) framesInBuffers = music.frameCount;
}
int framesSentToMix = music.stream.buffer->frameCursorPos%subBufferSize;
int framesPlayed = (framesProcessed - framesInFirstBuffer - framesInSecondBuffer + framesSentToMix)%(int)music.frameCount;
int framesPlayed = (framesProcessed - framesInBuffers + framesSentToMix)%(int)music.frameCount;
if (framesPlayed < 0) framesPlayed += music.frameCount;
secondsPlayed = (float)framesPlayed/music.stream.sampleRate;
ma_mutex_unlock(&AUDIO.System.lock);
@ -2684,8 +2689,7 @@ static void UpdateAudioStreamInLockedState(AudioStream stream, const void *data,
ma_uint32 subBufferSizeInFrames = stream.buffer->sizeInFrames/2;
unsigned char *subBuffer = stream.buffer->data + ((subBufferSizeInFrames*stream.channels*(stream.sampleSize/8))*subBufferToUpdate);
// Total frames processed in buffer is always the complete size, filled with 0 if required
stream.buffer->framesProcessed += subBufferSizeInFrames;
stream.buffer->framesProcessed += frameCount;
// Does this API expect a whole buffer to be updated in one go?
// Assuming so, but if not will need to change this logic

+ 10
- 1
src/rtextures.c ファイルの表示

@ -2927,7 +2927,16 @@ void ImageColorReplace(Image *image, Color color, Color replace)
image->data = pixels;
image->format = PIXELFORMAT_UNCOMPRESSED_R8G8B8A8;
ImageFormat(image, format);
// Only convert back to original format if it supported alpha
if ((format == PIXELFORMAT_UNCOMPRESSED_R8G8B8) ||
(format == PIXELFORMAT_UNCOMPRESSED_R5G6B5) ||
(format == PIXELFORMAT_UNCOMPRESSED_GRAYSCALE) ||
(format == PIXELFORMAT_UNCOMPRESSED_R32G32B32) ||
(format == PIXELFORMAT_UNCOMPRESSED_R16G16B16) ||
(format == PIXELFORMAT_COMPRESSED_DXT1_RGB) ||
(format == PIXELFORMAT_COMPRESSED_ETC1_RGB) ||
(format == PIXELFORMAT_COMPRESSED_ETC2_RGB) ||
(format == PIXELFORMAT_COMPRESSED_PVRT_RGB)) ImageFormat(image, format);
}
#endif // SUPPORT_IMAGE_MANIPULATION

読み込み中…
キャンセル
保存