Path Tracer
texture.h
Go to the documentation of this file.
1 /*
2 ---------------------------------------------------------------------------
3 Open Asset Import Library (assimp)
4 ---------------------------------------------------------------------------
5 
6 Copyright (c) 2006-2020, assimp team
7 
8 All rights reserved.
9 
10 Redistribution and use of this software in source and binary forms,
11 with or without modification, are permitted provided that the following
12 conditions are met:
13 
14 * Redistributions of source code must retain the above
15  copyright notice, this list of conditions and the
16  following disclaimer.
17 
18 * Redistributions in binary form must reproduce the above
19  copyright notice, this list of conditions and the
20  following disclaimer in the documentation and/or other
21  materials provided with the distribution.
22 
23 * Neither the name of the assimp team, nor the names of its
24  contributors may be used to endorse or promote products
25  derived from this software without specific prior
26  written permission of the assimp team.
27 
28 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
31 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
32 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
33 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
34 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
35 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
36 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
38 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39 ---------------------------------------------------------------------------
40 */
41 
50 #pragma once
51 #ifndef AI_TEXTURE_H_INC
52 #define AI_TEXTURE_H_INC
53 
54 #ifdef __GNUC__
55 # pragma GCC system_header
56 #endif
57 
58 #include <assimp/types.h>
59 
60 #ifdef __cplusplus
61 extern "C" {
62 #endif
63 
64 // --------------------------------------------------------------------------------
65 
69 #ifndef AI_EMBEDDED_TEXNAME_PREFIX
70 # define AI_EMBEDDED_TEXNAME_PREFIX "*"
71 #endif
72 
79 #if (!defined AI_MAKE_EMBEDDED_TEXNAME)
80 # define AI_MAKE_EMBEDDED_TEXNAME(_n_) AI_EMBEDDED_TEXNAME_PREFIX # _n_
81 #endif
82 
83 #include "./Compiler/pushpack1.h"
84 
85 // --------------------------------------------------------------------------------
90 struct aiTexel {
91  unsigned char b,g,r,a;
92 
93 #ifdef __cplusplus
94  bool operator== (const aiTexel& other) const
96  {
97  return b == other.b && r == other.r &&
98  g == other.g && a == other.a;
99  }
100 
102  bool operator!= (const aiTexel& other) const
103  {
104  return b != other.b || r != other.r ||
105  g != other.g || a != other.a;
106  }
107 
109  operator aiColor4D() const
110  {
111  return aiColor4D(r/255.f,g/255.f,b/255.f,a/255.f);
112  }
113 #endif // __cplusplus
114 
115 } PACK_STRUCT;
116 
117 #include "./Compiler/poppack1.h"
118 
119 #define HINTMAXTEXTURELEN 9
120 
121 // --------------------------------------------------------------------------------
135 struct aiTexture {
142  unsigned int mWidth;
143 
149  unsigned int mHeight;
150 
170  char achFormatHint[ HINTMAXTEXTURELEN ];// 8 for string + 1 for terminator.
171 
181  C_STRUCT aiTexel* pcData;
182 
187  C_STRUCT aiString mFilename;
188 
189 #ifdef __cplusplus
190 
196  bool CheckFormat(const char* s) const {
197  if (nullptr == s) {
198  return false;
199  }
200 
201  return (0 == ::strncmp(achFormatHint, s, sizeof(achFormatHint)));
202  }
203 
204  // Construction
205  aiTexture() AI_NO_EXCEPT
206  : mWidth(0)
207  , mHeight(0)
208  , pcData(nullptr)
209  , mFilename() {
210  memset(achFormatHint, 0, sizeof(achFormatHint));
211  }
212 
213  // Destruction
214  ~aiTexture () {
215  delete[] pcData;
216  }
217 #endif
218 };
219 
220 
221 #ifdef __cplusplus
222 }
223 #endif
224 
225 #endif // AI_TEXTURE_H_INC
aiTexture
Definition: texture.h:135
types.h
aiTexture::mWidth
unsigned int mWidth
Definition: texture.h:142
aiString
Definition: types.h:266
aiColor4D
Definition: color4.h:97
aiTexture::pcData
C_STRUCT aiTexel * pcData
Definition: texture.h:181
aiTexture::mFilename
C_STRUCT aiString mFilename
Definition: texture.h:187
aiTexture::mHeight
unsigned int mHeight
Definition: texture.h:149
aiTexture::achFormatHint
char achFormatHint[HINTMAXTEXTURELEN]
Definition: texture.h:170
aiTexel
Helper structure to represent a texel in a ARGB8888 format.
Definition: texture.h:90