00001 //----------------------------------------------------------------------------- 00002 // Product: OpenCTM 00003 // File: openctm.h 00004 // Description: OpenCTM API definition. 00005 //----------------------------------------------------------------------------- 00006 // Copyright (c) 2009-2010 Marcus Geelnard 00007 // 00008 // This software is provided 'as-is', without any express or implied 00009 // warranty. In no event will the authors be held liable for any damages 00010 // arising from the use of this software. 00011 // 00012 // Permission is granted to anyone to use this software for any purpose, 00013 // including commercial applications, and to alter it and redistribute it 00014 // freely, subject to the following restrictions: 00015 // 00016 // 1. The origin of this software must not be misrepresented; you must not 00017 // claim that you wrote the original software. If you use this software 00018 // in a product, an acknowledgment in the product documentation would be 00019 // appreciated but is not required. 00020 // 00021 // 2. Altered source versions must be plainly marked as such, and must not 00022 // be misrepresented as being the original software. 00023 // 00024 // 3. This notice may not be removed or altered from any source 00025 // distribution. 00026 //----------------------------------------------------------------------------- 00027 00028 #ifndef __OPENCTM_H_ 00029 #define __OPENCTM_H_ 00030 00117 #ifdef __cplusplus 00118 extern "C" { 00119 #endif 00120 00121 00122 // Declare calling conventions etc. 00123 #if defined(WIN32) || defined(_WIN32) 00124 // Windows 00125 #if defined(OPENCTM_STATIC) 00126 #define CTMEXPORT 00127 #else 00128 #if defined(OPENCTM_BUILD) 00129 #define CTMEXPORT __declspec(dllexport) 00130 #else 00131 #define CTMEXPORT __declspec(dllimport) 00132 #endif 00133 #endif 00134 #if defined(__MINGW32__) 00135 #define CTMCALL __attribute__ ((__stdcall__)) 00136 #elif (defined(_M_MRX000) || defined(_M_IX86) || defined(_M_ALPHA) || defined(_M_PPC)) && !defined(MIDL_PASS) 00137 #define CTMCALL __stdcall 00138 #else 00139 #define CTMCALL 00140 #endif 00141 #else 00142 // Unix 00143 #if !defined(OPENCTM_STATIC) && !defined(OPENCTM_BUILD) 00144 #define CTMEXPORT extern 00145 #else 00146 #if defined(OPENCTM_BUILD) && defined(__GNUC__) && (__GNUC__ >= 4) 00147 #define CTMEXPORT __attribute__ ((visibility("default"))) 00148 #else 00149 #define CTMEXPORT 00150 #endif 00151 #endif 00152 #define CTMCALL 00153 #endif 00154 00155 00156 // Get system specific type definitions for sized integers. We use the C99 00157 // standard stdint.h for this. 00158 #ifdef _MSC_VER 00159 // MS Visual Studio does not support C99 00160 typedef int int32_t; 00161 typedef unsigned int uint32_t; 00162 #else 00163 #include <stdint.h> 00164 #endif 00165 00166 00168 #define CTM_API_VERSION 0x00000100 00169 00171 #define CTM_TRUE 1 00172 00174 #define CTM_FALSE 0 00175 00177 typedef float CTMfloat; 00178 00180 typedef int32_t CTMint; 00181 00183 typedef uint32_t CTMuint; 00184 00186 typedef void * CTMcontext; 00187 00192 typedef enum { 00193 // Error codes (see ctmGetError()) 00194 CTM_NONE = 0x0000, 00195 00196 00197 00198 CTM_INVALID_CONTEXT = 0x0001, 00199 CTM_INVALID_ARGUMENT = 0x0002, 00200 CTM_INVALID_OPERATION = 0x0003, 00201 CTM_INVALID_MESH = 0x0004, 00202 CTM_OUT_OF_MEMORY = 0x0005, 00203 CTM_FILE_ERROR = 0x0006, 00204 CTM_BAD_FORMAT = 0x0007, 00205 CTM_LZMA_ERROR = 0x0008, 00206 CTM_INTERNAL_ERROR = 0x0009, 00207 CTM_UNSUPPORTED_FORMAT_VERSION = 0x000A, 00208 00209 // OpenCTM context modes 00210 CTM_IMPORT = 0x0101, 00211 CTM_EXPORT = 0x0102, 00212 00213 // Compression methods 00214 CTM_METHOD_RAW = 0x0201, 00215 CTM_METHOD_MG1 = 0x0202, 00216 CTM_METHOD_MG2 = 0x0203, 00217 00218 // Context queries 00219 CTM_VERTEX_COUNT = 0x0301, 00220 CTM_TRIANGLE_COUNT = 0x0302, 00221 CTM_HAS_NORMALS = 0x0303, 00222 CTM_UV_MAP_COUNT = 0x0304, 00223 CTM_ATTRIB_MAP_COUNT = 0x0305, 00224 CTM_VERTEX_PRECISION = 0x0306, 00225 CTM_NORMAL_PRECISION = 0x0307, 00226 CTM_COMPRESSION_METHOD = 0x0308, 00227 CTM_FILE_COMMENT = 0x0309, 00228 00229 // UV/attribute map queries 00230 CTM_NAME = 0x0501, 00231 CTM_FILE_NAME = 0x0502, 00232 CTM_PRECISION = 0x0503, 00233 00234 // Array queries 00235 CTM_INDICES = 0x0601, 00236 CTM_VERTICES = 0x0602, 00237 CTM_NORMALS = 0x0603, 00238 CTM_UV_MAP_1 = 0x0700, 00239 CTM_UV_MAP_2 = 0x0701, 00240 CTM_UV_MAP_3 = 0x0702, 00241 CTM_UV_MAP_4 = 0x0703, 00242 CTM_UV_MAP_5 = 0x0704, 00243 CTM_UV_MAP_6 = 0x0705, 00244 CTM_UV_MAP_7 = 0x0706, 00245 CTM_UV_MAP_8 = 0x0707, 00246 CTM_ATTRIB_MAP_1 = 0x0800, 00247 CTM_ATTRIB_MAP_2 = 0x0801, 00248 CTM_ATTRIB_MAP_3 = 0x0802, 00249 CTM_ATTRIB_MAP_4 = 0x0803, 00250 CTM_ATTRIB_MAP_5 = 0x0804, 00251 CTM_ATTRIB_MAP_6 = 0x0805, 00252 CTM_ATTRIB_MAP_7 = 0x0806, 00253 CTM_ATTRIB_MAP_8 = 0x0807 00254 } CTMenum; 00255 00264 typedef CTMuint (CTMCALL * CTMreadfn)(void * aBuf, CTMuint aCount, void * aUserData); 00265 00273 typedef CTMuint (CTMCALL * CTMwritefn)(const void * aBuf, CTMuint aCount, void * aUserData); 00274 00281 CTMEXPORT CTMcontext CTMCALL ctmNewContext(CTMenum aMode); 00282 00287 CTMEXPORT void CTMCALL ctmFreeContext(CTMcontext aContext); 00288 00297 CTMEXPORT CTMenum CTMCALL ctmGetError(CTMcontext aContext); 00298 00305 CTMEXPORT const char * CTMCALL ctmErrorString(CTMenum aError); 00306 00314 CTMEXPORT CTMuint CTMCALL ctmGetInteger(CTMcontext aContext, CTMenum aProperty); 00315 00323 CTMEXPORT CTMfloat CTMCALL ctmGetFloat(CTMcontext aContext, CTMenum aProperty); 00324 00339 CTMEXPORT const CTMuint * CTMCALL ctmGetIntegerArray(CTMcontext aContext, 00340 CTMenum aProperty); 00341 00356 CTMEXPORT const CTMfloat * CTMCALL ctmGetFloatArray(CTMcontext aContext, 00357 CTMenum aProperty); 00358 00366 CTMEXPORT CTMenum CTMCALL ctmGetNamedUVMap(CTMcontext aContext, 00367 const char * aName); 00368 00382 CTMEXPORT const char * CTMCALL ctmGetUVMapString(CTMcontext aContext, 00383 CTMenum aUVMap, CTMenum aProperty); 00384 00393 CTMEXPORT CTMfloat CTMCALL ctmGetUVMapFloat(CTMcontext aContext, 00394 CTMenum aUVMap, CTMenum aProperty); 00395 00403 CTMEXPORT CTMenum CTMCALL ctmGetNamedAttribMap(CTMcontext aContext, 00404 const char * aName); 00405 00420 CTMEXPORT const char * CTMCALL ctmGetAttribMapString(CTMcontext aContext, 00421 CTMenum aAttribMap, CTMenum aProperty); 00422 00432 CTMEXPORT CTMfloat CTMCALL ctmGetAttribMapFloat(CTMcontext aContext, 00433 CTMenum aAttribMap, CTMenum aProperty); 00434 00449 CTMEXPORT const char * CTMCALL ctmGetString(CTMcontext aContext, 00450 CTMenum aProperty); 00451 00461 CTMEXPORT void CTMCALL ctmCompressionMethod(CTMcontext aContext, 00462 CTMenum aMethod); 00463 00471 CTMEXPORT void CTMCALL ctmCompressionLevel(CTMcontext aContext, 00472 CTMuint aLevel); 00473 00481 CTMEXPORT void CTMCALL ctmVertexPrecision(CTMcontext aContext, 00482 CTMfloat aPrecision); 00483 00496 CTMEXPORT void CTMCALL ctmVertexPrecisionRel(CTMcontext aContext, 00497 CTMfloat aRelPrecision); 00498 00510 CTMEXPORT void CTMCALL ctmNormalPrecision(CTMcontext aContext, 00511 CTMfloat aPrecision); 00512 00523 CTMEXPORT void CTMCALL ctmUVCoordPrecision(CTMcontext aContext, 00524 CTMenum aUVMap, CTMfloat aPrecision); 00525 00537 CTMEXPORT void CTMCALL ctmAttribPrecision(CTMcontext aContext, 00538 CTMenum aAttribMap, CTMfloat aPrecision); 00539 00544 CTMEXPORT void CTMCALL ctmFileComment(CTMcontext aContext, 00545 const char * aFileComment); 00546 00562 CTMEXPORT void CTMCALL ctmDefineMesh(CTMcontext aContext, 00563 const CTMfloat * aVertices, CTMuint aVertexCount, const CTMuint * aIndices, 00564 CTMuint aTriangleCount, const CTMfloat * aNormals); 00565 00583 CTMEXPORT CTMenum CTMCALL ctmAddUVMap(CTMcontext aContext, 00584 const CTMfloat * aUVCoords, const char * aName, const char * aFileName); 00585 00602 CTMEXPORT CTMenum CTMCALL ctmAddAttribMap(CTMcontext aContext, 00603 const CTMfloat * aAttribValues, const char * aName); 00604 00610 CTMEXPORT void CTMCALL ctmLoad(CTMcontext aContext, const char * aFileName); 00611 00622 CTMEXPORT void CTMCALL ctmLoadCustom(CTMcontext aContext, CTMreadfn aReadFn, 00623 void * aUserData); 00624 00630 CTMEXPORT void CTMCALL ctmSave(CTMcontext aContext, const char * aFileName); 00631 00642 CTMEXPORT void CTMCALL ctmSaveCustom(CTMcontext aContext, CTMwritefn aWriteFn, 00643 void * aUserData); 00644 00645 #ifdef __cplusplus 00646 } 00647 #endif 00648 00649 00650 // C++ extensions to the API (to disable C++ extensions, define OPENCTM_NO_CPP) 00651 #if defined(__cplusplus) && !defined(OPENCTM_NO_CPP) 00652 #include "openctmpp.h" 00653 #endif 00654 00655 #endif // __OPENCTM_H_
Copyright © 2009-2010 Marcus Geelnard — openctm.sourceforge.net