Rename enum LogType names...

...to avoid possible conflicting symbols
This commit is contained in:
raysan5 2017-07-02 12:35:13 +02:00
parent bfa66f446a
commit 9f09f6f550
10 changed files with 397 additions and 417 deletions

View file

@ -170,7 +170,7 @@ typedef struct MusicData {
} MusicData;
#if defined(AUDIO_STANDALONE)
typedef enum { INFO = 0, ERROR, WARNING, DEBUG, OTHER } TraceLogType;
typedef enum { LOG_INFO = 0, LOG_ERROR, LOG_WARNING, LOG_DEBUG, LOG_OTHER } TraceLogType;
#endif
//----------------------------------------------------------------------------------
@ -193,7 +193,7 @@ static Wave LoadFLAC(const char *fileName); // Load FLAC file
#if defined(AUDIO_STANDALONE)
bool IsFileExtension(const char *fileName, const char *ext); // Check file extension
void TraceLog(int msgType, const char *text, ...); // Outputs trace log message (INFO, ERROR, WARNING)
void TraceLog(int msgType, const char *text, ...); // Show trace log messages (LOG_INFO, LOG_WARNING, LOG_ERROR, LOG_DEBUG)
#endif
//----------------------------------------------------------------------------------
@ -206,7 +206,7 @@ void InitAudioDevice(void)
// Open and initialize a device with default settings
ALCdevice *device = alcOpenDevice(NULL);
if (!device) TraceLog(ERROR, "Audio device could not be opened");
if (!device) TraceLog(LOG_ERROR, "Audio device could not be opened");
else
{
ALCcontext *context = alcCreateContext(device, NULL);
@ -217,11 +217,11 @@ void InitAudioDevice(void)
alcCloseDevice(device);
TraceLog(ERROR, "Could not initialize audio context");
TraceLog(LOG_ERROR, "Could not initialize audio context");
}
else
{
TraceLog(INFO, "Audio device and context initialized successfully: %s", alcGetString(device, ALC_DEVICE_SPECIFIER));
TraceLog(LOG_INFO, "Audio device and context initialized successfully: %s", alcGetString(device, ALC_DEVICE_SPECIFIER));
// Listener definition (just for 2D)
alListener3f(AL_POSITION, 0.0f, 0.0f, 0.0f);
@ -239,7 +239,7 @@ void CloseAudioDevice(void)
ALCdevice *device;
ALCcontext *context = alcGetCurrentContext();
if (context == NULL) TraceLog(WARNING, "Could not get current audio context for closing");
if (context == NULL) TraceLog(LOG_WARNING, "Could not get current audio context for closing");
device = alcGetContextsDevice(context);
@ -247,7 +247,7 @@ void CloseAudioDevice(void)
alcDestroyContext(context);
alcCloseDevice(device);
TraceLog(INFO, "Audio device closed successfully");
TraceLog(LOG_INFO, "Audio device closed successfully");
}
// Check if device has been initialized successfully
@ -298,12 +298,12 @@ Wave LoadWave(const char *fileName)
// NOTE: Parameters for RRES_TYPE_WAVE are: sampleCount, sampleRate, sampleSize, channels
if (rres[0].type == RRES_TYPE_WAVE) wave = LoadWaveEx(rres[0].data, rres[0].param1, rres[0].param2, rres[0].param3, rres[0].param4);
else TraceLog(WARNING, "[%s] Resource file does not contain wave data", fileName);
else TraceLog(LOG_WARNING, "[%s] Resource file does not contain wave data", fileName);
UnloadResource(rres);
}
#endif
else TraceLog(WARNING, "[%s] Audio fileformat not supported, it can't be loaded", fileName);
else TraceLog(LOG_WARNING, "[%s] Audio fileformat not supported, it can't be loaded", fileName);
return wave;
}
@ -358,7 +358,7 @@ Sound LoadSoundFromWave(Wave wave)
case 8: format = AL_FORMAT_MONO8; break;
case 16: format = AL_FORMAT_MONO16; break;
case 32: format = AL_FORMAT_MONO_FLOAT32; break; // Requires OpenAL extension: AL_EXT_FLOAT32
default: TraceLog(WARNING, "Wave sample size not supported: %i", wave.sampleSize); break;
default: TraceLog(LOG_WARNING, "Wave sample size not supported: %i", wave.sampleSize); break;
}
}
else if (wave.channels == 2)
@ -368,10 +368,10 @@ Sound LoadSoundFromWave(Wave wave)
case 8: format = AL_FORMAT_STEREO8; break;
case 16: format = AL_FORMAT_STEREO16; break;
case 32: format = AL_FORMAT_STEREO_FLOAT32; break; // Requires OpenAL extension: AL_EXT_FLOAT32
default: TraceLog(WARNING, "Wave sample size not supported: %i", wave.sampleSize); break;
default: TraceLog(LOG_WARNING, "Wave sample size not supported: %i", wave.sampleSize); break;
}
}
else TraceLog(WARNING, "Wave number of channels not supported: %i", wave.channels);
else TraceLog(LOG_WARNING, "Wave number of channels not supported: %i", wave.channels);
// Create an audio source
ALuint source;
@ -396,7 +396,7 @@ Sound LoadSoundFromWave(Wave wave)
// Attach sound buffer to source
alSourcei(source, AL_BUFFER, buffer);
TraceLog(INFO, "[SND ID %i][BUFR ID %i] Sound data loaded successfully (%i Hz, %i bit, %s)", source, buffer, wave.sampleRate, wave.sampleSize, (wave.channels == 1) ? "Mono" : "Stereo");
TraceLog(LOG_INFO, "[SND ID %i][BUFR ID %i] Sound data loaded successfully (%i Hz, %i bit, %s)", source, buffer, wave.sampleRate, wave.sampleSize, (wave.channels == 1) ? "Mono" : "Stereo");
sound.source = source;
sound.buffer = buffer;
@ -411,7 +411,7 @@ void UnloadWave(Wave wave)
{
if (wave.data != NULL) free(wave.data);
TraceLog(INFO, "Unloaded wave data from RAM");
TraceLog(LOG_INFO, "Unloaded wave data from RAM");
}
// Unload sound
@ -422,7 +422,7 @@ void UnloadSound(Sound sound)
alDeleteSources(1, &sound.source);
alDeleteBuffers(1, &sound.buffer);
TraceLog(INFO, "[SND ID %i][BUFR ID %i] Unloaded sound data from RAM", sound.source, sound.buffer);
TraceLog(LOG_INFO, "[SND ID %i][BUFR ID %i] Unloaded sound data from RAM", sound.source, sound.buffer);
}
// Update sound buffer with new data
@ -434,9 +434,9 @@ void UpdateSound(Sound sound, const void *data, int samplesCount)
alGetBufferi(sound.buffer, AL_BITS, &sampleSize); // It could also be retrieved from sound.format
alGetBufferi(sound.buffer, AL_CHANNELS, &channels); // It could also be retrieved from sound.format
TraceLog(DEBUG, "UpdateSound() : AL_FREQUENCY: %i", sampleRate);
TraceLog(DEBUG, "UpdateSound() : AL_BITS: %i", sampleSize);
TraceLog(DEBUG, "UpdateSound() : AL_CHANNELS: %i", channels);
TraceLog(LOG_DEBUG, "UpdateSound() : AL_FREQUENCY: %i", sampleRate);
TraceLog(LOG_DEBUG, "UpdateSound() : AL_BITS: %i", sampleSize);
TraceLog(LOG_DEBUG, "UpdateSound() : AL_CHANNELS: %i", channels);
unsigned int dataSize = samplesCount*channels*sampleSize/8; // Size of data in bytes
@ -457,7 +457,7 @@ void PlaySound(Sound sound)
{
alSourcePlay(sound.source); // Play the sound
//TraceLog(INFO, "Playing sound");
//TraceLog(LOG_INFO, "Playing sound");
// Find the current position of the sound being played
// NOTE: Only work when the entire file is in a single buffer
@ -639,7 +639,7 @@ void WaveCrop(Wave *wave, int initSample, int finalSample)
free(wave->data);
wave->data = data;
}
else TraceLog(WARNING, "Wave crop range out of bounds");
else TraceLog(LOG_WARNING, "Wave crop range out of bounds");
}
// Get samples data from wave as a floats array
@ -675,7 +675,7 @@ Music LoadMusicStream(const char *fileName)
// Open ogg audio stream
music->ctxOgg = stb_vorbis_open_filename(fileName, NULL, NULL);
if (music->ctxOgg == NULL) TraceLog(WARNING, "[%s] OGG audio file could not be opened", fileName);
if (music->ctxOgg == NULL) TraceLog(LOG_WARNING, "[%s] OGG audio file could not be opened", fileName);
else
{
stb_vorbis_info info = stb_vorbis_get_info(music->ctxOgg); // Get Ogg file info
@ -687,10 +687,10 @@ Music LoadMusicStream(const char *fileName)
music->ctxType = MUSIC_AUDIO_OGG;
music->loopCount = -1; // Infinite loop by default
TraceLog(DEBUG, "[%s] FLAC total samples: %i", fileName, music->totalSamples);
TraceLog(DEBUG, "[%s] OGG sample rate: %i", fileName, info.sample_rate);
TraceLog(DEBUG, "[%s] OGG channels: %i", fileName, info.channels);
TraceLog(DEBUG, "[%s] OGG memory required: %i", fileName, info.temp_memory_required);
TraceLog(LOG_DEBUG, "[%s] FLAC total samples: %i", fileName, music->totalSamples);
TraceLog(LOG_DEBUG, "[%s] OGG sample rate: %i", fileName, info.sample_rate);
TraceLog(LOG_DEBUG, "[%s] OGG channels: %i", fileName, info.channels);
TraceLog(LOG_DEBUG, "[%s] OGG memory required: %i", fileName, info.temp_memory_required);
}
}
#if defined(SUPPORT_FILEFORMAT_FLAC)
@ -698,7 +698,7 @@ Music LoadMusicStream(const char *fileName)
{
music->ctxFlac = drflac_open_file(fileName);
if (music->ctxFlac == NULL) TraceLog(WARNING, "[%s] FLAC audio file could not be opened", fileName);
if (music->ctxFlac == NULL) TraceLog(LOG_WARNING, "[%s] FLAC audio file could not be opened", fileName);
else
{
music->stream = InitAudioStream(music->ctxFlac->sampleRate, music->ctxFlac->bitsPerSample, music->ctxFlac->channels);
@ -707,10 +707,10 @@ Music LoadMusicStream(const char *fileName)
music->ctxType = MUSIC_AUDIO_FLAC;
music->loopCount = -1; // Infinite loop by default
TraceLog(DEBUG, "[%s] FLAC total samples: %i", fileName, music->totalSamples);
TraceLog(DEBUG, "[%s] FLAC sample rate: %i", fileName, music->ctxFlac->sampleRate);
TraceLog(DEBUG, "[%s] FLAC bits per sample: %i", fileName, music->ctxFlac->bitsPerSample);
TraceLog(DEBUG, "[%s] FLAC channels: %i", fileName, music->ctxFlac->channels);
TraceLog(LOG_DEBUG, "[%s] FLAC total samples: %i", fileName, music->totalSamples);
TraceLog(LOG_DEBUG, "[%s] FLAC sample rate: %i", fileName, music->ctxFlac->sampleRate);
TraceLog(LOG_DEBUG, "[%s] FLAC bits per sample: %i", fileName, music->ctxFlac->bitsPerSample);
TraceLog(LOG_DEBUG, "[%s] FLAC channels: %i", fileName, music->ctxFlac->channels);
}
}
#endif
@ -730,10 +730,10 @@ Music LoadMusicStream(const char *fileName)
music->ctxType = MUSIC_MODULE_XM;
music->loopCount = -1; // Infinite loop by default
TraceLog(DEBUG, "[%s] XM number of samples: %i", fileName, music->totalSamples);
TraceLog(DEBUG, "[%s] XM track length: %11.6f sec", fileName, (float)music->totalSamples/48000.0f);
TraceLog(LOG_DEBUG, "[%s] XM number of samples: %i", fileName, music->totalSamples);
TraceLog(LOG_DEBUG, "[%s] XM track length: %11.6f sec", fileName, (float)music->totalSamples/48000.0f);
}
else TraceLog(WARNING, "[%s] XM file could not be opened", fileName);
else TraceLog(LOG_WARNING, "[%s] XM file could not be opened", fileName);
}
#endif
#if defined(SUPPORT_FILEFORMAT_MOD)
@ -749,13 +749,13 @@ Music LoadMusicStream(const char *fileName)
music->ctxType = MUSIC_MODULE_MOD;
music->loopCount = -1; // Infinite loop by default
TraceLog(DEBUG, "[%s] MOD number of samples: %i", fileName, music->samplesLeft);
TraceLog(DEBUG, "[%s] MOD track length: %11.6f sec", fileName, (float)music->totalSamples/48000.0f);
TraceLog(LOG_DEBUG, "[%s] MOD number of samples: %i", fileName, music->samplesLeft);
TraceLog(LOG_DEBUG, "[%s] MOD track length: %11.6f sec", fileName, (float)music->totalSamples/48000.0f);
}
else TraceLog(WARNING, "[%s] MOD file could not be opened", fileName);
else TraceLog(LOG_WARNING, "[%s] MOD file could not be opened", fileName);
}
#endif
else TraceLog(WARNING, "[%s] Audio fileformat not supported, it can't be loaded", fileName);
else TraceLog(LOG_WARNING, "[%s] Audio fileformat not supported, it can't be loaded", fileName);
return music;
}
@ -799,7 +799,7 @@ void ResumeMusicStream(Music music)
if (state == AL_PAUSED)
{
TraceLog(INFO, "[AUD ID %i] Resume music stream playing", music->stream.source);
TraceLog(LOG_INFO, "[AUD ID %i] Resume music stream playing", music->stream.source);
alSourcePlay(music->stream.source);
}
}
@ -992,7 +992,7 @@ AudioStream InitAudioStream(unsigned int sampleRate, unsigned int sampleSize, un
if ((channels > 0) && (channels < 3)) stream.channels = channels;
else
{
TraceLog(WARNING, "Init audio stream: Number of channels not supported: %i", channels);
TraceLog(LOG_WARNING, "Init audio stream: Number of channels not supported: %i", channels);
stream.channels = 1; // Fallback to mono channel
}
@ -1004,7 +1004,7 @@ AudioStream InitAudioStream(unsigned int sampleRate, unsigned int sampleSize, un
case 8: stream.format = AL_FORMAT_MONO8; break;
case 16: stream.format = AL_FORMAT_MONO16; break;
case 32: stream.format = AL_FORMAT_MONO_FLOAT32; break; // Requires OpenAL extension: AL_EXT_FLOAT32
default: TraceLog(WARNING, "Init audio stream: Sample size not supported: %i", sampleSize); break;
default: TraceLog(LOG_WARNING, "Init audio stream: Sample size not supported: %i", sampleSize); break;
}
}
else if (stream.channels == 2)
@ -1014,7 +1014,7 @@ AudioStream InitAudioStream(unsigned int sampleRate, unsigned int sampleSize, un
case 8: stream.format = AL_FORMAT_STEREO8; break;
case 16: stream.format = AL_FORMAT_STEREO16; break;
case 32: stream.format = AL_FORMAT_STEREO_FLOAT32; break; // Requires OpenAL extension: AL_EXT_FLOAT32
default: TraceLog(WARNING, "Init audio stream: Sample size not supported: %i", sampleSize); break;
default: TraceLog(LOG_WARNING, "Init audio stream: Sample size not supported: %i", sampleSize); break;
}
}
@ -1041,7 +1041,7 @@ AudioStream InitAudioStream(unsigned int sampleRate, unsigned int sampleSize, un
alSourceQueueBuffers(stream.source, MAX_STREAM_BUFFERS, stream.buffers);
TraceLog(INFO, "[AUD ID %i] Audio stream loaded successfully (%i Hz, %i bit, %s)", stream.source, stream.sampleRate, stream.sampleSize, (stream.channels == 1) ? "Mono" : "Stereo");
TraceLog(LOG_INFO, "[AUD ID %i] Audio stream loaded successfully (%i Hz, %i bit, %s)", stream.source, stream.sampleRate, stream.sampleSize, (stream.channels == 1) ? "Mono" : "Stereo");
return stream;
}
@ -1068,7 +1068,7 @@ void CloseAudioStream(AudioStream stream)
alDeleteSources(1, &stream.source);
alDeleteBuffers(MAX_STREAM_BUFFERS, stream.buffers);
TraceLog(INFO, "[AUD ID %i] Unloaded audio stream data", stream.source);
TraceLog(LOG_INFO, "[AUD ID %i] Unloaded audio stream data", stream.source);
}
// Update audio stream buffers with data
@ -1085,7 +1085,7 @@ void UpdateAudioStream(AudioStream stream, const void *data, int samplesCount)
alBufferData(buffer, stream.format, data, samplesCount*stream.sampleSize/8*stream.channels, stream.sampleRate);
alSourceQueueBuffers(stream.source, 1, &buffer);
}
else TraceLog(WARNING, "[AUD ID %i] Audio buffer not available for unqueuing", stream.source);
else TraceLog(LOG_WARNING, "[AUD ID %i] Audio buffer not available for unqueuing", stream.source);
}
// Check if any audio stream buffers requires refill
@ -1168,7 +1168,7 @@ static Wave LoadWAV(const char *fileName)
if (wavFile == NULL)
{
TraceLog(WARNING, "[%s] WAV file could not be opened", fileName);
TraceLog(LOG_WARNING, "[%s] WAV file could not be opened", fileName);
wave.data = NULL;
}
else
@ -1180,7 +1180,7 @@ static Wave LoadWAV(const char *fileName)
if (strncmp(wavRiffHeader.chunkID, "RIFF", 4) ||
strncmp(wavRiffHeader.format, "WAVE", 4))
{
TraceLog(WARNING, "[%s] Invalid RIFF or WAVE Header", fileName);
TraceLog(LOG_WARNING, "[%s] Invalid RIFF or WAVE Header", fileName);
}
else
{
@ -1191,7 +1191,7 @@ static Wave LoadWAV(const char *fileName)
if ((wavFormat.subChunkID[0] != 'f') || (wavFormat.subChunkID[1] != 'm') ||
(wavFormat.subChunkID[2] != 't') || (wavFormat.subChunkID[3] != ' '))
{
TraceLog(WARNING, "[%s] Invalid Wave format", fileName);
TraceLog(LOG_WARNING, "[%s] Invalid Wave format", fileName);
}
else
{
@ -1205,7 +1205,7 @@ static Wave LoadWAV(const char *fileName)
if ((wavData.subChunkID[0] != 'd') || (wavData.subChunkID[1] != 'a') ||
(wavData.subChunkID[2] != 't') || (wavData.subChunkID[3] != 'a'))
{
TraceLog(WARNING, "[%s] Invalid data header", fileName);
TraceLog(LOG_WARNING, "[%s] Invalid data header", fileName);
}
else
{
@ -1223,7 +1223,7 @@ static Wave LoadWAV(const char *fileName)
// NOTE: Only support 8 bit, 16 bit and 32 bit sample sizes
if ((wave.sampleSize != 8) && (wave.sampleSize != 16) && (wave.sampleSize != 32))
{
TraceLog(WARNING, "[%s] WAV sample size (%ibit) not supported, converted to 16bit", fileName, wave.sampleSize);
TraceLog(LOG_WARNING, "[%s] WAV sample size (%ibit) not supported, converted to 16bit", fileName, wave.sampleSize);
WaveFormat(&wave, wave.sampleRate, 16, wave.channels);
}
@ -1231,13 +1231,13 @@ static Wave LoadWAV(const char *fileName)
if (wave.channels > 2)
{
WaveFormat(&wave, wave.sampleRate, wave.sampleSize, 2);
TraceLog(WARNING, "[%s] WAV channels number (%i) not supported, converted to 2 channels", fileName, wave.channels);
TraceLog(LOG_WARNING, "[%s] WAV channels number (%i) not supported, converted to 2 channels", fileName, wave.channels);
}
// NOTE: subChunkSize comes in bytes, we need to translate it to number of samples
wave.sampleCount = (wavData.subChunkSize/(wave.sampleSize/8))/wave.channels;
TraceLog(INFO, "[%s] WAV file loaded successfully (%i Hz, %i bit, %s)", fileName, wave.sampleRate, wave.sampleSize, (wave.channels == 1) ? "Mono" : "Stereo");
TraceLog(LOG_INFO, "[%s] WAV file loaded successfully (%i Hz, %i bit, %s)", fileName, wave.sampleRate, wave.sampleSize, (wave.channels == 1) ? "Mono" : "Stereo");
}
}
}
@ -1258,7 +1258,7 @@ static Wave LoadOGG(const char *fileName)
stb_vorbis *oggFile = stb_vorbis_open_filename(fileName, NULL, NULL);
if (oggFile == NULL) TraceLog(WARNING, "[%s] OGG file could not be opened", fileName);
if (oggFile == NULL) TraceLog(LOG_WARNING, "[%s] OGG file could not be opened", fileName);
else
{
stb_vorbis_info info = stb_vorbis_get_info(oggFile);
@ -1269,16 +1269,16 @@ static Wave LoadOGG(const char *fileName)
wave.sampleCount = (int)stb_vorbis_stream_length_in_samples(oggFile); // Independent by channel
float totalSeconds = stb_vorbis_stream_length_in_seconds(oggFile);
if (totalSeconds > 10) TraceLog(WARNING, "[%s] Ogg audio length is larger than 10 seconds (%f), that's a big file in memory, consider music streaming", fileName, totalSeconds);
if (totalSeconds > 10) TraceLog(LOG_WARNING, "[%s] Ogg audio length is larger than 10 seconds (%f), that's a big file in memory, consider music streaming", fileName, totalSeconds);
wave.data = (short *)malloc(wave.sampleCount*wave.channels*sizeof(short));
// NOTE: Returns the number of samples to process (be careful! we ask for number of shorts!)
int numSamplesOgg = stb_vorbis_get_samples_short_interleaved(oggFile, info.channels, (short *)wave.data, wave.sampleCount*wave.channels);
TraceLog(DEBUG, "[%s] Samples obtained: %i", fileName, numSamplesOgg);
TraceLog(LOG_DEBUG, "[%s] Samples obtained: %i", fileName, numSamplesOgg);
TraceLog(INFO, "[%s] OGG file loaded successfully (%i Hz, %i bit, %s)", fileName, wave.sampleRate, wave.sampleSize, (wave.channels == 1) ? "Mono" : "Stereo");
TraceLog(LOG_INFO, "[%s] OGG file loaded successfully (%i Hz, %i bit, %s)", fileName, wave.sampleRate, wave.sampleSize, (wave.channels == 1) ? "Mono" : "Stereo");
stb_vorbis_close(oggFile);
}
@ -1302,10 +1302,10 @@ static Wave LoadFLAC(const char *fileName)
wave.sampleSize = 16;
// NOTE: Only support up to 2 channels (mono, stereo)
if (wave.channels > 2) TraceLog(WARNING, "[%s] FLAC channels number (%i) not supported", fileName, wave.channels);
if (wave.channels > 2) TraceLog(LOG_WARNING, "[%s] FLAC channels number (%i) not supported", fileName, wave.channels);
if (wave.data == NULL) TraceLog(WARNING, "[%s] FLAC data could not be loaded", fileName);
else TraceLog(INFO, "[%s] FLAC file loaded successfully (%i Hz, %i bit, %s)", fileName, wave.sampleRate, wave.sampleSize, (wave.channels == 1) ? "Mono" : "Stereo");
if (wave.data == NULL) TraceLog(LOG_WARNING, "[%s] FLAC data could not be loaded", fileName);
else TraceLog(LOG_INFO, "[%s] FLAC file loaded successfully (%i Hz, %i bit, %s)", fileName, wave.sampleRate, wave.sampleSize, (wave.channels == 1) ? "Mono" : "Stereo");
return wave;
}
@ -1327,35 +1327,26 @@ bool IsFileExtension(const char *fileName, const char *ext)
return result;
}
// Outputs a trace log message (INFO, ERROR, WARNING)
// NOTE: If a file has been init, output log is written there
// Show trace log messages (LOG_INFO, LOG_WARNING, LOG_ERROR, LOG_DEBUG)
void TraceLog(int msgType, const char *text, ...)
{
va_list args;
int traceDebugMsgs = 0;
#if defined(DO_NOT_TRACE_DEBUG_MSGS)
traceDebugMsgs = 0;
#endif
va_start(args, text);
switch (msgType)
{
case INFO: fprintf(stdout, "INFO: "); break;
case ERROR: fprintf(stdout, "ERROR: "); break;
case WARNING: fprintf(stdout, "WARNING: "); break;
case DEBUG: if (traceDebugMsgs) fprintf(stdout, "DEBUG: "); break;
case LOG_INFO: fprintf(stdout, "INFO: "); break;
case LOG_ERROR: fprintf(stdout, "ERROR: "); break;
case LOG_WARNING: fprintf(stdout, "WARNING: "); break;
case LOG_DEBUG: fprintf(stdout, "DEBUG: "); break;
default: break;
}
if ((msgType != DEBUG) || ((msgType == DEBUG) && (traceDebugMsgs)))
{
va_start(args, text);
vfprintf(stdout, text, args);
fprintf(stdout, "\n");
va_end(args);
fprintf(stdout, "\n");
}
if (msgType == ERROR) exit(1); // If ERROR message, exit program
if (msgType == LOG_ERROR) exit(1);
}
#endif

View file

@ -412,7 +412,7 @@ static void *GamepadThread(void *arg); // Mouse reading thread
// Initialize window and OpenGL context
void InitWindow(int width, int height, const char *title)
{
TraceLog(INFO, "Initializing raylib (v1.7.0)");
TraceLog(LOG_INFO, "Initializing raylib (v1.7.0)");
// Store window title (could be useful...)
windowTitle = title;
@ -475,7 +475,7 @@ void InitWindow(int width, int height, const char *title)
// Initialize Android activity
void InitWindow(int width, int height, void *state)
{
TraceLog(INFO, "Initializing raylib (v1.7.0)");
TraceLog(LOG_INFO, "Initializing raylib (v1.7.0)");
app_dummy();
@ -491,19 +491,19 @@ void InitWindow(int width, int height, void *state)
int orientation = AConfiguration_getOrientation(app->config);
if (orientation == ACONFIGURATION_ORIENTATION_PORT) TraceLog(INFO, "PORTRAIT window orientation");
else if (orientation == ACONFIGURATION_ORIENTATION_LAND) TraceLog(INFO, "LANDSCAPE window orientation");
if (orientation == ACONFIGURATION_ORIENTATION_PORT) TraceLog(LOG_INFO, "PORTRAIT window orientation");
else if (orientation == ACONFIGURATION_ORIENTATION_LAND) TraceLog(LOG_INFO, "LANDSCAPE window orientation");
// TODO: Automatic orientation doesn't seem to work
if (width <= height)
{
AConfiguration_setOrientation(app->config, ACONFIGURATION_ORIENTATION_PORT);
TraceLog(WARNING, "Window set to portraid mode");
TraceLog(LOG_WARNING, "Window set to portraid mode");
}
else
{
AConfiguration_setOrientation(app->config, ACONFIGURATION_ORIENTATION_LAND);
TraceLog(WARNING, "Window set to landscape mode");
TraceLog(LOG_WARNING, "Window set to landscape mode");
}
//AConfiguration_getDensity(app->config);
@ -517,7 +517,7 @@ void InitWindow(int width, int height, void *state)
InitAssetManager(app->activity->assetManager);
TraceLog(INFO, "Android app initialized successfully");
TraceLog(LOG_INFO, "Android app initialized successfully");
// Wait for window to be initialized (display and context)
while (!windowReady)
@ -596,7 +596,7 @@ void CloseWindow(void)
pthread_join(gamepadThreadId, NULL);
#endif
TraceLog(INFO, "Window closed successfully");
TraceLog(LOG_INFO, "Window closed successfully");
}
// Check if KEY_ESCAPE pressed or Close icon pressed
@ -636,7 +636,7 @@ void ToggleFullscreen(void)
#endif
#if defined(PLATFORM_ANDROID) || defined(PLATFORM_RPI)
TraceLog(WARNING, "Could not toggle to windowed mode");
TraceLog(LOG_WARNING, "Could not toggle to windowed mode");
#endif
}
@ -677,9 +677,9 @@ void SetWindowMonitor(int monitor)
if ((monitor >= 0) && (monitor < monitorCount))
{
glfwSetWindowMonitor(window, monitors[monitor], 0, 0, screenWidth, screenHeight, GLFW_DONT_CARE);
TraceLog(INFO, "Selected fullscreen monitor: [%i] %s", monitor, glfwGetMonitorName(monitors[monitor]));
TraceLog(LOG_INFO, "Selected fullscreen monitor: [%i] %s", monitor, glfwGetMonitorName(monitors[monitor]));
}
else TraceLog(WARNING, "Selected monitor not found");
else TraceLog(LOG_WARNING, "Selected monitor not found");
#endif
}
@ -977,7 +977,7 @@ Ray GetMouseRay(Vector2 mousePosition, Camera camera)
// Store values in a vector
Vector3 deviceCoords = { x, y, z };
TraceLog(DEBUG, "Device coordinates: (%f, %f, %f)", deviceCoords.x, deviceCoords.y, deviceCoords.z);
TraceLog(LOG_DEBUG, "Device coordinates: (%f, %f, %f)", deviceCoords.x, deviceCoords.y, deviceCoords.z);
// Calculate projection matrix (from perspective instead of frustum)
Matrix matProj = MatrixPerspective(camera.fovy, ((double)GetScreenWidth()/(double)GetScreenHeight()), 0.01, 1000.0);
@ -1069,7 +1069,7 @@ void SetTargetFPS(int fps)
if (fps < 1) targetTime = 0.0;
else targetTime = 1.0/(double)fps;
TraceLog(INFO, "Target time per frame: %02.03f milliseconds", (float)targetTime*1000);
TraceLog(LOG_INFO, "Target time per frame: %02.03f milliseconds", (float)targetTime*1000);
}
// Returns current FPS
@ -1205,7 +1205,7 @@ void TakeScreenshot(const char *fileName)
SavePNG(fileName, imgData, renderWidth, renderHeight, 4); // Save image as PNG
free(imgData);
TraceLog(INFO, "Screenshot taken: %s", fileName);
TraceLog(LOG_INFO, "Screenshot taken: %s", fileName);
#endif
}
@ -1304,7 +1304,7 @@ void StorageSaveValue(int position, int value)
// If file doesn't exist, create a new storage data file
if (!storageFile) storageFile = fopen(path, "wb");
if (!storageFile) TraceLog(WARNING, "Storage data file could not be created");
if (!storageFile) TraceLog(LOG_WARNING, "Storage data file could not be created");
else
{
// Get file size
@ -1312,7 +1312,7 @@ void StorageSaveValue(int position, int value)
int fileSize = ftell(storageFile); // Size in bytes
fseek(storageFile, 0, SEEK_SET);
if (fileSize < (position*4)) TraceLog(WARNING, "Storage position could not be found");
if (fileSize < (position*4)) TraceLog(LOG_WARNING, "Storage position could not be found");
else
{
fseek(storageFile, (position*4), SEEK_SET);
@ -1341,7 +1341,7 @@ int StorageLoadValue(int position)
// Try open existing file to append data
FILE *storageFile = fopen(path, "rb");
if (!storageFile) TraceLog(WARNING, "Storage data file could not be found");
if (!storageFile) TraceLog(LOG_WARNING, "Storage data file could not be found");
else
{
// Get file size
@ -1349,7 +1349,7 @@ int StorageLoadValue(int position)
int fileSize = ftell(storageFile); // Size in bytes
rewind(storageFile);
if (fileSize < (position*4)) TraceLog(WARNING, "Storage position could not be found");
if (fileSize < (position*4)) TraceLog(LOG_WARNING, "Storage position could not be found");
else
{
fseek(storageFile, (position*4), SEEK_SET);
@ -1675,7 +1675,7 @@ Vector2 GetTouchPosition(int index)
#if defined(PLATFORM_ANDROID) || defined(PLATFORM_WEB)
if (index < MAX_TOUCH_POINTS) position = touchPosition[index];
else TraceLog(WARNING, "Required touch point out of range (Max touch points: %i)", MAX_TOUCH_POINTS);
else TraceLog(LOG_WARNING, "Required touch point out of range (Max touch points: %i)", MAX_TOUCH_POINTS);
if ((screenWidth > displayWidth) || (screenHeight > displayHeight))
{
@ -1716,7 +1716,7 @@ static void InitGraphicsDevice(int width, int height)
#if defined(PLATFORM_DESKTOP) || defined(PLATFORM_WEB)
glfwSetErrorCallback(ErrorCallback);
if (!glfwInit()) TraceLog(ERROR, "Failed to initialize GLFW");
if (!glfwInit()) TraceLog(LOG_ERROR, "Failed to initialize GLFW");
// NOTE: Getting video modes is not implemented in emscripten GLFW3 version
#if defined(PLATFORM_DESKTOP)
@ -1752,7 +1752,7 @@ static void InitGraphicsDevice(int width, int height)
if (configFlags & FLAG_MSAA_4X_HINT)
{
glfwWindowHint(GLFW_SAMPLES, 4); // Enables multisampling x4 (MSAA), default is 0
TraceLog(INFO, "Trying to enable MSAA x4");
TraceLog(LOG_INFO, "Trying to enable MSAA x4");
}
//glfwWindowHint(GLFW_RED_BITS, 8); // Framebuffer red color component bits
@ -1805,7 +1805,7 @@ static void InitGraphicsDevice(int width, int height)
}
}
TraceLog(WARNING, "Closest fullscreen videomode: %i x %i", displayWidth, displayHeight);
TraceLog(LOG_WARNING, "Closest fullscreen videomode: %i x %i", displayWidth, displayHeight);
// NOTE: ISSUE: Closest videomode could not match monitor aspect-ratio, for example,
// for a desired screen size of 800x450 (16:9), closest supported videomode is 800x600 (4:3),
@ -1844,17 +1844,17 @@ static void InitGraphicsDevice(int width, int height)
if (!window)
{
glfwTerminate();
TraceLog(ERROR, "GLFW Failed to initialize Window");
TraceLog(LOG_ERROR, "GLFW Failed to initialize Window");
}
else
{
TraceLog(INFO, "Display device initialized successfully");
TraceLog(LOG_INFO, "Display device initialized successfully");
#if defined(PLATFORM_DESKTOP)
TraceLog(INFO, "Display size: %i x %i", displayWidth, displayHeight);
TraceLog(LOG_INFO, "Display size: %i x %i", displayWidth, displayHeight);
#endif
TraceLog(INFO, "Render size: %i x %i", renderWidth, renderHeight);
TraceLog(INFO, "Screen size: %i x %i", screenWidth, screenHeight);
TraceLog(INFO, "Viewport offsets: %i, %i", renderOffsetX, renderOffsetY);
TraceLog(LOG_INFO, "Render size: %i x %i", renderWidth, renderHeight);
TraceLog(LOG_INFO, "Screen size: %i x %i", screenWidth, screenHeight);
TraceLog(LOG_INFO, "Viewport offsets: %i, %i", renderOffsetX, renderOffsetY);
}
glfwSetWindowSizeCallback(window, WindowSizeCallback); // NOTE: Resizing not allowed by default!
@ -1886,7 +1886,7 @@ static void InitGraphicsDevice(int width, int height)
if (configFlags & FLAG_VSYNC_HINT)
{
glfwSwapInterval(1);
TraceLog(INFO, "Trying to enable VSYNC");
TraceLog(LOG_INFO, "Trying to enable VSYNC");
}
#endif // defined(PLATFORM_DESKTOP) || defined(PLATFORM_WEB)
@ -1914,7 +1914,7 @@ static void InitGraphicsDevice(int width, int height)
{
samples = 4;
sampleBuffer = 1;
TraceLog(INFO, "Trying to enable MSAA x4");
TraceLog(LOG_INFO, "Trying to enable MSAA x4");
}
const EGLint framebufferAttribs[] =
@ -2022,7 +2022,7 @@ static void InitGraphicsDevice(int width, int height)
if (eglMakeCurrent(display, surface, surface, context) == EGL_FALSE)
{
TraceLog(ERROR, "Unable to attach EGL rendering context to EGL surface");
TraceLog(LOG_ERROR, "Unable to attach EGL rendering context to EGL surface");
}
else
{
@ -2030,11 +2030,11 @@ static void InitGraphicsDevice(int width, int height)
//eglQuerySurface(display, surface, EGL_WIDTH, &renderWidth);
//eglQuerySurface(display, surface, EGL_HEIGHT, &renderHeight);
TraceLog(INFO, "Display device initialized successfully");
TraceLog(INFO, "Display size: %i x %i", displayWidth, displayHeight);
TraceLog(INFO, "Render size: %i x %i", renderWidth, renderHeight);
TraceLog(INFO, "Screen size: %i x %i", screenWidth, screenHeight);
TraceLog(INFO, "Viewport offsets: %i, %i", renderOffsetX, renderOffsetY);
TraceLog(LOG_INFO, "Display device initialized successfully");
TraceLog(LOG_INFO, "Display size: %i x %i", displayWidth, displayHeight);
TraceLog(LOG_INFO, "Render size: %i x %i", renderWidth, renderHeight);
TraceLog(LOG_INFO, "Screen size: %i x %i", screenWidth, screenHeight);
TraceLog(LOG_INFO, "Viewport offsets: %i, %i", renderOffsetX, renderOffsetY);
}
#endif // defined(PLATFORM_ANDROID) || defined(PLATFORM_RPI)
@ -2085,7 +2085,7 @@ static void SetupFramebufferSize(int displayWidth, int displayHeight)
// Calculate renderWidth and renderHeight, we have the display size (input params) and the desired screen size (global var)
if ((screenWidth > displayWidth) || (screenHeight > displayHeight))
{
TraceLog(WARNING, "DOWNSCALING: Required screen size (%ix%i) is bigger than display size (%ix%i)", screenWidth, screenHeight, displayWidth, displayHeight);
TraceLog(LOG_WARNING, "DOWNSCALING: Required screen size (%ix%i) is bigger than display size (%ix%i)", screenWidth, screenHeight, displayWidth, displayHeight);
// Downscaling to fit display with border-bars
float widthRatio = (float)displayWidth/(float)screenWidth;
@ -2116,12 +2116,12 @@ static void SetupFramebufferSize(int displayWidth, int displayHeight)
renderWidth = displayWidth;
renderHeight = displayHeight;
TraceLog(WARNING, "Downscale matrix generated, content will be rendered at: %i x %i", renderWidth, renderHeight);
TraceLog(LOG_WARNING, "Downscale matrix generated, content will be rendered at: %i x %i", renderWidth, renderHeight);
}
else if ((screenWidth < displayWidth) || (screenHeight < displayHeight))
{
// Required screen size is smaller than display size
TraceLog(INFO, "UPSCALING: Required screen size: %i x %i -> Display size: %i x %i", screenWidth, screenHeight, displayWidth, displayHeight);
TraceLog(LOG_INFO, "UPSCALING: Required screen size: %i x %i -> Display size: %i x %i", screenWidth, screenHeight, displayWidth, displayHeight);
// Upscaling to fit display with border-bars
float displayRatio = (float)displayWidth/(float)displayHeight;
@ -2167,7 +2167,7 @@ static void InitTimer(void)
{
baseTime = (uint64_t)now.tv_sec*1000000000LLU + (uint64_t)now.tv_nsec;
}
else TraceLog(WARNING, "No hi-resolution timer available");
else TraceLog(LOG_WARNING, "No hi-resolution timer available");
#endif
previousTime = GetTime(); // Get time as double
@ -2397,7 +2397,7 @@ static void PollInputEvents(void)
// NOTE: Never close window, native activity is controlled by the system!
if (app->destroyRequested != 0)
{
//TraceLog(INFO, "Closing Window...");
//TraceLog(LOG_INFO, "Closing Window...");
//windowShouldClose = true;
//ANativeActivity_finish(app->activity);
}
@ -2431,7 +2431,7 @@ static void SwapBuffers(void)
// GLFW3 Error Callback, runs on GLFW3 error
static void ErrorCallback(int error, const char *description)
{
TraceLog(WARNING, "[GLFW3 Error] Code: %i Decription: %s", error, description);
TraceLog(LOG_WARNING, "[GLFW3 Error] Code: %i Decription: %s", error, description);
}
// GLFW3 Srolling Callback, runs on mouse wheel
@ -2460,7 +2460,7 @@ static void KeyCallback(GLFWwindow *window, int key, int scancode, int action, i
GifEnd();
gifRecording = false;
TraceLog(INFO, "End animated GIF recording");
TraceLog(LOG_INFO, "End animated GIF recording");
}
else
{
@ -2472,7 +2472,7 @@ static void KeyCallback(GLFWwindow *window, int key, int scancode, int action, i
GifBegin(FormatText("screenrec%03i.gif", screenshotCounter), screenWidth, screenHeight, (int)(GetFrameTime()*10.0f), 8, false);
screenshotCounter++;
TraceLog(INFO, "Begin animated GIF recording: %s", FormatText("screenrec%03i.gif", screenshotCounter));
TraceLog(LOG_INFO, "Begin animated GIF recording: %s", FormatText("screenrec%03i.gif", screenshotCounter));
}
}
else
@ -2557,7 +2557,7 @@ static void CharCallback(GLFWwindow *window, unsigned int key)
{
lastKeyPressed = key;
//TraceLog(INFO, "Char Callback Key pressed: %i\n", key);
//TraceLog(LOG_INFO, "Char Callback Key pressed: %i\n", key);
}
// GLFW3 CursorEnter Callback, when cursor enters the window
@ -2626,15 +2626,15 @@ static void AndroidCommandCallback(struct android_app *app, int32_t cmd)
case APP_CMD_START:
{
//rendering = true;
TraceLog(INFO, "APP_CMD_START");
TraceLog(LOG_INFO, "APP_CMD_START");
} break;
case APP_CMD_RESUME:
{
TraceLog(INFO, "APP_CMD_RESUME");
TraceLog(LOG_INFO, "APP_CMD_RESUME");
} break;
case APP_CMD_INIT_WINDOW:
{
TraceLog(INFO, "APP_CMD_INIT_WINDOW");
TraceLog(LOG_INFO, "APP_CMD_INIT_WINDOW");
if (app->window != NULL)
{
@ -2691,18 +2691,18 @@ static void AndroidCommandCallback(struct android_app *app, int32_t cmd)
} break;
case APP_CMD_GAINED_FOCUS:
{
TraceLog(INFO, "APP_CMD_GAINED_FOCUS");
TraceLog(LOG_INFO, "APP_CMD_GAINED_FOCUS");
appEnabled = true;
//ResumeMusicStream();
} break;
case APP_CMD_PAUSE:
{
TraceLog(INFO, "APP_CMD_PAUSE");
TraceLog(LOG_INFO, "APP_CMD_PAUSE");
} break;
case APP_CMD_LOST_FOCUS:
{
//DrawFrame();
TraceLog(INFO, "APP_CMD_LOST_FOCUS");
TraceLog(LOG_INFO, "APP_CMD_LOST_FOCUS");
appEnabled = false;
//PauseMusicStream();
} break;
@ -2716,22 +2716,22 @@ static void AndroidCommandCallback(struct android_app *app, int32_t cmd)
contextRebindRequired = true;
TraceLog(INFO, "APP_CMD_TERM_WINDOW");
TraceLog(LOG_INFO, "APP_CMD_TERM_WINDOW");
} break;
case APP_CMD_SAVE_STATE:
{
TraceLog(INFO, "APP_CMD_SAVE_STATE");
TraceLog(LOG_INFO, "APP_CMD_SAVE_STATE");
} break;
case APP_CMD_STOP:
{
TraceLog(INFO, "APP_CMD_STOP");
TraceLog(LOG_INFO, "APP_CMD_STOP");
} break;
case APP_CMD_DESTROY:
{
// TODO: Finish activity?
//ANativeActivity_finish(app->activity);
TraceLog(INFO, "APP_CMD_DESTROY");
TraceLog(LOG_INFO, "APP_CMD_DESTROY");
} break;
case APP_CMD_CONFIG_CHANGED:
{
@ -2740,7 +2740,7 @@ static void AndroidCommandCallback(struct android_app *app, int32_t cmd)
// Check screen orientation here!
TraceLog(INFO, "APP_CMD_CONFIG_CHANGED");
TraceLog(LOG_INFO, "APP_CMD_CONFIG_CHANGED");
} break;
default: break;
}
@ -2848,11 +2848,11 @@ static EM_BOOL EmscriptenFullscreenChangeCallback(int eventType, const Emscripte
if (e->isFullscreen)
{
TraceLog(INFO, "Canvas scaled to fullscreen. ElementSize: (%ix%i), ScreenSize(%ix%i)", e->elementWidth, e->elementHeight, e->screenWidth, e->screenHeight);
TraceLog(LOG_INFO, "Canvas scaled to fullscreen. ElementSize: (%ix%i), ScreenSize(%ix%i)", e->elementWidth, e->elementHeight, e->screenWidth, e->screenHeight);
}
else
{
TraceLog(INFO, "Canvas scaled to windowed. ElementSize: (%ix%i), ScreenSize(%ix%i)", e->elementWidth, e->elementHeight, e->screenWidth, e->screenHeight);
TraceLog(LOG_INFO, "Canvas scaled to windowed. ElementSize: (%ix%i), ScreenSize(%ix%i)", e->elementWidth, e->elementHeight, e->screenWidth, e->screenHeight);
}
// TODO: Depending on scaling factor (screen vs element), calculate factor to scale mouse/touch input
@ -2885,7 +2885,7 @@ static EM_BOOL EmscriptenMouseCallback(int eventType, const EmscriptenMouseEvent
{
emscripten_exit_pointerlock();
emscripten_get_pointerlock_status(&plce);
//if (plce.isActive) TraceLog(WARNING, "Pointer lock exit did not work!");
//if (plce.isActive) TraceLog(LOG_WARNING, "Pointer lock exit did not work!");
}
toggleCursorLock = false;
@ -3011,7 +3011,7 @@ static void InitKeyboard(void)
if (ioctl(STDIN_FILENO, KDGKBMODE, &defaultKeyboardMode) < 0)
{
// NOTE: It could mean we are using a remote keyboard through ssh!
TraceLog(WARNING, "Could not change keyboard mode (SSH keyboard?)");
TraceLog(LOG_WARNING, "Could not change keyboard mode (SSH keyboard?)");
}
else
{
@ -3046,7 +3046,7 @@ static void ProcessKeyboard(void)
// Fill all read bytes (looking for keys)
for (int i = 0; i < bufferByteCount; i++)
{
TraceLog(DEBUG, "Bytes on keysBuffer: %i", bufferByteCount);
TraceLog(LOG_DEBUG, "Bytes on keysBuffer: %i", bufferByteCount);
//printf("Key(s) bytes: ");
//for (int i = 0; i < bufferByteCount; i++) printf("0x%02x ", keysBuffer[i]);
@ -3107,7 +3107,7 @@ static void ProcessKeyboard(void)
else if (keysBuffer[i] == 0x7f) currentKeyState[259] = 1; // raylib KEY_BACKSPACE
else
{
TraceLog(DEBUG, "Pressed key (ASCII): 0x%02x", keysBuffer[i]);
TraceLog(LOG_DEBUG, "Pressed key (ASCII): 0x%02x", keysBuffer[i]);
// Translate lowercase a-z letters to A-Z
if ((keysBuffer[i] >= 97) && (keysBuffer[i] <= 122))
@ -3145,7 +3145,7 @@ static void InitMouse(void)
// NOTE: We can use /dev/input/mice to read from all available mice
if ((mouseStream = open(DEFAULT_MOUSE_DEV, O_RDONLY|O_NONBLOCK)) < 0)
{
TraceLog(WARNING, "Mouse device could not be opened, no mouse available");
TraceLog(LOG_WARNING, "Mouse device could not be opened, no mouse available");
}
else
{
@ -3153,8 +3153,8 @@ static void InitMouse(void)
int error = pthread_create(&mouseThreadId, NULL, &MouseThread, NULL);
if (error != 0) TraceLog(WARNING, "Error creating mouse input event thread");
else TraceLog(INFO, "Mouse device initialized successfully");
if (error != 0) TraceLog(LOG_WARNING, "Error creating mouse input event thread");
else TraceLog(LOG_INFO, "Mouse device initialized successfully");
}
}
@ -3224,7 +3224,7 @@ static void InitTouch(void)
{
if ((touchStream = open(DEFAULT_TOUCH_DEV, O_RDONLY|O_NONBLOCK)) < 0)
{
TraceLog(WARNING, "Touch device could not be opened, no touchscreen available");
TraceLog(LOG_WARNING, "Touch device could not be opened, no touchscreen available");
}
else
{
@ -3232,8 +3232,8 @@ static void InitTouch(void)
int error = pthread_create(&touchThreadId, NULL, &TouchThread, NULL);
if (error != 0) TraceLog(WARNING, "Error creating touch input event thread");
else TraceLog(INFO, "Touch device initialized successfully");
if (error != 0) TraceLog(LOG_WARNING, "Error creating touch input event thread");
else TraceLog(LOG_INFO, "Touch device initialized successfully");
}
}
@ -3335,7 +3335,7 @@ static void InitGamepad(void)
if ((gamepadStream[i] = open(gamepadDev, O_RDONLY|O_NONBLOCK)) < 0)
{
// NOTE: Only show message for first gamepad
if (i == 0) TraceLog(WARNING, "Gamepad device could not be opened, no gamepad available");
if (i == 0) TraceLog(LOG_WARNING, "Gamepad device could not be opened, no gamepad available");
}
else
{
@ -3346,8 +3346,8 @@ static void InitGamepad(void)
{
int error = pthread_create(&gamepadThreadId, NULL, &GamepadThread, NULL);
if (error != 0) TraceLog(WARNING, "Error creating gamepad input event thread");
else TraceLog(INFO, "Gamepad device initialized successfully");
if (error != 0) TraceLog(LOG_WARNING, "Error creating gamepad input event thread");
else TraceLog(LOG_INFO, "Gamepad device initialized successfully");
}
}
}
@ -3381,7 +3381,7 @@ static void *GamepadThread(void *arg)
// Process gamepad events by type
if (gamepadEvent.type == JS_EVENT_BUTTON)
{
TraceLog(DEBUG, "Gamepad button: %i, value: %i", gamepadEvent.number, gamepadEvent.value);
TraceLog(LOG_DEBUG, "Gamepad button: %i, value: %i", gamepadEvent.number, gamepadEvent.value);
if (gamepadEvent.number < MAX_GAMEPAD_BUTTONS)
{
@ -3394,7 +3394,7 @@ static void *GamepadThread(void *arg)
}
else if (gamepadEvent.type == JS_EVENT_AXIS)
{
TraceLog(DEBUG, "Gamepad axis: %i, value: %i", gamepadEvent.number, gamepadEvent.value);
TraceLog(LOG_DEBUG, "Gamepad axis: %i, value: %i", gamepadEvent.number, gamepadEvent.value);
if (gamepadEvent.number < MAX_GAMEPAD_AXIS)
{

View file

@ -595,10 +595,10 @@ Mesh LoadMesh(const char *fileName)
#if defined(SUPPORT_FILEFORMAT_OBJ)
if (IsFileExtension(fileName, ".obj")) mesh = LoadOBJ(fileName);
#else
TraceLog(WARNING, "[%s] Mesh fileformat not supported, it can't be loaded", fileName);
TraceLog(LOG_WARNING, "[%s] Mesh fileformat not supported, it can't be loaded", fileName);
#endif
if (mesh.vertexCount == 0) TraceLog(WARNING, "Mesh could not be loaded");
if (mesh.vertexCount == 0) TraceLog(LOG_WARNING, "Mesh could not be loaded");
else rlglLoadMesh(&mesh, false); // Upload vertex data to GPU (static mesh)
// TODO: Initialize default mesh data in case loading fails, maybe a cube?
@ -697,7 +697,7 @@ void UnloadModel(Model model)
UnloadMesh(&model.mesh);
UnloadMaterial(model.material);
TraceLog(INFO, "Unloaded model data (mesh and material) from RAM and VRAM");
TraceLog(LOG_INFO, "Unloaded model data (mesh and material) from RAM and VRAM");
}
// Load material data (from file)
@ -708,7 +708,7 @@ Material LoadMaterial(const char *fileName)
#if defined(SUPPORT_FILEFORMAT_MTL)
if (IsFileExtension(fileName, ".mtl")) material = LoadMTL(fileName);
#else
TraceLog(WARNING, "[%s] Material fileformat not supported, it can't be loaded", fileName);
TraceLog(LOG_WARNING, "[%s] Material fileformat not supported, it can't be loaded", fileName);
#endif
return material;
@ -1628,7 +1628,7 @@ static Mesh LoadOBJ(const char *fileName)
if (objFile == NULL)
{
TraceLog(WARNING, "[%s] OBJ file could not be opened", fileName);
TraceLog(LOG_WARNING, "[%s] OBJ file could not be opened", fileName);
return mesh;
}
@ -1680,10 +1680,10 @@ static Mesh LoadOBJ(const char *fileName)
}
}
TraceLog(DEBUG, "[%s] Model vertices: %i", fileName, vertexCount);
TraceLog(DEBUG, "[%s] Model texcoords: %i", fileName, texcoordCount);
TraceLog(DEBUG, "[%s] Model normals: %i", fileName, normalCount);
TraceLog(DEBUG, "[%s] Model triangles: %i", fileName, triangleCount);
TraceLog(LOG_DEBUG, "[%s] Model vertices: %i", fileName, vertexCount);
TraceLog(LOG_DEBUG, "[%s] Model texcoords: %i", fileName, texcoordCount);
TraceLog(LOG_DEBUG, "[%s] Model normals: %i", fileName, normalCount);
TraceLog(LOG_DEBUG, "[%s] Model triangles: %i", fileName, triangleCount);
// Once we know the number of vertices to store, we create required arrays
Vector3 *midVertices = (Vector3 *)malloc(vertexCount*sizeof(Vector3));
@ -1757,7 +1757,7 @@ static Mesh LoadOBJ(const char *fileName)
rewind(objFile); // Return to the beginning of the file, to read again
if (normalCount == 0) TraceLog(INFO, "[%s] No normals data on OBJ, normals will be generated from faces data", fileName);
if (normalCount == 0) TraceLog(LOG_INFO, "[%s] No normals data on OBJ, normals will be generated from faces data", fileName);
// Third reading pass: Get faces (triangles) data and fill VertexArray
while (!feof(objFile))
@ -1924,7 +1924,7 @@ static Mesh LoadOBJ(const char *fileName)
free(midTexCoords);
// NOTE: At this point we have all vertex, texcoord, normal data for the model in mesh struct
TraceLog(INFO, "[%s] Model loaded successfully in RAM (CPU)", fileName);
TraceLog(LOG_INFO, "[%s] Model loaded successfully in RAM (CPU)", fileName);
return mesh;
}
@ -1950,7 +1950,7 @@ static Material LoadMTL(const char *fileName)
if (mtlFile == NULL)
{
TraceLog(WARNING, "[%s] MTL file could not be opened", fileName);
TraceLog(LOG_WARNING, "[%s] MTL file could not be opened", fileName);
return material;
}
@ -1965,7 +1965,7 @@ static Material LoadMTL(const char *fileName)
// TODO: Support multiple materials in a single .mtl
sscanf(buffer, "newmtl %s", mapFileName);
TraceLog(INFO, "[%s] Loading material...", mapFileName);
TraceLog(LOG_INFO, "[%s] Loading material...", mapFileName);
}
case 'i': // illum int Illumination model
{
@ -2090,7 +2090,7 @@ static Material LoadMTL(const char *fileName)
fclose(mtlFile);
// NOTE: At this point we have all material data
TraceLog(INFO, "[%s] Material loaded successfully", fileName);
TraceLog(LOG_INFO, "[%s] Material loaded successfully", fileName);
return material;
}

View file

@ -1,6 +1,6 @@
/**********************************************************************************************
*
* raylib v1.7.0
* raylib v1.8.0
*
* A simple and easy-to-use library to learn videogames programming (www.raylib.com)
*
@ -533,11 +533,11 @@ typedef struct RRESData *RRES;
//----------------------------------------------------------------------------------
// Trace log type
typedef enum {
INFO = 0,
WARNING,
ERROR,
DEBUG,
OTHER
LOG_INFO = 0,
LOG_WARNING,
LOG_ERROR,
LOG_DEBUG,
LOG_OTHER
} LogType;
// Texture formats
@ -711,11 +711,10 @@ RLAPI float *MatrixToFloat(Matrix mat); // Converts Ma
// Misc. functions
RLAPI void ShowLogo(void); // Activate raylib logo at startup (can be done with flags)
RLAPI void SetConfigFlags(char flags); // Setup window configuration flags (view FLAGS)
RLAPI void TraceLog(int logType, const char *text, ...); // Show trace log messages (INFO, WARNING, ERROR, DEBUG)
RLAPI void TraceLog(int logType, const char *text, ...); // Show trace log messages (LOG_INFO, LOG_WARNING, LOG_ERROR, LOG_DEBUG)
RLAPI void TakeScreenshot(const char *fileName); // Takes a screenshot of current screen (saved a .png)
RLAPI int GetRandomValue(int min, int max); // Returns a random value between min and max (both included)
// Files management functions
RLAPI bool IsFileExtension(const char *fileName, const char *ext);// Check file extension
RLAPI const char *GetDirectoryPath(const char *fileName); // Get directory for a given fileName (with path)

View file

@ -415,7 +415,7 @@ void rlPushMatrix(void)
{
if (stackCounter == MATRIX_STACK_SIZE - 1)
{
TraceLog(ERROR, "Stack Buffer Overflow (MAX %i Matrix)", MATRIX_STACK_SIZE);
TraceLog(LOG_ERROR, "Stack Buffer Overflow (MAX %i Matrix)", MATRIX_STACK_SIZE);
}
stack[stackCounter] = *currentMatrix;
@ -678,7 +678,7 @@ void rlVertex3f(float x, float y, float z)
lines.vCounter++;
}
else TraceLog(ERROR, "MAX_LINES_BATCH overflow");
else TraceLog(LOG_ERROR, "MAX_LINES_BATCH overflow");
} break;
case RL_TRIANGLES:
@ -692,7 +692,7 @@ void rlVertex3f(float x, float y, float z)
triangles.vCounter++;
}
else TraceLog(ERROR, "MAX_TRIANGLES_BATCH overflow");
else TraceLog(LOG_ERROR, "MAX_TRIANGLES_BATCH overflow");
} break;
case RL_QUADS:
@ -708,7 +708,7 @@ void rlVertex3f(float x, float y, float z)
draws[drawsCounter - 1].vertexCount++;
}
else TraceLog(ERROR, "MAX_QUADS_BATCH overflow");
else TraceLog(LOG_ERROR, "MAX_QUADS_BATCH overflow");
} break;
default: break;
@ -847,7 +847,7 @@ void rlTextureParameters(unsigned int id, int param, int value)
case RL_TEXTURE_WRAP_S:
case RL_TEXTURE_WRAP_T:
{
if ((value == RL_WRAP_CLAMP_MIRROR) && !texClampMirrorSupported) TraceLog(WARNING, "Clamp mirror wrap mode not supported");
if ((value == RL_WRAP_CLAMP_MIRROR) && !texClampMirrorSupported) TraceLog(LOG_WARNING, "Clamp mirror wrap mode not supported");
else glTexParameteri(GL_TEXTURE_2D, param, value);
} break;
case RL_TEXTURE_MAG_FILTER:
@ -857,10 +857,10 @@ void rlTextureParameters(unsigned int id, int param, int value)
if (value <= maxAnisotropicLevel) glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, (float)value);
else if (maxAnisotropicLevel > 0.0f)
{
TraceLog(WARNING, "[TEX ID %i] Maximum anisotropic filter level supported is %iX", id, maxAnisotropicLevel);
TraceLog(LOG_WARNING, "[TEX ID %i] Maximum anisotropic filter level supported is %iX", id, maxAnisotropicLevel);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, (float)value);
}
else TraceLog(WARNING, "Anisotropic filtering not supported");
else TraceLog(LOG_WARNING, "Anisotropic filtering not supported");
} break;
default: break;
}
@ -934,7 +934,7 @@ void rlDeleteRenderTextures(RenderTexture2D target)
if (target.texture.id != 0) glDeleteTextures(1, &target.texture.id);
if (target.depth.id != 0) glDeleteTextures(1, &target.depth.id);
TraceLog(INFO, "[FBO ID %i] Unloaded render texture data from VRAM (GPU)", target.id);
TraceLog(LOG_INFO, "[FBO ID %i] Unloaded render texture data from VRAM (GPU)", target.id);
#endif
}
@ -953,7 +953,7 @@ void rlDeleteVertexArrays(unsigned int id)
if (vaoSupported)
{
if (id != 0) glDeleteVertexArrays(1, &id);
TraceLog(INFO, "[VAO ID %i] Unloaded model data from VRAM (GPU)", id);
TraceLog(LOG_INFO, "[VAO ID %i] Unloaded model data from VRAM (GPU)", id);
}
#endif
}
@ -965,7 +965,7 @@ void rlDeleteBuffers(unsigned int id)
if (id != 0)
{
glDeleteBuffers(1, &id);
if (!vaoSupported) TraceLog(INFO, "[VBO ID %i] Unloaded model vertex data from VRAM (GPU)", id);
if (!vaoSupported) TraceLog(LOG_INFO, "[VBO ID %i] Unloaded model vertex data from VRAM (GPU)", id);
}
#endif
}
@ -1014,33 +1014,33 @@ void rlglInit(int width, int height)
//------------------------------------------------------------------------------
// Print current OpenGL and GLSL version
TraceLog(INFO, "GPU: Vendor: %s", glGetString(GL_VENDOR));
TraceLog(INFO, "GPU: Renderer: %s", glGetString(GL_RENDERER));
TraceLog(INFO, "GPU: Version: %s", glGetString(GL_VERSION));
TraceLog(INFO, "GPU: GLSL: %s", glGetString(GL_SHADING_LANGUAGE_VERSION));
TraceLog(LOG_INFO, "GPU: Vendor: %s", glGetString(GL_VENDOR));
TraceLog(LOG_INFO, "GPU: Renderer: %s", glGetString(GL_RENDERER));
TraceLog(LOG_INFO, "GPU: Version: %s", glGetString(GL_VERSION));
TraceLog(LOG_INFO, "GPU: GLSL: %s", glGetString(GL_SHADING_LANGUAGE_VERSION));
// NOTE: We can get a bunch of extra information about GPU capabilities (glGet*)
//int maxTexSize;
//glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTexSize);
//TraceLog(INFO, "GL_MAX_TEXTURE_SIZE: %i", maxTexSize);
//TraceLog(LOG_INFO, "GL_MAX_TEXTURE_SIZE: %i", maxTexSize);
//GL_MAX_TEXTURE_IMAGE_UNITS
//GL_MAX_VIEWPORT_DIMS
//int numAuxBuffers;
//glGetIntegerv(GL_AUX_BUFFERS, &numAuxBuffers);
//TraceLog(INFO, "GL_AUX_BUFFERS: %i", numAuxBuffers);
//TraceLog(LOG_INFO, "GL_AUX_BUFFERS: %i", numAuxBuffers);
//GLint numComp = 0;
//GLint format[32] = { 0 };
//glGetIntegerv(GL_NUM_COMPRESSED_TEXTURE_FORMATS, &numComp);
//glGetIntegerv(GL_COMPRESSED_TEXTURE_FORMATS, format);
//for (int i = 0; i < numComp; i++) TraceLog(INFO, "Supported compressed format: 0x%x", format[i]);
//for (int i = 0; i < numComp; i++) TraceLog(LOG_INFO, "Supported compressed format: 0x%x", format[i]);
// NOTE: We don't need that much data on screen... right now...
#if defined(GRAPHICS_API_OPENGL_11)
//TraceLog(INFO, "OpenGL 1.1 (or driver default) profile initialized");
//TraceLog(LOG_INFO, "OpenGL 1.1 (or driver default) profile initialized");
#endif
#if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
@ -1096,10 +1096,10 @@ void rlglInit(int width, int height)
numExt -= 1;
#endif
TraceLog(INFO, "Number of supported extensions: %i", numExt);
TraceLog(LOG_INFO, "Number of supported extensions: %i", numExt);
// Show supported extensions
//for (int i = 0; i < numExt; i++) TraceLog(INFO, "Supported extension: %s", extList[i]);
//for (int i = 0; i < numExt; i++) TraceLog(LOG_INFO, "Supported extension: %s", extList[i]);
// Check required extensions
for (int i = 0; i < numExt; i++)
@ -1161,21 +1161,21 @@ void rlglInit(int width, int height)
#endif
#if defined(GRAPHICS_API_OPENGL_ES2)
if (vaoSupported) TraceLog(INFO, "[EXTENSION] VAO extension detected, VAO functions initialized successfully");
else TraceLog(WARNING, "[EXTENSION] VAO extension not found, VAO usage not supported");
if (vaoSupported) TraceLog(LOG_INFO, "[EXTENSION] VAO extension detected, VAO functions initialized successfully");
else TraceLog(LOG_WARNING, "[EXTENSION] VAO extension not found, VAO usage not supported");
if (texNPOTSupported) TraceLog(INFO, "[EXTENSION] NPOT textures extension detected, full NPOT textures supported");
else TraceLog(WARNING, "[EXTENSION] NPOT textures extension not found, limited NPOT support (no-mipmaps, no-repeat)");
if (texNPOTSupported) TraceLog(LOG_INFO, "[EXTENSION] NPOT textures extension detected, full NPOT textures supported");
else TraceLog(LOG_WARNING, "[EXTENSION] NPOT textures extension not found, limited NPOT support (no-mipmaps, no-repeat)");
#endif
if (texCompDXTSupported) TraceLog(INFO, "[EXTENSION] DXT compressed textures supported");
if (texCompETC1Supported) TraceLog(INFO, "[EXTENSION] ETC1 compressed textures supported");
if (texCompETC2Supported) TraceLog(INFO, "[EXTENSION] ETC2/EAC compressed textures supported");
if (texCompPVRTSupported) TraceLog(INFO, "[EXTENSION] PVRT compressed textures supported");
if (texCompASTCSupported) TraceLog(INFO, "[EXTENSION] ASTC compressed textures supported");
if (texCompDXTSupported) TraceLog(LOG_INFO, "[EXTENSION] DXT compressed textures supported");
if (texCompETC1Supported) TraceLog(LOG_INFO, "[EXTENSION] ETC1 compressed textures supported");
if (texCompETC2Supported) TraceLog(LOG_INFO, "[EXTENSION] ETC2/EAC compressed textures supported");
if (texCompPVRTSupported) TraceLog(LOG_INFO, "[EXTENSION] PVRT compressed textures supported");
if (texCompASTCSupported) TraceLog(LOG_INFO, "[EXTENSION] ASTC compressed textures supported");
if (texAnisotropicFilterSupported) TraceLog(INFO, "[EXTENSION] Anisotropic textures filtering supported (max: %.0fX)", maxAnisotropicLevel);
if (texClampMirrorSupported) TraceLog(INFO, "[EXTENSION] Clamp mirror wrap texture mode supported");
if (texAnisotropicFilterSupported) TraceLog(LOG_INFO, "[EXTENSION] Anisotropic textures filtering supported (max: %.0fX)", maxAnisotropicLevel);
if (texClampMirrorSupported) TraceLog(LOG_INFO, "[EXTENSION] Clamp mirror wrap texture mode supported");
// Initialize buffers, default shaders and default textures
//----------------------------------------------------------
@ -1185,8 +1185,8 @@ void rlglInit(int width, int height)
whiteTexture = rlglLoadTexture(pixels, 1, 1, UNCOMPRESSED_R8G8B8A8, 1);
if (whiteTexture != 0) TraceLog(INFO, "[TEX ID %i] Base white texture loaded successfully", whiteTexture);
else TraceLog(WARNING, "Base white texture could not be loaded");
if (whiteTexture != 0) TraceLog(LOG_INFO, "[TEX ID %i] Base white texture loaded successfully", whiteTexture);
else TraceLog(LOG_WARNING, "Base white texture could not be loaded");
// Init default Shader (customized for GL 3.3 and ES2)
defaultShader = LoadDefaultShader();
@ -1254,7 +1254,7 @@ void rlglInit(int width, int height)
screenWidth = width;
screenHeight = height;
TraceLog(INFO, "OpenGL default states initialized successfully");
TraceLog(LOG_INFO, "OpenGL default states initialized successfully");
}
// Vertex Buffer Object deinitialization (memory free)
@ -1266,7 +1266,7 @@ void rlglClose(void)
// Delete default white texture
glDeleteTextures(1, &whiteTexture);
TraceLog(INFO, "[TEX ID %i] Unloaded texture data (base white texture) from VRAM", whiteTexture);
TraceLog(LOG_INFO, "[TEX ID %i] Unloaded texture data (base white texture) from VRAM", whiteTexture);
free(draws);
#endif
@ -1292,14 +1292,14 @@ void rlglLoadExtensions(void *loader)
#if defined(GRAPHICS_API_OPENGL_21) || defined(GRAPHICS_API_OPENGL_33)
// NOTE: glad is generated and contains only required OpenGL 3.3 Core extensions (and lower versions)
#if !defined(__APPLE__)
if (!gladLoadGLLoader((GLADloadproc)loader)) TraceLog(WARNING, "GLAD: Cannot load OpenGL extensions");
else TraceLog(INFO, "GLAD: OpenGL extensions loaded successfully");
if (!gladLoadGLLoader((GLADloadproc)loader)) TraceLog(LOG_WARNING, "GLAD: Cannot load OpenGL extensions");
else TraceLog(LOG_INFO, "GLAD: OpenGL extensions loaded successfully");
#if defined(GRAPHICS_API_OPENGL_21)
if (GLAD_GL_VERSION_2_1) TraceLog(INFO, "OpenGL 2.1 profile supported");
if (GLAD_GL_VERSION_2_1) TraceLog(LOG_INFO, "OpenGL 2.1 profile supported");
#elif defined(GRAPHICS_API_OPENGL_33)
if(GLAD_GL_VERSION_3_3) TraceLog(INFO, "OpenGL 3.3 Core profile supported");
else TraceLog(ERROR, "OpenGL 3.3 Core profile not supported");
if(GLAD_GL_VERSION_3_3) TraceLog(LOG_INFO, "OpenGL 3.3 Core profile supported");
else TraceLog(LOG_ERROR, "OpenGL 3.3 Core profile not supported");
#endif
#endif
@ -1342,7 +1342,7 @@ unsigned int rlglLoadTexture(void *data, int width, int height, int format, int
#if defined(GRAPHICS_API_OPENGL_11)
if (format >= COMPRESSED_DXT1_RGB)
{
TraceLog(WARNING, "OpenGL 1.1 does not support GPU compressed texture formats");
TraceLog(LOG_WARNING, "OpenGL 1.1 does not support GPU compressed texture formats");
return id;
}
#endif
@ -1350,31 +1350,31 @@ unsigned int rlglLoadTexture(void *data, int width, int height, int format, int
if ((!texCompDXTSupported) && ((format == COMPRESSED_DXT1_RGB) || (format == COMPRESSED_DXT1_RGBA) ||
(format == COMPRESSED_DXT3_RGBA) || (format == COMPRESSED_DXT5_RGBA)))
{
TraceLog(WARNING, "DXT compressed texture format not supported");
TraceLog(LOG_WARNING, "DXT compressed texture format not supported");
return id;
}
#if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
if ((!texCompETC1Supported) && (format == COMPRESSED_ETC1_RGB))
{
TraceLog(WARNING, "ETC1 compressed texture format not supported");
TraceLog(LOG_WARNING, "ETC1 compressed texture format not supported");
return id;
}
if ((!texCompETC2Supported) && ((format == COMPRESSED_ETC2_RGB) || (format == COMPRESSED_ETC2_EAC_RGBA)))
{
TraceLog(WARNING, "ETC2 compressed texture format not supported");
TraceLog(LOG_WARNING, "ETC2 compressed texture format not supported");
return id;
}
if ((!texCompPVRTSupported) && ((format == COMPRESSED_PVRT_RGB) || (format == COMPRESSED_PVRT_RGBA)))
{
TraceLog(WARNING, "PVRT compressed texture format not supported");
TraceLog(LOG_WARNING, "PVRT compressed texture format not supported");
return id;
}
if ((!texCompASTCSupported) && ((format == COMPRESSED_ASTC_4x4_RGBA) || (format == COMPRESSED_ASTC_8x8_RGBA)))
{
TraceLog(WARNING, "ASTC compressed texture format not supported");
TraceLog(LOG_WARNING, "ASTC compressed texture format not supported");
return id;
}
#endif
@ -1411,7 +1411,7 @@ unsigned int rlglLoadTexture(void *data, int width, int height, int format, int
GLint swizzleMask[] = { GL_RED, GL_RED, GL_RED, GL_ONE };
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
TraceLog(INFO, "[TEX ID %i] Grayscale texture loaded and swizzled", id);
TraceLog(LOG_INFO, "[TEX ID %i] Grayscale texture loaded and swizzled", id);
} break;
case UNCOMPRESSED_GRAY_ALPHA:
{
@ -1438,7 +1438,7 @@ unsigned int rlglLoadTexture(void *data, int width, int height, int format, int
case COMPRESSED_PVRT_RGBA: if (texCompPVRTSupported) LoadCompressedTexture((unsigned char *)data, width, height, mipmapCount, GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG); break; // NOTE: Requires PowerVR GPU
case COMPRESSED_ASTC_4x4_RGBA: if (texCompASTCSupported) LoadCompressedTexture((unsigned char *)data, width, height, mipmapCount, GL_COMPRESSED_RGBA_ASTC_4x4_KHR); break; // NOTE: Requires OpenGL ES 3.1 or OpenGL 4.3
case COMPRESSED_ASTC_8x8_RGBA: if (texCompASTCSupported) LoadCompressedTexture((unsigned char *)data, width, height, mipmapCount, GL_COMPRESSED_RGBA_ASTC_8x8_KHR); break; // NOTE: Requires OpenGL ES 3.1 or OpenGL 4.3
default: TraceLog(WARNING, "Texture format not recognized"); break;
default: TraceLog(LOG_WARNING, "Texture format not recognized"); break;
}
#elif defined(GRAPHICS_API_OPENGL_11) || defined(GRAPHICS_API_OPENGL_ES2)
// NOTE: on OpenGL ES 2.0 (WebGL), internalFormat must match format and options allowed are: GL_LUMINANCE, GL_RGB, GL_RGBA
@ -1465,7 +1465,7 @@ unsigned int rlglLoadTexture(void *data, int width, int height, int format, int
case COMPRESSED_ASTC_4x4_RGBA: if (texCompASTCSupported) LoadCompressedTexture((unsigned char *)data, width, height, mipmapCount, GL_COMPRESSED_RGBA_ASTC_4x4_KHR); break; // NOTE: Requires OpenGL ES 3.1 or OpenGL 4.3
case COMPRESSED_ASTC_8x8_RGBA: if (texCompASTCSupported) LoadCompressedTexture((unsigned char *)data, width, height, mipmapCount, GL_COMPRESSED_RGBA_ASTC_8x8_KHR); break; // NOTE: Requires OpenGL ES 3.1 or OpenGL 4.3
#endif
default: TraceLog(WARNING, "Texture format not supported"); break;
default: TraceLog(LOG_WARNING, "Texture format not supported"); break;
}
#endif
@ -1508,8 +1508,8 @@ unsigned int rlglLoadTexture(void *data, int width, int height, int format, int
// Unbind current texture
glBindTexture(GL_TEXTURE_2D, 0);
if (id > 0) TraceLog(INFO, "[TEX ID %i] Texture created successfully (%ix%i)", id, width, height);
else TraceLog(WARNING, "Texture could not be created");
if (id > 0) TraceLog(LOG_INFO, "[TEX ID %i] Texture created successfully (%ix%i)", id, width, height);
else TraceLog(LOG_WARNING, "Texture could not be created");
return id;
}
@ -1584,16 +1584,16 @@ RenderTexture2D rlglLoadRenderTexture(int width, int height)
if (status != GL_FRAMEBUFFER_COMPLETE)
{
TraceLog(WARNING, "Framebuffer object could not be created...");
TraceLog(LOG_WARNING, "Framebuffer object could not be created...");
switch (status)
{
case GL_FRAMEBUFFER_UNSUPPORTED: TraceLog(WARNING, "Framebuffer is unsupported"); break;
case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT: TraceLog(WARNING, "Framebuffer incomplete attachment"); break;
case GL_FRAMEBUFFER_UNSUPPORTED: TraceLog(LOG_WARNING, "Framebuffer is unsupported"); break;
case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT: TraceLog(LOG_WARNING, "Framebuffer incomplete attachment"); break;
#if defined(GRAPHICS_API_OPENGL_ES2)
case GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS: TraceLog(WARNING, "Framebuffer incomplete dimensions"); break;
case GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS: TraceLog(LOG_WARNING, "Framebuffer incomplete dimensions"); break;
#endif
case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT: TraceLog(WARNING, "Framebuffer incomplete missing attachment"); break;
case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT: TraceLog(LOG_WARNING, "Framebuffer incomplete missing attachment"); break;
default: break;
}
@ -1601,7 +1601,7 @@ RenderTexture2D rlglLoadRenderTexture(int width, int height)
glDeleteTextures(1, &target.depth.id);
glDeleteFramebuffers(1, &target.id);
}
else TraceLog(INFO, "[FBO ID %i] Framebuffer object created successfully", target.id);
else TraceLog(LOG_INFO, "[FBO ID %i] Framebuffer object created successfully", target.id);
glBindFramebuffer(GL_FRAMEBUFFER, 0);
#endif
@ -1624,7 +1624,7 @@ void rlglUpdateTexture(unsigned int id, int width, int height, int format, const
case UNCOMPRESSED_R5G5B5A1: glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width, height, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, (unsigned short *)data); break;
case UNCOMPRESSED_R4G4B4A4: glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width, height, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, (unsigned short *)data); break;
case UNCOMPRESSED_R8G8B8A8: glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, (unsigned char *)data); break;
default: TraceLog(WARNING, "Texture format updating not supported"); break;
default: TraceLog(LOG_WARNING, "Texture format updating not supported"); break;
}
#elif defined(GRAPHICS_API_OPENGL_11) || defined(GRAPHICS_API_OPENGL_ES2)
// NOTE: on OpenGL ES 2.0 (WebGL), internalFormat must match format and options allowed are: GL_LUMINANCE, GL_RGB, GL_RGBA
@ -1637,7 +1637,7 @@ void rlglUpdateTexture(unsigned int id, int width, int height, int format, const
case UNCOMPRESSED_R5G5B5A1: glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width, height, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, (unsigned short *)data); break;
case UNCOMPRESSED_R4G4B4A4: glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width, height, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, (unsigned short *)data); break;
case UNCOMPRESSED_R8G8B8A8: glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, (unsigned char *)data); break;
default: TraceLog(WARNING, "Texture format updating not supported"); break;
default: TraceLog(LOG_WARNING, "Texture format updating not supported"); break;
}
#endif
}
@ -1681,7 +1681,7 @@ void rlglGenerateMipmaps(Texture2D *texture)
mipHeight /= 2;
}
TraceLog(WARNING, "[TEX ID %i] Mipmaps generated manually on CPU side", texture->id);
TraceLog(LOG_WARNING, "[TEX ID %i] Mipmaps generated manually on CPU side", texture->id);
// NOTE: Once mipmaps have been generated and data has been uploaded to GPU VRAM, we can discard RAM data
free(data);
@ -1692,7 +1692,7 @@ void rlglGenerateMipmaps(Texture2D *texture)
#if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
//glHint(GL_GENERATE_MIPMAP_HINT, GL_DONT_CARE); // Hint for mipmaps generation algorythm: GL_FASTEST, GL_NICEST, GL_DONT_CARE
glGenerateMipmap(GL_TEXTURE_2D); // Generate mipmaps automatically
TraceLog(INFO, "[TEX ID %i] Mipmaps generated automatically", texture->id);
TraceLog(LOG_INFO, "[TEX ID %i] Mipmaps generated automatically", texture->id);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); // Activate Trilinear filtering for mipmaps
@ -1703,7 +1703,7 @@ void rlglGenerateMipmaps(Texture2D *texture)
texture->mipmaps = 1 + (int)floor(log(MAX(texture->width, texture->height))/log(2));
#endif
}
else TraceLog(WARNING, "[TEX ID %i] Mipmaps can not be generated", texture->id);
else TraceLog(LOG_WARNING, "[TEX ID %i] Mipmaps can not be generated", texture->id);
glBindTexture(GL_TEXTURE_2D, 0);
}
@ -1834,13 +1834,13 @@ void rlglLoadMesh(Mesh *mesh, bool dynamic)
if (vaoId > 0)
{
mesh->vaoId = vaoId;
TraceLog(INFO, "[VAO ID %i] Mesh uploaded successfully to VRAM (GPU)", mesh->vaoId);
TraceLog(LOG_INFO, "[VAO ID %i] Mesh uploaded successfully to VRAM (GPU)", mesh->vaoId);
}
else TraceLog(WARNING, "Mesh could not be uploaded to VRAM (GPU)");
else TraceLog(LOG_WARNING, "Mesh could not be uploaded to VRAM (GPU)");
}
else
{
TraceLog(INFO, "[VBOs] Mesh uploaded successfully to VRAM (GPU)");
TraceLog(LOG_INFO, "[VBOs] Mesh uploaded successfully to VRAM (GPU)");
}
#endif
}
@ -2219,7 +2219,7 @@ void *rlglReadTexturePixels(Texture2D texture)
case UNCOMPRESSED_R5G5B5A1: pixels = (unsigned short *)malloc(size); glFormat = GL_RGBA; glType = GL_UNSIGNED_SHORT_5_5_5_1; break; // 16 bpp (1 bit alpha)
case UNCOMPRESSED_R4G4B4A4: pixels = (unsigned short *)malloc(size); glFormat = GL_RGBA; glType = GL_UNSIGNED_SHORT_4_4_4_4; break; // 16 bpp (4 bit alpha)
case UNCOMPRESSED_R8G8B8A8: pixels = (unsigned char *)malloc(size*4); glFormat = GL_RGBA; glType = GL_UNSIGNED_BYTE; break; // 32 bpp
default: TraceLog(WARNING, "Texture data retrieval, format not suported"); break;
default: TraceLog(LOG_WARNING, "Texture data retrieval, format not suported"); break;
}
// NOTE: Each row written to or read from by OpenGL pixel operations like glGetTexImage are aligned to a 4 byte boundary by default, which may add some padding.
@ -2369,7 +2369,7 @@ char *LoadText(const char *fileName)
fclose(textFile);
}
else TraceLog(WARNING, "[%s] Text file could not be opened", fileName);
else TraceLog(LOG_WARNING, "[%s] Text file could not be opened", fileName);
}
return text;
@ -2399,7 +2399,7 @@ Shader LoadShader(char *vsFileName, char *fsFileName)
if (shader.id == 0)
{
TraceLog(WARNING, "Custom shader could not be loaded");
TraceLog(LOG_WARNING, "Custom shader could not be loaded");
shader = defaultShader;
}
#endif
@ -2413,7 +2413,7 @@ void UnloadShader(Shader shader)
if (shader.id != 0)
{
rlDeleteShader(shader.id);
TraceLog(INFO, "[SHDR ID %i] Unloaded shader program data", shader.id);
TraceLog(LOG_INFO, "[SHDR ID %i] Unloaded shader program data", shader.id);
}
}
@ -2455,7 +2455,7 @@ int GetShaderLocation(Shader shader, const char *uniformName)
#if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
location = glGetUniformLocation(shader.id, uniformName);
if (location == -1) TraceLog(DEBUG, "[SHDR ID %i] Shader location for %s could not be found", shader.id, uniformName);
if (location == -1) TraceLog(LOG_DEBUG, "[SHDR ID %i] Shader location for %s could not be found", shader.id, uniformName);
#endif
return location;
}
@ -2470,7 +2470,7 @@ void SetShaderValue(Shader shader, int uniformLoc, float *value, int size)
else if (size == 2) glUniform2fv(uniformLoc, 1, value); // Shader uniform type: vec2
else if (size == 3) glUniform3fv(uniformLoc, 1, value); // Shader uniform type: vec3
else if (size == 4) glUniform4fv(uniformLoc, 1, value); // Shader uniform type: vec4
else TraceLog(WARNING, "Shader value float array size not supported");
else TraceLog(LOG_WARNING, "Shader value float array size not supported");
//glUseProgram(0); // Avoid reseting current shader program, in case other uniforms are set
#endif
@ -2486,7 +2486,7 @@ void SetShaderValuei(Shader shader, int uniformLoc, int *value, int size)
else if (size == 2) glUniform2iv(uniformLoc, 1, value); // Shader uniform type: ivec2
else if (size == 3) glUniform3iv(uniformLoc, 1, value); // Shader uniform type: ivec3
else if (size == 4) glUniform4iv(uniformLoc, 1, value); // Shader uniform type: ivec4
else TraceLog(WARNING, "Shader value int array size not supported");
else TraceLog(LOG_WARNING, "Shader value int array size not supported");
//glUseProgram(0);
#endif
@ -2572,7 +2572,7 @@ void InitVrSimulator(int vrDevice)
hmd.chromaAbCorrection[2] = 1.014f; // HMD chromatic aberration correction parameter 2
hmd.chromaAbCorrection[3] = 0.0f; // HMD chromatic aberration correction parameter 3
TraceLog(INFO, "Initializing VR Simulator (Oculus Rift DK2)");
TraceLog(LOG_INFO, "Initializing VR Simulator (Oculus Rift DK2)");
}
else if ((vrDevice == HMD_DEFAULT_DEVICE) || (vrDevice == HMD_OCULUS_RIFT_CV1))
{
@ -2599,12 +2599,12 @@ void InitVrSimulator(int vrDevice)
hmd.chromaAbCorrection[2] = 1.014f; // HMD chromatic aberration correction parameter 2
hmd.chromaAbCorrection[3] = 0.0f; // HMD chromatic aberration correction parameter 3
TraceLog(INFO, "Initializing VR Simulator (Oculus Rift CV1)");
TraceLog(LOG_INFO, "Initializing VR Simulator (Oculus Rift CV1)");
}
else
{
TraceLog(WARNING, "VR Simulator doesn't support selected device parameters,");
TraceLog(WARNING, "using default VR Simulator parameters");
TraceLog(LOG_WARNING, "VR Simulator doesn't support selected device parameters,");
TraceLog(LOG_WARNING, "using default VR Simulator parameters");
}
// Initialize framebuffer and textures for stereo rendering
@ -2623,7 +2623,7 @@ void InitVrSimulator(int vrDevice)
#endif
#if defined(GRAPHICS_API_OPENGL_11)
TraceLog(WARNING, "VR Simulator not supported on OpenGL 1.1");
TraceLog(LOG_WARNING, "VR Simulator not supported on OpenGL 1.1");
#endif
}
@ -2843,7 +2843,7 @@ static unsigned int LoadShaderProgram(const char *vShaderStr, const char *fShade
if (success != GL_TRUE)
{
TraceLog(WARNING, "[VSHDR ID %i] Failed to compile vertex shader...", vertexShader);
TraceLog(LOG_WARNING, "[VSHDR ID %i] Failed to compile vertex shader...", vertexShader);
int maxLength = 0;
int length;
@ -2857,13 +2857,13 @@ static unsigned int LoadShaderProgram(const char *vShaderStr, const char *fShade
#endif
glGetShaderInfoLog(vertexShader, maxLength, &length, log);
TraceLog(INFO, "%s", log);
TraceLog(LOG_INFO, "%s", log);
#ifdef _MSC_VER
free(log);
#endif
}
else TraceLog(INFO, "[VSHDR ID %i] Vertex shader compiled successfully", vertexShader);
else TraceLog(LOG_INFO, "[VSHDR ID %i] Vertex shader compiled successfully", vertexShader);
glCompileShader(fragmentShader);
@ -2871,7 +2871,7 @@ static unsigned int LoadShaderProgram(const char *vShaderStr, const char *fShade
if (success != GL_TRUE)
{
TraceLog(WARNING, "[FSHDR ID %i] Failed to compile fragment shader...", fragmentShader);
TraceLog(LOG_WARNING, "[FSHDR ID %i] Failed to compile fragment shader...", fragmentShader);
int maxLength = 0;
int length;
@ -2885,13 +2885,13 @@ static unsigned int LoadShaderProgram(const char *vShaderStr, const char *fShade
#endif
glGetShaderInfoLog(fragmentShader, maxLength, &length, log);
TraceLog(INFO, "%s", log);
TraceLog(LOG_INFO, "%s", log);
#ifdef _MSC_VER
free(log);
#endif
}
else TraceLog(INFO, "[FSHDR ID %i] Fragment shader compiled successfully", fragmentShader);
else TraceLog(LOG_INFO, "[FSHDR ID %i] Fragment shader compiled successfully", fragmentShader);
program = glCreateProgram();
@ -2916,7 +2916,7 @@ static unsigned int LoadShaderProgram(const char *vShaderStr, const char *fShade
if (success == GL_FALSE)
{
TraceLog(WARNING, "[SHDR ID %i] Failed to link shader program...", program);
TraceLog(LOG_WARNING, "[SHDR ID %i] Failed to link shader program...", program);
int maxLength = 0;
int length;
@ -2930,7 +2930,7 @@ static unsigned int LoadShaderProgram(const char *vShaderStr, const char *fShade
#endif
glGetProgramInfoLog(program, maxLength, &length, log);
TraceLog(INFO, "%s", log);
TraceLog(LOG_INFO, "%s", log);
#ifdef _MSC_VER
free(log);
@ -2939,7 +2939,7 @@ static unsigned int LoadShaderProgram(const char *vShaderStr, const char *fShade
program = 0;
}
else TraceLog(INFO, "[SHDR ID %i] Shader program loaded successfully", program);
else TraceLog(LOG_INFO, "[SHDR ID %i] Shader program loaded successfully", program);
glDeleteShader(vertexShader);
glDeleteShader(fragmentShader);
@ -3015,8 +3015,8 @@ static Shader LoadDefaultShader(void)
shader.id = LoadShaderProgram(vDefaultShaderStr, fDefaultShaderStr);
if (shader.id != 0) TraceLog(INFO, "[SHDR ID %i] Default shader loaded successfully", shader.id);
else TraceLog(WARNING, "[SHDR ID %i] Default shader could not be loaded", shader.id);
if (shader.id != 0) TraceLog(LOG_INFO, "[SHDR ID %i] Default shader loaded successfully", shader.id);
else TraceLog(LOG_WARNING, "[SHDR ID %i] Default shader could not be loaded", shader.id);
if (shader.id != 0) LoadDefaultShaderLocations(&shader);
@ -3135,7 +3135,7 @@ static void LoadDefaultBuffers(void)
quads.tcCounter = 0;
quads.cCounter = 0;
TraceLog(INFO, "[CPU] Default buffers initialized successfully (lines, triangles, quads)");
TraceLog(LOG_INFO, "[CPU] Default buffers initialized successfully (lines, triangles, quads)");
//--------------------------------------------------------------------------------------------
// [GPU] Upload vertex data and initialize VAOs/VBOs (lines, triangles, quads)
@ -3165,8 +3165,8 @@ static void LoadDefaultBuffers(void)
glEnableVertexAttribArray(currentShader.colorLoc);
glVertexAttribPointer(currentShader.colorLoc, 4, GL_UNSIGNED_BYTE, GL_TRUE, 0, 0);
if (vaoSupported) TraceLog(INFO, "[VAO ID %i] Default buffers VAO initialized successfully (lines)", lines.vaoId);
else TraceLog(INFO, "[VBO ID %i][VBO ID %i] Default buffers VBOs initialized successfully (lines)", lines.vboId[0], lines.vboId[1]);
if (vaoSupported) TraceLog(LOG_INFO, "[VAO ID %i] Default buffers VAO initialized successfully (lines)", lines.vaoId);
else TraceLog(LOG_INFO, "[VBO ID %i][VBO ID %i] Default buffers VBOs initialized successfully (lines)", lines.vboId[0], lines.vboId[1]);
// Upload and link triangles vertex buffers
if (vaoSupported)
@ -3191,8 +3191,8 @@ static void LoadDefaultBuffers(void)
glEnableVertexAttribArray(currentShader.colorLoc);
glVertexAttribPointer(currentShader.colorLoc, 4, GL_UNSIGNED_BYTE, GL_TRUE, 0, 0);
if (vaoSupported) TraceLog(INFO, "[VAO ID %i] Default buffers VAO initialized successfully (triangles)", triangles.vaoId);
else TraceLog(INFO, "[VBO ID %i][VBO ID %i] Default buffers VBOs initialized successfully (triangles)", triangles.vboId[0], triangles.vboId[1]);
if (vaoSupported) TraceLog(LOG_INFO, "[VAO ID %i] Default buffers VAO initialized successfully (triangles)", triangles.vaoId);
else TraceLog(LOG_INFO, "[VBO ID %i][VBO ID %i] Default buffers VBOs initialized successfully (triangles)", triangles.vboId[0], triangles.vboId[1]);
// Upload and link quads vertex buffers
if (vaoSupported)
@ -3233,8 +3233,8 @@ static void LoadDefaultBuffers(void)
glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(short)*6*MAX_QUADS_BATCH, quads.indices, GL_STATIC_DRAW);
#endif
if (vaoSupported) TraceLog(INFO, "[VAO ID %i] Default buffers VAO initialized successfully (quads)", quads.vaoId);
else TraceLog(INFO, "[VBO ID %i][VBO ID %i][VBO ID %i][VBO ID %i] Default buffers VBOs initialized successfully (quads)", quads.vboId[0], quads.vboId[1], quads.vboId[2], quads.vboId[3]);
if (vaoSupported) TraceLog(LOG_INFO, "[VAO ID %i] Default buffers VAO initialized successfully (quads)", quads.vaoId);
else TraceLog(LOG_INFO, "[VBO ID %i][VBO ID %i][VBO ID %i][VBO ID %i] Default buffers VBOs initialized successfully (quads)", quads.vboId[0], quads.vboId[1], quads.vboId[2], quads.vboId[3]);
// Unbind the current VAO
if (vaoSupported) glBindVertexArray(0);
@ -3432,14 +3432,14 @@ static void DrawDefaultBuffers()
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, quads.vboId[3]);
}
//TraceLog(DEBUG, "Draws required per frame: %i", drawsCounter);
//TraceLog(LOG_DEBUG, "Draws required per frame: %i", drawsCounter);
for (int i = 0; i < drawsCounter; i++)
{
quadsCount = draws[i].vertexCount/4;
numIndicesToProcess = quadsCount*6; // Get number of Quads*6 index by Quad
//TraceLog(DEBUG, "Quads to render: %i - Vertex Count: %i", quadsCount, draws[i].vertexCount);
//TraceLog(LOG_DEBUG, "Quads to render: %i - Vertex Count: %i", quadsCount, draws[i].vertexCount);
glBindTexture(GL_TEXTURE_2D, draws[i].textureId);
@ -3450,7 +3450,7 @@ static void DrawDefaultBuffers()
glDrawElements(GL_TRIANGLES, numIndicesToProcess, GL_UNSIGNED_SHORT, (GLvoid *)(sizeof(GLushort)*indicesOffset));
#endif
//GLenum err;
//if ((err = glGetError()) != GL_NO_ERROR) TraceLog(INFO, "OpenGL error: %i", (int)err); //GL_INVALID_ENUM!
//if ((err = glGetError()) != GL_NO_ERROR) TraceLog(LOG_INFO, "OpenGL error: %i", (int)err); //GL_INVALID_ENUM!
indicesOffset += draws[i].vertexCount/4*6;
}
@ -3557,17 +3557,17 @@ static void SetStereoConfig(VrDeviceInfo hmd)
hmd.distortionK[2]*lensRadiusSq*lensRadiusSq +
hmd.distortionK[3]*lensRadiusSq*lensRadiusSq*lensRadiusSq;
TraceLog(DEBUG, "VR: Distortion Scale: %f", distortionScale);
TraceLog(LOG_DEBUG, "VR: Distortion Scale: %f", distortionScale);
float normScreenWidth = 0.5f;
float normScreenHeight = 1.0f;
float scaleIn[2] = { 2.0f/normScreenWidth, 2.0f/normScreenHeight/aspect };
float scale[2] = { normScreenWidth*0.5f/distortionScale, normScreenHeight*0.5f*aspect/distortionScale };
TraceLog(DEBUG, "VR: Distortion Shader: LeftLensCenter = { %f, %f }", leftLensCenter[0], leftLensCenter[1]);
TraceLog(DEBUG, "VR: Distortion Shader: RightLensCenter = { %f, %f }", rightLensCenter[0], rightLensCenter[1]);
TraceLog(DEBUG, "VR: Distortion Shader: Scale = { %f, %f }", scale[0], scale[1]);
TraceLog(DEBUG, "VR: Distortion Shader: ScaleIn = { %f, %f }", scaleIn[0], scaleIn[1]);
TraceLog(LOG_DEBUG, "VR: Distortion Shader: LeftLensCenter = { %f, %f }", leftLensCenter[0], leftLensCenter[1]);
TraceLog(LOG_DEBUG, "VR: Distortion Shader: RightLensCenter = { %f, %f }", rightLensCenter[0], rightLensCenter[1]);
TraceLog(LOG_DEBUG, "VR: Distortion Shader: Scale = { %f, %f }", scale[0], scale[1]);
TraceLog(LOG_DEBUG, "VR: Distortion Shader: ScaleIn = { %f, %f }", scaleIn[0], scaleIn[1]);
#if defined(SUPPORT_DISTORTION_SHADER)
// Update distortion shader with lens and distortion-scale parameters
@ -3645,20 +3645,20 @@ static int GenerateMipmaps(unsigned char *data, int baseWidth, int baseHeight)
if (width != 1) width /= 2;
if (height != 1) height /= 2;
TraceLog(DEBUG, "Next mipmap size: %i x %i", width, height);
TraceLog(LOG_DEBUG, "Next mipmap size: %i x %i", width, height);
mipmapCount++;
size += (width*height*4); // Add mipmap size (in bytes)
}
TraceLog(DEBUG, "Total mipmaps required: %i", mipmapCount);
TraceLog(DEBUG, "Total size of data required: %i", size);
TraceLog(LOG_DEBUG, "Total mipmaps required: %i", mipmapCount);
TraceLog(LOG_DEBUG, "Total size of data required: %i", size);
unsigned char *temp = realloc(data, size);
if (temp != NULL) data = temp;
else TraceLog(WARNING, "Mipmaps required memory could not be allocated");
else TraceLog(LOG_WARNING, "Mipmaps required memory could not be allocated");
width = baseWidth;
height = baseHeight;
@ -3680,7 +3680,7 @@ static int GenerateMipmaps(unsigned char *data, int baseWidth, int baseHeight)
j++;
}
TraceLog(DEBUG, "Mipmap base (%ix%i)", width, height);
TraceLog(LOG_DEBUG, "Mipmap base (%ix%i)", width, height);
for (int mip = 1; mip < mipmapCount; mip++)
{
@ -3751,15 +3751,14 @@ static Color *GenNextMipmap(Color *srcData, int srcWidth, int srcHeight)
}
}
TraceLog(DEBUG, "Mipmap generated successfully (%ix%i)", width, height);
TraceLog(LOG_DEBUG, "Mipmap generated successfully (%ix%i)", width, height);
return mipmap;
}
#endif
#if defined(RLGL_STANDALONE)
// Output a trace log message
// NOTE: Expected msgType: (0)Info, (1)Error, (2)Warning
// Show trace log messages (LOG_INFO, LOG_WARNING, LOG_ERROR, LOG_DEBUG)
void TraceLog(int msgType, const char *text, ...)
{
va_list args;
@ -3767,10 +3766,10 @@ void TraceLog(int msgType, const char *text, ...)
switch (msgType)
{
case INFO: fprintf(stdout, "INFO: "); break;
case ERROR: fprintf(stdout, "ERROR: "); break;
case WARNING: fprintf(stdout, "WARNING: "); break;
case DEBUG: fprintf(stdout, "DEBUG: "); break;
case LOG_INFO: fprintf(stdout, "INFO: "); break;
case LOG_ERROR: fprintf(stdout, "ERROR: "); break;
case LOG_WARNING: fprintf(stdout, "WARNING: "); break;
case LOG_DEBUG: fprintf(stdout, "DEBUG: "); break;
default: break;
}
@ -3779,7 +3778,7 @@ void TraceLog(int msgType, const char *text, ...)
va_end(args);
if (msgType == ERROR) exit(1);
if (msgType == LOG_ERROR) exit(1);
}
// Converts Matrix to float array

View file

@ -236,11 +236,11 @@ typedef unsigned char byte;
// TraceLog message types
typedef enum {
INFO = 0,
ERROR,
WARNING,
DEBUG,
OTHER
LOG_INFO = 0,
LOG_ERROR,
LOG_WARNING,
LOG_DEBUG,
LOG_OTHER
} TraceLogType;
// Texture formats (support depends on OpenGL version)
@ -416,8 +416,8 @@ void EndShaderMode(void); // End custo
void BeginBlendMode(int mode); // Begin blending mode (alpha, additive, multiplied)
void EndBlendMode(void); // End blending mode (reset to default: alpha blending)
void TraceLog(int msgType, const char *text, ...);
float *MatrixToFloat(Matrix mat);
void TraceLog(int msgType, const char *text, ...); // Show trace log messages (LOG_INFO, LOG_WARNING, LOG_ERROR, LOG_DEBUG)
float *MatrixToFloat(Matrix mat); // Get float array from Matrix data
void InitVrSimulator(int vrDevice); // Init VR simulator for selected device
void CloseVrSimulator(void); // Close VR simulator for current device

View file

@ -252,7 +252,7 @@ RRESDEF RRES LoadResource(const char *fileName, int rresId)
FILE *rresFile = fopen(fileName, "rb");
if (rresFile == NULL) TraceLog(WARNING, "[%s] rRES raylib resource file could not be opened", fileName);
if (rresFile == NULL) TraceLog(LOG_WARNING, "[%s] rRES raylib resource file could not be opened", fileName);
else
{
// Read rres file info header
@ -266,7 +266,7 @@ RRESDEF RRES LoadResource(const char *fileName, int rresId)
// Verify "rRES" identifier
if ((fileHeader.id[0] != 'r') && (fileHeader.id[1] != 'R') && (fileHeader.id[2] != 'E') && (fileHeader.id[3] != 'S'))
{
TraceLog(WARNING, "[%s] This is not a valid raylib resource file", fileName);
TraceLog(LOG_WARNING, "[%s] This is not a valid raylib resource file", fileName);
}
else
{
@ -305,7 +305,7 @@ RRESDEF RRES LoadResource(const char *fileName, int rresId)
}
else rres[k].data = data;
if (rres[k].data != NULL) TraceLog(INFO, "[%s][ID %i] Resource data loaded successfully", fileName, (int)infoHeader.id);
if (rres[k].data != NULL) TraceLog(LOG_INFO, "[%s][ID %i] Resource data loaded successfully", fileName, (int)infoHeader.id);
// Read next part
fread(&infoHeader, sizeof(RRESInfoHeader), 1, rresFile);
@ -318,7 +318,7 @@ RRESDEF RRES LoadResource(const char *fileName, int rresId)
}
}
if (rres[0].data == NULL) TraceLog(WARNING, "[%s][ID %i] Requested resource could not be found", fileName, (int)rresId);
if (rres[0].data == NULL) TraceLog(LOG_WARNING, "[%s][ID %i] Requested resource could not be found", fileName, (int)rresId);
}
fclose(rresFile);
@ -349,7 +349,7 @@ static void *DecompressData(const unsigned char *data, unsigned long compSize, i
// Check correct memory allocation
if (uncompData == NULL)
{
TraceLog(WARNING, "Out of memory while decompressing data");
TraceLog(LOG_WARNING, "Out of memory while decompressing data");
}
else
{
@ -358,18 +358,18 @@ static void *DecompressData(const unsigned char *data, unsigned long compSize, i
if (tempUncompSize == -1)
{
TraceLog(WARNING, "Data decompression failed");
TraceLog(LOG_WARNING, "Data decompression failed");
RRES_FREE(uncompData);
}
if (uncompSize != (int)tempUncompSize)
{
TraceLog(WARNING, "Expected uncompressed size do not match, data may be corrupted");
TraceLog(WARNING, " -- Expected uncompressed size: %i", uncompSize);
TraceLog(WARNING, " -- Returned uncompressed size: %i", tempUncompSize);
TraceLog(LOG_WARNING, "Expected uncompressed size do not match, data may be corrupted");
TraceLog(LOG_WARNING, " -- Expected uncompressed size: %i", uncompSize);
TraceLog(LOG_WARNING, " -- Returned uncompressed size: %i", tempUncompSize);
}
TraceLog(INFO, "Data decompressed successfully from %u bytes to %u bytes", (mz_uint32)compSize, (mz_uint32)tempUncompSize);
TraceLog(LOG_INFO, "Data decompressed successfully from %u bytes to %u bytes", (mz_uint32)compSize, (mz_uint32)tempUncompSize);
}
return uncompData;
@ -377,36 +377,27 @@ static void *DecompressData(const unsigned char *data, unsigned long compSize, i
// Some required functions for rres standalone module version
#if defined(RRES_STANDALONE)
// Outputs a trace log message (INFO, ERROR, WARNING)
// NOTE: If a file has been init, output log is written there
// Show trace log messages (LOG_INFO, LOG_WARNING, LOG_ERROR, LOG_DEBUG)
void TraceLog(int logType, const char *text, ...)
{
va_list args;
int traceDebugMsgs = 0;
#ifdef DO_NOT_TRACE_DEBUG_MSGS
traceDebugMsgs = 0;
#endif
va_start(args, text);
switch (msgType)
{
case LOG_INFO: fprintf(stdout, "INFO: "); break;
case LOG_ERROR: fprintf(stdout, "ERROR: "); break;
case LOG_WARNING: fprintf(stdout, "WARNING: "); break;
case LOG_DEBUG: if (traceDebugMsgs) fprintf(stdout, "DEBUG: "); break;
case LOG_DEBUG: fprintf(stdout, "DEBUG: "); break;
default: break;
}
if ((msgType != LOG_DEBUG) || ((msgType == LOG_DEBUG) && (traceDebugMsgs)))
{
va_start(args, text);
vfprintf(stdout, text, args);
fprintf(stdout, "\n");
va_end(args);
fprintf(stdout, "\n");
}
if (msgType == ERROR) exit(1); // If ERROR message, exit program
if (msgType == LOG_ERROR) exit(1);
}
#endif

View file

@ -256,7 +256,7 @@ extern void LoadDefaultFont(void)
defaultFont.baseSize = defaultFont.chars[0].rec.height;
TraceLog(INFO, "[TEX ID %i] Default font loaded successfully", defaultFont.texture.id);
TraceLog(LOG_INFO, "[TEX ID %i] Default font loaded successfully", defaultFont.texture.id);
}
// Unload raylib default font
@ -330,7 +330,7 @@ SpriteFont LoadSpriteFont(const char *fileName)
if (spriteFont.texture.id == 0)
{
TraceLog(WARNING, "[%s] SpriteFont could not be loaded, using default font", fileName);
TraceLog(LOG_WARNING, "[%s] SpriteFont could not be loaded, using default font", fileName);
spriteFont = GetDefaultFont();
}
else SetTextureFilter(spriteFont.texture, FILTER_POINT); // By default we set point filter (best performance)
@ -364,7 +364,7 @@ SpriteFont LoadSpriteFontEx(const char *fileName, int fontSize, int charsCount,
if (spriteFont.texture.id == 0)
{
TraceLog(WARNING, "[%s] SpriteFont could not be generated, using default font", fileName);
TraceLog(LOG_WARNING, "[%s] SpriteFont could not be generated, using default font", fileName);
spriteFont = GetDefaultFont();
}
@ -380,7 +380,7 @@ void UnloadSpriteFont(SpriteFont spriteFont)
UnloadTexture(spriteFont.texture);
free(spriteFont.chars);
TraceLog(DEBUG, "Unloaded sprite font data");
TraceLog(LOG_DEBUG, "Unloaded sprite font data");
}
}
@ -677,7 +677,7 @@ static SpriteFont LoadImageFont(Image image, Color key, int firstChar)
xPosToRead = charSpacing;
}
TraceLog(DEBUG, "SpriteFont data parsed correctly from image");
TraceLog(LOG_DEBUG, "SpriteFont data parsed correctly from image");
// NOTE: We need to remove key color borders from image to avoid weird
// artifacts on texture scaling when using FILTER_BILINEAR or FILTER_TRILINEAR
@ -713,7 +713,7 @@ static SpriteFont LoadImageFont(Image image, Color key, int firstChar)
spriteFont.baseSize = spriteFont.chars[0].rec.height;
TraceLog(INFO, "Image file loaded correctly as SpriteFont");
TraceLog(LOG_INFO, "Image file loaded correctly as SpriteFont");
return spriteFont;
}
@ -743,7 +743,7 @@ static SpriteFont LoadBMFont(const char *fileName)
if (fntFile == NULL)
{
TraceLog(WARNING, "[%s] FNT file could not be opened", fileName);
TraceLog(LOG_WARNING, "[%s] FNT file could not be opened", fileName);
return font;
}
@ -756,20 +756,20 @@ static SpriteFont LoadBMFont(const char *fileName)
searchPoint = strstr(buffer, "lineHeight");
sscanf(searchPoint, "lineHeight=%i base=%i scaleW=%i scaleH=%i", &fontSize, &base, &texWidth, &texHeight);
TraceLog(DEBUG, "[%s] Font size: %i", fileName, fontSize);
TraceLog(DEBUG, "[%s] Font texture scale: %ix%i", fileName, texWidth, texHeight);
TraceLog(LOG_DEBUG, "[%s] Font size: %i", fileName, fontSize);
TraceLog(LOG_DEBUG, "[%s] Font texture scale: %ix%i", fileName, texWidth, texHeight);
fgets(buffer, MAX_BUFFER_SIZE, fntFile);
searchPoint = strstr(buffer, "file");
sscanf(searchPoint, "file=\"%128[^\"]\"", texFileName);
TraceLog(DEBUG, "[%s] Font texture filename: %s", fileName, texFileName);
TraceLog(LOG_DEBUG, "[%s] Font texture filename: %s", fileName, texFileName);
fgets(buffer, MAX_BUFFER_SIZE, fntFile);
searchPoint = strstr(buffer, "count");
sscanf(searchPoint, "count=%i", &charsCount);
TraceLog(DEBUG, "[%s] Font num chars: %i", fileName, charsCount);
TraceLog(LOG_DEBUG, "[%s] Font num chars: %i", fileName, charsCount);
// Compose correct path using route of .fnt file (fileName) and texFileName
char *texPath = NULL;
@ -785,7 +785,7 @@ static SpriteFont LoadBMFont(const char *fileName)
strncat(texPath, fileName, strlen(fileName) - strlen(lastSlash) + 1);
strncat(texPath, texFileName, strlen(texFileName));
TraceLog(DEBUG, "[%s] Font texture loading path: %s", fileName, texPath);
TraceLog(LOG_DEBUG, "[%s] Font texture loading path: %s", fileName, texPath);
Image imFont = LoadImage(texPath);
@ -832,7 +832,7 @@ static SpriteFont LoadBMFont(const char *fileName)
UnloadSpriteFont(font);
font = GetDefaultFont();
}
else TraceLog(INFO, "[%s] SpriteFont loaded successfully", fileName);
else TraceLog(LOG_INFO, "[%s] SpriteFont loaded successfully", fileName);
return font;
}
@ -853,7 +853,7 @@ static SpriteFont LoadTTF(const char *fileName, int fontSize, int charsCount, in
float guessSize = ceilf((float)fontSize*3/4)*ceilf(sqrtf((float)charsCount));
int textureSize = (int)powf(2, ceilf(logf((float)guessSize)/logf(2))); // Calculate next POT
TraceLog(INFO, "TTF spritefont loading: Predicted texture size: %ix%i", textureSize, textureSize);
TraceLog(LOG_INFO, "TTF spritefont loading: Predicted texture size: %ix%i", textureSize, textureSize);
unsigned char *ttfBuffer = (unsigned char *)malloc(MAX_TTF_SIZE*1024*1024);
unsigned char *dataBitmap = (unsigned char *)malloc(textureSize*textureSize*sizeof(unsigned char)); // One channel bitmap returned!
@ -865,22 +865,22 @@ static SpriteFont LoadTTF(const char *fileName, int fontSize, int charsCount, in
if (ttfFile == NULL)
{
TraceLog(WARNING, "[%s] TTF file could not be opened", fileName);
TraceLog(LOG_WARNING, "[%s] TTF file could not be opened", fileName);
return font;
}
// NOTE: We try reading up to 16 MB of elements of 1 byte
fread(ttfBuffer, 1, MAX_TTF_SIZE*1024*1024, ttfFile);
if (fontChars[0] != 32) TraceLog(WARNING, "TTF spritefont loading: first character is not SPACE(32) character");
if (fontChars[0] != 32) TraceLog(LOG_WARNING, "TTF spritefont loading: first character is not SPACE(32) character");
// NOTE: Using stb_truetype crappy packing method, no guarante the font fits the image...
// TODO: Replace this function by a proper packing method and support random chars order,
// we already receive a list (fontChars) with the ordered expected characters
int result = stbtt_BakeFontBitmap(ttfBuffer, 0, fontSize, dataBitmap, textureSize, textureSize, fontChars[0], charsCount, charData);
//if (result > 0) TraceLog(INFO, "TTF spritefont loading: first unused row of generated bitmap: %i", result);
if (result < 0) TraceLog(WARNING, "TTF spritefont loading: Not all the characters fit in the font");
//if (result > 0) TraceLog(LOG_INFO, "TTF spritefont loading: first unused row of generated bitmap: %i", result);
if (result < 0) TraceLog(LOG_WARNING, "TTF spritefont loading: Not all the characters fit in the font");
free(ttfBuffer);

View file

@ -167,7 +167,7 @@ Image LoadImage(const char *fileName)
// NOTE: Parameters for RRES_TYPE_IMAGE are: width, height, format, mipmaps
if (rres[0].type == RRES_TYPE_IMAGE) image = LoadImagePro(rres[0].data, rres[0].param1, rres[0].param2, rres[0].param3);
else TraceLog(WARNING, "[%s] Resource file does not contain image data", fileName);
else TraceLog(LOG_WARNING, "[%s] Resource file does not contain image data", fileName);
UnloadResource(rres);
}
@ -234,7 +234,7 @@ Image LoadImage(const char *fileName)
else
{
// TODO: Support different number of channels at 32 bit float
TraceLog(WARNING, "[%s] Image fileformat not supported (only 3 channel 32 bit floats)", fileName);
TraceLog(LOG_WARNING, "[%s] Image fileformat not supported (only 3 channel 32 bit floats)", fileName);
UnloadImage(image);
}
}
@ -254,10 +254,10 @@ Image LoadImage(const char *fileName)
#if defined(SUPPORT_FILEFORMAT_ASTC)
else if (IsFileExtension(fileName, ".astc")) image = LoadASTC(fileName);
#endif
else TraceLog(WARNING, "[%s] Image fileformat not supported", fileName);
else TraceLog(LOG_WARNING, "[%s] Image fileformat not supported", fileName);
if (image.data != NULL) TraceLog(INFO, "[%s] Image loaded successfully (%ix%i)", fileName, image.width, image.height);
else TraceLog(WARNING, "[%s] Image could not be loaded", fileName);
if (image.data != NULL) TraceLog(LOG_INFO, "[%s] Image loaded successfully (%ix%i)", fileName, image.width, image.height);
else TraceLog(LOG_WARNING, "[%s] Image could not be loaded", fileName);
return image;
}
@ -315,7 +315,7 @@ Image LoadImageRaw(const char *fileName, int width, int height, int format, int
if (rawFile == NULL)
{
TraceLog(WARNING, "[%s] RAW image file could not be opened", fileName);
TraceLog(LOG_WARNING, "[%s] RAW image file could not be opened", fileName);
}
else
{
@ -333,7 +333,7 @@ Image LoadImageRaw(const char *fileName, int width, int height, int format, int
case UNCOMPRESSED_R4G4B4A4: image.data = (unsigned short *)malloc(size); break; // 16 bpp (4 bit alpha)
case UNCOMPRESSED_R8G8B8A8: image.data = (unsigned char *)malloc(size*4); size *= 4; break; // 32 bpp
case UNCOMPRESSED_R32G32B32: image.data = (float *)malloc(size*12); size *= 12; break; // 4 byte per channel (12 byte)
default: TraceLog(WARNING, "Image format not suported"); break;
default: TraceLog(LOG_WARNING, "Image format not suported"); break;
}
// NOTE: fread() returns num read elements instead of bytes,
@ -343,7 +343,7 @@ Image LoadImageRaw(const char *fileName, int width, int height, int format, int
// Check if data has been read successfully
if (bytes < size)
{
TraceLog(WARNING, "[%s] RAW image data can not be read, wrong requested format or size", fileName);
TraceLog(LOG_WARNING, "[%s] RAW image data can not be read, wrong requested format or size", fileName);
if (image.data != NULL) free(image.data);
}
@ -373,7 +373,7 @@ Texture2D LoadTexture(const char *fileName)
texture = LoadTextureFromImage(image);
UnloadImage(image);
}
else TraceLog(WARNING, "Texture could not be created");
else TraceLog(LOG_WARNING, "Texture could not be created");
return texture;
}
@ -391,7 +391,7 @@ Texture2D LoadTextureFromImage(Image image)
texture.mipmaps = image.mipmaps;
texture.format = image.format;
TraceLog(DEBUG, "[TEX ID %i] Parameters: %ix%i, %i mips, format %i", texture.id, texture.width, texture.height, texture.mipmaps, texture.format);
TraceLog(LOG_DEBUG, "[TEX ID %i] Parameters: %ix%i, %i mips, format %i", texture.id, texture.width, texture.height, texture.mipmaps, texture.format);
return texture;
}
@ -410,7 +410,7 @@ void UnloadImage(Image image)
free(image.data);
// NOTE: It becomes anoying every time a texture is loaded
//TraceLog(INFO, "Unloaded image data");
//TraceLog(LOG_INFO, "Unloaded image data");
}
// Unload texture from GPU memory (VRAM)
@ -420,7 +420,7 @@ void UnloadTexture(Texture2D texture)
{
rlDeleteTextures(texture.id);
TraceLog(INFO, "[TEX ID %i] Unloaded texture data from VRAM (GPU)", texture.id);
TraceLog(LOG_INFO, "[TEX ID %i] Unloaded texture data from VRAM (GPU)", texture.id);
}
}
@ -510,7 +510,7 @@ Color *GetImageData(Image image)
k += 3;
} break;
default: TraceLog(WARNING, "Format not supported for pixel data retrieval"); break;
default: TraceLog(LOG_WARNING, "Format not supported for pixel data retrieval"); break;
}
}
@ -540,11 +540,11 @@ Image GetTextureData(Texture2D texture)
}
else image.format = texture.format;
TraceLog(INFO, "Texture pixel data obtained successfully");
TraceLog(LOG_INFO, "Texture pixel data obtained successfully");
}
else TraceLog(WARNING, "Texture pixel data could not be obtained");
else TraceLog(LOG_WARNING, "Texture pixel data could not be obtained");
}
else TraceLog(WARNING, "Compressed texture data could not be obtained");
else TraceLog(LOG_WARNING, "Compressed texture data could not be obtained");
return image;
}
@ -564,7 +564,7 @@ void SaveImageAs(const char* fileName, Image image)
SavePNG(fileName, imgData, image.width, image.height, 4);
free(imgData);
TraceLog(INFO, "Image saved: %s", fileName);
TraceLog(LOG_INFO, "Image saved: %s", fileName);
#endif
}
@ -697,7 +697,7 @@ void ImageFormat(Image *image, int newFormat)
free(pixels);
}
else TraceLog(WARNING, "Image data format is compressed, can not be converted");
else TraceLog(LOG_WARNING, "Image data format is compressed, can not be converted");
}
}
@ -708,11 +708,11 @@ void ImageAlphaMask(Image *image, Image alphaMask)
{
if ((image->width != alphaMask.width) || (image->height != alphaMask.height))
{
TraceLog(WARNING, "Alpha mask must be same size as image");
TraceLog(LOG_WARNING, "Alpha mask must be same size as image");
}
else if (image->format >= COMPRESSED_DXT1_RGB)
{
TraceLog(WARNING, "Alpha mask can not be applied to compressed data formats");
TraceLog(LOG_WARNING, "Alpha mask can not be applied to compressed data formats");
}
else
{
@ -775,7 +775,7 @@ void ImageToPOT(Image *image, Color fillColor)
}
}
TraceLog(WARNING, "Image converted to POT: (%ix%i) -> (%ix%i)", image->width, image->height, potWidth, potHeight);
TraceLog(LOG_WARNING, "Image converted to POT: (%ix%i) -> (%ix%i)", image->width, image->height, potWidth, potHeight);
free(pixels); // Free pixels data
free(image->data); // Free old image data
@ -821,7 +821,7 @@ Image ImageCopy(Image image)
case COMPRESSED_PVRT_RGB:
case COMPRESSED_PVRT_RGBA: byteSize /= 2; break; // 4 bpp
case COMPRESSED_ASTC_8x8_RGBA: byteSize /= 4; break;// 2 bpp
default: TraceLog(WARNING, "Image format not recognized"); break;
default: TraceLog(LOG_WARNING, "Image format not recognized"); break;
}
newImage.data = malloc(byteSize);
@ -848,13 +848,13 @@ void ImageCrop(Image *image, Rectangle crop)
if ((crop.x + crop.width) > image->width)
{
crop.width = image->width - crop.x;
TraceLog(WARNING, "Crop rectangle width out of bounds, rescaled crop width: %i", crop.width);
TraceLog(LOG_WARNING, "Crop rectangle width out of bounds, rescaled crop width: %i", crop.width);
}
if ((crop.y + crop.height) > image->height)
{
crop.height = image->height - crop.y;
TraceLog(WARNING, "Crop rectangle height out of bounds, rescaled crop height: %i", crop.height);
TraceLog(LOG_WARNING, "Crop rectangle height out of bounds, rescaled crop height: %i", crop.height);
}
if ((crop.x < image->width) && (crop.y < image->height))
@ -886,7 +886,7 @@ void ImageCrop(Image *image, Rectangle crop)
}
else
{
TraceLog(WARNING, "Image can not be cropped, crop rectangle out of bounds");
TraceLog(LOG_WARNING, "Image can not be cropped, crop rectangle out of bounds");
}
}
@ -961,13 +961,13 @@ void ImageDraw(Image *dst, Image src, Rectangle srcRec, Rectangle dstRec)
if ((srcRec.x + srcRec.width) > src.width)
{
srcRec.width = src.width - srcRec.x;
TraceLog(WARNING, "Source rectangle width out of bounds, rescaled width: %i", srcRec.width);
TraceLog(LOG_WARNING, "Source rectangle width out of bounds, rescaled width: %i", srcRec.width);
}
if ((srcRec.y + srcRec.height) > src.height)
{
srcRec.height = src.height - srcRec.y;
TraceLog(WARNING, "Source rectangle height out of bounds, rescaled height: %i", srcRec.height);
TraceLog(LOG_WARNING, "Source rectangle height out of bounds, rescaled height: %i", srcRec.height);
cropRequired = true;
}
@ -988,14 +988,14 @@ void ImageDraw(Image *dst, Image src, Rectangle srcRec, Rectangle dstRec)
if ((dstRec.x + dstRec.width) > dst->width)
{
dstRec.width = dst->width - dstRec.x;
TraceLog(WARNING, "Destination rectangle width out of bounds, rescaled width: %i", dstRec.width);
TraceLog(LOG_WARNING, "Destination rectangle width out of bounds, rescaled width: %i", dstRec.width);
cropRequired = true;
}
if ((dstRec.y + dstRec.height) > dst->height)
{
dstRec.height = dst->height - dstRec.y;
TraceLog(WARNING, "Destination rectangle height out of bounds, rescaled height: %i", dstRec.height);
TraceLog(LOG_WARNING, "Destination rectangle height out of bounds, rescaled height: %i", dstRec.height);
cropRequired = true;
}
@ -1098,7 +1098,7 @@ Image ImageTextEx(SpriteFont font, const char *text, float fontSize, int spacing
if (fontSize > imSize.y)
{
float scaleFactor = fontSize/imSize.y;
TraceLog(INFO, "Scalefactor: %f", scaleFactor);
TraceLog(LOG_INFO, "Scalefactor: %f", scaleFactor);
// Using nearest-neighbor scaling algorithm for default font
if (font.texture.id == GetDefaultFont().texture.id) ImageResizeNN(&imText, (int)(imSize.x*scaleFactor), (int)(imSize.y*scaleFactor));
@ -1186,13 +1186,13 @@ void ImageDither(Image *image, int rBpp, int gBpp, int bBpp, int aBpp)
{
if (image->format >= COMPRESSED_DXT1_RGB)
{
TraceLog(WARNING, "Compressed data formats can not be dithered");
TraceLog(LOG_WARNING, "Compressed data formats can not be dithered");
return;
}
if ((rBpp+gBpp+bBpp+aBpp) > 16)
{
TraceLog(WARNING, "Unsupported dithering bpps (%ibpp), only 16bpp or lower modes supported", (rBpp+gBpp+bBpp+aBpp));
TraceLog(LOG_WARNING, "Unsupported dithering bpps (%ibpp), only 16bpp or lower modes supported", (rBpp+gBpp+bBpp+aBpp));
}
else
{
@ -1202,7 +1202,7 @@ void ImageDither(Image *image, int rBpp, int gBpp, int bBpp, int aBpp)
if ((image->format != UNCOMPRESSED_R8G8B8) && (image->format != UNCOMPRESSED_R8G8B8A8))
{
TraceLog(WARNING, "Image format is already 16bpp or lower, dithering could have no effect");
TraceLog(LOG_WARNING, "Image format is already 16bpp or lower, dithering could have no effect");
}
// Define new image format, check if desired bpp match internal known format
@ -1212,7 +1212,7 @@ void ImageDither(Image *image, int rBpp, int gBpp, int bBpp, int aBpp)
else
{
image->format = 0;
TraceLog(WARNING, "Unsupported dithered OpenGL internal format: %ibpp (R%iG%iB%iA%i)", (rBpp+gBpp+bBpp+aBpp), rBpp, gBpp, bBpp, aBpp);
TraceLog(LOG_WARNING, "Unsupported dithered OpenGL internal format: %ibpp (R%iG%iB%iA%i)", (rBpp+gBpp+bBpp+aBpp), rBpp, gBpp, bBpp, aBpp);
}
// NOTE: We will store the dithered data as unsigned short (16bpp)
@ -1652,7 +1652,7 @@ void GenTextureMipmaps(Texture2D *texture)
// Check if texture is POT
if ((potWidth != texture->width) || (potHeight != texture->height))
{
TraceLog(WARNING, "Limited NPOT support, no mipmaps available for NPOT textures");
TraceLog(LOG_WARNING, "Limited NPOT support, no mipmaps available for NPOT textures");
}
else rlglGenerateMipmaps(texture);
#else
@ -1712,7 +1712,7 @@ void SetTextureFilter(Texture2D texture, int filterMode)
}
else
{
TraceLog(WARNING, "[TEX ID %i] No mipmaps available for TRILINEAR texture filtering", texture.id);
TraceLog(LOG_WARNING, "[TEX ID %i] No mipmaps available for TRILINEAR texture filtering", texture.id);
// RL_FILTER_LINEAR - tex filter: BILINEAR, no mipmaps
rlTextureParameters(texture.id, RL_TEXTURE_MIN_FILTER, RL_FILTER_LINEAR);
@ -1887,7 +1887,7 @@ static Image LoadDDS(const char *fileName)
if (ddsFile == NULL)
{
TraceLog(WARNING, "[%s] DDS file could not be opened", fileName);
TraceLog(LOG_WARNING, "[%s] DDS file could not be opened", fileName);
}
else
{
@ -1898,7 +1898,7 @@ static Image LoadDDS(const char *fileName)
if (strncmp(filecode, "DDS ", 4) != 0)
{
TraceLog(WARNING, "[%s] DDS file does not seem to be a valid image", fileName);
TraceLog(LOG_WARNING, "[%s] DDS file does not seem to be a valid image", fileName);
}
else
{
@ -1907,11 +1907,11 @@ static Image LoadDDS(const char *fileName)
// Get the image header
fread(&ddsHeader, sizeof(DDSHeader), 1, ddsFile);
TraceLog(DEBUG, "[%s] DDS file header size: %i", fileName, sizeof(DDSHeader));
TraceLog(DEBUG, "[%s] DDS file pixel format size: %i", fileName, ddsHeader.ddspf.size);
TraceLog(DEBUG, "[%s] DDS file pixel format flags: 0x%x", fileName, ddsHeader.ddspf.flags);
TraceLog(DEBUG, "[%s] DDS file format: 0x%x", fileName, ddsHeader.ddspf.fourCC);
TraceLog(DEBUG, "[%s] DDS file bit count: 0x%x", fileName, ddsHeader.ddspf.rgbBitCount);
TraceLog(LOG_DEBUG, "[%s] DDS file header size: %i", fileName, sizeof(DDSHeader));
TraceLog(LOG_DEBUG, "[%s] DDS file pixel format size: %i", fileName, ddsHeader.ddspf.size);
TraceLog(LOG_DEBUG, "[%s] DDS file pixel format flags: 0x%x", fileName, ddsHeader.ddspf.flags);
TraceLog(LOG_DEBUG, "[%s] DDS file format: 0x%x", fileName, ddsHeader.ddspf.fourCC);
TraceLog(LOG_DEBUG, "[%s] DDS file bit count: 0x%x", fileName, ddsHeader.ddspf.rgbBitCount);
image.width = ddsHeader.width;
image.height = ddsHeader.height;
@ -1999,7 +1999,7 @@ static Image LoadDDS(const char *fileName)
if (ddsHeader.mipmapCount > 1) size = ddsHeader.pitchOrLinearSize*2;
else size = ddsHeader.pitchOrLinearSize;
TraceLog(DEBUG, "Pitch or linear size: %i", ddsHeader.pitchOrLinearSize);
TraceLog(LOG_DEBUG, "Pitch or linear size: %i", ddsHeader.pitchOrLinearSize);
image.data = (unsigned char*)malloc(size*sizeof(unsigned char));
@ -2073,7 +2073,7 @@ static Image LoadPKM(const char *fileName)
if (pkmFile == NULL)
{
TraceLog(WARNING, "[%s] PKM file could not be opened", fileName);
TraceLog(LOG_WARNING, "[%s] PKM file could not be opened", fileName);
}
else
{
@ -2084,7 +2084,7 @@ static Image LoadPKM(const char *fileName)
if (strncmp(pkmHeader.id, "PKM ", 4) != 0)
{
TraceLog(WARNING, "[%s] PKM file does not seem to be a valid image", fileName);
TraceLog(LOG_WARNING, "[%s] PKM file does not seem to be a valid image", fileName);
}
else
{
@ -2093,9 +2093,9 @@ static Image LoadPKM(const char *fileName)
pkmHeader.width = ((pkmHeader.width & 0x00FF) << 8) | ((pkmHeader.width & 0xFF00) >> 8);
pkmHeader.height = ((pkmHeader.height & 0x00FF) << 8) | ((pkmHeader.height & 0xFF00) >> 8);
TraceLog(DEBUG, "PKM (ETC) image width: %i", pkmHeader.width);
TraceLog(DEBUG, "PKM (ETC) image height: %i", pkmHeader.height);
TraceLog(DEBUG, "PKM (ETC) image format: %i", pkmHeader.format);
TraceLog(LOG_DEBUG, "PKM (ETC) image width: %i", pkmHeader.width);
TraceLog(LOG_DEBUG, "PKM (ETC) image height: %i", pkmHeader.height);
TraceLog(LOG_DEBUG, "PKM (ETC) image format: %i", pkmHeader.format);
image.width = pkmHeader.width;
image.height = pkmHeader.height;
@ -2167,7 +2167,7 @@ static Image LoadKTX(const char *fileName)
if (ktxFile == NULL)
{
TraceLog(WARNING, "[%s] KTX image file could not be opened", fileName);
TraceLog(LOG_WARNING, "[%s] KTX image file could not be opened", fileName);
}
else
{
@ -2179,7 +2179,7 @@ static Image LoadKTX(const char *fileName)
if ((ktxHeader.id[1] != 'K') || (ktxHeader.id[2] != 'T') || (ktxHeader.id[3] != 'X') ||
(ktxHeader.id[4] != ' ') || (ktxHeader.id[5] != '1') || (ktxHeader.id[6] != '1'))
{
TraceLog(WARNING, "[%s] KTX file does not seem to be a valid file", fileName);
TraceLog(LOG_WARNING, "[%s] KTX file does not seem to be a valid file", fileName);
}
else
{
@ -2187,9 +2187,9 @@ static Image LoadKTX(const char *fileName)
image.height = ktxHeader.height;
image.mipmaps = ktxHeader.mipmapLevels;
TraceLog(DEBUG, "KTX (ETC) image width: %i", ktxHeader.width);
TraceLog(DEBUG, "KTX (ETC) image height: %i", ktxHeader.height);
TraceLog(DEBUG, "KTX (ETC) image format: 0x%x", ktxHeader.glInternalFormat);
TraceLog(LOG_DEBUG, "KTX (ETC) image width: %i", ktxHeader.width);
TraceLog(LOG_DEBUG, "KTX (ETC) image height: %i", ktxHeader.height);
TraceLog(LOG_DEBUG, "KTX (ETC) image format: 0x%x", ktxHeader.glInternalFormat);
unsigned char unused;
@ -2288,7 +2288,7 @@ static Image LoadPVR(const char *fileName)
if (pvrFile == NULL)
{
TraceLog(WARNING, "[%s] PVR file could not be opened", fileName);
TraceLog(LOG_WARNING, "[%s] PVR file could not be opened", fileName);
}
else
{
@ -2307,7 +2307,7 @@ static Image LoadPVR(const char *fileName)
if ((pvrHeader.id[0] != 'P') || (pvrHeader.id[1] != 'V') || (pvrHeader.id[2] != 'R') || (pvrHeader.id[3] != 3))
{
TraceLog(WARNING, "[%s] PVR file does not seem to be a valid image", fileName);
TraceLog(LOG_WARNING, "[%s] PVR file does not seem to be a valid image", fileName);
}
else
{
@ -2368,7 +2368,7 @@ static Image LoadPVR(const char *fileName)
fread(image.data, dataSize, 1, pvrFile);
}
}
else if (pvrVersion == 52) TraceLog(INFO, "PVR v2 not supported, update your files to PVR v3");
else if (pvrVersion == 52) TraceLog(LOG_INFO, "PVR v2 not supported, update your files to PVR v3");
fclose(pvrFile); // Close file pointer
}
@ -2412,7 +2412,7 @@ static Image LoadASTC(const char *fileName)
if (astcFile == NULL)
{
TraceLog(WARNING, "[%s] ASTC file could not be opened", fileName);
TraceLog(LOG_WARNING, "[%s] ASTC file could not be opened", fileName);
}
else
{
@ -2423,7 +2423,7 @@ static Image LoadASTC(const char *fileName)
if ((astcHeader.id[3] != 0x5c) || (astcHeader.id[2] != 0xa1) || (astcHeader.id[1] != 0xab) || (astcHeader.id[0] != 0x13))
{
TraceLog(WARNING, "[%s] ASTC file does not seem to be a valid image", fileName);
TraceLog(LOG_WARNING, "[%s] ASTC file does not seem to be a valid image", fileName);
}
else
{
@ -2434,9 +2434,9 @@ static Image LoadASTC(const char *fileName)
// NOTE: ASTC format only contains one mipmap level
image.mipmaps = 1;
TraceLog(DEBUG, "ASTC image width: %i", image.width);
TraceLog(DEBUG, "ASTC image height: %i", image.height);
TraceLog(DEBUG, "ASTC image blocks: %ix%i", astcHeader.blockX, astcHeader.blockY);
TraceLog(LOG_DEBUG, "ASTC image width: %i", image.width);
TraceLog(LOG_DEBUG, "ASTC image height: %i", image.height);
TraceLog(LOG_DEBUG, "ASTC image blocks: %ix%i", astcHeader.blockX, astcHeader.blockY);
// NOTE: Each block is always stored in 128bit so we can calculate the bpp
int bpp = 128/(astcHeader.blockX*astcHeader.blockY);
@ -2452,7 +2452,7 @@ static Image LoadASTC(const char *fileName)
if (bpp == 8) image.format = COMPRESSED_ASTC_4x4_RGBA;
else if (bpp == 2) image.format = COMPRESSED_ASTC_4x4_RGBA;
}
else TraceLog(WARNING, "[%s] ASTC block size configuration not supported", fileName);
else TraceLog(LOG_WARNING, "[%s] ASTC block size configuration not supported", fileName);
}
fclose(astcFile);

View file

@ -14,10 +14,10 @@
*
* #define SUPPORT_TRACELOG
* Show TraceLog() output messages
* NOTE: By default DEBUG traces not shown
* NOTE: By default LOG_DEBUG traces not shown
*
* #define SUPPORT_TRACELOG_DEBUG
* Show TraceLog() DEBUG messages
* Show TraceLog() LOG_DEBUG messages
*
* DEPENDENCIES:
* stb_image_write - BMP/PNG writting functions
@ -45,7 +45,7 @@
**********************************************************************************************/
#define SUPPORT_TRACELOG // Output tracelog messages
//#define SUPPORT_TRACELOG_DEBUG // Avoid DEBUG messages tracing
//#define SUPPORT_TRACELOG_DEBUG // Avoid LOG_DEBUG messages tracing
#include "utils.h"
@ -89,7 +89,7 @@ static int android_close(void *cookie);
// Module Functions Definition - Utilities
//----------------------------------------------------------------------------------
// Output trace log messages
// Show trace log messages (LOG_INFO, LOG_WARNING, LOG_ERROR, LOG_DEBUG)
void TraceLog(int msgType, const char *text, ...)
{
#if defined(SUPPORT_TRACELOG)
@ -102,10 +102,10 @@ void TraceLog(int msgType, const char *text, ...)
switch(msgType)
{
case INFO: strcpy(buffer, "INFO: "); break;
case ERROR: strcpy(buffer, "ERROR: "); break;
case WARNING: strcpy(buffer, "WARNING: "); break;
case DEBUG: strcpy(buffer, "DEBUG: "); break;
case LOG_INFO: strcpy(buffer, "INFO: "); break;
case LOG_ERROR: strcpy(buffer, "ERROR: "); break;
case LOG_WARNING: strcpy(buffer, "WARNING: "); break;
case LOG_DEBUG: strcpy(buffer, "DEBUG: "); break;
default: break;
}
@ -118,19 +118,19 @@ void TraceLog(int msgType, const char *text, ...)
#if defined(PLATFORM_ANDROID)
switch(msgType)
{
case INFO: __android_log_vprint(ANDROID_LOG_INFO, "raylib", buffer, args); break;
case ERROR: __android_log_vprint(ANDROID_LOG_ERROR, "raylib", buffer, args); break;
case WARNING: __android_log_vprint(ANDROID_LOG_WARN, "raylib", buffer, args); break;
case DEBUG: if (traceDebugMsgs) __android_log_vprint(ANDROID_LOG_DEBUG, "raylib", buffer, args); break;
case LOG_INFO: __android_log_vprint(ANDROID_LOG_INFO, "raylib", buffer, args); break;
case LOG_ERROR: __android_log_vprint(ANDROID_LOG_ERROR, "raylib", buffer, args); break;
case LOG_WARNING: __android_log_vprint(ANDROID_LOG_WARN, "raylib", buffer, args); break;
case LOG_DEBUG: if (traceDebugMsgs) __android_log_vprint(ANDROID_LOG_DEBUG, "raylib", buffer, args); break;
default: break;
}
#else
if ((msgType != DEBUG) || ((msgType == DEBUG) && (traceDebugMsgs))) vprintf(buffer, args);
if ((msgType != LOG_DEBUG) || ((msgType == LOG_DEBUG) && (traceDebugMsgs))) vprintf(buffer, args);
#endif
va_end(args);
if (msgType == ERROR) exit(1); // If ERROR message, exit program
if (msgType == LOG_ERROR) exit(1); // If LOG_ERROR message, exit program
#endif // SUPPORT_TRACELOG
}
@ -195,7 +195,7 @@ static int android_read(void *cookie, char *buf, int size)
static int android_write(void *cookie, const char *buf, int size)
{
TraceLog(ERROR, "Can't provide write access to the APK");
TraceLog(LOG_ERROR, "Can't provide write access to the APK");
return EACCES;
}