cat_engine_basement 0.0.0-alpha7

The CatEnigne's basement
Documentation
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
#[cfg(any(windows))]
use crate::windows::OpenGraphicsLibrary;

use core::mem::transmute;

const READ_FRAMEBUFFER:u32=0x8CA8;
const DRAW_FRAMEBUFFER:u32=0x8CA9;
const FRAMEBUFFER:u32=0x8D40;

const COLOR_ATTACHMENT0:u32=0x8CE0;
const DEPTH_ATTACHMENT:u32=0x8D00;
const STENCIL_ATTACHMENT:u32=0x8D20;
const DEPTH_STENCIL_ATTACHMENT:u32=0x821A;

const RENDERBUFFER:u32=0x8D41;

const COLOR_BUFFER_BIT:u32=0x00004000;
const DEPTH_BUFFER_BIT:u32=0x00000100;
const STENCIL_BUFFER_BIT:u32=0x00000400;

const NEAREST:u32=0x2600;
const LINEAR:u32=0x2601;

#[repr(u32)]
#[derive(Clone,Copy,Debug)]
pub enum FramebufferTarget{
    Read=READ_FRAMEBUFFER,
    Draw=DRAW_FRAMEBUFFER,
    ReadDraw=FRAMEBUFFER,
}

#[derive(Clone,Copy,Debug)]
pub struct FramebufferAttachement{
    attachement:u32
}

impl FramebufferAttachement{
    /// `attachment` must be in the range zero to the value of GL_MAX_COLOR_ATTACHMENTS - 1
    pub const fn colour(attachment:u32)->FramebufferAttachement{
        Self{
            attachement:COLOR_ATTACHMENT0+attachment
        }
    }

    pub const fn depth()->FramebufferAttachement{
        Self{
            attachement:DEPTH_ATTACHMENT
        }
    }

    pub const fn stencil()->FramebufferAttachement{
        Self{
            attachement:STENCIL_ATTACHMENT
        }
    }

    pub const fn depth_stencil()->FramebufferAttachement{
        Self{
            attachement:DEPTH_STENCIL_ATTACHMENT
        }
    }
}

#[repr(u32)]
#[derive(Clone,Copy,Debug)]
pub enum BlitMask{
    Colour=COLOR_BUFFER_BIT,
    Depth=DEPTH_BUFFER_BIT,
    Stencil=STENCIL_BUFFER_BIT,
    ColourDepth=COLOR_BUFFER_BIT|DEPTH_BUFFER_BIT,
    ColourStencil=COLOR_BUFFER_BIT|STENCIL_BUFFER_BIT,
    DepthStencil=DEPTH_BUFFER_BIT|STENCIL_BUFFER_BIT,
    ColourDepthStencil=COLOR_BUFFER_BIT|DEPTH_BUFFER_BIT|STENCIL_BUFFER_BIT
}

#[repr(u32)]
#[derive(Clone,Copy,Debug)]
pub enum FramebufferFilter{
    /// Returns the value of the texture element
    /// that is nearest (in Manhattan distance) to the specified texture coordinates.
    Nearest=NEAREST,

    /// Returns the weighted average of the four texture elements that are closest to the specified texture coordinates.
    /// These can include items wrapped or repeated from other parts of a texture,
    /// depending on the values of `GL_TEXTURE_WRAP_S` and `GL_TEXTURE_WRAP_T`,and on the exact mapping.
    Linear=LINEAR,
}

pub struct Framebuffer{
    glGenFramebuffers:usize,
    glDeleteFramebuffers:usize,

    glBindFramebuffer:usize,

    glFramebufferTexture:usize,
    glFramebufferTextureLayer:usize,
    glFramebufferTexture1D:usize,
    glFramebufferTexture2D:usize,
    glFramebufferTexture3D:usize,

    glFramebufferRenderbuffer:usize,

    glBlitFramebuffer:usize,

    glCheckFramebufferStatus:usize,
    glGetFramebufferAttachmentParameteriv:usize,
    glIsFramebuffer:usize,
}

