Reviewed some examples to work on RPI
This commit is contained in:
parent
db96cf4a8b
commit
8f95518858
4 changed files with 37 additions and 13 deletions
|
@ -25,14 +25,14 @@ int main()
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [models] example - mesh picking");
|
InitWindow(screenWidth, screenHeight, "raylib [models] example - mesh picking");
|
||||||
|
|
||||||
// Define the camera to look into our 3d world
|
// Define the camera to look into our 3d world
|
||||||
Camera camera;
|
Camera camera = { 0 };
|
||||||
camera.position = (Vector3){ 20.0f, 20.0f, 20.0f }; // Camera position
|
camera.position = (Vector3){ 20.0f, 20.0f, 20.0f }; // Camera position
|
||||||
camera.target = (Vector3){ 0.0f, 8.0f, 0.0f }; // Camera looking at point
|
camera.target = (Vector3){ 0.0f, 8.0f, 0.0f }; // Camera looking at point
|
||||||
camera.up = (Vector3){ 0.0f, 1.6f, 0.0f }; // Camera up vector (rotation towards target)
|
camera.up = (Vector3){ 0.0f, 1.6f, 0.0f }; // Camera up vector (rotation towards target)
|
||||||
camera.fovy = 45.0f; // Camera field-of-view Y
|
camera.fovy = 45.0f; // Camera field-of-view Y
|
||||||
camera.type = CAMERA_PERSPECTIVE; // Camera mode type
|
camera.type = CAMERA_PERSPECTIVE; // Camera mode type
|
||||||
|
|
||||||
Ray ray; // Picking ray
|
Ray ray = { 0 }; // Picking ray
|
||||||
|
|
||||||
Model tower = LoadModel("resources/models/turret.obj"); // Load OBJ model
|
Model tower = LoadModel("resources/models/turret.obj"); // Load OBJ model
|
||||||
Texture2D texture = LoadTexture("resources/models/turret_diffuse.png"); // Load model texture
|
Texture2D texture = LoadTexture("resources/models/turret_diffuse.png"); // Load model texture
|
||||||
|
@ -62,7 +62,7 @@ int main()
|
||||||
UpdateCamera(&camera); // Update camera
|
UpdateCamera(&camera); // Update camera
|
||||||
|
|
||||||
// Display information about closest hit
|
// Display information about closest hit
|
||||||
RayHitInfo nearestHit;
|
RayHitInfo nearestHit = { 0 };
|
||||||
char *hitObjectName = "None";
|
char *hitObjectName = "None";
|
||||||
nearestHit.distance = FLT_MAX;
|
nearestHit.distance = FLT_MAX;
|
||||||
nearestHit.hit = false;
|
nearestHit.hit = false;
|
||||||
|
@ -95,7 +95,7 @@ int main()
|
||||||
}
|
}
|
||||||
else hitTriangle = false;
|
else hitTriangle = false;
|
||||||
|
|
||||||
RayHitInfo meshHitInfo;
|
RayHitInfo meshHitInfo = { 0 };
|
||||||
|
|
||||||
// Check ray collision against bounding box first, before trying the full ray-mesh test
|
// Check ray collision against bounding box first, before trying the full ray-mesh test
|
||||||
if (CheckCollisionRayBox(ray, towerBBox))
|
if (CheckCollisionRayBox(ray, towerBBox))
|
||||||
|
@ -113,7 +113,9 @@ int main()
|
||||||
hitObjectName = "Mesh";
|
hitObjectName = "Mesh";
|
||||||
}
|
}
|
||||||
|
|
||||||
} hitMeshBBox = false;
|
}
|
||||||
|
|
||||||
|
hitMeshBBox = false;
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
|
||||||
// Draw
|
// Draw
|
||||||
|
|
|
@ -18,6 +18,12 @@
|
||||||
|
|
||||||
#include "raylib.h"
|
#include "raylib.h"
|
||||||
|
|
||||||
|
#if defined(PLATFORM_DESKTOP)
|
||||||
|
#define GLSL_VERSION 330
|
||||||
|
#else // PLATFORM_RPI, PLATFORM_ANDROID, PLATFORM_WEB
|
||||||
|
#define GLSL_VERSION 100
|
||||||
|
#endif
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
// Initialization
|
// Initialization
|
||||||
|
@ -43,8 +49,9 @@ int main()
|
||||||
|
|
||||||
Vector3 position = { 0.0f, 0.0f, 0.0f }; // Set model position
|
Vector3 position = { 0.0f, 0.0f, 0.0f }; // Set model position
|
||||||
|
|
||||||
Shader shader = LoadShader("resources/shaders/glsl330/base.vs",
|
// Load postprocessing shader
|
||||||
"resources/shaders/glsl330/swirl.fs"); // Load postpro shader
|
// NOTE: Defining 0 (NULL) for vertex shader forces usage of internal default vertex shader
|
||||||
|
Shader shader = LoadShader(0, FormatText("resources/shaders/glsl%i/swirl.fs", GLSL_VERSION));
|
||||||
|
|
||||||
// Get variable (uniform) location on the shader to connect with the program
|
// Get variable (uniform) location on the shader to connect with the program
|
||||||
// NOTE: If uniform variable could not be found in the shader, function returns -1
|
// NOTE: If uniform variable could not be found in the shader, function returns -1
|
||||||
|
|
|
@ -18,6 +18,12 @@
|
||||||
|
|
||||||
#include "raylib.h"
|
#include "raylib.h"
|
||||||
|
|
||||||
|
#if defined(PLATFORM_DESKTOP)
|
||||||
|
#define GLSL_VERSION 330
|
||||||
|
#else // PLATFORM_RPI, PLATFORM_ANDROID, PLATFORM_WEB
|
||||||
|
#define GLSL_VERSION 100
|
||||||
|
#endif
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
// Initialization
|
// Initialization
|
||||||
|
@ -39,8 +45,10 @@ int main()
|
||||||
|
|
||||||
Model model = LoadModel("resources/models/watermill.obj"); // Load OBJ model
|
Model model = LoadModel("resources/models/watermill.obj"); // Load OBJ model
|
||||||
Texture2D texture = LoadTexture("resources/models/watermill_diffuse.png"); // Load model texture
|
Texture2D texture = LoadTexture("resources/models/watermill_diffuse.png"); // Load model texture
|
||||||
Shader shader = LoadShader("resources/shaders/glsl330/base.vs",
|
|
||||||
"resources/shaders/glsl330/grayscale.fs"); // Load model shader
|
// Load shader for model
|
||||||
|
// NOTE: Defining 0 (NULL) for vertex shader forces usage of internal default vertex shader
|
||||||
|
Shader shader = LoadShader(0, FormatText("resources/shaders/glsl%i/grayscale.fs", GLSL_VERSION));
|
||||||
|
|
||||||
model.material.shader = shader; // Set shader effect to 3d model
|
model.material.shader = shader; // Set shader effect to 3d model
|
||||||
model.material.maps[MAP_DIFFUSE].texture = texture; // Bind texture to model
|
model.material.maps[MAP_DIFFUSE].texture = texture; // Bind texture to model
|
||||||
|
|
|
@ -18,6 +18,12 @@
|
||||||
|
|
||||||
#include "raylib.h"
|
#include "raylib.h"
|
||||||
|
|
||||||
|
#if defined(PLATFORM_DESKTOP)
|
||||||
|
#define GLSL_VERSION 330
|
||||||
|
#else // PLATFORM_RPI, PLATFORM_ANDROID, PLATFORM_WEB
|
||||||
|
#define GLSL_VERSION 100
|
||||||
|
#endif
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
// Initialization
|
// Initialization
|
||||||
|
@ -29,9 +35,10 @@ int main()
|
||||||
|
|
||||||
Texture2D fudesumi = LoadTexture("resources/fudesumi.png");
|
Texture2D fudesumi = LoadTexture("resources/fudesumi.png");
|
||||||
|
|
||||||
// NOTE: Using GLSL 330 shader version, on OpenGL ES 2.0 use GLSL 100 shader version
|
// Load shader to be used on some parts drawing
|
||||||
Shader shader = LoadShader("resources/shaders/glsl330/base.vs",
|
// NOTE 1: Using GLSL 330 shader version, on OpenGL ES 2.0 use GLSL 100 shader version
|
||||||
"resources/shaders/glsl330/grayscale.fs");
|
// NOTE 2: Defining 0 (NULL) for vertex shader forces usage of internal default vertex shader
|
||||||
|
Shader shader = LoadShader(0, FormatText("resources/shaders/glsl%i/grayscale.fs", GLSL_VERSION));
|
||||||
|
|
||||||
SetTargetFPS(60);
|
SetTargetFPS(60);
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue