File: OpenCTM.pas

package info (click to toggle)
openctm 1.0.3%2Bdfsg1-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 1,692 kB
  • sloc: ansic: 9,241; cpp: 5,199; python: 735; makefile: 30
file content (189 lines) | stat: -rw-r--r-- 8,457 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
unit OpenCTM;
//------------------------------------------------------------------------------
// Product:     OpenCTM
// File:        OpenCTM.pas
// Description: Delphi API bindings.
//-----------------------------------------------------------------------------
// Copyright (c) 2009-2010 Marcus Geelnard
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
//
//     1. The origin of this software must not be misrepresented; you must not
//     claim that you wrote the original software. If you use this software
//     in a product, an acknowledgment in the product documentation would be
//     appreciated but is not required.
//
//     2. Altered source versions must be plainly marked as such, and must not
//     be misrepresented as being the original software.
//
//     3. This notice may not be removed or altered from any source
//     distribution.
//------------------------------------------------------------------------------

interface

//------------------------------------------------------------------------------
// Types
//------------------------------------------------------------------------------

type
  // Basic types
  TCTMfloat = Single;
  TCTMint = Integer;
  TCTMuint = Cardinal;
  TCTMcontext = Pointer;
  TCTMenum = Cardinal;

  // Pointer types
  PCTMfloat = ^TCTMfloat;
  PCTMint = ^TCTMint;
  PCTMuint = ^TCTMuint;

  // Callback function pointer types
  TCTMreadfn = function (ABuf: Pointer; ACount: TCTMuint; AUserData: Pointer): TCTMuint; stdcall;
  TCTMwritefn = function (ABuf: Pointer; ACount: TCTMuint; AUserData: Pointer): TCTMuint; stdcall;


//------------------------------------------------------------------------------
// Constants
//------------------------------------------------------------------------------

const
  CTM_API_VERSION = $00000100;
  CTM_TRUE  = 1;
  CTM_FALSE = 0;

  // TCTMenum
  CTM_NONE              = $0000;
  CTM_INVALID_CONTEXT   = $0001;
  CTM_INVALID_ARGUMENT  = $0002;
  CTM_INVALID_OPERATION = $0003;
  CTM_INVALID_MESH      = $0004;
  CTM_OUT_OF_MEMORY     = $0005;
  CTM_FILE_ERROR        = $0006;
  CTM_BAD_FORMAT        = $0007;
  CTM_LZMA_ERROR        = $0008;
  CTM_INTERNAL_ERROR    = $0009;
  CTM_UNSUPPORTED_FORMAT_VERSION = $000A;
  CTM_IMPORT            = $0101;
  CTM_EXPORT            = $0102;
  CTM_METHOD_RAW        = $0201;
  CTM_METHOD_MG1        = $0202;
  CTM_METHOD_MG2        = $0203;
  CTM_VERTEX_COUNT      = $0301;
  CTM_TRIANGLE_COUNT    = $0302;
  CTM_HAS_NORMALS       = $0303;
  CTM_UV_MAP_COUNT      = $0304;
  CTM_ATTRIB_MAP_COUNT  = $0305;
  CTM_VERTEX_PRECISION  = $0306;
  CTM_NORMAL_PRECISION  = $0307;
  CTM_COMPRESSION_METHOD = $0308;
  CTM_FILE_COMMENT      = $0309;
  CTM_NAME              = $0501;
  CTM_FILE_NAME         = $0502;
  CTM_PRECISION         = $0503;
  CTM_INDICES           = $0601;
  CTM_VERTICES          = $0602;
  CTM_NORMALS           = $0603;
  CTM_UV_MAP_1          = $0700;
  CTM_UV_MAP_2          = $0701;
  CTM_UV_MAP_3          = $0702;
  CTM_UV_MAP_4          = $0703;
  CTM_UV_MAP_5          = $0704;
  CTM_UV_MAP_6          = $0705;
  CTM_UV_MAP_7          = $0706;
  CTM_UV_MAP_8          = $0707;
  CTM_ATTRIB_MAP_1      = $0800;
  CTM_ATTRIB_MAP_2      = $0801;
  CTM_ATTRIB_MAP_3      = $0802;
  CTM_ATTRIB_MAP_4      = $0803;
  CTM_ATTRIB_MAP_5      = $0804;
  CTM_ATTRIB_MAP_6      = $0805;
  CTM_ATTRIB_MAP_7      = $0806;
  CTM_ATTRIB_MAP_8      = $0807;


//------------------------------------------------------------------------------
// Function prototypes
//------------------------------------------------------------------------------