impl Framebuffer{
    pub const fn new()->Framebuffer{
        Self{
            glGenFramebuffers:0,
            glDeleteFramebuffers:0,

            glBindFramebuffer:0,

            glFramebufferTexture:0,
            glFramebufferTextureLayer:0,
            glFramebufferTexture1D:0,
            glFramebufferTexture2D:0,
            glFramebufferTexture3D:0,

            glFramebufferRenderbuffer:0,

            glBlitFramebuffer:0,

            glCheckFramebufferStatus:0,
            glGetFramebufferAttachmentParameteriv:0,
            glIsFramebuffer:0,
        }
    }

    #[cfg(any(windows))]
    pub fn load(&mut self,library:&OpenGraphicsLibrary){
        unsafe{
            self.glGenFramebuffers=transmute(library.get_proc_address("glGenFramebuffers\0"));
            self.glDeleteFramebuffers=transmute(library.get_proc_address("glDeleteFramebuffers\0"));

            self.glBindFramebuffer=transmute(library.get_proc_address("glBindFramebuffer\0"));

            self.glFramebufferTexture=transmute(library.get_proc_address("glFramebufferTexture\0"));
            self.glFramebufferTextureLayer=transmute(library.get_proc_address("glFramebufferTextureLayer\0"));
            self.glFramebufferTexture1D=transmute(library.get_proc_address("glFramebufferTexture1D\0"));
            self.glFramebufferTexture2D=transmute(library.get_proc_address("glFramebufferTexture2D\0"));
            self.glFramebufferTexture3D=transmute(library.get_proc_address("glFramebufferTexture3D\0"));

            self.glFramebufferRenderbuffer=transmute(library.get_proc_address("glFramebufferRenderbuffer\0"));

            self.glBlitFramebuffer=transmute(library.get_proc_address("glBlitFramebuffer\0"));

            self.glCheckFramebufferStatus=transmute(library.get_proc_address("glCheckFramebufferStatus\0"));
            self.glGetFramebufferAttachmentParameteriv=transmute(library.get_proc_address("glGetFramebufferAttachmentParameteriv\0"));
            self.glIsFramebuffer=transmute(library.get_proc_address("glIsFramebuffer\0"));
        }
    }
}

impl Framebuffer{
    /// Generates a framebuffer object name.
    /// 
    /// See `Framebuffer::generate`.
    #[inline(always)]
    pub fn generate_one(&self,framebuffer:&mut u32){
        unsafe{
            transmute::<usize,fn(i32,&mut u32)>(self.glGenFramebuffers)(1,framebuffer)
        }
    }

    /// Deletes a buffer object.
    /// 
    /// See `Framebuffer::delete`.
    #[inline(always)]
    pub fn delete_one(&self,framebuffer:&u32){
        unsafe{
            transmute::<usize,fn(i32,&u32)>(self.glDeleteFramebuffers)(1,framebuffer)
        }
    }

    /// Generates framebuffer object names.
    /// 
    /// Returns `framebuffers.len()` framebuffer object names in `framebuffers`.
    /// There is no guarantee that the names form a contiguous set of integers;
    /// however, it is guaranteed that none of the returned names was in use immediately
    /// before the call to `Framebuffer::generate`.
    /// 
    /// Framebuffer object names returned by a call to `Framebuffer::generate` are not returned by subsequent calls,
    /// unless they are first deleted with glDeleteFramebuffers.
    /// 
    /// The names returned in `framebuffers` are marked as used,
    /// for the purposes of `Framebuffer::generate` only,
    /// but they acquire state and type only when they are first bound.
    /// 
    /// `GLError::InvalidValue` is generated if `framebuffers.len()` is greater than `i32::MAX`.
    #[inline(always)]
    pub fn generate(&self,framebuffers:&mut [u32]){
        unsafe{
            transmute::<usize,fn(i32,&mut [u32])>(self.glGenFramebuffers)(framebuffers.len() as i32,framebuffers)
        }
    }

    /// Deletes buffer objects.
    /// 
    /// Deletes the `framebuffers.len()` framebuffer objects
    /// whose name are stored in the array addressed by `framebuffers`.
    /// The name zero is reserved by the GL and is silently ignored,
    /// should it occur in `framebuffers`, as are other unused names.
    /// Once a framebuffer object is deleted, its name is again unused and it has no attachments.
    /// If a framebuffer that is currently bound to one or more of the targets `GL_DRAW_FRAMEBUFFER`
    /// or `GL_READ_FRAMEBUFFER` is deleted,
    /// it is as though `Framebuffer::bind` had been executed with the corresponding `target` and `framebuffer` zero.
    /// 
    /// `GLError::InvalidValue` is generated if `framebuffers.len()` is greater than `i32::MAX`.
    #[inline(always)]
    pub fn delete(&self,framebuffers:&[u32]){
        unsafe{
            transmute::<usize,fn(i32,&[u32])>(self.glDeleteFramebuffers)(framebuffers.len() as i32,framebuffers)
        }
    }

    /// Determines if a name corresponds to a framebuffer object.
    /// 
    /// Returns `true` if `framebuffer` is currently the name of a framebuffer object.
    /// If `framebuffer` is zero, or if framebuffer is not the name of a framebuffer object,
    /// or if an error occurs, `Framebuffer::is_framebuffer` returns `false`.
    /// If `framebuffer` is a name returned by `Framebuffer::generate`,
    /// by that has not yet been bound through a call to `Framebuffer::bind`,
    /// then the name is not a framebuffer object and `Framebuffer::is_framebuffer` returns `false`.
    #[inline(always)]
    pub fn is_framebuffer(&self,framebuffer:u32)->bool{
        unsafe{
            transmute::<usize,fn(u32)->bool>(self.glIsFramebuffer)(framebuffer)
        }
    }
}

impl Framebuffer{
    /// Binds a framebuffer to a framebuffer target.
    /// 
    /// Binds the framebuffer object with name `framebuffer` to the framebuffer target specified by `target`.
    /// If a framebuffer object is bound to `FramebufferTarget::Draw` or `FramebufferTarget::Read`,
    /// it becomes the target for rendering or readback operations, respectively,
    /// until it is deleted or another framebuffer is bound to the corresponding bind point.
    /// Calling `Framebuffer::bind` with target set to `Framebuffer::ReadDraw` binds `framebuffer` to both
    /// the read and draw framebuffer targets.
    /// `framebuffer` is the name of a framebuffer object
    /// previously returned from a call to `Framebuffer::generate`,
    /// or zero to break the existing binding of a framebuffer object to target.
    /// 
    /// `GLError::InvalidOperation` is generated
    /// if `buffer` is not a name previously returned from a call to `Buffer::generate`.
    #[inline(always)]
    pub unsafe fn bind(&self,target:FramebufferTarget,framebuffer:u32){
        transmute::<usize,fn(FramebufferTarget,u32)>(self.glBindFramebuffer)(target,framebuffer)
    }
}

impl Framebuffer{
    /// Attaches a level of a texture object as a logical buffer to the currently bound framebuffer object.
    /// 
    /// Attachs a selected mipmap level or image of a texture object
    /// as one of the logical buffers of the framebuffer object currently bound to `target`.
    /// 
    /// `attachment` specifies the logical attachment of the framebuffer.
    /// Attaching a level of a texture to `FramebufferAttachement::depth_stencil()` is equivalent to attaching
    /// that level to both the `FramebufferAttachement::depth()`
    /// and the `FramebufferAttachement::stencil()` attachment points simultaneously.
    /// 
    /// `texture_target` specifies what type of texture is named by `texture`,
    /// and for cube map textures, specifies the face that is to be attached.
    /// If `texture` is not zero, it must be the name of an existing texture with type `texture_target`,
    /// unless it is a cube map texture, in which case `texture_target` must be
    /// GL_TEXTURE_CUBE_MAP_POSITIVE_X GL_TEXTURE_CUBE_MAP_NEGATIVE_X, GL_TEXTURE_CUBE_MAP_POSITIVE_Y,
    /// GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, GL_TEXTURE_CUBE_MAP_POSITIVE_Z, or GL_TEXTURE_CUBE_MAP_NEGATIVE_Z.
    /// 
    /// If `texture` is non-zero,
    /// the specified level of the texture object named `texture` is attached
    /// to the framebfufer attachment point named by attachment.
    /// For `glFramebufferTexture1D`, `glFramebufferTexture2D`, and `glFramebufferTexture3D`,
    /// `texture` must be zero or the name of an existing texture with a target of `texture_target`,
    /// or `texture` must be the name of an existing cube-map texture and `texture_target`
    /// must be one of GL_TEXTURE_CUBE_MAP_POSITIVE_X, GL_TEXTURE_CUBE_MAP_POSITIVE_Y,
    /// GL_TEXTURE_CUBE_MAP_POSITIVE_Z, GL_TEXTURE_CUBE_MAP_NEGATIVE_X,
    /// GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, or GL_TEXTURE_CUBE_MAP_NEGATIVE_Z.
    /// 
    /// If `texture_target` is GL_TEXTURE_RECTANGLE, GL_TEXTURE_2D_MULTISAMPLE,
    /// or GL_TEXTURE_2D_MULTISAMPLE_ARRAY,then level must be zero.
    /// If `texture_target` is GL_TEXTURE_3D, then level must be greater than or equal to zero
    /// and less than or equal to log2 of the value of GL_MAX_3D_TEXTURE_SIZE.
    /// If `texture_target` is one of GL_TEXTURE_CUBE_MAP_POSITIVE_X, GL_TEXTURE_CUBE_MAP_POSITIVE_Y,
    /// GL_TEXTURE_CUBE_MAP_POSITIVE_Z, GL_TEXTURE_CUBE_MAP_NEGATIVE_X,
    /// GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, or GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, then level must be greater than
    /// or equal to zero and less than or equal to log2 of the value of GL_MAX_CUBE_MAP_TEXTURE_SIZE.
    /// For all other values of `texture_target`, level must be greater than
    /// or equal to zero and no larger than log2 of the value of GL_MAX_TEXTURE_SIZE.
    /// 
    /// `GLError::InvalidEnum` is generated
    /// if `attachment` is not one of the accepted tokens.
    /// 
    /// `GLError::InvalidOperation` is generated if zero is bound to `target`,
    /// if `texture_target` and `texture` are not compatible.
    /// 
    /// Available only if the GL version is 3.2 or greater.
    #[inline(always)]
    pub unsafe fn texture(
        &self,
        target:FramebufferTarget,
        attachment:FramebufferAttachement,
        texture:u32,
        mipmap_level:i32,
    ){
        transmute::<usize,fn(
            FramebufferTarget,
            FramebufferAttachement,
            u32,
            i32
        )>(self.glFramebufferTexture)(target,attachment,texture,mipmap_level)
    }

    /// Attaches a single layer of a texture to a framebuffer.
    /// 
    /// Operates like `Framebuffer::texture`, except that only a single layer of the texture level,
    /// given by layer, is attached to the attachment point.
    /// If `texture` is not zero, layer must be greater than or equal to zero.
    /// `texture` must either be zero or the name of an existing three-dimensional texture,
    /// one- or two-dimensional array texture, or multisample array texture.
    /// 
    /// `GLError::InvalidEnum` is generated
    /// if `attachment` is not one of the accepted tokens.
    /// 
    /// `GLError::InvalidValue` is generated
    /// if `texture` is not zero or the name of an existing texture object,
    /// `texture` is not zero and layer is negative.
    /// 
    /// `GLError::InvalidOperation` is generated if zero is bound to `target`,
    /// if `texture` is not zero or the name of an existing cube map texture.
    /// 
    /// Available only if the GL version is 3.2 or greater.
    #[inline(always)]
    pub unsafe fn texture_layer(
        &self,
        target:FramebufferTarget,
        attachment:FramebufferAttachement,
        texture:u32,
        mipmap_level:i32,
        layer:i32,
    ){
        transmute::<usize,fn(
            FramebufferTarget,
            FramebufferAttachement,
            u32,
            i32,
            i32
        )>(self.glFramebufferTexture)(target,attachment,texture,mipmap_level,layer)
    }

    /// Attaches a level of a texture object as a logical buffer to the currently bound framebuffer object.
    /// 
    /// Attachs a selected mipmap level or image of a texture object
    /// as one of the logical buffers of the framebuffer object currently bound to `target`.
    /// 
    /// If `texture` is not zero, then `texture_target` must be GL_TEXTURE_1D.
    /// 
    /// For more details see `Framebuffer::texture`.
    #[inline(always)]
    pub unsafe fn texture_1d(
        &self,
        target:FramebufferTarget,
        attachment:FramebufferAttachement,
        texture_target:u32,
        texture:u32,
        mipmap_level:i32,
    ){
        transmute::<usize,fn(
            FramebufferTarget,
            FramebufferAttachement,
            u32,
            u32,
            i32
        )>(self.glFramebufferTexture1D)(target,attachment,texture_target,texture,mipmap_level)
    }

