File tree Expand file tree Collapse file tree 4 files changed +36
-0
lines changed Expand file tree Collapse file tree 4 files changed +36
-0
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ use NativeGLContextMethods;
6
6
use GLContextAttributes ;
7
7
use GLContextCapabilities ;
8
8
use GLFormats ;
9
+ use GLLimits ;
9
10
use DrawBuffer ;
10
11
use ColorAttachmentType ;
11
12
@@ -21,6 +22,7 @@ pub struct GLContext<Native> {
21
22
attributes : GLContextAttributes ,
22
23
capabilities : GLContextCapabilities ,
23
24
formats : GLFormats ,
25
+ limits : GLLimits ,
24
26
}
25
27
26
28
impl < Native > GLContext < Native >
@@ -30,13 +32,15 @@ impl<Native> GLContext<Native>
30
32
try!( native_context. make_current ( ) ) ;
31
33
let attributes = GLContextAttributes :: any ( ) ;
32
34
let formats = GLFormats :: detect ( & attributes) ;
35
+ let limits = GLLimits :: detect ( ) ;
33
36
34
37
Ok ( GLContext {
35
38
native_context : native_context,
36
39
draw_buffer : None ,
37
40
attributes : attributes,
38
41
capabilities : GLContextCapabilities :: detect ( ) ,
39
42
formats : formats,
43
+ limits : limits,
40
44
} )
41
45
}
42
46
@@ -110,6 +114,10 @@ impl<Native> GLContext<Native>
110
114
& self . formats
111
115
}
112
116
117
+ pub fn borrow_limits ( & self ) -> & GLLimits {
118
+ & self . limits
119
+ }
120
+
113
121
pub fn borrow_draw_buffer ( & self ) -> Option < & DrawBuffer > {
114
122
self . draw_buffer . as_ref ( )
115
123
}
Original file line number Diff line number Diff line change
1
+ use gleam:: gl:: types:: GLint ;
2
+ use gleam:: gl;
3
+
4
+ #[ derive( Clone , Deserialize , Serialize ) ]
5
+ pub struct GLLimits {
6
+ pub max_vertex_attribs : GLint ,
7
+ }
8
+
9
+ impl GLLimits {
10
+ pub fn detect ( ) -> GLLimits {
11
+ GLLimits {
12
+ max_vertex_attribs : gl:: get_integer_v ( gl:: MAX_VERTEX_ATTRIBS ) ,
13
+ }
14
+ }
15
+ }
Original file line number Diff line number Diff line change @@ -34,6 +34,9 @@ pub use gl_feature::GLFeature;
34
34
mod gl_formats;
35
35
pub use gl_formats:: GLFormats ;
36
36
37
+ mod gl_limits;
38
+ pub use gl_limits:: GLLimits ;
39
+
37
40
#[ macro_use]
38
41
extern crate log;
39
42
Original file line number Diff line number Diff line change @@ -159,3 +159,13 @@ fn test_sharing() {
159
159
160
160
test_pixels ( & vec) ;
161
161
}
162
+
163
+ #[ test]
164
+ fn test_limits ( ) {
165
+ let size = Size2D :: new ( 256 , 256 ) ;
166
+ let context = GLContext :: < NativeGLContext > :: new ( size,
167
+ GLContextAttributes :: default ( ) ,
168
+ ColorAttachmentType :: Texture ,
169
+ None ) . unwrap ( ) ;
170
+ assert ! ( context. borrow_limits( ) . max_vertex_attribs != 0 ) ;
171
+ }
You can’t perform that action at this time.
0 commit comments