Merge pull request #1 from raysan5/master

Update to latest master
This commit is contained in:
Kim Kulling 2018-10-21 11:21:02 +02:00 • committed by GitHub
commit 50659d1a6c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
173 changed files with 18513 additions and 16261 deletions

1
.gitignore vendored
View file

@ -33,6 +33,7 @@ Thumbs.db
[Bb]in [Bb]in
[Dd]ebug/ [Dd]ebug/
[Dd]ebug.win32/ [Dd]ebug.win32/
[Dd]ebug.DLL/
*.sbr *.sbr
*.sdf *.sdf
obj/ obj/

View file

@ -120,7 +120,6 @@ script:
-DBUILD_EXAMPLES=ON -DBUILD_GAMES=ON -DBUILD_EXAMPLES=ON -DBUILD_GAMES=ON
-DUSE_EXTERNAL_GLFW=$USE_EXTERNAL_GLFW -DUSE_EXTERNAL_GLFW=$USE_EXTERNAL_GLFW
-DUSE_WAYLAND=$WAYLAND -DUSE_WAYLAND=$WAYLAND
-DUSE_OPENAL_BACKEND=$OPENAL
-DINCLUDE_EVERYTHING=ON -DINCLUDE_EVERYTHING=ON
.. ..
- $RUNNER make VERBOSE=1 - $RUNNER make VERBOSE=1

View file