    /// Attaches a level of a texture object as a logical buffer to the currently bound framebuffer object.
    /// 
    /// Attachs a selected mipmap level or image of a texture object
    /// as one of the logical buffers of the framebuffer object currently bound to `target`.
    /// 
    /// If `texture` is not zero, `texture_target` must be one of GL_TEXTURE_2D,
    /// GL_TEXTURE_RECTANGLE, GL_TEXTURE_CUBE_MAP_POSITIVE_X, GL_TEXTURE_CUBE_MAP_POSITIVE_Y,
    /// GL_TEXTURE_CUBE_MAP_POSITIVE_Z, GL_TEXTURE_CUBE_MAP_NEGATIVE_X, GL_TEXTURE_CUBE_MAP_NEGATIVE_Y,
    /// GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, or GL_TEXTURE_2D_MULTISAMPLE.
    /// 
    /// For more details see `Framebuffer::texture`.
    #[inline(always)]
    pub unsafe fn texture_2d(
        &self,
        target:FramebufferTarget,
        attachment:FramebufferAttachement,
        texture_target:u32,
        texture:u32,
        mipmap_level:i32,
    ){
        transmute::<usize,fn(
            FramebufferTarget,
            FramebufferAttachement,
            u32,
            u32,
            i32
        )>(self.glFramebufferTexture2D)(target,attachment,texture_target,texture,mipmap_level)
    }

    /// Attaches a level of a texture object as a logical buffer to the currently bound framebuffer object.
    /// 
    /// Attachs a selected mipmap level or image of a texture object
    /// as one of the logical buffers of the framebuffer object currently bound to `target`.
    /// 
    /// `layer` specifies the layer of a 2-dimensional image within a 3-dimensional texture.
    /// 
    /// If `texture` is not zero, then `texture_target` must be GL_TEXTURE_3D.
    /// 
    /// For more details see `Framebuffer::texture`.
    #[inline(always)]
    pub unsafe fn texture_3d(
        &self,
        target:FramebufferTarget,
        attachment:FramebufferAttachement,
        texture_target:u32,
        texture:u32,
        mipmap_level:i32,
        layer:i32
    ){
        transmute::<usize,fn(
            FramebufferTarget,
            FramebufferAttachement,
            u32,
            u32,
            i32,
            i32
        )>(self.glFramebufferTexture3D)(target,attachment,texture_target,texture,mipmap_level,layer)
    }

    /// Attaches a renderbuffer as a logical buffer to the currently bound framebuffer object.
    /// 
    /// Attaches a renderbuffer as one of the logical buffers of the currently bound framebuffer object.
    /// `renderbuffer` is the name of the renderbuffer object to attach and must be either zero,
    /// or the name of an existing renderbuffer object of type `Renderbuffer`.
    /// If `renderbuffer` is not zero and if `Framebuffer::renderbuffer` is successful,
    /// then the renderbuffer name `renderbuffer` will be usedas the logical buffer identified
    /// by `attachment` of the framebuffer currently bound to `target`.
    /// 
    /// The value of `GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE`
    /// for the specified attachment point is set to `Renderbuffer`
    /// and the value of `GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME` is set to `renderbuffer`.
    /// All other state values of the attachment point
    /// specified by `attachment` are set to their default values.
    /// No change is made to the state of the renderbuuffer object
    /// and any previous attachment to the `attachment` logical buffer of the framebuffer `target` is broken.
    /// 
    /// Calling `Framebuffer::renderbuffer` with the renderbuffer name zero will detach the image,
    /// if any, identified by `attachment`, in the framebuffer currently bound to target.
    /// All state values of the attachment point specified by attachment
    /// in the objectbound to `target` are set to their default values.
    /// 
    /// Setting attachment to the value `GL_DEPTH_STENCIL_ATTACHMENT` is a special case
    /// causing both the depth and stencil attachments of the framebuffer object to be set to `renderbuffer`,
    /// which should have the base internal format `GL_DEPTH_STENCIL`.
    /// 
    /// `GLError::InvalidOperation` is generated if zero is bound to `target`.
    #[inline(always)]
    pub unsafe fn renderbuffer(
        &self,
        target:FramebufferTarget,
        attachment:FramebufferAttachement,
        renderbuffer:u32
    ){
        transmute::<usize,fn(
            FramebufferTarget,
            FramebufferAttachement,
            u32,
            u32
        )>(self.glFramebufferRenderbuffer)(target,attachment,RENDERBUFFER,renderbuffer)
    }
}

