Corrected some warnings

This commit is contained in:
Ray 2016-12-05 01:14:18 +01:00
parent ab9f5d5780
commit 377dcb025f
10 changed files with 108 additions and 99 deletions

View File

@ -411,6 +411,7 @@ Sound LoadSoundFromRES(const char *rresName, int resId)
else
{
// Depending on type, skip the right amount of parameters
/* TODO: Review
switch (infoHeader.type)
{
case 0: fseek(rresFile, 6, SEEK_CUR); break; // IMAGE: Jump 6 bytes of parameters
@ -420,6 +421,7 @@ Sound LoadSoundFromRES(const char *rresName, int resId)
case 4: break; // RAW: No parameters
default: break;
}
*/
// Jump DATA to read next infoHeader
fseek(rresFile, infoHeader.size, SEEK_CUR);
@ -604,7 +606,7 @@ void WaveFormat(Wave *wave, int sampleRate, int sampleSize, int channels)
// Copy a wave to a new wave
Wave WaveCopy(Wave wave)
{
Wave newWave;
Wave newWave = { 0 };
if (wave.sampleSize == 8) newWave.data = (unsigned char *)malloc(wave.sampleCount*wave.channels*sizeof(unsigned char));
else if (wave.sampleSize == 16) newWave.data = (short *)malloc(wave.sampleCount*wave.channels*sizeof(short));
@ -822,8 +824,8 @@ void UpdateMusicStream(Music music)
if (processed > 0)
{
bool active = true;
short pcm[AUDIO_BUFFER_SIZE];
float pcmf[AUDIO_BUFFER_SIZE];
short pcm[AUDIO_BUFFER_SIZE]; // TODO: Dynamic allocation (uses more than 16KB of stack)
float pcmf[AUDIO_BUFFER_SIZE]; // TODO: Dynamic allocation (uses more than 16KB of stack)
int numBuffersToProcess = processed;
int numSamples = 0; // Total size of data steamed in L+R samples for xm floats,
@ -952,7 +954,7 @@ float GetMusicTimePlayed(Music music)
float secondsPlayed = 0.0f;
unsigned int samplesPlayed = music->totalSamples - music->samplesLeft;
secondsPlayed = (float)samplesPlayed/(music->stream.sampleRate*music->stream.channels);
secondsPlayed = (float)(samplesPlayed/(music->stream.sampleRate*music->stream.channels));
return secondsPlayed;
}
@ -1004,17 +1006,17 @@ AudioStream InitAudioStream(unsigned int sampleRate, unsigned int sampleSize, un
{
if (stream.sampleSize == 8)
{
unsigned char pcm[AUDIO_BUFFER_SIZE] = { 0 };
unsigned char pcm[AUDIO_BUFFER_SIZE] = { 0 }; // TODO: Dynamic allocation (uses more than 16KB of stack)
alBufferData(stream.buffers[i], stream.format, pcm, AUDIO_BUFFER_SIZE*sizeof(unsigned char), stream.sampleRate);
}
else if (stream.sampleSize == 16)
{
short pcm[AUDIO_BUFFER_SIZE] = { 0 };
short pcm[AUDIO_BUFFER_SIZE] = { 0 }; // TODO: Dynamic allocation (uses more than 16KB of stack)
alBufferData(stream.buffers[i], stream.format, pcm, AUDIO_BUFFER_SIZE*sizeof(short), stream.sampleRate);
}
else if (stream.sampleSize == 32)
{
float pcm[AUDIO_BUFFER_SIZE] = { 0.0f };
float pcm[AUDIO_BUFFER_SIZE] = { 0.0f }; // TODO: Dynamic allocation (uses more than 16KB of stack)
alBufferData(stream.buffers[i], stream.format, pcm, AUDIO_BUFFER_SIZE*sizeof(float), stream.sampleRate);
}
}

View File

@ -223,15 +223,15 @@ void SetCameraMode(Camera camera, int mode)
float dy = v2.y - v1.y;
float dz = v2.z - v1.z;
cameraTargetDistance = sqrt(dx*dx + dy*dy + dz*dz);
cameraTargetDistance = sqrtf(dx*dx + dy*dy + dz*dz);
Vector2 distance = { 0.0f, 0.0f };
distance.x = sqrt(dx*dx + dz*dz);
distance.y = sqrt(dx*dx + dy*dy);
distance.x = sqrtf(dx*dx + dz*dz);
distance.y = sqrtf(dx*dx + dy*dy);
// Camera angle calculation
cameraAngle.x = asin(fabs(dx)/distance.x); // Camera angle in plane XZ (0 aligned with Z, move positive CCW)
cameraAngle.y = -asin(fabs(dy)/distance.y); // Camera angle in plane XY (0 aligned with X, move positive CW)
cameraAngle.x = asinf(fabsf(dx)/distance.x); // Camera angle in plane XZ (0 aligned with Z, move positive CCW)
cameraAngle.y = -asinf(fabsf(dy)/distance.y); // Camera angle in plane XY (0 aligned with X, move positive CW)
// NOTE: Just testing what cameraAngle means
//cameraAngle.x = 0.0f*DEG2RAD; // Camera angle in plane XZ (0 aligned with Z, move positive CCW)
@ -285,10 +285,10 @@ void UpdateCamera(Camera *camera)
{
HideCursor();
if (mousePosition.x < screenHeight/3) SetMousePosition((Vector2){ screenWidth - screenHeight/3, mousePosition.y });
else if (mousePosition.y < screenHeight/3) SetMousePosition((Vector2){ mousePosition.x, screenHeight - screenHeight/3 });
else if (mousePosition.x > (screenWidth - screenHeight/3)) SetMousePosition((Vector2){ screenHeight/3, mousePosition.y });
else if (mousePosition.y > (screenHeight - screenHeight/3)) SetMousePosition((Vector2){ mousePosition.x, screenHeight/3 });
if (mousePosition.x < (float)screenHeight/3.0f) SetMousePosition((Vector2){ screenWidth - screenHeight/3, mousePosition.y });
else if (mousePosition.y < (float)screenHeight/3.0f) SetMousePosition((Vector2){ mousePosition.x, screenHeight - screenHeight/3 });
else if (mousePosition.x > (screenWidth - (float)screenHeight/3.0f)) SetMousePosition((Vector2){ screenHeight/3, mousePosition.y });
else if (mousePosition.y > (screenHeight - (float)screenHeight/3.0f)) SetMousePosition((Vector2){ mousePosition.x, screenHeight/3 });
else
{
mousePositionDelta.x = mousePosition.x - previousMousePosition.x;
@ -321,6 +321,7 @@ void UpdateCamera(Camera *camera)
if (cameraTargetDistance > CAMERA_FREE_DISTANCE_MAX_CLAMP) cameraTargetDistance = CAMERA_FREE_DISTANCE_MAX_CLAMP;
}
// Camera looking down
// TODO: Review, weird comparisson of cameraTargetDistance == 120.0f?
else if ((camera->position.y > camera->target.y) && (cameraTargetDistance == CAMERA_FREE_DISTANCE_MAX_CLAMP) && (mouseWheelMove < 0))
{
camera->target.x += mouseWheelMove*(camera->target.x - camera->position.x)*CAMERA_MOUSE_SCROLL_SENSITIVITY/cameraTargetDistance;
@ -341,6 +342,7 @@ void UpdateCamera(Camera *camera)
if (cameraTargetDistance < CAMERA_FREE_DISTANCE_MIN_CLAMP) cameraTargetDistance = CAMERA_FREE_DISTANCE_MIN_CLAMP;
}
// Camera looking up
// TODO: Review, weird comparisson of cameraTargetDistance == 120.0f?
else if ((camera->position.y < camera->target.y) && (cameraTargetDistance == CAMERA_FREE_DISTANCE_MAX_CLAMP) && (mouseWheelMove < 0))
{
camera->target.x += mouseWheelMove*(camera->target.x - camera->position.x)*CAMERA_MOUSE_SCROLL_SENSITIVITY/cameraTargetDistance;
@ -385,9 +387,9 @@ void UpdateCamera(Camera *camera)
else
{
// Camera panning
camera->target.x += ((mousePositionDelta.x*-CAMERA_FREE_MOUSE_SENSITIVITY)*cos(cameraAngle.x) + (mousePositionDelta.y*CAMERA_FREE_MOUSE_SENSITIVITY)*sin(cameraAngle.x)*sin(cameraAngle.y))*(cameraTargetDistance/CAMERA_FREE_PANNING_DIVIDER);
camera->target.y += ((mousePositionDelta.y*CAMERA_FREE_MOUSE_SENSITIVITY)*cos(cameraAngle.y))*(cameraTargetDistance/CAMERA_FREE_PANNING_DIVIDER);
camera->target.z += ((mousePositionDelta.x*CAMERA_FREE_MOUSE_SENSITIVITY)*sin(cameraAngle.x) + (mousePositionDelta.y*CAMERA_FREE_MOUSE_SENSITIVITY)*cos(cameraAngle.x)*sin(cameraAngle.y))*(cameraTargetDistance/CAMERA_FREE_PANNING_DIVIDER);
camera->target.x += ((mousePositionDelta.x*-CAMERA_FREE_MOUSE_SENSITIVITY)*cosf(cameraAngle.x) + (mousePositionDelta.y*CAMERA_FREE_MOUSE_SENSITIVITY)*sinf(cameraAngle.x)*sinf(cameraAngle.y))*(cameraTargetDistance/CAMERA_FREE_PANNING_DIVIDER);
camera->target.y += ((mousePositionDelta.y*CAMERA_FREE_MOUSE_SENSITIVITY)*cosf(cameraAngle.y))*(cameraTargetDistance/CAMERA_FREE_PANNING_DIVIDER);
camera->target.z += ((mousePositionDelta.x*CAMERA_FREE_MOUSE_SENSITIVITY)*sinf(cameraAngle.x) + (mousePositionDelta.y*CAMERA_FREE_MOUSE_SENSITIVITY)*cosf(cameraAngle.x)*sinf(cameraAngle.y))*(cameraTargetDistance/CAMERA_FREE_PANNING_DIVIDER);
}
}
@ -404,19 +406,19 @@ void UpdateCamera(Camera *camera)
case CAMERA_FIRST_PERSON:
case CAMERA_THIRD_PERSON:
{
camera->position.x += (sin(cameraAngle.x)*direction[MOVE_BACK] -
sin(cameraAngle.x)*direction[MOVE_FRONT] -
cos(cameraAngle.x)*direction[MOVE_LEFT] +
cos(cameraAngle.x)*direction[MOVE_RIGHT])/PLAYER_MOVEMENT_SENSITIVITY;
camera->position.x += (sinf(cameraAngle.x)*direction[MOVE_BACK] -
sinf(cameraAngle.x)*direction[MOVE_FRONT] -
cosf(cameraAngle.x)*direction[MOVE_LEFT] +
cosf(cameraAngle.x)*direction[MOVE_RIGHT])/PLAYER_MOVEMENT_SENSITIVITY;
camera->position.y += (sin(cameraAngle.y)*direction[MOVE_FRONT] -
sin(cameraAngle.y)*direction[MOVE_BACK] +
camera->position.y += (sinf(cameraAngle.y)*direction[MOVE_FRONT] -
sinf(cameraAngle.y)*direction[MOVE_BACK] +
1.0f*direction[MOVE_UP] - 1.0f*direction[MOVE_DOWN])/PLAYER_MOVEMENT_SENSITIVITY;
camera->position.z += (cos(cameraAngle.x)*direction[MOVE_BACK] -
cos(cameraAngle.x)*direction[MOVE_FRONT] +
sin(cameraAngle.x)*direction[MOVE_LEFT] -
sin(cameraAngle.x)*direction[MOVE_RIGHT])/PLAYER_MOVEMENT_SENSITIVITY;
camera->position.z += (cosf(cameraAngle.x)*direction[MOVE_BACK] -
cosf(cameraAngle.x)*direction[MOVE_FRONT] +
sinf(cameraAngle.x)*direction[MOVE_LEFT] -
sinf(cameraAngle.x)*direction[MOVE_RIGHT])/PLAYER_MOVEMENT_SENSITIVITY;
bool isMoving = false; // Required for swinging
@ -439,9 +441,9 @@ void UpdateCamera(Camera *camera)
if (cameraTargetDistance < CAMERA_THIRD_PERSON_DISTANCE_CLAMP) cameraTargetDistance = CAMERA_THIRD_PERSON_DISTANCE_CLAMP;
// Camera is always looking at player
camera->target.x = camera->position.x + CAMERA_THIRD_PERSON_OFFSET.x*cos(cameraAngle.x) + CAMERA_THIRD_PERSON_OFFSET.z*sin(cameraAngle.x);
camera->target.x = camera->position.x + CAMERA_THIRD_PERSON_OFFSET.x*cosf(cameraAngle.x) + CAMERA_THIRD_PERSON_OFFSET.z*sinf(cameraAngle.x);
camera->target.y = camera->position.y + CAMERA_THIRD_PERSON_OFFSET.y;
camera->target.z = camera->position.z + CAMERA_THIRD_PERSON_OFFSET.z*sin(cameraAngle.x) - CAMERA_THIRD_PERSON_OFFSET.x*sin(cameraAngle.x);
camera->target.z = camera->position.z + CAMERA_THIRD_PERSON_OFFSET.z*sinf(cameraAngle.x) - CAMERA_THIRD_PERSON_OFFSET.x*sinf(cameraAngle.x);
}
else // CAMERA_FIRST_PERSON
{
@ -450,18 +452,18 @@ void UpdateCamera(Camera *camera)
else if (cameraAngle.y < CAMERA_FIRST_PERSON_MAX_CLAMP*DEG2RAD) cameraAngle.y = CAMERA_FIRST_PERSON_MAX_CLAMP*DEG2RAD;
// Camera is always looking at player
camera->target.x = camera->position.x - sin(cameraAngle.x)*CAMERA_FIRST_PERSON_FOCUS_DISTANCE;
camera->target.y = camera->position.y + sin(cameraAngle.y)*CAMERA_FIRST_PERSON_FOCUS_DISTANCE;
camera->target.z = camera->position.z - cos(cameraAngle.x)*CAMERA_FIRST_PERSON_FOCUS_DISTANCE;
camera->target.x = camera->position.x - sinf(cameraAngle.x)*CAMERA_FIRST_PERSON_FOCUS_DISTANCE;
camera->target.y = camera->position.y + sinf(cameraAngle.y)*CAMERA_FIRST_PERSON_FOCUS_DISTANCE;
camera->target.z = camera->position.z - cosf(cameraAngle.x)*CAMERA_FIRST_PERSON_FOCUS_DISTANCE;
if (isMoving) swingCounter++;
// Camera position update
// NOTE: On CAMERA_FIRST_PERSON player Y-movement is limited to player 'eyes position'
camera->position.y = playerEyesPosition - sin(swingCounter/CAMERA_FIRST_PERSON_STEP_TRIGONOMETRIC_DIVIDER)/CAMERA_FIRST_PERSON_STEP_DIVIDER;
camera->position.y = playerEyesPosition - sinf(swingCounter/CAMERA_FIRST_PERSON_STEP_TRIGONOMETRIC_DIVIDER)/CAMERA_FIRST_PERSON_STEP_DIVIDER;
camera->up.x = sin(swingCounter/(CAMERA_FIRST_PERSON_STEP_TRIGONOMETRIC_DIVIDER*2))/CAMERA_FIRST_PERSON_WAVING_DIVIDER;
camera->up.z = -sin(swingCounter/(CAMERA_FIRST_PERSON_STEP_TRIGONOMETRIC_DIVIDER*2))/CAMERA_FIRST_PERSON_WAVING_DIVIDER;
camera->up.x = sinf(swingCounter/(CAMERA_FIRST_PERSON_STEP_TRIGONOMETRIC_DIVIDER*2))/CAMERA_FIRST_PERSON_WAVING_DIVIDER;
camera->up.z = -sinf(swingCounter/(CAMERA_FIRST_PERSON_STEP_TRIGONOMETRIC_DIVIDER*2))/CAMERA_FIRST_PERSON_WAVING_DIVIDER;
}
} break;
default: break;
@ -473,10 +475,10 @@ void UpdateCamera(Camera *camera)
(cameraMode == CAMERA_THIRD_PERSON))
{
// TODO: It seems camera->position is not correctly updated or some rounding issue makes the camera move straight to camera->target...
camera->position.x = sin(cameraAngle.x)*cameraTargetDistance*cos(cameraAngle.y) + camera->target.x;
if (cameraAngle.y <= 0.0f) camera->position.y = sin(cameraAngle.y)*cameraTargetDistance*sin(cameraAngle.y) + camera->target.y;
else camera->position.y = -sin(cameraAngle.y)*cameraTargetDistance*sin(cameraAngle.y) + camera->target.y;
camera->position.z = cos(cameraAngle.x)*cameraTargetDistance*cos(cameraAngle.y) + camera->target.z;
camera->position.x = sinf(cameraAngle.x)*cameraTargetDistance*cosf(cameraAngle.y) + camera->target.x;
if (cameraAngle.y <= 0.0f) camera->position.y = sinf(cameraAngle.y)*cameraTargetDistance*sinf(cameraAngle.y) + camera->target.y;
else camera->position.y = -sinf(cameraAngle.y)*cameraTargetDistance*sinf(cameraAngle.y) + camera->target.y;
camera->position.z = cosf(cameraAngle.x)*cameraTargetDistance*cosf(cameraAngle.y) + camera->target.z;
}
}

View File

@ -1089,7 +1089,7 @@ Vector2 GetWorldToScreen(Vector3 position, Camera camera)
QuaternionTransform(&worldPos, matProj);
// Calculate normalized device coordinates (inverted y)
Vector3 ndcPos = { worldPos.x/worldPos.w, -worldPos.y/worldPos.w, worldPos.z/worldPos.z };
Vector3 ndcPos = { worldPos.x/worldPos.w, -worldPos.y/worldPos.w, worldPos.z/worldPos.w };
// Calculate 2d screen position vector
Vector2 screenPosition = { (ndcPos.x + 1.0f)/2.0f*(float)GetScreenWidth(), (ndcPos.y + 1.0f)/2.0f*(float)GetScreenHeight() };

View File

@ -179,7 +179,7 @@ static int tapCounter = 0; // TAP counter (one tap implies
// Hold gesture variables
static bool resetHold = false; // HOLD reset to get first touch point again
static float timeHold = 0.0f; // HOLD duration in milliseconds
static double timeHold = 0.0f; // HOLD duration in milliseconds
// Drag gesture variables
static Vector2 dragVector = { 0.0f , 0.0f }; // DRAG vector (between initial and current position)
@ -423,11 +423,11 @@ float GetGestureHoldDuration(void)
{
// NOTE: time is calculated on current gesture HOLD
float time = 0.0f;
double time = 0.0;
if (currentGesture == GESTURE_HOLD) time = (float)GetCurrentTime() - timeHold;
if (currentGesture == GESTURE_HOLD) time = GetCurrentTime() - timeHold;
return time;
return (float)time;
}
// Get drag vector (between initial touch point to current)
@ -474,7 +474,7 @@ static float Vector2Angle(Vector2 initialPosition, Vector2 finalPosition)
{
float angle;
angle = atan2(finalPosition.y - initialPosition.y, finalPosition.x - initialPosition.x)*(180.0f/PI);
angle = atan2f(finalPosition.y - initialPosition.y, finalPosition.x - initialPosition.x)*(180.0f/PI);
if (angle < 0) angle += 360.0f;
@ -489,7 +489,7 @@ static float Vector2Distance(Vector2 v1, Vector2 v2)
float dx = v2.x - v1.x;
float dy = v2.y - v1.y;
result = sqrt(dx*dx + dy*dy);
result = (float)sqrt(dx*dx + dy*dy);
return result;
}

View File

@ -707,6 +707,7 @@ Model LoadModelFromRES(const char *rresName, int resId)
else
{
// Depending on type, skip the right amount of parameters
/* Review
switch (infoHeader.type)
{
case 0: fseek(rresFile, 6, SEEK_CUR); break; // IMAGE: Jump 6 bytes of parameters
@ -716,6 +717,7 @@ Model LoadModelFromRES(const char *rresName, int resId)
case 4: break; // RAW: No parameters
default: break;
}
*/
// Jump DATA to read next infoHeader
fseek(rresFile, infoHeader.size, SEEK_CUR);
@ -1517,8 +1519,8 @@ bool CheckCollisionRayBox(Ray ray, BoundingBox box)
t[3] = (box.max.y - ray.position.y)/ray.direction.y;
t[4] = (box.min.z - ray.position.z)/ray.direction.z;
t[5] = (box.max.z - ray.position.z)/ray.direction.z;
t[6] = fmax(fmax(fmin(t[0], t[1]), fmin(t[2], t[3])), fmin(t[4], t[5]));
t[7] = fmin(fmin(fmax(t[0], t[1]), fmax(t[2], t[3])), fmax(t[4], t[5]));
t[6] = (float)fmax(fmax(fmin(t[0], t[1]), fmin(t[2], t[3])), fmin(t[4], t[5]));
t[7] = (float)fmin(fmin(fmax(t[0], t[1]), fmax(t[2], t[3])), fmax(t[4], t[5]));
collision = !(t[7] < 0 || t[6] > t[7]);

View File

@ -222,16 +222,16 @@ RMDEF Vector3 VectorPerpendicular(Vector3 v)
{
Vector3 result;
float min = fabs(v.x);
float min = fabsf(v.x);
Vector3 cardinalAxis = {1.0f, 0.0f, 0.0f};
if (fabs(v.y) < min)
if (fabsf(v.y) < min)
{
min = fabs(v.y);
min = fabsf(v.y);
cardinalAxis = (Vector3){0.0f, 1.0f, 0.0f};
}
if(fabs(v.z) < min)
if(fabsf(v.z) < min)
{
cardinalAxis = (Vector3){0.0f, 0.0f, 1.0f};
}
@ -256,7 +256,7 @@ RMDEF float VectorLength(const Vector3 v)
{
float length;
length = sqrt(v.x*v.x + v.y*v.y + v.z*v.z);
length = sqrtf(v.x*v.x + v.y*v.y + v.z*v.z);
return length;
}
@ -284,7 +284,7 @@ RMDEF void VectorNormalize(Vector3 *v)
length = VectorLength(*v);
if (length == 0) length = 1.0f;
if (length == 0.0f) length = 1.0f;
ilength = 1.0f/length;
@ -302,7 +302,7 @@ RMDEF float VectorDistance(Vector3 v1, Vector3 v2)
float dy = v2.y - v1.y;
float dz = v2.z - v1.z;
result = sqrt(dx*dx + dy*dy + dz*dz);
result = sqrtf(dx*dx + dy*dy + dz*dz);
return result;
}
@ -590,7 +590,7 @@ RMDEF Matrix MatrixRotate(Vector3 axis, float angle)
float x = axis.x, y = axis.y, z = axis.z;
float length = sqrt(x*x + y*y + z*z);
float length = sqrtf(x*x + y*y + z*z);
if ((length != 1.0f) && (length != 0.0f))
{

View File

@ -902,6 +902,10 @@ void rlDisableTexture(void)
#if defined(GRAPHICS_API_OPENGL_11)
glDisable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, 0);
#else
// NOTE: If quads batch limit is reached,
// we force a draw call and next batch starts
if (quads.vCounter/4 >= MAX_QUADS_BATCH) rlglDraw();
#endif
}
@ -922,11 +926,11 @@ void rlTextureParameters(unsigned int id, int param, int value)
case RL_TEXTURE_MIN_FILTER: glTexParameteri(GL_TEXTURE_2D, param, value); break;
case RL_TEXTURE_ANISOTROPIC_FILTER:
{
if (value <= maxAnisotropicLevel) glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 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);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, value);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, (float)value);
}
else TraceLog(WARNING, "Anisotropic filtering not supported");
} break;
@ -1776,7 +1780,7 @@ void rlglGenerateMipmaps(Texture2D *texture)
#define MIN(a,b) (((a)<(b))?(a):(b))
#define MAX(a,b) (((a)>(b))?(a):(b))
texture->mipmaps = 1 + floor(log2(MAX(texture->width, texture->height)));
texture->mipmaps = 1 + (int)floor(log2(MAX(texture->width, texture->height)));
#endif
}
else TraceLog(WARNING, "[TEX ID %i] Mipmaps can not be generated", texture->id);

