Skip to content

Commit

Permalink
rust: strips spec prefix from enumerations
Browse files Browse the repository at this point in the history
  • Loading branch information
Dav1dde committed Aug 22, 2021
1 parent 3970b3f commit aa38f7a
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 8 deletions.
2 changes: 1 addition & 1 deletion example/rust/gl-glfw-mx/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ fn draw(window: &mut Window) {
window.source.make_current();
unsafe {
window.gl.ClearColor(0.7, 0.9, 0.1, 1.0);
window.gl.Clear(gl::GL_COLOR_BUFFER_BIT);
window.gl.Clear(gl::COLOR_BUFFER_BIT);
}
window.source.swap_buffers();
}
Expand Down
2 changes: 1 addition & 1 deletion example/rust/gl-glfw/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ fn main() {

unsafe {
gl::ClearColor(0.7, 0.9, 0.1, 1.0);
gl::Clear(gl::GL_COLOR_BUFFER_BIT);
gl::Clear(gl::COLOR_BUFFER_BIT);
}

window.swap_buffers();
Expand Down
2 changes: 1 addition & 1 deletion glad/generator/rust/templates/impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ pub mod enumerations {
use super::types::*;

{% for enum in feature_set.enums %}
pub const {{ enum.name }}: {{ enum|enum_type }} = {{ enum|enum_value }};
pub const {{ enum.name|no_prefix }}: {{ enum|enum_type }} = {{ enum|enum_value }};
{% endfor %}
}

Expand Down
8 changes: 4 additions & 4 deletions glad/generator/rust/templates/types/glx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,14 @@ pub struct GLXBufferClobberEventSGIX {
#[repr(C)]
#[derive(Copy, Clone)]
pub struct GLXHyperpipeNetworkSGIX {
pub pipeName: [std::os::raw::c_char; super::enumerations::GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX as usize],
pub pipeName: [std::os::raw::c_char; super::enumerations::HYPERPIPE_PIPE_NAME_LENGTH_SGIX as usize],
pub networkId: std::os::raw::c_int,
}

#[repr(C)]
#[derive(Copy, Clone)]
pub struct GLXHyperpipeConfigSGIX {
pub pipeName: [std::os::raw::c_char; super::enumerations::GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX as usize],
pub pipeName: [std::os::raw::c_char; super::enumerations::HYPERPIPE_PIPE_NAME_LENGTH_SGIX as usize],
pub channel: std::os::raw::c_int,
pub participationType: std::os::raw::c_uint,
pub timeSlice: std::os::raw::c_int,
Expand All @@ -115,7 +115,7 @@ pub struct GLXHyperpipeConfigSGIX {
#[repr(C)]
#[derive(Copy, Clone)]
pub struct GLXPipeRect {
pub pipeName: [std::os::raw::c_char; super::enumerations::GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX as usize],
pub pipeName: [std::os::raw::c_char; super::enumerations::HYPERPIPE_PIPE_NAME_LENGTH_SGIX as usize],
pub srcXOrigin: std::os::raw::c_int,
pub srcYOrigin: std::os::raw::c_int,
pub srcWidth: std::os::raw::c_int,
Expand All @@ -129,7 +129,7 @@ pub struct GLXPipeRect {
#[repr(C)]
#[derive(Copy, Clone)]
pub struct GLXPipeRectLimits {
pub pipeName: [std::os::raw::c_char; super::enumerations::GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX as usize],
pub pipeName: [std::os::raw::c_char; super::enumerations::HYPERPIPE_PIPE_NAME_LENGTH_SGIX as usize],
pub XOrigin: std::os::raw::c_int,
pub YOrigin: std::os::raw::c_int,
pub maxHeight: std::os::raw::c_int,
Expand Down
10 changes: 10 additions & 0 deletions test/rust/compile/gl/default/003/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[package]
name = "compile-gl-default-003"
version = "0.1.0"

[[bin]]
path = "test.rs"
name = "test"

[dependencies]
glad-gl = { path = "./glad-gl/" }
16 changes: 16 additions & 0 deletions test/rust/compile/gl/default/003/test.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#![deny(warnings)]
/**
* Enums / Constants should not be prefixed.
*
* GLAD: $GLAD --out-path=$tmp --api="gl:core=" rust
* COMPILE: cp -r $test_dir/. $tmp && cd $tmp && cargo build
* RUN: cargo run
*/
extern crate glad_gl;
use glad_gl::gl;

#[allow(path_statements)]
fn main() {
gl::_1PASS_EXT;
gl::ALPHA;
}
2 changes: 1 addition & 1 deletion test/rust/run/gl/default/001/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ fn main() {
unsafe {
gl::Viewport(0, 0, 300, 300);
gl::ClearColor(0.7, 0.9, 0.1, 1.0);
gl::Clear(gl::GL_COLOR_BUFFER_BIT);
gl::Clear(gl::COLOR_BUFFER_BIT);
}

window.swap_buffers();
Expand Down

0 comments on commit aa38f7a

Please sign in to comment.