1/*******************************************************************************************
2*
3* raylib [models] example - Drawing billboards
4*
5* This example has been created using raylib 1.3 (www.raylib.com)
6* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
7*
8* Copyright (c) 2015 Ramon Santamaria (@raysan5)
9*
10********************************************************************************************/
11
12#include "raylib.h"
13
14int main(void)
15{
16 // Initialization
17 //--------------------------------------------------------------------------------------
18 const int screenWidth = 800;
19 const int screenHeight = 450;
20
21 InitWindow(screenWidth, screenHeight, "raylib [models] example - drawing billboards");
22
23 // Define the camera to look into our 3d world
24 Camera camera = { 0 };
25 camera.position = (Vector3){ 5.0f, 4.0f, 5.0f };
26 camera.target = (Vector3){ 0.0f, 2.0f, 0.0f };
27 camera.up = (Vector3){ 0.0f, 1.0f, 0.0f };
28 camera.fovy = 45.0f;
29 camera.type = CAMERA_PERSPECTIVE;
30
31 Texture2D bill = LoadTexture("resources/billboard.png"); // Our texture billboard
32 Vector3 billPosition = { 0.0f, 2.0f, 0.0f }; // Position where draw billboard
33
34 SetCameraMode(camera, CAMERA_ORBITAL); // Set an orbital camera mode
35
36 SetTargetFPS(60); // Set our game to run at 60 frames-per-second
37 //--------------------------------------------------------------------------------------
38
39 // Main game loop
40 while (!WindowShouldClose()) // Detect window close button or ESC key
41 {
42 // Update
43 //----------------------------------------------------------------------------------
44 UpdateCamera(&camera); // Update camera
45 //----------------------------------------------------------------------------------
46
47 // Draw
48 //----------------------------------------------------------------------------------
49 BeginDrawing();
50
51 ClearBackground(RAYWHITE);
52
53 BeginMode3D(camera);
54
55 DrawGrid(10, 1.0f); // Draw a grid
56
57 DrawBillboard(camera, bill, billPosition, 2.0f, WHITE);
58
59 EndMode3D();
60
61 DrawFPS(10, 10);
62
63 EndDrawing();
64 //----------------------------------------------------------------------------------
65 }
66
67 // De-Initialization
68 //--------------------------------------------------------------------------------------
69 UnloadTexture(bill); // Unload texture
70
71 CloseWindow(); // Close window and OpenGL context
72 //--------------------------------------------------------------------------------------
73
74 return 0;
75}