Corrected some float values
This commit is contained in:
parent
4f0165f32d
commit
3b4d8442e0
3 changed files with 57 additions and 57 deletions
16
src/core.c
16
src/core.c
|
@ -309,8 +309,8 @@ void InitWindow(int width, int height, const char *title)
|
||||||
emscripten_set_touchcancel_callback("#canvas", NULL, 1, EmscriptenInputCallback);
|
emscripten_set_touchcancel_callback("#canvas", NULL, 1, EmscriptenInputCallback);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
mousePosition.x = screenWidth/2;
|
mousePosition.x = (float)screenWidth/2.0f;
|
||||||
mousePosition.y = screenHeight/2;
|
mousePosition.y = (float)screenHeight/2.0f;
|
||||||
|
|
||||||
// raylib logo appearing animation (if enabled)
|
// raylib logo appearing animation (if enabled)
|
||||||
if (showLogo)
|
if (showLogo)
|
||||||
|
@ -577,7 +577,7 @@ void Begin3dMode(Camera camera)
|
||||||
|
|
||||||
// Setup perspective projection
|
// Setup perspective projection
|
||||||
float aspect = (float)screenWidth/(float)screenHeight;
|
float aspect = (float)screenWidth/(float)screenHeight;
|
||||||
double top = 0.1f*tan(45.0f*PI / 360.0f);
|
double top = 0.1f*tan(45.0f*PI/360.0f);
|
||||||
double right = top*aspect;
|
double right = top*aspect;
|
||||||
|
|
||||||
// NOTE: zNear and zFar values are important when computing depth buffer values
|
// NOTE: zNear and zFar values are important when computing depth buffer values
|
||||||
|
@ -608,7 +608,7 @@ void End3dMode(void)
|
||||||
// Set target FPS for the game
|
// Set target FPS for the game
|
||||||
void SetTargetFPS(int fps)
|
void SetTargetFPS(int fps)
|
||||||
{
|
{
|
||||||
targetTime = 1 / (double)fps;
|
targetTime = 1.0/(double)fps;
|
||||||
|
|
||||||
TraceLog(INFO, "Target time per frame: %02.03f milliseconds", (float)targetTime*1000);
|
TraceLog(INFO, "Target time per frame: %02.03f milliseconds", (float)targetTime*1000);
|
||||||
}
|
}
|
||||||
|
@ -625,7 +625,7 @@ float GetFrameTime(void)
|
||||||
// As we are operate quite a lot with frameTime,
|
// As we are operate quite a lot with frameTime,
|
||||||
// it could be no stable, so we round it before passing it around
|
// it could be no stable, so we round it before passing it around
|
||||||
// NOTE: There are still problems with high framerates (>500fps)
|
// NOTE: There are still problems with high framerates (>500fps)
|
||||||
double roundedFrameTime = round(frameTime*10000)/10000;
|
double roundedFrameTime = round(frameTime*10000)/10000.0;
|
||||||
|
|
||||||
return (float)roundedFrameTime; // Time in seconds to run a frame
|
return (float)roundedFrameTime; // Time in seconds to run a frame
|
||||||
}
|
}
|
||||||
|
@ -806,8 +806,8 @@ Ray GetMouseRay(Vector2 mousePosition, Camera camera)
|
||||||
|
|
||||||
// Calculate normalized device coordinates
|
// Calculate normalized device coordinates
|
||||||
// NOTE: y value is negative
|
// NOTE: y value is negative
|
||||||
float x = (2.0f * mousePosition.x) / GetScreenWidth() - 1.0f;
|
float x = (2.0f*mousePosition.x)/(float)GetScreenWidth() - 1.0f;
|
||||||
float y = 1.0f - (2.0f * mousePosition.y) / GetScreenHeight();
|
float y = 1.0f - (2.0f*mousePosition.y)/(float)GetScreenHeight();
|
||||||
float z = 1.0f;
|
float z = 1.0f;
|
||||||
|
|
||||||
// Store values in a vector
|
// Store values in a vector
|
||||||
|
@ -880,7 +880,7 @@ Vector2 WorldToScreen(Vector3 position, Camera camera)
|
||||||
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.z };
|
||||||
|
|
||||||
// Calculate 2d screen position vector
|
// Calculate 2d screen position vector
|
||||||
Vector2 screenPosition = { (ndcPos.x + 1.0f) / 2.0f * GetScreenWidth(), (ndcPos.y + 1.0f) / 2.0f * GetScreenHeight() };
|
Vector2 screenPosition = { (ndcPos.x + 1.0f)/2.0f*(float)GetScreenWidth(), (ndcPos.y + 1.0f)/2.0f*(float)GetScreenHeight() };
|
||||||
|
|
||||||
return screenPosition;
|
return screenPosition;
|
||||||
}
|
}
|
||||||
|
|
62
src/models.c
62
src/models.c
|
@ -741,8 +741,8 @@ Model LoadCubicmap(Image cubicmap)
|
||||||
|
|
||||||
// Map cube size will be 1.0
|
// Map cube size will be 1.0
|
||||||
float mapCubeSide = 1.0f;
|
float mapCubeSide = 1.0f;
|
||||||
int mapWidth = cubicmap.width * (int)mapCubeSide;
|
int mapWidth = cubicmap.width*(int)mapCubeSide;
|
||||||
int mapHeight = cubicmap.height * (int)mapCubeSide;
|
int mapHeight = cubicmap.height*(int)mapCubeSide;
|
||||||
|
|
||||||
// NOTE: Max possible number of triangles numCubes * (12 triangles by cube)
|
// NOTE: Max possible number of triangles numCubes * (12 triangles by cube)
|
||||||
int maxTriangles = cubicmap.width*cubicmap.height*12;
|
int maxTriangles = cubicmap.width*cubicmap.height*12;
|
||||||
|
@ -753,11 +753,11 @@ Model LoadCubicmap(Image cubicmap)
|
||||||
|
|
||||||
float w = mapCubeSide;
|
float w = mapCubeSide;
|
||||||
float h = mapCubeSide;
|
float h = mapCubeSide;
|
||||||
float h2 = mapCubeSide * 1.5; // TODO: Review walls height...
|
float h2 = mapCubeSide*1.5f; // TODO: Review walls height...
|
||||||
|
|
||||||
Vector3 *mapVertices = (Vector3 *)malloc(maxTriangles * 3 * sizeof(Vector3));
|
Vector3 *mapVertices = (Vector3 *)malloc(maxTriangles*3*sizeof(Vector3));
|
||||||
Vector2 *mapTexcoords = (Vector2 *)malloc(maxTriangles * 3 * sizeof(Vector2));
|
Vector2 *mapTexcoords = (Vector2 *)malloc(maxTriangles*3*sizeof(Vector2));
|
||||||
Vector3 *mapNormals = (Vector3 *)malloc(maxTriangles * 3 * sizeof(Vector3));
|
Vector3 *mapNormals = (Vector3 *)malloc(maxTriangles*3*sizeof(Vector3));
|
||||||
|
|
||||||
// Define the 6 normals of the cube, we will combine them accordingly later...
|
// Define the 6 normals of the cube, we will combine them accordingly later...
|
||||||
Vector3 n1 = { 1.0f, 0.0f, 0.0f };
|
Vector3 n1 = { 1.0f, 0.0f, 0.0f };
|
||||||
|
@ -775,12 +775,12 @@ Model LoadCubicmap(Image cubicmap)
|
||||||
float height;
|
float height;
|
||||||
} RectangleF;
|
} RectangleF;
|
||||||
|
|
||||||
RectangleF rightTexUV = { 0, 0, 0.5, 0.5 };
|
RectangleF rightTexUV = { 0.0f, 0.0f, 0.5f, 0.5f };
|
||||||
RectangleF leftTexUV = { 0.5, 0, 0.5, 0.5 };
|
RectangleF leftTexUV = { 0.5f, 0.0f, 0.5f, 0.5f };
|
||||||
RectangleF frontTexUV = { 0, 0, 0.5, 0.5 };
|
RectangleF frontTexUV = { 0.0f, 0.0f, 0.5f, 0.5f };
|
||||||
RectangleF backTexUV = { 0.5, 0, 0.5, 0.5 };
|
RectangleF backTexUV = { 0.5f, 0.0f, 0.5f, 0.5f };
|
||||||
RectangleF topTexUV = { 0, 0.5, 0.5, 0.5 };
|
RectangleF topTexUV = { 0.0f, 0.5f, 0.5f, 0.5f };
|
||||||
RectangleF bottomTexUV = { 0.5, 0.5, 0.5, 0.5 };
|
RectangleF bottomTexUV = { 0.5f, 0.5f, 0.5f, 0.5f };
|
||||||
|
|
||||||
for (int z = 0; z < mapHeight; z += mapCubeSide)
|
for (int z = 0; z < mapHeight; z += mapCubeSide)
|
||||||
{
|
{
|
||||||
|
@ -1147,7 +1147,7 @@ void SetModelTexture(Model *model, Texture2D texture)
|
||||||
void DrawModel(Model model, Vector3 position, float scale, Color tint)
|
void DrawModel(Model model, Vector3 position, float scale, Color tint)
|
||||||
{
|
{
|
||||||
Vector3 vScale = { scale, scale, scale };
|
Vector3 vScale = { scale, scale, scale };
|
||||||
Vector3 rotationAxis = { 0, 0, 0 };
|
Vector3 rotationAxis = { 0.0f, 0.0f, 0.0f };
|
||||||
|
|
||||||
DrawModelEx(model, position, 0.0f, rotationAxis, vScale, tint);
|
DrawModelEx(model, position, 0.0f, rotationAxis, vScale, tint);
|
||||||
}
|
}
|
||||||
|
@ -1163,7 +1163,7 @@ void DrawModelEx(Model model, Vector3 position, float rotationAngle, Vector3 rot
|
||||||
void DrawModelWires(Model model, Vector3 position, float scale, Color color)
|
void DrawModelWires(Model model, Vector3 position, float scale, Color color)
|
||||||
{
|
{
|
||||||
Vector3 vScale = { scale, scale, scale };
|
Vector3 vScale = { scale, scale, scale };
|
||||||
Vector3 rotationAxis = { 0, 0, 0 };
|
Vector3 rotationAxis = { 0.0f, 0.0f, 0.0f };
|
||||||
|
|
||||||
rlglDrawModel(model, position, 0.0f, rotationAxis, vScale, color, true);
|
rlglDrawModel(model, position, 0.0f, rotationAxis, vScale, color, true);
|
||||||
}
|
}
|
||||||
|
@ -1188,7 +1188,7 @@ void DrawBillboard(Camera camera, Texture2D texture, Vector3 center, float size,
|
||||||
//Vector3 up = { viewMatrix.m1, viewMatrix.m5, viewMatrix.m9 };
|
//Vector3 up = { viewMatrix.m1, viewMatrix.m5, viewMatrix.m9 };
|
||||||
|
|
||||||
// NOTE: Billboard locked to axis-Y
|
// NOTE: Billboard locked to axis-Y
|
||||||
Vector3 up = { 0, 1, 0 };
|
Vector3 up = { 0.0f, 1.0f, 0.0f };
|
||||||
/*
|
/*
|
||||||
a-------b
|
a-------b
|
||||||
| |
|
| |
|
||||||
|
@ -1366,7 +1366,7 @@ Vector3 ResolveCollisionCubicmap(Image cubicmap, Vector3 mapPosition, Vector3 *p
|
||||||
Color *cubicmapPixels = GetImageData(cubicmap);
|
Color *cubicmapPixels = GetImageData(cubicmap);
|
||||||
|
|
||||||
// Detect the cell where the player is located
|
// Detect the cell where the player is located
|
||||||
Vector3 impactDirection = { 0, 0, 0 };
|
Vector3 impactDirection = { 0.0f, 0.0f, 0.0f };
|
||||||
|
|
||||||
int locationCellX = 0;
|
int locationCellX = 0;
|
||||||
int locationCellY = 0;
|
int locationCellY = 0;
|
||||||
|
@ -1389,7 +1389,7 @@ Vector3 ResolveCollisionCubicmap(Image cubicmap, Vector3 mapPosition, Vector3 *p
|
||||||
{
|
{
|
||||||
playerPosition->x = locationCellX + mapPosition.x - (CUBIC_MAP_HALF_BLOCK_SIZE - radius);
|
playerPosition->x = locationCellX + mapPosition.x - (CUBIC_MAP_HALF_BLOCK_SIZE - radius);
|
||||||
playerPosition->z = locationCellY + mapPosition.z - (CUBIC_MAP_HALF_BLOCK_SIZE - radius);
|
playerPosition->z = locationCellY + mapPosition.z - (CUBIC_MAP_HALF_BLOCK_SIZE - radius);
|
||||||
impactDirection = (Vector3) { 1, 0, 1};
|
impactDirection = (Vector3){ 1.0f, 0.0f, 1.0f };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1405,7 +1405,7 @@ Vector3 ResolveCollisionCubicmap(Image cubicmap, Vector3 mapPosition, Vector3 *p
|
||||||
{
|
{
|
||||||
playerPosition->x = locationCellX + mapPosition.x - (CUBIC_MAP_HALF_BLOCK_SIZE - radius);
|
playerPosition->x = locationCellX + mapPosition.x - (CUBIC_MAP_HALF_BLOCK_SIZE - radius);
|
||||||
playerPosition->z = locationCellY + mapPosition.z + (CUBIC_MAP_HALF_BLOCK_SIZE - radius);
|
playerPosition->z = locationCellY + mapPosition.z + (CUBIC_MAP_HALF_BLOCK_SIZE - radius);
|
||||||
impactDirection = (Vector3) { 1, 0, 1};
|
impactDirection = (Vector3){ 1.0f, 0.0f, 1.0f };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1421,7 +1421,7 @@ Vector3 ResolveCollisionCubicmap(Image cubicmap, Vector3 mapPosition, Vector3 *p
|
||||||
{
|
{
|
||||||
playerPosition->x = locationCellX + mapPosition.x + (CUBIC_MAP_HALF_BLOCK_SIZE - radius);
|
playerPosition->x = locationCellX + mapPosition.x + (CUBIC_MAP_HALF_BLOCK_SIZE - radius);
|
||||||
playerPosition->z = locationCellY + mapPosition.z - (CUBIC_MAP_HALF_BLOCK_SIZE - radius);
|
playerPosition->z = locationCellY + mapPosition.z - (CUBIC_MAP_HALF_BLOCK_SIZE - radius);
|
||||||
impactDirection = (Vector3) { 1, 0, 1};
|
impactDirection = (Vector3){ 1.0f, 0.0f, 1.0f };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1437,7 +1437,7 @@ Vector3 ResolveCollisionCubicmap(Image cubicmap, Vector3 mapPosition, Vector3 *p
|
||||||
{
|
{
|
||||||
playerPosition->x = locationCellX + mapPosition.x + (CUBIC_MAP_HALF_BLOCK_SIZE - radius);
|
playerPosition->x = locationCellX + mapPosition.x + (CUBIC_MAP_HALF_BLOCK_SIZE - radius);
|
||||||
playerPosition->z = locationCellY + mapPosition.z + (CUBIC_MAP_HALF_BLOCK_SIZE - radius);
|
playerPosition->z = locationCellY + mapPosition.z + (CUBIC_MAP_HALF_BLOCK_SIZE - radius);
|
||||||
impactDirection = (Vector3) { 1, 0, 1};
|
impactDirection = (Vector3){ 1.0f, 0.0f, 1.0f };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1452,7 +1452,7 @@ Vector3 ResolveCollisionCubicmap(Image cubicmap, Vector3 mapPosition, Vector3 *p
|
||||||
if ((playerPosition->x - mapPosition.x + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellX < radius)
|
if ((playerPosition->x - mapPosition.x + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellX < radius)
|
||||||
{
|
{
|
||||||
playerPosition->x = locationCellX + mapPosition.x - (CUBIC_MAP_HALF_BLOCK_SIZE - radius);
|
playerPosition->x = locationCellX + mapPosition.x - (CUBIC_MAP_HALF_BLOCK_SIZE - radius);
|
||||||
impactDirection = (Vector3) { 1, 0, 0};
|
impactDirection = (Vector3){ 1.0f, 0.0f, 0.0f };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1464,7 +1464,7 @@ Vector3 ResolveCollisionCubicmap(Image cubicmap, Vector3 mapPosition, Vector3 *p
|
||||||
if ((playerPosition->x - mapPosition.x + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellX > 1 - radius)
|
if ((playerPosition->x - mapPosition.x + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellX > 1 - radius)
|
||||||
{
|
{
|
||||||
playerPosition->x = locationCellX + mapPosition.x + (CUBIC_MAP_HALF_BLOCK_SIZE - radius);
|
playerPosition->x = locationCellX + mapPosition.x + (CUBIC_MAP_HALF_BLOCK_SIZE - radius);
|
||||||
impactDirection = (Vector3) { 1, 0, 0};
|
impactDirection = (Vector3){ 1.0f, 0.0f, 0.0f };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1476,7 +1476,7 @@ Vector3 ResolveCollisionCubicmap(Image cubicmap, Vector3 mapPosition, Vector3 *p
|
||||||
if ((playerPosition->z - mapPosition.z + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellY < radius)
|
if ((playerPosition->z - mapPosition.z + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellY < radius)
|
||||||
{
|
{
|
||||||
playerPosition->z = locationCellY + mapPosition.z - (CUBIC_MAP_HALF_BLOCK_SIZE - radius);
|
playerPosition->z = locationCellY + mapPosition.z - (CUBIC_MAP_HALF_BLOCK_SIZE - radius);
|
||||||
impactDirection = (Vector3) { 0, 0, 1};
|
impactDirection = (Vector3){ 0.0f, 0.0f, 1.0f };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1488,7 +1488,7 @@ Vector3 ResolveCollisionCubicmap(Image cubicmap, Vector3 mapPosition, Vector3 *p
|
||||||
if ((playerPosition->z - mapPosition.z + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellY > 1 - radius)
|
if ((playerPosition->z - mapPosition.z + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellY > 1 - radius)
|
||||||
{
|
{
|
||||||
playerPosition->z = locationCellY + mapPosition.z + (CUBIC_MAP_HALF_BLOCK_SIZE - radius);
|
playerPosition->z = locationCellY + mapPosition.z + (CUBIC_MAP_HALF_BLOCK_SIZE - radius);
|
||||||
impactDirection = (Vector3) { 0, 0, 1};
|
impactDirection = (Vector3){ 0.0f, 0.0f, 1.0f };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1512,7 +1512,7 @@ Vector3 ResolveCollisionCubicmap(Image cubicmap, Vector3 mapPosition, Vector3 *p
|
||||||
if (((playerPosition->x - mapPosition.x + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellX < radius / 3) &&
|
if (((playerPosition->x - mapPosition.x + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellX < radius / 3) &&
|
||||||
((playerPosition->z - mapPosition.z + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellY < radius / 3))
|
((playerPosition->z - mapPosition.z + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellY < radius / 3))
|
||||||
{
|
{
|
||||||
impactDirection = (Vector3) { 1, 0, 1};
|
impactDirection = (Vector3){ 1.0f, 0.0f, 1.0f };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1535,7 +1535,7 @@ Vector3 ResolveCollisionCubicmap(Image cubicmap, Vector3 mapPosition, Vector3 *p
|
||||||
if (((playerPosition->x - mapPosition.x + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellX < radius / 3) &&
|
if (((playerPosition->x - mapPosition.x + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellX < radius / 3) &&
|
||||||
((playerPosition->z - mapPosition.z + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellY > 1 - radius / 3))
|
((playerPosition->z - mapPosition.z + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellY > 1 - radius / 3))
|
||||||
{
|
{
|
||||||
impactDirection = (Vector3) { 1, 0, 1};
|
impactDirection = (Vector3){ 1.0f, 0.0f, 1.0f };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1558,7 +1558,7 @@ Vector3 ResolveCollisionCubicmap(Image cubicmap, Vector3 mapPosition, Vector3 *p
|
||||||
if (((playerPosition->x - mapPosition.x + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellX > 1 - radius / 3) &&
|
if (((playerPosition->x - mapPosition.x + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellX > 1 - radius / 3) &&
|
||||||
((playerPosition->z - mapPosition.z + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellY < radius / 3))
|
((playerPosition->z - mapPosition.z + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellY < radius / 3))
|
||||||
{
|
{
|
||||||
impactDirection = (Vector3) { 1, 0, 1};
|
impactDirection = (Vector3){ 1.0f, 0.0f, 1.0f };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1581,7 +1581,7 @@ Vector3 ResolveCollisionCubicmap(Image cubicmap, Vector3 mapPosition, Vector3 *p
|
||||||
if (((playerPosition->x - mapPosition.x + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellX > 1 - radius / 3) &&
|
if (((playerPosition->x - mapPosition.x + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellX > 1 - radius / 3) &&
|
||||||
((playerPosition->z - mapPosition.z + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellY > 1 - radius / 3))
|
((playerPosition->z - mapPosition.z + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellY > 1 - radius / 3))
|
||||||
{
|
{
|
||||||
impactDirection = (Vector3) { 1, 0, 1};
|
impactDirection = (Vector3){ 1.0f, 0.0f, 1.0f };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1591,13 +1591,13 @@ Vector3 ResolveCollisionCubicmap(Image cubicmap, Vector3 mapPosition, Vector3 *p
|
||||||
// Floor collision
|
// Floor collision
|
||||||
if (playerPosition->y <= radius)
|
if (playerPosition->y <= radius)
|
||||||
{
|
{
|
||||||
playerPosition->y = radius + 0.01;
|
playerPosition->y = radius + 0.01f;
|
||||||
impactDirection = (Vector3) { impactDirection.x, 1, impactDirection.z};
|
impactDirection = (Vector3) { impactDirection.x, 1, impactDirection.z};
|
||||||
}
|
}
|
||||||
// Roof collision
|
// Roof collision
|
||||||
else if (playerPosition->y >= 1.5 - radius)
|
else if (playerPosition->y >= (1.5f - radius))
|
||||||
{
|
{
|
||||||
playerPosition->y = (1.5 - radius) - 0.01;
|
playerPosition->y = (1.5f - radius) - 0.01f;
|
||||||
impactDirection = (Vector3) { impactDirection.x, 1, impactDirection.z};
|
impactDirection = (Vector3) { impactDirection.x, 1, impactDirection.z};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
36
src/rlgl.c
36
src/rlgl.c
|
@ -821,10 +821,10 @@ void rlDeleteBuffers(unsigned int id)
|
||||||
void rlClearColor(byte r, byte g, byte b, byte a)
|
void rlClearColor(byte r, byte g, byte b, byte a)
|
||||||
{
|
{
|
||||||
// Color values clamp to 0.0f(0) and 1.0f(255)
|
// Color values clamp to 0.0f(0) and 1.0f(255)
|
||||||
float cr = (float)r / 255;
|
float cr = (float)r/255;
|
||||||
float cg = (float)g / 255;
|
float cg = (float)g/255;
|
||||||
float cb = (float)b / 255;
|
float cb = (float)b/255;
|
||||||
float ca = (float)a / 255;
|
float ca = (float)a/255;
|
||||||
|
|
||||||
glClearColor(cr, cg, cb, ca);
|
glClearColor(cr, cg, cb, ca);
|
||||||
}
|
}
|
||||||
|
@ -1104,12 +1104,12 @@ void rlglInitPostpro(void)
|
||||||
|
|
||||||
quadData.vertexCount = 6;
|
quadData.vertexCount = 6;
|
||||||
|
|
||||||
float w = screenWidth;
|
float w = (float)screenWidth;
|
||||||
float h = screenHeight;
|
float h = (float)screenHeight;
|
||||||
|
|
||||||
float quadPositions[6*3] = { w, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, h, 0.0, 0, h, 0.0, w, h, 0.0, w, 0.0, 0.0 };
|
float quadPositions[6*3] = { w, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, h, 0.0f, 0.0f, h, 0.0f, w, h, 0.0f, w, 0.0f, 0.0f };
|
||||||
float quadTexcoords[6*2] = { 1.0, 1.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 1.0 };
|
float quadTexcoords[6*2] = { 1.0f, 1.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f };
|
||||||
float quadNormals[6*3] = { 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0 };
|
float quadNormals[6*3] = { 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f };
|
||||||
unsigned char quadColors[6*4] = { 255 };
|
unsigned char quadColors[6*4] = { 255 };
|
||||||
|
|
||||||
quadData.vertices = quadPositions;
|
quadData.vertices = quadPositions;
|
||||||
|
@ -1667,7 +1667,7 @@ void rlglInitGraphics(int offsetX, int offsetY, int width, int height)
|
||||||
// NOTE: Using global variables: screenWidth, screenHeight
|
// NOTE: Using global variables: screenWidth, screenHeight
|
||||||
Vector3 rlglUnproject(Vector3 source, Matrix proj, Matrix view)
|
Vector3 rlglUnproject(Vector3 source, Matrix proj, Matrix view)
|
||||||
{
|
{
|
||||||
Vector3 result = { 0, 0, 0 }; // Object coordinates
|
Vector3 result = { 0.0f, 0.0f, 0.0f }; // Object coordinates
|
||||||
|
|
||||||
//GLint viewport[4];
|
//GLint viewport[4];
|
||||||
//glGetIntegerv(GL_VIEWPORT, viewport); // Not available on OpenGL ES 2.0
|
//glGetIntegerv(GL_VIEWPORT, viewport); // Not available on OpenGL ES 2.0
|
||||||
|
@ -1698,11 +1698,11 @@ Vector3 rlglUnproject(Vector3 source, Matrix proj, Matrix view)
|
||||||
quat.x = ((source.x - (float)x)/(float)width)*2.0f - 1.0f;
|
quat.x = ((source.x - (float)x)/(float)width)*2.0f - 1.0f;
|
||||||
quat.y = ((source.y - (float)y)/(float)height)*2.0f - 1.0f;
|
quat.y = ((source.y - (float)y)/(float)height)*2.0f - 1.0f;
|
||||||
quat.z = source.z*2.0f - 1.0f;
|
quat.z = source.z*2.0f - 1.0f;
|
||||||
quat.w = 1.0;
|
quat.w = 1.0f;
|
||||||
|
|
||||||
QuaternionTransform(&quat, modelviewprojection);
|
QuaternionTransform(&quat, modelviewprojection);
|
||||||
|
|
||||||
if (quat.w != 0.0)
|
if (quat.w != 0.0f)
|
||||||
{
|
{
|
||||||
quat.x /= quat.w;
|
quat.x /= quat.w;
|
||||||
quat.y /= quat.w;
|
quat.y /= quat.w;
|
||||||
|
@ -2171,7 +2171,7 @@ void *rlglReadTexturePixels(Texture2D texture)
|
||||||
// Render texture to fbo
|
// Render texture to fbo
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, fbo.id);
|
glBindFramebuffer(GL_FRAMEBUFFER, fbo.id);
|
||||||
|
|
||||||
glClearColor(0.0, 0.0, 0.0, 0.0);
|
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||||
glClearDepthf(1.0f);
|
glClearDepthf(1.0f);
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
glViewport(0, 0, width, height);
|
glViewport(0, 0, width, height);
|
||||||
|
@ -2189,7 +2189,7 @@ void *rlglReadTexturePixels(Texture2D texture)
|
||||||
quad.transform = MatrixIdentity();
|
quad.transform = MatrixIdentity();
|
||||||
quad.shader = simpleShader;
|
quad.shader = simpleShader;
|
||||||
|
|
||||||
DrawModel(quad, (Vector3){ 0, 0, 0 }, 1.0f, WHITE);
|
DrawModel(quad, (Vector3){ 0.0f, 0.0f, 0.0f }, 1.0f, WHITE);
|
||||||
|
|
||||||
pixels = (unsigned char *)malloc(texture.width*texture.height*3*sizeof(unsigned char));
|
pixels = (unsigned char *)malloc(texture.width*texture.height*3*sizeof(unsigned char));
|
||||||
|
|
||||||
|
@ -3239,19 +3239,19 @@ static pixel *GenNextMipmap(pixel *srcData, int srcWidth, int srcHeight)
|
||||||
int x2, y2;
|
int x2, y2;
|
||||||
pixel prow, pcol;
|
pixel prow, pcol;
|
||||||
|
|
||||||
int width = srcWidth / 2;
|
int width = srcWidth/2;
|
||||||
int height = srcHeight / 2;
|
int height = srcHeight/2;
|
||||||
|
|
||||||
pixel *mipmap = (pixel *)malloc(width*height*sizeof(pixel));
|
pixel *mipmap = (pixel *)malloc(width*height*sizeof(pixel));
|
||||||
|
|
||||||
// Scaling algorithm works perfectly (box-filter)
|
// Scaling algorithm works perfectly (box-filter)
|
||||||
for (int y = 0; y < height; y++)
|
for (int y = 0; y < height; y++)
|
||||||
{
|
{
|
||||||
y2 = 2 * y;
|
y2 = 2*y;
|
||||||
|
|
||||||
for (int x = 0; x < width; x++)
|
for (int x = 0; x < width; x++)
|
||||||
{
|
{
|
||||||
x2 = 2 * x;
|
x2 = 2*x;
|
||||||
|
|
||||||
prow.r = (srcData[y2*srcWidth + x2].r + srcData[y2*srcWidth + x2 + 1].r)/2;
|
prow.r = (srcData[y2*srcWidth + x2].r + srcData[y2*srcWidth + x2 + 1].r)/2;
|
||||||
prow.g = (srcData[y2*srcWidth + x2].g + srcData[y2*srcWidth + x2 + 1].g)/2;
|
prow.g = (srcData[y2*srcWidth + x2].g + srcData[y2*srcWidth + x2 + 1].g)/2;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue