logo
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
use super::{Buffer, Context};
use std::fmt;

#[derive(Debug, Clone)]
pub struct AttributeBuffer {
    parent: Buffer,
}

impl AttributeBuffer {
    // attribute_buffer_new:
    // @context: A #Context
    // @bytes: The number of bytes to allocate for vertex attribute data.
    // @data: (array length=bytes): An optional pointer to vertex data to
    //        upload immediately.
    //
    // Describes a new #AttributeBuffer of @size bytes to contain
    // arrays of vertex attribute data and also uploads @size bytes read
    // from @data to the new buffer.
    //
    // You should never pass a %NULL data pointer.
    //
    // This fn does not report out-of-memory errors back to
    // the caller by returning %NULL and so you can assume this function
    // always succeeds.
    //
    // In the unlikely case that there is an out of memory problem
    // then  will abort the application with a message. If your
    // application needs to gracefully handle out-of-memory errors then
    // you can use attribute_buffer_new_with_size() and then
    // explicitly catch errors with buffer_set_data() or
    // buffer_map().
    //
    // Return value: (transfer full): A newly allocated #AttributeBuffer (never %NULL)
    //
    // Since: 1.4
    // Stability: Unstable
    pub fn new(context: &Context, data: &[u8]) -> AttributeBuffer {
        let buffer = AttributeBuffer::with_size(context, data.len());

        // Note: to keep the common cases simple this API doesn't throw
        // Errors, so developers can assume this fn never returns
        // NULL and we will simply abort on error.
        //
        // Developers wanting to catch errors can use
        // attribute_buffer_new_with_size() and catch errors when later
        // calling buffer_set_data() or buffer_map().

        // XXX: NB: for  2.0 we don't allow NULL data here but we can't
        // break the api for 1.x and so we keep the check for now.

        // if data {
        //     _buffer_set_data (BUFFER (buffer),
        //                         0,
        //                         data,
        //                         bytes,
        //                         NULL);
        // }

        buffer
    }

    // attribute_buffer_new_with_size:
    // @context: A #Context
    // @bytes: The number of bytes to allocate for vertex attribute data.
    //
    // Describes a new #AttributeBuffer of @size bytes to contain
    // arrays of vertex attribute data. Afterwards data can be set using
    // buffer_set_data() or by mapping it into the application's
    // address space using buffer_map().
    //
    // The underlying storage of this buffer isn't allocated by this
    // fn so that you have an opportunity to use the
    // buffer_set_update_hint() and buffer_set_usage_hint()
    // functions which may influence how the storage is allocated. The
    // storage will be allocated once you upload data to the buffer.
    //
    // Note: You can assume this fn always succeeds and won't return
    // %NULL
    //
    // Return value: (transfer full): A newly allocated #AttributeBuffer. Never %NULL.
    //
    // Stability: Unstable
    pub fn with_size(context: &Context, size: usize) -> AttributeBuffer {
        // AttributeBuffer *buffer = g_slice_new (AttributeBuffer);

        // // parent's constructor
        // _buffer_initialize(BUFFER (buffer),
        //                         context,
        //                         bytes,
        //                         BUFFER_BIND_TARGET_ATTRIBUTE_BUFFER,
        //                         BUFFER_USAGE_HINT_ATTRIBUTE_BUFFER,
        //                         BUFFER_UPDATE_HINT_STATIC);

        // return _attribute_buffer_object_new (buffer);
        unimplemented!()
    }
}

impl fmt::Display for AttributeBuffer {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(f, "AttributeBuffer")
    }
}