Skip to content

Commit 0e3cba1

Browse files
committed
Base instance drawing
1 parent 9196975 commit 0e3cba1

File tree

5 files changed

+178
-18
lines changed

5 files changed

+178
-18
lines changed

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@ repository = "https://github.com/servo/gleam"
99
description = "Generated OpenGL bindings and wrapper for Servo."
1010

1111
[build-dependencies]
12-
gl_generator = "0.14"
12+
#gl_generator = "0.14"
13+
gl_generator = { path = "../gl-rs/gl_generator" }

build.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ fn main() {
1818
"GL_APPLE_fence",
1919
"GL_APPLE_texture_range",
2020
"GL_APPLE_vertex_array_object",
21+
"GL_ARB_base_instance",
2122
"GL_ARB_blend_func_extended",
2223
"GL_ARB_copy_image",
2324
"GL_ARB_get_program_binary",
@@ -43,24 +44,25 @@ fn main() {
4344

4445
// GLES 3.0 bindings
4546
let gles_extensions = [
47+
"GL_ANGLE_base_vertex_base_instance",
48+
"GL_ANGLE_copy_texture_3d",
49+
"GL_ANGLE_provoking_vertex",
50+
"GL_ANGLE_texture_usage",
51+
"GL_CHROMIUM_copy_texture",
4652
"GL_EXT_copy_image",
4753
"GL_EXT_debug_marker",
4854
"GL_EXT_disjoint_timer_query",
55+
"GL_EXT_shader_pixel_local_storage",
4956
"GL_EXT_shader_texture_lod",
5057
"GL_EXT_texture_filter_anisotropic",
5158
"GL_EXT_texture_format_BGRA8888",
5259
"GL_EXT_texture_storage",
53-
"GL_OES_EGL_image_external",
5460
"GL_OES_EGL_image",
61+
"GL_OES_EGL_image_external",
5562
"GL_OES_texture_half_float",
56-
"GL_EXT_shader_pixel_local_storage",
57-
"GL_ANGLE_provoking_vertex",
58-
"GL_ANGLE_texture_usage",
59-
"GL_CHROMIUM_copy_texture",
60-
"GL_KHR_debug",
6163
"GL_KHR_blend_equation_advanced",
6264
"GL_KHR_blend_equation_advanced_coherent",
63-
"GL_ANGLE_copy_texture_3d",
65+
"GL_KHR_debug",
6466
];
6567
let gles_reg = Registry::new(
6668
Api::Gles2,

src/gl.rs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,20 @@ declare_gl_apis! {
446446
first: GLint,
447447
count: GLsizei,
448448
primcount: GLsizei);
449+
// GL_ARB_base_instance
450+
fn draw_arrays_instanced_base_instance(&self,
451+
mode: GLenum,
452+
first: GLint,
453+
count: GLsizei,
454+
instance_count: GLsizei,
455+
base_instance: GLuint);
456+
// GL_ANGLE_base_vertex_base_instance
457+
fn draw_arrays_instanced_base_instance_angle(&self,
458+
mode: GLenum,
459+
first: GLint,
460+
count: GLsizei,
461+
instance_count: GLsizei,
462+
base_instance: GLuint);
449463
fn draw_elements(&self,
450464
mode: GLenum,
451465
count: GLsizei,
@@ -457,6 +471,24 @@ declare_gl_apis! {
457471
element_type: GLenum,
458472
indices_offset: GLuint,
459473
primcount: GLsizei);
474+
// GL_ARB_base_instance
475+
fn draw_elements_instanced_base_instance(&self,
476+
mode: GLenum,
477+
count: GLsizei,
478+
element_type: GLenum,
479+
indices_offset: GLuint,
480+
instance_count: GLsizei,
481+
base_instance: GLuint);
482+
// GL_ANGLE_base_vertex_base_instance
483+
fn draw_elements_instanced_base_vertex_base_instance_angle(&self,
484+
mode: GLenum,
485+
count: GLsizei,
486+
element_type: GLenum,
487+
indices_offset: GLuint,
488+
instance_count: GLsizei,
489+
base_vertex: GLsizei,
490+
base_instance: GLuint);
491+
460492
fn blend_color(&self, r: f32, g: f32, b: f32, a: f32);
461493
fn blend_func(&self, sfactor: GLenum, dfactor: GLenum);
462494
fn blend_func_separate(&self,

src/gl_fns.rs

Lines changed: 63 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1156,7 +1156,7 @@ impl Gl for GlFns {
11561156

11571157
fn draw_arrays(&self, mode: GLenum, first: GLint, count: GLsizei) {
11581158
unsafe {
1159-
return self.ffi_gl_.DrawArrays(mode, first, count);
1159+
self.ffi_gl_.DrawArrays(mode, first, count);
11601160
}
11611161
}
11621162

@@ -1168,12 +1168,36 @@ impl Gl for GlFns {
11681168
primcount: GLsizei,
11691169
) {
11701170
unsafe {
1171-
return self
1172-
.ffi_gl_
1171+
self.ffi_gl_
11731172
.DrawArraysInstanced(mode, first, count, primcount);
11741173
}
11751174
}
11761175

1176+
fn draw_arrays_instanced_base_instance(
1177+
&self,
1178+
mode: GLenum,
1179+
first: GLint,
1180+
count: GLsizei,
1181+
instance_count: GLsizei,
1182+
base_instance: GLuint,
1183+
) {
1184+
unsafe {
1185+
self.ffi_gl_
1186+
.DrawArraysInstancedBaseInstance(mode, first, count, instance_count, base_instance);
1187+
}
1188+
}
1189+
1190+
fn draw_arrays_instanced_base_instance_angle(
1191+
&self,
1192+
_: GLenum,
1193+
_: GLint,
1194+
_: GLsizei,
1195+
_: GLsizei,
1196+
_: GLuint,
1197+
) {
1198+
unimplemented!()
1199+
}
1200+
11771201
fn draw_elements(
11781202
&self,
11791203
mode: GLenum,
@@ -1182,7 +1206,7 @@ impl Gl for GlFns {
11821206
indices_offset: GLuint,
11831207
) {
11841208
unsafe {
1185-
return self.ffi_gl_.DrawElements(
1209+
self.ffi_gl_.DrawElements(
11861210
mode,
11871211
count,
11881212
element_type,
@@ -1200,7 +1224,7 @@ impl Gl for GlFns {
12001224
primcount: GLsizei,
12011225
) {
12021226
unsafe {
1203-
return self.ffi_gl_.DrawElementsInstanced(
1227+
self.ffi_gl_.DrawElementsInstanced(
12041228
mode,
12051229
count,
12061230
element_type,
@@ -1210,6 +1234,40 @@ impl Gl for GlFns {
12101234
}
12111235
}
12121236

1237+
fn draw_elements_instanced_base_instance(
1238+
&self,
1239+
mode: GLenum,
1240+
count: GLsizei,
1241+
element_type: GLenum,
1242+
indices_offset: GLuint,
1243+
instance_count: GLsizei,
1244+
base_instance: GLuint,
1245+
) {
1246+
unsafe {
1247+
self.ffi_gl_.DrawElementsInstancedBaseInstance(
1248+
mode,
1249+
count,
1250+
element_type,
1251+
indices_offset as *const c_void,
1252+
instance_count,
1253+
base_instance,
1254+
);
1255+
}
1256+
}
1257+
1258+
fn draw_elements_instanced_base_vertex_base_instance_angle(
1259+
&self,
1260+
_: GLenum,
1261+
_: GLsizei,
1262+
_: GLenum,
1263+
_: GLuint,
1264+
_: GLsizei,
1265+
_: GLsizei,
1266+
_: GLuint,
1267+
) {
1268+
unimplemented!()
1269+
}
1270+
12131271
fn blend_color(&self, r: f32, g: f32, b: f32, a: f32) {
12141272
unsafe {
12151273
self.ffi_gl_.BlendColor(r, g, b, a);

src/gles_fns.rs

Lines changed: 72 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1159,7 +1159,7 @@ impl Gl for GlesFns {
11591159

11601160
fn draw_arrays(&self, mode: GLenum, first: GLint, count: GLsizei) {
11611161
unsafe {
1162-
return self.ffi_gl_.DrawArrays(mode, first, count);
1162+
self.ffi_gl_.DrawArrays(mode, first, count);
11631163
}
11641164
}
11651165

@@ -1171,12 +1171,36 @@ impl Gl for GlesFns {
11711171
primcount: GLsizei,
11721172
) {
11731173
unsafe {
1174-
return self
1175-
.ffi_gl_
1174+
self.ffi_gl_
11761175
.DrawArraysInstanced(mode, first, count, primcount);
11771176
}
11781177
}
11791178

1179+
fn draw_arrays_instanced_base_instance(
1180+
&self,
1181+
mode: GLenum,
1182+
first: GLint,
1183+
count: GLsizei,
1184+
instance_count: GLsizei,
1185+
base_instance: GLuint,
1186+
) {
1187+
self.draw_arrays_instanced_base_instance_angle(mode, first, count, instance_count, base_instance)
1188+
}
1189+
1190+
fn draw_arrays_instanced_base_instance_angle(
1191+
&self,
1192+
mode: GLenum,
1193+
first: GLint,
1194+
count: GLsizei,
1195+
instance_count: GLsizei,
1196+
base_instance: GLuint,
1197+
) {
1198+
unsafe {
1199+
self.ffi_gl_
1200+
.DrawArraysInstancedBaseInstanceANGLE(mode, first, count, instance_count, base_instance);
1201+
}
1202+
}
1203+
11801204
fn draw_elements(
11811205
&self,
11821206
mode: GLenum,
@@ -1185,7 +1209,7 @@ impl Gl for GlesFns {
11851209
indices_offset: GLuint,
11861210
) {
11871211
unsafe {
1188-
return self.ffi_gl_.DrawElements(
1212+
self.ffi_gl_.DrawElements(
11891213
mode,
11901214
count,
11911215
element_type,
@@ -1203,7 +1227,7 @@ impl Gl for GlesFns {
12031227
primcount: GLsizei,
12041228
) {
12051229
unsafe {
1206-
return self.ffi_gl_.DrawElementsInstanced(
1230+
self.ffi_gl_.DrawElementsInstanced(
12071231
mode,
12081232
count,
12091233
element_type,
@@ -1213,6 +1237,49 @@ impl Gl for GlesFns {
12131237
}
12141238
}
12151239

1240+
fn draw_elements_instanced_base_instance(
1241+
&self,
1242+
mode: GLenum,
1243+
count: GLsizei,
1244+
element_type: GLenum,
1245+
indices_offset: GLuint,
1246+
instance_count: GLsizei,
1247+
base_instance: GLuint,
1248+
) {
1249+
self.draw_elements_instanced_base_vertex_base_instance_angle(
1250+
mode,
1251+
count,
1252+
element_type,
1253+
indices_offset,
1254+
instance_count,
1255+
0,
1256+
base_instance,
1257+
)
1258+
}
1259+
1260+
fn draw_elements_instanced_base_vertex_base_instance_angle(
1261+
&self,
1262+
mode: GLenum,
1263+
count: GLsizei,
1264+
element_type: GLenum,
1265+
indices_offset: GLuint,
1266+
instance_count: GLsizei,
1267+
base_vertex: GLsizei,
1268+
base_instance: GLuint,
1269+
) {
1270+
unsafe {
1271+
self.ffi_gl_.DrawElementsInstancedBaseVertexBaseInstanceANGLE(
1272+
mode,
1273+
count,
1274+
element_type,
1275+
indices_offset as *const c_void,
1276+
instance_count,
1277+
base_vertex,
1278+
base_instance,
1279+
);
1280+
}
1281+
}
1282+
12161283
fn blend_color(&self, r: f32, g: f32, b: f32, a: f32) {
12171284
unsafe {
12181285
self.ffi_gl_.BlendColor(r, g, b, a);

0 commit comments

Comments
 (0)