View File

@ -453,16 +453,17 @@ bool CheckCollisionCircleRec(Vector2 center, float radius, Rectangle rec)
int recCenterX = rec.x + rec.width/2;
int recCenterY = rec.y + rec.height/2;
float dx = fabs(center.x - recCenterX);
float dy = fabs(center.y - recCenterY);
float dx = fabsf(center.x - recCenterX);
float dy = fabsf(center.y - recCenterY);
if (dx > (rec.width/2 + radius)) { return false; }
if (dy > (rec.height/2 + radius)) { return false; }
if (dx > ((float)rec.width/2.0f + radius)) { return false; }
if (dy > ((float)rec.height/2.0f + radius)) { return false; }
if (dx <= (rec.width/2)) { return true; }
if (dy <= (rec.height/2)) { return true; }
if (dx <= ((float)rec.width/2.0f)) { return true; }
if (dy <= ((float)rec.height/2.0f)) { return true; }
float cornerDistanceSq = (dx - rec.width/2)*(dx - rec.width/2) + (dy - rec.height/2)*(dy - rec.height/2);
float cornerDistanceSq = (dx - (float)rec.width/2.0f)*(dx - (float)rec.width/2.0f) +
(dy - (float)rec.height/2.0f)*(dy - (float)rec.height/2.0f);
return (cornerDistanceSq <= (radius*radius));
}

