Revert "Updates following rename of PropertyBuffer"
[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) 2016 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/property-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 PropertyBuffer
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   /**
57    * Creates an instance of GameModel and loads the '.mod' file
58    * @param[in] filename Name of file to load
59    */
60   GameModel( const char* filename );
61
62   /**
63    * Destroys an instance of GameModel
64    */
65   ~GameModel();
66
67   /**
68    * Returns DALi geometry object
69    * @return Returns DALi geometry object
70    */
71   Dali::Geometry& GetGeometry();
72
73   /**
74    * Checks status of model, returns false if failed to load
75    * @return true if model has been loaded, false otherwise
76    */
77   bool IsReady();
78
79   /**
80    * Returns unique Id of the texture
81    * @return Unique Id
82    */
83   uint32_t GetUniqueId();
84
85 private:
86
87   Dali::Geometry        mGeometry;
88   Dali::PropertyBuffer  mVertexBuffer;
89
90   ModelHeader           mHeader;
91
92   uint32_t              mUniqueId;
93   bool                  mIsReady;
94 };
95
96 #endif