impl Framebuffer{
    /// Copies a block of pixels from the read framebuffer to the draw.
    /// 
    /// Transfers a rectangle of pixel values from one region of the read framebuffer
    /// to another region in the draw framebuffer.
    /// `mask` indicats which buffers are to be copied.
    /// The pixels corresponding to these buffers
    /// are copied from the source rectangle bounded by the locations (srcX0; srcY0)
    /// and (srcX1; srcY1) to the destination rectangle bounded by the locations (dstX0; dstY0)
    /// and (dstX1; dstY1).
    /// The lower bounds of the rectangle are inclusive,
    /// while the upper bounds are exclusive.
    /// 
    /// The actual region taken from the read framebuffer is limited
    /// to the intersection of the source buffers being transferred,
    /// which may include the color buffer selected by the read buffer,
    /// the depth buffer, and/or the stencil buffer depending on mask.
    /// The actual region written to the draw framebuffer is limited
    /// to the intersection of the destination buffers being written,
    /// which may include multiple draw buffers, the depth buffer,
    /// and/or the stencil buffer depending on mask.
    /// Whether or not the source or destination regions are altered due to these limits,
    /// the scaling and offset applied to pixels being transferred
    /// is performedas though no such limits were present.
    /// 
    /// If the sizes of the source and destination rectangles are not equal,
    /// filter specifies the interpolation method that will be applied to resize the source image.
    /// GL_LINEAR is only a valid interpolation method for the color buffer.
    /// If filter is not GL_NEAREST and mask includes GL_DEPTH_BUFFER_BIT or GL_STENCIL_BUFFER_BIT,
    /// no data is transferred and a GL_INVALID_OPERATION error is generated.
    /// 
    /// If filter is GL_LINEAR and the source rectangle would require
    /// sampling outside the bounds of the source framebuffer,
    /// values are read as if the GL_CLAMP_TO_EDGE texture wrapping mode were applied.
    /// 
    /// When the color buffer is transferred,
    /// values are taken from the read buffer of the read framebuffer
    /// and written to each of the draw buffers of the draw framebuffer.
    /// 
    /// If the source and destination rectangles overlap or are the same,
    /// and the read and draw buffers are the same,
    /// the result of the operation is undefined.
    /// 
    /// GL_INVALID_OPERATION is generated if mask contains any of the GL_DEPTH_BUFFER_BIT or GL_STENCIL_BUFFER_BIT and filter is not GL_NEAREST.
    /// 
    /// GL_INVALID_OPERATION is generated if mask contains GL_COLOR_BUFFER_BIT and any of the following conditions hold:
    /// 
    /// The read buffer contains fixed-point or floating-point values and any draw buffer contains neither fixed-point nor floating-point values.
    /// 
    /// The read buffer contains unsigned integer values and any draw buffer does not contain unsigned integer values.
    /// 
    /// The read buffer contains signed integer values and any draw buffer does not contain signed integer values.
    /// 
    /// GL_INVALID_OPERATION is generated if mask contains GL_DEPTH_BUFFER_BIT or GL_STENCIL_BUFFER_BIT and the source and destination depth and stencil formats do not match.
    /// 
    /// GL_INVALID_OPERATION is generated if filter is GL_LINEAR and the read buffer contains integer data.
    /// 
    /// GL_INVALID_OPERATION is generated if the value of GL_SAMPLES for the read and draw buffers is not identical.
    /// 
    /// GL_INVALID_OPERATION is generated if GL_SAMPLE_BUFFERS for both read and draw buffers greater than zero and the dimensions of the source and destination rectangles is not identical.
    /// 
    /// GL_INVALID_FRAMEBUFFER_OPERATION is generated if the objects bound to GL_DRAW_FRAMEBUFFER_BINDING or GL_READ_FRAMEBUFFER_BINDING are not framebuffer complete.
    #[inline(always)]
    pub unsafe fn blit(
        &self,
        source:[i32;4],
        destination:[i32;4],
        mask:BlitMask,
        filter:FramebufferFilter
    ){
        transmute::<usize,fn(
            i32,
            i32,
            i32,
            i32,
            i32,
            i32,
            i32,
            i32,
            BlitMask,
            FramebufferFilter
        )>(self.glBlitFramebuffer)(
            source[0],
            source[1],
            source[2],
            source[3],
            destination[0],
            destination[1],
            destination[2],
            destination[3],
            mask,
            filter,
        )
    }
}