function ctmNewContext(AMode: TCTMenum): TCTMcontext; stdcall;
procedure ctmFreeContext(AContext: TCTMcontext); stdcall;
function ctmGetError(AContext: TCTMcontext): TCTMenum; stdcall;
function ctmErrorString(AError: TCTMenum): PChar; stdcall;
function ctmGetInteger(AContext: TCTMcontext; AProperty: TCTMenum): TCTMuint; stdcall;
function ctmGetFloat(AContext: TCTMcontext; AProperty: TCTMenum): TCTMfloat; stdcall;
function ctmGetIntegerArray(AContext: TCTMcontext; AProperty: TCTMenum): PCTMuint; stdcall;
function ctmGetFloatArray(AContext: TCTMcontext; AProperty: TCTMenum): PCTMfloat; stdcall;
function ctmGetNamedUVMap(AContext: TCTMcontext; AName: PChar): TCTMenum; stdcall;
function ctmGetUVMapString(AContext: TCTMcontext; AUVMap: TCTMenum; AProperty: TCTMenum): PChar; stdcall;
function ctmGetUVMapFloat(AContext: TCTMcontext; AUVMap: TCTMenum; AProperty: TCTMenum): TCTMfloat; stdcall;
function ctmGetNamedAttribMap(AContext: TCTMcontext; AName: PChar): TCTMenum; stdcall;
function ctmGetAttribMapString(AContext: TCTMcontext; AAttribMap: TCTMenum; AProperty: TCTMenum): PChar; stdcall;
function ctmGetAttribMapFloat(AContext: TCTMcontext; AAttribMap: TCTMenum; AProperty: TCTMenum): TCTMfloat; stdcall;
function ctmGetString(AContext: TCTMcontext; AProperty: TCTMenum): PChar; stdcall;
procedure ctmCompressionMethod(AContext: TCTMcontext; AMethod: TCTMenum); stdcall;
procedure ctmCompressionLevel(AContext: TCTMcontext; ALevel: TCTMuint); stdcall;
procedure ctmVertexPrecision(AContext: TCTMcontext; APrecision: TCTMfloat); stdcall;
procedure ctmVertexPrecisionRel(AContext: TCTMcontext; ARelPrecision: TCTMfloat); stdcall;
procedure ctmNormalPrecision(AContext: TCTMcontext; APrecision: TCTMfloat); stdcall;
procedure ctmUVCoordPrecision(AContext: TCTMcontext; AUVMap: TCTMenum; APrecision: TCTMfloat); stdcall;
procedure ctmAttribPrecision(AContext: TCTMcontext; AAttribMap: TCTMenum; APrecision: TCTMfloat); stdcall;
procedure ctmFileComment(AContext: TCTMcontext; AFileComment: PChar); stdcall;
procedure ctmDefineMesh(AContext: TCTMcontext; AVertices: PCTMfloat; AVertexCount: TCTMuint; AIndices: PCTMuint; ATriangleCount: TCTMuint; ANormals: PCTMfloat); stdcall;
function ctmAddUVMap(AContext: TCTMcontext; AUVCoords: PCTMfloat; AName: PChar; AFileName: PChar): TCTMenum; stdcall;
function ctmAddAttribMap(AContext: TCTMcontext; AAttribValues: PCTMfloat; AName: PChar): TCTMenum; stdcall;
procedure ctmLoad(AContext: TCTMcontext; AFileName: PChar); stdcall;
procedure ctmLoadCustom(AContext: TCTMcontext; AReadFn: TCTMreadfn; AUserData: Pointer); stdcall;
procedure ctmSave(AContext: TCTMcontext; AFileName: PChar); stdcall;
procedure ctmSaveCustom(AContext: TCTMcontext; AWriteFn: TCTMwritefn; AUserData: Pointer); stdcall;


implementation

//------------------------------------------------------------------------------
// DLL interface
//------------------------------------------------------------------------------

const
  DLLNAME = 'openctm.dll';

function ctmNewContext; external DLLNAME;
procedure ctmFreeContext; external DLLNAME;
function ctmGetError; external DLLNAME;
function ctmErrorString; external DLLNAME;
function ctmGetInteger; external DLLNAME;
function ctmGetFloat; external DLLNAME;
function ctmGetIntegerArray; external DLLNAME;
function ctmGetFloatArray; external DLLNAME;
function ctmGetNamedUVMap; external DLLNAME;
function ctmGetUVMapString; external DLLNAME;
function ctmGetUVMapFloat; external DLLNAME;
function ctmGetNamedAttribMap; external DLLNAME;
function ctmGetAttribMapString; external DLLNAME;
function ctmGetAttribMapFloat; external DLLNAME;
function ctmGetString; external DLLNAME;
procedure ctmCompressionMethod; external DLLNAME;
procedure ctmCompressionLevel; external DLLNAME;
procedure ctmVertexPrecision; external DLLNAME;
procedure ctmVertexPrecisionRel; external DLLNAME;
procedure ctmNormalPrecision; external DLLNAME;
procedure ctmUVCoordPrecision; external DLLNAME;
procedure ctmAttribPrecision; external DLLNAME;
procedure ctmFileComment; external DLLNAME;
procedure ctmDefineMesh; external DLLNAME;
function ctmAddUVMap; external DLLNAME;
function ctmAddAttribMap; external DLLNAME;
procedure ctmLoad; external DLLNAME;
procedure ctmLoadCustom; external DLLNAME;
procedure ctmSave; external DLLNAME;
procedure ctmSaveCustom; external DLLNAME;

end.