summaryrefslogtreecommitdiff
path: root/modules/graphic_objects/includes/DataLoader.hxx
blob: b039c40e33f7ede041172c1e351d3e66ed5bf654 (plain)
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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
/*
 *  Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
 *  Copyright (C) 2010 - DIGITEO - Pierre Lando
 *
 *  This file must be used under the terms of the CeCILL.
 *  This source file is licensed as described in the file COPYING, which
 *  you should have received as part of this distribution.  The terms
 *  are also available at
 *  http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
 *
 */

#ifndef DATA_LOADER_HXX
#define DATA_LOADER_HXX

#ifdef __cplusplus
extern "C"
{
#endif

    typedef struct
    {
        void * address;
        unsigned int size;
    } JavaDirectBuffer;

    /**
     * Return the texture width for the given object.
     * @param[in] the given object id.
     * @return the texture width for the given object.
     */
    int getTextureWidth(int id);

    /**
     * Return the texture height for the given object.
     * @param[in] the given object id.
     * @return the texture height for the given object.
     */
    int getTextureHeight(int id);

    /**
     * Fill the given buffer with texture data.
     * @param[in] the id of the object texture.
     * @param[out] the buffer to fill.
     * @param[in] the buffer length in number of elements.
     * @return the length of writed data.
     */
    int fillTextureData(int id, unsigned char* buffer, int bufferLength);

    /**
     * Fill the given buffer with sub-texture data.
     * @param[in] the id of the object texture.
     * @param[out] the buffer to fill.
     * @param[in] the buffer length in number of elements.
     * @param[in] the x-coordinate of the first pixel.
     * @param[in] the y-coordinate of the first pixel.
     * @param[in] the width of the sub-texture.
     * @param[in] the length of the sub-texture.
     * @return the length of writed data.
     */
    int fillSubTextureData(int id, unsigned char* buffer, int bufferLength, int x, int y, int width, int height);

    /**
     * Return the number of data elements for the given object.
     * @param[in] the given object id.
     * @return the number of data elements.
     */
    int getDataSize(int id);

    /**
     * Fill the given buffer with vertex data from the given object.
     * @param[in] the id of the given object.
     * @param[out] the buffer to fill.
     * @param[in] the buffer length in number of elements.
     * @param[in] the number of coordinate taken by one element in the buffer.
     * @param[in] this byte mask specifies which coordinates are filled (1 for X, 2 for Y, 4 for Z).
     * @param[in] the conversion scale factor to apply to data.
     * @param[in] the conversion translation factor to apply to data.
     * @param[in] the bit mask specifying whether logarithmic coordinates are used.
     */
    void fillVertices(int id, float* buffer, int bufferLength, int elementsSize, int coordinateMask, double scale[], double translation[], int logMask);

    /**
     * Fill the given buffer with normal data from the given object.
     * @param[in] the id of the given object.
     * @param[in] the buffer with position data.
     * @param[out] the buffer to fill.
     * @param[in] the buffer length in number of elements.
     * @param[in] the number of coordinate taken by one element in the buffer.
     */
    void fillNormals(int id, float* position, float* buffer, int bufferLength, int elementsSize);


    /**
     * Fill the given buffer with color data from the given object.
     * @param[in] the id of the given object.
     * @param[in] the buffer to fill.
     * @param[in] the buffer length in number of elements.
     * @param[in] the number of coordinate taken by one element in the buffer (3 for RGB, 4 for RGBA).
     */
    void fillColors(int id, float* buffer, int bufferLength, int elementsSize);

    /**
     * Fill the given buffer with texture coordinates data from the given object.
     * @param[in] the id of the given object.
     * @param[in] the buffer to fill.
     * @param[in] the buffer length in number of elements.
     */
    void fillTextureCoordinates(int id, float* buffer, int bufferLength);

    /**
     * Return the number of indices for the given object.
     * @param[in] the given object id.
     * @return the object's number of indices.
     */
    int getIndicesSize(int id);

    /**
     * Fill the given buffer with indices data of the given object.
     * @param[in] the id of the given object.
     * @param[out] the buffer to fill.
     * @param[in] the buffer length.
     * @param[in] the bit mask specifying whether logarithmic coordinates are used.
     * @return the number of indices actually written.
     */
    int fillIndices(int id, int* buffer, int bufferLength, int logMask);

    /**
     * Return the number of indices for the wire of the given object.
     * @param[in] the given object id.
     * @return the object's number of indices.
     */
    int getWireIndicesSize(int id);

    /**
     * Fill the given buffer with wire indices data of the given object.
     * @param[in] the id of the given object.
     * @param[out] the buffer to fill.
     * @param[in] the buffer length.
     * @param[in] the bit mask specifying whether logarithmic coordinates are used.
     * @return the number of indices actually written.
     */
    int fillWireIndices(int id, int* buffer, int bufferLength, int logMask);

    /**
     * Return the number of mark indices of the given object.
     * @param[in] the given object id.
     * @return the number of mark indices.
     */
    int getMarkIndicesSize(int id);

    /**
     * Fill the given buffer with mark indices data of the given object.
     * @param[in] the id of the given object.
     * @param[out] the buffer to fill.
     * @param[in] the buffer length.
     * @return the number of indices actually written.
     */
    int fillMarkIndices(int id, int* buffer, int bufferLength);

    /**
     * Get texture data of the given object.
     * @param[in] the id of the given object.
     * @return a JavaDirectBuffer struct which will be converted into a java.nio.ByteBuffer.
     */
    JavaDirectBuffer getTextureData(int id);

    /**
     * Get texture image type of the given object.
     * @param[in] id the id of the given object.
     * @return the image type.
     */
    int getTextureImageType(int id);

    /**
     * Get the Scilab data type associated with the texture of the given object.
     * @param[in] id the id of the given object.
     * @return the image type (0 for RGB, 1 for RGBA, 2 for GRAY).
     */
    int getTextureDataType(int id);

    /**
     * Get texture OpenGL type of the given object.
     * @param[in] id the id of the given object.
     * @return the OpenGL type.
     */
    int getTextureGLType(int id);

    /**
     * Dispose texture data of the given object.
     * @param[in] id the id of the given object.
     * @param[in] buffer the address of the buffer to dipose.
     */
    void disposeTextureData(int id, unsigned char * buffer);

    /**
     * Dispose texture data of the given object.
     * @param[in] id the id of the given object.
     * @return 1 if the texture is ROW_MAJOR_ORDER
     */
    int isTextureRowOrder(int id);

    /**
     * Set tha availability of the ABGR extension
     * @param[in] isAvailable 0 if it is not available
     */
    void setABGRExt(int isAvailable);

#ifdef __cplusplus
} //extern "C"
#endif

#endif /* DATA_LOADER_HXX */