Updated demos to use DALi clang-format
[platform/core/uifw/dali-demo.git] / examples / fpp-game / game-model.h
1 #ifndef GAME_MODEL_H
2 #define GAME_MODEL_H
3
4 /*
5  * Copyright (c) 2020 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20
21 #include <dali/public-api/rendering/geometry.h>
22 #include <dali/public-api/rendering/vertex-buffer.h>
23
24 #include <inttypes.h>
25
26 /**
27  * @brief The ModelHeader struct
28  * Model file header structure
29  */
30 struct ModelHeader
31 {
32   uint32_t tag;                 /// 'MODV' tag
33   uint32_t version;             /// File version
34   uint32_t vertexBufferSize;    /// total size of the vertex buffer to allocate
35   uint32_t attributeCount;      /// number of stored attributes
36   uint32_t attributeFormat[16]; /// format encoded as ((type << 16)|(count)); 'type' represents primitive type, 'count' represents number of components ( 1-4 )
37   uint32_t attributeOffset[16]; /// attribute offsets
38   uint32_t attributeSize[16];   /// attribute size in bytes
39   uint32_t vertexStride;        /// vertex stride
40   uint32_t reserved;            /// reserved, may point at additional structure
41   uint32_t dataBeginOffset;     /// start of actual vertex data
42 };
43
44 /**
45  * @brief The GameModel class
46  * GameModel represents model geometry. It loads model data from external model file ( .mod file ).
47  * Such data is ready to be used as GL buffer so it can be copied directly into the VertexBuffer
48  * object.
49  *
50  * Model file is multi-architecture so can be loaded on little and big endian architectures
51  */
52 class GameModel
53 {
54 public:
55   /**
56    * Creates an instance of GameModel and loads the '.mod' file
57    * @param[in] filename Name of file to load
58    */
59   GameModel(const char* filename);
60
61   /**
62    * Destroys an instance of GameModel
63    */
64   ~GameModel();
65
66   /**
67    * Returns DALi geometry object
68    * @return Returns DALi geometry object
69    */
70   Dali::Geometry& GetGeometry();
71
72   /**
73    * Checks status of model, returns false if failed to load
74    * @return true if model has been loaded, false otherwise
75    */
76   bool IsReady();
77
78   /**
79    * Returns unique Id of the texture
80    * @return Unique Id
81    */
82   uint32_t GetUniqueId();
83
84 private:
85   Dali::Geometry     mGeometry;
86   Dali::VertexBuffer mVertexBuffer;
87
88   ModelHeader mHeader;
89
90   uint32_t mUniqueId;
91   bool     mIsReady;
92 };
93
94 #endif