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
// This file was generated by gir (https://github.com/gtk-rs/gir) // from gir-files (https://github.com/gtk-rs/gir-files) // DO NOT EDIT use glib; use glib::object::IsA; use glib::object::ObjectType as ObjectType_; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; #[cfg(any(feature = "v1_16", feature = "dox"))] use glib::GString; use glib::StaticType; use glib::Value; use glib_sys; use gobject_sys; use gst; use gst_gl_sys; use std::boxed::Box as Box_; use std::mem::transmute; use std::ptr; use GLContext; #[cfg(any(feature = "v1_16", feature = "dox"))] use GLSLProfile; use GLSLStage; #[cfg(any(feature = "v1_16", feature = "dox"))] use GLSLVersion; glib_wrapper! { /// /// /// # Implements /// /// [`gst::ObjectExt`](../gst/trait.ObjectExt.html), [`glib::object::ObjectExt`](../glib/object/trait.ObjectExt.html) pub struct GLShader(Object<gst_gl_sys::GstGLShader, gst_gl_sys::GstGLShaderClass, GLShaderClass>) @extends gst::Object; match fn { get_type => || gst_gl_sys::gst_gl_shader_get_type(), } } impl GLShader { /// Note: must be called in the GL thread /// ## `context` /// a `GLContext` /// /// # Returns /// /// a new empty `shader` pub fn new<P: IsA<GLContext>>(context: &P) -> GLShader { skip_assert_initialized!(); unsafe { from_glib_full(gst_gl_sys::gst_gl_shader_new( context.as_ref().to_glib_none().0, )) } } /// Note: must be called in the GL thread /// ## `context` /// a `GLContext` /// /// # Returns /// /// a default `shader` or `None` on failure pub fn new_default<P: IsA<GLContext>>(context: &P) -> Result<GLShader, glib::Error> { skip_assert_initialized!(); unsafe { let mut error = ptr::null_mut(); let ret = gst_gl_sys::gst_gl_shader_new_default( context.as_ref().to_glib_none().0, &mut error, ); if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } //pub fn new_link_with_stages<P: IsA<GLContext>>(context: &P, error: &mut glib::Error, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) -> GLShader { // unsafe { TODO: call gst_gl_sys:gst_gl_shader_new_link_with_stages() } //} //pub fn with_stages<P: IsA<GLContext>>(context: &P, error: &mut glib::Error, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) -> GLShader { // unsafe { TODO: call gst_gl_sys:gst_gl_shader_new_with_stages() } //} /// Attaches `stage` to `self`. `stage` must have been successfully compiled /// with `GLSLStage::compile`. /// /// Note: must be called in the GL thread /// ## `stage` /// a `GLSLStage` to attach /// /// # Returns /// /// whether `stage` could be attached to `self` pub fn attach(&self, stage: &GLSLStage) -> Result<(), glib::error::BoolError> { unsafe { glib_result_from_gboolean!( gst_gl_sys::gst_gl_shader_attach(self.to_glib_none().0, stage.to_glib_none().0), "Failed to attach stage to shader" ) } } /// Attaches `stage` to `self`. `stage` must have been successfully compiled /// with `GLSLStage::compile`. /// /// Note: must be called in the GL thread /// ## `stage` /// a `GLSLStage` to attach /// /// # Returns /// /// whether `stage` could be attached to `self` pub fn attach_unlocked(&self, stage: &GLSLStage) -> Result<(), glib::error::BoolError> { unsafe { glib_result_from_gboolean!( gst_gl_sys::gst_gl_shader_attach_unlocked( self.to_glib_none().0, stage.to_glib_none().0 ), "Failed to attach stage to shader" ) } } /// Bind attribute `name` to the specified location `index` using /// `glBindAttributeLocation()`. /// ## `index` /// attribute index to set /// ## `name` /// name of the attribute pub fn bind_attribute_location(&self, index: u32, name: &str) { unsafe { gst_gl_sys::gst_gl_shader_bind_attribute_location( self.to_glib_none().0, index, name.to_glib_none().0, ); } } /// Bind attribute `name` to the specified location `index` using /// `glBindFragDataLocation()`. /// ## `index` /// attribute index to set /// ## `name` /// name of the attribute pub fn bind_frag_data_location(&self, index: u32, name: &str) { unsafe { gst_gl_sys::gst_gl_shader_bind_frag_data_location( self.to_glib_none().0, index, name.to_glib_none().0, ); } } /// Compiles `stage` and attaches it to `self`. /// /// Note: must be called in the GL thread /// ## `stage` /// a `GLSLStage` to attach /// /// # Returns /// /// whether `stage` could be compiled and attached to `self` pub fn compile_attach_stage(&self, stage: &GLSLStage) -> Result<(), glib::Error> { unsafe { let mut error = ptr::null_mut(); let _ = gst_gl_sys::gst_gl_shader_compile_attach_stage( self.to_glib_none().0, stage.to_glib_none().0, &mut error, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } /// Detaches `stage` from `self`. `stage` must have been successfully attached /// to `self` with `GLShader::attach` or `GLShader::attach_unlocked`. /// /// Note: must be called in the GL thread /// ## `stage` /// a `GLSLStage` to attach pub fn detach(&self, stage: &GLSLStage) { unsafe { gst_gl_sys::gst_gl_shader_detach(self.to_glib_none().0, stage.to_glib_none().0); } } /// Detaches `stage` from `self`. `stage` must have been successfully attached /// to `self` with `GLShader::attach` or `GLShader::attach_unlocked`. /// /// Note: must be called in the GL thread /// ## `stage` /// a `GLSLStage` to attach pub fn detach_unlocked(&self, stage: &GLSLStage) { unsafe { gst_gl_sys::gst_gl_shader_detach_unlocked( self.to_glib_none().0, stage.to_glib_none().0, ); } } /// ## `name` /// name of the attribute /// /// # Returns /// /// the attribute index for `name` in `self` or -1 on failure pub fn get_attribute_location(&self, name: &str) -> i32 { unsafe { gst_gl_sys::gst_gl_shader_get_attribute_location( self.to_glib_none().0, name.to_glib_none().0, ) } } /// /// # Returns /// /// the GL program handle for this shader pub fn get_program_handle(&self) -> i32 { unsafe { gst_gl_sys::gst_gl_shader_get_program_handle(self.to_glib_none().0) } } /// Note: must be called in the GL thread /// /// # Returns /// /// whether `self` has been successfully linked pub fn is_linked(&self) -> bool { unsafe { from_glib(gst_gl_sys::gst_gl_shader_is_linked(self.to_glib_none().0)) } } /// Links the current list of `GLSLStage`'s in `self`. /// /// Note: must be called in the GL thread /// /// # Returns /// /// whether `self` could be linked together. pub fn link(&self) -> Result<(), glib::Error> { unsafe { let mut error = ptr::null_mut(); let _ = gst_gl_sys::gst_gl_shader_link(self.to_glib_none().0, &mut error); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } /// Releases the shader and stages. /// /// Note: must be called in the GL thread pub fn release(&self) { unsafe { gst_gl_sys::gst_gl_shader_release(self.to_glib_none().0); } } /// Releases the shader and stages. /// /// Note: must be called in the GL thread pub fn release_unlocked(&self) { unsafe { gst_gl_sys::gst_gl_shader_release_unlocked(self.to_glib_none().0); } } /// Perform `glUniform1f()` for `name` on `self` /// ## `name` /// name of the uniform /// ## `value` /// value to set pub fn set_uniform_1f(&self, name: &str, value: f32) { unsafe { gst_gl_sys::gst_gl_shader_set_uniform_1f( self.to_glib_none().0, name.to_glib_none().0, value, ); } } /// Perform `glUniform1fv()` for `name` on `self` /// ## `name` /// name of the uniform /// ## `count` /// number of values to set /// ## `value` /// values to set pub fn set_uniform_1fv(&self, name: &str, value: &[f32]) { let count = value.len() as u32; unsafe { gst_gl_sys::gst_gl_shader_set_uniform_1fv( self.to_glib_none().0, name.to_glib_none().0, count, value.to_glib_none().0, ); } } /// Perform `glUniform1i()` for `name` on `self` /// ## `name` /// name of the uniform /// ## `value` /// value to set pub fn set_uniform_1i(&self, name: &str, value: i32) { unsafe { gst_gl_sys::gst_gl_shader_set_uniform_1i( self.to_glib_none().0, name.to_glib_none().0, value, ); } } /// Perform `glUniform1iv()` for `name` on `self` /// ## `name` /// name of the uniform /// ## `count` /// number of values to set /// ## `value` /// values to set pub fn set_uniform_1iv(&self, name: &str, value: &[i32]) { let count = value.len() as u32; unsafe { gst_gl_sys::gst_gl_shader_set_uniform_1iv( self.to_glib_none().0, name.to_glib_none().0, count, value.to_glib_none().0, ); } } /// Perform `glUniform2f()` for `name` on `self` /// ## `name` /// name of the uniform /// ## `v0` /// first value to set /// ## `v1` /// second value to set pub fn set_uniform_2f(&self, name: &str, v0: f32, v1: f32) { unsafe { gst_gl_sys::gst_gl_shader_set_uniform_2f( self.to_glib_none().0, name.to_glib_none().0, v0, v1, ); } } /// Perform `glUniform2fv()` for `name` on `self` /// ## `name` /// name of the uniform /// ## `count` /// number of values to set /// ## `value` /// values to set pub fn set_uniform_2fv(&self, name: &str, value: &[f32]) { let count = value.len() as u32; unsafe { gst_gl_sys::gst_gl_shader_set_uniform_2fv( self.to_glib_none().0, name.to_glib_none().0, count, value.to_glib_none().0, ); } } /// Perform `glUniform2i()` for `name` on `self` /// ## `name` /// name of the uniform /// ## `v0` /// first value to set /// ## `v1` /// second value to set pub fn set_uniform_2i(&self, name: &str, v0: i32, v1: i32) { unsafe { gst_gl_sys::gst_gl_shader_set_uniform_2i( self.to_glib_none().0, name.to_glib_none().0, v0, v1, ); } } /// Perform `glUniform2iv()` for `name` on `self` /// ## `name` /// name of the uniform /// ## `count` /// number of values to set /// ## `value` /// values to set pub fn set_uniform_2iv(&self, name: &str, value: &[i32]) { let count = value.len() as u32; unsafe { gst_gl_sys::gst_gl_shader_set_uniform_2iv( self.to_glib_none().0, name.to_glib_none().0, count, value.to_glib_none().0, ); } } /// Perform `glUniform3f()` for `name` on `self` /// ## `name` /// name of the uniform /// ## `v0` /// first value to set /// ## `v1` /// second value to set /// ## `v2` /// third value to set pub fn set_uniform_3f(&self, name: &str, v0: f32, v1: f32, v2: f32) { unsafe { gst_gl_sys::gst_gl_shader_set_uniform_3f( self.to_glib_none().0, name.to_glib_none().0, v0, v1, v2, ); } } /// Perform `glUniform3fv()` for `name` on `self` /// ## `name` /// name of the uniform /// ## `count` /// number of values to set /// ## `value` /// values to set pub fn set_uniform_3fv(&self, name: &str, value: &[f32]) { let count = value.len() as u32; unsafe { gst_gl_sys::gst_gl_shader_set_uniform_3fv( self.to_glib_none().0, name.to_glib_none().0, count, value.to_glib_none().0, ); } } /// Perform `glUniform3i()` for `name` on `self` /// ## `name` /// name of the uniform /// ## `v0` /// first value to set /// ## `v1` /// second value to set /// ## `v2` /// third value to set pub fn set_uniform_3i(&self, name: &str, v0: i32, v1: i32, v2: i32) { unsafe { gst_gl_sys::gst_gl_shader_set_uniform_3i( self.to_glib_none().0, name.to_glib_none().0, v0, v1, v2, ); } } /// Perform `glUniform3iv()` for `name` on `self` /// ## `name` /// name of the uniform /// ## `count` /// number of values to set /// ## `value` /// values to set pub fn set_uniform_3iv(&self, name: &str, value: &[i32]) { let count = value.len() as u32; unsafe { gst_gl_sys::gst_gl_shader_set_uniform_3iv( self.to_glib_none().0, name.to_glib_none().0, count, value.to_glib_none().0, ); } } /// Perform `glUniform4f()` for `name` on `self` /// ## `name` /// name of the uniform /// ## `v0` /// first value to set /// ## `v1` /// second value to set /// ## `v2` /// third value to set /// ## `v3` /// fourth value to set pub fn set_uniform_4f(&self, name: &str, v0: f32, v1: f32, v2: f32, v3: f32) { unsafe { gst_gl_sys::gst_gl_shader_set_uniform_4f( self.to_glib_none().0, name.to_glib_none().0, v0, v1, v2, v3, ); } } /// Perform `glUniform4fv()` for `name` on `self` /// ## `name` /// name of the uniform /// ## `count` /// number of values to set /// ## `value` /// values to set pub fn set_uniform_4fv(&self, name: &str, value: &[f32]) { let count = value.len() as u32; unsafe { gst_gl_sys::gst_gl_shader_set_uniform_4fv( self.to_glib_none().0, name.to_glib_none().0, count, value.to_glib_none().0, ); } } /// Perform `glUniform4i()` for `name` on `self` /// ## `name` /// name of the uniform /// ## `v0` /// first value to set /// ## `v1` /// second value to set /// ## `v2` /// third value to set /// ## `v3` /// fourth value to set pub fn set_uniform_4i(&self, name: &str, v0: i32, v1: i32, v2: i32, v3: i32) { unsafe { gst_gl_sys::gst_gl_shader_set_uniform_4i( self.to_glib_none().0, name.to_glib_none().0, v0, v1, v2, v3, ); } } /// Perform `glUniform4iv()` for `name` on `self` /// ## `name` /// name of the uniform /// ## `count` /// number of values to set /// ## `value` /// values to set pub fn set_uniform_4iv(&self, name: &str, value: &[i32]) { let count = value.len() as u32; unsafe { gst_gl_sys::gst_gl_shader_set_uniform_4iv( self.to_glib_none().0, name.to_glib_none().0, count, value.to_glib_none().0, ); } } pub fn use_(&self) { unsafe { gst_gl_sys::gst_gl_shader_use(self.to_glib_none().0); } } pub fn get_property_linked(&self) -> bool { unsafe { let mut value = Value::from_type(<bool as StaticType>::static_type()); gobject_sys::g_object_get_property( self.as_ptr() as *mut gobject_sys::GObject, b"linked\0".as_ptr() as *const _, value.to_glib_none_mut().0, ); value .get() .expect("Return Value for property `linked` getter") .unwrap() } } /// /// Feature: `v1_16` /// /// ## `context` /// a `GLContext` /// ## `version` /// a `GLSLVersion` /// ## `profile` /// a `GLSLProfile` /// /// # Returns /// /// a passthrough shader string for copying an input external-oes /// texture to the output #[cfg(any(feature = "v1_16", feature = "dox"))] pub fn string_fragment_external_oes_get_default<P: IsA<GLContext>>( context: &P, version: GLSLVersion, profile: GLSLProfile, ) -> Option<GString> { skip_assert_initialized!(); unsafe { from_glib_full( gst_gl_sys::gst_gl_shader_string_fragment_external_oes_get_default( context.as_ref().to_glib_none().0, version.to_glib(), profile.to_glib(), ), ) } } /// /// Feature: `v1_16` /// /// ## `context` /// a `GLContext` /// ## `version` /// a `GLSLVersion` /// ## `profile` /// a `GLSLProfile` /// /// # Returns /// /// a passthrough shader string for copying an input texture to /// the output #[cfg(any(feature = "v1_16", feature = "dox"))] pub fn string_fragment_get_default<P: IsA<GLContext>>( context: &P, version: GLSLVersion, profile: GLSLProfile, ) -> Option<GString> { skip_assert_initialized!(); unsafe { from_glib_full(gst_gl_sys::gst_gl_shader_string_fragment_get_default( context.as_ref().to_glib_none().0, version.to_glib(), profile.to_glib(), )) } } /// Generates a shader string that defines the precision of float types in /// GLSL shaders. This is particularly needed for fragment shaders in a /// GLSL ES context where there is no default precision specified. /// /// Practically, this will return the string 'precision mediump float' /// or 'precision highp float' depending on if high precision floats are /// determined to be supported. /// /// Feature: `v1_16` /// /// ## `context` /// a `GLContext` /// ## `version` /// a `GLSLVersion` /// ## `profile` /// a `GLSLProfile` /// /// # Returns /// /// a shader string defining the precision of float types based on /// `context`, `version` and `profile` #[cfg(any(feature = "v1_16", feature = "dox"))] pub fn string_get_highest_precision<P: IsA<GLContext>>( context: &P, version: GLSLVersion, profile: GLSLProfile, ) -> Option<GString> { skip_assert_initialized!(); unsafe { from_glib_none(gst_gl_sys::gst_gl_shader_string_get_highest_precision( context.as_ref().to_glib_none().0, version.to_glib(), profile.to_glib(), )) } } pub fn connect_property_linked_notify<F: Fn(&GLShader) + Send + Sync + 'static>( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn notify_linked_trampoline<F: Fn(&GLShader) + Send + Sync + 'static>( this: *mut gst_gl_sys::GstGLShader, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, ) { let f: &F = &*(f as *const F); f(&from_glib_borrow(this)) } unsafe { let f: Box_<F> = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::linked\0".as_ptr() as *const _, Some(transmute::<_, unsafe extern "C" fn()>( notify_linked_trampoline::<F> as *const (), )), Box_::into_raw(f), ) } } } unsafe impl Send for GLShader {} unsafe impl Sync for GLShader {}