88*/
99module inochi2d.cffi.render ;
1010import inochi2d.core.render ;
11+ import inochi2d.core.mesh ;
1112
1213version (IN_DYNLIB):
1314extern (C ) export @nogc :
@@ -161,4 +162,151 @@ void in_texture_flip_vertically(in_texture_t* obj) {
161162*/
162163void * in_texture_get_pixels (in_texture_t* obj) {
163164 return (cast (Texture)obj).pixels.ptr;
165+ }
166+
167+ //
168+ // DRAWLIST
169+ //
170+
171+ /**
172+ DrawState flags
173+ */
174+ alias in_drawstate_t = uint ;
175+ enum in_drawstate_t
176+ IN_DRAW_STATE_NORMAL = 0 ,
177+ IN_DRAW_STATE_DEFINE_MASK = 1 ,
178+ IN_DRAW_STATE_MASKED_DRAW = 2 ,
179+ IN_DRAW_STATE_COMPOSITE_BEGIN = 3 ,
180+ IN_DRAW_STATE_COMPOSITE_END = 4 ,
181+ IN_DRAW_STATE_COMPOSITE_BLIT = 5 ;
182+
183+ /**
184+ Masking modes
185+ */
186+ alias in_mask_mode_t = uint ;
187+ enum in_mask_mode_t
188+ IN_MASK_MODE_MASK = 0 ,
189+ IN_MASK_MODE_DODGE = 1 ;
190+
191+ /**
192+ Blending modes
193+ */
194+ alias in_blend_mode_t = uint ;
195+ enum in_blend_mode_t
196+ IN_BLEND_MODE_NORMAL = 0x00 ,
197+ IN_BLEND_MODE_MULTIPLY = 0x01 ,
198+ IN_BLEND_MODE_SCREEN = 0x02 ,
199+ IN_BLEND_MODE_OVERLAY = 0x03 ,
200+ IN_BLEND_MODE_DARKEN = 0x04 ,
201+ IN_BLEND_MODE_LIGHTEN = 0x05 ,
202+ IN_BLEND_MODE_COLOR_DODGE = 0x06 ,
203+ IN_BLEND_MODE_LINEAR_DODGE = 0x07 ,
204+ IN_BLEND_MODE_ADD_GLOW = 0x08 ,
205+ IN_BLEND_MODE_COLOR_BURN = 0x09 ,
206+ IN_BLEND_MODE_HARD_LIGHT = 0x0A ,
207+ IN_BLEND_MODE_SOFT_LIGHT = 0x0B ,
208+ IN_BLEND_MODE_DIFFERENCE = 0x0C ,
209+ IN_BLEND_MODE_EXCLUSION = 0x0D ,
210+ IN_BLEND_MODE_SUBTRACT = 0x0E ,
211+ IN_BLEND_MODE_INVERSE = 0x0F ,
212+ IN_BLEND_MODE_DESTINATION_IN = 0x10 ,
213+ IN_BLEND_MODE_CLIP_TO_LOWER = 0x11 ,
214+ IN_BLEND_MODE_SLICE_FROM_LOWER = 0x12 ;
215+
216+ /**
217+ A drawing command from the Inochi2D draw list
218+ */
219+ struct in_drawcmd_t {
220+ in_texture_t* [IN_MAX_ATTACHMENTS ] sources;
221+ in_drawstate_t state;
222+ float opacity;
223+ in_blend_mode_t blendMode;
224+ in_mask_mode_t maskMode;
225+ uint vtxOffset;
226+ uint idxOffset;
227+ uint elemCount;
228+ }
229+
230+ /**
231+ A drawlist instance
232+ */
233+ struct in_drawlist_t ;
234+
235+ /**
236+ Gets whether the draw list uses base vertex offsets.
237+
238+ Params:
239+ obj = The drawlist
240+
241+ Returns:
242+ $(D true) if base vertex offsets are being generated,
243+ $(D false) otherwise.
244+ */
245+ bool in_drawlist_get_use_base_vertex (in_drawlist_t* obj) {
246+ return (cast (DrawList)obj).useBaseVertex;
247+ }
248+
249+ /**
250+ Sets whether the draw list uses base vertex offsets.
251+
252+ Params:
253+ obj = The drawlist
254+ value = The value to set.
255+ */
256+ void in_drawlist_set_use_base_vertex (in_drawlist_t* obj, bool value) {
257+ (cast (DrawList)obj).useBaseVertex = value;
258+ }
259+
260+ /**
261+ Gets all of the commands stored in the draw list for iteration.
262+
263+ This memory is owned by the draw list and should not be freed
264+ by you.
265+
266+ Params:
267+ obj = The drawlist
268+ count = Where to store the command count
269+
270+ Returns:
271+ A pointer to an array of draw commands
272+ */
273+ in_drawcmd_t* in_drawlist_get_commands (in_drawlist_t* obj, ref uint count) {
274+ count = cast (uint )(cast (DrawList)obj).commands.length;
275+ return cast (in_drawcmd_t* )(cast (DrawList)obj).commands.ptr;
276+ }
277+
278+ /**
279+ Gets all of the vertex data stored in the draw list.
280+
281+ This memory is owned by the draw list and should not be freed
282+ by you.
283+
284+ Params:
285+ obj = The drawlist
286+ bytes = Where to store the byte count of the data.
287+
288+ Returns:
289+ A pointer to the data
290+ */
291+ void * in_drawlist_get_vertex_data (in_drawlist_t* obj, ref uint bytes) {
292+ bytes = cast (uint )((cast (DrawList)obj).vertices.length* VtxData.sizeof);
293+ return cast (void * )(cast (DrawList)obj).vertices.ptr;
294+ }
295+
296+ /**
297+ Gets all of the index data stored in the draw list.
298+
299+ This memory is owned by the draw list and should not be freed
300+ by you.
301+
302+ Params:
303+ obj = The drawlist
304+ bytes = Where to store the byte count of the data.
305+
306+ Returns:
307+ A pointer to the data
308+ */
309+ void * in_drawlist_get_index_data (in_drawlist_t* obj, ref uint bytes) {
310+ bytes = cast (uint )((cast (DrawList)obj).indices.length* uint .sizeof);
311+ return cast (void * )(cast (DrawList)obj).indices.ptr;
164312}
0 commit comments