forked from RobLoach/raylib-cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodels_billboard.cpp
More file actions
63 lines (52 loc) · 2.3 KB
/
models_billboard.cpp
File metadata and controls
63 lines (52 loc) · 2.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/*******************************************************************************************
*
* raylib [models] example - Drawing billboards
*
* This example has been created using raylib 1.3 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
*
* Copyright (c) 2015 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
#include "raylib-cpp.hpp"
int main() {
// Initialization
//--------------------------------------------------------------------------------------
const int screenWidth = 800;
const int screenHeight = 450;
raylib::Window window(screenWidth, screenHeight, "raylib [models] example - drawing billboards");
// Define the camera to look into our 3d world
raylib::Camera camera(
raylib::Vector3(5.0f, 4.0f, 5.0f),
raylib::Vector3(0.0f, 2.0f, 0.0f),
raylib::Vector3(0.0f, 1.0f, 0.0f),
45.0f,
CAMERA_PERSPECTIVE);
raylib::Texture2D bill("resources/billboard.png"); // Our texture billboard
raylib::Vector3 billPosition(0.0f, 2.0f, 0.0f); // Position where draw billboard
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------
// Main game loop
while (!window.ShouldClose()) { // Detect window close button or ESC key
// Update
//----------------------------------------------------------------------------------
camera.Update(CAMERA_ORBITAL); // Update camera
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
{
window.ClearBackground(RAYWHITE);
camera.BeginMode();
{
DrawGrid(10, 1.0f); // Draw a grid
bill.DrawBillboard(camera, billPosition, 2.0f);
}
camera.EndMode();
DrawFPS(10, 10);
}
EndDrawing();
//----------------------------------------------------------------------------------
}
return 0;
}