From 75298b50fbfe8a8fad9c52c3cd8882072fb1ed36 Mon Sep 17 00:00:00 2001 From: Ray Date: Thu, 21 Feb 2019 11:28:10 +0100 Subject: Corrected issue with OpenURL() It was not working on Windows 10 --- src/core.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/core.c') diff --git a/src/core.c b/src/core.c index 67357ce9..36315113 100644 --- a/src/core.c +++ b/src/core.c @@ -1917,14 +1917,13 @@ void OpenURL(const char *url) char *cmd = (char *)calloc(strlen(url) + 10, sizeof(char)); #if defined(_WIN32) - sprintf(cmd, "explorer '%s'", url); + sprintf(cmd, "explorer %s", url); #elif defined(__linux__) sprintf(cmd, "xdg-open '%s'", url); // Alternatives: firefox, x-www-browser #elif defined(__APPLE__) sprintf(cmd, "open '%s'", url); #endif system(cmd); - free(cmd); } } -- cgit v1.2.3 From 641895b5ba778fdc9024ebb58446dcc8ea36a00a Mon Sep 17 00:00:00 2001 From: Ray Date: Thu, 21 Feb 2019 18:45:19 +0100 Subject: Remove end-line spaces --- src/core.c | 6 +- src/models.c | 208 ++++++++++++++++++++++++++++----------------------------- src/raudio.c | 14 ++-- src/rlgl.h | 114 +++++++++++++++---------------- src/shapes.c | 8 +-- src/text.c | 86 ++++++++++++------------ src/textures.c | 4 +- 7 files changed, 220 insertions(+), 220 deletions(-) (limited to 'src/core.c') diff --git a/src/core.c b/src/core.c index 36315113..714e6e2c 100644 --- a/src/core.c +++ b/src/core.c @@ -707,7 +707,7 @@ bool WindowShouldClose(void) { #if defined(PLATFORM_WEB) // Emterpreter-Async required to run sync code - // https://github.com/kripken/emscripten/wiki/Emterpreter#emterpreter-async-run-synchronous-code + // https://github.com/emscripten-core/emscripten/wiki/Emterpreter#emterpreter-async-run-synchronous-code // By default, this function is never called on a web-ready raylib example because we encapsulate // frame code in a UpdateDrawFrame() function, to allow browser manage execution asynchronously // but now emscripten allows sync code to be executed in an interpreted way, using emterpreter! @@ -1228,7 +1228,7 @@ void BeginTextureMode(RenderTexture2D target) rlLoadIdentity(); // Reset current matrix (MODELVIEW) //rlScalef(0.0f, -1.0f, 0.0f); // Flip Y-drawing (?) - + // Setup current width/height for proper aspect ratio // calculation when using BeginMode3D() currentWidth = target.texture.width; @@ -1254,7 +1254,7 @@ void EndTextureMode(void) rlMatrixMode(RL_MODELVIEW); // Switch back to MODELVIEW matrix rlLoadIdentity(); // Reset current matrix (MODELVIEW) - + // Reset current screen size currentWidth = GetScreenWidth(); currentHeight = GetScreenHeight(); diff --git a/src/models.c b/src/models.c index eace0f66..384c8db4 100644 --- a/src/models.c +++ b/src/models.c @@ -116,7 +116,7 @@ void DrawLine3D(Vector3 startPos, Vector3 endPos, Color color) void DrawCircle3D(Vector3 center, float radius, Vector3 rotationAxis, float rotationAngle, Color color) { if (rlCheckBufferLimit(2*36)) rlglDraw(); - + rlPushMatrix(); rlTranslatef(center.x, center.y, center.z); rlRotatef(rotationAngle, rotationAxis.x, rotationAxis.y, rotationAxis.z); @@ -140,7 +140,7 @@ void DrawCube(Vector3 position, float width, float height, float length, Color c float x = 0.0f; float y = 0.0f; float z = 0.0f; - + if (rlCheckBufferLimit(36)) rlglDraw(); rlPushMatrix(); @@ -221,7 +221,7 @@ void DrawCubeWires(Vector3 position, float width, float height, float length, Co float x = 0.0f; float y = 0.0f; float z = 0.0f; - + if (rlCheckBufferLimit(36)) rlglDraw(); rlPushMatrix(); @@ -626,7 +626,7 @@ Model LoadModel(const char *fileName) Model LoadModelFromMesh(Mesh mesh) { Model model = { 0 }; - + model.mesh = mesh; model.transform = MatrixIdentity(); model.material = LoadMaterialDefault(); @@ -679,11 +679,11 @@ void UnloadMesh(Mesh *mesh) void ExportMesh(Mesh mesh, const char *fileName) { bool success = false; - + if (IsFileExtension(fileName, ".obj")) { FILE *objFile = fopen(fileName, "wt"); - + fprintf(objFile, "# //////////////////////////////////////////////////////////////////////////////////\n"); fprintf(objFile, "# // //\n"); fprintf(objFile, "# // rMeshOBJ exporter v1.0 - Mesh exported as triangle faces and not optimized //\n"); @@ -696,33 +696,33 @@ void ExportMesh(Mesh mesh, const char *fileName) fprintf(objFile, "# //////////////////////////////////////////////////////////////////////////////////\n\n"); fprintf(objFile, "# Vertex Count: %i\n", mesh.vertexCount); fprintf(objFile, "# Triangle Count: %i\n\n", mesh.triangleCount); - + fprintf(objFile, "g mesh\n"); - + for (int i = 0, v = 0; i < mesh.vertexCount; i++, v += 3) { fprintf(objFile, "v %.2f %.2f %.2f\n", mesh.vertices[v], mesh.vertices[v + 1], mesh.vertices[v + 2]); } - + for (int i = 0, v = 0; i < mesh.vertexCount; i++, v += 2) { fprintf(objFile, "vt %.2f %.2f\n", mesh.texcoords[v], mesh.texcoords[v + 1]); } - + for (int i = 0, v = 0; i < mesh.vertexCount; i++, v += 3) { fprintf(objFile, "vn %.2f %.2f %.2f\n", mesh.normals[v], mesh.normals[v + 1], mesh.normals[v + 2]); } - + for (int i = 0; i < mesh.triangleCount; i += 3) { fprintf(objFile, "f %i/%i/%i %i/%i/%i %i/%i/%i\n", i, i, i, i + 1, i + 1, i + 1, i + 2, i + 2, i + 2); } - + fprintf(objFile, "\n"); - + fclose(objFile); - + success = true; } else if (IsFileExtension(fileName, ".raw")) { } // TODO: Support additional file formats to export mesh vertex data @@ -737,7 +737,7 @@ Mesh GenMeshPoly(int sides, float radius) { Mesh mesh = { 0 }; int vertexCount = sides*3; - + // Vertices definition Vector3 *vertices = (Vector3 *)malloc(vertexCount*sizeof(Vector3)); for (int i = 0, v = 0; i < 360; i += 360/sides, v += 3) @@ -745,13 +745,13 @@ Mesh GenMeshPoly(int sides, float radius) vertices[v] = (Vector3){ 0.0f, 0.0f, 0.0f }; vertices[v + 1] = (Vector3){ sinf(DEG2RAD*i)*radius, 0.0f, cosf(DEG2RAD*i)*radius }; vertices[v + 2] = (Vector3){ sinf(DEG2RAD*(i + 360/sides))*radius, 0.0f, cosf(DEG2RAD*(i + 360/sides))*radius }; - } - + } + // Normals definition Vector3 *normals = (Vector3 *)malloc(vertexCount*sizeof(Vector3)); for (int n = 0; n < vertexCount; n++) normals[n] = (Vector3){ 0.0f, 1.0f, 0.0f }; // Vector3.up; - // TexCoords definition + // TexCoords definition Vector2 *texcoords = (Vector2 *)malloc(vertexCount*sizeof(Vector2)); for (int n = 0; n < vertexCount; n++) texcoords[n] = (Vector2){ 0.0f, 0.0f }; @@ -760,7 +760,7 @@ Mesh GenMeshPoly(int sides, float radius) mesh.vertices = (float *)malloc(mesh.vertexCount*3*sizeof(float)); mesh.texcoords = (float *)malloc(mesh.vertexCount*2*sizeof(float)); mesh.normals = (float *)malloc(mesh.vertexCount*3*sizeof(float)); - + // Mesh vertices position array for (int i = 0; i < mesh.vertexCount; i++) { @@ -768,14 +768,14 @@ Mesh GenMeshPoly(int sides, float radius) mesh.vertices[3*i + 1] = vertices[i].y; mesh.vertices[3*i + 2] = vertices[i].z; } - + // Mesh texcoords array for (int i = 0; i < mesh.vertexCount; i++) { mesh.texcoords[2*i] = texcoords[i].x; mesh.texcoords[2*i + 1] = texcoords[i].y; } - + // Mesh normals array for (int i = 0; i < mesh.vertexCount; i++) { @@ -783,14 +783,14 @@ Mesh GenMeshPoly(int sides, float radius) mesh.normals[3*i + 1] = normals[i].y; mesh.normals[3*i + 2] = normals[i].z; } - + free(vertices); free(normals); free(texcoords); // Upload vertex data to GPU (static mesh) - rlLoadMesh(&mesh, false); - + rlLoadMesh(&mesh, false); + return mesh; } @@ -803,7 +803,7 @@ Mesh GenMeshPlane(float width, float length, int resX, int resZ) #if defined(CUSTOM_MESH_GEN_PLANE) resX++; resZ++; - + // Vertices definition int vertexCount = resX*resZ; // vertices get reused for the faces @@ -824,7 +824,7 @@ Mesh GenMeshPlane(float width, float length, int resX, int resZ) Vector3 *normals = (Vector3 *)malloc(vertexCount*sizeof(Vector3)); for (int n = 0; n < vertexCount; n++) normals[n] = (Vector3){ 0.0f, 1.0f, 0.0f }; // Vector3.up; - // TexCoords definition + // TexCoords definition Vector2 *texcoords = (Vector2 *)malloc(vertexCount*sizeof(Vector2)); for (int v = 0; v < resZ; v++) { @@ -847,7 +847,7 @@ Mesh GenMeshPlane(float width, float length, int resX, int resZ) triangles[t++] = i + 1; triangles[t++] = i; - triangles[t++] = i + resX; + triangles[t++] = i + resX; triangles[t++] = i + resX + 1; triangles[t++] = i + 1; } @@ -858,7 +858,7 @@ Mesh GenMeshPlane(float width, float length, int resX, int resZ) mesh.texcoords = (float *)malloc(mesh.vertexCount*2*sizeof(float)); mesh.normals = (float *)malloc(mesh.vertexCount*3*sizeof(float)); mesh.indices = (unsigned short *)malloc(mesh.triangleCount*3*sizeof(unsigned short)); - + // Mesh vertices position array for (int i = 0; i < mesh.vertexCount; i++) { @@ -866,14 +866,14 @@ Mesh GenMeshPlane(float width, float length, int resX, int resZ) mesh.vertices[3*i + 1] = vertices[i].y; mesh.vertices[3*i + 2] = vertices[i].z; } - + // Mesh texcoords array for (int i = 0; i < mesh.vertexCount; i++) { mesh.texcoords[2*i] = texcoords[i].x; mesh.texcoords[2*i + 1] = texcoords[i].y; } - + // Mesh normals array for (int i = 0; i < mesh.vertexCount; i++) { @@ -881,22 +881,22 @@ Mesh GenMeshPlane(float width, float length, int resX, int resZ) mesh.normals[3*i + 1] = normals[i].y; mesh.normals[3*i + 2] = normals[i].z; } - + // Mesh indices array initialization for (int i = 0; i < mesh.triangleCount*3; i++) mesh.indices[i] = triangles[i]; - + free(vertices); free(normals); free(texcoords); free(triangles); - + #else // Use par_shapes library to generate plane mesh par_shapes_mesh *plane = par_shapes_create_plane(resX, resZ); // No normals/texcoords generated!!! par_shapes_scale(plane, width, length, 1.0f); par_shapes_rotate(plane, -PI/2.0f, (float[]){ 1, 0, 0 }); par_shapes_translate(plane, -width/2, 0.0f, length/2); - + mesh.vertices = (float *)malloc(plane->ntriangles*3*3*sizeof(float)); mesh.texcoords = (float *)malloc(plane->ntriangles*3*2*sizeof(float)); mesh.normals = (float *)malloc(plane->ntriangles*3*3*sizeof(float)); @@ -909,11 +909,11 @@ Mesh GenMeshPlane(float width, float length, int resX, int resZ) mesh.vertices[k*3] = plane->points[plane->triangles[k]*3]; mesh.vertices[k*3 + 1] = plane->points[plane->triangles[k]*3 + 1]; mesh.vertices[k*3 + 2] = plane->points[plane->triangles[k]*3 + 2]; - + mesh.normals[k*3] = plane->normals[plane->triangles[k]*3]; mesh.normals[k*3 + 1] = plane->normals[plane->triangles[k]*3 + 1]; mesh.normals[k*3 + 2] = plane->normals[plane->triangles[k]*3 + 2]; - + mesh.texcoords[k*2] = plane->tcoords[plane->triangles[k]*2]; mesh.texcoords[k*2 + 1] = plane->tcoords[plane->triangles[k]*2 + 1]; } @@ -922,7 +922,7 @@ Mesh GenMeshPlane(float width, float length, int resX, int resZ) #endif // Upload vertex data to GPU (static mesh) - rlLoadMesh(&mesh, false); + rlLoadMesh(&mesh, false); return mesh; } @@ -960,7 +960,7 @@ Mesh GenMeshCube(float width, float height, float length) -width/2, height/2, length/2, -width/2, height/2, -length/2 }; - + float texcoords[] = { 0.0f, 0.0f, 1.0f, 0.0f, @@ -987,7 +987,7 @@ Mesh GenMeshCube(float width, float height, float length) 1.0f, 1.0f, 0.0f, 1.0f }; - + float normals[] = { 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, @@ -1017,15 +1017,15 @@ Mesh GenMeshCube(float width, float height, float length) mesh.vertices = (float *)malloc(24*3*sizeof(float)); memcpy(mesh.vertices, vertices, 24*3*sizeof(float)); - + mesh.texcoords = (float *)malloc(24*2*sizeof(float)); memcpy(mesh.texcoords, texcoords, 24*2*sizeof(float)); - + mesh.normals = (float *)malloc(24*3*sizeof(float)); memcpy(mesh.normals, normals, 24*3*sizeof(float)); - + mesh.indices = (unsigned short *)malloc(36*sizeof(unsigned short)); - + int k = 0; // Indices can be initialized right now @@ -1040,10 +1040,10 @@ Mesh GenMeshCube(float width, float height, float length) k++; } - + mesh.vertexCount = 24; mesh.triangleCount = 12; - + #else // Use par_shapes library to generate cube mesh /* // Platonic solids: @@ -1057,11 +1057,11 @@ par_shapes_mesh* par_shapes_create_icosahedron(); // 20 sides polyhedron // NOTE: No normals/texcoords generated by default par_shapes_mesh *cube = par_shapes_create_cube(); cube->tcoords = PAR_MALLOC(float, 2*cube->npoints); - for (int i = 0; i < 2*cube->npoints; i++) cube->tcoords[i] = 0.0f; + for (int i = 0; i < 2*cube->npoints; i++) cube->tcoords[i] = 0.0f; par_shapes_scale(cube, width, height, length); par_shapes_translate(cube, -width/2, 0.0f, -length/2); par_shapes_compute_normals(cube); - + mesh.vertices = (float *)malloc(cube->ntriangles*3*3*sizeof(float)); mesh.texcoords = (float *)malloc(cube->ntriangles*3*2*sizeof(float)); mesh.normals = (float *)malloc(cube->ntriangles*3*3*sizeof(float)); @@ -1074,11 +1074,11 @@ par_shapes_mesh* par_shapes_create_icosahedron(); // 20 sides polyhedron mesh.vertices[k*3] = cube->points[cube->triangles[k]*3]; mesh.vertices[k*3 + 1] = cube->points[cube->triangles[k]*3 + 1]; mesh.vertices[k*3 + 2] = cube->points[cube->triangles[k]*3 + 2]; - + mesh.normals[k*3] = cube->normals[cube->triangles[k]*3]; mesh.normals[k*3 + 1] = cube->normals[cube->triangles[k]*3 + 1]; mesh.normals[k*3 + 2] = cube->normals[cube->triangles[k]*3 + 2]; - + mesh.texcoords[k*2] = cube->tcoords[cube->triangles[k]*2]; mesh.texcoords[k*2 + 1] = cube->tcoords[cube->triangles[k]*2 + 1]; } @@ -1087,7 +1087,7 @@ par_shapes_mesh* par_shapes_create_icosahedron(); // 20 sides polyhedron #endif // Upload vertex data to GPU (static mesh) - rlLoadMesh(&mesh, false); + rlLoadMesh(&mesh, false); return mesh; } @@ -1099,8 +1099,8 @@ RLAPI Mesh GenMeshSphere(float radius, int rings, int slices) par_shapes_mesh *sphere = par_shapes_create_parametric_sphere(slices, rings); par_shapes_scale(sphere, radius, radius, radius); - // NOTE: Soft normals are computed internally - + // NOTE: Soft normals are computed internally + mesh.vertices = (float *)malloc(sphere->ntriangles*3*3*sizeof(float)); mesh.texcoords = (float *)malloc(sphere->ntriangles*3*2*sizeof(float)); mesh.normals = (float *)malloc(sphere->ntriangles*3*3*sizeof(float)); @@ -1113,19 +1113,19 @@ RLAPI Mesh GenMeshSphere(float radius, int rings, int slices) mesh.vertices[k*3] = sphere->points[sphere->triangles[k]*3]; mesh.vertices[k*3 + 1] = sphere->points[sphere->triangles[k]*3 + 1]; mesh.vertices[k*3 + 2] = sphere->points[sphere->triangles[k]*3 + 2]; - + mesh.normals[k*3] = sphere->normals[sphere->triangles[k]*3]; mesh.normals[k*3 + 1] = sphere->normals[sphere->triangles[k]*3 + 1]; mesh.normals[k*3 + 2] = sphere->normals[sphere->triangles[k]*3 + 2]; - + mesh.texcoords[k*2] = sphere->tcoords[sphere->triangles[k]*2]; mesh.texcoords[k*2 + 1] = sphere->tcoords[sphere->triangles[k]*2 + 1]; } par_shapes_free_mesh(sphere); - + // Upload vertex data to GPU (static mesh) - rlLoadMesh(&mesh, false); + rlLoadMesh(&mesh, false); return mesh; } @@ -1137,8 +1137,8 @@ RLAPI Mesh GenMeshHemiSphere(float radius, int rings, int slices) par_shapes_mesh *sphere = par_shapes_create_hemisphere(slices, rings); par_shapes_scale(sphere, radius, radius, radius); - // NOTE: Soft normals are computed internally - + // NOTE: Soft normals are computed internally + mesh.vertices = (float *)malloc(sphere->ntriangles*3*3*sizeof(float)); mesh.texcoords = (float *)malloc(sphere->ntriangles*3*2*sizeof(float)); mesh.normals = (float *)malloc(sphere->ntriangles*3*3*sizeof(float)); @@ -1151,19 +1151,19 @@ RLAPI Mesh GenMeshHemiSphere(float radius, int rings, int slices) mesh.vertices[k*3] = sphere->points[sphere->triangles[k]*3]; mesh.vertices[k*3 + 1] = sphere->points[sphere->triangles[k]*3 + 1]; mesh.vertices[k*3 + 2] = sphere->points[sphere->triangles[k]*3 + 2]; - + mesh.normals[k*3] = sphere->normals[sphere->triangles[k]*3]; mesh.normals[k*3 + 1] = sphere->normals[sphere->triangles[k]*3 + 1]; mesh.normals[k*3 + 2] = sphere->normals[sphere->triangles[k]*3 + 2]; - + mesh.texcoords[k*2] = sphere->tcoords[sphere->triangles[k]*2]; mesh.texcoords[k*2 + 1] = sphere->tcoords[sphere->triangles[k]*2 + 1]; } par_shapes_free_mesh(sphere); - + // Upload vertex data to GPU (static mesh) - rlLoadMesh(&mesh, false); + rlLoadMesh(&mesh, false); return mesh; } @@ -1175,7 +1175,7 @@ Mesh GenMeshCylinder(float radius, float height, int slices) // Instance a cylinder that sits on the Z=0 plane using the given tessellation // levels across the UV domain. Think of "slices" like a number of pizza - // slices, and "stacks" like a number of stacked rings. + // slices, and "stacks" like a number of stacked rings. // Height and radius are both 1.0, but they can easily be changed with par_shapes_scale par_shapes_mesh *cylinder = par_shapes_create_cylinder(slices, 8); par_shapes_scale(cylinder, radius, radius, height); @@ -1187,16 +1187,16 @@ Mesh GenMeshCylinder(float radius, float height, int slices) for (int i = 0; i < 2*capTop->npoints; i++) capTop->tcoords[i] = 0.0f; par_shapes_rotate(capTop, -PI/2.0f, (float[]){ 1, 0, 0 }); par_shapes_translate(capTop, 0, height, 0); - + // Generate an orientable disk shape (bottom cap) par_shapes_mesh *capBottom = par_shapes_create_disk(radius, slices, (float[]){ 0, 0, 0 }, (float[]){ 0, 0, -1 }); capBottom->tcoords = PAR_MALLOC(float, 2*capBottom->npoints); for (int i = 0; i < 2*capBottom->npoints; i++) capBottom->tcoords[i] = 0.95f; par_shapes_rotate(capBottom, PI/2.0f, (float[]){ 1, 0, 0 }); - + par_shapes_merge_and_free(cylinder, capTop); par_shapes_merge_and_free(cylinder, capBottom); - + mesh.vertices = (float *)malloc(cylinder->ntriangles*3*3*sizeof(float)); mesh.texcoords = (float *)malloc(cylinder->ntriangles*3*2*sizeof(float)); mesh.normals = (float *)malloc(cylinder->ntriangles*3*3*sizeof(float)); @@ -1209,19 +1209,19 @@ Mesh GenMeshCylinder(float radius, float height, int slices) mesh.vertices[k*3] = cylinder->points[cylinder->triangles[k]*3]; mesh.vertices[k*3 + 1] = cylinder->points[cylinder->triangles[k]*3 + 1]; mesh.vertices[k*3 + 2] = cylinder->points[cylinder->triangles[k]*3 + 2]; - + mesh.normals[k*3] = cylinder->normals[cylinder->triangles[k]*3]; mesh.normals[k*3 + 1] = cylinder->normals[cylinder->triangles[k]*3 + 1]; mesh.normals[k*3 + 2] = cylinder->normals[cylinder->triangles[k]*3 + 2]; - + mesh.texcoords[k*2] = cylinder->tcoords[cylinder->triangles[k]*2]; mesh.texcoords[k*2 + 1] = cylinder->tcoords[cylinder->triangles[k]*2 + 1]; } par_shapes_free_mesh(cylinder); - + // Upload vertex data to GPU (static mesh) - rlLoadMesh(&mesh, false); + rlLoadMesh(&mesh, false); return mesh; } @@ -1233,7 +1233,7 @@ Mesh GenMeshTorus(float radius, float size, int radSeg, int sides) if (radius > 1.0f) radius = 1.0f; else if (radius < 0.1f) radius = 0.1f; - + // Create a donut that sits on the Z=0 plane with the specified inner radius // The outer radius can be controlled with par_shapes_scale par_shapes_mesh *torus = par_shapes_create_torus(radSeg, sides, radius); @@ -1251,19 +1251,19 @@ Mesh GenMeshTorus(float radius, float size, int radSeg, int sides) mesh.vertices[k*3] = torus->points[torus->triangles[k]*3]; mesh.vertices[k*3 + 1] = torus->points[torus->triangles[k]*3 + 1]; mesh.vertices[k*3 + 2] = torus->points[torus->triangles[k]*3 + 2]; - + mesh.normals[k*3] = torus->normals[torus->triangles[k]*3]; mesh.normals[k*3 + 1] = torus->normals[torus->triangles[k]*3 + 1]; mesh.normals[k*3 + 2] = torus->normals[torus->triangles[k]*3 + 2]; - + mesh.texcoords[k*2] = torus->tcoords[torus->triangles[k]*2]; mesh.texcoords[k*2 + 1] = torus->tcoords[torus->triangles[k]*2 + 1]; } par_shapes_free_mesh(torus); - + // Upload vertex data to GPU (static mesh) - rlLoadMesh(&mesh, false); + rlLoadMesh(&mesh, false); return mesh; } @@ -1272,7 +1272,7 @@ Mesh GenMeshTorus(float radius, float size, int radSeg, int sides) Mesh GenMeshKnot(float radius, float size, int radSeg, int sides) { Mesh mesh = { 0 }; - + if (radius > 3.0f) radius = 3.0f; else if (radius < 0.5f) radius = 0.5f; @@ -1291,19 +1291,19 @@ Mesh GenMeshKnot(float radius, float size, int radSeg, int sides) mesh.vertices[k*3] = knot->points[knot->triangles[k]*3]; mesh.vertices[k*3 + 1] = knot->points[knot->triangles[k]*3 + 1]; mesh.vertices[k*3 + 2] = knot->points[knot->triangles[k]*3 + 2]; - + mesh.normals[k*3] = knot->normals[knot->triangles[k]*3]; mesh.normals[k*3 + 1] = knot->normals[knot->triangles[k]*3 + 1]; mesh.normals[k*3 + 2] = knot->normals[knot->triangles[k]*3 + 2]; - + mesh.texcoords[k*2] = knot->tcoords[knot->triangles[k]*2]; mesh.texcoords[k*2 + 1] = knot->tcoords[knot->triangles[k]*2 + 1]; } par_shapes_free_mesh(knot); - + // Upload vertex data to GPU (static mesh) - rlLoadMesh(&mesh, false); + rlLoadMesh(&mesh, false); return mesh; } @@ -1411,7 +1411,7 @@ Mesh GenMeshHeightmap(Image heightmap, Vector3 size) } free(pixels); - + // Upload vertex data to GPU (static mesh) rlLoadMesh(&mesh, false); @@ -1771,9 +1771,9 @@ Mesh GenMeshCubicmap(Image cubicmap, Vector3 cubeSize) free(mapTexcoords); free(cubicmapPixels); // Free image pixel data - + // Upload vertex data to GPU (static mesh) - rlLoadMesh(&mesh, false); + rlLoadMesh(&mesh, false); return mesh; } @@ -1821,7 +1821,7 @@ void UnloadMaterial(Material material) // Unload loaded texture maps (avoid unloading default texture, managed by raylib) for (int i = 0; i < MAX_MATERIAL_MAPS; i++) { - if (material.maps[i].texture.id != GetTextureDefault().id) rlDeleteTextures(material.maps[i].texture.id); + if (material.maps[i].texture.id != GetTextureDefault().id) rlDeleteTextures(material.maps[i].texture.id); } } @@ -1842,7 +1842,7 @@ void DrawModelEx(Model model, Vector3 position, Vector3 rotationAxis, float rota Matrix matScale = MatrixScale(scale.x, scale.y, scale.z); Matrix matRotation = MatrixRotate(rotationAxis, rotationAngle*DEG2RAD); Matrix matTranslation = MatrixTranslate(position.x, position.y, position.z); - + Matrix matTransform = MatrixMultiply(MatrixMultiply(matScale, matRotation), matTranslation); // Combine model transformation matrix (model.transform) with matrix generated by function parameters (matTransform) @@ -2037,7 +2037,7 @@ bool CheckCollisionRaySphereEx(Ray ray, Vector3 spherePosition, float sphereRadi if (distance < sphereRadius) collisionDistance = vector + sqrtf(d); else collisionDistance = vector - sqrtf(d); - + // Calculate collision point Vector3 cPoint = Vector3Add(ray.position, Vector3Scale(ray.direction, collisionDistance)); @@ -2097,7 +2097,7 @@ RayHitInfo GetCollisionRayModel(Ray ray, Model *model) b = vertdata[i*3 + 1]; c = vertdata[i*3 + 2]; } - + a = Vector3Transform(a, model->transform); b = Vector3Transform(b, model->transform); c = Vector3Transform(c, model->transform); @@ -2231,7 +2231,7 @@ void MeshTangents(Mesh *mesh) { if (mesh->tangents == NULL) mesh->tangents = (float *)malloc(mesh->vertexCount*4*sizeof(float)); else TraceLog(LOG_WARNING, "Mesh tangents already exist"); - + Vector3 *tan1 = (Vector3 *)malloc(mesh->vertexCount*sizeof(Vector3)); Vector3 *tan2 = (Vector3 *)malloc(mesh->vertexCount*sizeof(Vector3)); @@ -2264,7 +2264,7 @@ void MeshTangents(Mesh *mesh) Vector3 sdir = { (t2*x1 - t1*x2)*r, (t2*y1 - t1*y2)*r, (t2*z1 - t1*z2)*r }; Vector3 tdir = { (s1*x2 - s2*x1)*r, (s1*y2 - s2*y1)*r, (s1*z2 - s2*z1)*r }; - + tan1[i + 0] = sdir; tan1[i + 1] = sdir; tan1[i + 2] = sdir; @@ -2296,10 +2296,10 @@ void MeshTangents(Mesh *mesh) mesh->tangents[i*4 + 3] = (Vector3DotProduct(Vector3CrossProduct(normal, tangent), tan2[i]) < 0.0f) ? -1.0f : 1.0f; #endif } - + free(tan1); free(tan2); - + TraceLog(LOG_INFO, "Tangents computed for mesh"); } @@ -2311,7 +2311,7 @@ void MeshBinormals(Mesh *mesh) Vector3 normal = { mesh->normals[i*3 + 0], mesh->normals[i*3 + 1], mesh->normals[i*3 + 2] }; Vector3 tangent = { mesh->tangents[i*4 + 0], mesh->tangents[i*4 + 1], mesh->tangents[i*4 + 2] }; float tangentW = mesh->tangents[i*4 + 3]; - + // TODO: Register computed binormal in mesh->binormal ? // Vector3 binormal = Vector3Multiply(Vector3CrossProduct(normal, tangent), tangentW); } @@ -2740,11 +2740,11 @@ static Material LoadMTL(const char *fileName) static Mesh LoadIQM(const char *fileName) { Mesh mesh = { 0 }; - + // TODO: Load IQM file - + return mesh; -} +} #endif #if defined(SUPPORT_FILEFORMAT_GLTF) @@ -2752,10 +2752,10 @@ static Mesh LoadIQM(const char *fileName) static Mesh LoadGLTF(const char *fileName) { Mesh mesh = { 0 }; - + // glTF file loading FILE *gltfFile = fopen(fileName, "rb"); - + if (gltfFile == NULL) { TraceLog(LOG_WARNING, "[%s] glTF file could not be opened", fileName); @@ -2768,31 +2768,31 @@ static Mesh LoadGLTF(const char *fileName) void *buffer = malloc(size); fread(buffer, size, 1, gltfFile); - + fclose(gltfFile); // glTF data loading cgltf_options options = {0}; cgltf_data data; cgltf_result result = cgltf_parse(&options, buffer, size, &data); - + free(buffer); - + if (result == cgltf_result_success) { printf("Type: %u\n", data.file_type); printf("Version: %d\n", data.version); printf("Meshes: %lu\n", data.meshes_count); - + // TODO: Process glTF data and map to mesh - + // NOTE: data.buffers[] and data.images[] should be loaded // using buffers[n].uri and images[n].uri... or use cgltf_load_buffers(&options, data, fileName); - + cgltf_free(&data); } else TraceLog(LOG_WARNING, "[%s] glTF data could not be loaded", fileName); - return mesh; + return mesh; } #endif diff --git a/src/raudio.c b/src/raudio.c index b19c7d86..e1c9fd48 100644 --- a/src/raudio.c +++ b/src/raudio.c @@ -1245,7 +1245,7 @@ Music LoadMusicStream(const char *fileName) void UnloadMusicStream(Music music) { if (music == NULL) return; - + CloseAudioStream(music->stream); #if defined(SUPPORT_FILEFORMAT_OGG) @@ -1311,7 +1311,7 @@ void ResumeMusicStream(Music music) void StopMusicStream(Music music) { if (music == NULL) return; - + StopAudioStream(music->stream); // Restart music context @@ -1343,7 +1343,7 @@ void StopMusicStream(Music music) void UpdateMusicStream(Music music) { if (music == NULL) return; - + bool streamEnding = false; unsigned int subBufferSizeInFrames = ((AudioBuffer *)music->stream.audioBuffer)->bufferSizeInFrames/2; @@ -1393,16 +1393,16 @@ void UpdateMusicStream(Music music) } break; #endif #if defined(SUPPORT_FILEFORMAT_MOD) - case MUSIC_MODULE_MOD: + case MUSIC_MODULE_MOD: { // NOTE: 3rd parameter (nbsample) specify the number of stereo 16bits samples you want, so sampleCount/2 - jar_mod_fillbuffer(&music->ctxMod, (short *)pcm, samplesCount/2, 0); + jar_mod_fillbuffer(&music->ctxMod, (short *)pcm, samplesCount/2, 0); } break; #endif default: break; } - + UpdateAudioStream(music->stream, pcm, samplesCount); if ((music->ctxType == MUSIC_MODULE_XM) || (music->ctxType == MUSIC_MODULE_MOD)) { @@ -1475,7 +1475,7 @@ void SetMusicLoopCount(Music music, int count) float GetMusicTimeLength(Music music) { float totalSeconds = 0.0f; - + if (music != NULL) totalSeconds = (float)music->totalSamples/(music->stream.sampleRate*music->stream.channels); return totalSeconds; diff --git a/src/rlgl.h b/src/rlgl.h index f2762637..c9f15385 100644 --- a/src/rlgl.h +++ b/src/rlgl.h @@ -356,7 +356,7 @@ typedef unsigned char byte; LOC_MAP_PREFILTER, LOC_MAP_BRDF } ShaderLocationIndex; - + // Shader uniform data types typedef enum { UNIFORM_FLOAT = 0, @@ -993,14 +993,14 @@ void rlPushMatrix(void) // Pop lattest inserted matrix from stack void rlPopMatrix(void) -{ +{ if (stackCounter > 0) { Matrix mat = stack[stackCounter - 1]; *currentMatrix = mat; stackCounter--; } - + if ((stackCounter == 0) && (currentMatrixMode == RL_MODELVIEW)) { currentMatrix = &modelview; @@ -1141,7 +1141,7 @@ void rlEnd(void) // Make sure vertexCount is the same for vertices, texcoords, colors and normals // NOTE: In OpenGL 1.1, one glColor call can be made for all the subsequent glVertex calls - + // Make sure colors count match vertex count if (vertexData[currentBuffer].vCounter != vertexData[currentBuffer].cCounter) { @@ -1156,7 +1156,7 @@ void rlEnd(void) vertexData[currentBuffer].cCounter++; } } - + // Make sure texcoords count match vertex count if (vertexData[currentBuffer].vCounter != vertexData[currentBuffer].tcCounter) { @@ -1194,10 +1194,10 @@ void rlEnd(void) void rlVertex3f(float x, float y, float z) { Vector3 vec = { x, y, z }; - + // Transform provided vector if required if (useTransformMatrix) vec = Vector3Transform(vec, transformMatrix); - + // Verify that MAX_BATCH_ELEMENTS limit not reached if (vertexData[currentBuffer].vCounter < (MAX_BATCH_ELEMENTS*4)) { @@ -1499,7 +1499,7 @@ void rlglInit(int width, int height) //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... - + // TODO: Automatize extensions loading using rlLoadExtensions() and GLAD // Actually, when rlglInit() is called in InitWindow() in core.c, // OpenGL required extensions have already been loaded (PLATFORM_DESKTOP) @@ -1512,7 +1512,7 @@ void rlglInit(int width, int height) // NOTE: On OpenGL 3.3 VAO and NPOT are supported by default vaoSupported = true; - + // Multiple texture extensions supported by default texNPOTSupported = true; texFloatSupported = true; @@ -1585,11 +1585,11 @@ void rlglInit(int width, int height) // Check texture float support if (strcmp(extList[i], (const char *)"GL_OES_texture_float") == 0) texFloatSupported = true; - + // Check depth texture support if ((strcmp(extList[i], (const char *)"GL_OES_depth_texture") == 0) || (strcmp(extList[i], (const char *)"GL_WEBGL_depth_texture") == 0)) texDepthSupported = true; - + if (strcmp(extList[i], (const char *)"GL_OES_depth24") == 0) maxDepthBits = 24; if (strcmp(extList[i], (const char *)"GL_OES_depth32") == 0) maxDepthBits = 32; #endif @@ -1648,8 +1648,8 @@ void rlglInit(int width, int height) if (debugMarkerSupported) TraceLog(LOG_INFO, "[EXTENSION] Debug Marker supported"); - - + + // Initialize buffers, default shaders and default textures //---------------------------------------------------------- @@ -1666,7 +1666,7 @@ void rlglInit(int width, int height) // Init default vertex arrays buffers LoadBuffersDefault(); - + // Init transformations matrix accumulator transformMatrix = MatrixIdentity(); @@ -1995,9 +1995,9 @@ unsigned int rlLoadTextureDepth(int width, int height, int bits, bool useRenderB { unsigned int id = 0; unsigned int glInternalFormat = GL_DEPTH_COMPONENT16; - + if ((bits != 16) && (bits != 24) && (bits != 32)) bits = 16; - + if (bits == 24) { #if defined(GRAPHICS_API_OPENGL_33) @@ -2006,7 +2006,7 @@ unsigned int rlLoadTextureDepth(int width, int height, int bits, bool useRenderB if (maxDepthBits >= 24) glInternalFormat = GL_DEPTH_COMPONENT24_OES; #endif } - + if (bits == 32) { #if defined(GRAPHICS_API_OPENGL_33) @@ -2021,7 +2021,7 @@ unsigned int rlLoadTextureDepth(int width, int height, int bits, bool useRenderB glGenTextures(1, &id); glBindTexture(GL_TEXTURE_2D, id); glTexImage2D(GL_TEXTURE_2D, 0, glInternalFormat, width, height, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, NULL); - + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); @@ -2036,10 +2036,10 @@ unsigned int rlLoadTextureDepth(int width, int height, int bits, bool useRenderB glGenRenderbuffers(1, &id); glBindRenderbuffer(GL_RENDERBUFFER, id); glRenderbufferStorage(GL_RENDERBUFFER, glInternalFormat, width, height); - + glBindRenderbuffer(GL_RENDERBUFFER, 0); } - + return id; } @@ -2053,7 +2053,7 @@ unsigned int rlLoadTextureCubemap(void *data, int size, int format) glGenTextures(1, &cubemapId); glBindTexture(GL_TEXTURE_CUBE_MAP, cubemapId); - + unsigned int glInternalFormat, glFormat, glType; rlGetGlTextureFormats(format, &glInternalFormat, &glFormat, &glType); @@ -2084,7 +2084,7 @@ unsigned int rlLoadTextureCubemap(void *data, int size, int format) #endif } } - + // Set cubemap texture sampling parameters glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR); @@ -2178,14 +2178,14 @@ void rlUnloadTexture(unsigned int id) RenderTexture2D rlLoadRenderTexture(int width, int height, int format, int depthBits, bool useDepthTexture) { RenderTexture2D target = { 0 }; - + if (useDepthTexture && texDepthSupported) target.depthTexture = true; -#if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) +#if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) // Create the framebuffer object glGenFramebuffers(1, &target.id); glBindFramebuffer(GL_FRAMEBUFFER, target.id); - + // Create fbo color texture attachment //----------------------------------------------------------------------------------------------------- if ((format != -1) && (format < COMPRESSED_DXT1_RGB)) @@ -2198,7 +2198,7 @@ RenderTexture2D rlLoadRenderTexture(int width, int height, int format, int depth target.texture.mipmaps = 1; } //----------------------------------------------------------------------------------------------------- - + // Create fbo depth renderbuffer/texture //----------------------------------------------------------------------------------------------------- if (depthBits > 0) @@ -2210,7 +2210,7 @@ RenderTexture2D rlLoadRenderTexture(int width, int height, int format, int depth target.depth.mipmaps = 1; } //----------------------------------------------------------------------------------------------------- - + // Attach color texture and depth renderbuffer to FBO //----------------------------------------------------------------------------------------------------- rlRenderTextureAttach(target, target.texture.id, 0); // COLOR attachment @@ -2235,12 +2235,12 @@ void rlRenderTextureAttach(RenderTexture2D target, unsigned int id, int attachTy glBindFramebuffer(GL_FRAMEBUFFER, target.id); if (attachType == 0) glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, id, 0); - else if (attachType == 1) + else if (attachType == 1) { if (target.depthTexture) glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, id, 0); else glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, id); } - + glBindFramebuffer(GL_FRAMEBUFFER, 0); } @@ -2248,7 +2248,7 @@ void rlRenderTextureAttach(RenderTexture2D target, unsigned int id, int attachTy bool rlRenderTextureComplete(RenderTexture target) { glBindFramebuffer(GL_FRAMEBUFFER, target.id); - + GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER); if (status != GL_FRAMEBUFFER_COMPLETE) @@ -2264,9 +2264,9 @@ bool rlRenderTextureComplete(RenderTexture target) default: break; } } - + glBindFramebuffer(GL_FRAMEBUFFER, 0); - + return (status == GL_FRAMEBUFFER_COMPLETE); } @@ -2349,7 +2349,7 @@ void rlLoadMesh(Mesh *mesh, bool dynamic) TraceLog(LOG_WARNING, "Trying to re-load an already loaded mesh"); return; } - + mesh->vaoId = 0; // Vertex Array Object mesh->vboId[0] = 0; // Vertex positions VBO mesh->vboId[1] = 0; // Vertex texcoords VBO @@ -2766,7 +2766,7 @@ unsigned char *rlReadScreenPixels(int width, int height) for (int x = 0; x < (width*4); x++) { imgData[((height - 1) - y)*width*4 + x] = screenData[(y*width*4) + x]; // Flip line - + // Set alpha component value to 255 (no trasparent image retrieval) // NOTE: Alpha value has already been applied to RGB in framebuffer, we don't need it! if (((x + 1)%4) == 0) imgData[((height - 1) - y)*width*4 + x] = 255; @@ -2822,7 +2822,7 @@ void *rlReadTexturePixels(Texture2D texture) // We are using Option 1, just need to care for texture format on retrieval // NOTE: This behaviour could be conditioned by graphic driver... RenderTexture2D fbo = rlLoadRenderTexture(texture.width, texture.height, UNCOMPRESSED_R8G8B8A8, 16, false); - + glBindFramebuffer(GL_FRAMEBUFFER, fbo.id); glBindTexture(GL_TEXTURE_2D, 0); @@ -2836,7 +2836,7 @@ void *rlReadTexturePixels(Texture2D texture) // Get OpenGL internal formats and data type from our texture format unsigned int glInternalFormat, glFormat, glType; rlGetGlTextureFormats(texture.format, &glInternalFormat, &glFormat, &glType); - + // NOTE: We read data as RGBA because FBO texture is configured as RGBA, despite binding a RGB texture... glReadPixels(0, 0, texture.width, texture.height, glFormat, glType, pixels); @@ -3064,7 +3064,7 @@ void SetShaderValueV(Shader shader, int uniformLoc, const void *value, int unifo case UNIFORM_SAMPLER2D: glUniform1iv(uniformLoc, count, (int *)value); break; default: TraceLog(LOG_WARNING, "Shader uniform could not be set data type not recognized"); } - + //glUseProgram(0); // Avoid reseting current shader program, in case other uniforms are set #endif } @@ -3143,7 +3143,7 @@ Texture2D GenTextureCubemap(Shader shader, Texture2D skyHDR, int size) // NOTE: Faces are stored as 32 bit floating point values glGenTextures(1, &cubemap.id); glBindTexture(GL_TEXTURE_CUBE_MAP, cubemap.id); - for (unsigned int i = 0; i < 6; i++) + for (unsigned int i = 0; i < 6; i++) { #if defined(GRAPHICS_API_OPENGL_33) glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, GL_RGB32F, size, size, 0, GL_RGB, GL_FLOAT, NULL); @@ -3151,7 +3151,7 @@ Texture2D GenTextureCubemap(Shader shader, Texture2D skyHDR, int size) if (texFloatSupported) glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, GL_RGB, size, size, 0, GL_RGB, GL_FLOAT, NULL); #endif } - + glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); #if defined(GRAPHICS_API_OPENGL_33) @@ -3231,7 +3231,7 @@ Texture2D GenTextureIrradiance(Shader shader, Texture2D cubemap, int size) { glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, GL_RGB16F, size, size, 0, GL_RGB, GL_FLOAT, NULL); } - + glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE); @@ -3309,7 +3309,7 @@ Texture2D GenTexturePrefilter(Shader shader, Texture2D cubemap, int size) { glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, GL_RGB16F, size, size, 0, GL_RGB, GL_FLOAT, NULL); } - + glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE); @@ -3417,7 +3417,7 @@ Texture2D GenTextureBRDF(Shader shader, int size) // Unbind framebuffer and textures glBindFramebuffer(GL_FRAMEBUFFER, 0); - + // Unload framebuffer but keep color texture glDeleteRenderbuffers(1, &rbo); glDeleteFramebuffers(1, &fbo); @@ -3464,7 +3464,7 @@ void EndBlendMode(void) void BeginScissorMode(int x, int y, int width, int height) { rlglDraw(); // Force drawing elements - + glEnable(GL_SCISSOR_TEST); glScissor(x, screenHeight - (y + height), width, height); } @@ -3473,7 +3473,7 @@ void BeginScissorMode(int x, int y, int width, int height) void EndScissorMode(void) { rlglDraw(); // Force drawing elements - + glDisable(GL_SCISSOR_TEST); } @@ -4050,7 +4050,7 @@ static void LoadBuffersDefault(void) glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(short)*6*MAX_BATCH_ELEMENTS, vertexData[i].indices, GL_STATIC_DRAW); #endif } - + TraceLog(LOG_INFO, "Internal buffers uploaded successfully (GPU)"); // Unbind the current VAO @@ -4073,7 +4073,7 @@ static void UpdateBuffersDefault(void) glBindBuffer(GL_ARRAY_BUFFER, vertexData[currentBuffer].vboId[0]); glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(float)*3*vertexData[currentBuffer].vCounter, vertexData[currentBuffer].vertices); //glBufferData(GL_ARRAY_BUFFER, sizeof(float)*3*4*MAX_BATCH_ELEMENTS, vertexData[currentBuffer].vertices, GL_DYNAMIC_DRAW); // Update all buffer - + // Texture coordinates buffer glBindBuffer(GL_ARRAY_BUFFER, vertexData[currentBuffer].vboId[1]); glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(float)*2*vertexData[currentBuffer].vCounter, vertexData[currentBuffer].texcoords); @@ -4083,13 +4083,13 @@ static void UpdateBuffersDefault(void) glBindBuffer(GL_ARRAY_BUFFER, vertexData[currentBuffer].vboId[2]); glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(unsigned char)*4*vertexData[currentBuffer].vCounter, vertexData[currentBuffer].colors); //glBufferData(GL_ARRAY_BUFFER, sizeof(float)*4*4*MAX_BATCH_ELEMENTS, vertexData[currentBuffer].colors, GL_DYNAMIC_DRAW); // Update all buffer - + // NOTE: glMapBuffer() causes sync issue. - // If GPU is working with this buffer, glMapBuffer() will wait(stall) until GPU to finish its job. + // If GPU is working with this buffer, glMapBuffer() will wait(stall) until GPU to finish its job. // To avoid waiting (idle), you can call first glBufferData() with NULL pointer before glMapBuffer(). // If you do that, the previous data in PBO will be discarded and glMapBuffer() returns a new // allocated pointer immediately even if GPU is still working with the previous data. - + // Another option: map the buffer object into client's memory // Probably this code could be moved somewhere else... // vertexData[currentBuffer].vertices = (float *)glMapBuffer(GL_ARRAY_BUFFER, GL_READ_WRITE); @@ -4135,7 +4135,7 @@ static void DrawBuffersDefault(void) glUniform1i(currentShader.locs[LOC_MAP_DIFFUSE], 0); // NOTE: Additional map textures not considered for default buffers drawing - + int vertexOffset = 0; if (vaoSupported) glBindVertexArray(vertexData[currentBuffer].vaoId); @@ -4160,7 +4160,7 @@ static void DrawBuffersDefault(void) } glActiveTexture(GL_TEXTURE0); - + for (int i = 0; i < drawsCounter; i++) { glBindTexture(GL_TEXTURE_2D, draws[i].textureId); @@ -4170,7 +4170,7 @@ static void DrawBuffersDefault(void) { #if defined(GRAPHICS_API_OPENGL_33) // We need to define the number of indices to be processed: quadsCount*6 - // NOTE: The final parameter tells the GPU the offset in bytes from the + // NOTE: The final parameter tells the GPU the offset in bytes from the // start of the index buffer to the location of the first index to process glDrawElements(GL_TRIANGLES, draws[i].vertexCount/4*6, GL_UNSIGNED_INT, (GLvoid *)(sizeof(GLuint)*vertexOffset/4*6)); #elif defined(GRAPHICS_API_OPENGL_ES2) @@ -4216,7 +4216,7 @@ static void DrawBuffersDefault(void) } drawsCounter = 1; - + // Change to next buffer in the list currentBuffer++; if (currentBuffer >= MAX_BATCH_BUFFERING) currentBuffer = 0; @@ -4369,14 +4369,14 @@ static void GenDrawCube(void) static VrStereoConfig SetStereoConfig(VrDeviceInfo hmd, Shader distortion) { VrStereoConfig config = { 0 }; - + // Initialize framebuffer and textures for stereo rendering // NOTE: Screen size should match HMD aspect ratio config.stereoFbo = rlLoadRenderTexture(screenWidth, screenHeight, UNCOMPRESSED_R8G8B8A8, 24, false); - + // Assign distortion shader config.distortionShader = distortion; - + // Compute aspect ratio float aspect = ((float)hmd.hResolution*0.5f)/(float)hmd.vResolution; @@ -4442,7 +4442,7 @@ static VrStereoConfig SetStereoConfig(VrDeviceInfo hmd, Shader distortion) SetShaderValue(config.distortionShader, GetShaderLocation(config.distortionShader, "hmdWarpParam"), hmd.lensDistortionValues, UNIFORM_VEC4); SetShaderValue(config.distortionShader, GetShaderLocation(config.distortionShader, "chromaAbParam"), hmd.chromaAbCorrection, UNIFORM_VEC4); #endif - + return config; } diff --git a/src/shapes.c b/src/shapes.c index 8976c81c..87bb573c 100644 --- a/src/shapes.c +++ b/src/shapes.c @@ -143,7 +143,7 @@ void DrawLineEx(Vector2 startPos, Vector2 endPos, float thick, Color color) rlTexCoord2f(recTexShapes.x/texShapes.width, (recTexShapes.y + recTexShapes.height)/texShapes.height); rlVertex2f(0.0f, thick); - + rlTexCoord2f((recTexShapes.x + recTexShapes.width)/texShapes.width, (recTexShapes.y + recTexShapes.height)/texShapes.height); rlVertex2f(d, thick); @@ -187,7 +187,7 @@ void DrawCircle(int centerX, int centerY, float radius, Color color) void DrawCircleSector(Vector2 center, float radius, int startAngle, int endAngle, Color color) { #define CIRCLE_SECTOR_LENGTH 10 - + #if defined(SUPPORT_QUADS_DRAW_MODE) if (rlCheckBufferLimit(4*((360/CIRCLE_SECTOR_LENGTH)/2))) rlglDraw(); @@ -307,10 +307,10 @@ void DrawRectanglePro(Rectangle rec, Vector2 origin, float rotation, Color color rlTexCoord2f(recTexShapes.x/texShapes.width, recTexShapes.y/texShapes.height); rlVertex2f(0.0f, 0.0f); - + rlTexCoord2f(recTexShapes.x/texShapes.width, (recTexShapes.y + recTexShapes.height)/texShapes.height); rlVertex2f(0.0f, rec.height); - + rlTexCoord2f((recTexShapes.x + recTexShapes.width)/texShapes.width, (recTexShapes.y + recTexShapes.height)/texShapes.height); rlVertex2f(rec.width, rec.height); diff --git a/src/text.c b/src/text.c index 17f6d9dd..9a7d690d 100644 --- a/src/text.c +++ b/src/text.c @@ -790,14 +790,14 @@ void DrawTextEx(Font font, const char *text, Vector2 position, float fontSize, f } // Draw text using font inside rectangle limits -void DrawTextRec(Font font, const char *text, Rectangle rec, float fontSize, float spacing, bool wordWrap, Color tint) +void DrawTextRec(Font font, const char *text, Rectangle rec, float fontSize, float spacing, bool wordWrap, Color tint) { DrawTextRecEx(font, text, rec, fontSize, spacing, wordWrap, tint, 0, 0, WHITE, WHITE); } // Draw text using font inside rectangle limits with support for text selection -void DrawTextRecEx(Font font, const char *text, Rectangle rec, float fontSize, float spacing, bool wordWrap, Color tint, - int selectStart, int selectLength, Color selectText, Color selectBack) +void DrawTextRecEx(Font font, const char *text, Rectangle rec, float fontSize, float spacing, bool wordWrap, Color tint, + int selectStart, int selectLength, Color selectText, Color selectBack) { int length = strlen(text); int textOffsetX = 0; // Offset between characters @@ -813,12 +813,12 @@ void DrawTextRecEx(Font font, const char *text, Rectangle rec, float fontSize, f int state = wordWrap? MEASURE_STATE : DRAW_STATE; int startLine = -1; // Index where to begin drawing (where a line begins) int endLine = -1; // Index where to stop drawing (where a line ends) - + for (int i = 0; i < length; i++) { int glyphWidth = 0; letter = (unsigned char)text[i]; - + if (letter != '\n') { if ((unsigned char)text[i] == 0xc2) // UTF-8 encoding identification HACK! @@ -836,41 +836,41 @@ void DrawTextRecEx(Font font, const char *text, Rectangle rec, float fontSize, f i++; } else index = GetGlyphIndex(font, (unsigned char)text[i]); - - glyphWidth = (font.chars[index].advanceX == 0)? + + glyphWidth = (font.chars[index].advanceX == 0)? (int)(font.chars[index].rec.width*scaleFactor + spacing): (int)(font.chars[index].advanceX*scaleFactor + spacing); } - + // NOTE: When wordWrap is ON we first measure how much of the text we can draw - // before going outside of the `rec` container. We store this info inside + // before going outside of the `rec` container. We store this info inside // `startLine` and `endLine` then we change states, draw the text between those two // variables then change states again and again recursively until the end of the text // (or until we get outside of the container). - // When wordWrap is OFF we don't need the measure state so we go to the drawing - // state immediately and begin drawing on the next line before we can get outside + // When wordWrap is OFF we don't need the measure state so we go to the drawing + // state immediately and begin drawing on the next line before we can get outside // the container. - if (state == MEASURE_STATE) + if (state == MEASURE_STATE) { if ((letter == ' ') || (letter == '\t') || (letter == '\n')) endLine = i; - - if ((textOffsetX + glyphWidth + 1) >= rec.width) + + if ((textOffsetX + glyphWidth + 1) >= rec.width) { endLine = (endLine < 1) ? i : endLine; if (i == endLine) endLine -= 1; if ((startLine + 1) == endLine) endLine = i - 1; state = !state; - } - else if ((i + 1) == length) + } + else if ((i + 1) == length) { endLine = i; state = !state; } - else if (letter == '\n') + else if (letter == '\n') { state = !state; } - + if (state == DRAW_STATE) { textOffsetX = 0; @@ -878,8 +878,8 @@ void DrawTextRecEx(Font font, const char *text, Rectangle rec, float fontSize, f glyphWidth = 0; } - } - else + } + else { if (letter == '\n') { @@ -888,17 +888,17 @@ void DrawTextRecEx(Font font, const char *text, Rectangle rec, float fontSize, f textOffsetY += (int)((font.baseSize + font.baseSize/2)*scaleFactor); textOffsetX = 0; } - } - else + } + else { if (!wordWrap && ((textOffsetX + glyphWidth + 1) >= rec.width)) { textOffsetY += (int)((font.baseSize + font.baseSize/2)*scaleFactor); textOffsetX = 0; } - + if ((textOffsetY + (int)((font.baseSize + font.baseSize/2)*scaleFactor)) > rec.height) break; - + //draw selected bool isGlyphSelected = false; if ((selectStart >= 0) && (i >= selectStart) && (i < (selectStart + selectLength))) @@ -907,7 +907,7 @@ void DrawTextRecEx(Font font, const char *text, Rectangle rec, float fontSize, f DrawRectangleRec(strec, selectBack); isGlyphSelected = true; } - + //draw glyph if ((letter != ' ') && (letter != '\t')) { @@ -915,12 +915,12 @@ void DrawTextRecEx(Font font, const char *text, Rectangle rec, float fontSize, f (Rectangle){ rec.x + textOffsetX + font.chars[index].offsetX*scaleFactor, rec.y + textOffsetY + font.chars[index].offsetY*scaleFactor, font.chars[index].rec.width*scaleFactor, - font.chars[index].rec.height*scaleFactor }, (Vector2){ 0, 0 }, 0.0f, + font.chars[index].rec.height*scaleFactor }, (Vector2){ 0, 0 }, 0.0f, (!isGlyphSelected) ? tint : selectText); } } - - if (wordWrap && (i == endLine)) + + if (wordWrap && (i == endLine)) { textOffsetY += (int)((font.baseSize + font.baseSize/2)*scaleFactor); textOffsetX = 0; @@ -930,7 +930,7 @@ void DrawTextRecEx(Font font, const char *text, Rectangle rec, float fontSize, f state = !state; } } - + textOffsetX += glyphWidth; } } @@ -968,11 +968,11 @@ Vector2 MeasureTextEx(Font font, const char *text, float fontSize, float spacing unsigned char letter = 0; // Current character int index = 0; // Index position in sprite font - + for (int i = 0; i < len; i++) { lenCounter++; - + if (text[i] != '\n') { if ((unsigned char)text[i] == 0xc2) // UTF-8 encoding identification @@ -1105,7 +1105,7 @@ const char *TextSubtext(const char *text, int position, int length) const char *TextReplace(char *text, const char *replace, const char *by) { char *result; - + char *insertPoint; // Next insert point char *temp; // Temp pointer int replaceLen; // Replace string length of (the string to remove) @@ -1163,7 +1163,7 @@ const char *TextInsert(const char *text, const char *insert, int position) for (int i = 0; i < position; i++) result[i] = text[i]; for (int i = position; i < insertLen + position; i++) result[i] = insert[i]; for (int i = (insertLen + position); i < (textLen + insertLen); i++) result[i] = text[i]; - + result[textLen + insertLen] = '\0'; // Make sure text string is valid! return result; @@ -1174,7 +1174,7 @@ const char *TextInsert(const char *text, const char *insert, int position) const char *TextJoin(const char **textList, int count, const char *delimiter) { // TODO: Make sure joined text could fit inside MAX_TEXT_BUFFER_LENGTH - + static char text[MAX_TEXT_BUFFER_LENGTH] = { 0 }; memset(text, 0, MAX_TEXT_BUFFER_LENGTH); @@ -1197,9 +1197,9 @@ const char **TextSplit(const char *text, char delimiter, int *count) // all used memory is static... it has some limitations: // 1. Maximum number of possible split strings is set by MAX_SUBSTRINGS_COUNT // 2. Maximum size of text to split is MAX_TEXT_BUFFER_LENGTH - + #define MAX_SUBSTRINGS_COUNT 64 - + static const char *result[MAX_SUBSTRINGS_COUNT] = { NULL }; static char buffer[MAX_TEXT_BUFFER_LENGTH] = { 0 }; memset(buffer, 0, MAX_TEXT_BUFFER_LENGTH); @@ -1208,7 +1208,7 @@ const char **TextSplit(const char *text, char delimiter, int *count) int counter = 1; // Count how many substrings we have on text and point to every one - for (int i = 0; i < MAX_TEXT_BUFFER_LENGTH; i++) + for (int i = 0; i < MAX_TEXT_BUFFER_LENGTH; i++) { buffer[i] = text[i]; if (buffer[i] == '\0') break; @@ -1217,7 +1217,7 @@ const char **TextSplit(const char *text, char delimiter, int *count) buffer[i] = '\0'; // Set an end of string at this point result[counter] = buffer + i + 1; counter++; - + if (counter == MAX_SUBSTRINGS_COUNT) break; } } @@ -1239,11 +1239,11 @@ void TextAppend(char *text, const char *append, int *position) int TextFindIndex(const char *text, const char *find) { int position = -1; - + char *ptr = strstr(text, find); - + if (ptr != NULL) position = ptr - text; - + return position; } @@ -1314,10 +1314,10 @@ int TextToInteger(const char *text) { if ((text[i] > 47) && (text[i] < 58)) result += ((int)text[i] - 48)*units; else { result = -1; break; } - + units *= 10; } - + return result; } diff --git a/src/textures.c b/src/textures.c index 75624fdb..48b89384 100644 --- a/src/textures.c +++ b/src/textures.c @@ -2529,7 +2529,7 @@ void DrawTextureQuad(Texture2D texture, Vector2 tiling, Vector2 offset, Rectangl { Rectangle source = { offset.x*texture.width, offset.y*texture.height, tiling.x*texture.width, tiling.y*texture.height }; Vector2 origin = { 0.0f, 0.0f }; - + DrawTexturePro(texture, source, quad, origin, 0.0f, tint); } @@ -3198,7 +3198,7 @@ static int SaveKTX(Image image, const char *fileName) //unsigned char id[12] = { 0xAB, 0x4B, 0x54, 0x58, 0x20, 0x31, 0x31, 0xBB, 0x0D, 0x0A, 0x1A, 0x0A }; const char ktxIdentifier[12] = { 0xAB, 'K', 'T', 'X', ' ', '1', '1', 0xBB, '\r', '\n', 0x1A, '\n' }; - + // Get the image header strncpy(ktxHeader.id, ktxIdentifier, 12); // KTX 1.1 signature ktxHeader.endianness = 0; -- cgit v1.2.3 From a886f5e743cd50744d7800cd70a47f5cb9f663e3 Mon Sep 17 00:00:00 2001 From: Ray Date: Fri, 22 Feb 2019 12:12:21 +0100 Subject: Remove TABS --- src/core.c | 4 ++-- src/raudio.c | 4 ++-- src/shapes.c | 2 +- src/text.c | 8 ++++---- src/textures.c | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) (limited to 'src/core.c') diff --git a/src/core.c b/src/core.c index 714e6e2c..9f62b4c8 100644 --- a/src/core.c +++ b/src/core.c @@ -871,7 +871,7 @@ void *GetWindowHandle(void) { #if defined(_WIN32) // NOTE: Returned handle is: void *HWND (windows.h) - return glfwGetWin32Window(window); + return glfwGetWin32Window(window); #elif defined(__linux__) // NOTE: Returned handle is: unsigned long Window (X.h) // typedef unsigned long XID; @@ -2213,7 +2213,7 @@ void SetMouseOffset(int offsetX, int offsetY) // NOTE: Useful when rendering to different size targets void SetMouseScale(float scaleX, float scaleY) { - mouseScale = (Vector2){ scaleX, scaleY }; + mouseScale = (Vector2){ scaleX, scaleY }; } // Returns mouse wheel movement Y diff --git a/src/raudio.c b/src/raudio.c index e1c9fd48..4f3e9220 100644 --- a/src/raudio.c +++ b/src/raudio.c @@ -1406,8 +1406,8 @@ void UpdateMusicStream(Music music) UpdateAudioStream(music->stream, pcm, samplesCount); if ((music->ctxType == MUSIC_MODULE_XM) || (music->ctxType == MUSIC_MODULE_MOD)) { - if (samplesCount > 1) music->samplesLeft -= samplesCount/2; - else music->samplesLeft -= samplesCount; + if (samplesCount > 1) music->samplesLeft -= samplesCount/2; + else music->samplesLeft -= samplesCount; } else music->samplesLeft -= samplesCount; diff --git a/src/shapes.c b/src/shapes.c index 87bb573c..dbc38082 100644 --- a/src/shapes.c +++ b/src/shapes.c @@ -644,7 +644,7 @@ bool CheckCollisionCircleRec(Vector2 center, float radius, Rectangle rec) if (dy <= (rec.height/2.0f)) { return true; } float cornerDistanceSq = (dx - rec.width/2.0f)*(dx - rec.width/2.0f) + - (dy - rec.height/2.0f)*(dy - rec.height/2.0f); + (dy - rec.height/2.0f)*(dy - rec.height/2.0f); return (cornerDistanceSq <= (radius*radius)); } diff --git a/src/text.c b/src/text.c index 9a7d690d..3a5b33d6 100644 --- a/src/text.c +++ b/src/text.c @@ -1386,10 +1386,10 @@ static Font LoadBMFont(const char *fileName) char *lastSlash = NULL; lastSlash = strrchr(fileName, '/'); - if (lastSlash == NULL) - { - lastSlash = strrchr(fileName, '\\'); - } + if (lastSlash == NULL) + { + lastSlash = strrchr(fileName, '\\'); + } // NOTE: We need some extra space to avoid memory corruption on next allocations! texPath = malloc(strlen(fileName) - strlen(lastSlash) + strlen(texFileName) + 4); diff --git a/src/textures.c b/src/textures.c index 48b89384..5c48ba45 100644 --- a/src/textures.c +++ b/src/textures.c @@ -1631,7 +1631,7 @@ Color *ImageExtractPalette(Image image, int maxPaletteSize, int *extractCount) if (palCount >= maxPaletteSize) { i = image.width*image.height; // Finish palette get - printf("WARNING: Image palette is greater than %i colors!\n", maxPaletteSize); + TraceLog(LOG_WARNING, "Image palette is greater than %i colors!", maxPaletteSize); } } } -- cgit v1.2.3 From 374811c440302701496bfb474ce5861c951c5884 Mon Sep 17 00:00:00 2001 From: Ray Date: Fri, 22 Feb 2019 13:13:11 +0100 Subject: Change ternary operator formatting --- src/core.c | 44 ++++++++++++++++++++++---------------------- src/models.c | 8 ++++---- src/raudio.c | 22 +++++++++++----------- src/rlgl.h | 10 +++++----- src/shapes.c | 2 +- src/text.c | 10 +++++----- src/textures.c | 8 ++++---- 7 files changed, 52 insertions(+), 52 deletions(-) (limited to 'src/core.c') diff --git a/src/core.c b/src/core.c index 9f62b4c8..bff92600 100644 --- a/src/core.c +++ b/src/core.c @@ -1430,11 +1430,11 @@ Vector3 ColorToHSV(Color color) Vector3 hsv = { 0.0f, 0.0f, 0.0f }; float min, max, delta; - min = rgb.x < rgb.y ? rgb.x : rgb.y; - min = min < rgb.z ? min : rgb.z; + min = rgb.x < rgb.y? rgb.x : rgb.y; + min = min < rgb.z? min : rgb.z; - max = rgb.x > rgb.y ? rgb.x : rgb.y; - max = max > rgb.z ? max : rgb.z; + max = rgb.x > rgb.y? rgb.x : rgb.y; + max = max > rgb.z? max : rgb.z; hsv.z = max; // Value delta = max - min; @@ -1485,25 +1485,25 @@ Color ColorFromHSV(Vector3 hsv) // Red channel float k = fmod((5.0f + h/60.0f), 6); float t = 4.0f - k; - k = (t < k) ? t : k; - k = (k < 1) ? k : 1; - k = (k > 0) ? k : 0; + k = (t < k)? t : k; + k = (k < 1)? k : 1; + k = (k > 0)? k : 0; color.r = (v - v*s*k)*255; // Green channel k = fmod((3.0f + h/60.0f), 6); t = 4.0f - k; - k = (t < k) ? t : k; - k = (k < 1) ? k : 1; - k = (k > 0) ? k : 0; + k = (t < k)? t : k; + k = (k < 1)? k : 1; + k = (k > 0)? k : 0; color.g = (v - v*s*k)*255; // Blue channel k = fmod((1.0f + h/60.0f), 6); t = 4.0f - k; - k = (t < k) ? t : k; - k = (k < 1) ? k : 1; - k = (k > 0) ? k : 0; + k = (t < k)? t : k; + k = (k < 1)? k : 1; + k = (k > 0)? k : 0; color.b = (v - v*s*k)*255; return color; @@ -1677,7 +1677,7 @@ const char *GetFileNameWithoutExt(const char *filePath) // NOTE: strrchr() returns a pointer to the last occurrence of character lastDot = strrchr(result, nameDot); - lastSep = (pathSep == 0) ? NULL : strrchr(result, pathSep); + lastSep = (pathSep == 0)? NULL : strrchr(result, pathSep); if (lastDot != NULL) // Check if it has an extension separator... { @@ -3191,7 +3191,7 @@ static void PollInputEvents(void) // Poll Events (registered events) // NOTE: Activity is paused if not enabled (appEnabled) - while ((ident = ALooper_pollAll(appEnabled ? 0 : -1, NULL, &events,(void**)&source)) >= 0) + while ((ident = ALooper_pollAll(appEnabled? 0 : -1, NULL, &events,(void**)&source)) >= 0) { // Process this event if (source != NULL) source->process(androidApp, source); @@ -3771,7 +3771,7 @@ static EM_BOOL EmscriptenTouchCallback(int eventType, const EmscriptenTouchEvent } printf("%s, numTouches: %d %s%s%s%s\n", emscripten_event_type_to_string(eventType), event->numTouches, - event->ctrlKey ? " CTRL" : "", event->shiftKey ? " SHIFT" : "", event->altKey ? " ALT" : "", event->metaKey ? " META" : ""); + event->ctrlKey? " CTRL" : "", event->shiftKey? " SHIFT" : "", event->altKey? " ALT" : "", event->metaKey? " META" : ""); for (int i = 0; i < event->numTouches; ++i) { @@ -3825,7 +3825,7 @@ static EM_BOOL EmscriptenGamepadCallback(int eventType, const EmscriptenGamepadE { /* printf("%s: timeStamp: %g, connected: %d, index: %ld, numAxes: %d, numButtons: %d, id: \"%s\", mapping: \"%s\"\n", - eventType != 0 ? emscripten_event_type_to_string(eventType) : "Gamepad state", + eventType != 0? emscripten_event_type_to_string(eventType) : "Gamepad state", gamepadEvent->timestamp, gamepadEvent->connected, gamepadEvent->index, gamepadEvent->numAxes, gamepadEvent->numButtons, gamepadEvent->id, gamepadEvent->mapping); for(int i = 0; i < gamepadEvent->numAxes; ++i) printf("Axis %d: %g\n", i, gamepadEvent->axis[i]); @@ -4189,11 +4189,11 @@ static void EventThreadSpawn(char *device) { // Looks like a interesting device TraceLog(LOG_INFO, "Opening input device [%s] (%s%s%s%s%s)", device, - worker->isMouse ? "mouse " : "", - worker->isMultitouch ? "multitouch " : "", - worker->isTouch ? "touchscreen " : "", - worker->isGamepad ? "gamepad " : "", - worker->isKeyboard ? "keyboard " : ""); + worker->isMouse? "mouse " : "", + worker->isMultitouch? "multitouch " : "", + worker->isTouch? "touchscreen " : "", + worker->isGamepad? "gamepad " : "", + worker->isKeyboard? "keyboard " : ""); // Create a thread for this device int error = pthread_create(&worker->threadId, NULL, &EventThread, (void *)worker); diff --git a/src/models.c b/src/models.c index 384c8db4..b261f58d 100644 --- a/src/models.c +++ b/src/models.c @@ -2260,7 +2260,7 @@ void MeshTangents(Mesh *mesh) float t2 = uv3.y - uv1.y; float div = s1*t2 - s2*t1; - float r = (div == 0.0f) ? 0.0f : 1.0f/div; + float r = (div == 0.0f)? 0.0f : 1.0f/div; Vector3 sdir = { (t2*x1 - t1*x2)*r, (t2*y1 - t1*y2)*r, (t2*z1 - t1*z2)*r }; Vector3 tdir = { (s1*x2 - s2*x1)*r, (s1*y2 - s2*y1)*r, (s1*z2 - s2*z1)*r }; @@ -2293,7 +2293,7 @@ void MeshTangents(Mesh *mesh) mesh->tangents[i*4 + 0] = tangent.x; mesh->tangents[i*4 + 1] = tangent.y; mesh->tangents[i*4 + 2] = tangent.z; - mesh->tangents[i*4 + 3] = (Vector3DotProduct(Vector3CrossProduct(normal, tangent), tan2[i]) < 0.0f) ? -1.0f : 1.0f; + mesh->tangents[i*4 + 3] = (Vector3DotProduct(Vector3CrossProduct(normal, tangent), tan2[i]) < 0.0f)? -1.0f : 1.0f; #endif } @@ -2312,7 +2312,7 @@ void MeshBinormals(Mesh *mesh) Vector3 tangent = { mesh->tangents[i*4 + 0], mesh->tangents[i*4 + 1], mesh->tangents[i*4 + 2] }; float tangentW = mesh->tangents[i*4 + 3]; - // TODO: Register computed binormal in mesh->binormal ? + // TODO: Register computed binormal in mesh->binormal? // Vector3 binormal = Vector3Multiply(Vector3CrossProduct(normal, tangent), tangentW); } } @@ -2639,7 +2639,7 @@ static Material LoadMTL(const char *fileName) } break; case 'e': // Ke float float float Emmisive color (RGB) { - // TODO: Support Ke ? + // TODO: Support Ke? } break; default: break; } diff --git a/src/raudio.c b/src/raudio.c index 4f3e9220..451d3bc3 100644 --- a/src/raudio.c +++ b/src/raudio.c @@ -834,7 +834,7 @@ Sound LoadSoundFromWave(Wave wave) // // I have decided on the first option because it offloads work required for the format conversion to the to the loading stage. // The downside to this is that it uses more memory if the original sound is u8 or s16. - mal_format formatIn = ((wave.sampleSize == 8) ? mal_format_u8 : ((wave.sampleSize == 16) ? mal_format_s16 : mal_format_f32)); + mal_format formatIn = ((wave.sampleSize == 8)? mal_format_u8 : ((wave.sampleSize == 16)? mal_format_s16 : mal_format_f32)); mal_uint32 frameCountIn = wave.sampleCount/wave.channels; mal_uint32 frameCount = (mal_uint32)mal_convert_frames(NULL, DEVICE_FORMAT, DEVICE_CHANNELS, DEVICE_SAMPLE_RATE, NULL, formatIn, wave.channels, wave.sampleRate, frameCountIn); @@ -946,7 +946,7 @@ void ExportWaveAsCode(Wave wave, const char *fileName) // Write byte data as hexadecimal text fprintf(txtFile, "static unsigned char %s_DATA[%i] = { ", varFileName, dataSize); - for (int i = 0; i < dataSize - 1; i++) fprintf(txtFile, ((i%BYTES_TEXT_PER_LINE == 0) ? "0x%x,\n" : "0x%x, "), ((unsigned char *)wave.data)[i]); + for (int i = 0; i < dataSize - 1; i++) fprintf(txtFile, ((i%BYTES_TEXT_PER_LINE == 0)? "0x%x,\n" : "0x%x, "), ((unsigned char *)wave.data)[i]); fprintf(txtFile, "0x%x };\n", ((unsigned char *)wave.data)[dataSize - 1]); fclose(txtFile); @@ -997,8 +997,8 @@ void SetSoundPitch(Sound sound, float pitch) // Convert wave data to desired format void WaveFormat(Wave *wave, int sampleRate, int sampleSize, int channels) { - mal_format formatIn = ((wave->sampleSize == 8) ? mal_format_u8 : ((wave->sampleSize == 16) ? mal_format_s16 : mal_format_f32)); - mal_format formatOut = (( sampleSize == 8) ? mal_format_u8 : (( sampleSize == 16) ? mal_format_s16 : mal_format_f32)); + mal_format formatIn = ((wave->sampleSize == 8)? mal_format_u8 : ((wave->sampleSize == 16)? mal_format_s16 : mal_format_f32)); + mal_format formatOut = (( sampleSize == 8)? mal_format_u8 : (( sampleSize == 16)? mal_format_s16 : mal_format_f32)); mal_uint32 frameCountIn = wave->sampleCount; // Is wave->sampleCount actually the frame count? That terminology needs to change, if so. @@ -1511,7 +1511,7 @@ AudioStream InitAudioStream(unsigned int sampleRate, unsigned int sampleSize, un stream.channels = 1; // Fallback to mono channel } - mal_format formatIn = ((stream.sampleSize == 8) ? mal_format_u8 : ((stream.sampleSize == 16) ? mal_format_s16 : mal_format_f32)); + mal_format formatIn = ((stream.sampleSize == 8)? mal_format_u8 : ((stream.sampleSize == 16)? mal_format_s16 : mal_format_f32)); // The size of a streaming buffer must be at least double the size of a period. unsigned int periodSize = device.bufferSizeInFrames/device.periods; @@ -1528,7 +1528,7 @@ AudioStream InitAudioStream(unsigned int sampleRate, unsigned int sampleSize, un audioBuffer->looping = true; // Always loop for streaming buffers. stream.audioBuffer = audioBuffer; - 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"); + 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; } @@ -1566,7 +1566,7 @@ void UpdateAudioStream(AudioStream stream, const void *data, int samplesCount) else { // Just update whichever sub-buffer is processed. - subBufferToUpdate = (audioBuffer->isSubBufferProcessed[0]) ? 0 : 1; + subBufferToUpdate = (audioBuffer->isSubBufferProcessed[0])? 0 : 1; } mal_uint32 subBufferSizeInFrames = audioBuffer->bufferSizeInFrames/2; @@ -1769,7 +1769,7 @@ static Wave LoadWAV(const char *fileName) // NOTE: subChunkSize comes in bytes, we need to translate it to number of samples wave.sampleCount = (wavData.subChunkSize/(wave.sampleSize/8))/wave.channels; - TraceLog(LOG_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"); } } } @@ -1890,7 +1890,7 @@ static Wave LoadOGG(const char *fileName) TraceLog(LOG_DEBUG, "[%s] Samples obtained: %i", fileName, numSamplesOgg); - TraceLog(LOG_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); } @@ -1917,7 +1917,7 @@ static Wave LoadFLAC(const char *fileName) if (wave.channels > 2) TraceLog(LOG_WARNING, "[%s] FLAC channels number (%i) not supported", fileName, wave.channels); 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"); + 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; } @@ -1944,7 +1944,7 @@ static Wave LoadMP3(const char *fileName) if (wave.channels > 2) TraceLog(LOG_WARNING, "[%s] MP3 channels number (%i) not supported", fileName, wave.channels); if (wave.data == NULL) TraceLog(LOG_WARNING, "[%s] MP3 data could not be loaded", fileName); - else TraceLog(LOG_INFO, "[%s] MP3 file loaded successfully (%i Hz, %i bit, %s)", fileName, wave.sampleRate, wave.sampleSize, (wave.channels == 1) ? "Mono" : "Stereo"); + else TraceLog(LOG_INFO, "[%s] MP3 file loaded successfully (%i Hz, %i bit, %s)", fileName, wave.sampleRate, wave.sampleSize, (wave.channels == 1)? "Mono" : "Stereo"); return wave; } diff --git a/src/rlgl.h b/src/rlgl.h index c9f15385..52165150 100644 --- a/src/rlgl.h +++ b/src/rlgl.h @@ -775,8 +775,8 @@ typedef struct DrawCall { #endif "void main() \n" "{ \n" - " vec2 lensCenter = fragTexCoord.x < 0.5 ? leftLensCenter : rightLensCenter; \n" - " vec2 screenCenter = fragTexCoord.x < 0.5 ? leftScreenCenter : rightScreenCenter; \n" + " vec2 lensCenter = fragTexCoord.x < 0.5? leftLensCenter : rightLensCenter; \n" + " vec2 screenCenter = fragTexCoord.x < 0.5? leftScreenCenter : rightScreenCenter; \n" " vec2 theta = (fragTexCoord - lensCenter)*scaleIn; \n" " float rSq = theta.x*theta.x + theta.y*theta.y; \n" " vec2 theta1 = theta*(hmdWarpParam.x + hmdWarpParam.y*rSq + hmdWarpParam.z*rSq*rSq + hmdWarpParam.w*rSq*rSq*rSq); \n" @@ -1136,7 +1136,7 @@ void rlEnd(void) // TODO: System could be improved (a bit) just storing every draw alignment value // and adding it to vertexOffset on drawing... maybe in a future... int vertexCount = draws[drawsCounter - 1].vertexCount; - int vertexToAlign = (vertexCount >= 4) ? vertexCount%4 : (4 - vertexCount%4); + int vertexToAlign = (vertexCount >= 4)? vertexCount%4 : (4 - vertexCount%4); for (int i = 0; i < vertexToAlign; i++) rlVertex3f(-1, -1, -1); // Make sure vertexCount is the same for vertices, texcoords, colors and normals @@ -1233,7 +1233,7 @@ void rlTexCoord2f(float x, float y) } // Define one vertex (normal) -// NOTE: Normals limited to TRIANGLES only ? +// NOTE: Normals limited to TRIANGLES only? void rlNormal3f(float x, float y, float z) { // TODO: Normals usage... @@ -2206,7 +2206,7 @@ RenderTexture2D rlLoadRenderTexture(int width, int height, int format, int depth target.depth.id = rlLoadTextureDepth(width, height, depthBits, !useDepthTexture); target.depth.width = width; target.depth.height = height; - target.depth.format = 19; //DEPTH_COMPONENT_24BIT ? + target.depth.format = 19; //DEPTH_COMPONENT_24BIT? target.depth.mipmaps = 1; } //----------------------------------------------------------------------------------------------------- diff --git a/src/shapes.c b/src/shapes.c index dbc38082..837e4e9c 100644 --- a/src/shapes.c +++ b/src/shapes.c @@ -132,7 +132,7 @@ void DrawLineEx(Vector2 startPos, Vector2 endPos, float thick, Color color) rlPushMatrix(); rlTranslatef((float)startPos.x, (float)startPos.y, 0.0f); rlRotatef(RAD2DEG*angle, 0.0f, 0.0f, 1.0f); - rlTranslatef(0, (thick > 1.0f) ? -thick/2.0f : -1.0f, 0.0f); + rlTranslatef(0, (thick > 1.0f)? -thick/2.0f : -1.0f, 0.0f); rlBegin(RL_QUADS); rlColor4ub(color.r, color.g, color.b, color.a); diff --git a/src/text.c b/src/text.c index 56db3f28..39582db2 100644 --- a/src/text.c +++ b/src/text.c @@ -306,7 +306,7 @@ Font LoadFontEx(const char *fileName, int fontSize, int *fontChars, int charsCou Font font = { 0 }; font.baseSize = fontSize; - font.charsCount = (charsCount > 0) ? charsCount : 95; + font.charsCount = (charsCount > 0)? charsCount : 95; font.chars = LoadFontData(fileName, font.baseSize, fontChars, font.charsCount, FONT_DEFAULT); #if defined(SUPPORT_FILEFORMAT_TTF) @@ -483,7 +483,7 @@ CharInfo *LoadFontData(const char *fileName, int fontSize, int *fontChars, int c stbtt_GetFontVMetrics(&fontInfo, &ascent, &descent, &lineGap); // In case no chars count provided, default to 95 - charsCount = (charsCount > 0) ? charsCount : 95; + charsCount = (charsCount > 0)? charsCount : 95; // Fill fontChars in case not provided externally // NOTE: By default we fill charsCount consecutevely, starting at 32 (Space) @@ -557,7 +557,7 @@ Image GenImageFontAtlas(CharInfo *chars, int charsCount, int fontSize, int paddi Image atlas = { 0 }; // In case no chars count provided we suppose default of 95 - charsCount = (charsCount > 0) ? charsCount : 95; + charsCount = (charsCount > 0)? charsCount : 95; // Calculate image size based on required pixel area // NOTE 1: Image is forced to be squared and POT... very conservative! @@ -856,7 +856,7 @@ void DrawTextRecEx(Font font, const char *text, Rectangle rec, float fontSize, f if ((textOffsetX + glyphWidth + 1) >= rec.width) { - endLine = (endLine < 1) ? i : endLine; + endLine = (endLine < 1)? i : endLine; if (i == endLine) endLine -= 1; if ((startLine + 1) == endLine) endLine = i - 1; state = !state; @@ -916,7 +916,7 @@ void DrawTextRecEx(Font font, const char *text, Rectangle rec, float fontSize, f rec.y + textOffsetY + font.chars[index].offsetY*scaleFactor, font.chars[index].rec.width*scaleFactor, font.chars[index].rec.height*scaleFactor }, (Vector2){ 0, 0 }, 0.0f, - (!isGlyphSelected) ? tint : selectText); + (!isGlyphSelected)? tint : selectText); } } diff --git a/src/textures.c b/src/textures.c index 5c48ba45..d79cb3cb 100644 --- a/src/textures.c +++ b/src/textures.c @@ -588,7 +588,7 @@ Vector4 *GetImageDataNormalized(Image image) pixels[i].x = (float)((pixel & 0b1111100000000000) >> 11)*(1.0f/31); pixels[i].y = (float)((pixel & 0b0000011111000000) >> 6)*(1.0f/31); pixels[i].z = (float)((pixel & 0b0000000000111110) >> 1)*(1.0f/31); - pixels[i].w = ((pixel & 0b0000000000000001) == 0) ? 0.0f : 1.0f; + pixels[i].w = ((pixel & 0b0000000000000001) == 0)? 0.0f : 1.0f; } break; case UNCOMPRESSED_R5G6B5: @@ -814,7 +814,7 @@ void ExportImageAsCode(Image image, const char *fileName) fprintf(txtFile, "#define %s_FORMAT %i // raylib internal pixel format\n\n", varFileName, image.format); fprintf(txtFile, "static unsigned char %s_DATA[%i] = { ", varFileName, dataSize); - for (int i = 0; i < dataSize - 1; i++) fprintf(txtFile, ((i%BYTES_TEXT_PER_LINE == 0) ? "0x%x,\n" : "0x%x, "), ((unsigned char *)image.data)[i]); + for (int i = 0; i < dataSize - 1; i++) fprintf(txtFile, ((i%BYTES_TEXT_PER_LINE == 0)? "0x%x,\n" : "0x%x, "), ((unsigned char *)image.data)[i]); fprintf(txtFile, "0x%x };\n", ((unsigned char *)image.data)[dataSize - 1]); fclose(txtFile); @@ -984,7 +984,7 @@ void ImageFormat(Image *image, int newFormat) r = (unsigned char)(round(pixels[i].x*31.0f)); g = (unsigned char)(round(pixels[i].y*31.0f)); b = (unsigned char)(round(pixels[i].z*31.0f)); - a = (pixels[i].w > ((float)ALPHA_THRESHOLD/255.0f)) ? 1 : 0; + a = (pixels[i].w > ((float)ALPHA_THRESHOLD/255.0f))? 1 : 0; ((unsigned short *)image->data)[i] = (unsigned short)r << 11 | (unsigned short)g << 6 | (unsigned short)b << 1 | (unsigned short)a; } @@ -2231,7 +2231,7 @@ Image GenImageGradientH(int width, int height, Color left, Color right) Image GenImageGradientRadial(int width, int height, float density, Color inner, Color outer) { Color *pixels = (Color *)malloc(width*height*sizeof(Color)); - float radius = (width < height) ? (float)width/2.0f : (float)height/2.0f; + float radius = (width < height)? (float)width/2.0f : (float)height/2.0f; float centerX = (float)width/2.0f; float centerY = (float)height/2.0f; -- cgit v1.2.3 From 50da9f623e1c2c70530653399a9acf1092e30a1d Mon Sep 17 00:00:00 2001 From: Ray Date: Thu, 28 Feb 2019 22:25:27 +0100 Subject: Return value in GetClipboardText() --- src/core.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/core.c') diff --git a/src/core.c b/src/core.c index bff92600..dc60eee4 100644 --- a/src/core.c +++ b/src/core.c @@ -990,6 +990,8 @@ const char *GetClipboardText(void) { #if defined(PLATFORM_DESKTOP) return glfwGetClipboardString(window); +#else + return NULL; #endif } -- cgit v1.2.3 From 36fa0207f29a4f3e2ed1a8e4d541bcd14e09ff2b Mon Sep 17 00:00:00 2001 From: Ray Date: Thu, 28 Feb 2019 23:06:37 +0100 Subject: Some spacing review --- src/core.c | 2 +- src/rlgl.h | 6 +++--- src/shapes.c | 2 +- src/text.c | 2 -- 4 files changed, 5 insertions(+), 7 deletions(-) (limited to 'src/core.c') diff --git a/src/core.c b/src/core.c index dc60eee4..4e195ec7 100644 --- a/src/core.c +++ b/src/core.c @@ -4321,7 +4321,7 @@ static void *EventThread(void *arg) // Button parsing if (event.type == EV_KEY) { - if((event.code == BTN_TOUCH) || (event.code == BTN_LEFT)) + if ((event.code == BTN_TOUCH) || (event.code == BTN_LEFT)) { currentMouseStateEvdev[MOUSE_LEFT_BUTTON] = event.value; if (event.value > 0) gestureEvent.touchAction = TOUCH_DOWN; diff --git a/src/rlgl.h b/src/rlgl.h index a8987839..b8895a08 100644 --- a/src/rlgl.h +++ b/src/rlgl.h @@ -1624,7 +1624,7 @@ void rlglInit(int width, int height) if (strcmp(extList[i], (const char *)"GL_EXT_texture_mirror_clamp") == 0) texMirrorClampSupported = true; // Debug marker support - if(strcmp(extList[i], (const char *)"GL_EXT_debug_marker") == 0) debugMarkerSupported = true; + if (strcmp(extList[i], (const char *)"GL_EXT_debug_marker") == 0) debugMarkerSupported = true; } #if defined(_WIN32) && defined(_MSC_VER) @@ -1804,7 +1804,7 @@ void rlLoadExtensions(void *loader) #if defined(GRAPHICS_API_OPENGL_21) 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(LOG_INFO, "OpenGL 3.3 Core profile 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 @@ -4095,7 +4095,7 @@ static void UpdateBuffersDefault(void) // Another option: map the buffer object into client's memory // Probably this code could be moved somewhere else... // vertexData[currentBuffer].vertices = (float *)glMapBuffer(GL_ARRAY_BUFFER, GL_READ_WRITE); - // if(vertexData[currentBuffer].vertices) + // if (vertexData[currentBuffer].vertices) // { // Update vertex data // } diff --git a/src/shapes.c b/src/shapes.c index 837e4e9c..fd28f3a3 100644 --- a/src/shapes.c +++ b/src/shapes.c @@ -400,7 +400,7 @@ void DrawRectangleLinesEx(Rectangle rec, int lineThick, Color color) { if (lineThick > rec.width || lineThick > rec.height) { - if(rec.width > rec.height) lineThick = (int)rec.height/2; + if (rec.width > rec.height) lineThick = (int)rec.height/2; else if (rec.width < rec.height) lineThick = (int)rec.width/2; } diff --git a/src/text.c b/src/text.c index f228a4df..d44cdd11 100644 --- a/src/text.c +++ b/src/text.c @@ -1326,13 +1326,11 @@ int TextToInteger(const char *text) return result; } - //---------------------------------------------------------------------------------- //---------------------------------------------------------------------------------- // Module specific Functions Definition //---------------------------------------------------------------------------------- - #if defined(SUPPORT_FILEFORMAT_FNT) // Load a BMFont file (AngelCode font file) static Font LoadBMFont(const char *fileName) -- cgit v1.2.3 From 2e99c6cefbaacf03d71ad10c03a60fbb49c46aa1 Mon Sep 17 00:00:00 2001 From: Ray Date: Mon, 4 Mar 2019 22:58:20 +0100 Subject: ADDED: IsWindowResized() --- src/core.c | 15 +++++++++++++++ src/raylib.h | 1 + 2 files changed, 16 insertions(+) (limited to 'src/core.c') diff --git a/src/core.c b/src/core.c index 4e195ec7..e6852eef 100644 --- a/src/core.c +++ b/src/core.c @@ -273,6 +273,7 @@ static GLFWwindow *window; // Native window (graphic device #endif static bool windowReady = false; // Check if window has been initialized successfully static bool windowMinimized = false; // Check if window has been minimized +static bool windowResized = false; // Check if window has been resized static const char *windowTitle = NULL; // Window text title... static unsigned int displayWidth, displayHeight;// Display width and height (monitor, device-screen, LCD, ...) @@ -742,6 +743,16 @@ bool IsWindowMinimized(void) #endif } +// Check if window has been resized +bool IsWindowResized(void) +{ +#if defined(PLATFORM_DESKTOP) || defined(PLATFORM_WEB) || defined(PLATFORM_UWP) + return windowResized; +#else + return false; +#endif +} + // Check if window is currently hidden bool IsWindowHidden(void) { @@ -3137,6 +3148,8 @@ static void PollInputEvents(void) gamepadAxisCount = axisCount; } } + + windowResized = false; #if defined(SUPPORT_EVENTS_WAITING) glfwWaitEvents(); @@ -3414,6 +3427,8 @@ static void WindowSizeCallback(GLFWwindow *window, int width, int height) currentHeight = height; // NOTE: Postprocessing texture is not scaled to new size + + windowResized = true; } // GLFW3 WindowIconify Callback, runs when window is minimized/restored diff --git a/src/raylib.h b/src/raylib.h index 17a6efc6..9fdcf2d8 100644 --- a/src/raylib.h +++ b/src/raylib.h @@ -865,6 +865,7 @@ RLAPI bool WindowShouldClose(void); // Check if KE RLAPI void CloseWindow(void); // Close window and unload OpenGL context RLAPI bool IsWindowReady(void); // Check if window has been initialized successfully RLAPI bool IsWindowMinimized(void); // Check if window has been minimized (or lost focus) +RLAPI bool IsWindowResized(void); // Check if window has been resized RLAPI bool IsWindowHidden(void); // Check if window is currently hidden RLAPI void ToggleFullscreen(void); // Toggle fullscreen mode (only PLATFORM_DESKTOP) RLAPI void UnhideWindow(void); // Show the window -- cgit v1.2.3 From 477ea4d6606aa4659549f786935096942f187b37 Mon Sep 17 00:00:00 2001 From: Ray Date: Tue, 12 Mar 2019 16:00:26 +0100 Subject: Support external config flags --- src/core.c | 2 ++ src/rlgl.h | 5 ++++- src/textures.c | 13 +++++++++++++ src/utils.c | 8 ++++++-- 4 files changed, 25 insertions(+), 3 deletions(-) (limited to 'src/core.c') diff --git a/src/core.c b/src/core.c index e6852eef..55b6ba82 100644 --- a/src/core.c +++ b/src/core.c @@ -92,6 +92,8 @@ // Check if config flags have been externally provided on compilation line #if !defined(EXTERNAL_CONFIG_FLAGS) #include "config.h" // Defines module configuration flags +#else + #define RAYLIB_VERSION "2.5" #endif #if (defined(__linux__) || defined(PLATFORM_WEB)) && _POSIX_C_SOURCE < 199309L diff --git a/src/rlgl.h b/src/rlgl.h index b8895a08..00658fa1 100644 --- a/src/rlgl.h +++ b/src/rlgl.h @@ -563,7 +563,10 @@ int GetPixelDataSize(int width, int height, int format);// Get pixel data size i #define SUPPORT_VR_SIMULATOR #define SUPPORT_DISTORTION_SHADER #else - #include "config.h" // rlgl module configuration + // Check if config flags have been externally provided on compilation line + #if !defined(EXTERNAL_CONFIG_FLAGS) + #include "config.h" // Defines module configuration flags + #endif #endif #include // Required for: fopen(), fclose(), fread()... [Used only on LoadText()] diff --git a/src/textures.c b/src/textures.c index 01c9b2f5..95cb4eb5 100644 --- a/src/textures.c +++ b/src/textures.c @@ -181,6 +181,15 @@ static Image LoadASTC(const char *fileName); // Load ASTC file Image LoadImage(const char *fileName) { Image image = { 0 }; + +#if defined(SUPPORT_FILEFORMAT_PNG) || \ + defined(SUPPORT_FILEFORMAT_BMP) || \ + defined(SUPPORT_FILEFORMAT_TGA) || \ + defined(SUPPORT_FILEFORMAT_GIF) || \ + defined(SUPPORT_FILEFORMAT_PIC) || \ + defined(SUPPORT_FILEFORMAT_PSD) +#define STBI_REQUIRED +#endif #if defined(SUPPORT_FILEFORMAT_PNG) if ((IsFileExtension(fileName, ".png")) @@ -207,6 +216,7 @@ Image LoadImage(const char *fileName) #endif ) { +#if defined(STBI_REQUIRED) int imgWidth = 0; int imgHeight = 0; int imgBpp = 0; @@ -229,6 +239,7 @@ Image LoadImage(const char *fileName) else if (imgBpp == 3) image.format = UNCOMPRESSED_R8G8B8; else if (imgBpp == 4) image.format = UNCOMPRESSED_R8G8B8A8; } +#endif } #if defined(SUPPORT_FILEFORMAT_HDR) else if (IsFileExtension(fileName, ".hdr")) @@ -1403,6 +1414,8 @@ void ImageResizeCanvas(Image *image, int newWidth,int newHeight, int offsetX, in else { // TODO: ImageCrop(), define proper cropping rectangle + + UnloadImage(imTemp); } } diff --git a/src/utils.c b/src/utils.c index b31ce6ae..6b174354 100644 --- a/src/utils.c +++ b/src/utils.c @@ -30,9 +30,13 @@ * **********************************************************************************************/ -#include "config.h" - #include "raylib.h" // WARNING: Required for: LogType enum + +// Check if config flags have been externally provided on compilation line +#if !defined(EXTERNAL_CONFIG_FLAGS) + #include "config.h" // Defines module configuration flags +#endif + #include "utils.h" #if defined(PLATFORM_ANDROID) -- cgit v1.2.3 From 5e8427a8b53dfe5b9525626da2093eba8f9c8da9 Mon Sep 17 00:00:00 2001 From: Ray Date: Wed, 13 Mar 2019 10:07:01 +0100 Subject: REDESIGNED: GetFileNameWithoutExt() Removed possible memory leak when using this function --- src/core.c | 48 ++++++++++++++++++------------------------------ 1 file changed, 18 insertions(+), 30 deletions(-) (limited to 'src/core.c') diff --git a/src/core.c b/src/core.c index 55b6ba82..c30c243d 100644 --- a/src/core.c +++ b/src/core.c @@ -180,15 +180,14 @@ //#define GLFW_EXPOSE_NATIVE_COCOA // WARNING: Fails due to type redefinition #include // Required for: glfwGetCocoaWindow() - #endif #endif #if defined(__linux__) - #include // for NAME_MAX and PATH_MAX defines - #define MAX_FILEPATH_LENGTH PATH_MAX // Use Linux define (4096) + #include // for NAME_MAX and PATH_MAX defines + #define MAX_FILEPATH_LENGTH PATH_MAX // Use Linux define (4096) #else - #define MAX_FILEPATH_LENGTH 256 // Use common value + #define MAX_FILEPATH_LENGTH 512 // Use common value #endif #if defined(PLATFORM_ANDROID) @@ -1676,37 +1675,26 @@ const char *GetFileName(const char *filePath) // Get filename string without extension (memory should be freed) const char *GetFileNameWithoutExt(const char *filePath) { - char *result, *lastDot, *lastSep; - - char nameDot = '.'; // Default filename to extension separator character - char pathSep = '/'; // Default filepath separator character - - // Error checks and allocate string - if (filePath == NULL) return NULL; - - // Try to allocate new string, same size as original - // NOTE: By default strlen() does not count the '\0' character - if ((result = (char *)malloc(strlen(filePath) + 1)) == NULL) return NULL; - - strcpy(result, filePath); // Make a copy of the string - - // NOTE: strrchr() returns a pointer to the last occurrence of character - lastDot = strrchr(result, nameDot); - lastSep = (pathSep == 0)? NULL : strrchr(result, pathSep); - - if (lastDot != NULL) // Check if it has an extension separator... + #define MAX_FILENAMEWITHOUTEXT_LENGTH 64 + + static char fileName[MAX_FILENAMEWITHOUTEXT_LENGTH]; + memset(fileName, 0, MAX_FILENAMEWITHOUTEXT_LENGTH); + + strcpy(fileName, GetFileName(filePath)); // Get filename with extension + + int len = strlen(fileName); + + for (int i = 0; (i < len) && (i < MAX_FILENAMEWITHOUTEXT_LENGTH); i++) { - if (lastSep != NULL) // ...and it's before the extenstion separator... + if (fileName[i] == '.') { - if (lastSep < lastDot) - { - *lastDot = '\0'; // ...then remove it - } + // NOTE: We break on first '.' found + fileName[i] = '\0'; + break; } - else *lastDot = '\0'; // Has extension separator with no path separator } - return result; // Return the modified string + return fileName; } // Get directory for a given fileName (with path) -- cgit v1.2.3 From ff1bcfb2faaf6bfca99ed4b2b2816ba0d24d7647 Mon Sep 17 00:00:00 2001 From: Ray Date: Wed, 13 Mar 2019 10:26:33 +0100 Subject: Remove comment --- src/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/core.c') diff --git a/src/core.c b/src/core.c index c30c243d..2018b3b0 100644 --- a/src/core.c +++ b/src/core.c @@ -3439,7 +3439,7 @@ static void WindowDropCallback(GLFWwindow *window, int count, const char **paths for (int i = 0; i < count; i++) { - dropFilesPath[i] = (char *)malloc(sizeof(char)*MAX_FILEPATH_LENGTH); // Max path length using MAX_FILEPATH_LENGTH set to 256 char + dropFilesPath[i] = (char *)malloc(sizeof(char)*MAX_FILEPATH_LENGTH); strcpy(dropFilesPath[i], paths[i]); } -- cgit v1.2.3 From a61d3ad5122e860e21211c8bacd30f560d71f3da Mon Sep 17 00:00:00 2001 From: raysan5 Date: Sat, 16 Mar 2019 13:00:46 +0100 Subject: SetWindowIcon() redesigned Now core does not depend on textures module directly, only through text module. --- src/core.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) (limited to 'src/core.c') diff --git a/src/core.c b/src/core.c index 2018b3b0..aab60f13 100644 --- a/src/core.c +++ b/src/core.c @@ -780,24 +780,23 @@ void ToggleFullscreen(void) } // Set icon for window (only PLATFORM_DESKTOP) +// NOTE: Image must be in RGBA format, 8bit per channel void SetWindowIcon(Image image) { #if defined(PLATFORM_DESKTOP) - Image imicon = ImageCopy(image); - ImageFormat(&imicon, UNCOMPRESSED_R8G8B8A8); - - GLFWimage icon[1] = { 0 }; - - icon[0].width = imicon.width; - icon[0].height = imicon.height; - icon[0].pixels = (unsigned char *)imicon.data; + if (image.format == UNCOMPRESSED_R8G8B8A8) + { + GLFWimage icon[1] = { 0 }; - // NOTE 1: We only support one image icon - // NOTE 2: The specified image data is copied before this function returns - glfwSetWindowIcon(window, 1, icon); + icon[0].width = image.width; + icon[0].height = image.height; + icon[0].pixels = (unsigned char *)image.data; - // TODO: Support multi-image icons --> image.mipmaps - UnloadImage(imicon); + // NOTE 1: We only support one image icon + // NOTE 2: The specified image data is copied before this function returns + glfwSetWindowIcon(window, 1, icon); + } + else TraceLog(LOG_WARNING, "Window icon image must be in R8G8B8A8 pixel format"); #endif } -- cgit v1.2.3 From 7524fdc3e1815245841cbfb0193f4dc234916de0 Mon Sep 17 00:00:00 2001 From: Ray Date: Mon, 25 Mar 2019 12:30:20 +0100 Subject: Review gestures disable flag --- src/core.c | 56 +++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 41 insertions(+), 15 deletions(-) (limited to 'src/core.c') diff --git a/src/core.c b/src/core.c index aab60f13..7e807ed4 100644 --- a/src/core.c +++ b/src/core.c @@ -3684,7 +3684,6 @@ static int32_t AndroidInputCallback(struct android_app *app, AInputEvent *event) ProcessGestureEvent(gestureEvent); } #else - // Support only simple touch position if (flags == AMOTION_EVENT_ACTION_DOWN) { @@ -3788,6 +3787,7 @@ static EM_BOOL EmscriptenTouchCallback(int eventType, const EmscriptenTouchEvent } */ +#if defined(SUPPORT_GESTURES_SYSTEM) GestureEvent gestureEvent; // Register touch actions @@ -3822,6 +3822,17 @@ static EM_BOOL EmscriptenTouchCallback(int eventType, const EmscriptenTouchEvent // Gesture data is sent to gestures system for processing ProcessGestureEvent(gestureEvent); +#else + // Support only simple touch position + if (eventType == EMSCRIPTEN_EVENT_TOUCHSTART) + { + // Get first touch position + touchPosition[0] = (Vector2){ touchEvent->touches[0].targetX, touchEvent->touches[0].targetY }; + + touchPosition[0].x /= (float)GetScreenWidth(); + touchPosition[0].y /= (float)GetScreenHeight(); + } +#endif return 1; } @@ -4242,9 +4253,10 @@ static void EventThreadSpawn(char *device) static void *EventThread(void *arg) { struct input_event event; - GestureEvent gestureEvent; InputEventWorker *worker = (InputEventWorker *)arg; - bool GestureNeedsUpdate = false; + + int touchAction = -1; + bool gestureUpdate = false; while (!windowShouldClose) { @@ -4257,16 +4269,18 @@ static void *EventThread(void *arg) { mousePosition.x += event.value; touchPosition[0].x = mousePosition.x; - gestureEvent.touchAction = TOUCH_MOVE; - GestureNeedsUpdate = true; + + touchAction = TOUCH_MOVE; + gestureUpdate = true; } if (event.code == REL_Y) { mousePosition.y += event.value; touchPosition[0].y = mousePosition.y; - gestureEvent.touchAction = TOUCH_MOVE; - GestureNeedsUpdate = true; + + touchAction = TOUCH_MOVE; + gestureUpdate = true; } if (event.code == REL_WHEEL) @@ -4282,15 +4296,17 @@ static void *EventThread(void *arg) if (event.code == ABS_X) { mousePosition.x = (event.value - worker->absRange.x)*screenWidth/worker->absRange.width; // Scale acording to absRange - gestureEvent.touchAction = TOUCH_MOVE; - GestureNeedsUpdate = true; + + touchAction = TOUCH_MOVE; + gestureUpdate = true; } if (event.code == ABS_Y) { mousePosition.y = (event.value - worker->absRange.y)*screenHeight/worker->absRange.height; // Scale acording to absRange - gestureEvent.touchAction = TOUCH_MOVE; - GestureNeedsUpdate = true; + + touchAction = TOUCH_MOVE; + gestureUpdate = true; } // Multitouch movement @@ -4328,9 +4344,10 @@ static void *EventThread(void *arg) if ((event.code == BTN_TOUCH) || (event.code == BTN_LEFT)) { currentMouseStateEvdev[MOUSE_LEFT_BUTTON] = event.value; - if (event.value > 0) gestureEvent.touchAction = TOUCH_DOWN; - else gestureEvent.touchAction = TOUCH_UP; - GestureNeedsUpdate = true; + + if (event.value > 0) touchAction = TOUCH_DOWN; + else touchAction = TOUCH_UP; + gestureUpdate = true; } if (event.code == BTN_RIGHT) currentMouseStateEvdev[MOUSE_RIGHT_BUTTON] = event.value; @@ -4346,22 +4363,31 @@ static void *EventThread(void *arg) if (mousePosition.y > screenHeight/mouseScale.y) mousePosition.y = screenHeight/mouseScale.y; // Gesture update - if (GestureNeedsUpdate) + if (gestureUpdate) { +#if defined(SUPPORT_GESTURES_SYSTEM) + GestureEvent gestureEvent = { 0 }; + gestureEvent.pointCount = 0; + gestureEvent.touchAction = touchAction; + if (touchPosition[0].x >= 0) gestureEvent.pointCount++; if (touchPosition[1].x >= 0) gestureEvent.pointCount++; if (touchPosition[2].x >= 0) gestureEvent.pointCount++; if (touchPosition[3].x >= 0) gestureEvent.pointCount++; + gestureEvent.pointerId[0] = 0; gestureEvent.pointerId[1] = 1; gestureEvent.pointerId[2] = 2; gestureEvent.pointerId[3] = 3; + gestureEvent.position[0] = touchPosition[0]; gestureEvent.position[1] = touchPosition[1]; gestureEvent.position[2] = touchPosition[2]; gestureEvent.position[3] = touchPosition[3]; + ProcessGestureEvent(gestureEvent); +#endif } } else -- cgit v1.2.3 From b1e914bbf317cad17eeb3b161dc04c0a7ec78d0d Mon Sep 17 00:00:00 2001 From: Berni8k Date: Thu, 28 Mar 2019 19:46:39 +0100 Subject: RaspberryPi Keyboard input with evdev Based on pull request from user "DarkElvenAngel", better integrated with the current event system and enhanced with buffer to help with fast typing at low framerates. --- src/core.c | 85 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 77 insertions(+), 8 deletions(-) (limited to 'src/core.c') diff --git a/src/core.c b/src/core.c index 7e807ed4..d70d0827 100644 --- a/src/core.c +++ b/src/core.c @@ -361,6 +361,15 @@ typedef struct { static InputEventWorker eventWorkers[10]; // List of worker threads for every monitored "/dev/input/event" +typedef struct{ + int Contents[8]; + char Head; + char Tail; +} KeyEventFifo; + +static KeyEventFifo lastKeyPressedEvdev; // Buffer for holding keydown events as they arrive (Needed due to multitreading of event workers) +static char currentKeyStateEvdev[512] = { 0 }; // Registers current frame key state from event based driver (Needs to be seperate because the legacy console based method clears keys on every frame) + #endif #if defined(PLATFORM_WEB) static bool toggleCursorLock = false; // Ask for cursor pointer lock on next click @@ -470,7 +479,7 @@ static EM_BOOL EmscriptenGamepadCallback(int eventType, const EmscriptenGamepadE static void InitKeyboard(void); // Init raw keyboard system (standard input reading) static void ProcessKeyboard(void); // Process keyboard events static void RestoreKeyboard(void); // Restore keyboard system -static void InitMouse(void); // Mouse initialization (including mouse thread) +static void InitEvdevInput(void); // Mouse initialization (including mouse thread) static void EventThreadSpawn(char *device); // Identifies a input device and spawns a thread to handle it if needed static void *EventThread(void *arg); // Input device events reading thread static void InitGamepad(void); // Init raw gamepad input @@ -590,7 +599,7 @@ void InitWindow(int width, int height, const char *title) #if defined(PLATFORM_RPI) // Init raw input system - InitMouse(); // Mouse init + InitEvdevInput(); // Mouse init InitKeyboard(); // Keyboard init InitGamepad(); // Gamepad init #endif @@ -3054,8 +3063,16 @@ static void PollInputEvents(void) #endif #if defined(PLATFORM_RPI) + // Register previous keys states - for (int i = 0; i < 512; i++) previousKeyState[i] = currentKeyState[i]; + for (int i = 0; i < 512; i++)previousKeyState[i] = currentKeyState[i]; + + // Grab a keypress from the evdev fifo if avalable + if(lastKeyPressedEvdev.Head != lastKeyPressedEvdev.Tail) + { + lastKeyPressed = lastKeyPressedEvdev.Contents[lastKeyPressedEvdev.Tail]; // Read the key from the buffer + lastKeyPressedEvdev.Tail = (lastKeyPressedEvdev.Tail + 1) & 0x07; // Increment the tail pointer forwards and binary wraparound after 7 (fifo is 8 elements long) + } // Register previous mouse states previousMouseWheelY = currentMouseWheelY; @@ -3211,10 +3228,10 @@ static void PollInputEvents(void) #endif #if defined(PLATFORM_RPI) - // NOTE: Mouse input events polling is done asynchonously in another pthread - MouseThread() + // NOTE: Mouse input events polling is done asynchonously in another pthread - EventThread() // NOTE: Keyboard reading could be done using input_event(s) reading or just read from stdin, - // we use method 2 (stdin) but maybe in a future we should change to method 1... + // we now use both methods inside here. 2nd method is still used for legacy purposes (Allows for input trough SSH console) ProcessKeyboard(); // NOTE: Gamepad (Joystick) input events polling is done asynchonously in another pthread - GamepadThread() @@ -3921,6 +3938,9 @@ static void ProcessKeyboard(void) // Reset pressed keys array (it will be filled below) for (int i = 0; i < 512; i++) currentKeyState[i] = 0; + // Check keys from event input workers (This is the new keyboard reading method) + for (int i = 0; i < 512; i++)currentKeyState[i] = currentKeyStateEvdev[i]; + // Fill all read bytes (looking for keys) for (int i = 0; i < bufferByteCount; i++) { @@ -4021,8 +4041,8 @@ static void RestoreKeyboard(void) ioctl(STDIN_FILENO, KDSKBMODE, defaultKeyboardMode); } -// Mouse initialization (including mouse thread) -static void InitMouse(void) +// Initialise user input from evdev(/dev/input/event) this means mouse, keyboard or gamepad devices +static void InitEvdevInput(void) { char path[MAX_FILEPATH_LENGTH]; DIR *directory; @@ -4034,6 +4054,11 @@ static void InitMouse(void) touchPosition[i].x = -1; touchPosition[i].y = -1; } + // Reset keypress buffer + lastKeyPressedEvdev.Head = 0; + lastKeyPressedEvdev.Tail = 0; + // Reset keyboard key state + for (int i = 0; i < 512; i++) currentKeyStateEvdev[i] = 0; // Open the linux directory of "/dev/input" directory = opendir(DEFAULT_EVDEV_PATH); @@ -4202,7 +4227,7 @@ static void EventThreadSpawn(char *device) // Decide what to do with the device //------------------------------------------------------------------------------------------------------- - if (worker->isTouch || worker->isMouse) + if (worker->isTouch || worker->isMouse || worker->isKeyboard) { // Looks like a interesting device TraceLog(LOG_INFO, "Opening input device [%s] (%s%s%s%s%s)", device, @@ -4252,14 +4277,35 @@ static void EventThreadSpawn(char *device) // Input device events reading thread static void *EventThread(void *arg) { + // Scancode to keycode mapping for US keyboards + // TODO: Proabobly replace this with a keymap from the X11 to get the correct regional map for the keyboard (Currently non US keyboards will have the wrong mapping for some keys) + static const int keymap_US[] = + {0,256,49,50,51,52,53,54,55,56,57,48,45,61,259,258,81,87,69,82,84, + 89,85,73,79,80,91,93,257,341,65,83,68,70,71,72,74,75,76,59,39,96, + 340,92,90,88,67,86,66,78,77,44,46,47,344,332,342,32,280,290,291, + 292,293,294,295,296,297,298,299,282,281,327,328,329,333,324,325, + 326,334,321,322,323,320,330,0,85,86,300,301,89,90,91,92,93,94,95, + 335,345,331,283,346,101,268,265,266,263,262,269,264,267,260,261, + 112,113,114,115,116,117,118,119,120,121,122,123,124,125,347,127, + 128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143, + 144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159, + 160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175, + 176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191, + 192,193,194,0,0,0,0,0,200,201,202,203,204,205,206,207,208,209,210, + 211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226, + 227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242, + 243,244,245,246,247,248,0,0,0,0,0,0,0,}; + struct input_event event; InputEventWorker *worker = (InputEventWorker *)arg; int touchAction = -1; bool gestureUpdate = false; + int keycode; while (!windowShouldClose) { + // Try to read data from the device and only continue if successful if (read(worker->fd, &event, sizeof(event)) == (int)sizeof(event)) { // Relative movement parsing @@ -4341,6 +4387,8 @@ static void *EventThread(void *arg) // Button parsing if (event.type == EV_KEY) { + + // Mouse button parsing if ((event.code == BTN_TOUCH) || (event.code == BTN_LEFT)) { currentMouseStateEvdev[MOUSE_LEFT_BUTTON] = event.value; @@ -4353,6 +4401,27 @@ static void *EventThread(void *arg) if (event.code == BTN_RIGHT) currentMouseStateEvdev[MOUSE_RIGHT_BUTTON] = event.value; if (event.code == BTN_MIDDLE) currentMouseStateEvdev[MOUSE_MIDDLE_BUTTON] = event.value; + + // Keyboard button parsing + if((event.code >= 1) && (event.code <= 255)) //Keyboard keys appear for codes 1 to 255 + { + keycode = keymap_US[event.code & 0xFF]; // The code we get is a scancode so we look up the apropriate keycode + // Make sure we got a valid keycode + if((keycode > 0) && (keycode < sizeof(currentKeyState))) + { + // Store the key information for raylib to later use + currentKeyStateEvdev[keycode] = event.value; + if(event.value > 0) + { + // Add the key int the fifo + lastKeyPressedEvdev.Contents[lastKeyPressedEvdev.Head] = keycode; // Put the data at the front of the fifo snake + lastKeyPressedEvdev.Head = (lastKeyPressedEvdev.Head + 1) & 0x07; // Increment the head pointer forwards and binary wraparound after 7 (fifo is 8 elements long) + // TODO: This fifo is not fully threadsafe with multiple writers, so multiple keyboards hitting a key at the exact same time could miss a key (double write to head before it was incremented) + } + TraceLog(LOG_DEBUG, "KEY%s ScanCode: %4i KeyCode: %4i",event.value == 0 ? "UP":"DOWN", event.code, keycode); + } + } + } // Screen confinement -- cgit v1.2.3 From ea96d0afea630cb5f174a5d433f46f722522fbb3 Mon Sep 17 00:00:00 2001 From: Berni8k Date: Thu, 28 Mar 2019 20:38:13 +0100 Subject: Fixes compile error when SUPPORT_GESTURES_SYSTEM is undefined on RPi --- src/core.c | 40 +++++++++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 15 deletions(-) (limited to 'src/core.c') diff --git a/src/core.c b/src/core.c index d70d0827..7cfa6f8b 100644 --- a/src/core.c +++ b/src/core.c @@ -4315,18 +4315,22 @@ static void *EventThread(void *arg) { mousePosition.x += event.value; touchPosition[0].x = mousePosition.x; - - touchAction = TOUCH_MOVE; - gestureUpdate = true; + + #if defined(SUPPORT_GESTURES_SYSTEM) + touchAction = TOUCH_MOVE; + gestureUpdate = true; + #endif } if (event.code == REL_Y) { mousePosition.y += event.value; touchPosition[0].y = mousePosition.y; - - touchAction = TOUCH_MOVE; - gestureUpdate = true; + + #if defined(SUPPORT_GESTURES_SYSTEM) + touchAction = TOUCH_MOVE; + gestureUpdate = true; + #endif } if (event.code == REL_WHEEL) @@ -4342,17 +4346,21 @@ static void *EventThread(void *arg) if (event.code == ABS_X) { mousePosition.x = (event.value - worker->absRange.x)*screenWidth/worker->absRange.width; // Scale acording to absRange - - touchAction = TOUCH_MOVE; - gestureUpdate = true; + + #if defined(SUPPORT_GESTURES_SYSTEM) + touchAction = TOUCH_MOVE; + gestureUpdate = true; + #endif } if (event.code == ABS_Y) { mousePosition.y = (event.value - worker->absRange.y)*screenHeight/worker->absRange.height; // Scale acording to absRange - - touchAction = TOUCH_MOVE; - gestureUpdate = true; + + #if defined(SUPPORT_GESTURES_SYSTEM) + touchAction = TOUCH_MOVE; + gestureUpdate = true; + #endif } // Multitouch movement @@ -4393,9 +4401,11 @@ static void *EventThread(void *arg) { currentMouseStateEvdev[MOUSE_LEFT_BUTTON] = event.value; - if (event.value > 0) touchAction = TOUCH_DOWN; - else touchAction = TOUCH_UP; - gestureUpdate = true; + #if defined(SUPPORT_GESTURES_SYSTEM) + if (event.value > 0) touchAction = TOUCH_DOWN; + else touchAction = TOUCH_UP; + gestureUpdate = true; + #endif } if (event.code == BTN_RIGHT) currentMouseStateEvdev[MOUSE_RIGHT_BUTTON] = event.value; -- cgit v1.2.3 From 69656cb090a53705c515975c127405af87d4f15d Mon Sep 17 00:00:00 2001 From: Ray Date: Fri, 29 Mar 2019 12:23:02 +0100 Subject: Added comment --- src/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/core.c') diff --git a/src/core.c b/src/core.c index 7cfa6f8b..7f2f7f1c 100644 --- a/src/core.c +++ b/src/core.c @@ -1164,7 +1164,7 @@ void BeginMode2D(Camera2D camera) Matrix matTransform = MatrixMultiply(MatrixMultiply(matOrigin, MatrixMultiply(matScale, matRotation)), matTranslation); - rlMultMatrixf(MatrixToFloat(matTransform)); + rlMultMatrixf(MatrixToFloat(matTransform)); // Apply transformation to modelview } // Ends 2D mode with custom camera -- cgit v1.2.3 From a103086443b3d3a3a94ec52ef19ec9be68a0069c Mon Sep 17 00:00:00 2001 From: Ray Date: Thu, 4 Apr 2019 13:50:52 +0200 Subject: Removed trail spaces --- src/core.c | 32 ++++++++++++------------ src/models.c | 78 +++++++++++++++++++++++++++++----------------------------- src/raudio.c | 4 +-- src/raylib.h | 14 +++++------ src/rlgl.h | 28 ++++++++++----------- src/textures.c | 18 +++++++------- 6 files changed, 87 insertions(+), 87 deletions(-) (limited to 'src/core.c') diff --git a/src/core.c b/src/core.c index 7f2f7f1c..acc87292 100644 --- a/src/core.c +++ b/src/core.c @@ -760,7 +760,7 @@ bool IsWindowResized(void) return windowResized; #else return false; -#endif +#endif } // Check if window is currently hidden @@ -1684,14 +1684,14 @@ const char *GetFileName(const char *filePath) const char *GetFileNameWithoutExt(const char *filePath) { #define MAX_FILENAMEWITHOUTEXT_LENGTH 64 - + static char fileName[MAX_FILENAMEWITHOUTEXT_LENGTH]; memset(fileName, 0, MAX_FILENAMEWITHOUTEXT_LENGTH); - + strcpy(fileName, GetFileName(filePath)); // Get filename with extension - + int len = strlen(fileName); - + for (int i = 0; (i < len) && (i < MAX_FILENAMEWITHOUTEXT_LENGTH); i++) { if (fileName[i] == '.') @@ -3154,7 +3154,7 @@ static void PollInputEvents(void) gamepadAxisCount = axisCount; } } - + windowResized = false; #if defined(SUPPORT_EVENTS_WAITING) @@ -3433,7 +3433,7 @@ static void WindowSizeCallback(GLFWwindow *window, int width, int height) currentHeight = height; // NOTE: Postprocessing texture is not scaled to new size - + windowResized = true; } @@ -4279,7 +4279,7 @@ static void *EventThread(void *arg) { // Scancode to keycode mapping for US keyboards // TODO: Proabobly replace this with a keymap from the X11 to get the correct regional map for the keyboard (Currently non US keyboards will have the wrong mapping for some keys) - static const int keymap_US[] = + static const int keymap_US[] = {0,256,49,50,51,52,53,54,55,56,57,48,45,61,259,258,81,87,69,82,84, 89,85,73,79,80,91,93,257,341,65,83,68,70,71,72,74,75,76,59,39,96, 340,92,90,88,67,86,66,78,77,44,46,47,344,332,342,32,280,290,291, @@ -4298,7 +4298,7 @@ static void *EventThread(void *arg) struct input_event event; InputEventWorker *worker = (InputEventWorker *)arg; - + int touchAction = -1; bool gestureUpdate = false; int keycode; @@ -4400,7 +4400,7 @@ static void *EventThread(void *arg) if ((event.code == BTN_TOUCH) || (event.code == BTN_LEFT)) { currentMouseStateEvdev[MOUSE_LEFT_BUTTON] = event.value; - + #if defined(SUPPORT_GESTURES_SYSTEM) if (event.value > 0) touchAction = TOUCH_DOWN; else touchAction = TOUCH_UP; @@ -4415,9 +4415,9 @@ static void *EventThread(void *arg) // Keyboard button parsing if((event.code >= 1) && (event.code <= 255)) //Keyboard keys appear for codes 1 to 255 { - keycode = keymap_US[event.code & 0xFF]; // The code we get is a scancode so we look up the apropriate keycode + keycode = keymap_US[event.code & 0xFF]; // The code we get is a scancode so we look up the apropriate keycode // Make sure we got a valid keycode - if((keycode > 0) && (keycode < sizeof(currentKeyState))) + if((keycode > 0) && (keycode < sizeof(currentKeyState))) { // Store the key information for raylib to later use currentKeyStateEvdev[keycode] = event.value; @@ -4449,22 +4449,22 @@ static void *EventThread(void *arg) gestureEvent.pointCount = 0; gestureEvent.touchAction = touchAction; - + if (touchPosition[0].x >= 0) gestureEvent.pointCount++; if (touchPosition[1].x >= 0) gestureEvent.pointCount++; if (touchPosition[2].x >= 0) gestureEvent.pointCount++; if (touchPosition[3].x >= 0) gestureEvent.pointCount++; - + gestureEvent.pointerId[0] = 0; gestureEvent.pointerId[1] = 1; gestureEvent.pointerId[2] = 2; gestureEvent.pointerId[3] = 3; - + gestureEvent.position[0] = touchPosition[0]; gestureEvent.position[1] = touchPosition[1]; gestureEvent.position[2] = touchPosition[2]; gestureEvent.position[3] = touchPosition[3]; - + ProcessGestureEvent(gestureEvent); #endif } diff --git a/src/models.c b/src/models.c index 632aca2b..239ab5d8 100644 --- a/src/models.c +++ b/src/models.c @@ -624,19 +624,19 @@ Model LoadModel(const char *fileName) #if defined(SUPPORT_FILEFORMAT_IQM) if (IsFileExtension(fileName, ".iqm")) model = LoadIQM(fileName); #endif - + // Make sure model transform is set to identity matrix! model.transform = MatrixIdentity(); - if (model.meshCount == 0) + if (model.meshCount == 0) { TraceLog(LOG_WARNING, "[%s] No meshes can be loaded, default to cube mesh", fileName); - + model.meshCount = 1; model.meshes = (Mesh *)calloc(model.meshCount, sizeof(Mesh)); model.meshes[0] = GenMeshCube(1.0f, 1.0f, 1.0f); } - else + else { // Upload vertex data to GPU (static mesh) for (int i = 0; i < model.meshCount; i++) rlLoadMesh(&model.meshes[i], false); @@ -645,11 +645,11 @@ Model LoadModel(const char *fileName) if (model.materialCount == 0) { TraceLog(LOG_WARNING, "[%s] No materials can be loaded, default to white material", fileName); - + model.materialCount = 1; model.materials = (Material *)calloc(model.materialCount, sizeof(Material)); model.materials[0] = LoadMaterialDefault(); - + model.meshMaterial = (int *)calloc(model.meshCount, sizeof(int)); } @@ -665,15 +665,15 @@ Model LoadModelFromMesh(Mesh mesh) Model model = { 0 }; model.transform = MatrixIdentity(); - + model.meshCount = 1; model.meshes = (Mesh *)malloc(model.meshCount*sizeof(Mesh)); model.meshes[0] = mesh; - + model.materialCount = 1; model.materials = (Material *)malloc(model.materialCount*sizeof(Material)); model.materials[0] = LoadMaterialDefault(); - + model.meshMaterial = (int *)malloc(model.meshCount*sizeof(int)); model.meshMaterial[0] = 0; // First material index @@ -685,11 +685,11 @@ void UnloadModel(Model model) { for (int i = 0; i < model.meshCount; i++) UnloadMesh(&model.meshes[i]); for (int i = 0; i < model.materialCount; i++) UnloadMaterial(model.materials[i]); - + free(model.meshes); free(model.materials); free(model.meshMaterial); - + // Unload animation data free(model.bones); free(model.bindPose); @@ -1817,11 +1817,11 @@ Material LoadMaterial(const char *fileName) { tinyobj_material_t *materials; unsigned int materialCount = 0; - + int result = tinyobj_parse_mtl_file(&materials, &materialCount, fileName); - + // TODO: Process materials to return - + tinyobj_materials_free(materials, materialCount); } #else @@ -1886,7 +1886,7 @@ void DrawModelEx(Model model, Vector3 position, Vector3 rotationAxis, float rota // Combine model transformation matrix (model.transform) with matrix generated by function parameters (matTransform) model.transform = MatrixMultiply(model.transform, matTransform); - for (int i = 0; i < model.meshCount; i++) + for (int i = 0; i < model.meshCount; i++) { model.materials[model.meshMaterial[i]].maps[MAP_DIFFUSE].color = tint; rlDrawMesh(model.meshes[i], model.materials[model.meshMaterial[i]], model.transform); @@ -2246,7 +2246,7 @@ BoundingBox MeshBoundingBox(Mesh mesh) // Get min and max vertex to construct bounds (AABB) Vector3 minVertex = { 0 }; Vector3 maxVertex = { 0 }; - + printf("Mesh vertex count: %i\n", mesh.vertexCount); if (mesh.vertices != NULL) @@ -2402,20 +2402,20 @@ static Model LoadOBJ(const char *fileName) { unsigned int flags = TINYOBJ_FLAG_TRIANGULATE; int ret = tinyobj_parse_obj(&attrib, &meshes, &meshCount, &materials, &materialCount, data, dataLength, flags); - + if (ret != TINYOBJ_SUCCESS) TraceLog(LOG_WARNING, "[%s] Model data could not be loaded", fileName); else TraceLog(LOG_INFO, "[%s] Model data loaded successfully: %i meshes / %i materials", fileName, meshCount, materialCount); - + // Init model meshes array model.meshCount = meshCount; model.meshes = (Mesh *)malloc(model.meshCount*sizeof(Mesh)); - + // Init model materials array model.materialCount = materialCount; model.materials = (Material *)malloc(model.materialCount*sizeof(Material)); model.meshMaterial = (int *)calloc(model.meshCount, sizeof(int)); - - /* + + /* // Multiple meshes data reference // NOTE: They are provided as a faces offset typedef struct { @@ -2424,7 +2424,7 @@ static Model LoadOBJ(const char *fileName) unsigned int length; } tinyobj_shape_t; */ - + // Init model meshes for (int m = 0; m < 1; m++) { @@ -2435,25 +2435,25 @@ static Model LoadOBJ(const char *fileName) mesh.vertices = (float *)malloc(mesh.vertexCount*3*sizeof(float)); mesh.texcoords = (float *)malloc(mesh.vertexCount*2*sizeof(float)); mesh.normals = (float *)malloc(mesh.vertexCount*3*sizeof(float)); - + int vCount = 0; int vtCount = 0; int vnCount = 0; - + for (int f = 0; f < attrib.num_faces; f++) { // Get indices for the face tinyobj_vertex_index_t idx0 = attrib.faces[3*f + 0]; tinyobj_vertex_index_t idx1 = attrib.faces[3*f + 1]; tinyobj_vertex_index_t idx2 = attrib.faces[3*f + 2]; - + // TraceLog(LOG_DEBUG, "Face %i index: v %i/%i/%i . vt %i/%i/%i . vn %i/%i/%i\n", f, idx0.v_idx, idx1.v_idx, idx2.v_idx, idx0.vt_idx, idx1.vt_idx, idx2.vt_idx, idx0.vn_idx, idx1.vn_idx, idx2.vn_idx); - + // Fill vertices buffer (float) using vertex index of the face for (int v = 0; v < 3; v++) { mesh.vertices[vCount + v] = attrib.vertices[idx0.v_idx*3 + v]; } vCount +=3; for (int v = 0; v < 3; v++) { mesh.vertices[vCount + v] = attrib.vertices[idx1.v_idx*3 + v]; } vCount +=3; for (int v = 0; v < 3; v++) { mesh.vertices[vCount + v] = attrib.vertices[idx2.v_idx*3 + v]; } vCount +=3; - + // Fill texcoords buffer (float) using vertex index of the face // NOTE: Y-coordinate must be flipped upside-down mesh.texcoords[vtCount + 0] = attrib.texcoords[idx0.vt_idx*2 + 0]; @@ -2462,7 +2462,7 @@ static Model LoadOBJ(const char *fileName) mesh.texcoords[vtCount + 1] = 1.0f - attrib.texcoords[idx1.vt_idx*2 + 1]; vtCount += 2; mesh.texcoords[vtCount + 0] = attrib.texcoords[idx2.vt_idx*2 + 0]; mesh.texcoords[vtCount + 1] = 1.0f - attrib.texcoords[idx2.vt_idx*2 + 1]; vtCount += 2; - + // Fill normals buffer (float) using vertex index of the face for (int v = 0; v < 3; v++) { mesh.normals[vnCount + v] = attrib.normals[idx0.vn_idx*3 + v]; } vnCount +=3; for (int v = 0; v < 3; v++) { mesh.normals[vnCount + v] = attrib.normals[idx1.vn_idx*3 + v]; } vnCount +=3; @@ -2481,7 +2481,7 @@ static Model LoadOBJ(const char *fileName) // Init material to default // NOTE: Uses default shader, only MAP_DIFFUSE supported model.materials[m] = LoadMaterialDefault(); - + /* typedef struct { char *name; @@ -2508,19 +2508,19 @@ static Model LoadOBJ(const char *fileName) char *alpha_texname; // map_d } tinyobj_material_t; */ - + model.materials[m].maps[MAP_DIFFUSE].texture = LoadTexture(materials[m].diffuse_texname); //char *diffuse_texname; // map_Kd model.materials[m].maps[MAP_DIFFUSE].color = (Color){ (float)(materials[m].diffuse[0]*255.0f), (float)(materials[m].diffuse[1]*255.0f), (float)(materials[m].diffuse[2]*255.0f), 255 }; //float diffuse[3]; model.materials[m].maps[MAP_DIFFUSE].value = 0.0f; - + model.materials[m].maps[MAP_SPECULAR].texture = LoadTexture(materials[m].specular_texname); //char *specular_texname; // map_Ks model.materials[m].maps[MAP_SPECULAR].color = (Color){ (float)(materials[m].specular[0]*255.0f), (float)(materials[m].specular[1]*255.0f), (float)(materials[m].specular[2]*255.0f), 255 }; //float specular[3]; model.materials[m].maps[MAP_SPECULAR].value = 0.0f; - + model.materials[m].maps[MAP_NORMAL].texture = LoadTexture(materials[m].bump_texname); //char *bump_texname; // map_bump, bump model.materials[m].maps[MAP_NORMAL].color = WHITE; model.materials[m].maps[MAP_NORMAL].value = materials[m].shininess; - + model.materials[m].maps[MAP_EMISSION].color = (Color){ (float)(materials[m].emission[0]*255.0f), (float)(materials[m].emission[1]*255.0f), (float)(materials[m].emission[2]*255.0f), 255 }; //float emission[3]; model.materials[m].maps[MAP_HEIGHT].texture = LoadTexture(materials[m].displacement_texname); //char *displacement_texname; // disp @@ -2579,7 +2579,7 @@ static Model LoadIQM(const char *fileName) } IQMTriangle; // NOTE: Adjacency unused by default - typedef struct IQMAdjacency { + typedef struct IQMAdjacency { unsigned int triangle[3]; } IQMAdjacency; @@ -2677,7 +2677,7 @@ static Model LoadIQM(const char *fileName) model.meshCount = iqm.num_meshes; model.meshes = malloc(sizeof(Mesh)*iqm.num_meshes); - + char name[MESH_NAME_LENGTH]; for (int i = 0; i < iqm.num_meshes; i++) @@ -2685,17 +2685,17 @@ static Model LoadIQM(const char *fileName) fseek(iqmFile,iqm.ofs_text+imesh[i].name,SEEK_SET); fread(name, sizeof(char)*MESH_NAME_LENGTH, 1, iqmFile); // Mesh name not used... model.meshes[i].vertexCount = imesh[i].num_vertexes; - + model.meshes[i].vertices = malloc(sizeof(float)*imesh[i].num_vertexes*3); // Default vertex positions model.meshes[i].normals = malloc(sizeof(float)*imesh[i].num_vertexes*3); // Default vertex normals model.meshes[i].texcoords = malloc(sizeof(float)*imesh[i].num_vertexes*2); // Default vertex texcoords - + model.meshes[i].boneIds = malloc(sizeof(int)*imesh[i].num_vertexes*4); // Up-to 4 bones supported! model.meshes[i].boneWeights = malloc(sizeof(float)*imesh[i].num_vertexes*4); // Up-to 4 bones supported! - + model.meshes[i].triangleCount = imesh[i].num_triangles; model.meshes[i].indices = malloc(sizeof(unsigned short)*imesh[i].num_triangles*3); - + // Animated verted data, what we actually process for rendering // NOTE: Animated vertex should be re-uploaded to GPU (if not using GPU skinning) model.meshes[i].animVertices = malloc(sizeof(float)*imesh[i].num_vertexes*3); diff --git a/src/raudio.c b/src/raudio.c index 1c153009..d360b2d3 100644 --- a/src/raudio.c +++ b/src/raudio.c @@ -525,7 +525,7 @@ void InitAudioDevice(void) TraceLog(LOG_INFO, "Audio channels: %d -> %d", device.playback.channels, device.playback.internalChannels); TraceLog(LOG_INFO, "Audio sample rate: %d -> %d", device.sampleRate, device.playback.internalSampleRate); TraceLog(LOG_INFO, "Audio buffer size: %d", device.playback.internalBufferSizeInFrames); - + isAudioInitialized = MA_TRUE; } @@ -587,7 +587,7 @@ AudioBuffer *CreateAudioBuffer(ma_format format, ma_uint32 channels, ma_uint32 s dspConfig.pUserData = audioBuffer; dspConfig.allowDynamicSampleRate = MA_TRUE; // <-- Required for pitch shifting. ma_result result = ma_pcm_converter_init(&dspConfig, &audioBuffer->dsp); - + if (result != MA_SUCCESS) { TraceLog(LOG_ERROR, "CreateAudioBuffer() : Failed to create data conversion pipeline"); diff --git a/src/raylib.h b/src/raylib.h index 93965038..c365fa47 100644 --- a/src/raylib.h +++ b/src/raylib.h @@ -339,7 +339,7 @@ typedef struct Material { // Transformation properties typedef struct Transform { - Vector3 translation; // Translation + Vector3 translation; // Translation Quaternion rotation; // Rotation Vector3 scale; // Scale } Transform; @@ -353,14 +353,14 @@ typedef struct BoneInfo { // Model type typedef struct Model { Matrix transform; // Local transform matrix - + int meshCount; // Number of meshes Mesh *meshes; // Meshes array int materialCount; // Number of materials Material *materials; // Materials array int *meshMaterial; // Mesh material number - + // Animation data int boneCount; // Number of bones BoneInfo *bones; // Bones information (skeleton) @@ -371,7 +371,7 @@ typedef struct Model { typedef struct ModelAnimation { int boneCount; // Number of bones BoneInfo *bones; // Bones information (skeleton) - + int frameCount; // Number of animation frames Transform **framePoses; // Poses array by frame } ModelAnimation; @@ -1082,8 +1082,8 @@ RLAPI void DrawRectangleGradientH(int posX, int posY, int width, int height, Col RLAPI void DrawRectangleGradientEx(Rectangle rec, Color col1, Color col2, Color col3, Color col4); // Draw a gradient-filled rectangle with custom vertex colors RLAPI void DrawRectangleLines(int posX, int posY, int width, int height, Color color); // Draw rectangle outline RLAPI void DrawRectangleLinesEx(Rectangle rec, int lineThick, Color color); // Draw rectangle outline with extended parameters -RLAPI void DrawRoundedRect(Rectangle rec, float roundness, int segments, Color color); // Draw rectangle with rounded edges -RLAPI void DrawRoundedRectLines(Rectangle rec, float roundness, int segments, int lineThick, Color color); // Draw rounded rectangle outline +RLAPI void DrawRectangleRounded(Rectangle rec, float roundness, int segments, Color color); // Draw rectangle with rounded edges +RLAPI void DrawRectangleRoundedLines(Rectangle rec, float roundness, int segments, int lineThick, Color color); // Draw rectangle with rounded edges outline RLAPI void DrawTriangle(Vector2 v1, Vector2 v2, Vector2 v3, Color color); // Draw a color-filled triangle RLAPI void DrawTriangleLines(Vector2 v1, Vector2 v2, Vector2 v3, Color color); // Draw triangle outline RLAPI void DrawPoly(Vector2 center, int sides, float radius, float rotation, Color color); // Draw a regular polygon (Vector version) @@ -1201,7 +1201,7 @@ RLAPI void DrawFPS(int posX, int posY); RLAPI void DrawText(const char *text, int posX, int posY, int fontSize, Color color); // Draw text (using default font) RLAPI void DrawTextEx(Font font, const char *text, Vector2 position, float fontSize, float spacing, Color tint); // Draw text using font and additional parameters RLAPI void DrawTextRec(Font font, const char *text, Rectangle rec, float fontSize, float spacing, bool wordWrap, Color tint); // Draw text using font inside rectangle limits -RLAPI void DrawTextRecEx(Font font, const char *text, Rectangle rec, float fontSize, float spacing, bool wordWrap, Color tint, +RLAPI void DrawTextRecEx(Font font, const char *text, Rectangle rec, float fontSize, float spacing, bool wordWrap, Color tint, int selectStart, int selectLength, Color selectText, Color selectBack); // Draw text using font inside rectangle limits with support for text selection // Text misc. functions diff --git a/src/rlgl.h b/src/rlgl.h index 8cc4c590..3f305462 100644 --- a/src/rlgl.h +++ b/src/rlgl.h @@ -1130,22 +1130,22 @@ void rlBegin(int mode) // Make sure current draws[i].vertexCount is aligned a multiple of 4, // that way, following QUADS drawing will keep aligned with index processing // It implies adding some extra alignment vertex at the end of the draw, - // those vertex are not processed but they are considered as an additional offset + // those vertex are not processed but they are considered as an additional offset // for the next set of vertex to be drawn if (draws[drawsCounter - 1].mode == RL_LINES) draws[drawsCounter - 1].vertexAlignment = ((draws[drawsCounter - 1].vertexCount < 4)? draws[drawsCounter - 1].vertexCount : draws[drawsCounter - 1].vertexCount%4); else if (draws[drawsCounter - 1].mode == RL_TRIANGLES) draws[drawsCounter - 1].vertexAlignment = ((draws[drawsCounter - 1].vertexCount < 4)? 1 : (4 - (draws[drawsCounter - 1].vertexCount%4))); - + if (rlCheckBufferLimit(draws[drawsCounter - 1].vertexAlignment)) rlglDraw(); else { vertexData[currentBuffer].vCounter += draws[drawsCounter - 1].vertexAlignment; vertexData[currentBuffer].cCounter += draws[drawsCounter - 1].vertexAlignment; vertexData[currentBuffer].tcCounter += draws[drawsCounter - 1].vertexAlignment; - + drawsCounter++; } } - + if (drawsCounter >= MAX_DRAWCALL_REGISTERED) rlglDraw(); draws[drawsCounter - 1].mode = mode; @@ -1301,22 +1301,22 @@ void rlEnableTexture(unsigned int id) // Make sure current draws[i].vertexCount is aligned a multiple of 4, // that way, following QUADS drawing will keep aligned with index processing // It implies adding some extra alignment vertex at the end of the draw, - // those vertex are not processed but they are considered as an additional offset + // those vertex are not processed but they are considered as an additional offset // for the next set of vertex to be drawn if (draws[drawsCounter - 1].mode == RL_LINES) draws[drawsCounter - 1].vertexAlignment = ((draws[drawsCounter - 1].vertexCount < 4)? draws[drawsCounter - 1].vertexCount : draws[drawsCounter - 1].vertexCount%4); else if (draws[drawsCounter - 1].mode == RL_TRIANGLES) draws[drawsCounter - 1].vertexAlignment = ((draws[drawsCounter - 1].vertexCount < 4)? 1 : (4 - (draws[drawsCounter - 1].vertexCount%4))); - + if (rlCheckBufferLimit(draws[drawsCounter - 1].vertexAlignment)) rlglDraw(); else { vertexData[currentBuffer].vCounter += draws[drawsCounter - 1].vertexAlignment; vertexData[currentBuffer].cCounter += draws[drawsCounter - 1].vertexAlignment; vertexData[currentBuffer].tcCounter += draws[drawsCounter - 1].vertexAlignment; - + drawsCounter++; } } - + if (drawsCounter >= MAX_DRAWCALL_REGISTERED) rlglDraw(); draws[drawsCounter - 1].textureId = id; @@ -2044,7 +2044,7 @@ unsigned int rlLoadTexture(void *data, int width, int height, int format, int mi unsigned int rlLoadTextureDepth(int width, int height, int bits, bool useRenderBuffer) { unsigned int id = 0; - + #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) unsigned int glInternalFormat = GL_DEPTH_COMPONENT16; @@ -2103,7 +2103,7 @@ unsigned int rlLoadTextureCubemap(void *data, int size, int format) { unsigned int cubemapId = 0; unsigned int dataSize = GetPixelDataSize(size, size, format); - + #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) glGenTextures(1, &cubemapId); glBindTexture(GL_TEXTURE_CUBE_MAP, cubemapId); @@ -2305,7 +2305,7 @@ void rlRenderTextureAttach(RenderTexture2D target, unsigned int id, int attachTy bool rlRenderTextureComplete(RenderTexture target) { bool result = false; - + #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) glBindFramebuffer(GL_FRAMEBUFFER, target.id); @@ -4196,7 +4196,7 @@ static void DrawBuffersDefault(void) glUniformMatrix4fv(currentShader.locs[LOC_MATRIX_MVP], 1, false, MatrixToFloat(matMVP)); glUniform4f(currentShader.locs[LOC_COLOR_DIFFUSE], 1.0f, 1.0f, 1.0f, 1.0f); glUniform1i(currentShader.locs[LOC_MAP_DIFFUSE], 0); // Provided value refers to the texture unit (active) - + // TODO: Support additional texture units on custom shader //if (currentShader->locs[LOC_MAP_SPECULAR] > 0) glUniform1i(currentShader.locs[LOC_MAP_SPECULAR], 1); //if (currentShader->locs[LOC_MAP_NORMAL] > 0) glUniform1i(currentShader.locs[LOC_MAP_NORMAL], 2); @@ -4231,7 +4231,7 @@ static void DrawBuffersDefault(void) for (int i = 0; i < drawsCounter; i++) { glBindTexture(GL_TEXTURE_2D, draws[i].textureId); - + // TODO: Find some way to bind additional textures --> Use global texture IDs? Register them on draw[i]? //if (currentShader->locs[LOC_MAP_SPECULAR] > 0) { glActiveTexture(GL_TEXTURE1); glBindTexture(GL_TEXTURE_2D, textureUnit1_id); } //if (currentShader->locs[LOC_MAP_SPECULAR] > 0) { glActiveTexture(GL_TEXTURE2); glBindTexture(GL_TEXTURE_2D, textureUnit2_id); } @@ -4248,7 +4248,7 @@ static void DrawBuffersDefault(void) glDrawElements(GL_TRIANGLES, draws[i].vertexCount/4*6, GL_UNSIGNED_SHORT, (GLvoid *)(sizeof(GLushort)*vertexOffset/4*6)); #endif } - + vertexOffset += (draws[i].vertexCount + draws[i].vertexAlignment); } diff --git a/src/textures.c b/src/textures.c index 38995f11..cd0bd208 100644 --- a/src/textures.c +++ b/src/textures.c @@ -181,7 +181,7 @@ static Image LoadASTC(const char *fileName); // Load ASTC file Image LoadImage(const char *fileName) { Image image = { 0 }; - + #if defined(SUPPORT_FILEFORMAT_PNG) || \ defined(SUPPORT_FILEFORMAT_BMP) || \ defined(SUPPORT_FILEFORMAT_TGA) || \ @@ -744,7 +744,7 @@ Image GetTextureData(Texture2D texture) RLAPI Image GetScreenData(void) { Image image = { 0 }; - + image.width = GetScreenWidth(); image.height = GetScreenHeight(); image.mipmaps = 1; @@ -1411,13 +1411,13 @@ void ImageResizeNN(Image *image,int newWidth,int newHeight) void ImageResizeCanvas(Image *image, int newWidth,int newHeight, int offsetX, int offsetY, Color color) { // TODO: Review different scaling situations - + if ((newWidth != image->width) || (newHeight != image->height)) { if ((newWidth > image->width) && (newHeight > image->height)) { Image imTemp = GenImageColor(newWidth, newHeight, color); - + Rectangle srcRec = { 0.0f, 0.0f, (float)image->width, (float)image->height }; Rectangle dstRec = { (float)offsetX, (float)offsetY, (float)srcRec.width, (float)srcRec.height }; @@ -1434,23 +1434,23 @@ void ImageResizeCanvas(Image *image, int newWidth,int newHeight, int offsetX, in else // One side is bigger and the other is smaller { Image imTemp = GenImageColor(newWidth, newHeight, color); - + Rectangle srcRec = { 0.0f, 0.0f, (float)image->width, (float)image->height }; Rectangle dstRec = { (float)offsetX, (float)offsetY, (float)newWidth, (float)newHeight }; - + if (newWidth < image->width) { srcRec.x = offsetX; srcRec.width = newWidth; - + dstRec.x = 0.0f; } - + if (newHeight < image->height) { srcRec.y = offsetY; srcRec.height = newHeight; - + dstRec.y = 0.0f; } -- cgit v1.2.3 From 28b9de661d49911f7c5b7996576c7faeea0684d5 Mon Sep 17 00:00:00 2001 From: Ray Date: Fri, 5 Apr 2019 13:12:54 +0200 Subject: Minor tweaks --- src/core.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) (limited to 'src/core.c') diff --git a/src/core.c b/src/core.c index acc87292..b0c0658d 100644 --- a/src/core.c +++ b/src/core.c @@ -3191,7 +3191,7 @@ static void PollInputEvents(void) } else currentGamepadState[i][j] = 0; - //printf("Gamepad %d, button %d: Digital: %d, Analog: %g\n", gamepadState.index, j, gamepadState.digitalButton[j], gamepadState.analogButton[j]); + //TraceLog(LOG_DEBUG, "Gamepad %d, button %d: Digital: %d, Analog: %g", gamepadState.index, j, gamepadState.digitalButton[j], gamepadState.analogButton[j]); } // Register axis data for every connected gamepad @@ -3792,14 +3792,14 @@ static EM_BOOL EmscriptenTouchCallback(int eventType, const EmscriptenTouchEvent y = touchEvent->touches[i].canvasY; } - printf("%s, numTouches: %d %s%s%s%s\n", emscripten_event_type_to_string(eventType), event->numTouches, + TraceLog(LOG_DEBUG, "%s, numTouches: %d %s%s%s%s", emscripten_event_type_to_string(eventType), event->numTouches, event->ctrlKey? " CTRL" : "", event->shiftKey? " SHIFT" : "", event->altKey? " ALT" : "", event->metaKey? " META" : ""); for (int i = 0; i < event->numTouches; ++i) { const EmscriptenTouchPoint *t = &event->touches[i]; - printf(" %ld: screen: (%ld,%ld), client: (%ld,%ld), page: (%ld,%ld), isChanged: %d, onTarget: %d, canvas: (%ld, %ld)\n", + TraceLog(LOG_DEBUG, " %ld: screen: (%ld,%ld), client: (%ld,%ld), page: (%ld,%ld), isChanged: %d, onTarget: %d, canvas: (%ld, %ld)", t->identifier, t->screenX, t->screenY, t->clientX, t->clientY, t->pageX, t->pageY, t->isChanged, t->onTarget, t->canvasX, t->canvasY); } */ @@ -3858,12 +3858,12 @@ static EM_BOOL EmscriptenTouchCallback(int eventType, const EmscriptenTouchEvent static EM_BOOL EmscriptenGamepadCallback(int eventType, const EmscriptenGamepadEvent *gamepadEvent, void *userData) { /* - printf("%s: timeStamp: %g, connected: %d, index: %ld, numAxes: %d, numButtons: %d, id: \"%s\", mapping: \"%s\"\n", + TraceLog(LOG_DEBUG, "%s: timeStamp: %g, connected: %d, index: %ld, numAxes: %d, numButtons: %d, id: \"%s\", mapping: \"%s\"", eventType != 0? emscripten_event_type_to_string(eventType) : "Gamepad state", gamepadEvent->timestamp, gamepadEvent->connected, gamepadEvent->index, gamepadEvent->numAxes, gamepadEvent->numButtons, gamepadEvent->id, gamepadEvent->mapping); - for(int i = 0; i < gamepadEvent->numAxes; ++i) printf("Axis %d: %g\n", i, gamepadEvent->axis[i]); - for(int i = 0; i < gamepadEvent->numButtons; ++i) printf("Button %d: Digital: %d, Analog: %g\n", i, gamepadEvent->digitalButton[i], gamepadEvent->analogButton[i]); + for(int i = 0; i < gamepadEvent->numAxes; ++i) TraceLog(LOG_DEBUG, "Axis %d: %g", i, gamepadEvent->axis[i]); + for(int i = 0; i < gamepadEvent->numButtons; ++i) TraceLog(LOG_DEBUG, "Button %d: Digital: %d, Analog: %g", i, gamepadEvent->digitalButton[i], gamepadEvent->analogButton[i]); */ if ((gamepadEvent->connected) && (gamepadEvent->index < MAX_GAMEPADS)) gamepadReady[gamepadEvent->index] = true; @@ -3939,17 +3939,13 @@ static void ProcessKeyboard(void) for (int i = 0; i < 512; i++) currentKeyState[i] = 0; // Check keys from event input workers (This is the new keyboard reading method) - for (int i = 0; i < 512; i++)currentKeyState[i] = currentKeyStateEvdev[i]; + for (int i = 0; i < 512; i++) currentKeyState[i] = currentKeyStateEvdev[i]; // Fill all read bytes (looking for keys) for (int i = 0; i < bufferByteCount; i++) { TraceLog(LOG_DEBUG, "Bytes on keysBuffer: %i", bufferByteCount); - //printf("Key(s) bytes: "); - //for (int i = 0; i < bufferByteCount; i++) printf("0x%02x ", keysBuffer[i]); - //printf("\n"); - // NOTE: If (key == 0x1b), depending on next key, it could be a special keymap code! // Up -> 1b 5b 41 / Left -> 1b 5b 44 / Right -> 1b 5b 43 / Down -> 1b 5b 42 if (keysBuffer[i] == 0x1b) -- cgit v1.2.3 From f21761fbbb02f0b58b5b54342f0c3ad3abc0003e Mon Sep 17 00:00:00 2001 From: ChillerDragon Date: Sun, 7 Apr 2019 17:49:12 +0200 Subject: Happy new year 2019 --- examples/Makefile | 2 +- examples/audio/audio_raw_stream.c | 2 +- examples/models/models_obj_viewer.c | 2 +- examples/others/rlgl_standalone.c | 2 +- games/Makefile | 2 +- games/cat_vs_roomba/Makefile | 2 +- games/cat_vs_roomba/roomba.c | 2 +- games/cat_vs_roomba/screens/screen_ending.c | 2 +- games/cat_vs_roomba/screens/screen_gameplay.c | 2 +- games/cat_vs_roomba/screens/screen_logo.c | 2 +- games/cat_vs_roomba/screens/screen_title.c | 2 +- games/cat_vs_roomba/screens/screens.h | 2 +- games/drturtle/Makefile | 2 +- games/just_do/Makefile | 2 +- games/koala_seasons/Makefile | 2 +- games/light_my_ritual/Makefile | 2 +- games/skully_escape/Makefile | 2 +- games/transmission/Makefile | 2 +- games/transmission/screens/screen_ending.c | 2 +- games/transmission/screens/screen_gameplay.c | 2 +- games/transmission/screens/screen_logo.c | 2 +- games/transmission/screens/screen_mission.c | 2 +- games/transmission/screens/screen_title.c | 2 +- games/transmission/screens/screens.h | 2 +- games/transmission/transmission.c | 2 +- games/wave_collector/Makefile | 2 +- projects/VSCode/Makefile | 2 +- src/Makefile | 2 +- src/core.c | 2 +- src/gestures.h | 2 +- src/models.c | 2 +- src/raylib.h | 2 +- src/rglfw.c | 2 +- src/rlgl.h | 2 +- src/shapes.c | 2 +- src/text.c | 2 +- src/textures.c | 2 +- src/utils.c | 2 +- src/utils.h | 2 +- templates/advance_game/Makefile | 2 +- templates/advance_game/advance_game.c | 2 +- templates/advance_game/screens/screen_ending.c | 2 +- templates/advance_game/screens/screen_gameplay.c | 2 +- templates/advance_game/screens/screen_logo.c | 2 +- templates/advance_game/screens/screen_options.c | 2 +- templates/advance_game/screens/screen_title.c | 2 +- templates/advance_game/screens/screens.h | 2 +- templates/simple_game/Makefile | 2 +- templates/simple_game/simple_game.c | 2 +- templates/standard_game/Makefile | 2 +- templates/standard_game/screens/screen_ending.c | 2 +- templates/standard_game/screens/screen_gameplay.c | 2 +- templates/standard_game/screens/screen_logo.c | 2 +- templates/standard_game/screens/screen_options.c | 2 +- templates/standard_game/screens/screen_title.c | 2 +- templates/standard_game/screens/screens.h | 2 +- templates/standard_game/standard_game.c | 2 +- 57 files changed, 57 insertions(+), 57 deletions(-) (limited to 'src/core.c') diff --git a/examples/Makefile b/examples/Makefile index e14762b3..b35e39f9 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -2,7 +2,7 @@ # # raylib makefile for Desktop platforms, Raspberry Pi, Android and HTML5 # -# Copyright (c) 2013-2018 Ramon Santamaria (@raysan5) +# Copyright (c) 2013-2019 Ramon Santamaria (@raysan5) # # This software is provided "as-is", without any express or implied warranty. In no event # will the authors be held liable for any damages arising from the use of this software. diff --git a/examples/audio/audio_raw_stream.c b/examples/audio/audio_raw_stream.c index 7eee46f6..d7fa5d79 100644 --- a/examples/audio/audio_raw_stream.c +++ b/examples/audio/audio_raw_stream.c @@ -7,7 +7,7 @@ * This example has been created using raylib 1.6 (www.raylib.com) * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) * -* Copyright (c) 2015-2018 Ramon Santamaria (@raysan5) and James Hofmann (@triplefox) +* Copyright (c) 2015-2019 Ramon Santamaria (@raysan5) and James Hofmann (@triplefox) * ********************************************************************************************/ diff --git a/examples/models/models_obj_viewer.c b/examples/models/models_obj_viewer.c index 0581df34..7d387441 100644 --- a/examples/models/models_obj_viewer.c +++ b/examples/models/models_obj_viewer.c @@ -5,7 +5,7 @@ * This example has been created using raylib 2.0 (www.raylib.com) * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) * -* Copyright (c) 2014-2018 Ramon Santamaria (@raysan5) +* Copyright (c) 2014-2019 Ramon Santamaria (@raysan5) * ********************************************************************************************/ diff --git a/examples/others/rlgl_standalone.c b/examples/others/rlgl_standalone.c index 4b262bbd..42aec2e2 100644 --- a/examples/others/rlgl_standalone.c +++ b/examples/others/rlgl_standalone.c @@ -24,7 +24,7 @@ * This example is licensed under an unmodified zlib/libpng license, which is an OSI-certified, * BSD-like license that allows static linking with closed source software: * -* Copyright (c) 2014-2018 Ramon Santamaria (@raysan5) +* Copyright (c) 2014-2019 Ramon Santamaria (@raysan5) * * This software is provided "as-is", without any express or implied warranty. In no event * will the authors be held liable for any damages arising from the use of this software. diff --git a/games/Makefile b/games/Makefile index 5d60f15d..44e053c6 100644 --- a/games/Makefile +++ b/games/Makefile @@ -2,7 +2,7 @@ # # raylib makefile for Desktop platforms, Raspberry Pi, Android and HTML5 # -# Copyright (c) 2013-2018 Ramon Santamaria (@raysan5) +# Copyright (c) 2013-2019 Ramon Santamaria (@raysan5) # # This software is provided "as-is", without any express or implied warranty. In no event # will the authors be held liable for any damages arising from the use of this software. diff --git a/games/cat_vs_roomba/Makefile b/games/cat_vs_roomba/Makefile index 6662a6be..b1304656 100644 --- a/games/cat_vs_roomba/Makefile +++ b/games/cat_vs_roomba/Makefile @@ -2,7 +2,7 @@ # # raylib makefile for Desktop platforms, Raspberry Pi, Android and HTML5 # -# Copyright (c) 2013-2018 Ramon Santamaria (@raysan5) +# Copyright (c) 2013-2019 Ramon Santamaria (@raysan5) # # This software is provided "as-is", without any express or implied warranty. In no event # will the authors be held liable for any damages arising from the use of this software. diff --git a/games/cat_vs_roomba/roomba.c b/games/cat_vs_roomba/roomba.c index 0d236775..eeee7a71 100644 --- a/games/cat_vs_roomba/roomba.c +++ b/games/cat_vs_roomba/roomba.c @@ -8,7 +8,7 @@ * This game has been created using raylib (www.raylib.com) * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) * -* Copyright (c) 2014-2018 Ramon Santamaria (@raysan5) +* Copyright (c) 2014-2019 Ramon Santamaria (@raysan5) * ********************************************************************************************/ diff --git a/games/cat_vs_roomba/screens/screen_ending.c b/games/cat_vs_roomba/screens/screen_ending.c index ef2a5f74..466d9b91 100644 --- a/games/cat_vs_roomba/screens/screen_ending.c +++ b/games/cat_vs_roomba/screens/screen_ending.c @@ -4,7 +4,7 @@ * * Ending Screen Functions Definitions (Init, Update, Draw, Unload) * -* Copyright (c) 2014-2018 Ramon Santamaria (@raysan5) +* Copyright (c) 2014-2019 Ramon Santamaria (@raysan5) * * This software is provided "as-is", without any express or implied warranty. In no event * will the authors be held liable for any damages arising from the use of this software. diff --git a/games/cat_vs_roomba/screens/screen_gameplay.c b/games/cat_vs_roomba/screens/screen_gameplay.c index 49a0bb6b..4dd13856 100644 --- a/games/cat_vs_roomba/screens/screen_gameplay.c +++ b/games/cat_vs_roomba/screens/screen_gameplay.c @@ -4,7 +4,7 @@ * * Gameplay Screen Functions Definitions (Init, Update, Draw, Unload) * -* Copyright (c) 2014-2018 Ramon Santamaria (@raysan5) +* Copyright (c) 2014-2019 Ramon Santamaria (@raysan5) * * This software is provided "as-is", without any express or implied warranty. In no event * will the authors be held liable for any damages arising from the use of this software. diff --git a/games/cat_vs_roomba/screens/screen_logo.c b/games/cat_vs_roomba/screens/screen_logo.c index 9fc704c7..a697013e 100644 --- a/games/cat_vs_roomba/screens/screen_logo.c +++ b/games/cat_vs_roomba/screens/screen_logo.c @@ -4,7 +4,7 @@ * * Logo Screen Functions Definitions (Init, Update, Draw, Unload) * -* Copyright (c) 2014-2018 Ramon Santamaria (@raysan5) +* Copyright (c) 2014-2019 Ramon Santamaria (@raysan5) * * This software is provided "as-is", without any express or implied warranty. In no event * will the authors be held liable for any damages arising from the use of this software. diff --git a/games/cat_vs_roomba/screens/screen_title.c b/games/cat_vs_roomba/screens/screen_title.c index 009fbd0a..6acadce5 100644 --- a/games/cat_vs_roomba/screens/screen_title.c +++ b/games/cat_vs_roomba/screens/screen_title.c @@ -4,7 +4,7 @@ * * Title Screen Functions Definitions (Init, Update, Draw, Unload) * -* Copyright (c) 2014-2018 Ramon Santamaria (@raysan5) +* Copyright (c) 2014-2019 Ramon Santamaria (@raysan5) * * This software is provided "as-is", without any express or implied warranty. In no event * will the authors be held liable for any damages arising from the use of this software. diff --git a/games/cat_vs_roomba/screens/screens.h b/games/cat_vs_roomba/screens/screens.h index 9cc07eab..0ad4f9af 100644 --- a/games/cat_vs_roomba/screens/screens.h +++ b/games/cat_vs_roomba/screens/screens.h @@ -4,7 +4,7 @@ * * Screens Functions Declarations (Init, Update, Draw, Unload) * -* Copyright (c) 2014-2018 Ramon Santamaria (@raysan5) +* Copyright (c) 2014-2019 Ramon Santamaria (@raysan5) * * This software is provided "as-is", without any express or implied warranty. In no event * will the authors be held liable for any damages arising from the use of this software. diff --git a/games/drturtle/Makefile b/games/drturtle/Makefile index 8f1934b5..4cd5033e 100644 --- a/games/drturtle/Makefile +++ b/games/drturtle/Makefile @@ -2,7 +2,7 @@ # # raylib makefile for Desktop platforms, Raspberry Pi, Android and HTML5 # -# Copyright (c) 2013-2018 Ramon Santamaria (@raysan5) +# Copyright (c) 2013-2019 Ramon Santamaria (@raysan5) # # This software is provided "as-is", without any express or implied warranty. In no event # will the authors be held liable for any damages arising from the use of this software. diff --git a/games/just_do/Makefile b/games/just_do/Makefile index b6c935f6..af9b31c1 100644 --- a/games/just_do/Makefile +++ b/games/just_do/Makefile @@ -2,7 +2,7 @@ # # raylib makefile for Desktop platforms, Raspberry Pi, Android and HTML5 # -# Copyright (c) 2013-2018 Ramon Santamaria (@raysan5) +# Copyright (c) 2013-2019 Ramon Santamaria (@raysan5) # # This software is provided "as-is", without any express or implied warranty. In no event # will the authors be held liable for any damages arising from the use of this software. diff --git a/games/koala_seasons/Makefile b/games/koala_seasons/Makefile index 8482bf2d..25dbe696 100644 --- a/games/koala_seasons/Makefile +++ b/games/koala_seasons/Makefile @@ -2,7 +2,7 @@ # # raylib makefile for Desktop platforms, Raspberry Pi, Android and HTML5 # -# Copyright (c) 2013-2018 Ramon Santamaria (@raysan5) +# Copyright (c) 2013-2019 Ramon Santamaria (@raysan5) # # This software is provided "as-is", without any express or implied warranty. In no event # will the authors be held liable for any damages arising from the use of this software. diff --git a/games/light_my_ritual/Makefile b/games/light_my_ritual/Makefile index fbc34aac..3291bb3e 100644 --- a/games/light_my_ritual/Makefile +++ b/games/light_my_ritual/Makefile @@ -2,7 +2,7 @@ # # raylib makefile for Desktop platforms, Raspberry Pi, Android and HTML5 # -# Copyright (c) 2013-2018 Ramon Santamaria (@raysan5) +# Copyright (c) 2013-2019 Ramon Santamaria (@raysan5) # # This software is provided "as-is", without any express or implied warranty. In no event # will the authors be held liable for any damages arising from the use of this software. diff --git a/games/skully_escape/Makefile b/games/skully_escape/Makefile index 8875ad52..4673a549 100644 --- a/games/skully_escape/Makefile +++ b/games/skully_escape/Makefile @@ -2,7 +2,7 @@ # # raylib makefile for Desktop platforms, Raspberry Pi, Android and HTML5 # -# Copyright (c) 2013-2018 Ramon Santamaria (@raysan5) +# Copyright (c) 2013-2019 Ramon Santamaria (@raysan5) # # This software is provided "as-is", without any express or implied warranty. In no event # will the authors be held liable for any damages arising from the use of this software. diff --git a/games/transmission/Makefile b/games/transmission/Makefile index a1b7e764..f62fe080 100644 --- a/games/transmission/Makefile +++ b/games/transmission/Makefile @@ -2,7 +2,7 @@ # # raylib makefile for Desktop platforms, Raspberry Pi, Android and HTML5 # -# Copyright (c) 2013-2018 Ramon Santamaria (@raysan5) +# Copyright (c) 2013-2019 Ramon Santamaria (@raysan5) # # This software is provided "as-is", without any express or implied warranty. In no event # will the authors be held liable for any damages arising from the use of this software. diff --git a/games/transmission/screens/screen_ending.c b/games/transmission/screens/screen_ending.c index bb355b8b..0492a0cc 100644 --- a/games/transmission/screens/screen_ending.c +++ b/games/transmission/screens/screen_ending.c @@ -4,7 +4,7 @@ * * Ending Screen Functions Definitions (Init, Update, Draw, Unload) * -* Copyright (c) 2014-2018 Ramon Santamaria (@raysan5) +* Copyright (c) 2014-2019 Ramon Santamaria (@raysan5) * * This software is provided "as-is", without any express or implied warranty. In no event * will the authors be held liable for any damages arising from the use of this software. diff --git a/games/transmission/screens/screen_gameplay.c b/games/transmission/screens/screen_gameplay.c index ee70632a..3dfce714 100644 --- a/games/transmission/screens/screen_gameplay.c +++ b/games/transmission/screens/screen_gameplay.c @@ -4,7 +4,7 @@ * * Gameplay Screen Functions Definitions (Init, Update, Draw, Unload) * -* Copyright (c) 2014-2018 Ramon Santamaria (@raysan5) +* Copyright (c) 2014-2019 Ramon Santamaria (@raysan5) * * This software is provided "as-is", without any express or implied warranty. In no event * will the authors be held liable for any damages arising from the use of this software. diff --git a/games/transmission/screens/screen_logo.c b/games/transmission/screens/screen_logo.c index 37543302..dc016423 100644 --- a/games/transmission/screens/screen_logo.c +++ b/games/transmission/screens/screen_logo.c @@ -4,7 +4,7 @@ * * Logo Screen Functions Definitions (Init, Update, Draw, Unload) * -* Copyright (c) 2014-2018 Ramon Santamaria (@raysan5) +* Copyright (c) 2014-2019 Ramon Santamaria (@raysan5) * * This software is provided "as-is", without any express or implied warranty. In no event * will the authors be held liable for any damages arising from the use of this software. diff --git a/games/transmission/screens/screen_mission.c b/games/transmission/screens/screen_mission.c index 1cd2563b..77777c73 100644 --- a/games/transmission/screens/screen_mission.c +++ b/games/transmission/screens/screen_mission.c @@ -3,7 +3,7 @@ * raylib - transmission mission * * -* Copyright (c) 2014-2018 Ramon Santamaria (@raysan5) +* Copyright (c) 2014-2019 Ramon Santamaria (@raysan5) * * This software is provided "as-is", without any express or implied warranty. In no event * will the authors be held liable for any damages arising from the use of this software. diff --git a/games/transmission/screens/screen_title.c b/games/transmission/screens/screen_title.c index 2a30a6ba..e9023b08 100644 --- a/games/transmission/screens/screen_title.c +++ b/games/transmission/screens/screen_title.c @@ -3,7 +3,7 @@ * raylib - transmission mission * * -* Copyright (c) 2014-2018 Ramon Santamaria (@raysan5) +* Copyright (c) 2014-2019 Ramon Santamaria (@raysan5) * * This software is provided "as-is", without any express or implied warranty. In no event * will the authors be held liable for any damages arising from the use of this software. diff --git a/games/transmission/screens/screens.h b/games/transmission/screens/screens.h index be5e31d9..49698f0d 100644 --- a/games/transmission/screens/screens.h +++ b/games/transmission/screens/screens.h @@ -4,7 +4,7 @@ * * Screens Functions Declarations (Init, Update, Draw, Unload) * -* Copyright (c) 2014-2018 Ramon Santamaria (@raysan5) +* Copyright (c) 2014-2019 Ramon Santamaria (@raysan5) * * This software is provided "as-is", without any express or implied warranty. In no event * will the authors be held liable for any damages arising from the use of this software. diff --git a/games/transmission/transmission.c b/games/transmission/transmission.c index 91ca28c1..9fc3d802 100644 --- a/games/transmission/transmission.c +++ b/games/transmission/transmission.c @@ -7,7 +7,7 @@ * This game has been created using raylib (www.raylib.com) * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) * -* Copyright (c) 2014-2018 Ramon Santamaria (@raysan5) +* Copyright (c) 2014-2019 Ramon Santamaria (@raysan5) * ********************************************************************************************/ diff --git a/games/wave_collector/Makefile b/games/wave_collector/Makefile index 06e74799..703383b8 100644 --- a/games/wave_collector/Makefile +++ b/games/wave_collector/Makefile @@ -2,7 +2,7 @@ # # raylib makefile for Desktop platforms, Raspberry Pi, Android and HTML5 # -# Copyright (c) 2013-2018 Ramon Santamaria (@raysan5) +# Copyright (c) 2013-2019 Ramon Santamaria (@raysan5) # # This software is provided "as-is", without any express or implied warranty. In no event # will the authors be held liable for any damages arising from the use of this software. diff --git a/projects/VSCode/Makefile b/projects/VSCode/Makefile index 747718fc..3cffaaba 100644 --- a/projects/VSCode/Makefile +++ b/projects/VSCode/Makefile @@ -2,7 +2,7 @@ # # raylib makefile for Desktop platforms, Raspberry Pi, Android and HTML5 # -# Copyright (c) 2013-2018 Ramon Santamaria (@raysan5) +# Copyright (c) 2013-2019 Ramon Santamaria (@raysan5) # # This software is provided "as-is", without any express or implied warranty. In no event # will the authors be held liable for any damages arising from the use of this software. diff --git a/src/Makefile b/src/Makefile index e2fe6c5d..0217c198 100644 --- a/src/Makefile +++ b/src/Makefile @@ -14,7 +14,7 @@ # Many thanks to Milan Nikolic (@gen2brain) for implementing Android platform pipeline. # Many thanks to Emanuele Petriglia for his contribution on GNU/Linux pipeline. # -# Copyright (c) 2014-2018 Ramon Santamaria (@raysan5) +# Copyright (c) 2014-2019 Ramon Santamaria (@raysan5) # # This software is provided "as-is", without any express or implied warranty. # In no event will the authors be held liable for any damages arising from diff --git a/src/core.c b/src/core.c index b0c0658d..42db214f 100644 --- a/src/core.c +++ b/src/core.c @@ -68,7 +68,7 @@ * * LICENSE: zlib/libpng * -* Copyright (c) 2014-2018 Ramon Santamaria (@raysan5) +* Copyright (c) 2014-2019 Ramon Santamaria (@raysan5) * * This software is provided "as-is", without any express or implied warranty. In no event * will the authors be held liable for any damages arising from the use of this software. diff --git a/src/gestures.h b/src/gestures.h index a4546eb1..36775333 100644 --- a/src/gestures.h +++ b/src/gestures.h @@ -24,7 +24,7 @@ * * LICENSE: zlib/libpng * -* Copyright (c) 2014-2018 Ramon Santamaria (@raysan5) +* Copyright (c) 2014-2019 Ramon Santamaria (@raysan5) * * This software is provided "as-is", without any express or implied warranty. In no event * will the authors be held liable for any damages arising from the use of this software. diff --git a/src/models.c b/src/models.c index 7a9acdf7..07f8203b 100644 --- a/src/models.c +++ b/src/models.c @@ -17,7 +17,7 @@ * * LICENSE: zlib/libpng * -* Copyright (c) 2014-2018 Ramon Santamaria (@raysan5) +* Copyright (c) 2014-2019 Ramon Santamaria (@raysan5) * * This software is provided "as-is", without any express or implied warranty. In no event * will the authors be held liable for any damages arising from the use of this software. diff --git a/src/raylib.h b/src/raylib.h index dc864b8d..dade7aba 100644 --- a/src/raylib.h +++ b/src/raylib.h @@ -49,7 +49,7 @@ * raylib is licensed under an unmodified zlib/libpng license, which is an OSI-certified, * BSD-like license that allows static linking with closed source software: * -* Copyright (c) 2013-2018 Ramon Santamaria (@raysan5) +* Copyright (c) 2013-2019 Ramon Santamaria (@raysan5) * * This software is provided "as-is", without any express or implied warranty. In no event * will the authors be held liable for any damages arising from the use of this software. diff --git a/src/rglfw.c b/src/rglfw.c index 853c5200..3463bb96 100644 --- a/src/rglfw.c +++ b/src/rglfw.c @@ -7,7 +7,7 @@ * * LICENSE: zlib/libpng * -* Copyright (c) 2017-2018 Ramon Santamaria (@raysan5) +* Copyright (c) 2017-2019 Ramon Santamaria (@raysan5) * * This software is provided "as-is", without any express or implied warranty. In no event * will the authors be held liable for any damages arising from the use of this software. diff --git a/src/rlgl.h b/src/rlgl.h index 81f39d68..3e428241 100644 --- a/src/rlgl.h +++ b/src/rlgl.h @@ -42,7 +42,7 @@ * * LICENSE: zlib/libpng * -* Copyright (c) 2014-2018 Ramon Santamaria (@raysan5) +* Copyright (c) 2014-2019 Ramon Santamaria (@raysan5) * * This software is provided "as-is", without any express or implied warranty. In no event * will the authors be held liable for any damages arising from the use of this software. diff --git a/src/shapes.c b/src/shapes.c index b7f7e3df..fbc70fc4 100644 --- a/src/shapes.c +++ b/src/shapes.c @@ -14,7 +14,7 @@ * * LICENSE: zlib/libpng * -* Copyright (c) 2014-2018 Ramon Santamaria (@raysan5) +* Copyright (c) 2014-2019 Ramon Santamaria (@raysan5) * * This software is provided "as-is", without any express or implied warranty. In no event * will the authors be held liable for any damages arising from the use of this software. diff --git a/src/text.c b/src/text.c index d44cdd11..cd7a6802 100644 --- a/src/text.c +++ b/src/text.c @@ -17,7 +17,7 @@ * * LICENSE: zlib/libpng * -* Copyright (c) 2014-2018 Ramon Santamaria (@raysan5) +* Copyright (c) 2014-2019 Ramon Santamaria (@raysan5) * * This software is provided "as-is", without any express or implied warranty. In no event * will the authors be held liable for any damages arising from the use of this software. diff --git a/src/textures.c b/src/textures.c index cd0bd208..5189b635 100644 --- a/src/textures.c +++ b/src/textures.c @@ -38,7 +38,7 @@ * * LICENSE: zlib/libpng * -* Copyright (c) 2014-2018 Ramon Santamaria (@raysan5) +* Copyright (c) 2014-2019 Ramon Santamaria (@raysan5) * * This software is provided "as-is", without any express or implied warranty. In no event * will the authors be held liable for any damages arising from the use of this software. diff --git a/src/utils.c b/src/utils.c index 6b174354..10cce9b9 100644 --- a/src/utils.c +++ b/src/utils.c @@ -11,7 +11,7 @@ * * LICENSE: zlib/libpng * -* Copyright (c) 2014-2018 Ramon Santamaria (@raysan5) +* Copyright (c) 2014-2019 Ramon Santamaria (@raysan5) * * This software is provided "as-is", without any express or implied warranty. In no event * will the authors be held liable for any damages arising from the use of this software. diff --git a/src/utils.h b/src/utils.h index 08b33962..d7ab8829 100644 --- a/src/utils.h +++ b/src/utils.h @@ -5,7 +5,7 @@ * * LICENSE: zlib/libpng * -* Copyright (c) 2014-2018 Ramon Santamaria (@raysan5) +* Copyright (c) 2014-2019 Ramon Santamaria (@raysan5) * * This software is provided "as-is", without any express or implied warranty. In no event * will the authors be held liable for any damages arising from the use of this software. diff --git a/templates/advance_game/Makefile b/templates/advance_game/Makefile index 2e5d6e26..e475f72c 100644 --- a/templates/advance_game/Makefile +++ b/templates/advance_game/Makefile @@ -2,7 +2,7 @@ # # raylib makefile for Desktop platforms, Raspberry Pi, Android and HTML5 # -# Copyright (c) 2013-2018 Ramon Santamaria (@raysan5) +# Copyright (c) 2013-2019 Ramon Santamaria (@raysan5) # # This software is provided "as-is", without any express or implied warranty. In no event # will the authors be held liable for any damages arising from the use of this software. diff --git a/templates/advance_game/advance_game.c b/templates/advance_game/advance_game.c index 48a34f6d..3fb5d657 100644 --- a/templates/advance_game/advance_game.c +++ b/templates/advance_game/advance_game.c @@ -8,7 +8,7 @@ * This game has been created using raylib (www.raylib.com) * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) * -* Copyright (c) 2014-2018 Ramon Santamaria (@raysan5) +* Copyright (c) 2014-2019 Ramon Santamaria (@raysan5) * ********************************************************************************************/ diff --git a/templates/advance_game/screens/screen_ending.c b/templates/advance_game/screens/screen_ending.c index 66b5ddf9..62d1267a 100644 --- a/templates/advance_game/screens/screen_ending.c +++ b/templates/advance_game/screens/screen_ending.c @@ -4,7 +4,7 @@ * * Ending Screen Functions Definitions (Init, Update, Draw, Unload) * -* Copyright (c) 2014-2018 Ramon Santamaria (@raysan5) +* Copyright (c) 2014-2019 Ramon Santamaria (@raysan5) * * This software is provided "as-is", without any express or implied warranty. In no event * will the authors be held liable for any damages arising from the use of this software. diff --git a/templates/advance_game/screens/screen_gameplay.c b/templates/advance_game/screens/screen_gameplay.c index 8943adb5..8ea61491 100644 --- a/templates/advance_game/screens/screen_gameplay.c +++ b/templates/advance_game/screens/screen_gameplay.c @@ -4,7 +4,7 @@ * * Gameplay Screen Functions Definitions (Init, Update, Draw, Unload) * -* Copyright (c) 2014-2018 Ramon Santamaria (@raysan5) +* Copyright (c) 2014-2019 Ramon Santamaria (@raysan5) * * This software is provided "as-is", without any express or implied warranty. In no event * will the authors be held liable for any damages arising from the use of this software. diff --git a/templates/advance_game/screens/screen_logo.c b/templates/advance_game/screens/screen_logo.c index 6282e83e..8badbf52 100644 --- a/templates/advance_game/screens/screen_logo.c +++ b/templates/advance_game/screens/screen_logo.c @@ -4,7 +4,7 @@ * * Logo Screen Functions Definitions (Init, Update, Draw, Unload) * -* Copyright (c) 2014-2018 Ramon Santamaria (@raysan5) +* Copyright (c) 2014-2019 Ramon Santamaria (@raysan5) * * This software is provided "as-is", without any express or implied warranty. In no event * will the authors be held liable for any damages arising from the use of this software. diff --git a/templates/advance_game/screens/screen_options.c b/templates/advance_game/screens/screen_options.c index dc8d74fa..4b58da13 100644 --- a/templates/advance_game/screens/screen_options.c +++ b/templates/advance_game/screens/screen_options.c @@ -4,7 +4,7 @@ * * Options Screen Functions Definitions (Init, Update, Draw, Unload) * -* Copyright (c) 2014-2018 Ramon Santamaria (@raysan5) +* Copyright (c) 2014-2019 Ramon Santamaria (@raysan5) * * This software is provided "as-is", without any express or implied warranty. In no event * will the authors be held liable for any damages arising from the use of this software. diff --git a/templates/advance_game/screens/screen_title.c b/templates/advance_game/screens/screen_title.c index 5727546a..8e74a027 100644 --- a/templates/advance_game/screens/screen_title.c +++ b/templates/advance_game/screens/screen_title.c @@ -4,7 +4,7 @@ * * Title Screen Functions Definitions (Init, Update, Draw, Unload) * -* Copyright (c) 2014-2018 Ramon Santamaria (@raysan5) +* Copyright (c) 2014-2019 Ramon Santamaria (@raysan5) * * This software is provided "as-is", without any express or implied warranty. In no event * will the authors be held liable for any damages arising from the use of this software. diff --git a/templates/advance_game/screens/screens.h b/templates/advance_game/screens/screens.h index 4d7f9b53..7c2dfb48 100644 --- a/templates/advance_game/screens/screens.h +++ b/templates/advance_game/screens/screens.h @@ -4,7 +4,7 @@ * * Screens Functions Declarations (Init, Update, Draw, Unload) * -* Copyright (c) 2014-2018 Ramon Santamaria (@raysan5) +* Copyright (c) 2014-2019 Ramon Santamaria (@raysan5) * * This software is provided "as-is", without any express or implied warranty. In no event * will the authors be held liable for any damages arising from the use of this software. diff --git a/templates/simple_game/Makefile b/templates/simple_game/Makefile index 86e0dbde..9f27a429 100644 --- a/templates/simple_game/Makefile +++ b/templates/simple_game/Makefile @@ -2,7 +2,7 @@ # # raylib makefile for Desktop platforms, Raspberry Pi, Android and HTML5 # -# Copyright (c) 2013-2018 Ramon Santamaria (@raysan5) +# Copyright (c) 2013-2019 Ramon Santamaria (@raysan5) # # This software is provided "as-is", without any express or implied warranty. In no event # will the authors be held liable for any damages arising from the use of this software. diff --git a/templates/simple_game/simple_game.c b/templates/simple_game/simple_game.c index 028b1da8..8f2dc36a 100644 --- a/templates/simple_game/simple_game.c +++ b/templates/simple_game/simple_game.c @@ -8,7 +8,7 @@ * This game has been created using raylib (www.raylib.com) * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) * -* Copyright (c) 2014-2018 Ramon Santamaria (@raysan5) +* Copyright (c) 2014-2019 Ramon Santamaria (@raysan5) * ********************************************************************************************/ diff --git a/templates/standard_game/Makefile b/templates/standard_game/Makefile index b9c6c188..4333c8b8 100644 --- a/templates/standard_game/Makefile +++ b/templates/standard_game/Makefile @@ -2,7 +2,7 @@ # # raylib makefile for Desktop platforms, Raspberry Pi, Android and HTML5 # -# Copyright (c) 2013-2018 Ramon Santamaria (@raysan5) +# Copyright (c) 2013-2019 Ramon Santamaria (@raysan5) # # This software is provided "as-is", without any express or implied warranty. In no event # will the authors be held liable for any damages arising from the use of this software. diff --git a/templates/standard_game/screens/screen_ending.c b/templates/standard_game/screens/screen_ending.c index 87196977..1bd5ce98 100644 --- a/templates/standard_game/screens/screen_ending.c +++ b/templates/standard_game/screens/screen_ending.c @@ -4,7 +4,7 @@ * * Ending Screen Functions Definitions (Init, Update, Draw, Unload) * -* Copyright (c) 2014-2018 Ramon Santamaria (@raysan5) +* Copyright (c) 2014-2019 Ramon Santamaria (@raysan5) * * This software is provided "as-is", without any express or implied warranty. In no event * will the authors be held liable for any damages arising from the use of this software. diff --git a/templates/standard_game/screens/screen_gameplay.c b/templates/standard_game/screens/screen_gameplay.c index 7f108265..427e5ba7 100644 --- a/templates/standard_game/screens/screen_gameplay.c +++ b/templates/standard_game/screens/screen_gameplay.c @@ -4,7 +4,7 @@ * * Gameplay Screen Functions Definitions (Init, Update, Draw, Unload) * -* Copyright (c) 2014-2018 Ramon Santamaria (@raysan5) +* Copyright (c) 2014-2019 Ramon Santamaria (@raysan5) * * This software is provided "as-is", without any express or implied warranty. In no event * will the authors be held liable for any damages arising from the use of this software. diff --git a/templates/standard_game/screens/screen_logo.c b/templates/standard_game/screens/screen_logo.c index c0b60571..435ea241 100644 --- a/templates/standard_game/screens/screen_logo.c +++ b/templates/standard_game/screens/screen_logo.c @@ -4,7 +4,7 @@ * * Logo Screen Functions Definitions (Init, Update, Draw, Unload) * -* Copyright (c) 2014-2018 Ramon Santamaria (@raysan5) +* Copyright (c) 2014-2019 Ramon Santamaria (@raysan5) * * This software is provided "as-is", without any express or implied warranty. In no event * will the authors be held liable for any damages arising from the use of this software. diff --git a/templates/standard_game/screens/screen_options.c b/templates/standard_game/screens/screen_options.c index 9f6690d1..df68dd26 100644 --- a/templates/standard_game/screens/screen_options.c +++ b/templates/standard_game/screens/screen_options.c @@ -4,7 +4,7 @@ * * Options Screen Functions Definitions (Init, Update, Draw, Unload) * -* Copyright (c) 2014-2018 Ramon Santamaria (@raysan5) +* Copyright (c) 2014-2019 Ramon Santamaria (@raysan5) * * This software is provided "as-is", without any express or implied warranty. In no event * will the authors be held liable for any damages arising from the use of this software. diff --git a/templates/standard_game/screens/screen_title.c b/templates/standard_game/screens/screen_title.c index 328448ba..5bd33825 100644 --- a/templates/standard_game/screens/screen_title.c +++ b/templates/standard_game/screens/screen_title.c @@ -4,7 +4,7 @@ * * Title Screen Functions Definitions (Init, Update, Draw, Unload) * -* Copyright (c) 2014-2018 Ramon Santamaria (@raysan5) +* Copyright (c) 2014-2019 Ramon Santamaria (@raysan5) * * This software is provided "as-is", without any express or implied warranty. In no event * will the authors be held liable for any damages arising from the use of this software. diff --git a/templates/standard_game/screens/screens.h b/templates/standard_game/screens/screens.h index e961b533..9450c29f 100644 --- a/templates/standard_game/screens/screens.h +++ b/templates/standard_game/screens/screens.h @@ -4,7 +4,7 @@ * * Screens Functions Declarations (Init, Update, Draw, Unload) * -* Copyright (c) 2014-2018 Ramon Santamaria (@raysan5) +* Copyright (c) 2014-2019 Ramon Santamaria (@raysan5) * * This software is provided "as-is", without any express or implied warranty. In no event * will the authors be held liable for any damages arising from the use of this software. diff --git a/templates/standard_game/standard_game.c b/templates/standard_game/standard_game.c index 8871484e..7918562c 100644 --- a/templates/standard_game/standard_game.c +++ b/templates/standard_game/standard_game.c @@ -8,7 +8,7 @@ * This game has been created using raylib (www.raylib.com) * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) * -* Copyright (c) 2014-2018 Ramon Santamaria (@raysan5) +* Copyright (c) 2014-2019 Ramon Santamaria (@raysan5) * ********************************************************************************************/ -- cgit v1.2.3 From b8ada4b877497cf31aad0efdec41c032fc686552 Mon Sep 17 00:00:00 2001 From: Ray Date: Mon, 8 Apr 2019 12:25:13 +0200 Subject: Review creation years --- src/config.h | 2 +- src/core.c | 2 +- src/models.c | 2 +- src/raudio.c | 2 +- src/shapes.c | 2 +- src/text.c | 2 +- src/textures.c | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) (limited to 'src/core.c') diff --git a/src/config.h b/src/config.h index 561bcfd3..dc30eeb2 100644 --- a/src/config.h +++ b/src/config.h @@ -6,7 +6,7 @@ * * LICENSE: zlib/libpng * -* Copyright (c) 2018 Ahmad Fatoum & Ramon Santamaria (@raysan5) +* Copyright (c) 2018-2019 Ahmad Fatoum & Ramon Santamaria (@raysan5) * * This software is provided "as-is", without any express or implied warranty. In no event * will the authors be held liable for any damages arising from the use of this software. diff --git a/src/core.c b/src/core.c index 42db214f..32773a0d 100644 --- a/src/core.c +++ b/src/core.c @@ -68,7 +68,7 @@ * * LICENSE: zlib/libpng * -* Copyright (c) 2014-2019 Ramon Santamaria (@raysan5) +* Copyright (c) 2013-2019 Ramon Santamaria (@raysan5) * * This software is provided "as-is", without any express or implied warranty. In no event * will the authors be held liable for any damages arising from the use of this software. diff --git a/src/models.c b/src/models.c index 07f8203b..d5e74e33 100644 --- a/src/models.c +++ b/src/models.c @@ -17,7 +17,7 @@ * * LICENSE: zlib/libpng * -* Copyright (c) 2014-2019 Ramon Santamaria (@raysan5) +* Copyright (c) 2013-2019 Ramon Santamaria (@raysan5) * * This software is provided "as-is", without any express or implied warranty. In no event * will the authors be held liable for any damages arising from the use of this software. diff --git a/src/raudio.c b/src/raudio.c index d360b2d3..636d15b8 100644 --- a/src/raudio.c +++ b/src/raudio.c @@ -46,7 +46,7 @@ * * LICENSE: zlib/libpng * -* Copyright (c) 2014-2019 Ramon Santamaria (@raysan5) +* Copyright (c) 2013-2019 Ramon Santamaria (@raysan5) * * This software is provided "as-is", without any express or implied warranty. In no event * will the authors be held liable for any damages arising from the use of this software. diff --git a/src/shapes.c b/src/shapes.c index fbc70fc4..f407f0d2 100644 --- a/src/shapes.c +++ b/src/shapes.c @@ -14,7 +14,7 @@ * * LICENSE: zlib/libpng * -* Copyright (c) 2014-2019 Ramon Santamaria (@raysan5) +* Copyright (c) 2013-2019 Ramon Santamaria (@raysan5) * * This software is provided "as-is", without any express or implied warranty. In no event * will the authors be held liable for any damages arising from the use of this software. diff --git a/src/text.c b/src/text.c index cd7a6802..c07f807a 100644 --- a/src/text.c +++ b/src/text.c @@ -17,7 +17,7 @@ * * LICENSE: zlib/libpng * -* Copyright (c) 2014-2019 Ramon Santamaria (@raysan5) +* Copyright (c) 2013-2019 Ramon Santamaria (@raysan5) * * This software is provided "as-is", without any express or implied warranty. In no event * will the authors be held liable for any damages arising from the use of this software. diff --git a/src/textures.c b/src/textures.c index 5189b635..169f8f86 100644 --- a/src/textures.c +++ b/src/textures.c @@ -38,7 +38,7 @@ * * LICENSE: zlib/libpng * -* Copyright (c) 2014-2019 Ramon Santamaria (@raysan5) +* Copyright (c) 2013-2019 Ramon Santamaria (@raysan5) * * This software is provided "as-is", without any express or implied warranty. In no event * will the authors be held liable for any damages arising from the use of this software. -- cgit v1.2.3 From df90ba6e463e5689039821fe93ea93d0a996b035 Mon Sep 17 00:00:00 2001 From: Ray Date: Fri, 12 Apr 2019 13:31:05 +0200 Subject: WARNING: Added GLFW hint to support hi-DPI This needs to be tested on a hi-DPI monitor, probably requiring a FLAG to enable it would be a good idea... --- src/core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/core.c') diff --git a/src/core.c b/src/core.c index 32773a0d..e8316213 100644 --- a/src/core.c +++ b/src/core.c @@ -2347,7 +2347,7 @@ static bool InitGraphicsDevice(int width, int height) displayHeight = screenHeight; #endif // defined(PLATFORM_WEB) - glfwDefaultWindowHints(); // Set default windows hints: + glfwDefaultWindowHints(); // Set default windows hints: //glfwWindowHint(GLFW_RED_BITS, 8); // Framebuffer red color component bits //glfwWindowHint(GLFW_GREEN_BITS, 8); // Framebuffer green color component bits //glfwWindowHint(GLFW_BLUE_BITS, 8); // Framebuffer blue color component bits @@ -2356,6 +2356,7 @@ static bool InitGraphicsDevice(int width, int height) //glfwWindowHint(GLFW_REFRESH_RATE, 0); // Refresh rate for fullscreen window //glfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_API); // OpenGL API to use. Alternative: GLFW_OPENGL_ES_API //glfwWindowHint(GLFW_AUX_BUFFERS, 0); // Number of auxiliar buffers + glfwWindowHint(GLFW_SCALE_TO_MONITOR, GLFW_TRUE); // Scale content area based on the monitor content scale where window is placed on // Check some Window creation flags if (configFlags & FLAG_WINDOW_HIDDEN) glfwWindowHint(GLFW_VISIBLE, GL_FALSE); // Visible window -- cgit v1.2.3 From fc5dd5d99fb233879885cd02da5010d81f37d0b0 Mon Sep 17 00:00:00 2001 From: Ray Date: Fri, 12 Apr 2019 13:44:16 +0200 Subject: FLAG not supported on web GLFW implementation --- src/core.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/core.c') diff --git a/src/core.c b/src/core.c index e8316213..ba41c773 100644 --- a/src/core.c +++ b/src/core.c @@ -2356,7 +2356,9 @@ static bool InitGraphicsDevice(int width, int height) //glfwWindowHint(GLFW_REFRESH_RATE, 0); // Refresh rate for fullscreen window //glfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_API); // OpenGL API to use. Alternative: GLFW_OPENGL_ES_API //glfwWindowHint(GLFW_AUX_BUFFERS, 0); // Number of auxiliar buffers +#if defined(PLATFORM_DESKTOP) glfwWindowHint(GLFW_SCALE_TO_MONITOR, GLFW_TRUE); // Scale content area based on the monitor content scale where window is placed on +#endif // Check some Window creation flags if (configFlags & FLAG_WINDOW_HIDDEN) glfwWindowHint(GLFW_VISIBLE, GL_FALSE); // Visible window -- cgit v1.2.3 From 152b7471e9bd750f28f3fe494ba4e30affe23a47 Mon Sep 17 00:00:00 2001 From: Ray Date: Mon, 22 Apr 2019 18:46:05 +0200 Subject: Comment HiDPI window request At least until a proper solution is found! --- src/core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/core.c') diff --git a/src/core.c b/src/core.c index ba41c773..6bb54c51 100644 --- a/src/core.c +++ b/src/core.c @@ -2357,7 +2357,8 @@ static bool InitGraphicsDevice(int width, int height) //glfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_API); // OpenGL API to use. Alternative: GLFW_OPENGL_ES_API //glfwWindowHint(GLFW_AUX_BUFFERS, 0); // Number of auxiliar buffers #if defined(PLATFORM_DESKTOP) - glfwWindowHint(GLFW_SCALE_TO_MONITOR, GLFW_TRUE); // Scale content area based on the monitor content scale where window is placed on + // TODO: If using external GLFW, it requires latest GLFW 3.3 for this functionality + //glfwWindowHint(GLFW_SCALE_TO_MONITOR, GLFW_TRUE); // Scale content area based on the monitor content scale where window is placed on #endif // Check some Window creation flags -- cgit v1.2.3 From e67ebabb02c1068d6e7f5107dcff5388ede3faa5 Mon Sep 17 00:00:00 2001 From: Ray Date: Tue, 23 Apr 2019 14:55:35 +0200 Subject: Support custom memory management macros Users can define their custom memory management macros. NOTE: Most external libraries support custom macros in the same way, raylib should redefine those macros to raylib ones, to unify custom memory loading. That redefinition is only implemented as example for stb_image.h in [textures] module. --- src/core.c | 24 ++--- src/models.c | 291 +++++++++++++++++++++++++++++---------------------------- src/raudio.c | 38 ++++---- src/raudio.h | 11 ++- src/raylib.h | 11 +++ src/rlgl.h | 88 ++++++++--------- src/text.c | 54 +++++------ src/textures.c | 181 ++++++++++++++++++----------------- src/utils.c | 6 +- 9 files changed, 365 insertions(+), 339 deletions(-) (limited to 'src/core.c') diff --git a/src/core.c b/src/core.c index 6bb54c51..844994d0 100644 --- a/src/core.c +++ b/src/core.c @@ -1113,7 +1113,7 @@ void EndDrawing(void) unsigned char *screenData = rlReadScreenPixels(screenWidth, screenHeight); GifWriteFrame(screenData, screenWidth, screenHeight, 10, 8, false); - free(screenData); // Free image data + RL_FREE(screenData); // Free image data } if (((gifFramesCounter/15)%2) == 1) @@ -1595,7 +1595,7 @@ void TakeScreenshot(const char *fileName) #endif ExportImage(image, path); - free(imgData); + RL_FREE(imgData); #if defined(PLATFORM_WEB) // Download file from MEMFS (emscripten memory filesystem) @@ -1742,8 +1742,8 @@ char **GetDirectoryFiles(const char *dirPath, int *fileCount) ClearDirectoryFiles(); // Memory allocation for MAX_DIRECTORY_FILES - dirFilesPath = (char **)malloc(sizeof(char *)*MAX_DIRECTORY_FILES); - for (int i = 0; i < MAX_DIRECTORY_FILES; i++) dirFilesPath[i] = (char *)malloc(sizeof(char)*MAX_FILEPATH_LENGTH); + dirFilesPath = (char **)RL_MALLOC(sizeof(char *)*MAX_DIRECTORY_FILES); + for (int i = 0; i < MAX_DIRECTORY_FILES; i++) dirFilesPath[i] = (char *)RL_MALLOC(sizeof(char)*MAX_FILEPATH_LENGTH); int counter = 0; struct dirent *ent; @@ -1776,9 +1776,9 @@ void ClearDirectoryFiles(void) { if (dirFilesCount > 0) { - for (int i = 0; i < dirFilesCount; i++) free(dirFilesPath[i]); + for (int i = 0; i < dirFilesCount; i++) RL_FREE(dirFilesPath[i]); - free(dirFilesPath); + RL_FREE(dirFilesPath); dirFilesCount = 0; } } @@ -1808,9 +1808,9 @@ void ClearDroppedFiles(void) { if (dropFilesCount > 0) { - for (int i = 0; i < dropFilesCount; i++) free(dropFilesPath[i]); + for (int i = 0; i < dropFilesCount; i++) RL_FREE(dropFilesPath[i]); - free(dropFilesPath); + RL_FREE(dropFilesPath); dropFilesCount = 0; } @@ -1925,7 +1925,7 @@ void OpenURL(const char *url) } else { - char *cmd = (char *)calloc(strlen(url) + 10, sizeof(char)); + char *cmd = (char *)RL_CALLOC(strlen(url) + 10, sizeof(char)); #if defined(_WIN32) sprintf(cmd, "explorer %s", url); @@ -1935,7 +1935,7 @@ void OpenURL(const char *url) sprintf(cmd, "open '%s'", url); #endif system(cmd); - free(cmd); + RL_FREE(cmd); } } @@ -3455,11 +3455,11 @@ static void WindowDropCallback(GLFWwindow *window, int count, const char **paths { ClearDroppedFiles(); - dropFilesPath = (char **)malloc(sizeof(char *)*count); + dropFilesPath = (char **)RL_MALLOC(sizeof(char *)*count); for (int i = 0; i < count; i++) { - dropFilesPath[i] = (char *)malloc(sizeof(char)*MAX_FILEPATH_LENGTH); + dropFilesPath[i] = (char *)RL_MALLOC(sizeof(char)*MAX_FILEPATH_LENGTH); strcpy(dropFilesPath[i], paths[i]); } diff --git a/src/models.c b/src/models.c index 631c4942..c81dfe19 100644 --- a/src/models.c +++ b/src/models.c @@ -651,7 +651,7 @@ Model LoadModel(const char *fileName) TraceLog(LOG_WARNING, "[%s] No meshes can be loaded, default to cube mesh", fileName); model.meshCount = 1; - model.meshes = (Mesh *)calloc(model.meshCount, sizeof(Mesh)); + model.meshes = (Mesh *)RL_CALLOC(model.meshCount, sizeof(Mesh)); model.meshes[0] = GenMeshCube(1.0f, 1.0f, 1.0f); } else @@ -665,10 +665,10 @@ Model LoadModel(const char *fileName) TraceLog(LOG_WARNING, "[%s] No materials can be loaded, default to white material", fileName); model.materialCount = 1; - model.materials = (Material *)calloc(model.materialCount, sizeof(Material)); + model.materials = (Material *)RL_CALLOC(model.materialCount, sizeof(Material)); model.materials[0] = LoadMaterialDefault(); - model.meshMaterial = (int *)calloc(model.meshCount, sizeof(int)); + model.meshMaterial = (int *)RL_CALLOC(model.meshCount, sizeof(int)); } return model; @@ -685,14 +685,14 @@ Model LoadModelFromMesh(Mesh mesh) model.transform = MatrixIdentity(); model.meshCount = 1; - model.meshes = (Mesh *)malloc(model.meshCount*sizeof(Mesh)); + model.meshes = (Mesh *)RL_MALLOC(model.meshCount*sizeof(Mesh)); model.meshes[0] = mesh; model.materialCount = 1; - model.materials = (Material *)malloc(model.materialCount*sizeof(Material)); + model.materials = (Material *)RL_MALLOC(model.materialCount*sizeof(Material)); model.materials[0] = LoadMaterialDefault(); - model.meshMaterial = (int *)malloc(model.meshCount*sizeof(int)); + model.meshMaterial = (int *)RL_MALLOC(model.meshCount*sizeof(int)); model.meshMaterial[0] = 0; // First material index return model; @@ -704,13 +704,13 @@ void UnloadModel(Model model) for (int i = 0; i < model.meshCount; i++) UnloadMesh(&model.meshes[i]); for (int i = 0; i < model.materialCount; i++) UnloadMaterial(model.materials[i]); - free(model.meshes); - free(model.materials); - free(model.meshMaterial); + RL_FREE(model.meshes); + RL_FREE(model.materials); + RL_FREE(model.meshMaterial); // Unload animation data - free(model.bones); - free(model.bindPose); + RL_FREE(model.bones); + RL_FREE(model.bindPose); TraceLog(LOG_INFO, "Unloaded model data from RAM and VRAM"); } @@ -866,7 +866,7 @@ void SetModelMeshMaterial(Model *model, int meshId, int materialId) // Load model animations from file ModelAnimation *LoadModelAnimations(const char *filename, int *animCount) { - ModelAnimation *animations = (ModelAnimation *)malloc(1*sizeof(ModelAnimation)); + ModelAnimation *animations = (ModelAnimation *)RL_MALLOC(1*sizeof(ModelAnimation)); int count = 1; #define IQM_MAGIC "INTERQUAKEMODEL" // IQM file magic number @@ -935,12 +935,12 @@ ModelAnimation *LoadModelAnimations(const char *filename, int *animCount) // bones IQMPose *poses; - poses = malloc(sizeof(IQMPose)*iqm.num_poses); + poses = RL_MALLOC(sizeof(IQMPose)*iqm.num_poses); fseek(iqmFile, iqm.ofs_poses, SEEK_SET); fread(poses, sizeof(IQMPose)*iqm.num_poses, 1, iqmFile); animation.boneCount = iqm.num_poses; - animation.bones = malloc(sizeof(BoneInfo)*iqm.num_poses); + animation.bones = RL_MALLOC(sizeof(BoneInfo)*iqm.num_poses); for (int j = 0; j < iqm.num_poses; j++) { @@ -957,12 +957,12 @@ ModelAnimation *LoadModelAnimations(const char *filename, int *animCount) //animation.framerate = anim.framerate; // frameposes - unsigned short *framedata = malloc(sizeof(unsigned short)*iqm.num_frames*iqm.num_framechannels); + unsigned short *framedata = RL_MALLOC(sizeof(unsigned short)*iqm.num_frames*iqm.num_framechannels); fseek(iqmFile, iqm.ofs_frames, SEEK_SET); fread(framedata, sizeof(unsigned short)*iqm.num_frames*iqm.num_framechannels, 1, iqmFile); - animation.framePoses = malloc(sizeof(Transform*)*anim.num_frames); - for (int j = 0; j < anim.num_frames; j++) animation.framePoses[j] = malloc(sizeof(Transform)*iqm.num_poses); + animation.framePoses = RL_MALLOC(sizeof(Transform*)*anim.num_frames); + for (int j = 0; j < anim.num_frames; j++) animation.framePoses[j] = RL_MALLOC(sizeof(Transform)*iqm.num_poses); int dcounter = anim.first_frame*iqm.num_framechannels; @@ -1069,8 +1069,8 @@ ModelAnimation *LoadModelAnimations(const char *filename, int *animCount) } } - free(framedata); - free(poses); + RL_FREE(framedata); + RL_FREE(poses); fclose(iqmFile); @@ -1145,10 +1145,10 @@ void UpdateModelAnimation(Model model, ModelAnimation anim, int frame) // Unload animation data void UnloadModelAnimation(ModelAnimation anim) { - for (int i = 0; i < anim.frameCount; i++) free(anim.framePoses[i]); + for (int i = 0; i < anim.frameCount; i++) RL_FREE(anim.framePoses[i]); - free(anim.bones); - free(anim.framePoses); + RL_FREE(anim.bones); + RL_FREE(anim.framePoses); } // Check model animation skeleton match @@ -1177,7 +1177,7 @@ Mesh GenMeshPoly(int sides, float radius) int vertexCount = sides*3; // Vertices definition - Vector3 *vertices = (Vector3 *)malloc(vertexCount*sizeof(Vector3)); + Vector3 *vertices = (Vector3 *)RL_MALLOC(vertexCount*sizeof(Vector3)); for (int i = 0, v = 0; i < 360; i += 360/sides, v += 3) { vertices[v] = (Vector3){ 0.0f, 0.0f, 0.0f }; @@ -1186,18 +1186,18 @@ Mesh GenMeshPoly(int sides, float radius) } // Normals definition - Vector3 *normals = (Vector3 *)malloc(vertexCount*sizeof(Vector3)); + Vector3 *normals = (Vector3 *)RL_MALLOC(vertexCount*sizeof(Vector3)); for (int n = 0; n < vertexCount; n++) normals[n] = (Vector3){ 0.0f, 1.0f, 0.0f }; // Vector3.up; // TexCoords definition - Vector2 *texcoords = (Vector2 *)malloc(vertexCount*sizeof(Vector2)); + Vector2 *texcoords = (Vector2 *)RL_MALLOC(vertexCount*sizeof(Vector2)); for (int n = 0; n < vertexCount; n++) texcoords[n] = (Vector2){ 0.0f, 0.0f }; mesh.vertexCount = vertexCount; mesh.triangleCount = sides; - mesh.vertices = (float *)malloc(mesh.vertexCount*3*sizeof(float)); - mesh.texcoords = (float *)malloc(mesh.vertexCount*2*sizeof(float)); - mesh.normals = (float *)malloc(mesh.vertexCount*3*sizeof(float)); + mesh.vertices = (float *)RL_MALLOC(mesh.vertexCount*3*sizeof(float)); + mesh.texcoords = (float *)RL_MALLOC(mesh.vertexCount*2*sizeof(float)); + mesh.normals = (float *)RL_MALLOC(mesh.vertexCount*3*sizeof(float)); // Mesh vertices position array for (int i = 0; i < mesh.vertexCount; i++) @@ -1222,9 +1222,9 @@ Mesh GenMeshPoly(int sides, float radius) mesh.normals[3*i + 2] = normals[i].z; } - free(vertices); - free(normals); - free(texcoords); + RL_FREE(vertices); + RL_FREE(normals); + RL_FREE(texcoords); // Upload vertex data to GPU (static mesh) rlLoadMesh(&mesh, false); @@ -1245,7 +1245,7 @@ Mesh GenMeshPlane(float width, float length, int resX, int resZ) // Vertices definition int vertexCount = resX*resZ; // vertices get reused for the faces - Vector3 *vertices = (Vector3 *)malloc(vertexCount*sizeof(Vector3)); + Vector3 *vertices = (Vector3 *)RL_MALLOC(vertexCount*sizeof(Vector3)); for (int z = 0; z < resZ; z++) { // [-length/2, length/2] @@ -1259,11 +1259,11 @@ Mesh GenMeshPlane(float width, float length, int resX, int resZ) } // Normals definition - Vector3 *normals = (Vector3 *)malloc(vertexCount*sizeof(Vector3)); + Vector3 *normals = (Vector3 *)RL_MALLOC(vertexCount*sizeof(Vector3)); for (int n = 0; n < vertexCount; n++) normals[n] = (Vector3){ 0.0f, 1.0f, 0.0f }; // Vector3.up; // TexCoords definition - Vector2 *texcoords = (Vector2 *)malloc(vertexCount*sizeof(Vector2)); + Vector2 *texcoords = (Vector2 *)RL_MALLOC(vertexCount*sizeof(Vector2)); for (int v = 0; v < resZ; v++) { for (int u = 0; u < resX; u++) @@ -1274,7 +1274,7 @@ Mesh GenMeshPlane(float width, float length, int resX, int resZ) // Triangles definition (indices) int numFaces = (resX - 1)*(resZ - 1); - int *triangles = (int *)malloc(numFaces*6*sizeof(int)); + int *triangles = (int *)RL_MALLOC(numFaces*6*sizeof(int)); int t = 0; for (int face = 0; face < numFaces; face++) { @@ -1292,10 +1292,10 @@ Mesh GenMeshPlane(float width, float length, int resX, int resZ) mesh.vertexCount = vertexCount; mesh.triangleCount = numFaces*2; - mesh.vertices = (float *)malloc(mesh.vertexCount*3*sizeof(float)); - mesh.texcoords = (float *)malloc(mesh.vertexCount*2*sizeof(float)); - mesh.normals = (float *)malloc(mesh.vertexCount*3*sizeof(float)); - mesh.indices = (unsigned short *)malloc(mesh.triangleCount*3*sizeof(unsigned short)); + mesh.vertices = (float *)RL_MALLOC(mesh.vertexCount*3*sizeof(float)); + mesh.texcoords = (float *)RL_MALLOC(mesh.vertexCount*2*sizeof(float)); + mesh.normals = (float *)RL_MALLOC(mesh.vertexCount*3*sizeof(float)); + mesh.indices = (unsigned short *)RL_MALLOC(mesh.triangleCount*3*sizeof(unsigned short)); // Mesh vertices position array for (int i = 0; i < mesh.vertexCount; i++) @@ -1323,10 +1323,10 @@ Mesh GenMeshPlane(float width, float length, int resX, int resZ) // Mesh indices array initialization for (int i = 0; i < mesh.triangleCount*3; i++) mesh.indices[i] = triangles[i]; - free(vertices); - free(normals); - free(texcoords); - free(triangles); + RL_FREE(vertices); + RL_FREE(normals); + RL_FREE(texcoords); + RL_FREE(triangles); #else // Use par_shapes library to generate plane mesh @@ -1335,9 +1335,9 @@ Mesh GenMeshPlane(float width, float length, int resX, int resZ) par_shapes_rotate(plane, -PI/2.0f, (float[]){ 1, 0, 0 }); par_shapes_translate(plane, -width/2, 0.0f, length/2); - mesh.vertices = (float *)malloc(plane->ntriangles*3*3*sizeof(float)); - mesh.texcoords = (float *)malloc(plane->ntriangles*3*2*sizeof(float)); - mesh.normals = (float *)malloc(plane->ntriangles*3*3*sizeof(float)); + mesh.vertices = (float *)RL_MALLOC(plane->ntriangles*3*3*sizeof(float)); + mesh.texcoords = (float *)RL_MALLOC(plane->ntriangles*3*2*sizeof(float)); + mesh.normals = (float *)RL_MALLOC(plane->ntriangles*3*3*sizeof(float)); mesh.vertexCount = plane->ntriangles*3; mesh.triangleCount = plane->ntriangles; @@ -1453,16 +1453,16 @@ Mesh GenMeshCube(float width, float height, float length) -1.0f, 0.0f, 0.0f }; - mesh.vertices = (float *)malloc(24*3*sizeof(float)); + mesh.vertices = (float *)RL_MALLOC(24*3*sizeof(float)); memcpy(mesh.vertices, vertices, 24*3*sizeof(float)); - mesh.texcoords = (float *)malloc(24*2*sizeof(float)); + mesh.texcoords = (float *)RL_MALLOC(24*2*sizeof(float)); memcpy(mesh.texcoords, texcoords, 24*2*sizeof(float)); - mesh.normals = (float *)malloc(24*3*sizeof(float)); + mesh.normals = (float *)RL_MALLOC(24*3*sizeof(float)); memcpy(mesh.normals, normals, 24*3*sizeof(float)); - mesh.indices = (unsigned short *)malloc(36*sizeof(unsigned short)); + mesh.indices = (unsigned short *)RL_MALLOC(36*sizeof(unsigned short)); int k = 0; @@ -1500,9 +1500,9 @@ par_shapes_mesh* par_shapes_create_icosahedron(); // 20 sides polyhedron par_shapes_translate(cube, -width/2, 0.0f, -length/2); par_shapes_compute_normals(cube); - mesh.vertices = (float *)malloc(cube->ntriangles*3*3*sizeof(float)); - mesh.texcoords = (float *)malloc(cube->ntriangles*3*2*sizeof(float)); - mesh.normals = (float *)malloc(cube->ntriangles*3*3*sizeof(float)); + mesh.vertices = (float *)RL_MALLOC(cube->ntriangles*3*3*sizeof(float)); + mesh.texcoords = (float *)RL_MALLOC(cube->ntriangles*3*2*sizeof(float)); + mesh.normals = (float *)RL_MALLOC(cube->ntriangles*3*3*sizeof(float)); mesh.vertexCount = cube->ntriangles*3; mesh.triangleCount = cube->ntriangles; @@ -1539,9 +1539,9 @@ RLAPI Mesh GenMeshSphere(float radius, int rings, int slices) par_shapes_scale(sphere, radius, radius, radius); // NOTE: Soft normals are computed internally - mesh.vertices = (float *)malloc(sphere->ntriangles*3*3*sizeof(float)); - mesh.texcoords = (float *)malloc(sphere->ntriangles*3*2*sizeof(float)); - mesh.normals = (float *)malloc(sphere->ntriangles*3*3*sizeof(float)); + mesh.vertices = (float *)RL_MALLOC(sphere->ntriangles*3*3*sizeof(float)); + mesh.texcoords = (float *)RL_MALLOC(sphere->ntriangles*3*2*sizeof(float)); + mesh.normals = (float *)RL_MALLOC(sphere->ntriangles*3*3*sizeof(float)); mesh.vertexCount = sphere->ntriangles*3; mesh.triangleCount = sphere->ntriangles; @@ -1577,9 +1577,9 @@ RLAPI Mesh GenMeshHemiSphere(float radius, int rings, int slices) par_shapes_scale(sphere, radius, radius, radius); // NOTE: Soft normals are computed internally - mesh.vertices = (float *)malloc(sphere->ntriangles*3*3*sizeof(float)); - mesh.texcoords = (float *)malloc(sphere->ntriangles*3*2*sizeof(float)); - mesh.normals = (float *)malloc(sphere->ntriangles*3*3*sizeof(float)); + mesh.vertices = (float *)RL_MALLOC(sphere->ntriangles*3*3*sizeof(float)); + mesh.texcoords = (float *)RL_MALLOC(sphere->ntriangles*3*2*sizeof(float)); + mesh.normals = (float *)RL_MALLOC(sphere->ntriangles*3*3*sizeof(float)); mesh.vertexCount = sphere->ntriangles*3; mesh.triangleCount = sphere->ntriangles; @@ -1635,9 +1635,9 @@ Mesh GenMeshCylinder(float radius, float height, int slices) par_shapes_merge_and_free(cylinder, capTop); par_shapes_merge_and_free(cylinder, capBottom); - mesh.vertices = (float *)malloc(cylinder->ntriangles*3*3*sizeof(float)); - mesh.texcoords = (float *)malloc(cylinder->ntriangles*3*2*sizeof(float)); - mesh.normals = (float *)malloc(cylinder->ntriangles*3*3*sizeof(float)); + mesh.vertices = (float *)RL_MALLOC(cylinder->ntriangles*3*3*sizeof(float)); + mesh.texcoords = (float *)RL_MALLOC(cylinder->ntriangles*3*2*sizeof(float)); + mesh.normals = (float *)RL_MALLOC(cylinder->ntriangles*3*3*sizeof(float)); mesh.vertexCount = cylinder->ntriangles*3; mesh.triangleCount = cylinder->ntriangles; @@ -1677,9 +1677,9 @@ Mesh GenMeshTorus(float radius, float size, int radSeg, int sides) par_shapes_mesh *torus = par_shapes_create_torus(radSeg, sides, radius); par_shapes_scale(torus, size/2, size/2, size/2); - mesh.vertices = (float *)malloc(torus->ntriangles*3*3*sizeof(float)); - mesh.texcoords = (float *)malloc(torus->ntriangles*3*2*sizeof(float)); - mesh.normals = (float *)malloc(torus->ntriangles*3*3*sizeof(float)); + mesh.vertices = (float *)RL_MALLOC(torus->ntriangles*3*3*sizeof(float)); + mesh.texcoords = (float *)RL_MALLOC(torus->ntriangles*3*2*sizeof(float)); + mesh.normals = (float *)RL_MALLOC(torus->ntriangles*3*3*sizeof(float)); mesh.vertexCount = torus->ntriangles*3; mesh.triangleCount = torus->ntriangles; @@ -1717,9 +1717,9 @@ Mesh GenMeshKnot(float radius, float size, int radSeg, int sides) par_shapes_mesh *knot = par_shapes_create_trefoil_knot(radSeg, sides, radius); par_shapes_scale(knot, size, size, size); - mesh.vertices = (float *)malloc(knot->ntriangles*3*3*sizeof(float)); - mesh.texcoords = (float *)malloc(knot->ntriangles*3*2*sizeof(float)); - mesh.normals = (float *)malloc(knot->ntriangles*3*3*sizeof(float)); + mesh.vertices = (float *)RL_MALLOC(knot->ntriangles*3*3*sizeof(float)); + mesh.texcoords = (float *)RL_MALLOC(knot->ntriangles*3*2*sizeof(float)); + mesh.normals = (float *)RL_MALLOC(knot->ntriangles*3*3*sizeof(float)); mesh.vertexCount = knot->ntriangles*3; mesh.triangleCount = knot->ntriangles; @@ -1764,9 +1764,9 @@ Mesh GenMeshHeightmap(Image heightmap, Vector3 size) mesh.vertexCount = mesh.triangleCount*3; - mesh.vertices = (float *)malloc(mesh.vertexCount*3*sizeof(float)); - mesh.normals = (float *)malloc(mesh.vertexCount*3*sizeof(float)); - mesh.texcoords = (float *)malloc(mesh.vertexCount*2*sizeof(float)); + mesh.vertices = (float *)RL_MALLOC(mesh.vertexCount*3*sizeof(float)); + mesh.normals = (float *)RL_MALLOC(mesh.vertexCount*3*sizeof(float)); + mesh.texcoords = (float *)RL_MALLOC(mesh.vertexCount*2*sizeof(float)); mesh.colors = NULL; int vCounter = 0; // Used to count vertices float by float @@ -1848,7 +1848,7 @@ Mesh GenMeshHeightmap(Image heightmap, Vector3 size) } } - free(pixels); + RL_FREE(pixels); // Upload vertex data to GPU (static mesh) rlLoadMesh(&mesh, false); @@ -1878,9 +1878,9 @@ Mesh GenMeshCubicmap(Image cubicmap, Vector3 cubeSize) float h = cubeSize.z; float h2 = cubeSize.y; - Vector3 *mapVertices = (Vector3 *)malloc(maxTriangles*3*sizeof(Vector3)); - Vector2 *mapTexcoords = (Vector2 *)malloc(maxTriangles*3*sizeof(Vector2)); - Vector3 *mapNormals = (Vector3 *)malloc(maxTriangles*3*sizeof(Vector3)); + Vector3 *mapVertices = (Vector3 *)RL_MALLOC(maxTriangles*3*sizeof(Vector3)); + Vector2 *mapTexcoords = (Vector2 *)RL_MALLOC(maxTriangles*3*sizeof(Vector2)); + Vector3 *mapNormals = (Vector3 *)RL_MALLOC(maxTriangles*3*sizeof(Vector3)); // Define the 6 normals of the cube, we will combine them accordingly later... Vector3 n1 = { 1.0f, 0.0f, 0.0f }; @@ -2167,9 +2167,9 @@ Mesh GenMeshCubicmap(Image cubicmap, Vector3 cubeSize) mesh.vertexCount = vCounter; mesh.triangleCount = vCounter/3; - mesh.vertices = (float *)malloc(mesh.vertexCount*3*sizeof(float)); - mesh.normals = (float *)malloc(mesh.vertexCount*3*sizeof(float)); - mesh.texcoords = (float *)malloc(mesh.vertexCount*2*sizeof(float)); + mesh.vertices = (float *)RL_MALLOC(mesh.vertexCount*3*sizeof(float)); + mesh.normals = (float *)RL_MALLOC(mesh.vertexCount*3*sizeof(float)); + mesh.texcoords = (float *)RL_MALLOC(mesh.vertexCount*2*sizeof(float)); mesh.colors = NULL; int fCounter = 0; @@ -2204,11 +2204,11 @@ Mesh GenMeshCubicmap(Image cubicmap, Vector3 cubeSize) fCounter += 2; } - free(mapVertices); - free(mapNormals); - free(mapTexcoords); + RL_FREE(mapVertices); + RL_FREE(mapNormals); + RL_FREE(mapTexcoords); - free(cubicmapPixels); // Free image pixel data + RL_FREE(cubicmapPixels); // Free image pixel data // Upload vertex data to GPU (static mesh) rlLoadMesh(&mesh, false); @@ -2250,11 +2250,11 @@ BoundingBox MeshBoundingBox(Mesh mesh) // Implementation base don: https://answers.unity.com/questions/7789/calculating-tangents-vector4.html void MeshTangents(Mesh *mesh) { - if (mesh->tangents == NULL) mesh->tangents = (float *)malloc(mesh->vertexCount*4*sizeof(float)); + if (mesh->tangents == NULL) mesh->tangents = (float *)RL_MALLOC(mesh->vertexCount*4*sizeof(float)); else TraceLog(LOG_WARNING, "Mesh tangents already exist"); - Vector3 *tan1 = (Vector3 *)malloc(mesh->vertexCount*sizeof(Vector3)); - Vector3 *tan2 = (Vector3 *)malloc(mesh->vertexCount*sizeof(Vector3)); + Vector3 *tan1 = (Vector3 *)RL_MALLOC(mesh->vertexCount*sizeof(Vector3)); + Vector3 *tan2 = (Vector3 *)RL_MALLOC(mesh->vertexCount*sizeof(Vector3)); for (int i = 0; i < mesh->vertexCount; i += 3) { @@ -2318,8 +2318,8 @@ void MeshTangents(Mesh *mesh) #endif } - free(tan1); - free(tan2); + RL_FREE(tan1); + RL_FREE(tan2); // Load a new tangent attributes buffer mesh->vboId[LOC_VERTEX_TANGENT] = rlLoadAttribBuffer(mesh->vaoId, LOC_VERTEX_TANGENT, mesh->tangents, mesh->vertexCount*4*sizeof(float), false); @@ -2746,7 +2746,7 @@ static Model LoadOBJ(const char *fileName) long length = ftell(objFile); // Get file size fseek(objFile, 0, SEEK_SET); // Reset file pointer - data = (char *)malloc(length); + data = (char *)RL_MALLOC(length); fread(data, length, 1, objFile); dataLength = length; @@ -2763,12 +2763,12 @@ static Model LoadOBJ(const char *fileName) // Init model meshes array model.meshCount = meshCount; - model.meshes = (Mesh *)malloc(model.meshCount*sizeof(Mesh)); + model.meshes = (Mesh *)RL_MALLOC(model.meshCount*sizeof(Mesh)); // Init model materials array model.materialCount = materialCount; - model.materials = (Material *)malloc(model.materialCount*sizeof(Material)); - model.meshMaterial = (int *)calloc(model.meshCount, sizeof(int)); + model.materials = (Material *)RL_MALLOC(model.materialCount*sizeof(Material)); + model.meshMaterial = (int *)RL_CALLOC(model.meshCount, sizeof(int)); /* // Multiple meshes data reference @@ -2787,9 +2787,9 @@ static Model LoadOBJ(const char *fileName) memset(&mesh, 0, sizeof(Mesh)); mesh.vertexCount = attrib.num_faces*3; mesh.triangleCount = attrib.num_faces; - mesh.vertices = (float *)malloc(mesh.vertexCount*3*sizeof(float)); - mesh.texcoords = (float *)malloc(mesh.vertexCount*2*sizeof(float)); - mesh.normals = (float *)malloc(mesh.vertexCount*3*sizeof(float)); + mesh.vertices = (float *)RL_MALLOC(mesh.vertexCount*3*sizeof(float)); + mesh.texcoords = (float *)RL_MALLOC(mesh.vertexCount*2*sizeof(float)); + mesh.normals = (float *)RL_MALLOC(mesh.vertexCount*3*sizeof(float)); int vCount = 0; int vtCount = 0; @@ -2934,17 +2934,26 @@ static Model LoadIQM(const char *fileName) typedef struct IQMTriangle { unsigned int vertex[3]; } IQMTriangle; - - // NOTE: Adjacency unused by default - typedef struct IQMAdjacency { - unsigned int triangle[3]; - } IQMAdjacency; - + typedef struct IQMJoint { unsigned int name; int parent; float translate[3], rotate[4], scale[3]; } IQMJoint; + + typedef struct IQMVertexArray { + unsigned int type; + unsigned int flags; + unsigned int format; + unsigned int size; + unsigned int offset; + } IQMVertexArray; + + // NOTE: Below IQM structures are not used but listed for reference + /* + typedef struct IQMAdjacency { + unsigned int triangle[3]; + } IQMAdjacency; typedef struct IQMPose { int parent; @@ -2960,19 +2969,11 @@ static Model LoadIQM(const char *fileName) unsigned int flags; } IQMAnim; - typedef struct IQMVertexArray { - unsigned int type; - unsigned int flags; - unsigned int format; - unsigned int size; - unsigned int offset; - } IQMVertexArray; - - // NOTE: Bounds unused by default typedef struct IQMBounds { float bbmin[3], bbmax[3]; float xyradius, radius; } IQMBounds; + */ //----------------------------------------------------------------------------------- // IQM vertex data types @@ -3028,12 +3029,12 @@ static Model LoadIQM(const char *fileName) } // Meshes data processing - imesh = malloc(sizeof(IQMMesh)*iqm.num_meshes); + imesh = RL_MALLOC(sizeof(IQMMesh)*iqm.num_meshes); fseek(iqmFile, iqm.ofs_meshes, SEEK_SET); fread(imesh, sizeof(IQMMesh)*iqm.num_meshes, 1, iqmFile); model.meshCount = iqm.num_meshes; - model.meshes = malloc(model.meshCount*sizeof(Mesh)); + model.meshes = RL_MALLOC(model.meshCount*sizeof(Mesh)); char name[MESH_NAME_LENGTH]; @@ -3043,24 +3044,24 @@ static Model LoadIQM(const char *fileName) fread(name, sizeof(char)*MESH_NAME_LENGTH, 1, iqmFile); // Mesh name not used... model.meshes[i].vertexCount = imesh[i].num_vertexes; - model.meshes[i].vertices = malloc(sizeof(float)*model.meshes[i].vertexCount*3); // Default vertex positions - model.meshes[i].normals = malloc(sizeof(float)*model.meshes[i].vertexCount*3); // Default vertex normals - model.meshes[i].texcoords = malloc(sizeof(float)*model.meshes[i].vertexCount*2); // Default vertex texcoords + model.meshes[i].vertices = RL_MALLOC(sizeof(float)*model.meshes[i].vertexCount*3); // Default vertex positions + model.meshes[i].normals = RL_MALLOC(sizeof(float)*model.meshes[i].vertexCount*3); // Default vertex normals + model.meshes[i].texcoords = RL_MALLOC(sizeof(float)*model.meshes[i].vertexCount*2); // Default vertex texcoords - model.meshes[i].boneIds = malloc(sizeof(int)*model.meshes[i].vertexCount*4); // Up-to 4 bones supported! - model.meshes[i].boneWeights = malloc(sizeof(float)*model.meshes[i].vertexCount*4); // Up-to 4 bones supported! + model.meshes[i].boneIds = RL_MALLOC(sizeof(int)*model.meshes[i].vertexCount*4); // Up-to 4 bones supported! + model.meshes[i].boneWeights = RL_MALLOC(sizeof(float)*model.meshes[i].vertexCount*4); // Up-to 4 bones supported! model.meshes[i].triangleCount = imesh[i].num_triangles; - model.meshes[i].indices = malloc(sizeof(unsigned short)*model.meshes[i].triangleCount*3); + model.meshes[i].indices = RL_MALLOC(sizeof(unsigned short)*model.meshes[i].triangleCount*3); // Animated verted data, what we actually process for rendering // NOTE: Animated vertex should be re-uploaded to GPU (if not using GPU skinning) - model.meshes[i].animVertices = malloc(sizeof(float)*model.meshes[i].vertexCount*3); - model.meshes[i].animNormals = malloc(sizeof(float)*model.meshes[i].vertexCount*3); + model.meshes[i].animVertices = RL_MALLOC(sizeof(float)*model.meshes[i].vertexCount*3); + model.meshes[i].animNormals = RL_MALLOC(sizeof(float)*model.meshes[i].vertexCount*3); } // Triangles data processing - tri = malloc(sizeof(IQMTriangle)*iqm.num_triangles); + tri = RL_MALLOC(sizeof(IQMTriangle)*iqm.num_triangles); fseek(iqmFile, iqm.ofs_triangles, SEEK_SET); fread(tri, sizeof(IQMTriangle)*iqm.num_triangles, 1, iqmFile); @@ -3079,7 +3080,7 @@ static Model LoadIQM(const char *fileName) } // Vertex arrays data processing - va = malloc(sizeof(IQMVertexArray)*iqm.num_vertexarrays); + va = RL_MALLOC(sizeof(IQMVertexArray)*iqm.num_vertexarrays); fseek(iqmFile, iqm.ofs_vertexarrays, SEEK_SET); fread(va, sizeof(IQMVertexArray)*iqm.num_vertexarrays, 1, iqmFile); @@ -3089,7 +3090,7 @@ static Model LoadIQM(const char *fileName) { case IQM_POSITION: { - vertex = malloc(sizeof(float)*iqm.num_vertexes*3); + vertex = RL_MALLOC(sizeof(float)*iqm.num_vertexes*3); fseek(iqmFile, va[i].offset, SEEK_SET); fread(vertex, sizeof(float)*iqm.num_vertexes*3, 1, iqmFile); @@ -3106,7 +3107,7 @@ static Model LoadIQM(const char *fileName) } break; case IQM_NORMAL: { - normal = malloc(sizeof(float)*iqm.num_vertexes*3); + normal = RL_MALLOC(sizeof(float)*iqm.num_vertexes*3); fseek(iqmFile, va[i].offset, SEEK_SET); fread(normal, sizeof(float)*iqm.num_vertexes*3, 1, iqmFile); @@ -3123,7 +3124,7 @@ static Model LoadIQM(const char *fileName) } break; case IQM_TEXCOORD: { - text = malloc(sizeof(float)*iqm.num_vertexes*2); + text = RL_MALLOC(sizeof(float)*iqm.num_vertexes*2); fseek(iqmFile, va[i].offset, SEEK_SET); fread(text, sizeof(float)*iqm.num_vertexes*2, 1, iqmFile); @@ -3139,7 +3140,7 @@ static Model LoadIQM(const char *fileName) } break; case IQM_BLENDINDEXES: { - blendi = malloc(sizeof(char)*iqm.num_vertexes*4); + blendi = RL_MALLOC(sizeof(char)*iqm.num_vertexes*4); fseek(iqmFile, va[i].offset, SEEK_SET); fread(blendi, sizeof(char)*iqm.num_vertexes*4, 1, iqmFile); @@ -3155,7 +3156,7 @@ static Model LoadIQM(const char *fileName) } break; case IQM_BLENDWEIGHTS: { - blendw = malloc(sizeof(unsigned char)*iqm.num_vertexes*4); + blendw = RL_MALLOC(sizeof(unsigned char)*iqm.num_vertexes*4); fseek(iqmFile,va[i].offset,SEEK_SET); fread(blendw,sizeof(unsigned char)*iqm.num_vertexes*4,1,iqmFile); @@ -3173,13 +3174,13 @@ static Model LoadIQM(const char *fileName) } // Bones (joints) data processing - ijoint = malloc(sizeof(IQMJoint)*iqm.num_joints); + ijoint = RL_MALLOC(sizeof(IQMJoint)*iqm.num_joints); fseek(iqmFile, iqm.ofs_joints, SEEK_SET); fread(ijoint, sizeof(IQMJoint)*iqm.num_joints, 1, iqmFile); model.boneCount = iqm.num_joints; - model.bones = malloc(sizeof(BoneInfo)*iqm.num_joints); - model.bindPose = malloc(sizeof(Transform)*iqm.num_joints); + model.bones = RL_MALLOC(sizeof(BoneInfo)*iqm.num_joints); + model.bindPose = RL_MALLOC(sizeof(Transform)*iqm.num_joints); for (int i = 0; i < iqm.num_joints; i++) { @@ -3216,15 +3217,15 @@ static Model LoadIQM(const char *fileName) } fclose(iqmFile); - free(imesh); - free(tri); - free(va); - free(vertex); - free(normal); - free(text); - free(blendi); - free(blendw); - free(ijoint); + RL_FREE(imesh); + RL_FREE(tri); + RL_FREE(va); + RL_FREE(vertex); + RL_FREE(normal); + RL_FREE(text); + RL_FREE(blendi); + RL_FREE(blendw); + RL_FREE(ijoint); return model; } @@ -3249,7 +3250,7 @@ static Model LoadGLTF(const char *fileName) int size = ftell(gltfFile); fseek(gltfFile, 0, SEEK_SET); - void *buffer = malloc(size); + void *buffer = RL_MALLOC(size); fread(buffer, size, 1, gltfFile); fclose(gltfFile); @@ -3259,7 +3260,7 @@ static Model LoadGLTF(const char *fileName) cgltf_data *data; cgltf_result result = cgltf_parse(&options, buffer, size, &data); - free(buffer); + RL_FREE(buffer); if (result == cgltf_result_success) { @@ -3270,7 +3271,7 @@ static Model LoadGLTF(const char *fileName) // Process glTF data and map to model model.meshCount = data->meshes_count; - model.meshes = malloc(model.meshCount*sizeof(Mesh)); + model.meshes = RL_MALLOC(model.meshCount*sizeof(Mesh)); for (int i = 0; i < model.meshCount; i++) { @@ -3282,11 +3283,11 @@ static Model LoadGLTF(const char *fileName) model.meshes[i].triangleCount = data->meshes[i].primitives_count; // data.meshes[i].weights not used (array of weights to be applied to the Morph Targets) - model.meshes[i].vertices = malloc(sizeof(float)*model.meshes[i].vertexCount*3); // Default vertex positions - model.meshes[i].normals = malloc(sizeof(float)*model.meshes[i].vertexCount*3); // Default vertex normals - model.meshes[i].texcoords = malloc(sizeof(float)*model.meshes[i].vertexCount*2); // Default vertex texcoords + model.meshes[i].vertices = RL_MALLOC(sizeof(float)*model.meshes[i].vertexCount*3); // Default vertex positions + model.meshes[i].normals = RL_MALLOC(sizeof(float)*model.meshes[i].vertexCount*3); // Default vertex normals + model.meshes[i].texcoords = RL_MALLOC(sizeof(float)*model.meshes[i].vertexCount*2); // Default vertex texcoords - model.meshes[i].indices = malloc(sizeof(unsigned short)*model.meshes[i].triangleCount*3); + model.meshes[i].indices = RL_MALLOC(sizeof(unsigned short)*model.meshes[i].triangleCount*3); } } diff --git a/src/raudio.c b/src/raudio.c index 636d15b8..9108a903 100644 --- a/src/raudio.c +++ b/src/raudio.c @@ -567,7 +567,7 @@ void SetMasterVolume(float volume) // Create a new audio buffer. Initially filled with silence AudioBuffer *CreateAudioBuffer(ma_format format, ma_uint32 channels, ma_uint32 sampleRate, ma_uint32 bufferSizeInFrames, AudioBufferUsage usage) { - AudioBuffer *audioBuffer = (AudioBuffer *)calloc(sizeof(*audioBuffer) + (bufferSizeInFrames*channels*ma_get_bytes_per_sample(format)), 1); + AudioBuffer *audioBuffer = (AudioBuffer *)RL_CALLOC(sizeof(*audioBuffer) + (bufferSizeInFrames*channels*ma_get_bytes_per_sample(format)), 1); if (audioBuffer == NULL) { TraceLog(LOG_ERROR, "CreateAudioBuffer() : Failed to allocate memory for audio buffer"); @@ -591,7 +591,7 @@ AudioBuffer *CreateAudioBuffer(ma_format format, ma_uint32 channels, ma_uint32 s if (result != MA_SUCCESS) { TraceLog(LOG_ERROR, "CreateAudioBuffer() : Failed to create data conversion pipeline"); - free(audioBuffer); + RL_FREE(audioBuffer); return NULL; } @@ -623,7 +623,7 @@ void DeleteAudioBuffer(AudioBuffer *audioBuffer) } UntrackAudioBuffer(audioBuffer); - free(audioBuffer); + RL_FREE(audioBuffer); } // Check if an audio buffer is playing @@ -863,7 +863,7 @@ Sound LoadSoundFromWave(Wave wave) // Unload wave data void UnloadWave(Wave wave) { - if (wave.data != NULL) free(wave.data); + if (wave.data != NULL) RL_FREE(wave.data); TraceLog(LOG_INFO, "Unloaded wave data from RAM"); } @@ -1017,7 +1017,7 @@ void WaveFormat(Wave *wave, int sampleRate, int sampleSize, int channels) return; } - void *data = malloc(frameCount*channels*(sampleSize/8)); + void *data = RL_MALLOC(frameCount*channels*(sampleSize/8)); frameCount = (ma_uint32)ma_convert_frames(data, formatOut, channels, sampleRate, wave->data, formatIn, wave->channels, wave->sampleRate, frameCountIn); if (frameCount == 0) @@ -1030,7 +1030,7 @@ void WaveFormat(Wave *wave, int sampleRate, int sampleSize, int channels) wave->sampleSize = sampleSize; wave->sampleRate = sampleRate; wave->channels = channels; - free(wave->data); + RL_FREE(wave->data); wave->data = data; } @@ -1039,7 +1039,7 @@ Wave WaveCopy(Wave wave) { Wave newWave = { 0 }; - newWave.data = malloc(wave.sampleCount*wave.sampleSize/8*wave.channels); + newWave.data = RL_MALLOC(wave.sampleCount*wave.sampleSize/8*wave.channels); if (newWave.data != NULL) { @@ -1064,11 +1064,11 @@ void WaveCrop(Wave *wave, int initSample, int finalSample) { int sampleCount = finalSample - initSample; - void *data = malloc(sampleCount*wave->sampleSize/8*wave->channels); + void *data = RL_MALLOC(sampleCount*wave->sampleSize/8*wave->channels); memcpy(data, (unsigned char *)wave->data + (initSample*wave->channels*wave->sampleSize/8), sampleCount*wave->channels*wave->sampleSize/8); - free(wave->data); + RL_FREE(wave->data); wave->data = data; } else TraceLog(LOG_WARNING, "Wave crop range out of bounds"); @@ -1078,7 +1078,7 @@ void WaveCrop(Wave *wave, int initSample, int finalSample) // NOTE: Returned sample values are normalized to range [-1..1] float *GetWaveData(Wave wave) { - float *samples = (float *)malloc(wave.sampleCount*wave.channels*sizeof(float)); + float *samples = (float *)RL_MALLOC(wave.sampleCount*wave.channels*sizeof(float)); for (unsigned int i = 0; i < wave.sampleCount; i++) { @@ -1100,7 +1100,7 @@ float *GetWaveData(Wave wave) // Load music stream from file Music LoadMusicStream(const char *fileName) { - Music music = (MusicData *)malloc(sizeof(MusicData)); + Music music = (MusicData *)RL_MALLOC(sizeof(MusicData)); bool musicLoaded = true; #if defined(SUPPORT_FILEFORMAT_OGG) @@ -1228,7 +1228,7 @@ Music LoadMusicStream(const char *fileName) if (false) {} #endif #if defined(SUPPORT_FILEFORMAT_FLAC) - else if (music->ctxType == MUSIC_AUDIO_FLAC) drflac_free(music->ctxFlac); + else if (music->ctxType == MUSIC_AUDIO_FLAC) drflac_RL_FREE(music->ctxFlac); #endif #if defined(SUPPORT_FILEFORMAT_MP3) else if (music->ctxType == MUSIC_AUDIO_MP3) drmp3_uninit(&music->ctxMp3); @@ -1240,7 +1240,7 @@ Music LoadMusicStream(const char *fileName) else if (music->ctxType == MUSIC_MODULE_MOD) jar_mod_unload(&music->ctxMod); #endif - free(music); + RL_FREE(music); music = NULL; TraceLog(LOG_WARNING, "[%s] Music file could not be opened", fileName); @@ -1262,7 +1262,7 @@ void UnloadMusicStream(Music music) if (false) {} #endif #if defined(SUPPORT_FILEFORMAT_FLAC) - else if (music->ctxType == MUSIC_AUDIO_FLAC) drflac_free(music->ctxFlac); + else if (music->ctxType == MUSIC_AUDIO_FLAC) drflac_RL_FREE(music->ctxFlac); #endif #if defined(SUPPORT_FILEFORMAT_MP3) else if (music->ctxType == MUSIC_AUDIO_MP3) drmp3_uninit(&music->ctxMp3); @@ -1274,7 +1274,7 @@ void UnloadMusicStream(Music music) else if (music->ctxType == MUSIC_MODULE_MOD) jar_mod_unload(&music->ctxMod); #endif - free(music); + RL_FREE(music); } // Start music playing (open stream) @@ -1357,7 +1357,7 @@ void UpdateMusicStream(Music music) unsigned int subBufferSizeInFrames = ((AudioBuffer *)music->stream.audioBuffer)->bufferSizeInFrames/2; // NOTE: Using dynamic allocation because it could require more than 16KB - void *pcm = calloc(subBufferSizeInFrames*music->stream.channels*music->stream.sampleSize/8, 1); + void *pcm = RL_CALLOC(subBufferSizeInFrames*music->stream.channels*music->stream.sampleSize/8, 1); int samplesCount = 0; // Total size of data steamed in L+R samples for xm floats, individual L or R for ogg shorts @@ -1427,7 +1427,7 @@ void UpdateMusicStream(Music music) } // Free allocated pcm data - free(pcm); + RL_FREE(pcm); // Reset audio stream for looping if (streamEnding) @@ -1750,7 +1750,7 @@ static Wave LoadWAV(const char *fileName) else { // Allocate memory for data - wave.data = malloc(wavData.subChunkSize); + wave.data = RL_MALLOC(wavData.subChunkSize); // Read in the sound data into the soundData variable fread(wave.data, wavData.subChunkSize, 1, wavFile); @@ -1891,7 +1891,7 @@ static Wave LoadOGG(const char *fileName) float totalSeconds = stb_vorbis_stream_length_in_seconds(oggFile); 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)); + wave.data = (short *)RL_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); diff --git a/src/raudio.h b/src/raudio.h index e8701814..f71a3083 100644 --- a/src/raudio.h +++ b/src/raudio.h @@ -56,7 +56,16 @@ //---------------------------------------------------------------------------------- // Defines and Macros //---------------------------------------------------------------------------------- -//... +// Allow custom memory allocators +#ifndef RL_MALLOC + #define RL_MALLOC(sz) malloc(sz) +#endif +#ifndef RL_CALLOC + #define RL_CALLOC(n,sz) calloc(n,sz) +#endif +#ifndef RL_FREE + #define RL_FREE(p) free(p) +#endif //---------------------------------------------------------------------------------- // Types and Structures Definition diff --git a/src/raylib.h b/src/raylib.h index 424a9dd7..43260e06 100644 --- a/src/raylib.h +++ b/src/raylib.h @@ -99,6 +99,17 @@ // Shader and material limits #define MAX_SHADER_LOCATIONS 32 // Maximum number of predefined locations stored in shader struct #define MAX_MATERIAL_MAPS 12 // Maximum number of texture maps stored in shader struct + +// Allow custom memory allocators +#ifndef RL_MALLOC + #define RL_MALLOC(sz) malloc(sz) +#endif +#ifndef RL_CALLOC + #define RL_CALLOC(n,sz) calloc(n,sz) +#endif +#ifndef RL_FREE + #define RL_FREE(p) free(p) +#endif // NOTE: MSC C++ compiler does not support compound literals (C99 feature) // Plain structures in C++ (without constructors) can be initialized from { } initializers. diff --git a/src/rlgl.h b/src/rlgl.h index 0356858a..c2ddd028 100644 --- a/src/rlgl.h +++ b/src/rlgl.h @@ -1492,7 +1492,7 @@ void rlglInit(int width, int height) glGetIntegerv(GL_NUM_EXTENSIONS, &numExt); #if defined(_MSC_VER) - const char **extList = malloc(sizeof(const char *)*numExt); + const char **extList = RL_MALLOC(sizeof(const char *)*numExt); #else const char *extList[numExt]; #endif @@ -1504,7 +1504,7 @@ void rlglInit(int width, int height) // NOTE: We have to duplicate string because glGetString() returns a const string int len = strlen(extensions) + 1; - char *extensionsDup = (char *)malloc(len); + char *extensionsDup = (char *)RL_MALLOC(len); strcpy(extensionsDup, extensions); // NOTE: String could be splitted using strtok() function (string.h) @@ -1520,7 +1520,7 @@ void rlglInit(int width, int height) extList[numExt] = strtok(NULL, " "); } - free(extensionsDup); // Duplicated string must be deallocated + RL_FREE(extensionsDup); // Duplicated string must be deallocated numExt -= 1; #endif @@ -1595,7 +1595,7 @@ void rlglInit(int width, int height) } #if defined(_WIN32) && defined(_MSC_VER) - free(extList); + RL_FREE(extList); #endif #if defined(GRAPHICS_API_OPENGL_ES2) @@ -1640,7 +1640,7 @@ void rlglInit(int width, int height) transformMatrix = MatrixIdentity(); // Init draw calls tracking system - draws = (DrawCall *)malloc(sizeof(DrawCall)*MAX_DRAWCALL_REGISTERED); + draws = (DrawCall *)RL_MALLOC(sizeof(DrawCall)*MAX_DRAWCALL_REGISTERED); for (int i = 0; i < MAX_DRAWCALL_REGISTERED; i++) { @@ -1710,7 +1710,7 @@ void rlglClose(void) TraceLog(LOG_INFO, "[TEX ID %i] Unloaded texture data (base white texture) from VRAM", defaultTextureId); - free(draws); + RL_FREE(draws); #endif } @@ -2300,7 +2300,7 @@ void rlGenerateMipmaps(Texture2D *texture) } texture->mipmaps = mipmapCount + 1; - free(data); // Once mipmaps have been generated and data has been uploaded to GPU VRAM, we can discard RAM data + RL_FREE(data); // Once mipmaps have been generated and data has been uploaded to GPU VRAM, we can discard RAM data TraceLog(LOG_WARNING, "[TEX ID %i] Mipmaps [%i] generated manually on CPU side", texture->id, texture->mipmaps); } @@ -2735,18 +2735,18 @@ void rlDrawMesh(Mesh mesh, Material material, Matrix transform) // Unload mesh data from CPU and GPU void rlUnloadMesh(Mesh *mesh) { - free(mesh->vertices); - free(mesh->texcoords); - free(mesh->normals); - free(mesh->colors); - free(mesh->tangents); - free(mesh->texcoords2); - free(mesh->indices); - - free(mesh->animVertices); - free(mesh->animNormals); - free(mesh->boneWeights); - free(mesh->boneIds); + RL_FREE(mesh->vertices); + RL_FREE(mesh->texcoords); + RL_FREE(mesh->normals); + RL_FREE(mesh->colors); + RL_FREE(mesh->tangents); + RL_FREE(mesh->texcoords2); + RL_FREE(mesh->indices); + + RL_FREE(mesh->animVertices); + RL_FREE(mesh->animNormals); + RL_FREE(mesh->boneWeights); + RL_FREE(mesh->boneIds); rlDeleteBuffers(mesh->vboId[0]); // vertex rlDeleteBuffers(mesh->vboId[1]); // texcoords @@ -2762,14 +2762,14 @@ void rlUnloadMesh(Mesh *mesh) // Read screen pixel data (color buffer) unsigned char *rlReadScreenPixels(int width, int height) { - unsigned char *screenData = (unsigned char *)calloc(width*height*4, sizeof(unsigned char)); + unsigned char *screenData = (unsigned char *)RL_CALLOC(width*height*4, sizeof(unsigned char)); // NOTE 1: glReadPixels returns image flipped vertically -> (0,0) is the bottom left corner of the framebuffer // NOTE 2: We are getting alpha channel! Be careful, it can be transparent if not cleared properly! glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, screenData); // Flip image vertically! - unsigned char *imgData = (unsigned char *)malloc(width*height*sizeof(unsigned char)*4); + unsigned char *imgData = (unsigned char *)RL_MALLOC(width*height*sizeof(unsigned char)*4); for (int y = height - 1; y >= 0; y--) { @@ -2783,7 +2783,7 @@ unsigned char *rlReadScreenPixels(int width, int height) } } - free(screenData); + RL_FREE(screenData); return imgData; // NOTE: image data should be freed } @@ -2815,7 +2815,7 @@ void *rlReadTexturePixels(Texture2D texture) if ((glInternalFormat != -1) && (texture.format < COMPRESSED_DXT1_RGB)) { - pixels = (unsigned char *)malloc(size); + pixels = (unsigned char *)RL_MALLOC(size); glGetTexImage(GL_TEXTURE_2D, 0, glFormat, glType, pixels); } else TraceLog(LOG_WARNING, "Texture data retrieval not suported for pixel format"); @@ -2841,7 +2841,7 @@ void *rlReadTexturePixels(Texture2D texture) glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture.id, 0); // Allocate enough memory to read back our texture data - pixels = (unsigned char *)malloc(GetPixelDataSize(texture.width, texture.height, texture.format)); + pixels = (unsigned char *)RL_MALLOC(GetPixelDataSize(texture.width, texture.height, texture.format)); // Get OpenGL internal formats and data type from our texture format unsigned int glInternalFormat, glFormat, glType; @@ -2911,7 +2911,7 @@ char *LoadText(const char *fileName) if (size > 0) { - text = (char *)malloc(sizeof(char)*(size + 1)); + text = (char *)RL_MALLOC(sizeof(char)*(size + 1)); int count = fread(text, sizeof(char), size, textFile); text[count] = '\0'; } @@ -2938,8 +2938,8 @@ Shader LoadShader(const char *vsFileName, const char *fsFileName) shader = LoadShaderCode(vShaderStr, fShaderStr); - if (vShaderStr != NULL) free(vShaderStr); - if (fShaderStr != NULL) free(fShaderStr); + if (vShaderStr != NULL) RL_FREE(vShaderStr); + if (fShaderStr != NULL) RL_FREE(fShaderStr); return shader; } @@ -3758,7 +3758,7 @@ static unsigned int CompileShader(const char *shaderStr, int type) glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &maxLength); #if defined(_MSC_VER) - char *log = malloc(maxLength); + char *log = RL_MALLOC(maxLength); #else char log[maxLength]; #endif @@ -3767,7 +3767,7 @@ static unsigned int CompileShader(const char *shaderStr, int type) TraceLog(LOG_INFO, "%s", log); #if defined(_MSC_VER) - free(log); + RL_FREE(log); #endif } else TraceLog(LOG_INFO, "[SHDR ID %i] Shader compiled successfully", shader); @@ -3814,7 +3814,7 @@ static unsigned int LoadShaderProgram(unsigned int vShaderId, unsigned int fShad glGetProgramiv(program, GL_INFO_LOG_LENGTH, &maxLength); #if defined(_MSC_VER) - char *log = malloc(maxLength); + char *log = RL_MALLOC(maxLength); #else char log[maxLength]; #endif @@ -3823,7 +3823,7 @@ static unsigned int LoadShaderProgram(unsigned int vShaderId, unsigned int fShad TraceLog(LOG_INFO, "%s", log); #if defined(_MSC_VER) - free(log); + RL_FREE(log); #endif glDeleteProgram(program); @@ -3984,13 +3984,13 @@ static void LoadBuffersDefault(void) //-------------------------------------------------------------------------------------------- for (int i = 0; i < MAX_BATCH_BUFFERING; i++) { - vertexData[i].vertices = (float *)malloc(sizeof(float)*3*4*MAX_BATCH_ELEMENTS); // 3 float by vertex, 4 vertex by quad - vertexData[i].texcoords = (float *)malloc(sizeof(float)*2*4*MAX_BATCH_ELEMENTS); // 2 float by texcoord, 4 texcoord by quad - vertexData[i].colors = (unsigned char *)malloc(sizeof(unsigned char)*4*4*MAX_BATCH_ELEMENTS); // 4 float by color, 4 colors by quad + vertexData[i].vertices = (float *)RL_MALLOC(sizeof(float)*3*4*MAX_BATCH_ELEMENTS); // 3 float by vertex, 4 vertex by quad + vertexData[i].texcoords = (float *)RL_MALLOC(sizeof(float)*2*4*MAX_BATCH_ELEMENTS); // 2 float by texcoord, 4 texcoord by quad + vertexData[i].colors = (unsigned char *)RL_MALLOC(sizeof(unsigned char)*4*4*MAX_BATCH_ELEMENTS); // 4 float by color, 4 colors by quad #if defined(GRAPHICS_API_OPENGL_33) - vertexData[i].indices = (unsigned int *)malloc(sizeof(unsigned int)*6*MAX_BATCH_ELEMENTS); // 6 int by quad (indices) + vertexData[i].indices = (unsigned int *)RL_MALLOC(sizeof(unsigned int)*6*MAX_BATCH_ELEMENTS); // 6 int by quad (indices) #elif defined(GRAPHICS_API_OPENGL_ES2) - vertexData[i].indices = (unsigned short *)malloc(sizeof(unsigned short)*6*MAX_BATCH_ELEMENTS); // 6 int by quad (indices) + vertexData[i].indices = (unsigned short *)RL_MALLOC(sizeof(unsigned short)*6*MAX_BATCH_ELEMENTS); // 6 int by quad (indices) #endif for (int j = 0; j < (3*4*MAX_BATCH_ELEMENTS); j++) vertexData[i].vertices[j] = 0.0f; @@ -4266,10 +4266,10 @@ static void UnloadBuffersDefault(void) if (vaoSupported) glDeleteVertexArrays(1, &vertexData[i].vaoId); // Free vertex arrays memory from CPU (RAM) - free(vertexData[i].vertices); - free(vertexData[i].texcoords); - free(vertexData[i].colors); - free(vertexData[i].indices); + RL_FREE(vertexData[i].vertices); + RL_FREE(vertexData[i].texcoords); + RL_FREE(vertexData[i].colors); + RL_FREE(vertexData[i].indices); } } @@ -4444,7 +4444,7 @@ static int GenerateMipmaps(unsigned char *data, int baseWidth, int baseHeight) // Generate mipmaps // NOTE: Every mipmap data is stored after data - Color *image = (Color *)malloc(width*height*sizeof(Color)); + Color *image = (Color *)RL_MALLOC(width*height*sizeof(Color)); Color *mipmap = NULL; int offset = 0; int j = 0; @@ -4481,13 +4481,13 @@ static int GenerateMipmaps(unsigned char *data, int baseWidth, int baseHeight) j++; } - free(image); + RL_FREE(image); image = mipmap; mipmap = NULL; } - free(mipmap); // free mipmap data + RL_FREE(mipmap); // free mipmap data return mipmapCount; } @@ -4501,7 +4501,7 @@ static Color *GenNextMipmap(Color *srcData, int srcWidth, int srcHeight) int width = srcWidth/2; int height = srcHeight/2; - Color *mipmap = (Color *)malloc(width*height*sizeof(Color)); + Color *mipmap = (Color *)RL_MALLOC(width*height*sizeof(Color)); // Scaling algorithm works perfectly (box-filter) for (int y = 0; y < height; y++) diff --git a/src/text.c b/src/text.c index bd9e09f0..22bd7659 100644 --- a/src/text.c +++ b/src/text.c @@ -174,7 +174,7 @@ extern void LoadDefaultFont(void) int imWidth = 128; int imHeight = 128; - Color *imagePixels = (Color *)malloc(imWidth*imHeight*sizeof(Color)); + Color *imagePixels = (Color *)RL_MALLOC(imWidth*imHeight*sizeof(Color)); for (int i = 0; i < imWidth*imHeight; i++) imagePixels[i] = BLANK; // Initialize array @@ -196,7 +196,7 @@ extern void LoadDefaultFont(void) Image image = LoadImageEx(imagePixels, imWidth, imHeight); ImageFormat(&image, UNCOMPRESSED_GRAY_ALPHA); - free(imagePixels); + RL_FREE(imagePixels); defaultFont.texture = LoadTextureFromImage(image); UnloadImage(image); @@ -206,7 +206,7 @@ extern void LoadDefaultFont(void) // Allocate space for our characters info data // NOTE: This memory should be freed at end! --> CloseWindow() - defaultFont.chars = (CharInfo *)malloc(defaultFont.charsCount*sizeof(CharInfo)); + defaultFont.chars = (CharInfo *)RL_MALLOC(defaultFont.charsCount*sizeof(CharInfo)); int currentLine = 0; int currentPosX = charsDivisor; @@ -249,7 +249,7 @@ extern void LoadDefaultFont(void) extern void UnloadDefaultFont(void) { UnloadTexture(defaultFont.texture); - free(defaultFont.chars); + RL_FREE(defaultFont.chars); } #endif // SUPPORT_DEFAULT_FONT @@ -407,7 +407,7 @@ Font LoadFontFromImage(Image image, Color key, int firstChar) // Create a new image with the processed color data (key color replaced by BLANK) Image fontClear = LoadImageEx(pixels, image.width, image.height); - free(pixels); // Free pixels array memory + RL_FREE(pixels); // Free pixels array memory // Create spritefont with all data parsed from image Font spriteFont = { 0 }; @@ -419,7 +419,7 @@ Font LoadFontFromImage(Image image, Color key, int firstChar) // We got tempCharValues and tempCharsRecs populated with chars data // Now we move temp data to sized charValues and charRecs arrays - spriteFont.chars = (CharInfo *)malloc(spriteFont.charsCount*sizeof(CharInfo)); + spriteFont.chars = (CharInfo *)RL_MALLOC(spriteFont.charsCount*sizeof(CharInfo)); for (int i = 0; i < spriteFont.charsCount; i++) { @@ -466,7 +466,7 @@ CharInfo *LoadFontData(const char *fileName, int fontSize, int *fontChars, int c long size = ftell(fontFile); // Get file size fseek(fontFile, 0, SEEK_SET); // Reset file pointer - unsigned char *fontBuffer = (unsigned char *)malloc(size); + unsigned char *fontBuffer = (unsigned char *)RL_MALLOC(size); fread(fontBuffer, size, 1, fontFile); fclose(fontFile); @@ -491,12 +491,12 @@ CharInfo *LoadFontData(const char *fileName, int fontSize, int *fontChars, int c int genFontChars = false; if (fontChars == NULL) { - fontChars = (int *)malloc(charsCount*sizeof(int)); + fontChars = (int *)RL_MALLOC(charsCount*sizeof(int)); for (int i = 0; i < charsCount; i++) fontChars[i] = i + 32; genFontChars = true; } - chars = (CharInfo *)malloc(charsCount*sizeof(CharInfo)); + chars = (CharInfo *)RL_MALLOC(charsCount*sizeof(CharInfo)); // NOTE: Using simple packaging, one char after another for (int i = 0; i < charsCount; i++) @@ -540,8 +540,8 @@ CharInfo *LoadFontData(const char *fileName, int fontSize, int *fontChars, int c chars[i].advanceX *= scaleFactor; } - free(fontBuffer); - if (genFontChars) free(fontChars); + RL_FREE(fontBuffer); + if (genFontChars) RL_FREE(fontChars); } else TraceLog(LOG_WARNING, "[%s] TTF file could not be opened", fileName); #else @@ -572,7 +572,7 @@ Image GenImageFontAtlas(CharInfo *chars, int charsCount, int fontSize, int paddi atlas.width = imageSize; // Atlas bitmap width atlas.height = imageSize; // Atlas bitmap height - atlas.data = (unsigned char *)calloc(1, atlas.width*atlas.height); // Create a bitmap to store characters (8 bpp) + atlas.data = (unsigned char *)RL_CALLOC(1, atlas.width*atlas.height); // Create a bitmap to store characters (8 bpp) atlas.format = UNCOMPRESSED_GRAYSCALE; atlas.mipmaps = 1; @@ -619,11 +619,11 @@ Image GenImageFontAtlas(CharInfo *chars, int charsCount, int fontSize, int paddi { TraceLog(LOG_DEBUG, "Using Skyline packing algorythm!"); - stbrp_context *context = (stbrp_context *)malloc(sizeof(*context)); - stbrp_node *nodes = (stbrp_node *)malloc(charsCount*sizeof(*nodes)); + stbrp_context *context = (stbrp_context *)RL_MALLOC(sizeof(*context)); + stbrp_node *nodes = (stbrp_node *)RL_MALLOC(charsCount*sizeof(*nodes)); stbrp_init_target(context, atlas.width, atlas.height, nodes, charsCount); - stbrp_rect *rects = (stbrp_rect *)malloc(charsCount*sizeof(stbrp_rect)); + stbrp_rect *rects = (stbrp_rect *)RL_MALLOC(charsCount*sizeof(stbrp_rect)); // Fill rectangles for packaging for (int i = 0; i < charsCount; i++) @@ -655,16 +655,16 @@ Image GenImageFontAtlas(CharInfo *chars, int charsCount, int fontSize, int paddi else TraceLog(LOG_WARNING, "Character could not be packed: %i", i); } - free(rects); - free(nodes); - free(context); + RL_FREE(rects); + RL_FREE(nodes); + RL_FREE(context); } // TODO: Crop image if required for smaller size // Convert image data from GRAYSCALE to GRAY_ALPHA // WARNING: ImageAlphaMask(&atlas, atlas) does not work in this case, requires manual operation - unsigned char *dataGrayAlpha = (unsigned char *)malloc(imageSize*imageSize*sizeof(unsigned char)*2); // Two channels + unsigned char *dataGrayAlpha = (unsigned char *)RL_MALLOC(imageSize*imageSize*sizeof(unsigned char)*2); // Two channels for (int i = 0, k = 0; i < atlas.width*atlas.height; i++, k += 2) { @@ -672,7 +672,7 @@ Image GenImageFontAtlas(CharInfo *chars, int charsCount, int fontSize, int paddi dataGrayAlpha[k + 1] = ((unsigned char *)atlas.data)[i]; } - free(atlas.data); + RL_FREE(atlas.data); atlas.data = dataGrayAlpha; atlas.format = UNCOMPRESSED_GRAY_ALPHA; @@ -688,10 +688,10 @@ void UnloadFont(Font font) { for (int i = 0; i < font.charsCount; i++) { - free(font.chars[i].data); + RL_FREE(font.chars[i].data); } UnloadTexture(font.texture); - free(font.chars); + RL_FREE(font.chars); TraceLog(LOG_DEBUG, "Unloaded sprite font data"); } @@ -1214,7 +1214,7 @@ const char *TextReplace(char *text, const char *replace, const char *by) for (count = 0; (temp = strstr(insertPoint, replace)); count++) insertPoint = temp + replaceLen; // Allocate returning string and point temp to it - temp = result = malloc(strlen(text) + (byLen - replaceLen)*count + 1); + temp = result = RL_MALLOC(strlen(text) + (byLen - replaceLen)*count + 1); if (!result) return NULL; // Memory could not be allocated @@ -1245,7 +1245,7 @@ const char *TextInsert(const char *text, const char *insert, int position) int textLen = strlen(text); int insertLen = strlen(insert); - char *result = (char *)malloc(textLen + insertLen + 1); + char *result = (char *)RL_MALLOC(textLen + insertLen + 1); for (int i = 0; i < position; i++) result[i] = text[i]; for (int i = position; i < insertLen + position; i++) result[i] = insert[i]; @@ -1477,7 +1477,7 @@ static Font LoadBMFont(const char *fileName) } // NOTE: We need some extra space to avoid memory corruption on next allocations! - texPath = malloc(strlen(fileName) - strlen(lastSlash) + strlen(texFileName) + 4); + texPath = RL_MALLOC(strlen(fileName) - strlen(lastSlash) + strlen(texFileName) + 4); // NOTE: strcat() and strncat() required a '\0' terminated string to work! *texPath = '\0'; @@ -1501,13 +1501,13 @@ static Font LoadBMFont(const char *fileName) else font.texture = LoadTextureFromImage(imFont); UnloadImage(imFont); - free(texPath); + RL_FREE(texPath); // Fill font characters info data font.baseSize = fontSize; font.charsCount = charsCount; - font.chars = (CharInfo *)malloc(charsCount*sizeof(CharInfo)); + font.chars = (CharInfo *)RL_MALLOC(charsCount*sizeof(CharInfo)); int charId, charX, charY, charWidth, charHeight, charOffsetX, charOffsetY, charAdvanceX; diff --git a/src/textures.c b/src/textures.c index 7059fabb..eb743026 100644 --- a/src/textures.c +++ b/src/textures.c @@ -112,9 +112,14 @@ defined(SUPPORT_FILEFORMAT_GIF) || \ defined(SUPPORT_FILEFORMAT_PIC) || \ defined(SUPPORT_FILEFORMAT_HDR)) + + #define STBI_MALLOC RL_MALLOC + #define STBI_FREE RL_FREE + #define STBI_REALLOC(p,newsz) realloc(p,newsz) + #define STB_IMAGE_IMPLEMENTATION - #include "external/stb_image.h" // Required for: stbi_load_from_file() - // NOTE: Used to read image data (multiple formats support) + #include "external/stb_image.h" // Required for: stbi_load_from_file() + // NOTE: Used to read image data (multiple formats support) #endif #if defined(SUPPORT_IMAGE_EXPORT) @@ -305,7 +310,7 @@ Image LoadImageEx(Color *pixels, int width, int height) int k = 0; - image.data = (unsigned char *)malloc(image.width*image.height*4*sizeof(unsigned char)); + image.data = (unsigned char *)RL_MALLOC(image.width*image.height*4*sizeof(unsigned char)); for (int i = 0; i < image.width*image.height*4; i += 4) { @@ -353,7 +358,7 @@ Image LoadImageRaw(const char *fileName, int width, int height, int format, int unsigned int size = GetPixelDataSize(width, height, format); - image.data = malloc(size); // Allocate required memory in bytes + image.data = RL_MALLOC(size); // Allocate required memory in bytes // NOTE: fread() returns num read elements instead of bytes, // to get bytes we need to read (1 byte size, elements) instead of (x byte size, 1 element) @@ -364,7 +369,7 @@ Image LoadImageRaw(const char *fileName, int width, int height, int format, int { TraceLog(LOG_WARNING, "[%s] RAW image data can not be read, wrong requested format or size", fileName); - free(image.data); + RL_FREE(image.data); } else { @@ -425,7 +430,7 @@ RenderTexture2D LoadRenderTexture(int width, int height) // Unload image from CPU memory (RAM) void UnloadImage(Image image) { - free(image.data); + RL_FREE(image.data); } // Unload texture from GPU memory (VRAM) @@ -448,7 +453,7 @@ void UnloadRenderTexture(RenderTexture2D target) // Get pixel data from image in the form of Color struct array Color *GetImageData(Image image) { - Color *pixels = (Color *)malloc(image.width*image.height*sizeof(Color)); + Color *pixels = (Color *)RL_MALLOC(image.width*image.height*sizeof(Color)); if (image.format >= COMPRESSED_DXT1_RGB) TraceLog(LOG_WARNING, "Pixel data retrieval not supported for compressed image formats"); else @@ -563,7 +568,7 @@ Color *GetImageData(Image image) // Get pixel data from image as Vector4 array (float normalized) Vector4 *GetImageDataNormalized(Image image) { - Vector4 *pixels = (Vector4 *)malloc(image.width*image.height*sizeof(Vector4)); + Vector4 *pixels = (Vector4 *)RL_MALLOC(image.width*image.height*sizeof(Vector4)); if (image.format >= COMPRESSED_DXT1_RGB) TraceLog(LOG_WARNING, "Pixel data retrieval not supported for compressed image formats"); else @@ -797,7 +802,7 @@ void ExportImage(Image image, const char *fileName) fclose(rawFile); } - free(imgData); + RL_FREE(imgData); #endif if (success != 0) TraceLog(LOG_INFO, "Image exported successfully: %s", fileName); @@ -863,7 +868,7 @@ Image ImageCopy(Image image) if (height < 1) height = 1; } - newImage.data = malloc(size); + newImage.data = RL_MALLOC(size); if (newImage.data != NULL) { @@ -896,7 +901,7 @@ void ImageToPOT(Image *image, Color fillColor) Color *pixelsPOT = NULL; // Generate POT array from NPOT data - pixelsPOT = (Color *)malloc(potWidth*potHeight*sizeof(Color)); + pixelsPOT = (Color *)RL_MALLOC(potWidth*potHeight*sizeof(Color)); for (int j = 0; j < potHeight; j++) { @@ -909,15 +914,15 @@ void ImageToPOT(Image *image, Color fillColor) 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 + RL_FREE(pixels); // Free pixels data + RL_FREE(image->data); // Free old image data int format = image->format; // Store image data format to reconvert later // NOTE: Image size changes, new width and height *image = LoadImageEx(pixelsPOT, potWidth, potHeight); - free(pixelsPOT); // Free POT pixels data + RL_FREE(pixelsPOT); // Free POT pixels data ImageFormat(image, format); // Reconvert image to previous format } @@ -932,7 +937,7 @@ void ImageFormat(Image *image, int newFormat) { Vector4 *pixels = GetImageDataNormalized(*image); // Supports 8 to 32 bit per channel - free(image->data); // WARNING! We loose mipmaps data --> Regenerated at the end... + RL_FREE(image->data); // WARNING! We loose mipmaps data --> Regenerated at the end... image->data = NULL; image->format = newFormat; @@ -942,7 +947,7 @@ void ImageFormat(Image *image, int newFormat) { case UNCOMPRESSED_GRAYSCALE: { - image->data = (unsigned char *)malloc(image->width*image->height*sizeof(unsigned char)); + image->data = (unsigned char *)RL_MALLOC(image->width*image->height*sizeof(unsigned char)); for (int i = 0; i < image->width*image->height; i++) { @@ -952,7 +957,7 @@ void ImageFormat(Image *image, int newFormat) } break; case UNCOMPRESSED_GRAY_ALPHA: { - image->data = (unsigned char *)malloc(image->width*image->height*2*sizeof(unsigned char)); + image->data = (unsigned char *)RL_MALLOC(image->width*image->height*2*sizeof(unsigned char)); for (int i = 0; i < image->width*image->height*2; i += 2, k++) { @@ -963,7 +968,7 @@ void ImageFormat(Image *image, int newFormat) } break; case UNCOMPRESSED_R5G6B5: { - image->data = (unsigned short *)malloc(image->width*image->height*sizeof(unsigned short)); + image->data = (unsigned short *)RL_MALLOC(image->width*image->height*sizeof(unsigned short)); unsigned char r = 0; unsigned char g = 0; @@ -981,7 +986,7 @@ void ImageFormat(Image *image, int newFormat) } break; case UNCOMPRESSED_R8G8B8: { - image->data = (unsigned char *)malloc(image->width*image->height*3*sizeof(unsigned char)); + image->data = (unsigned char *)RL_MALLOC(image->width*image->height*3*sizeof(unsigned char)); for (int i = 0, k = 0; i < image->width*image->height*3; i += 3, k++) { @@ -994,7 +999,7 @@ void ImageFormat(Image *image, int newFormat) { #define ALPHA_THRESHOLD 50 - image->data = (unsigned short *)malloc(image->width*image->height*sizeof(unsigned short)); + image->data = (unsigned short *)RL_MALLOC(image->width*image->height*sizeof(unsigned short)); unsigned char r = 0; unsigned char g = 0; @@ -1014,7 +1019,7 @@ void ImageFormat(Image *image, int newFormat) } break; case UNCOMPRESSED_R4G4B4A4: { - image->data = (unsigned short *)malloc(image->width*image->height*sizeof(unsigned short)); + image->data = (unsigned short *)RL_MALLOC(image->width*image->height*sizeof(unsigned short)); unsigned char r = 0; unsigned char g = 0; @@ -1034,7 +1039,7 @@ void ImageFormat(Image *image, int newFormat) } break; case UNCOMPRESSED_R8G8B8A8: { - image->data = (unsigned char *)malloc(image->width*image->height*4*sizeof(unsigned char)); + image->data = (unsigned char *)RL_MALLOC(image->width*image->height*4*sizeof(unsigned char)); for (int i = 0, k = 0; i < image->width*image->height*4; i += 4, k++) { @@ -1048,7 +1053,7 @@ void ImageFormat(Image *image, int newFormat) { // WARNING: Image is converted to GRAYSCALE eqeuivalent 32bit - image->data = (float *)malloc(image->width*image->height*sizeof(float)); + image->data = (float *)RL_MALLOC(image->width*image->height*sizeof(float)); for (int i = 0; i < image->width*image->height; i++) { @@ -1057,7 +1062,7 @@ void ImageFormat(Image *image, int newFormat) } break; case UNCOMPRESSED_R32G32B32: { - image->data = (float *)malloc(image->width*image->height*3*sizeof(float)); + image->data = (float *)RL_MALLOC(image->width*image->height*3*sizeof(float)); for (int i = 0, k = 0; i < image->width*image->height*3; i += 3, k++) { @@ -1068,7 +1073,7 @@ void ImageFormat(Image *image, int newFormat) } break; case UNCOMPRESSED_R32G32B32A32: { - image->data = (float *)malloc(image->width*image->height*4*sizeof(float)); + image->data = (float *)RL_MALLOC(image->width*image->height*4*sizeof(float)); for (int i = 0, k = 0; i < image->width*image->height*4; i += 4, k++) { @@ -1081,7 +1086,7 @@ void ImageFormat(Image *image, int newFormat) default: break; } - free(pixels); + RL_FREE(pixels); pixels = NULL; // In case original image had mipmaps, generate mipmaps for formated image @@ -1286,7 +1291,7 @@ void ImageCrop(Image *image, Rectangle crop) { // Start the cropping process Color *pixels = GetImageData(*image); // Get data as Color pixels array - Color *cropPixels = (Color *)malloc((int)crop.width*(int)crop.height*sizeof(Color)); + Color *cropPixels = (Color *)RL_MALLOC((int)crop.width*(int)crop.height*sizeof(Color)); for (int j = (int)crop.y; j < (int)(crop.y + crop.height); j++) { @@ -1296,7 +1301,7 @@ void ImageCrop(Image *image, Rectangle crop) } } - free(pixels); + RL_FREE(pixels); int format = image->format; @@ -1304,7 +1309,7 @@ void ImageCrop(Image *image, Rectangle crop) *image = LoadImageEx(cropPixels, (int)crop.width, (int)crop.height); - free(cropPixels); + RL_FREE(cropPixels); // Reformat 32bit RGBA image to original format ImageFormat(image, format); @@ -1341,7 +1346,7 @@ void ImageAlphaCrop(Image *image, float threshold) Rectangle crop = { xMin, yMin, (xMax + 1) - xMin, (yMax + 1) - yMin }; - free(pixels); + RL_FREE(pixels); // Check for not empty image brefore cropping if (!((xMax < xMin) || (yMax < yMin))) ImageCrop(image, crop); @@ -1355,7 +1360,7 @@ void ImageResize(Image *image, int newWidth, int newHeight) { // Get data as Color pixels array to work with it Color *pixels = GetImageData(*image); - Color *output = (Color *)malloc(newWidth*newHeight*sizeof(Color)); + Color *output = (Color *)RL_MALLOC(newWidth*newHeight*sizeof(Color)); // NOTE: Color data is casted to (unsigned char *), there shouldn't been any problem... stbir_resize_uint8((unsigned char *)pixels, image->width, image->height, 0, (unsigned char *)output, newWidth, newHeight, 0, 4); @@ -1367,15 +1372,15 @@ void ImageResize(Image *image, int newWidth, int newHeight) *image = LoadImageEx(output, newWidth, newHeight); ImageFormat(image, format); // Reformat 32bit RGBA image to original format - free(output); - free(pixels); + RL_FREE(output); + RL_FREE(pixels); } // Resize and image to new size using Nearest-Neighbor scaling algorithm void ImageResizeNN(Image *image,int newWidth,int newHeight) { Color *pixels = GetImageData(*image); - Color *output = (Color *)malloc(newWidth*newHeight*sizeof(Color)); + Color *output = (Color *)RL_MALLOC(newWidth*newHeight*sizeof(Color)); // EDIT: added +1 to account for an early rounding problem int xRatio = (int)((image->width << 16)/newWidth) + 1; @@ -1400,8 +1405,8 @@ void ImageResizeNN(Image *image,int newWidth,int newHeight) *image = LoadImageEx(output, newWidth, newHeight); ImageFormat(image, format); // Reformat 32bit RGBA image to original format - free(output); - free(pixels); + RL_FREE(output); + RL_FREE(pixels); } // Resize canvas and fill with color @@ -1555,7 +1560,7 @@ void ImageDither(Image *image, int rBpp, int gBpp, int bBpp, int aBpp) { Color *pixels = GetImageData(*image); - free(image->data); // free old image data + RL_FREE(image->data); // free old image data if ((image->format != UNCOMPRESSED_R8G8B8) && (image->format != UNCOMPRESSED_R8G8B8A8)) { @@ -1573,7 +1578,7 @@ void ImageDither(Image *image, int rBpp, int gBpp, int bBpp, int aBpp) } // NOTE: We will store the dithered data as unsigned short (16bpp) - image->data = (unsigned short *)malloc(image->width*image->height*sizeof(unsigned short)); + image->data = (unsigned short *)RL_MALLOC(image->width*image->height*sizeof(unsigned short)); Color oldPixel = WHITE; Color newPixel = WHITE; @@ -1641,7 +1646,7 @@ void ImageDither(Image *image, int rBpp, int gBpp, int bBpp, int aBpp) } } - free(pixels); + RL_FREE(pixels); } } @@ -1652,7 +1657,7 @@ Color *ImageExtractPalette(Image image, int maxPaletteSize, int *extractCount) #define COLOR_EQUAL(col1, col2) ((col1.r == col2.r)&&(col1.g == col2.g)&&(col1.b == col2.b)&&(col1.a == col2.a)) Color *pixels = GetImageData(image); - Color *palette = (Color *)malloc(maxPaletteSize*sizeof(Color)); + Color *palette = (Color *)RL_MALLOC(maxPaletteSize*sizeof(Color)); int palCount = 0; for (int i = 0; i < maxPaletteSize; i++) palette[i] = BLANK; // Set all colors to BLANK @@ -1689,7 +1694,7 @@ Color *ImageExtractPalette(Image image, int maxPaletteSize, int *extractCount) } } - free(pixels); + RL_FREE(pixels); *extractCount = palCount; @@ -1799,8 +1804,8 @@ void ImageDraw(Image *dst, Image src, Rectangle srcRec, Rectangle dstRec) *dst = LoadImageEx(dstPixels, (int)dst->width, (int)dst->height); ImageFormat(dst, dst->format); - free(srcPixels); - free(dstPixels); + RL_FREE(srcPixels); + RL_FREE(dstPixels); } // Create an image from text (default font) @@ -1933,7 +1938,7 @@ void ImageDrawTextEx(Image *dst, Vector2 position, Font font, const char *text, void ImageFlipVertical(Image *image) { Color *srcPixels = GetImageData(*image); - Color *dstPixels = (Color *)malloc(image->width*image->height*sizeof(Color)); + Color *dstPixels = (Color *)RL_MALLOC(image->width*image->height*sizeof(Color)); for (int y = 0; y < image->height; y++) { @@ -1947,8 +1952,8 @@ void ImageFlipVertical(Image *image) ImageFormat(&processed, image->format); UnloadImage(*image); - free(srcPixels); - free(dstPixels); + RL_FREE(srcPixels); + RL_FREE(dstPixels); image->data = processed.data; } @@ -1957,7 +1962,7 @@ void ImageFlipVertical(Image *image) void ImageFlipHorizontal(Image *image) { Color *srcPixels = GetImageData(*image); - Color *dstPixels = (Color *)malloc(image->width*image->height*sizeof(Color)); + Color *dstPixels = (Color *)RL_MALLOC(image->width*image->height*sizeof(Color)); for (int y = 0; y < image->height; y++) { @@ -1971,8 +1976,8 @@ void ImageFlipHorizontal(Image *image) ImageFormat(&processed, image->format); UnloadImage(*image); - free(srcPixels); - free(dstPixels); + RL_FREE(srcPixels); + RL_FREE(dstPixels); image->data = processed.data; } @@ -1981,7 +1986,7 @@ void ImageFlipHorizontal(Image *image) void ImageRotateCW(Image *image) { Color *srcPixels = GetImageData(*image); - Color *rotPixels = (Color *)malloc(image->width*image->height*sizeof(Color)); + Color *rotPixels = (Color *)RL_MALLOC(image->width*image->height*sizeof(Color)); for (int y = 0; y < image->height; y++) { @@ -1995,8 +2000,8 @@ void ImageRotateCW(Image *image) ImageFormat(&processed, image->format); UnloadImage(*image); - free(srcPixels); - free(rotPixels); + RL_FREE(srcPixels); + RL_FREE(rotPixels); image->data = processed.data; image->width = processed.width; @@ -2007,7 +2012,7 @@ void ImageRotateCW(Image *image) void ImageRotateCCW(Image *image) { Color *srcPixels = GetImageData(*image); - Color *rotPixels = (Color *)malloc(image->width*image->height*sizeof(Color)); + Color *rotPixels = (Color *)RL_MALLOC(image->width*image->height*sizeof(Color)); for (int y = 0; y < image->height; y++) { @@ -2021,8 +2026,8 @@ void ImageRotateCCW(Image *image) ImageFormat(&processed, image->format); UnloadImage(*image); - free(srcPixels); - free(rotPixels); + RL_FREE(srcPixels); + RL_FREE(rotPixels); image->data = processed.data; image->width = processed.width; @@ -2059,7 +2064,7 @@ void ImageColorTint(Image *image, Color color) Image processed = LoadImageEx(pixels, image->width, image->height); ImageFormat(&processed, image->format); UnloadImage(*image); - free(pixels); + RL_FREE(pixels); image->data = processed.data; } @@ -2082,7 +2087,7 @@ void ImageColorInvert(Image *image) Image processed = LoadImageEx(pixels, image->width, image->height); ImageFormat(&processed, image->format); UnloadImage(*image); - free(pixels); + RL_FREE(pixels); image->data = processed.data; } @@ -2142,7 +2147,7 @@ void ImageColorContrast(Image *image, float contrast) Image processed = LoadImageEx(pixels, image->width, image->height); ImageFormat(&processed, image->format); UnloadImage(*image); - free(pixels); + RL_FREE(pixels); image->data = processed.data; } @@ -2182,7 +2187,7 @@ void ImageColorBrightness(Image *image, int brightness) Image processed = LoadImageEx(pixels, image->width, image->height); ImageFormat(&processed, image->format); UnloadImage(*image); - free(pixels); + RL_FREE(pixels); image->data = processed.data; } @@ -2212,7 +2217,7 @@ void ImageColorReplace(Image *image, Color color, Color replace) Image processed = LoadImageEx(pixels, image->width, image->height); ImageFormat(&processed, image->format); UnloadImage(*image); - free(pixels); + RL_FREE(pixels); image->data = processed.data; } @@ -2221,13 +2226,13 @@ void ImageColorReplace(Image *image, Color color, Color replace) // Generate image: plain color Image GenImageColor(int width, int height, Color color) { - Color *pixels = (Color *)calloc(width*height, sizeof(Color)); + Color *pixels = (Color *)RL_CALLOC(width*height, sizeof(Color)); for (int i = 0; i < width*height; i++) pixels[i] = color; Image image = LoadImageEx(pixels, width, height); - free(pixels); + RL_FREE(pixels); return image; } @@ -2236,7 +2241,7 @@ Image GenImageColor(int width, int height, Color color) // Generate image: vertical gradient Image GenImageGradientV(int width, int height, Color top, Color bottom) { - Color *pixels = (Color *)malloc(width*height*sizeof(Color)); + Color *pixels = (Color *)RL_MALLOC(width*height*sizeof(Color)); for (int j = 0; j < height; j++) { @@ -2251,7 +2256,7 @@ Image GenImageGradientV(int width, int height, Color top, Color bottom) } Image image = LoadImageEx(pixels, width, height); - free(pixels); + RL_FREE(pixels); return image; } @@ -2259,7 +2264,7 @@ Image GenImageGradientV(int width, int height, Color top, Color bottom) // Generate image: horizontal gradient Image GenImageGradientH(int width, int height, Color left, Color right) { - Color *pixels = (Color *)malloc(width*height*sizeof(Color)); + Color *pixels = (Color *)RL_MALLOC(width*height*sizeof(Color)); for (int i = 0; i < width; i++) { @@ -2274,7 +2279,7 @@ Image GenImageGradientH(int width, int height, Color left, Color right) } Image image = LoadImageEx(pixels, width, height); - free(pixels); + RL_FREE(pixels); return image; } @@ -2282,7 +2287,7 @@ Image GenImageGradientH(int width, int height, Color left, Color right) // Generate image: radial gradient Image GenImageGradientRadial(int width, int height, float density, Color inner, Color outer) { - Color *pixels = (Color *)malloc(width*height*sizeof(Color)); + Color *pixels = (Color *)RL_MALLOC(width*height*sizeof(Color)); float radius = (width < height)? (float)width/2.0f : (float)height/2.0f; float centerX = (float)width/2.0f; @@ -2306,7 +2311,7 @@ Image GenImageGradientRadial(int width, int height, float density, Color inner, } Image image = LoadImageEx(pixels, width, height); - free(pixels); + RL_FREE(pixels); return image; } @@ -2314,7 +2319,7 @@ Image GenImageGradientRadial(int width, int height, float density, Color inner, // Generate image: checked Image GenImageChecked(int width, int height, int checksX, int checksY, Color col1, Color col2) { - Color *pixels = (Color *)malloc(width*height*sizeof(Color)); + Color *pixels = (Color *)RL_MALLOC(width*height*sizeof(Color)); for (int y = 0; y < height; y++) { @@ -2326,7 +2331,7 @@ Image GenImageChecked(int width, int height, int checksX, int checksY, Color col } Image image = LoadImageEx(pixels, width, height); - free(pixels); + RL_FREE(pixels); return image; } @@ -2334,7 +2339,7 @@ Image GenImageChecked(int width, int height, int checksX, int checksY, Color col // Generate image: white noise Image GenImageWhiteNoise(int width, int height, float factor) { - Color *pixels = (Color *)malloc(width*height*sizeof(Color)); + Color *pixels = (Color *)RL_MALLOC(width*height*sizeof(Color)); for (int i = 0; i < width*height; i++) { @@ -2343,7 +2348,7 @@ Image GenImageWhiteNoise(int width, int height, float factor) } Image image = LoadImageEx(pixels, width, height); - free(pixels); + RL_FREE(pixels); return image; } @@ -2351,7 +2356,7 @@ Image GenImageWhiteNoise(int width, int height, float factor) // Generate image: perlin noise Image GenImagePerlinNoise(int width, int height, int offsetX, int offsetY, float scale) { - Color *pixels = (Color *)malloc(width*height*sizeof(Color)); + Color *pixels = (Color *)RL_MALLOC(width*height*sizeof(Color)); for (int y = 0; y < height; y++) { @@ -2374,7 +2379,7 @@ Image GenImagePerlinNoise(int width, int height, int offsetX, int offsetY, float } Image image = LoadImageEx(pixels, width, height); - free(pixels); + RL_FREE(pixels); return image; } @@ -2382,13 +2387,13 @@ Image GenImagePerlinNoise(int width, int height, int offsetX, int offsetY, float // Generate image: cellular algorithm. Bigger tileSize means bigger cells Image GenImageCellular(int width, int height, int tileSize) { - Color *pixels = (Color *)malloc(width*height*sizeof(Color)); + Color *pixels = (Color *)RL_MALLOC(width*height*sizeof(Color)); int seedsPerRow = width/tileSize; int seedsPerCol = height/tileSize; int seedsCount = seedsPerRow * seedsPerCol; - Vector2 *seeds = (Vector2 *)malloc(seedsCount*sizeof(Vector2)); + Vector2 *seeds = (Vector2 *)RL_MALLOC(seedsCount*sizeof(Vector2)); for (int i = 0; i < seedsCount; i++) { @@ -2431,10 +2436,10 @@ Image GenImageCellular(int width, int height, int tileSize) } } - free(seeds); + RL_FREE(seeds); Image image = LoadImageEx(pixels, width, height); - free(pixels); + RL_FREE(pixels); return image; } @@ -2921,7 +2926,7 @@ static Image LoadDDS(const char *fileName) { if (ddsHeader.ddspf.flags == 0x40) // no alpha channel { - image.data = (unsigned short *)malloc(image.width*image.height*sizeof(unsigned short)); + image.data = (unsigned short *)RL_MALLOC(image.width*image.height*sizeof(unsigned short)); fread(image.data, image.width*image.height*sizeof(unsigned short), 1, ddsFile); image.format = UNCOMPRESSED_R5G6B5; @@ -2930,7 +2935,7 @@ static Image LoadDDS(const char *fileName) { if (ddsHeader.ddspf.aBitMask == 0x8000) // 1bit alpha { - image.data = (unsigned short *)malloc(image.width*image.height*sizeof(unsigned short)); + image.data = (unsigned short *)RL_MALLOC(image.width*image.height*sizeof(unsigned short)); fread(image.data, image.width*image.height*sizeof(unsigned short), 1, ddsFile); unsigned char alpha = 0; @@ -2947,7 +2952,7 @@ static Image LoadDDS(const char *fileName) } else if (ddsHeader.ddspf.aBitMask == 0xf000) // 4bit alpha { - image.data = (unsigned short *)malloc(image.width*image.height*sizeof(unsigned short)); + image.data = (unsigned short *)RL_MALLOC(image.width*image.height*sizeof(unsigned short)); fread(image.data, image.width*image.height*sizeof(unsigned short), 1, ddsFile); unsigned char alpha = 0; @@ -2967,14 +2972,14 @@ static Image LoadDDS(const char *fileName) if (ddsHeader.ddspf.flags == 0x40 && ddsHeader.ddspf.rgbBitCount == 24) // DDS_RGB, no compressed { // NOTE: not sure if this case exists... - image.data = (unsigned char *)malloc(image.width*image.height*3*sizeof(unsigned char)); + image.data = (unsigned char *)RL_MALLOC(image.width*image.height*3*sizeof(unsigned char)); fread(image.data, image.width*image.height*3, 1, ddsFile); image.format = UNCOMPRESSED_R8G8B8; } else if (ddsHeader.ddspf.flags == 0x41 && ddsHeader.ddspf.rgbBitCount == 32) // DDS_RGBA, no compressed { - image.data = (unsigned char *)malloc(image.width*image.height*4*sizeof(unsigned char)); + image.data = (unsigned char *)RL_MALLOC(image.width*image.height*4*sizeof(unsigned char)); fread(image.data, image.width*image.height*4, 1, ddsFile); unsigned char blue = 0; @@ -3001,7 +3006,7 @@ static Image LoadDDS(const char *fileName) TraceLog(LOG_DEBUG, "Pitch or linear size: %i", ddsHeader.pitchOrLinearSize); - image.data = (unsigned char *)malloc(size*sizeof(unsigned char)); + image.data = (unsigned char *)RL_MALLOC(size*sizeof(unsigned char)); fread(image.data, size, 1, ddsFile); @@ -3098,7 +3103,7 @@ static Image LoadPKM(const char *fileName) int size = image.width*image.height*bpp/8; // Total data size in bytes - image.data = (unsigned char *)malloc(size*sizeof(unsigned char)); + image.data = (unsigned char *)RL_MALLOC(size*sizeof(unsigned char)); fread(image.data, size, 1, pkmFile); @@ -3192,7 +3197,7 @@ static Image LoadKTX(const char *fileName) int dataSize; fread(&dataSize, sizeof(unsigned int), 1, ktxFile); - image.data = (unsigned char *)malloc(dataSize*sizeof(unsigned char)); + image.data = (unsigned char *)RL_MALLOC(dataSize*sizeof(unsigned char)); fread(image.data, dataSize, 1, ktxFile); @@ -3441,7 +3446,7 @@ static Image LoadPVR(const char *fileName) } int dataSize = image.width*image.height*bpp/8; // Total data size in bytes - image.data = (unsigned char *)malloc(dataSize*sizeof(unsigned char)); + image.data = (unsigned char *)RL_MALLOC(dataSize*sizeof(unsigned char)); // Read data from file fread(image.data, dataSize, 1, pvrFile); @@ -3518,7 +3523,7 @@ static Image LoadASTC(const char *fileName) { int dataSize = image.width*image.height*bpp/8; // Data size in bytes - image.data = (unsigned char *)malloc(dataSize*sizeof(unsigned char)); + image.data = (unsigned char *)RL_MALLOC(dataSize*sizeof(unsigned char)); fread(image.data, dataSize, 1, astcFile); if (bpp == 8) image.format = COMPRESSED_ASTC_4x4_RGBA; diff --git a/src/utils.c b/src/utils.c index 10cce9b9..3cff472b 100644 --- a/src/utils.c +++ b/src/utils.c @@ -45,10 +45,10 @@ #include // Required for: Android assets manager: AAsset, AAssetManager_open(), ... #endif -#include // Required for: malloc(), free() -#include // Required for: fopen(), fclose(), fputc(), fwrite(), printf(), fprintf(), funopen() +#include // Required for: exit() +#include // Required for: printf(), sprintf() #include // Required for: va_list, va_start(), vfprintf(), va_end() -#include // Required for: strlen(), strrchr(), strcmp() +#include // Required for: strcpy(), strcat() #define MAX_TRACELOG_BUFFER_SIZE 128 // Max length of one trace-log message -- cgit v1.2.3 From 0c567cd259285fb33b3e2ab514c48322da0a0000 Mon Sep 17 00:00:00 2001 From: Ray Date: Tue, 23 Apr 2019 18:10:38 +0200 Subject: WARNING: Issues on web building Found some issues when building for web using latest emscripten 1.38.30, traced the error and found that eglGetProcAdress does not return function pointers for VAO functionality, supported by extension. It requires more investigation but now it works (avoiding VAO usage) --- examples/Makefile | 9 +++++---- src/Makefile | 2 +- src/core.c | 3 ++- src/external/cgltf.h | 4 ++-- src/external/miniaudio.h | 2 -- src/rlgl.h | 12 ++++++++++++ templates/web_shell/shell.html | 10 +++++----- 7 files changed, 27 insertions(+), 15 deletions(-) (limited to 'src/core.c') diff --git a/examples/Makefile b/examples/Makefile index 2ceb3f7d..a1d45ef6 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -25,7 +25,7 @@ # Define required raylib variables PROJECT_NAME ?= raylib_examples -RAYLIB_VERSION ?= 2.0.0 +RAYLIB_VERSION ?= 2.5.0 RAYLIB_API_VERSION ?= 1 RAYLIB_PATH ?= .. @@ -118,8 +118,8 @@ endif ifeq ($(PLATFORM),PLATFORM_WEB) # Emscripten required variables EMSDK_PATH = C:/emsdk - EMSCRIPTEN_VERSION = 1.38.21 - CLANG_VERSION = e1.38.21_64bit + EMSCRIPTEN_VERSION = 1.38.30 + CLANG_VERSION = e1.38.30_64bit PYTHON_VERSION = 2.7.13.1_64bit\python-2.7.13.amd64 NODE_VERSION = 8.9.1_64bit export PATH = $(EMSDK_PATH);$(EMSDK_PATH)\clang\$(CLANG_VERSION);$(EMSDK_PATH)\node\$(NODE_VERSION)\bin;$(EMSDK_PATH)\python\$(PYTHON_VERSION);$(EMSDK_PATH)\emscripten\$(EMSCRIPTEN_VERSION);C:\raylib\MinGW\bin:$$(PATH) @@ -249,7 +249,8 @@ ifeq ($(PLATFORM),PLATFORM_WEB) # -s EMTERPRETIFY_ASYNC=1 # support synchronous loops by emterpreter # --profiling # include information for code profiling # --preload-file resources # specify a resources folder for data compilation - CFLAGS += -Os -s USE_GLFW=3 -s ASSERTIONS=1 -s WASM=1 -s EMTERPRETIFY=1 -s EMTERPRETIFY_ASYNC=1 + CFLAGS += -Os -s USE_GLFW=3 -s ASSERTIONS=2 -s WASM=1 + # -Os -s WASM=1 -s EMTERPRETIFY=1 -s EMTERPRETIFY_ASYNC=1 # NOTE: Simple raylib examples are compiled to be interpreter by emterpreter, that way, # we can compile same code for ALL platforms with no change required, but, working on bigger diff --git a/src/Makefile b/src/Makefile index 997f041c..ea09aa9f 100644 --- a/src/Makefile +++ b/src/Makefile @@ -42,7 +42,7 @@ .PHONY: all clean install uninstall # Define required raylib variables -RAYLIB_VERSION = 2.4.0 +RAYLIB_VERSION = 2.5.0 RAYLIB_API_VERSION = 2 # See below for alternatives. diff --git a/src/core.c b/src/core.c index 844994d0..5ec3b76a 100644 --- a/src/core.c +++ b/src/core.c @@ -3172,7 +3172,8 @@ static void PollInputEvents(void) // NOTE: GLFW3 joystick functionality not available in web #if defined(PLATFORM_WEB) // Get number of gamepads connected - int numGamepads = emscripten_get_num_gamepads(); + int numGamepads = 0; + if (emscripten_sample_gamepad_data() == EMSCRIPTEN_RESULT_SUCCESS) numGamepads = emscripten_get_num_gamepads(); for (int i = 0; (i < numGamepads) && (i < MAX_GAMEPADS); i++) { diff --git a/src/external/cgltf.h b/src/external/cgltf.h index 4302e77b..85d5c985 100644 --- a/src/external/cgltf.h +++ b/src/external/cgltf.h @@ -369,7 +369,7 @@ typedef struct cgltf_light { cgltf_float spot_outer_cone_angle; } cgltf_light; -typedef struct cgltf_node { +struct cgltf_node { char* name; cgltf_node* parent; cgltf_node** children; @@ -388,7 +388,7 @@ typedef struct cgltf_node { cgltf_float rotation[4]; cgltf_float scale[3]; cgltf_float matrix[16]; -} cgltf_node; +}; typedef struct cgltf_scene { char* name; diff --git a/src/external/miniaudio.h b/src/external/miniaudio.h index a5646c71..dae605f2 100644 --- a/src/external/miniaudio.h +++ b/src/external/miniaudio.h @@ -21915,8 +21915,6 @@ extern "C" { #endif EMSCRIPTEN_KEEPALIVE void ma_device_process_pcm_frames_capture__webaudio(ma_device* pDevice, int frameCount, float* pFrames) { - ma_result result; - if (pDevice->type == ma_device_type_duplex) { ma_device__handle_duplex_callback_capture(pDevice, (ma_uint32)frameCount, pFrames, &pDevice->webaudio.duplexRB); } else { diff --git a/src/rlgl.h b/src/rlgl.h index dd2929ca..71a1dc4b 100644 --- a/src/rlgl.h +++ b/src/rlgl.h @@ -1559,7 +1559,19 @@ void rlglInit(int width, int height) glBindVertexArray = (PFNGLBINDVERTEXARRAYOESPROC)eglGetProcAddress("glBindVertexArrayOES"); glDeleteVertexArrays = (PFNGLDELETEVERTEXARRAYSOESPROC)eglGetProcAddress("glDeleteVertexArraysOES"); //glIsVertexArray = (PFNGLISVERTEXARRAYOESPROC)eglGetProcAddress("glIsVertexArrayOES"); // NOTE: Fails in WebGL, omitted + + if (glGenVertexArrays == NULL) printf("glGenVertexArrays is NULL.\n"); // WEB: ISSUE FOUND! ...but why? + if (glBindVertexArray == NULL) printf("glBindVertexArray is NULL.\n"); // WEB: ISSUE FOUND! ...but why? } + + // TODO: HACK REVIEW! + // For some reason on raylib 2.5, VAO usage breaks the build + // error seems related to function pointers but I can not get detailed info... + // Avoiding VAO usage is the only solution for now... :( + // Ref: https://emscripten.org/docs/porting/guidelines/function_pointer_issues.html + #if defined(PLATFORM_WEB) + vaoSupported = false; + #endif // Check NPOT textures support // NOTE: Only check on OpenGL ES, OpenGL 3.3 has NPOT textures full support as core feature diff --git a/templates/web_shell/shell.html b/templates/web_shell/shell.html index f158c432..2e891461 100644 --- a/templates/web_shell/shell.html +++ b/templates/web_shell/shell.html @@ -178,14 +178,14 @@ } + + + {{{ SCRIPT }}} + + \ No newline at end of file diff --git a/templates/advance_game/Makefile b/templates/advance_game/Makefile index 784c7dca..95fb6f6f 100644 --- a/templates/advance_game/Makefile +++ b/templates/advance_game/Makefile @@ -236,7 +236,7 @@ ifeq ($(PLATFORM),PLATFORM_WEB) endif # Define a custom shell .html and output extension - CFLAGS += --shell-file $(RAYLIB_PATH)\templates\web_shell\shell.html + CFLAGS += --shell-file $(RAYLIB_PATH)\src\shell.html EXT = .html endif diff --git a/templates/simple_game/Makefile b/templates/simple_game/Makefile index a1e65772..ea732c92 100644 --- a/templates/simple_game/Makefile +++ b/templates/simple_game/Makefile @@ -236,7 +236,7 @@ ifeq ($(PLATFORM),PLATFORM_WEB) endif # Define a custom shell .html and output extension - CFLAGS += --shell-file $(RAYLIB_PATH)\templates\web_shell\shell.html + CFLAGS += --shell-file $(RAYLIB_PATH)\src\shell.html EXT = .html endif diff --git a/templates/standard_game/Makefile b/templates/standard_game/Makefile index bd7906b8..56b76b42 100644 --- a/templates/standard_game/Makefile +++ b/templates/standard_game/Makefile @@ -230,7 +230,7 @@ ifeq ($(PLATFORM),PLATFORM_WEB) endif # Define a custom shell .html and output extension - CFLAGS += --shell-file $(RAYLIB_PATH)\templates\web_shell\shell.html + CFLAGS += --shell-file $(RAYLIB_PATH)\src\shell.html EXT = .html endif diff --git a/templates/web_shell/shell.html b/templates/web_shell/shell.html deleted file mode 100644 index 641cfc02..00000000 --- a/templates/web_shell/shell.html +++ /dev/null @@ -1,257 +0,0 @@ - - - - - - - raylib HTML5 GAME - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - -
-
Downloading...
- - - - - -
- -
-
- -
- -
- - - - - - - {{{ SCRIPT }}} - - \ No newline at end of file -- cgit v1.2.3 From f45691ca8ddf165b4527097762b38e038c350509 Mon Sep 17 00:00:00 2001 From: Ray Date: Wed, 22 May 2019 16:12:47 +0200 Subject: Rename function to follow javascript notation --- src/core.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/core.c') diff --git a/src/core.c b/src/core.c index 8dd1090b..26a8b2a4 100644 --- a/src/core.c +++ b/src/core.c @@ -1640,8 +1640,8 @@ void TakeScreenshot(const char *fileName) #if defined(PLATFORM_WEB) // Download file from MEMFS (emscripten memory filesystem) - // SaveFileFromMEMFSToDisk() function is defined in raylib/src/shell.html - emscripten_run_script(TextFormat("SaveFileFromMEMFSToDisk('%s','%s')", GetFileName(path), GetFileName(path))); + // saveFileFromMEMFSToDisk() function is defined in raylib/src/shell.html + emscripten_run_script(TextFormat("saveFileFromMEMFSToDisk('%s','%s')", GetFileName(path), GetFileName(path))); #endif TraceLog(LOG_INFO, "Screenshot taken: %s", path); @@ -3610,8 +3610,8 @@ static void KeyCallback(GLFWwindow *window, int key, int scancode, int action, i #if defined(PLATFORM_WEB) // Download file from MEMFS (emscripten memory filesystem) - // SaveFileFromMEMFSToDisk() function is defined in raylib/templates/web_shel/shell.html - emscripten_run_script(TextFormat("SaveFileFromMEMFSToDisk('%s','%s')", TextFormat("screenrec%03i.gif", screenshotCounter - 1), TextFormat("screenrec%03i.gif", screenshotCounter - 1))); + // saveFileFromMEMFSToDisk() function is defined in raylib/templates/web_shel/shell.html + emscripten_run_script(TextFormat("saveFileFromMEMFSToDisk('%s','%s')", TextFormat("screenrec%03i.gif", screenshotCounter - 1), TextFormat("screenrec%03i.gif", screenshotCounter - 1))); #endif TraceLog(LOG_INFO, "End animated GIF recording"); -- cgit v1.2.3 From 272d9d58e39f442b282dd27f2811269991f89592 Mon Sep 17 00:00:00 2001 From: Mohamed Shazan Date: Thu, 6 Jun 2019 15:03:03 +0530 Subject: Add VS2017.ANGLE Project --- .../examples/core_basic_window.vcxproj | 194 ++++++++++++++++++++ .../examples/core_basic_window_cpp.vcxproj | 192 ++++++++++++++++++++ projects/VS2017.ANGLE/raylib.sln | 57 ++++++ projects/VS2017.ANGLE/raylib/raylib.vcxproj | 198 +++++++++++++++++++++ src/core.c | 6 +- src/external/ANGLE/lib/x64/d3dcompiler_47.dll | Bin 0 -> 4493352 bytes src/external/ANGLE/lib/x64/libEGL.dll | Bin 0 -> 62976 bytes src/external/ANGLE/lib/x64/libEGL.lib | Bin 0 -> 14164 bytes src/external/ANGLE/lib/x64/libGLESv2.dll | Bin 0 -> 18712576 bytes src/external/ANGLE/lib/x64/libGLESv2.lib | Bin 0 -> 548600 bytes src/external/ANGLE/lib/x86/d3dcompiler_47.dll | Bin 0 -> 3705472 bytes src/external/ANGLE/lib/x86/libEGL.dll | Bin 0 -> 51712 bytes src/external/ANGLE/lib/x86/libEGL.lib | Bin 0 -> 14992 bytes src/external/ANGLE/lib/x86/libGLESv2.dll | Bin 0 -> 16666624 bytes src/external/ANGLE/lib/x86/libGLESv2.lib | Bin 0 -> 575538 bytes 15 files changed, 646 insertions(+), 1 deletion(-) create mode 100644 projects/VS2017.ANGLE/examples/core_basic_window.vcxproj create mode 100644 projects/VS2017.ANGLE/examples/core_basic_window_cpp.vcxproj create mode 100644 projects/VS2017.ANGLE/raylib.sln create mode 100644 projects/VS2017.ANGLE/raylib/raylib.vcxproj create mode 100644 src/external/ANGLE/lib/x64/d3dcompiler_47.dll create mode 100644 src/external/ANGLE/lib/x64/libEGL.dll create mode 100644 src/external/ANGLE/lib/x64/libEGL.lib create mode 100644 src/external/ANGLE/lib/x64/libGLESv2.dll create mode 100644 src/external/ANGLE/lib/x64/libGLESv2.lib create mode 100644 src/external/ANGLE/lib/x86/d3dcompiler_47.dll create mode 100644 src/external/ANGLE/lib/x86/libEGL.dll create mode 100644 src/external/ANGLE/lib/x86/libEGL.lib create mode 100644 src/external/ANGLE/lib/x86/libGLESv2.dll create mode 100644 src/external/ANGLE/lib/x86/libGLESv2.lib (limited to 'src/core.c') diff --git a/projects/VS2017.ANGLE/examples/core_basic_window.vcxproj b/projects/VS2017.ANGLE/examples/core_basic_window.vcxproj new file mode 100644 index 00000000..e47a7ccf --- /dev/null +++ b/projects/VS2017.ANGLE/examples/core_basic_window.vcxproj @@ -0,0 +1,194 @@ + + + + + Debug.DLL + Win32 + + + Debug + Win32 + + + Release.DLL + Win32 + + + Release + Win32 + + + + {0981CA98-E4A5-4DF1-987F-A41D09131EFC} + Win32Proj + core_basic_window + 10.0 + core_basic_window + + + + Application + true + v142 + Unicode + + + Application + true + v142 + Unicode + + + Application + false + v142 + true + Unicode + + + Application + false + v142 + true + Unicode + + + + + + + + + + + + + + + + + + + + + true + $(ProjectDir)$(ProjectName)\$(Configuration)\ + $(ProjectDir)$(ProjectName)\$(Configuration)\temp + + + true + $(ProjectDir)$(ProjectName)\$(Configuration)\ + $(ProjectDir)$(ProjectName)\$(Configuration)\temp + + + false + $(ProjectDir)$(ProjectName)\$(Configuration)\ + $(ProjectDir)$(ProjectName)\$(Configuration)\temp + + + false + $(ProjectDir)$(ProjectName)\$(Configuration)\ + $(ProjectDir)$(ProjectName)\$(Configuration)\temp + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions) + CompileAsC + $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) + + + Console + true + %(AdditionalLibraryDirectories) + kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + + + xcopy $(SolutionDir)..\..\src\external\ANGLE\lib\$(PlatformTarget)\*.dll $(OutDir) /Y /E /Q + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions) + CompileAsC + $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) + + + Console + true + %(AdditionalLibraryDirectories) + kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + + + xcopy $(SolutionDir)..\..\src\external\ANGLE\lib\$(PlatformTarget)\*.dll $(OutDir) /Y /E /Q + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP + $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) + CompileAsC + true + + + Console + true + true + true + kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + $(SolutionDir)deps;%(AdditionalLibraryDirectories) + + + xcopy $(SolutionDir)..\..\src\external\ANGLE\lib\$(PlatformTarget)\*.dll $(OutDir) /Y /E /Q + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP + $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) + CompileAsC + true + + + Console + true + true + true + kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + %(AdditionalLibraryDirectories) + + + xcopy $(SolutionDir)..\..\src\external\ANGLE\lib\$(PlatformTarget)\*.dll $(OutDir) /Y /E /Q + + + + + + + + {e89d61ac-55de-4482-afd4-df7242ebc859} + + + + + + \ No newline at end of file diff --git a/projects/VS2017.ANGLE/examples/core_basic_window_cpp.vcxproj b/projects/VS2017.ANGLE/examples/core_basic_window_cpp.vcxproj new file mode 100644 index 00000000..fcbc6bfd --- /dev/null +++ b/projects/VS2017.ANGLE/examples/core_basic_window_cpp.vcxproj @@ -0,0 +1,192 @@ + + + + + Debug.DLL + Win32 + + + Debug + Win32 + + + Release.DLL + Win32 + + + Release + Win32 + + + + {B655E850-3322-42F7-941D-6AC18FD66CA1} + Win32Proj + raylib_example_cpp + 10.0 + core_basic_window_cpp + + + + Application + true + v142 + Unicode + + + Application + true + v142 + Unicode + + + Application + false + v142 + true + Unicode + + + Application + false + v142 + true + Unicode + + + + + + + + + + + + + + + + + + + + + true + $(ProjectDir)$(ProjectName)\$(Configuration) + $(ProjectDir)$(ProjectName)\$(Configuration)\temp + + + true + $(ProjectDir)$(ProjectName)\$(Configuration) + $(ProjectDir)$(ProjectName)\$(Configuration)\temp + + + false + $(ProjectDir)$(ProjectName)\$(Configuration) + $(ProjectDir)$(ProjectName)\$(Configuration)\temp + + + false + $(ProjectDir)$(ProjectName)\$(Configuration) + $(ProjectDir)$(ProjectName)\$(Configuration)\temp + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) + CompileAsCpp + + + Console + true + kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + $(SolutionDir)..\..\release\libs\win32\msvc;%(AdditionalLibraryDirectories) + + + xcopy $(SolutionDir)..\..\src\external\ANGLE\lib\$(PlatformTarget)\*.dll $(OutDir) /Y /E /Q + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) + CompileAsCpp + + + Console + true + kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + $(SolutionDir)..\..\release\libs\win32\msvc;%(AdditionalLibraryDirectories) + + + xcopy $(SolutionDir)..\..\src\external\ANGLE\lib\$(PlatformTarget)\*.dll $(OutDir) /Y /E /Q + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + CompileAsCpp + $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) + + + Console + true + true + true + $(SolutionDir)..\..\release\libs\win32\msvc;%(AdditionalLibraryDirectories) + kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + + + xcopy $(SolutionDir)..\..\src\external\ANGLE\lib\$(PlatformTarget)\*.dll $(OutDir) /Y /E /Q + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + CompileAsCpp + $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) + + + Console + true + true + true + %(AdditionalLibraryDirectories) + kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + + + xcopy $(SolutionDir)..\..\src\external\ANGLE\lib\$(PlatformTarget)\*.dll $(OutDir) /Y /E /Q + + + + + {e89d61ac-55de-4482-afd4-df7242ebc859} + + + + + + + + + \ No newline at end of file diff --git a/projects/VS2017.ANGLE/raylib.sln b/projects/VS2017.ANGLE/raylib.sln new file mode 100644 index 00000000..f163b7b7 --- /dev/null +++ b/projects/VS2017.ANGLE/raylib.sln @@ -0,0 +1,57 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.27130.2024 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "core_basic_window", "examples\core_basic_window.vcxproj", "{0981CA98-E4A5-4DF1-987F-A41D09131EFC}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "raylib", "raylib\raylib.vcxproj", "{E89D61AC-55DE-4482-AFD4-DF7242EBC859}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "core_basic_window_cpp", "examples\core_basic_window_cpp.vcxproj", "{B655E850-3322-42F7-941D-6AC18FD66CA1}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "examples", "examples", "{8716DC0F-4FDE-4F57-8E25-5F78DFB80FE1}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug.DLL|x86 = Debug.DLL|x86 + Debug|x86 = Debug|x86 + Release.DLL|x86 = Release.DLL|x86 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {0981CA98-E4A5-4DF1-987F-A41D09131EFC}.Debug.DLL|x86.ActiveCfg = Debug.DLL|Win32 + {0981CA98-E4A5-4DF1-987F-A41D09131EFC}.Debug.DLL|x86.Build.0 = Debug.DLL|Win32 + {0981CA98-E4A5-4DF1-987F-A41D09131EFC}.Debug|x86.ActiveCfg = Debug|Win32 + {0981CA98-E4A5-4DF1-987F-A41D09131EFC}.Debug|x86.Build.0 = Debug|Win32 + {0981CA98-E4A5-4DF1-987F-A41D09131EFC}.Release.DLL|x86.ActiveCfg = Release.DLL|Win32 + {0981CA98-E4A5-4DF1-987F-A41D09131EFC}.Release.DLL|x86.Build.0 = Release.DLL|Win32 + {0981CA98-E4A5-4DF1-987F-A41D09131EFC}.Release|x86.ActiveCfg = Release|Win32 + {0981CA98-E4A5-4DF1-987F-A41D09131EFC}.Release|x86.Build.0 = Release|Win32 + {E89D61AC-55DE-4482-AFD4-DF7242EBC859}.Debug.DLL|x86.ActiveCfg = Debug.DLL|Win32 + {E89D61AC-55DE-4482-AFD4-DF7242EBC859}.Debug.DLL|x86.Build.0 = Debug.DLL|Win32 + {E89D61AC-55DE-4482-AFD4-DF7242EBC859}.Debug|x86.ActiveCfg = Debug|Win32 + {E89D61AC-55DE-4482-AFD4-DF7242EBC859}.Debug|x86.Build.0 = Debug|Win32 + {E89D61AC-55DE-4482-AFD4-DF7242EBC859}.Release.DLL|x86.ActiveCfg = Release.DLL|Win32 + {E89D61AC-55DE-4482-AFD4-DF7242EBC859}.Release.DLL|x86.Build.0 = Release.DLL|Win32 + {E89D61AC-55DE-4482-AFD4-DF7242EBC859}.Release|x86.ActiveCfg = Release|Win32 + {E89D61AC-55DE-4482-AFD4-DF7242EBC859}.Release|x86.Build.0 = Release|Win32 + {B655E850-3322-42F7-941D-6AC18FD66CA1}.Debug.DLL|x86.ActiveCfg = Debug.DLL|Win32 + {B655E850-3322-42F7-941D-6AC18FD66CA1}.Debug.DLL|x86.Build.0 = Debug.DLL|Win32 + {B655E850-3322-42F7-941D-6AC18FD66CA1}.Debug|x86.ActiveCfg = Debug|Win32 + {B655E850-3322-42F7-941D-6AC18FD66CA1}.Debug|x86.Build.0 = Debug|Win32 + {B655E850-3322-42F7-941D-6AC18FD66CA1}.Release.DLL|x86.ActiveCfg = Release.DLL|Win32 + {B655E850-3322-42F7-941D-6AC18FD66CA1}.Release.DLL|x86.Build.0 = Release.DLL|Win32 + {B655E850-3322-42F7-941D-6AC18FD66CA1}.Release|x86.ActiveCfg = Release|Win32 + {B655E850-3322-42F7-941D-6AC18FD66CA1}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {0981CA98-E4A5-4DF1-987F-A41D09131EFC} = {8716DC0F-4FDE-4F57-8E25-5F78DFB80FE1} + {B655E850-3322-42F7-941D-6AC18FD66CA1} = {8716DC0F-4FDE-4F57-8E25-5F78DFB80FE1} + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {E926C768-6307-4423-A1EC-57E95B1FAB29} + EndGlobalSection +EndGlobal diff --git a/projects/VS2017.ANGLE/raylib/raylib.vcxproj b/projects/VS2017.ANGLE/raylib/raylib.vcxproj new file mode 100644 index 00000000..b1cf67b9 --- /dev/null +++ b/projects/VS2017.ANGLE/raylib/raylib.vcxproj @@ -0,0 +1,198 @@ + + + + + Debug.DLL + Win32 + + + Debug + Win32 + + + Release.DLL + Win32 + + + Release + Win32 + + + + {E89D61AC-55DE-4482-AFD4-DF7242EBC859} + Win32Proj + raylib + 10.0 + + + + StaticLibrary + true + v142 + Unicode + + + DynamicLibrary + true + v142 + Unicode + + + StaticLibrary + false + v142 + true + Unicode + + + DynamicLibrary + false + v142 + true + Unicode + + + + + + + + + + + + + + + + + + + + + $(SolutionDir)$(ProjectName)\$(Configuration)\ + + + $(SolutionDir)$(ProjectName)\$(Configuration)\ + + + $(SolutionDir)$(ProjectName)\$(Configuration)\ + $(SolutionDir)$(ProjectName)\$(Configuration)\temp + + + $(SolutionDir)$(ProjectName)\$(Configuration)\ + $(SolutionDir)$(ProjectName)\$(Configuration)\temp + + + + + + Level3 + Disabled + WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions);GRAPHICS_API_OPENGL_ES2;PLATFORM_DESKTOP + CompileAsC + $(SolutionDir)..\..\src\external\ANGLE;$(SolutionDir)..\..\release\include;$(SolutionDir)..\..\src\external\glfw\include + + + Windows + + + $(SolutionDir)..\..\src\external\ANGLE\lib\$(PlatformTarget);%(AdditionalLibraryDirectories) + libEGL.lib;libGLESv2.lib + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions);GRAPHICS_API_OPENGL_33;PLATFORM_DESKTOP;BUILD_LIBTYPE_SHARED + CompileAsC + $(SolutionDir)..\..\release\include;$(SolutionDir)..\..\src\external\glfw\include + MultiThreadedDebug + + + Windows + + + %(AdditionalLibraryDirectories) + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions);GRAPHICS_API_OPENGL_ES2;PLATFORM_DESKTOP + $(SolutionDir)..\..\src\external\ANGLE;$(SolutionDir)..\..\release\include;$(SolutionDir)..\..\src\external\glfw\include + CompileAsC + + + Windows + true + true + + + $(SolutionDir)..\..\src\external\ANGLE\lib\$(PlatformTarget);%(AdditionalLibraryDirectories) + libEGL.lib;libGLESv2.lib + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions);GRAPHICS_API_OPENGL_33;PLATFORM_DESKTOP;BUILD_LIBTYPE_SHARED + $(SolutionDir)..\..\release\include;$(SolutionDir)..\..\src\external\glfw\include + CompileAsC + MultiThreaded + + + Windows + true + true + winmm.lib;%(AdditionalDependencies) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/core.c b/src/core.c index 26a8b2a4..45539d24 100644 --- a/src/core.c +++ b/src/core.c @@ -2470,7 +2470,11 @@ static bool InitGraphicsDevice(int width, int height) glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 2); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0); glfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_ES_API); - glfwWindowHint(GLFW_CONTEXT_CREATION_API, GLFW_NATIVE_CONTEXT_API); // Alternative: GLFW_EGL_CONTEXT_API (ANGLE) +#if defined(PLATFORM_DESKTOP) + glfwWindowHint(GLFW_CONTEXT_CREATION_API, GLFW_EGL_CONTEXT_API); +#else + glfwWindowHint(GLFW_CONTEXT_CREATION_API, GLFW_NATIVE_CONTEXT_API); +#endif } if (fullscreen) diff --git a/src/external/ANGLE/lib/x64/d3dcompiler_47.dll b/src/external/ANGLE/lib/x64/d3dcompiler_47.dll new file mode 100644 index 00000000..47040da0 Binary files /dev/null and b/src/external/ANGLE/lib/x64/d3dcompiler_47.dll differ diff --git a/src/external/ANGLE/lib/x64/libEGL.dll b/src/external/ANGLE/lib/x64/libEGL.dll new file mode 100644 index 00000000..71c20a7a Binary files /dev/null and b/src/external/ANGLE/lib/x64/libEGL.dll differ diff --git a/src/external/ANGLE/lib/x64/libEGL.lib b/src/external/ANGLE/lib/x64/libEGL.lib new file mode 100644 index 00000000..b440f78c Binary files /dev/null and b/src/external/ANGLE/lib/x64/libEGL.lib differ diff --git a/src/external/ANGLE/lib/x64/libGLESv2.dll b/src/external/ANGLE/lib/x64/libGLESv2.dll new file mode 100644 index 00000000..66fcba06 Binary files /dev/null and b/src/external/ANGLE/lib/x64/libGLESv2.dll differ diff --git a/src/external/ANGLE/lib/x64/libGLESv2.lib b/src/external/ANGLE/lib/x64/libGLESv2.lib new file mode 100644 index 00000000..af5ba5ad Binary files /dev/null and b/src/external/ANGLE/lib/x64/libGLESv2.lib differ diff --git a/src/external/ANGLE/lib/x86/d3dcompiler_47.dll b/src/external/ANGLE/lib/x86/d3dcompiler_47.dll new file mode 100644 index 00000000..4ffad2d7 Binary files /dev/null and b/src/external/ANGLE/lib/x86/d3dcompiler_47.dll differ diff --git a/src/external/ANGLE/lib/x86/libEGL.dll b/src/external/ANGLE/lib/x86/libEGL.dll new file mode 100644 index 00000000..a9cb4a9a Binary files /dev/null and b/src/external/ANGLE/lib/x86/libEGL.dll differ diff --git a/src/external/ANGLE/lib/x86/libEGL.lib b/src/external/ANGLE/lib/x86/libEGL.lib new file mode 100644 index 00000000..1954ceb3 Binary files /dev/null and b/src/external/ANGLE/lib/x86/libEGL.lib differ diff --git a/src/external/ANGLE/lib/x86/libGLESv2.dll b/src/external/ANGLE/lib/x86/libGLESv2.dll new file mode 100644 index 00000000..47a71ff7 Binary files /dev/null and b/src/external/ANGLE/lib/x86/libGLESv2.dll differ diff --git a/src/external/ANGLE/lib/x86/libGLESv2.lib b/src/external/ANGLE/lib/x86/libGLESv2.lib new file mode 100644 index 00000000..562310cc Binary files /dev/null and b/src/external/ANGLE/lib/x86/libGLESv2.lib differ -- cgit v1.2.3