View File

@ -367,7 +367,7 @@ void DrawTextEx(SpriteFont spriteFont, const char *text, Vector2 position, float
if ((unsigned char)text[i] == '\n')
{
// NOTE: Fixed line spacing of 1.5 lines
textOffsetY += ((spriteFont.size + spriteFont.size/2)*scaleFactor);
textOffsetY += (int)((spriteFont.size + spriteFont.size/2)*scaleFactor);
textOffsetX = 0;
}
else
@ -394,8 +394,8 @@ void DrawTextEx(SpriteFont spriteFont, const char *text, Vector2 position, float
spriteFont.charRecs[index].width*scaleFactor,
spriteFont.charRecs[index].height*scaleFactor }, (Vector2){ 0, 0 }, 0.0f, tint);
if (spriteFont.charAdvanceX[index] == 0) textOffsetX += (spriteFont.charRecs[index].width*scaleFactor + spacing);
else textOffsetX += (spriteFont.charAdvanceX[index]*scaleFactor + spacing);
if (spriteFont.charAdvanceX[index] == 0) textOffsetX += (int)(spriteFont.charRecs[index].width*scaleFactor + spacing);
else textOffsetX += (int)(spriteFont.charAdvanceX[index]*scaleFactor + spacing);
}
}
}
@ -463,11 +463,11 @@ Vector2 MeasureTextEx(SpriteFont spriteFont, const char *text, float fontSize, i
int tempLen = 0; // Used to count longer text line num chars
int lenCounter = 0;
int textWidth = 0;
int tempTextWidth = 0; // Used to count longer text line width
float textWidth = 0;
float tempTextWidth = 0; // Used to count longer text line width
int textHeight = spriteFont.size;
float scaleFactor = fontSize/spriteFont.size;
float textHeight = (float)spriteFont.size;
float scaleFactor = fontSize/(float)spriteFont.size;
for (int i = 0; i < len; i++)
{
@ -485,7 +485,7 @@ Vector2 MeasureTextEx(SpriteFont spriteFont, const char *text, float fontSize, i
if (tempTextWidth < textWidth) tempTextWidth = textWidth;
lenCounter = 0;
textWidth = 0;
textHeight += (spriteFont.size + spriteFont.size/2); // NOTE: Fixed line spacing of 1.5 lines
textHeight += ((float)spriteFont.size*1.5f); // NOTE: Fixed line spacing of 1.5 lines
}
if (tempLen < lenCounter) tempLen = lenCounter;
@ -494,8 +494,8 @@ Vector2 MeasureTextEx(SpriteFont spriteFont, const char *text, float fontSize, i
if (tempTextWidth < textWidth) tempTextWidth = textWidth;
Vector2 vec;
vec.x = (float)tempTextWidth*scaleFactor + (tempLen - 1)*spacing; // Adds chars spacing to measure
vec.y = (float)textHeight*scaleFactor;
vec.x = tempTextWidth*scaleFactor + (float)((tempLen - 1)*spacing); // Adds chars spacing to measure
vec.y = textHeight*scaleFactor;
return vec;
}
@ -504,10 +504,8 @@ Vector2 MeasureTextEx(SpriteFont spriteFont, const char *text, float fontSize, i
// NOTE: Uses default font
void DrawFPS(int posX, int posY)
{
char buffer[20];
// NOTE: We are rendering fps every second for better viewing on high framerates
// TODO: Not working properly on ANDROID and RPI
// TODO: Not working properly on ANDROID and RPI (for high framerates)
static float fps = 0.0f;
static int counter = 0;
@ -520,12 +518,11 @@ void DrawFPS(int posX, int posY)
else
{
fps = GetFPS();
refreshRate = fps;
refreshRate = (int)fps;
counter = 0;
}
sprintf(buffer, "%2.0f FPS", fps);
DrawText(buffer, posX, posY, 20, LIME);
DrawText(FormatText("%2.0f FPS", fps), posX, posY, 20, LIME);
}
//----------------------------------------------------------------------------------

View File

@ -317,6 +317,7 @@ Image LoadImageFromRES(const char *rresName, int resId)
else
{
// Depending on type, skip the right amount of parameters
/* TODO: Review
switch (infoHeader.type)
{
case 0: fseek(rresFile, 6, SEEK_CUR); break; // IMAGE: Jump 6 bytes of parameters
@ -326,7 +327,7 @@ Image LoadImageFromRES(const char *rresName, int resId)
case 4: break; // RAW: No parameters
default: break;
}
*/
// Jump DATA to read next infoHeader
fseek(rresFile, infoHeader.size, SEEK_CUR);
}
@ -1100,18 +1101,18 @@ void ImageResizeNN(Image *image,int newWidth,int newHeight)
Color *output = (Color *)malloc(newWidth*newHeight*sizeof(Color));
// EDIT: added +1 to account for an early rounding problem
int x_ratio = (int)((image->width<<16)/newWidth) + 1;
int y_ratio = (int)((image->height<<16)/newHeight) + 1;
int xRatio = (int)((image->width << 16)/newWidth) + 1;
int yRatio = (int)((image->height << 16)/newHeight) + 1;
int x2, y2;
for (int i = 0; i < newHeight; i++)
for (int y = 0; y < newHeight; y++)
{
for (int j = 0; j < newWidth; j++)
for (int x = 0; x < newWidth; x++)
{
x2 = ((j*x_ratio) >> 16);
y2 = ((i*y_ratio) >> 16);
x2 = ((x*xRatio) >> 16);
y2 = ((y*yRatio) >> 16);
output[(i*newWidth) + j] = pixels[(y2*image->width) + x2] ;
output[(y*newWidth) + x] = pixels[(y2*image->width) + x2] ;
}
}
@ -1584,7 +1585,7 @@ void DrawTexturePro(Texture2D texture, Rectangle sourceRec, Rectangle destRec, V
rlEnableTexture(texture.id);
rlPushMatrix();
rlTranslatef(destRec.x, destRec.y, 0);
rlTranslatef((float)destRec.x, (float)destRec.y, 0);
rlRotatef(rotation, 0, 0, 1);
rlTranslatef(-origin.x, -origin.y, 0);
@ -1598,15 +1599,15 @@ void DrawTexturePro(Texture2D texture, Rectangle sourceRec, Rectangle destRec, V
// Bottom-right corner for texture and quad
rlTexCoord2f((float)sourceRec.x/texture.width, (float)(sourceRec.y + sourceRec.height)/texture.height);
rlVertex2f(0.0f, destRec.height);
rlVertex2f(0.0f, (float)destRec.height);
// Top-right corner for texture and quad
rlTexCoord2f((float)(sourceRec.x + sourceRec.width)/texture.width, (float)(sourceRec.y + sourceRec.height)/texture.height);
rlVertex2f(destRec.width, destRec.height);
rlVertex2f((float)destRec.width, (float)destRec.height);
// Top-left corner for texture and quad
rlTexCoord2f((float)(sourceRec.x + sourceRec.width)/texture.width, (float)sourceRec.y/texture.height);
rlVertex2f(destRec.width, 0.0f);
rlVertex2f((float)destRec.width, 0.0f);
rlEnd();
rlPopMatrix();