const FRAMEBUFFER_COMPLETE:u32=0x8CD5;
const FRAMEBUFFER_UNDEFINED:u32=0x8219;

#[repr(u32)]
#[derive(Clone,Copy,Debug)]
pub enum FramebufferStatus{
    /// Returned if the framebuffer bound to `target` is complete.
    Complete=FRAMEBUFFER_COMPLETE,

    /// Returned if `target` is the default framebuffer,
    /// but the default framebuffer does not exist.
    Undefined=FRAMEBUFFER_UNDEFINED,

    /// Returned if any of the framebuffer attachment points are framebuffer incomplete.
    FRAMEBUFFER_INCOMPLETE_ATTACHMENT,

    /// Returned if the framebuffer does not have at least one image attached to it.
    FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT,

    /// Returned if the value of `GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE`
    /// is `GL_NONE` for any color attachment point(s) named by `GL_DRAW_BUFFERi`.
    FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER,

    /// returned if `GL_READ_BUFFER` is not `GL_NONE` and the value of `GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE`
    /// is `GL_NONE` for the color attachment point named by `GL_READ_BUFFER`.
    FRAMEBUFFER_INCOMPLETE_READ_BUFFER,

    /// Returned if the combination of internal formats of the attached images
    /// violates an implementation-dependent set of restrictions.
    FRAMEBUFFER_UNSUPPORTED,

    /// Returned if the value of `GL_RENDERBUFFER_SAMPLES` is not the same for all attached renderbuffers;
    /// if the value of `GL_TEXTURE_SAMPLES` is the not same for all attached textures;
    /// if the attached images are a mix of renderbuffers and textures,
    /// the value of `GL_RENDERBUFFER_SAMPLES` does not match the value of `GL_TEXTURE_SAMPLES`;
    /// if the value of `GL_TEXTURE_FIXED_SAMPLE_LOCATIONS` is not the same for all attached textures;
    /// or, if the attached images are a mix of renderbuffers and textures,
    /// the value of `GL_TEXTURE_FIXED_SAMPLE_LOCATIONS` is not GL_TRUE for all attached textures.
    FRAMEBUFFER_INCOMPLETE_MULTISAMPLE,

    /// Returned if any framebuffer attachment is layered,
    /// and any populated attachment is not layered,
    /// or if all populated color attachments are not from textures of the same target.
    FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS

}

pub enum FramebufferParameter{

}

impl Framebuffer{
    /// Checks the completeness status of a framebuffer.
    /// 
    /// Queries the completeness status of the framebuffer object currently bound to `target`.
    #[inline(always)]
    pub fn check_status(&self,target:FramebufferTarget)->FramebufferStatus{
        unsafe{
            transmute::<usize,fn(FramebufferTarget)->FramebufferStatus>(self.glIsFramebuffer)(target)
        }
    }

