Working on examples...

- Removed rbmf font example
- Reviewed physac examples
This commit is contained in:
raysan5 2017-04-16 19:08:19 +02:00
parent c67cffea38
commit b4d28cc7a1
29 changed files with 75 additions and 51 deletions

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);

Binary file not shown.

After

Width:  |  Height:  |  Size: 96 KiB

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;
}

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;
}

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;
}

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;
}

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;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

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[8];
SpriteFont fonts[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[8] = { "ALAGARD FONT designed by Hewett Tsoi",
const char *messages[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[8] = { 2, 4, 8, 4, 3, 4, 4, 1 };
const int spacings[MAX_FONTS] = { 2, 4, 8, 4, 3, 4, 4, 1 };
Vector2 positions[8];
Vector2 positions[MAX_FONTS];
for (int i = 0; i < 8; i++)
for (int i = 0; i < 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 < 8; i++)
for (int i = 0; i < 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 < 8; i++) UnloadSpriteFont(fonts[i]);
for (int i = 0; i < MAX_FONTS; i++) UnloadSpriteFont(fonts[i]);
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

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];

Binary file not shown.

After

Width:  |  Height:  |  Size: 411 KiB