@ -7,7 +7,7 @@ Use your best judgement, and feel free to propose changes to this document in a
### raylib philosophy ### raylib philosophy
- raylib is a tool to LEARN videogames programming, every single function in raylib should be a tutorial on itself. - raylib is a tool to enjoy videogames programming, every single function in raylib should be a tutorial on itself.
- raylib is SIMPLE and EASY-TO-USE, I tried to keep it compact with a small set of functions, if a function is too complex or is not clearly useful, better not to include it. - raylib is SIMPLE and EASY-TO-USE, I tried to keep it compact with a small set of functions, if a function is too complex or is not clearly useful, better not to include it.
- raylib is open source and free; educators and institutions can use this tool to TEACH videogames programming completely by free. - raylib is open source and free; educators and institutions can use this tool to TEACH videogames programming completely by free.
- raylib is collaborative; contribution of tutorials / code-examples / bugs-solving / code-comments are highly appreciated. - raylib is collaborative; contribution of tutorials / code-examples / bugs-solving / code-comments are highly appreciated.
@ -59,15 +59,23 @@ To open new issue for raylib (bug, enhancement, discussion...), just try to foll
Some people ported raylib to other languages in form of bindings or wrappers to the library, here is a list with the ones I'm aware of: Some people ported raylib to other languages in form of bindings or wrappers to the library, here is a list with the ones I'm aware of:
- [raylib C/C++ version (default)](https://github.com/raysan5/raylib) - [raylib](https://github.com/raysan5/raylib) : raylib **C/C++** version (default)
- [raylib Lua binding](https://github.com/raysan5/raylib-lua) - [raylib-lua](https://github.com/raysan5/raylib-lua) : raylib **Lua** binding
- [raylib Go binding](https://github.com/gen2brain/raylib-go) - [raylib-go](https://github.com/gen2brain/raylib-go) : raylib **Go** binding
- [raylib Nim binding](https://gitlab.com/define-private-public/raylib-Nim) - [raylib-Nim](https://gitlab.com/define-private-public/raylib-Nim) : raylib **Nim** binding
- [raylib Crystal binding](https://gitlab.com/Zatherz/cray) - [cray](https://gitlab.com/Zatherz/cray) - raylib **Crystal** binding
- [raylib Perl wrapper](https://metacpan.org/pod/Graphics::Raylib) - [Graphics::Raylib](https://metacpan.org/pod/Graphics::Raylib) : raylib **Perl** wrapper
- raylib Pascal binding with custom IDE (closed-source) - [raylib-pascal](https://github.com/drezgames/raylib-pascal) - raylib **Pascal** binding
- [raylib flat-assembler Usage example](http://forum.raylib.com/index.php?p=/discussion/comment/425/#Comment_425) - [Raylib-cs](https://github.com/ChrisDill/Raylib-cs) : raylib **C#** binding
- [raylib COBOL Usage example](https://github.com/Martinfx/Cobol/tree/master/OpenCobol/Games/raylib) - [RaylibSharp](https://github.com/TheLumaio/RaylibSharp) : raylib **C#** binding
- [raylib-ruby-ffi](https://github.com/D3nX/raylib-ruby-ffi) : raylib **Ruby** binding
- [raylib-rs](https://github.com/deltaphc/raylib-rs) : raylib **Rust** binding
- [raylib-rust](https://github.com/dtcristo/raylib-rust) : raylib **Rust** binding
- [raylib-py](https://github.com/overdev/raylib-py) : raylib **Python** binding
- [raylib-haskell](https://github.com/DevJac/raylib-haskell) : raylib **Haskell** binding
- [raylib-java]() : raylib **Java** binding
- *[raylib flat-assembler Usage example](http://forum.raylib.com/index.php?p=/discussion/comment/425/#Comment_425)*
- *[raylib COBOL Usage example](https://github.com/Martinfx/Cobol/tree/master/OpenCobol/Games/raylib)*
Usually, raylib bindings follow the convention: `raylib-{language}` Usually, raylib bindings follow the convention: `raylib-{language}`
@ -79,7 +87,7 @@ provide the icon/logo for that new language binding.
If you have any doubt, don't hesitate to [contact me](mailto:ray@raylib.com)!. If you have any doubt, don't hesitate to [contact me](mailto:ray@raylib.com)!.
You can write me a direct mail but you can also contact me on the following networks: You can write me a direct mail but you can also contact me on the following networks:
- [raylib forum](http://forum.raylib.com/) - A good place for discussions or to ask for help. - [raylib reddit](https://www.reddit.com/r/raylib/) - A good place for discussions or to ask for help.
- [raylib Discord](https://discord.gg/VkzNHUE) - A direct communication channel for project discussions. - [raylib Discord](https://discord.gg/VkzNHUE) - A direct communication channel for project discussions.
- [raylib twitter](https://twitter.com/raysan5) - My personal twitter account, I usually post about raylib, you can send me PMs. - [raylib twitter](https://twitter.com/raysan5) - My personal twitter account, I usually post about raylib, you can send me PMs.
- [raylib web](http://www.raylib.com/) - On top-right corner there is a bunch of networks where you can find me. - [raylib web](http://www.raylib.com/) - On top-right corner there is a bunch of networks where you can find me.

View file

@ -18,7 +18,7 @@ with a small [donation](http://www.raylib.com/helpme.html) or contributing with
raylib philosophy raylib philosophy
------------------ ------------------
* raylib is a tool to LEARN videogames programming, every single function in raylib should be a tutorial on itself. * raylib is a tool to enjoy videogames programming, every single function in raylib should be a tutorial on itself.
* raylib is SIMPLE and EASY-TO-USE, I tried to keep it compact with a small set of functions, if a function is too complex or has not a clear usefulness, better not to include it. * raylib is SIMPLE and EASY-TO-USE, I tried to keep it compact with a small set of functions, if a function is too complex or has not a clear usefulness, better not to include it.
* raylib is open source and free; educators and institutions can use this tool to TEACH videogames programming completely by free. * raylib is open source and free; educators and institutions can use this tool to TEACH videogames programming completely by free.
* raylib is collaborative; contribution of tutorials / code-examples / bugs-solving / code-comments are highly appreciated. * raylib is collaborative; contribution of tutorials / code-examples / bugs-solving / code-comments are highly appreciated.

View file

@ -7,7 +7,7 @@ source code
raylib is licensed under an unmodified zlib/libpng license, which is an OSI-certified, 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: BSD-like license that allows static linking with closed source software:
Copyright (c) 2013-2016 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 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. will the authors be held liable for any damages arising from the use of this software.
@ -41,9 +41,9 @@ The following fonts [provided with raylib](https://github.com/raysan5/raylib/tre
2d art 2d art
------ ------
[scarfy spritesheet](https://github.com/raysan5/raylib/blob/master/examples/textures/resources/scarfy.png) and [fudesumi image](https://github.com/raysan5/raylib/blob/master/examples/textures/resources/fudesumi.png) have been created by [Eiden Marsal](https://www.artstation.com/artist/marshall_z) and licensed as [Creative Commons Attribution-NonCommercial 3.0](https://creativecommons.org/licenses/by-nc/3.0/legalcode) [scarfy spritesheet](https://github.com/raysan5/raylib/blob/master/examples/textures/resources/scarfy.png) and [fudesumi image](https://github.com/raysan5/raylib/blob/master/examples/textures/resources/fudesumi.png) have been created by [Eiden Marsal](https://www.artstation.com/artist/marshall_z) and are licensed as [Creative Commons Attribution-NonCommercial 3.0](https://creativecommons.org/licenses/by-nc/3.0/legalcode)
3d models 3d models
--------- ---------
[medieval city 3d models and textures](https://github.com/raysan5/raylib/tree/master/examples/models/resources/medieval) have been created by Alberto Cano and licensed as [Creative Commons Attribution-NonCommercial 4.0](https://creativecommons.org/licenses/by-nc/4.0/legalcode) [medieval city 3d models and textures](https://github.com/raysan5/raylib/tree/master/examples/models/resources/medieval) have been created by Alberto Cano and are licensed as [Creative Commons Attribution-NonCommercial 4.0](https://creativecommons.org/licenses/by-nc/4.0/legalcode)

View file

@ -1,12 +1,12 @@
<img align="left" src="https://github.com/raysan5/raylib/blob/master/logo/raylib_256x256.png" width=256> <img align="left" src="https://github.com/raysan5/raylib/blob/master/logo/raylib_256x256.png" width=256>
**raylib is a simple and easy-to-use library to learn videogames programming.** **raylib is a simple and easy-to-use library to enjoy videogames programming.**
raylib is highly inspired by Borland BGI graphics lib and by XNA framework. raylib is highly inspired by Borland BGI graphics lib and by XNA framework.
raylib could be useful for prototyping, tools development, graphic applications, embedded systems and education. raylib could be useful for prototyping, tools development, graphic applications, embedded systems and education.
NOTE for ADVENTURERS: raylib is a programming library to learn videogames programming; NOTE for ADVENTURERS: raylib is a programming library to enjoy videogames programming;
no fancy interface, no visual helpers, no auto-debugging... just coding in the most no fancy interface, no visual helpers, no auto-debugging... just coding in the most
pure spartan-programmers way. Are you ready to learn? Jump to [code examples!](http://www.raylib.com/examples.html) pure spartan-programmers way. Are you ready to learn? Jump to [code examples!](http://www.raylib.com/examples.html)
@ -22,7 +22,7 @@ features
- Multiple platforms supported: **Windows, Linux, MacOS, Android... and many more!** - Multiple platforms supported: **Windows, Linux, MacOS, Android... and many more!**
- Written in plain C code (C99) in PascalCase/camelCase notation - Written in plain C code (C99) in PascalCase/camelCase notation
- Hardware accelerated with OpenGL (**1.1, 2.1, 3.3 or ES 2.0**) - Hardware accelerated with OpenGL (**1.1, 2.1, 3.3 or ES 2.0**)
- **Unique OpenGL abstraction layer** (usable as standalone module): [rlgl](https://github.com/raysan5/raylib/blob/master/src/rlgl.c) - **Unique OpenGL abstraction layer** (usable as standalone module): [rlgl](https://github.com/raysan5/raylib/blob/master/src/rlgl.h)
- Multiple Fonts formats supported (XNA fonts, AngelCode fonts, TTF) - Multiple Fonts formats supported (XNA fonts, AngelCode fonts, TTF)
- Outstanding texture formats support, including compressed formats (DXT, ETC, ASTC) - Outstanding texture formats support, including compressed formats (DXT, ETC, ASTC)
- **Full 3d support** for 3d Shapes, Models, Billboards, Heightmaps and more! - **Full 3d support** for 3d Shapes, Models, Billboards, Heightmaps and more!
@ -31,7 +31,7 @@ features
- **Powerful math module** for Vector, Matrix and Quaternion operations: [raymath](https://github.com/raysan5/raylib/blob/master/src/raymath.h) - **Powerful math module** for Vector, Matrix and Quaternion operations: [raymath](https://github.com/raysan5/raylib/blob/master/src/raymath.h)
- Audio loading and playing with streaming support (WAV, OGG, MP3, FLAC, XM, MOD) - Audio loading and playing with streaming support (WAV, OGG, MP3, FLAC, XM, MOD)
- **VR stereo rendering** support with configurable HMD device parameters - **VR stereo rendering** support with configurable HMD device parameters
- Bindings to **Lua** ([raylib-lua](https://github.com/raysan5/raylib-lua)), **Go** ([raylib-go](https://github.com/gen2brain/raylib-go)) and more! - Bindings to **Lua** ([raylib-lua](https://github.com/raysan5/raylib-lua)), **Go** ([raylib-go](https://github.com/gen2brain/raylib-go)) and [more](https://github.com/raysan5/raylib/blob/master/CONTRIBUTING.md#raylib-bindings)!
raylib uses on its [core](https://github.com/raysan5/raylib/blob/master/src/core.c) module the outstanding [GLFW3](http://www.glfw.org/) library, embedded inside raylib in the form of [rglfw](https://github.com/raysan5/raylib/blob/master/src/rglfw.c) module, avoiding that way external dependencies. raylib uses on its [core](https://github.com/raysan5/raylib/blob/master/src/core.c) module the outstanding [GLFW3](http://www.glfw.org/) library, embedded inside raylib in the form of [rglfw](https://github.com/raysan5/raylib/blob/master/src/rglfw.c) module, avoiding that way external dependencies.

View file

@ -5,8 +5,7 @@
* This example has been created using raylib 1.8 (www.raylib.com) * This example has been created using raylib 1.8 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
* *
* Example based on Berni work on Raspberry Pi: * Example based on Berni work on Raspberry Pi.
* http://forum.raylib.com/index.php?p=/discussion/124/line-versus-triangle-drawing-order
* *
* Copyright (c) 2017 Ramon Santamaria (@raysan5) * Copyright (c) 2017 Ramon Santamaria (@raysan5)
* *

View file

@ -64,29 +64,32 @@ typedef struct Pose {
} Pose; } Pose;
typedef struct Animation { typedef struct Animation {
int jointCount; int jointCount; // Number of joints (bones)
Joint *joints; // NOTE: Joints in anims do not have names Joint *joints; // Joints array
// NOTE: Joints in anims do not have names
int frameCount; int frameCount; // Number of animation frames
float framerate; float framerate; // Frame change speed
Pose **framepose; Pose **framepose; // Poses array by frame (and one pose by joint)
} Animation; } Animation;
// Animated Model type // Animated Model type
typedef struct AnimatedModel { typedef struct AnimatedModel {
int meshCount; Matrix transform; // Local transform matrix
Mesh *mesh;
int meshCount; // Number of meshes
Mesh *meshes; // Meshes array
int materialCount; int materialCount; // Number of materials
int *meshMaterialId; Material *materials; // Materials array
Material *materials;
int *meshMaterialId; // Mesh materials ids
int jointCount; // Animation required data
Joint *joints; int jointCount; // Number of joints (and keyposes)
Joint *joints; // Mesh joints (bones)
Pose *basepose; Pose *basepose; // Mesh base-poses by joint
Matrix transform;
} AnimatedModel; } AnimatedModel;
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
@ -233,7 +236,7 @@ AnimatedModel LoadAnimatedModel(const char *filename)
{ {
AnimatedModel out = LoadIQM(filename); AnimatedModel out = LoadIQM(filename);
for (int i = 0; i < out.meshCount; i++) rlLoadMesh(&out.mesh[i], false); for (int i = 0; i < out.meshCount; i++) rlLoadMesh(&out.meshes[i], false);
out.transform = MatrixIdentity(); out.transform = MatrixIdentity();
out.meshMaterialId = malloc(sizeof(int)*out.meshCount); out.meshMaterialId = malloc(sizeof(int)*out.meshCount);
@ -258,7 +261,7 @@ AnimatedModel AnimatedModelAddTexture(AnimatedModel model, const char *filename)
return model; return model;
} }
// Set the material for a mesh // Set the material for a meshes
AnimatedModel SetMeshMaterial(AnimatedModel model, int meshid, int textureid) AnimatedModel SetMeshMaterial(AnimatedModel model, int meshid, int textureid)
{ {
if (meshid > model.meshCount) if (meshid > model.meshCount)
@ -466,9 +469,9 @@ void UnloadAnimatedModel(AnimatedModel model)
free(model.joints); free(model.joints);
free(model.basepose); free(model.basepose);
for (int i = 0; i < model.meshCount; i++) rlUnloadMesh(&model.mesh[i]); for (int i = 0; i < model.meshCount; i++) rlUnloadMesh(&model.meshes[i]);
free(model.mesh); free(model.meshes);
} }
// Unload animation // Unload animation
@ -515,9 +518,9 @@ void AnimateModel(AnimatedModel model, Animation anim, int frame)
int wcounter = 0; int wcounter = 0;
int weightId = 0; int weightId = 0;
for (int i = 0; i < model.mesh[m].vertexCount; i++) for (int i = 0; i < model.meshes[m].vertexCount; i++)
{ {
weightId = model.mesh[m].weightId[wcounter]; weightId = model.meshes[m].weightId[wcounter];
baset = model.basepose[weightId].translation; baset = model.basepose[weightId].translation;
baser = model.basepose[weightId].rotation; baser = model.basepose[weightId].rotation;
bases = model.basepose[weightId].scale; bases = model.basepose[weightId].scale;
@ -526,23 +529,23 @@ void AnimateModel(AnimatedModel model, Animation anim, int frame)
outs = anim.framepose[frame][weightId].scale; outs = anim.framepose[frame][weightId].scale;
// vertices // vertices
// NOTE: We use mesh.baseVertices (default position) to calculate mesh.vertices (animated position) // NOTE: We use meshes.baseVertices (default position) to calculate meshes.vertices (animated position)
outv = (Vector3){ model.mesh[m].baseVertices[vcounter], model.mesh[m].baseVertices[vcounter + 1], model.mesh[m].baseVertices[vcounter + 2] }; outv = (Vector3){ model.meshes[m].baseVertices[vcounter], model.meshes[m].baseVertices[vcounter + 1], model.meshes[m].baseVertices[vcounter + 2] };
outv = Vector3MultiplyV(outv, outs); outv = Vector3MultiplyV(outv, outs);
outv = Vector3Subtract(outv, baset); outv = Vector3Subtract(outv, baset);
outv = Vector3RotateByQuaternion(outv, QuaternionMultiply(outr, QuaternionInvert(baser))); outv = Vector3RotateByQuaternion(outv, QuaternionMultiply(outr, QuaternionInvert(baser)));
outv = Vector3Add(outv, outt); outv = Vector3Add(outv, outt);
model.mesh[m].vertices[vcounter] = outv.x; model.meshes[m].vertices[vcounter] = outv.x;
model.mesh[m].vertices[vcounter + 1] = outv.y; model.meshes[m].vertices[vcounter + 1] = outv.y;
model.mesh[m].vertices[vcounter + 2] = outv.z; model.meshes[m].vertices[vcounter + 2] = outv.z;
// normals // normals
// NOTE: We use mesh.baseNormals (default normal) to calculate mesh.normals (animated normals) // NOTE: We use meshes.baseNormals (default normal) to calculate meshes.normals (animated normals)
outn = (Vector3){ model.mesh[m].baseNormals[vcounter], model.mesh[m].baseNormals[vcounter + 1], model.mesh[m].baseNormals[vcounter + 2] }; outn = (Vector3){ model.meshes[m].baseNormals[vcounter], model.meshes[m].baseNormals[vcounter + 1], model.meshes[m].baseNormals[vcounter + 2] };
outn = Vector3RotateByQuaternion(outn, QuaternionMultiply(outr, QuaternionInvert(baser))); outn = Vector3RotateByQuaternion(outn, QuaternionMultiply(outr, QuaternionInvert(baser)));
model.mesh[m].normals[vcounter] = outn.x; model.meshes[m].normals[vcounter] = outn.x;
model.mesh[m].normals[vcounter + 1] = outn.y; model.meshes[m].normals[vcounter + 1] = outn.y;
model.mesh[m].normals[vcounter + 2] = outn.z; model.meshes[m].normals[vcounter + 2] = outn.z;
vcounter += 3; vcounter += 3;
wcounter += 4; wcounter += 4;
} }
@ -563,7 +566,7 @@ void DrawAnimatedModelEx(AnimatedModel model, Vector3 position, Vector3 rotation
{ {
if (model.materialCount == 0) if (model.materialCount == 0)
{ {
TraceLog(LOG_WARNING,"No materials set, can't draw animated mesh\n"); TraceLog(LOG_WARNING,"No materials set, can't draw animated meshes\n");
return; return;
} }
@ -576,9 +579,9 @@ void DrawAnimatedModelEx(AnimatedModel model, Vector3 position, Vector3 rotation
for (int i = 0; i < model.meshCount; i++) for (int i = 0; i < model.meshCount; i++)
{ {
rlUpdateMesh(model.mesh[i], 0, model.mesh[i].vertexCount); // Update vertex position rlUpdateMesh(model.meshes[i], 0, model.meshes[i].vertexCount); // Update vertex position
rlUpdateMesh(model.mesh[i], 2, model.mesh[i].vertexCount); // Update vertex normals rlUpdateMesh(model.meshes[i], 2, model.meshes[i].vertexCount); // Update vertex normals
rlDrawMesh(model.mesh[i], model.materials[model.meshMaterialId[i]], model.transform); // Draw mesh rlDrawMesh(model.meshes[i], model.materials[model.meshMaterialId[i]], model.transform); // Draw meshes
} }
} }
@ -632,7 +635,7 @@ static AnimatedModel LoadIQM(const char *filename)
fread(imesh, sizeof(IQMMesh)*iqm.num_meshes, 1, iqmFile); fread(imesh, sizeof(IQMMesh)*iqm.num_meshes, 1, iqmFile);
model.meshCount = iqm.num_meshes; model.meshCount = iqm.num_meshes;
model.mesh = malloc(sizeof(Mesh)*iqm.num_meshes); model.meshes = malloc(sizeof(Mesh)*iqm.num_meshes);
char name[MESH_NAME_LENGTH]; char name[MESH_NAME_LENGTH];
@ -640,21 +643,21 @@ static AnimatedModel LoadIQM(const char *filename)
{ {
fseek(iqmFile,iqm.ofs_text+imesh[i].name,SEEK_SET); fseek(iqmFile,iqm.ofs_text+imesh[i].name,SEEK_SET);
fread(name, sizeof(char)*MESH_NAME_LENGTH, 1, iqmFile); // Mesh name not used... fread(name, sizeof(char)*MESH_NAME_LENGTH, 1, iqmFile); // Mesh name not used...
model.mesh[i].vertexCount = imesh[i].num_vertexes; model.meshes[i].vertexCount = imesh[i].num_vertexes;
model.mesh[i].baseVertices = malloc(sizeof(float)*imesh[i].num_vertexes*3); // Default IQM base position model.meshes[i].baseVertices = malloc(sizeof(float)*imesh[i].num_vertexes*3); // Default IQM base position
model.mesh[i].baseNormals = malloc(sizeof(float)*imesh[i].num_vertexes*3); // Default IQM base normal model.meshes[i].baseNormals = malloc(sizeof(float)*imesh[i].num_vertexes*3); // Default IQM base normal
model.mesh[i].texcoords = malloc(sizeof(float)*imesh[i].num_vertexes*2); model.meshes[i].texcoords = malloc(sizeof(float)*imesh[i].num_vertexes*2);
model.mesh[i].weightId = malloc(sizeof(int)*imesh[i].num_vertexes*4); model.meshes[i].weightId = malloc(sizeof(int)*imesh[i].num_vertexes*4);
model.mesh[i].weightBias = malloc(sizeof(float)*imesh[i].num_vertexes*4); model.meshes[i].weightBias = malloc(sizeof(float)*imesh[i].num_vertexes*4);
model.mesh[i].triangleCount = imesh[i].num_triangles; model.meshes[i].triangleCount = imesh[i].num_triangles;
model.mesh[i].indices = malloc(sizeof(unsigned short)*imesh[i].num_triangles*3); model.meshes[i].indices = malloc(sizeof(unsigned short)*imesh[i].num_triangles*3);
// What we actually process for rendering, should be updated transforming mesh.vertices and mesh.normals // What we actually process for rendering, should be updated transforming meshes.vertices and meshes.normals
model.mesh[i].vertices = malloc(sizeof(float)*imesh[i].num_vertexes*3); model.meshes[i].vertices = malloc(sizeof(float)*imesh[i].num_vertexes*3);
model.mesh[i].normals = malloc(sizeof(float)*imesh[i].num_vertexes*3); model.meshes[i].normals = malloc(sizeof(float)*imesh[i].num_vertexes*3);
} }
// tris // tris
@ -669,9 +672,9 @@ static AnimatedModel LoadIQM(const char *filename)
for (int i = imesh[m].first_triangle; i < imesh[m].first_triangle+imesh[m].num_triangles; i++) for (int i = imesh[m].first_triangle; i < imesh[m].first_triangle+imesh[m].num_triangles; i++)
{ {
// IQM triangles are stored counter clockwise, but raylib sets opengl to clockwise drawing, so we swap them around // IQM triangles are stored counter clockwise, but raylib sets opengl to clockwise drawing, so we swap them around
model.mesh[m].indices[tcounter+2] = tri[i].vertex[0] - imesh[m].first_vertex; model.meshes[m].indices[tcounter+2] = tri[i].vertex[0] - imesh[m].first_vertex;
model.mesh[m].indices[tcounter+1] = tri[i].vertex[1] - imesh[m].first_vertex; model.meshes[m].indices[tcounter+1] = tri[i].vertex[1] - imesh[m].first_vertex;
model.mesh[m].indices[tcounter] = tri[i].vertex[2] - imesh[m].first_vertex; model.meshes[m].indices[tcounter] = tri[i].vertex[2] - imesh[m].first_vertex;
tcounter += 3; tcounter += 3;
} }
} }
@ -696,8 +699,8 @@ static AnimatedModel LoadIQM(const char *filename)
int vcounter = 0; int vcounter = 0;
for (int i = imesh[m].first_vertex*3; i < (imesh[m].first_vertex + imesh[m].num_vertexes)*3; i++) for (int i = imesh[m].first_vertex*3; i < (imesh[m].first_vertex + imesh[m].num_vertexes)*3; i++)
{ {
model.mesh[m].vertices[vcounter] = vertex[i]; model.meshes[m].vertices[vcounter] = vertex[i];
model.mesh[m].baseVertices[vcounter] = vertex[i]; model.meshes[m].baseVertices[vcounter] = vertex[i];
vcounter++; vcounter++;
} }
} }
@ -713,8 +716,8 @@ static AnimatedModel LoadIQM(const char *filename)
int vcounter = 0; int vcounter = 0;
for (int i = imesh[m].first_vertex*3; i < (imesh[m].first_vertex + imesh[m].num_vertexes)*3; i++) for (int i = imesh[m].first_vertex*3; i < (imesh[m].first_vertex + imesh[m].num_vertexes)*3; i++)
{ {
model.mesh[m].normals[vcounter] = normal[i]; model.meshes[m].normals[vcounter] = normal[i];
model.mesh[m].baseNormals[vcounter] = normal[i]; model.meshes[m].baseNormals[vcounter] = normal[i];
vcounter++; vcounter++;
} }
} }
@ -730,7 +733,7 @@ static AnimatedModel LoadIQM(const char *filename)
int vcounter = 0; int vcounter = 0;
for (int i = imesh[m].first_vertex*2; i < (imesh[m].first_vertex + imesh[m].num_vertexes)*2; i++) for (int i = imesh[m].first_vertex*2; i < (imesh[m].first_vertex + imesh[m].num_vertexes)*2; i++)
{ {
model.mesh[m].texcoords[vcounter] = text[i]; model.meshes[m].texcoords[vcounter] = text[i];
vcounter++; vcounter++;
} }
} }
@ -746,7 +749,7 @@ static AnimatedModel LoadIQM(const char *filename)
int vcounter = 0; int vcounter = 0;
for (int i = imesh[m].first_vertex*4; i < (imesh[m].first_vertex + imesh[m].num_vertexes)*4; i++) for (int i = imesh[m].first_vertex*4; i < (imesh[m].first_vertex + imesh[m].num_vertexes)*4; i++)
{ {
model.mesh[m].weightId[vcounter] = blendi[i]; model.meshes[m].weightId[vcounter] = blendi[i];
vcounter++; vcounter++;
} }
} }
@ -762,7 +765,7 @@ static AnimatedModel LoadIQM(const char *filename)
int vcounter = 0; int vcounter = 0;
for (int i = imesh[m].first_vertex*4; i < (imesh[m].first_vertex + imesh[m].num_vertexes)*4; i++) for (int i = imesh[m].first_vertex*4; i < (imesh[m].first_vertex + imesh[m].num_vertexes)*4; i++)
{ {
model.mesh[m].weightBias[vcounter] = blendw[i]/255.0f; model.meshes[m].weightBias[vcounter] = blendw[i]/255.0f;
vcounter++; vcounter++;
} }
} }

View file

@ -17,6 +17,7 @@
#include "raylib.h" #include "raylib.h"
#define PHYSAC_IMPLEMENTATION #define PHYSAC_IMPLEMENTATION
#define PHYSAC_NO_THREADS
#include "physac.h" #include "physac.h"
int main() int main()
@ -54,6 +55,8 @@ int main()
// Update // Update
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Delay initialization of variables due to physics reset async // Delay initialization of variables due to physics reset async
RunPhysicsStep();
if (needsReset) if (needsReset)
{ {
floor = CreatePhysicsBodyRectangle((Vector2){ screenWidth/2, screenHeight }, 500, 100, 10); floor = CreatePhysicsBodyRectangle((Vector2){ screenWidth/2, screenHeight }, 500, 100, 10);
@ -61,6 +64,8 @@ int main()
circle = CreatePhysicsBodyCircle((Vector2){ screenWidth/2, screenHeight/2 }, 45, 10); circle = CreatePhysicsBodyCircle((Vector2){ screenWidth/2, screenHeight/2 }, 45, 10);
circle->enabled = false; circle->enabled = false;
needsReset = false;
} }
// Reset physics input // Reset physics input
@ -134,4 +139,3 @@ int main()
return 0; return 0;
} }

View file

@ -17,6 +17,7 @@
#include "raylib.h" #include "raylib.h"
#define PHYSAC_IMPLEMENTATION #define PHYSAC_IMPLEMENTATION
#define PHYSAC_NO_THREADS
#include "physac.h" #include "physac.h"
int main() int main()
@ -71,6 +72,8 @@ int main()
{ {
// Update // Update
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
RunPhysicsStep();
if (IsKeyPressed('R')) // Reset physics input if (IsKeyPressed('R')) // Reset physics input
{ {
// Reset dynamic physics bodies position, velocity and rotation // Reset dynamic physics bodies position, velocity and rotation
@ -141,4 +144,3 @@ int main()
return 0; return 0;
} }

View file

@ -17,6 +17,7 @@
#include "raylib.h" #include "raylib.h"
#define PHYSAC_IMPLEMENTATION #define PHYSAC_IMPLEMENTATION
#define PHYSAC_NO_THREADS
#include "physac.h" #include "physac.h"
#define VELOCITY 0.5f #define VELOCITY 0.5f
@ -64,6 +65,8 @@ int main()
{ {
// Update // Update
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
RunPhysicsStep();
if (IsKeyPressed('R')) // Reset physics input if (IsKeyPressed('R')) // Reset physics input
{ {
// Reset movement physics body position, velocity and rotation // Reset movement physics body position, velocity and rotation
@ -127,4 +130,3 @@ int main()
return 0; return 0;
} }

View file

@ -17,6 +17,7 @@
#include "raylib.h" #include "raylib.h"
#define PHYSAC_IMPLEMENTATION #define PHYSAC_IMPLEMENTATION
#define PHYSAC_NO_THREADS
#include "physac.h" #include "physac.h"
int main() int main()
@ -50,6 +51,9 @@ int main()
circleC->restitution = 1; circleC->restitution = 1;
SetTargetFPS(60); SetTargetFPS(60);
// Restitution demo needs a very tiny physics time step for a proper simulation
SetPhysicsTimeStep(1.0/60.0/100 * 1000);
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
// Main game loop // Main game loop
@ -57,6 +61,8 @@ int main()
{ {
// Update // Update
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
RunPhysicsStep();
if (IsKeyPressed('R')) // Reset physics input if (IsKeyPressed('R')) // Reset physics input
{ {
// Reset circles physics bodies position and velocity // Reset circles physics bodies position and velocity
@ -120,4 +126,3 @@ int main()
return 0; return 0;
} }

View file

@ -17,7 +17,8 @@
#include "raylib.h" #include "raylib.h"
#define PHYSAC_IMPLEMENTATION #define PHYSAC_IMPLEMENTATION
#include "physac.h" #define PHYSAC_NO_THREADS
#include "physac.h"
int main() int main()
{ {
@ -48,12 +49,15 @@ int main()
while (!WindowShouldClose()) // Detect window close button or ESC key while (!WindowShouldClose()) // Detect window close button or ESC key
{ {
// Update // Update
RunPhysicsStep();
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Delay initialization of variables due to physics reset asynchronous // Delay initialization of variables due to physics reset asynchronous
if (needsReset) if (needsReset)
{ {
// Create random polygon physics body to shatter // Create random polygon physics body to shatter
CreatePhysicsBodyPolygon((Vector2){ screenWidth/2, screenHeight/2 }, GetRandomValue(80, 200), GetRandomValue(3, 8), 10); CreatePhysicsBodyPolygon((Vector2){ screenWidth/2, screenHeight/2 }, GetRandomValue(80, 200), GetRandomValue(3, 8), 10);
needsReset = false;
} }
if (IsKeyPressed('R')) // Reset physics input if (IsKeyPressed('R')) // Reset physics input
@ -118,4 +122,3 @@ int main()
return 0; return 0;
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.1 KiB

After

Width:  |  Height:  |  Size: 6.4 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 37 KiB

After

Width:  |  Height:  |  Size: 44 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 28 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 32 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.4 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

Before After
Before After

Some files were not shown because too many files have changed in this diff Show more