-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCogl-0.d.ts
5476 lines (5352 loc) · 219 KB
/
Cogl-0.d.ts
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
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/** Generated with https://github.com/Gr3q/GIR2TS - If possible do not modify. */
declare namespace imports.gi.Cogl {
/** This construct is only for enabling class multi-inheritance,
* use {@link Bitmap} instead.
*/
interface IBitmap {
get_format(): PixelFormat;
get_height(): number;
get_rowstride(): number;
get_width(): number;
}
type BitmapInitOptionsMixin = ObjectInitOptions
export interface BitmapInitOptions extends BitmapInitOptionsMixin {}
/** This construct is only for enabling class multi-inheritance,
* use {@link Bitmap} instead.
*/
type BitmapMixin = IBitmap & Object;
interface Bitmap extends BitmapMixin {}
class Bitmap {
public constructor(options?: Partial<BitmapInitOptions>);
/**
* Creates a bitmap using some existing data. The data is not copied
* so the application must keep the buffer alive for the lifetime of
* the {@link Bitmap}. This can be used for example with
* {@link Cogl.Framebuffer.read_pixels_into_bitmap} to read data directly
* into an application buffer with the specified rowstride.
* @param context A {@link Context}
* @param width The width of the bitmap.
* @param height The height of the bitmap.
* @param format The format of the pixel data.
* @param rowstride The rowstride of the bitmap (the number of bytes from
* the start of one row of the bitmap to the next).
* @param data A pointer to the data. The bitmap will take ownership of this data.
* @returns A new {@link Bitmap}.
*/
public static new_for_data(context: Context, width: number, height: number, format: PixelFormat, rowstride: number, data: number): Bitmap;
/**
* Wraps some image data that has been uploaded into a {@link Buffer} as
* a #CoglBitmap. The data is not copied in this process.
* @param buffer A {@link Buffer} containing image data
* @param format The {@link PixelFormat} defining the format of the image data
* in the given #buffer.
* @param width The width of the image data in the given #buffer.
* @param height The height of the image data in the given #buffer.
* @param rowstride The rowstride in bytes of the image data in the given #buffer.
* @param offset The offset into the given #buffer to the first pixel that
* should be considered part of the {@link Bitmap}.
* @returns a {@link Bitmap} encapsulating the given #buffer.
*/
public static new_from_buffer(buffer: any, format: PixelFormat, width: number, height: number, rowstride: number, offset: number): Bitmap;
/**
* Loads an image file from disk. This function can be safely called from
* within a thread.
* @param filename the file to load.
* @returns a {@link Bitmap} to the new loaded
* image data, or %NULL if loading the image failed.
*/
public static new_from_file(filename: string): Bitmap;
/**
* Creates a new {@link Bitmap} with the given width, height and format.
* The initial contents of the bitmap are undefined.
*
* The data for the bitmap will be stored in a newly created
* #CoglPixelBuffer. You can get a pointer to the pixel buffer using
* {@link Cogl.Bitmap.get_buffer}. The #CoglBuffer API can then be
* used to fill the bitmap with data.
*
* <note>Cogl will try its best to provide a hardware array you can
* map, write into and effectively do a zero copy upload when creating
* a texture from it with cogl_texture_new_from_bitmap(). For various
* reasons, such arrays are likely to have a stride larger than width
* * bytes_per_pixel. The user must take the stride into account when
* writing into it. The stride can be retrieved with
* cogl_bitmap_get_rowstride().</note>
* @param context A {@link Context}
* @param width width of the bitmap in pixels
* @param height height of the bitmap in pixels
* @param format the format of the pixels the array will store
* @returns a {@link PixelBuffer} representing the
* newly created array or %NULL on failure
*/
public static new_with_size(context: Context, width: number, height: number, format: PixelFormat): Bitmap;
public static error_quark(): number;
/**
* Parses an image file enough to extract the width and height
* of the bitmap.
* @param filename the file to check
* @returns %TRUE if the image was successfully parsed
*
* return location for the bitmap width, or %NULL
*
* return location for the bitmap height, or %NULL
*/
public static get_size_from_file(filename: string): [ boolean, number, number ];
}
/** This construct is only for enabling class multi-inheritance,
* use {@link Context} instead.
*/
interface IContext {
}
type ContextInitOptionsMixin = ObjectInitOptions
export interface ContextInitOptions extends ContextInitOptionsMixin {}
/** This construct is only for enabling class multi-inheritance,
* use {@link Context} instead.
*/
type ContextMixin = IContext & Object;
interface Context extends ContextMixin {}
class Context {
public constructor(options?: Partial<ContextInitOptions>);
/**
* Creates a new {@link Context} which acts as an application sandbox
* for any state objects that are allocated.
* @param display A {@link Display} pointer
* @returns A newly allocated {@link Context}
*/
public static new(display?: any | null): Context;
}
/** This construct is only for enabling class multi-inheritance,
* use {@link Object} instead.
*/
interface IObject {
}
type ObjectInitOptionsMixin = {};
export interface ObjectInitOptions extends ObjectInitOptionsMixin {}
/** This construct is only for enabling class multi-inheritance,
* use {@link Object} instead.
*/
type ObjectMixin = IObject;
interface Object extends ObjectMixin {}
class Object {
public constructor(options?: Partial<ObjectInitOptions>);
/**
* Increases the reference count of #object by 1
* @param object a {@link Object}
* @returns the #object, with its reference count increased
*/
public static ref(object?: any | null): any | null;
/**
* Drecreases the reference count of #object by 1; if the reference
* count reaches 0, the resources allocated by #object will be freed
* @param object a {@link Object}
*/
public static unref(object?: any | null): void;
}
/** This construct is only for enabling class multi-inheritance,
* use {@link Offscreen} instead.
*/
interface IOffscreen {
}
type OffscreenInitOptionsMixin = ObjectInitOptions & FramebufferInitOptions
export interface OffscreenInitOptions extends OffscreenInitOptionsMixin {}
/** This construct is only for enabling class multi-inheritance,
* use {@link Offscreen} instead.
*/
type OffscreenMixin = IOffscreen & Object & Framebuffer;
interface Offscreen extends OffscreenMixin {}
class Offscreen {
public constructor(options?: Partial<OffscreenInitOptions>);
/**
* @deprecated
* Use cogl_offscreen_new_with_texture instead.
*
* This creates an offscreen buffer object using the given #texture as the
* primary color buffer. It doesn't just initialize the contents of the
* offscreen buffer with the #texture; they are tightly bound so that
* drawing to the offscreen buffer effectivly updates the contents of the
* given texture. You don't need to destroy the offscreen buffer before
* you can use the #texture again.
*
* <note>This only works with low-level {@link Texture} types such as
* #CoglTexture2D and not with meta-texture types such as
* #CoglTexture2DSliced.</note>
* @param texture A {@link Texture} pointer
* @returns a newly instantiated {@link Offscreen}
* framebuffer or %NULL if it wasn't possible to create the
* buffer.
*/
public static new_to_texture(texture: Texture): Offscreen;
/**
* This creates an offscreen framebuffer object using the given
* #texture as the primary color buffer. It doesn't just initialize
* the contents of the offscreen buffer with the #texture; they are
* tightly bound so that drawing to the offscreen buffer effectively
* updates the contents of the given texture. You don't need to
* destroy the offscreen buffer before you can use the #texture again.
*
* <note>This api only works with low-level {@link Texture} types such as
* #CoglTexture2D and not with meta-texture types such as
* #CoglTexture2DSliced.</note>
*
* The storage for the framebuffer is actually allocated lazily
* so this function will never return %NULL to indicate a runtime
* error. This means it is still possible to configure the framebuffer
* before it is really allocated.
*
* Simple applications without full error handling can simply rely on
* Cogl to lazily allocate the storage of framebuffers but you should
* be aware that if Cogl encounters an error (such as running out of
* GPU memory) then your application will simply abort with an error
* message. If you need to be able to catch such exceptions at runtime
* then you can explicitly allocate your framebuffer when you have
* finished configuring it by calling {@link Cogl.Framebuffer.allocate} and
* passing in a #GError argument to catch any exceptions.
* @param texture A {@link Texture} pointer
* @returns a newly instantiated {@link Offscreen}
* framebuffer.
*/
public static new_with_texture(texture: Texture): Offscreen;
}
/** This construct is only for enabling class multi-inheritance,
* use {@link Onscreen} instead.
*/
interface IOnscreen {
/**
* Installs a #callback function that will be called whenever the
* window system has lost the contents of a region of the onscreen
* buffer and the application should redraw it to repair the buffer.
* For example this may happen in a window system without a compositor
* if a window that was previously covering up the onscreen window has
* been moved causing a region of the onscreen to be exposed.
*
* The #callback will be passed a {@link OnscreenDirtyInfo} struct which
* decribes a rectangle containing the newly dirtied region. Note that
* this may be called multiple times to describe a non-rectangular
* region composed of multiple smaller rectangles.
*
* The dirty events are separate from %COGL_FRAME_EVENT_SYNC events so
* the application should also listen for this event before rendering
* the dirty region to ensure that the framebuffer is actually ready
* for rendering.
* @param callback A callback function to call for dirty events
* @param destroy An optional callback to destroy #user_data when the
* #callback is removed or #onscreen is freed.
* @returns a {@link OnscreenDirtyClosure} pointer that can be used to
* remove the callback and associated #user_data later.
*/
add_dirty_callback(callback: OnscreenDirtyCallback, destroy?: UserDataDestroyCallback | null): OnscreenDirtyClosure;
/**
* Registers a #callback with #onscreen that will be called whenever
* the #onscreen framebuffer changes size.
*
* The #callback can be removed using
* {@link Cogl.Onscreen.remove_resize_callback} passing the returned closure
* pointer.
*
* <note>Since Cogl automatically updates the viewport of an #onscreen
* framebuffer that is resized, a resize callback can also be used to
* track when the viewport has been changed automatically by Cogl in
* case your application needs more specialized control over the
* viewport.</note>
*
* <note>A resize callback will only ever be called while dispatching
* Cogl events from the system mainloop; so for example during
* cogl_poll_renderer_dispatch(). This is so that callbacks shouldn't
* occur while an application might have arbitrary locks held for
* example.</note>
* @param callback A {@link OnscreenResizeCallback} to call when
* the #onscreen changes size.
* @param destroy An optional callback to destroy #user_data
* when the #callback is removed or #onscreen is freed.
* @returns a {@link OnscreenResizeClosure} pointer that can be used to
* remove the callback and associated #user_data later.
*/
add_resize_callback(callback: OnscreenResizeCallback, destroy?: UserDataDestroyCallback | null): OnscreenResizeClosure;
/**
* Gets the current age of the buffer contents.
*
* This function allows applications to query the age of the current
* back buffer contents for a {@link Onscreen} as the number of frames
* elapsed since the contents were most recently defined.
*
* These age values exposes enough information to applications about
* how Cogl internally manages back buffers to allow applications to
* re-use the contents of old frames and minimize how much must be
* redrawn for the next frame.
*
* The back buffer contents can either be reported as invalid (has an
* age of 0) or it may be reported to be the same contents as from n
* frames prior to the current frame.
*
* The queried value remains valid until the next buffer swap.
*
* <note>One caveat is that under X11 the buffer age does not reflect
* changes to buffer contents caused by the window systems. X11
* applications must track Expose events to determine what buffer
* regions need to additionally be repaired each frame.</note>
*
* The recommended way to take advantage of this buffer age api is to
* build up a circular buffer of length 3 for tracking damage regions
* over the last 3 frames and when starting a new frame look at the
* age of the buffer and combine the damage regions for the current
* frame with the damage regions of previous #age frames so you know
* everything that must be redrawn to update the old contents for the
* new frame.
*
* <note>If the system doesn't not support being able to track the age
* of back buffers then this function will always return 0 which
* implies that the contents are undefined.</note>
*
* <note>The %COGL_FEATURE_ID_BUFFER_AGE feature can optionally be
* explicitly checked to determine if Cogl is currently tracking the
* age of #CoglOnscreen back buffer contents. If this feature is
* missing then this function will always return 0.</note>
* @returns The age of the buffer contents or 0 when the buffer
* contents are undefined.
*/
get_buffer_age(): number;
/**
* Gets the value of the framebuffers frame counter. This is
* a counter that increases by one each time
* {@link Cogl.Onscreen.swap_buffers} or cogl_onscreen_swap_region()
* is called.
* @returns the current frame counter value
*/
get_frame_counter(): number;
/**
* Lets you query whether #onscreen has been marked as resizable via
* the {@link Cogl.Onscreen.set_resizable} api.
*
* By default, if possible, a #onscreen will be created by Cogl
* as non resizable, but it is not guaranteed that this is always
* possible for all window systems.
*
* <note>If cogl_onscreen_set_resizable(#onscreen, %TRUE) has been
* previously called then this function will return %TRUE, but it's
* possible that the current windowing system being used does not
* support window resizing (consider fullscreen windows on a phone or
* a TV). This function is not aware of whether resizing is truly
* meaningful with your window system, only whether the #onscreen has
* been marked as resizable.</note>
* @returns Returns whether #onscreen has been marked as
* resizable or not.
*/
get_resizable(): boolean;
/**
* This requests to make #onscreen invisible to the user.
*
* Actually the precise semantics of this function depend on the
* window system currently in use, and if you don't have a
* multi-windowining system this function may in-fact do nothing.
*
* This function does not implicitly allocate the given #onscreen
* framebuffer before hiding it.
*
* <note>Since Cogl doesn't explicitly track the visibility status of
* onscreen framebuffers it wont try to avoid redundant window system
* requests e.g. to show an already visible window. This also means
* that it's acceptable to alternatively use native APIs to show and
* hide windows without confusing Cogl.</note>
*/
hide(): void;
/**
* Removes a callback and associated user data that were previously
* registered using {@link Cogl.Onscreen.add_dirty_callback}.
*
* If a destroy callback was passed to
* cogl_onscreen_add_dirty_callback() to destroy the user data then
* this will also get called.
* @param closure A {@link OnscreenDirtyClosure} returned from
* {@link Cogl.Onscreen.add_dirty_callback}
*/
remove_dirty_callback(closure: OnscreenDirtyClosure): void;
/**
* Removes a callback and associated user data that were previously
* registered using {@link Cogl.Onscreen.add_frame_callback}.
*
* If a destroy callback was passed to
* cogl_onscreen_add_frame_callback() to destroy the user data then
* this will get called.
* @param closure A {@link FrameClosure} returned from
* {@link Cogl.Onscreen.add_frame_callback}
*/
remove_frame_callback(closure: FrameClosure): void;
/**
* Removes a resize #callback and #user_data pair that were previously
* associated with #onscreen via {@link Cogl.Onscreen.add_resize_callback}.
* @param closure An identifier returned from {@link Cogl.Onscreen.add_resize_callback}
*/
remove_resize_callback(closure: OnscreenResizeClosure): void;
/**
* Lets you request Cogl to mark an #onscreen framebuffer as
* resizable or not.
*
* By default, if possible, a #onscreen will be created by Cogl
* as non resizable, but it is not guaranteed that this is always
* possible for all window systems.
*
* <note>Cogl does not know whether marking the #onscreen framebuffer
* is truly meaningful for your current window system (consider
* applications being run fullscreen on a phone or TV) so this
* function may not have any useful effect. If you are running on a
* multi windowing system such as X11 or Win32 or OSX then Cogl will
* request to the window system that users be allowed to resize the
* #onscreen, although it's still possible that some other window
* management policy will block this possibility.</note>
*
* <note>Whenever an #onscreen framebuffer is resized the viewport
* will be automatically updated to match the new size of the
* framebuffer with an origin of (0,0). If your application needs more
* specialized control of the viewport it will need to register a
* resize handler using {@link Cogl.Onscreen.add_resize_callback} so that it
* can track when the viewport has been changed automatically.</note>
* @param resizable
*/
set_resizable(resizable: boolean): void;
/**
* This requests to make #onscreen visible to the user.
*
* Actually the precise semantics of this function depend on the
* window system currently in use, and if you don't have a
* multi-windowining system this function may in-fact do nothing.
*
* This function will implicitly allocate the given #onscreen
* framebuffer before showing it if it hasn't already been allocated.
*
* When using the Wayland winsys calling this will set the surface to
* a toplevel type which will make it appear. If the application wants
* to set a different type for the surface, it can avoid calling
* {@link Cogl.Onscreen.show} and set its own type directly with the Wayland
* client API via cogl_wayland_onscreen_get_surface().
*
* <note>Since Cogl doesn't explicitly track the visibility status of
* onscreen framebuffers it wont try to avoid redundant window system
* requests e.g. to show an already visible window. This also means
* that it's acceptable to alternatively use native APIs to show and
* hide windows without confusing Cogl.</note>
*/
show(): void;
/**
* Swaps the current back buffer being rendered too, to the front for display.
*
* This function also implicitly discards the contents of the color, depth and
* stencil buffers as if {@link Cogl.Framebuffer.discard_buffers} were used. The
* significance of the discard is that you should not expect to be able to
* start a new frame that incrementally builds on the contents of the previous
* frame.
*
* <note>It is highly recommended that applications use
* cogl_onscreen_swap_buffers_with_damage() instead whenever possible
* and also use the cogl_onscreen_get_buffer_age() api so they can
* perform incremental updates to older buffers instead of having to
* render a full buffer for every frame.</note>
*/
swap_buffers(): void;
/**
* Swaps the current back buffer being rendered too, to the front for
* display and provides information to any system compositor about
* what regions of the buffer have changed (damage) with respect to
* the last swapped buffer.
*
* This function has the same semantics as
* {@link Cogl.Framebuffer.swap_buffers} except that it additionally allows
* applications to pass a list of damaged rectangles which may be
* passed on to a compositor so that it can minimize how much of the
* screen is redrawn in response to this applications newly swapped
* front buffer.
*
* For example if your application is only animating a small object in
* the corner of the screen and everything else is remaining static
* then it can help the compositor to know that only the bottom right
* corner of your newly swapped buffer has really changed with respect
* to your previously swapped front buffer.
*
* If #n_rectangles is 0 then the whole buffer will implicitly be
* reported as damaged as if cogl_onscreen_swap_buffers() had been
* called.
*
* This function also implicitly discards the contents of the color,
* depth and stencil buffers as if cogl_framebuffer_discard_buffers()
* were used. The significance of the discard is that you should not
* expect to be able to start a new frame that incrementally builds on
* the contents of the previous frame. If you want to perform
* incremental updates to older back buffers then please refer to the
* cogl_onscreen_get_buffer_age() api.
*
* Whenever possible it is recommended that applications use this
* function instead of cogl_onscreen_swap_buffers() to improve
* performance when running under a compositor.
*
* <note>It is highly recommended to use this API in conjunction with
* the cogl_onscreen_get_buffer_age() api so that your application can
* perform incremental rendering based on old back buffers.</note>
* @param rectangles An array of integer 4-tuples representing damaged
* rectangles as (x, y, width, height) tuples.
* @param n_rectangles The number of 4-tuples to be read from #rectangles
*/
swap_buffers_with_damage(rectangles: number, n_rectangles: number): void;
/**
* Swaps a region of the back buffer being rendered too, to the front for
* display. #rectangles represents the region as array of #n_rectangles each
* defined by 4 sequential (x, y, width, height) integers.
*
* This function also implicitly discards the contents of the color, depth and
* stencil buffers as if {@link Cogl.Framebuffer.discard_buffers} were used. The
* significance of the discard is that you should not expect to be able to
* start a new frame that incrementally builds on the contents of the previous
* frame.
* @param rectangles An array of integer 4-tuples representing rectangles as
* (x, y, width, height) tuples.
* @param n_rectangles The number of 4-tuples to be read from #rectangles
*/
swap_region(rectangles: number, n_rectangles: number): void;
}
type OnscreenInitOptionsMixin = ObjectInitOptions & FramebufferInitOptions
export interface OnscreenInitOptions extends OnscreenInitOptionsMixin {}
/** This construct is only for enabling class multi-inheritance,
* use {@link Onscreen} instead.
*/
type OnscreenMixin = IOnscreen & Object & Framebuffer;
interface Onscreen extends OnscreenMixin {}
class Onscreen {
public constructor(options?: Partial<OnscreenInitOptions>);
/**
* Instantiates an "unallocated" {@link Onscreen} framebuffer that may be
* configured before later being allocated, either implicitly when
* it is first used or explicitly via {@link Cogl.Framebuffer.allocate}.
* @param context A {@link Context}
* @param width The desired framebuffer width
* @param height The desired framebuffer height
* @returns A newly instantiated {@link Onscreen} framebuffer
*/
public static new(context: Context, width: number, height: number): Onscreen;
}
/** This construct is only for enabling class multi-inheritance,
* use {@link Pipeline} instead.
*/
interface IPipeline {
/**
* Creates a new pipeline with the configuration copied from the
* source pipeline.
*
* We would strongly advise developers to always aim to use
* {@link Cogl.Pipeline.copy} instead of cogl_pipeline_new() whenever there will
* be any similarity between two pipelines. Copying a pipeline helps Cogl
* keep track of a pipelines ancestry which we may use to help minimize GPU
* state changes.
* @returns a pointer to the newly allocated {@link Pipeline}
*/
copy(): Pipeline;
/**
* Iterates all the layer indices of the given #pipeline.
* @param callback A {@link PipelineLayerCallback} to be
* called for each layer index
*/
foreach_layer(callback: PipelineLayerCallback): void;
get_alpha_test_function(): PipelineAlphaFunc;
get_alpha_test_reference(): number;
/**
* Retrieves the current pipeline color.
* @returns The location to store the color
*/
get_color(): Color;
get_cull_face_mode(): PipelineCullFaceMode;
/**
* The order of the vertices within a primitive specifies whether it
* is considered to be front or back facing. This function specifies
* which order is considered to be the front
* faces. %COGL_WINDING_COUNTER_CLOCKWISE sets the front faces to
* primitives with vertices in a counter-clockwise order and
* %COGL_WINDING_CLOCKWISE sets them to be clockwise. The default is
* %COGL_WINDING_COUNTER_CLOCKWISE.
* @returns The #pipeline front face winding
*
* Status: Unstable
*/
get_front_face_winding(): Winding;
/**
* Retrieves the currently set magnification {@link PipelineFilter} set on
* the specified layer. The magnification filter determines how the
* layer should be sampled when up-scaled.
*
* The default filter is %COGL_PIPELINE_FILTER_LINEAR but this can be
* changed using {@link Cogl.Pipeline.set_layer_filters}.
* @param layer_index the layer number to change.
* @returns The magnification {@link PipelineFilter} for the
* specified layer.
*/
get_layer_mag_filter(layer_index: number): PipelineFilter;
/**
* Retrieves the currently set minification {@link PipelineFilter} set on
* the specified layer. The miniifcation filter determines how the
* layer should be sampled when down-scaled.
*
* The default filter is %COGL_PIPELINE_FILTER_LINEAR but this can be
* changed using {@link Cogl.Pipeline.set_layer_filters}.
* @param layer_index the layer number to change.
* @returns The minification {@link PipelineFilter} for the
* specified layer.
*/
get_layer_min_filter(layer_index: number): PipelineFilter;
/**
* Gets whether point sprite coordinate generation is enabled for this
* texture layer.
* @param layer_index the layer number to check.
* @returns whether the texture coordinates will be replaced with
* point sprite coordinates.
*/
get_layer_point_sprite_coords_enabled(layer_index: number): boolean;
get_layer_texture(layer_index: number): Texture;
/**
* Returns the wrap mode for the 's' coordinate of texture lookups on this
* layer.
* @param layer_index the layer number to change.
* @returns the wrap mode for the 's' coordinate of texture lookups on
* this layer.
*/
get_layer_wrap_mode_s(layer_index: number): PipelineWrapMode;
/**
* Returns the wrap mode for the 't' coordinate of texture lookups on this
* layer.
* @param layer_index the layer number to change.
* @returns the wrap mode for the 't' coordinate of texture lookups on
* this layer.
*/
get_layer_wrap_mode_t(layer_index: number): PipelineWrapMode;
/**
* Retrieves the number of layers defined for the given #pipeline
* @returns the number of layers
*/
get_n_layers(): number;
get_per_vertex_point_size(): boolean;
/**
* Get the size of points drawn when %COGL_VERTICES_MODE_POINTS is
* used with the vertex buffer API.
* @returns the point size of the #pipeline.
*/
get_point_size(): number;
/**
* This is used to get an integer representing the uniform with the
* name #uniform_name. The integer can be passed to functions such as
* {@link Cogl.Pipeline.set_uniform_1f} to set the value of a uniform.
*
* This function will always return a valid integer. Ie, unlike
* OpenGL, it does not return -1 if the uniform is not available in
* this pipeline so it can not be used to test whether uniforms are
* present. It is not necessary to set the program on the pipeline
* before calling this function.
* @param uniform_name The name of a uniform
* @returns A integer representing the location of the given uniform.
*/
get_uniform_location(uniform_name: string): number;
/**
* Queries what user program has been associated with the given
* #pipeline using {@link Cogl.Pipeline.set_user_program}.
* @returns The current user program or %NULL.
*/
get_user_program(): Handle;
/**
* This function removes a layer from your pipeline
* @param layer_index Specifies the layer you want to remove
*/
remove_layer(layer_index: number): void;
/**
* Before a primitive is blended with the framebuffer, it goes through an
* alpha test stage which lets you discard fragments based on the current
* alpha value. This function lets you change the function used to evaluate
* the alpha channel, and thus determine which fragments are discarded
* and which continue on to the blending stage.
*
* The default is %COGL_PIPELINE_ALPHA_FUNC_ALWAYS
* @param alpha_func A {@link PipelineAlphaFunc} constant
* @param alpha_reference A reference point that the chosen alpha function uses
* to compare incoming fragments to.
*/
set_alpha_test_function(alpha_func: PipelineAlphaFunc, alpha_reference: number): void;
/**
* If not already familiar; please refer <link linkend="cogl-Blend-Strings">here</link>
* for an overview of what blend strings are, and their syntax.
*
* Blending occurs after the alpha test function, and combines fragments with
* the framebuffer.
*
* Currently the only blend function Cogl exposes is ADD(). So any valid
* blend statements will be of the form:
*
* |[
* <channel-mask>=ADD(SRC_COLOR*(<factor>), DST_COLOR*(<factor>))
* ]|
*
* This is the list of source-names usable as blend factors:
* <itemizedlist>
* <listitem><para>SRC_COLOR: The color of the in comming fragment</para></listitem>
* <listitem><para>DST_COLOR: The color of the framebuffer</para></listitem>
* <listitem><para>CONSTANT: The constant set via cogl_pipeline_set_blend_constant()</para></listitem>
* </itemizedlist>
*
* The source names can be used according to the
* <link linkend="cogl-Blend-String-syntax">color-source and factor syntax</link>,
* so for example "(1-SRC_COLOR[A])" would be a valid factor, as would
* "(CONSTANT[RGB])"
*
* These can also be used as factors:
* <itemizedlist>
* <listitem>0: (0, 0, 0, 0)</listitem>
* <listitem>1: (1, 1, 1, 1)</listitem>
* <listitem>SRC_ALPHA_SATURATE_FACTOR: (f,f,f,1) where f = MIN(SRC_COLOR[A],1-DST_COLOR[A])</listitem>
* </itemizedlist>
*
* <note>Remember; all color components are normalized to the range [0, 1]
* before computing the result of blending.</note>
*
* <example id="cogl-Blend-Strings-blend-unpremul">
* <title>Blend Strings/1</title>
* <para>Blend a non-premultiplied source over a destination with
* premultiplied alpha:</para>
* <programlisting>
* "RGB = ADD(SRC_COLOR*(SRC_COLOR[A]), DST_COLOR*(1-SRC_COLOR[A]))"
* "A = ADD(SRC_COLOR, DST_COLOR*(1-SRC_COLOR[A]))"
* </programlisting>
* </example>
*
* <example id="cogl-Blend-Strings-blend-premul">
* <title>Blend Strings/2</title>
* <para>Blend a premultiplied source over a destination with
* premultiplied alpha</para>
* <programlisting>
* "RGBA = ADD(SRC_COLOR, DST_COLOR*(1-SRC_COLOR[A]))"
* </programlisting>
* </example>
*
* The default blend string is:
* |[
* RGBA = ADD (SRC_COLOR, DST_COLOR*(1-SRC_COLOR[A]))
* ]|
*
* That gives normal alpha-blending when the calculated color for the pipeline
* is in premultiplied form.
* @param blend_string A <link linkend="cogl-Blend-Strings">Cogl blend string</link>
* describing the desired blend function.
* @returns %TRUE if the blend string was successfully parsed, and the
* described blending is supported by the underlying driver/hardware. If
* there was an error, %FALSE is returned and #error is set accordingly (if
* present).
*/
set_blend(blend_string: string): boolean;
/**
* When blending is setup to reference a CONSTANT blend factor then
* blending will depend on the constant set with this function.
* @param constant_color The constant color you want
*/
set_blend_constant(constant_color: Color): void;
/**
* Sets the basic color of the pipeline, used when no lighting is enabled.
*
* Note that if you don't add any layers to the pipeline then the color
* will be blended unmodified with the destination; the default blend
* expects premultiplied colors: for example, use (0.5, 0.0, 0.0, 0.5) for
* semi-transparent red. See {@link Cogl.Color.premultiply}.
*
* The default value is (1.0, 1.0, 1.0, 1.0)
* @param color The components of the color
*/
set_color(color: Color): void;
/**
* Sets the basic color of the pipeline, used when no lighting is enabled.
*
* The default value is (1.0, 1.0, 1.0, 1.0)
* @param red The red component
* @param green The green component
* @param blue The blue component
* @param alpha The alpha component
*/
set_color4f(red: number, green: number, blue: number, alpha: number): void;
/**
* Sets the basic color of the pipeline, used when no lighting is enabled.
*
* The default value is (0xff, 0xff, 0xff, 0xff)
* @param red The red component
* @param green The green component
* @param blue The blue component
* @param alpha The alpha component
*/
set_color4ub(red: number, green: number, blue: number, alpha: number): void;
/**
* Sets which faces will be culled when drawing. Face culling can be
* used to increase efficiency by avoiding drawing faces that would
* get overridden. For example, if a model has gaps so that it is
* impossible to see the inside then faces which are facing away from
* the screen will never be seen so there is no point in drawing
* them. This can be acheived by setting the cull face mode to
* %COGL_PIPELINE_CULL_FACE_MODE_BACK.
*
* Face culling relies on the primitives being drawn with a specific
* order to represent which faces are facing inside and outside the
* model. This order can be specified by calling
* {@link Cogl.Pipeline.set_front_face_winding}.
*
* Status: Unstable
* @param cull_face_mode The new mode to set
*/
set_cull_face_mode(cull_face_mode: PipelineCullFaceMode): void;
/**
* The order of the vertices within a primitive specifies whether it
* is considered to be front or back facing. This function specifies
* which order is considered to be the front
* faces. %COGL_WINDING_COUNTER_CLOCKWISE sets the front faces to
* primitives with vertices in a counter-clockwise order and
* %COGL_WINDING_CLOCKWISE sets them to be clockwise. The default is
* %COGL_WINDING_COUNTER_CLOCKWISE.
*
* Status: Unstable
* @param front_winding the winding order
*/
set_front_face_winding(front_winding: Winding): void;
/**
* If not already familiar; you can refer
* <link linkend="cogl-Blend-Strings">here</link> for an overview of what blend
* strings are and there syntax.
*
* These are all the functions available for texture combining:
* <itemizedlist>
* <listitem>REPLACE(arg0) = arg0</listitem>
* <listitem>MODULATE(arg0, arg1) = arg0 x arg1</listitem>
* <listitem>ADD(arg0, arg1) = arg0 + arg1</listitem>
* <listitem>ADD_SIGNED(arg0, arg1) = arg0 + arg1 - 0.5</listitem>
* <listitem>INTERPOLATE(arg0, arg1, arg2) = arg0 x arg2 + arg1 x (1 - arg2)</listitem>
* <listitem>SUBTRACT(arg0, arg1) = arg0 - arg1</listitem>
* <listitem>
* <programlisting>
* DOT3_RGB(arg0, arg1) = 4 x ((arg0[R] - 0.5)) * (arg1[R] - 0.5) +
* (arg0[G] - 0.5)) * (arg1[G] - 0.5) +
* (arg0[B] - 0.5)) * (arg1[B] - 0.5))
* </programlisting>
* </listitem>
* <listitem>
* <programlisting>
* DOT3_RGBA(arg0, arg1) = 4 x ((arg0[R] - 0.5)) * (arg1[R] - 0.5) +
* (arg0[G] - 0.5)) * (arg1[G] - 0.5) +
* (arg0[B] - 0.5)) * (arg1[B] - 0.5))
* </programlisting>
* </listitem>
* </itemizedlist>
*
* Refer to the
* <link linkend="cogl-Blend-String-syntax">color-source syntax</link> for
* describing the arguments. The valid source names for texture combining
* are:
* <variablelist>
* <varlistentry>
* <term>TEXTURE</term>
* <listitem>Use the color from the current texture layer</listitem>
* </varlistentry>
* <varlistentry>
* <term>TEXTURE_0, TEXTURE_1, etc</term>
* <listitem>Use the color from the specified texture layer</listitem>
* </varlistentry>
* <varlistentry>
* <term>CONSTANT</term>
* <listitem>Use the color from the constant given with
* {@link Cogl.Pipeline.set_layer_combine_constant}</listitem>
* </varlistentry>
* <varlistentry>
* <term>PRIMARY</term>
* <listitem>Use the color of the pipeline as set with
* cogl_pipeline_set_color()</listitem>
* </varlistentry>
* <varlistentry>
* <term>PREVIOUS</term>
* <listitem>Either use the texture color from the previous layer, or
* if this is layer 0, use the color of the pipeline as set with
* cogl_pipeline_set_color()</listitem>
* </varlistentry>
* </variablelist>
*
* <refsect2 id="cogl-Layer-Combine-Examples">
* <title>Layer Combine Examples</title>
* <para>This is effectively what the default blending is:</para>
* <informalexample><programlisting>
* RGBA = MODULATE (PREVIOUS, TEXTURE)
* </programlisting></informalexample>
* <para>This could be used to cross-fade between two images, using
* the alpha component of a constant as the interpolator. The constant
* color is given by calling
* cogl_pipeline_set_layer_combine_constant().</para>
* <informalexample><programlisting>
* RGBA = INTERPOLATE (PREVIOUS, TEXTURE, CONSTANT[A])
* </programlisting></informalexample>
* </refsect2>
*
* <note>You can't give a multiplication factor for arguments as you can
* with blending.</note>
* @param layer_index Specifies the layer you want define a combine function for
* @param blend_string A <link linkend="cogl-Blend-Strings">Cogl blend string</link>
* describing the desired texture combine function.
* @returns %TRUE if the blend string was successfully parsed, and the
* described texture combining is supported by the underlying driver and
* or hardware. On failure, %FALSE is returned and #error is set
*/
set_layer_combine(layer_index: number, blend_string: string): boolean;
/**
* When you are using the 'CONSTANT' color source in a layer combine
* description then you can use this function to define its value.
* @param layer_index Specifies the layer you want to specify a constant used
* for texture combining
* @param constant The constant color you want
*/
set_layer_combine_constant(layer_index: number, constant: Color): void;
/**
* Changes the decimation and interpolation filters used when a texture is
* drawn at other scales than 100%.
*
* <note>It is an error to pass anything other than
* %COGL_PIPELINE_FILTER_NEAREST or %COGL_PIPELINE_FILTER_LINEAR as
* magnification filters since magnification doesn't ever need to
* reference values stored in the mipmap chain.</note>
* @param layer_index the layer number to change.
* @param min_filter the filter used when scaling a texture down.
* @param mag_filter the filter used when magnifying a texture.
*/
set_layer_filters(layer_index: number, min_filter: PipelineFilter, mag_filter: PipelineFilter): void;
/**
* This function lets you set a matrix that can be used to e.g. translate
* and rotate a single layer of a pipeline used to fill your geometry.
* @param layer_index the index for the layer inside #pipeline
* @param matrix the transformation matrix for the layer
*/
set_layer_matrix(layer_index: number, matrix: Matrix): void;
set_layer_max_mipmap_level(layer: number, max_level: number): void;
/**
* Sets the texture for this layer to be the default texture for the
* given type. The default texture is a 1x1 pixel white texture.
*
* This function is mostly useful if you want to create a base
* pipeline that you want to create multiple copies from using
* {@link Cogl.Pipeline.copy}. In that case this function can be used to
* specify the texture type so that any pipeline copies can share the
* internal texture type state for efficiency.
* @param layer_index The layer number to modify
*/
set_layer_null_texture(layer_index: number): void;
/**
* When rendering points, if #enable is %TRUE then the texture
* coordinates for this layer will be replaced with coordinates that
* vary from 0.0 to 1.0 across the primitive. The top left of the
* point will have the coordinates 0.0,0.0 and the bottom right will
* have 1.0,1.0. If #enable is %FALSE then the coordinates will be
* fixed for the entire point.
* @param layer_index the layer number to change.
* @param enable whether to enable point sprite coord generation.
* @returns %TRUE if the function succeeds, %FALSE otherwise.
*/
set_layer_point_sprite_coords_enabled(layer_index: number, enable: boolean): boolean;
set_layer_texture(layer_index: number, texture: Texture): void;
/**
* Sets the wrap mode for all three coordinates of texture lookups on
* this layer. This is equivalent to calling
* {@link Cogl.Pipeline.set_layer_wrap_mode_s} and
* cogl_pipeline_set_layer_wrap_mode_t() separately.
* @param layer_index the layer number to change.
* @param mode the new wrap mode
*/
set_layer_wrap_mode(layer_index: number, mode: PipelineWrapMode): void;
/**
* Sets the wrap mode for the 's' coordinate of texture lookups on this layer.
* @param layer_index the layer number to change.
* @param mode the new wrap mode
*/
set_layer_wrap_mode_s(layer_index: number, mode: PipelineWrapMode): void;
/**
* Sets the wrap mode for the 't' coordinate of texture lookups on this layer.
* @param layer_index the layer number to change.
* @param mode the new wrap mode
*/
set_layer_wrap_mode_t(layer_index: number, mode: PipelineWrapMode): void;
/**
* Sets whether to use a per-vertex point size or to use the value set
* by {@link Cogl.Pipeline.set_point_size}. If per-vertex point size is
* enabled then the point size can be set for an individual point
* either by drawing with a {@link Attribute} with the name
* ‘cogl_point_size_in’ or by writing to the GLSL builtin
* ‘cogl_point_size_out’ from a vertex shader snippet.
*