    /// Retrieve information about attachments of a bound framebuffer object.
    /// 
    /// Returns information about attachments of a bound framebuffer object.
    /// 
    /// If the default framebuffer is bound to target
    /// then attachment must be one of `GL_FRONT_LEFT`,
    /// `GL_FRONT_RIGHT`, `GL_BACK_LEFT`, or `GL_BACK_RIGHT`,
    /// identifying a color buffer, `GL_DEPTH`, identifying the depth buffer,
    /// or GL_STENCIL, identifying the stencil buffer.
    /// 
    /// If attachment is `FramebufferAttachment::DepthStencil`
    /// and different objects are bound to the depth
    /// and stencil attachment points of targetthe query will fail.
    /// If the same object is bound to both attachment points,
    /// information about that object will be returned.
    /// 
    /// Upon successful return from glGetFramebufferAttachmentParameteriv,
    /// if pname is `GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE`,
    /// then params will contain one of GL_NONE,
    /// GL_FRAMEBUFFER_DEFAULT GL_TEXTURE, or GL_RENDERBUFFER,
    /// identifying the type of object which contains the attached image.
    /// Other values accepted for pname depend on the type of object, as described below.
    /// 
    /// If the value of GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE is GL_NONE,
    /// no framebuffer is bound to target.
    /// In this case querying pname GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME will return zero,
    /// and all other queries will generate an error.
    /// 
    /// If the value of GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE is not GL_NONE,
    /// these queries apply to all other framebuffer types:
    /// 
    /// If pname is GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE, GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE, GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE, GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE, GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE, or GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE, then params will contain the number of bits in the corresponding red, green, blue, alpha, depth, or stencil component of the specified attachment. Zero is returned if the requested component is not present in attachment.
    /// 
    /// If pname is GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE, params will contain the format of components of the specified attachment, one of GL_FLOAT, GL_INT, GL_UNSIGNED_INT, GL_SIGNED_NORMALIZED, or GL_UNSIGNED_NORMALIZED for floating-point, signed integer, unsigned integer, signed normalized fixed-point, or unsigned normalized fixed-point components respectively. Only color buffers may have integer components.
    /// 
    /// If pname is GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING, param will contain the encoding of components of the specified attachment, one of GL_LINEAR or GL_SRGB for linear or sRGB-encoded components, respectively. Only color buffer components may be sRGB-encoded; such components are treated as described in sections 4.1.7 and 4.1.8. For the default framebuffer, color encoding is determined by the implementation. For framebuffer objects, components are sRGB-encoded if the internal format of a color attachment is one of the color-renderable SRGB formats.
    /// 
    /// If the value of GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE is GL_RENDERBUFFER, then:
    /// 
    /// If pname is GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, params will contain the name of the renderbuffer object which contains the attached image.
    /// 
    /// If the value of GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE is GL_TEXTURE, then:
    /// 
    /// If pname is GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, then params will contain the name of the texture object which contains the attached image.
    /// 
    /// If pname is GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL, then params will contain the mipmap level of the texture object which contains the attached image.
    /// 
    /// If pname is GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE and the texture object named GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME is a cube map texture, then params will contain the cube map face of the cubemap texture object which contains the attached image. Otherwise params will contain the value zero.
    /// 
    /// If pname is GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER and the texture object named GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME is a layer of a three-dimensional texture or a one-or two-dimensional array texture, then params will contain the number of the texture layer which contains the attached image. Otherwise params will contain the value zero.
    /// 
    /// If pname is GL_FRAMEBUFFER_ATTACHMENT_LAYERED, then params will contain GL_TRUE if an entire level of a three-dimesional texture, cube map texture, or one-or two-dimensional array texture is attached. Otherwise, params will contain GL_FALSE.
    /// 
    /// Any combinations of framebuffer type and pname not described above will generate an error.
    /// 
    /// GL_INVALID_ENUM is generated if target is not one of the accepted tokens.
    /// 
    /// GL_INVALID_ENUM is generated if pname is not valid for the value of GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE.
    /// 
    /// GL_INVALID_OPERATION is generated if attachment is not the accepted values for target.
    /// 
    /// GL_INVALID_OPERATION is generated if attachment is GL_DEPTH_STENCIL_ATTACHMENT and different objects are bound to the depth and stencil attachment points of target.
    /// 
    /// GL_INVALID_OPERATION is generated if the value of GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE is GL_NONE and pname is not GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME.
    #[inline(always)]
    pub fn get_attachment_parameter(
        &self,
        target:FramebufferTarget,
        attachment:u32,
        paramenter:FramebufferParameter,
        parameters:&mut [i32]
    ){
        unsafe{
            transmute::<usize,fn(
                FramebufferTarget,
                u32,
                FramebufferParameter,
                &mut [i32]
            )>(self.glGetFramebufferAttachmentParameteriv)(
                target,
                attachment,
                paramenter,
                parameters
            )
        }
    }
}