Browse Source

Working on examples...

- Removed rbmf font example
- Reviewed physac examples
pull/262/head
raysan5 7 years ago
parent
commit
b4d28cc7a1
29 changed files with 75 additions and 51 deletions
  1. +8
    -10
      examples/models/models_mesh_picking.c
  2. BIN
      examples/models/models_mesh_picking.png
  3. +6
    -3
      examples/physac/physics_demo.c
  4. +7
    -3
      examples/physac/physics_friction.c
  5. +8
    -4
      examples/physac/physics_movement.c
  6. +7
    -3
      examples/physac/physics_restitution.c
  7. +7
    -3
      examples/physac/physics_shatter.c
  8. BIN
      examples/text/resources/fonts/alagard.png
  9. BIN
      examples/text/resources/fonts/alagard.rbmf
  10. BIN
      examples/text/resources/fonts/alpha_beta.png
  11. BIN
      examples/text/resources/fonts/alpha_beta.rbmf
  12. BIN
      examples/text/resources/fonts/jupiter_crash.png
  13. BIN
      examples/text/resources/fonts/jupiter_crash.rbmf
  14. BIN
      examples/text/resources/fonts/mecha.png
  15. BIN
      examples/text/resources/fonts/mecha.rbmf
  16. BIN
      examples/text/resources/fonts/pixantiqua.png
  17. BIN
      examples/text/resources/fonts/pixantiqua.rbmf
  18. BIN
      examples/text/resources/fonts/pixelplay.png
  19. BIN
      examples/text/resources/fonts/pixelplay.rbmf
  20. BIN
      examples/text/resources/fonts/romulus.png
  21. BIN
      examples/text/resources/fonts/romulus.rbmf
  22. BIN
      examples/text/resources/fonts/setback.png
  23. BIN
      examples/text/resources/fonts/setback.rbmf
  24. +0
    -0
      examples/text/resources/pixantiqua.fnt
  25. +28
    -21
      examples/text/text_raylib_fonts.c
  26. BIN
      examples/text/text_raylib_fonts.png
  27. BIN
      examples/text/text_rbmf_fonts.png
  28. +4
    -4
      examples/textures/textures_particles_blending.c
  29. BIN
      examples/textures/textures_particles_blending.png

examples/models/models_ray_picking.c → examples/models/models_mesh_picking.c View File

@ -1,6 +1,6 @@
/*******************************************************************************************
*
* raylib [models] example - Ray picking in 3d mode, ground plane, triangle, mesh
* raylib [models] example - Mesh picking in 3d mode, ground plane, triangle, mesh
*
* This example has been created using raylib 1.7 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
@ -13,9 +13,7 @@
#include "raylib.h"
#include "raymath.h"
#include <stdio.h>
#include <float.h>
#define FLT_MAX 3.40282347E+38F // Maximum value of a float, defined in <float.h>
int main()
{
@ -24,7 +22,7 @@ int main()
int screenWidth = 800;
int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [models] example - 3d ray picking");
InitWindow(screenWidth, screenHeight, "raylib [models] example - mesh picking");
// Define the camera to look into our 3d world
Camera camera;
@ -33,7 +31,7 @@ int main()
camera.up = (Vector3){ 0.0f, 1.6f, 0.0f }; // Camera up vector (rotation towards target)
camera.fovy = 45.0f; // Camera field-of-view Y
Ray ray; // Picking line ray
Ray ray; // Picking ray
Model tower = LoadModel("resources/tower.obj"); // Load OBJ model
Texture2D texture = LoadTexture("resources/tower.png"); // Load model texture
@ -91,7 +89,7 @@ int main()
cursorColor = PURPLE;
hitObjectName = "Triangle";
bary = Barycenter(nearestHit.hitPosition, ta, tb, tc);
bary = VectorBarycenter(nearestHit.hitPosition, ta, tb, tc);
hitTriangle = true;
}
else hitTriangle = false;
@ -138,15 +136,15 @@ int main()
// If we hit something, draw the cursor at the hit point
if (nearestHit.hit)
{
DrawCube(nearestHit.hitPosition, 0.5, 0.5, 0.5, cursorColor);
DrawCubeWires(nearestHit.hitPosition, 0.5, 0.5, 0.5, YELLOW);
DrawCube(nearestHit.hitPosition, 0.3, 0.3, 0.3, cursorColor);
DrawCubeWires(nearestHit.hitPosition, 0.3, 0.3, 0.3, RED);
Vector3 normalEnd;
normalEnd.x = nearestHit.hitPosition.x + nearestHit.hitNormal.x;
normalEnd.y = nearestHit.hitPosition.y + nearestHit.hitNormal.y;
normalEnd.z = nearestHit.hitPosition.z + nearestHit.hitNormal.z;
DrawLine3D(nearestHit.hitPosition, normalEnd, YELLOW);
DrawLine3D(nearestHit.hitPosition, normalEnd, RED);
}
DrawRay(ray, MAROON);

BIN
examples/models/models_mesh_picking.png View File

Before After
Width: 800  |  Height: 450  |  Size: 96 KiB

+ 6
- 3
examples/physac/physics_demo.c View File

@ -2,9 +2,11 @@
*
* Physac - Physics demo
*
* NOTE: Physac requires multi-threading, when InitPhysics() a second thread is created to manage physics calculations.
* NOTE 1: Physac requires multi-threading, when InitPhysics() a second thread is created to manage physics calculations.
* NOTE 2: Physac requires static C library linkage to avoid dependency on MinGW DLL (-static -lpthread)
*
* Use the following line to compile:
*
* Use the following code to compile (-static -lpthread):
* gcc -o $(NAME_PART).exe $(FILE_NAME) -s $(RAYLIB_DIR)\raylib\raylib_icon -static -lraylib -lpthread
* -lglfw3 -lopengl32 -lgdi32 -lopenal32 -lwinmm -std=c99 -Wl,--subsystem,windows -Wl,-allow-multiple-definition
*
@ -15,7 +17,7 @@
#include "raylib.h"
#define PHYSAC_IMPLEMENTATION
#include "../src/physac.h"
#include "physac.h"
int main()
{
@ -123,3 +125,4 @@ int main()
return 0;
}

+ 7
- 3
examples/physac/physics_friction.c View File

@ -2,9 +2,11 @@
*
* Physac - Physics friction
*
* NOTE: Physac requires multi-threading, when InitPhysics() a second thread is created to manage physics calculations.
* NOTE 1: Physac requires multi-threading, when InitPhysics() a second thread is created to manage physics calculations.
* NOTE 2: Physac requires static C library linkage to avoid dependency on MinGW DLL (-static -lpthread)
*
* Use the following line to compile:
*
* Use the following code to compile (-static -lpthread):
* gcc -o $(NAME_PART).exe $(FILE_NAME) -s $(RAYLIB_DIR)\raylib\raylib_icon -static -lraylib -lpthread
* -lglfw3 -lopengl32 -lgdi32 -lopenal32 -lwinmm -std=c99 -Wl,--subsystem,windows -Wl,-allow-multiple-definition
*
@ -15,7 +17,7 @@
#include "raylib.h"
#define PHYSAC_IMPLEMENTATION
#include "../src/physac.h"
#include "physac.h"
int main()
{
@ -132,8 +134,10 @@ int main()
// De-Initialization
//--------------------------------------------------------------------------------------
ClosePhysics(); // Unitialize physics
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
return 0;
}

+ 8
- 4
examples/physac/physics_movement.c View File

@ -2,9 +2,11 @@
*
* Physac - Physics movement
*
* NOTE: Physac requires multi-threading, when InitPhysics() a second thread is created to manage physics calculations.
* NOTE 1: Physac requires multi-threading, when InitPhysics() a second thread is created to manage physics calculations.
* NOTE 2: Physac requires static C library linkage to avoid dependency on MinGW DLL (-static -lpthread)
*
* Use the following line to compile:
*
* Use the following code to compile (-static -lpthread):
* gcc -o $(NAME_PART).exe $(FILE_NAME) -s $(RAYLIB_DIR)\raylib\raylib_icon -static -lraylib -lpthread
* -lglfw3 -lopengl32 -lgdi32 -lopenal32 -lwinmm -std=c99 -Wl,--subsystem,windows -Wl,-allow-multiple-definition
*
@ -15,9 +17,9 @@
#include "raylib.h"
#define PHYSAC_IMPLEMENTATION
#include "../src/physac.h"
#include "physac.h"
#define VELOCITY 0.5f
#define VELOCITY 0.5f
int main()
{
@ -118,8 +120,10 @@ int main()
// De-Initialization
//--------------------------------------------------------------------------------------
ClosePhysics(); // Unitialize physics
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
return 0;
}

+ 7
- 3
examples/physac/physics_restitution.c View File

@ -2,9 +2,11 @@
*
* Physac - Physics restitution
*
* NOTE: Physac requires multi-threading, when InitPhysics() a second thread is created to manage physics calculations.
* NOTE 1: Physac requires multi-threading, when InitPhysics() a second thread is created to manage physics calculations.
* NOTE 2: Physac requires static C library linkage to avoid dependency on MinGW DLL (-static -lpthread)
*
* Use the following line to compile:
*
* Use the following code to compile (-static -lpthread):
* gcc -o $(NAME_PART).exe $(FILE_NAME) -s $(RAYLIB_DIR)\raylib\raylib_icon -static -lraylib -lpthread
* -lglfw3 -lopengl32 -lgdi32 -lopenal32 -lwinmm -std=c99 -Wl,--subsystem,windows -Wl,-allow-multiple-definition
*
@ -15,7 +17,7 @@
#include "raylib.h"
#define PHYSAC_IMPLEMENTATION
#include "../src/physac.h"
#include "physac.h"
int main()
{
@ -111,8 +113,10 @@ int main()
// De-Initialization
//--------------------------------------------------------------------------------------
ClosePhysics(); // Unitialize physics
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
return 0;
}

+ 7
- 3
examples/physac/physics_shatter.c View File

@ -2,9 +2,11 @@
*
* Physac - Body shatter
*
* NOTE: Physac requires multi-threading, when InitPhysics() a second thread is created to manage physics calculations.
* NOTE 1: Physac requires multi-threading, when InitPhysics() a second thread is created to manage physics calculations.
* NOTE 2: Physac requires static C library linkage to avoid dependency on MinGW DLL (-static -lpthread)
*
* Use the following line to compile:
*
* Use the following code to compile (-static -lpthread):
* gcc -o $(NAME_PART).exe $(FILE_NAME) -s $(RAYLIB_DIR)\raylib\raylib_icon -static -lraylib -lpthread
* -lglfw3 -lopengl32 -lgdi32 -lopenal32 -lwinmm -std=c99 -Wl,--subsystem,windows -Wl,-allow-multiple-definition
*
@ -15,7 +17,7 @@
#include "raylib.h"
#define PHYSAC_IMPLEMENTATION
#include "../src/physac.h"
#include "physac.h"
int main()
{
@ -103,8 +105,10 @@ int main()
// De-Initialization
//--------------------------------------------------------------------------------------
ClosePhysics(); // Unitialize physics
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
return 0;
}

BIN
examples/text/resources/fonts/alagard.png View File

Before After
Width: 128  |  Height: 128  |  Size: 4.3 KiB

BIN
examples/text/resources/fonts/alagard.rbmf View File


BIN
examples/text/resources/fonts/alpha_beta.png View File

Before After
Width: 128  |  Height: 128  |  Size: 2.4 KiB

BIN
examples/text/resources/fonts/alpha_beta.rbmf View File


BIN
examples/text/resources/fonts/jupiter_crash.png View File

Before After
Width: 128  |  Height: 128  |  Size: 3.4 KiB

BIN
examples/text/resources/fonts/jupiter_crash.rbmf View File


BIN
examples/text/resources/fonts/mecha.png View File

Before After
Width: 128  |  Height: 128  |  Size: 2.3 KiB

BIN
examples/text/resources/fonts/mecha.rbmf View File


BIN
examples/text/resources/fonts/pixantiqua.png View File

Before After
Width: 128  |  Height: 128  |  Size: 2.9 KiB

BIN
examples/text/resources/fonts/pixantiqua.rbmf View File


BIN
examples/text/resources/fonts/pixelplay.png View File

Before After
Width: 128  |  Height: 128  |  Size: 2.8 KiB

BIN
examples/text/resources/fonts/pixelplay.rbmf View File


BIN
examples/text/resources/fonts/romulus.png View File

Before After
Width: 128  |  Height: 128  |  Size: 2.9 KiB

BIN
examples/text/resources/fonts/romulus.rbmf View File


BIN
examples/text/resources/fonts/setback.png View File

Before After
Width: 128  |  Height: 128  |  Size: 2.5 KiB

BIN
examples/text/resources/fonts/setback.rbmf View File


examples/text/resources/fonts/pixantiqua.fnt → examples/text/resources/pixantiqua.fnt View File


examples/text/text_rbmf_fonts.c → examples/text/text_raylib_fonts.c View File

@ -1,19 +1,21 @@
/*******************************************************************************************
*
* raylib [text] example - raylib bitmap font (rbmf) loading and usage
* raylib [text] example - raylib font loading and usage
*
* NOTE: raylib is distributed with some free to use fonts (even for commercial pourposes!)
* To view details and credits for those fonts, check raylib license file
*
* This example has been created using raylib 1.3 (www.raylib.com)
* This example has been created using raylib 1.7 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
*
* Copyright (c) 2015 Ramon Santamaria (@raysan5)
* Copyright (c) 2017 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
#include "raylib.h"
#define MAX_FONTS 8
int main()
{
// Initialization
@ -21,21 +23,21 @@ int main()
int screenWidth = 800;
int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [text] example - rBMF fonts");
InitWindow(screenWidth, screenHeight, "raylib [text] example - raylib fonts");
// NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required)
SpriteFont fonts[mi">8];
SpriteFont fonts[n">MAX_FONTS];
fonts[0] = LoadSpriteFont("resources/fonts/alagard.rbmf"); // rBMF font loading
fonts[1] = LoadSpriteFont("resources/fonts/pixelplay.rbmf"); // rBMF font loading
fonts[2] = LoadSpriteFont("resources/fonts/mecha.rbmf"); // rBMF font loading
fonts[3] = LoadSpriteFont("resources/fonts/setback.rbmf"); // rBMF font loading
fonts[4] = LoadSpriteFont("resources/fonts/romulus.rbmf"); // rBMF font loading
fonts[5] = LoadSpriteFont("resources/fonts/pixantiqua.rbmf"); // rBMF font loading
fonts[6] = LoadSpriteFont("resources/fonts/alpha_beta.rbmf"); // rBMF font loading
fonts[7] = LoadSpriteFont("resources/fonts/jupiter_crash.rbmf"); // rBMF font loading
fonts[0] = LoadSpriteFont("resources/fonts/alagard.png");
fonts[1] = LoadSpriteFont("resources/fonts/pixelplay.png");
fonts[2] = LoadSpriteFont("resources/fonts/mecha.png");
fonts[3] = LoadSpriteFont("resources/fonts/setback.png");
fonts[4] = LoadSpriteFont("resources/fonts/romulus.png");
fonts[5] = LoadSpriteFont("resources/fonts/pixantiqua.png");
fonts[6] = LoadSpriteFont("resources/fonts/alpha_beta.png");
fonts[7] = LoadSpriteFont("resources/fonts/jupiter_crash.png");
const char *messages[mi">8] = { "ALAGARD FONT designed by Hewett Tsoi",
const char *messages[n">MAX_FONTS] = { "ALAGARD FONT designed by Hewett Tsoi",
"PIXELPLAY FONT designed by Aleksander Shevchuk",
"MECHA FONT designed by Captain Falcon",
"SETBACK FONT designed by Brian Kent (AEnigma)",
@ -44,17 +46,22 @@ int main()
"ALPHA_BETA FONT designed by Brian Kent (AEnigma)",
"JUPITER_CRASH FONT designed by Brian Kent (AEnigma)" };
const int spacings[mi">8] = { 2, 4, 8, 4, 3, 4, 4, 1 };
const int spacings[n">MAX_FONTS] = { 2, 4, 8, 4, 3, 4, 4, 1 };
Vector2 positions[mi">8];
Vector2 positions[n">MAX_FONTS];
for (int i = 0; i < mi">8; i++)
for (int i = 0; i < n">MAX_FONTS; i++)
{
positions[i].x = screenWidth/2 - MeasureTextEx(fonts[i], messages[i], fonts[i].baseSize*2, spacings[i]).x/2;
positions[i].y = 60 + fonts[i].baseSize + 50*i;
positions[i].y = 60 + fonts[i].baseSize + 45*i;
}
Color colors[8] = { MAROON, ORANGE, DARKGREEN, DARKBLUE, DARKPURPLE, LIME, GOLD };
// Small Y position corrections
positions[3].y += 8;
positions[4].y += 2;
positions[7].y -= 8;
Color colors[MAX_FONTS] = { MAROON, ORANGE, DARKGREEN, DARKBLUE, DARKPURPLE, LIME, GOLD, RED };
//--------------------------------------------------------------------------------------
// Main game loop
@ -74,7 +81,7 @@ int main()
DrawText("free fonts included with raylib", 250, 20, 20, DARKGRAY);
DrawLine(220, 50, 590, 50, DARKGRAY);
for (int i = 0; i < mi">8; i++)
for (int i = 0; i < n">MAX_FONTS; i++)
{
DrawTextEx(fonts[i], messages[i], positions[i], fonts[i].baseSize*2, spacings[i], colors[i]);
}
@ -87,7 +94,7 @@ int main()
//--------------------------------------------------------------------------------------
// SpriteFonts unloading
for (int i = 0; i < mi">8; i++) UnloadSpriteFont(fonts[i]);
for (int i = 0; i < n">MAX_FONTS; i++) UnloadSpriteFont(fonts[i]);
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------

BIN
examples/text/text_raylib_fonts.png View File

Before After
Width: 800  |  Height: 450  |  Size: 20 KiB

BIN
examples/text/text_rbmf_fonts.png View File

Before After
Width: 800  |  Height: 450  |  Size: 19 KiB

examples/others/particles_trail_blending.c → examples/textures/textures_particles_blending.c View File

@ -1,11 +1,11 @@
/*******************************************************************************************
*
* raylib example - particles trail blending
* raylib example - particles blending
*
* This example has been created using raylib 1.3 (www.raylib.com)
* This example has been created using raylib 1.7 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
*
* Copyright (c) 2015 Ramon Santamaria (@raysan5)
* Copyright (c) 2017 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
@ -30,7 +30,7 @@ int main()
int screenWidth = 800;
int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [textures] example - particles trail blending");
InitWindow(screenWidth, screenHeight, "raylib [textures] example - particles blending");
// Particles pool, reuse them!
Particle mouseTail[MAX_PARTICLES];

BIN
examples/textures/textures_particles_blending.png View File

Before After
Width: 800  |  Height: 450  |  Size: 411 KiB

Loading…
Cancel
Save