I have the following code in file a.rs that is without a problem:
pub fn on_draw(&mut self, ren: &RenderArgs, window: &mut PistonWindow, event: &Event) {
let window_dimensions = ren.draw_size;
let width = window_dimensions[0];
let height = window_dimensions[1];
self.scx = (width / 2) as f64;
self.scy = (height / 2) as f64;
window.draw_2d(event, |context, graphics, _| {
clear([0.0, 0.0, 0.0, 1.0], graphics);
let center = context.transform.trans(self.scx, self.scy);
// THIS IS A FUNCTION CALL TO AN INSTANCE (board_display) OF A STRUCT
self.board_display.render(graphics, center);
});
}
but when I try to call "self.board_display.render(graphics, center);" above,
the following code gives me this error: from a different file b.rs
pub fn render(&self, g: &mut GfxGraphics<gfx_device_gl::Resources, gfx_device_gl::command::CommandBuffer>, view: math::Matrix2d) {
}
error[E0433]: failed to resolve: use of undeclared type or module `gfx_device_gl`
--> src/chessboard.rs:121:46
|
121 | pub fn render(&self, g: &mut GfxGraphics<gfx_device_gl::Resources, gfx_device_gl::command::CommandBuffer>, view: math::Matrix2d) {
| ^^^^^^^^^^^^^ use of undeclared type or module `gfx_device_gl`
error[E0433]: failed to resolve: use of undeclared type or module `gfx_device_gl`
--> src/chessboard.rs:121:72
|
121 | pub fn render(&self, g: &mut GfxGraphics<gfx_device_gl::Resources, gfx_device_gl::command::CommandBuffer>, view: math::Matrix2d) {
| ^^^^^^^^^^^^^ use of undeclared type or module `gfx_device_gl`
error[E0412]: cannot find type `GfxGraphics` in this scope
--> src/chessboard.rs:121:34
|
121 | pub fn render(&self, g: &mut GfxGraphics<Resources, CommandBuffer>, view: math::Matrix2d) {
| ^^^^^^^^^^^ help: a trait with a similar name exists: `Graphics`
|
::: /home/nexus/.cargo/registry/src/github.com-1ecc6299db9ec823/piston2d-graphics-0.36.0/./src/graphics.rs:35:1
|
35 | pub trait Graphics: Sized {
| ------------------------- similarly named trait `Graphics` defined here
error[E0412]: cannot find type `Resources` in this scope
--> src/chessboard.rs:121:46
|
43 | impl Chessboard {
| - help: you might be missing a type parameter: `<Resources>`
...
121 | pub fn render(&self, g: &mut GfxGraphics<Resources, CommandBuffer>, view: math::Matrix2d) {
| ^^^^^^^^^ not found in this scope
error[E0412]: cannot find type `CommandBuffer` in this scope
--> src/chessboard.rs:121:57
|
43 | impl Chessboard {
| - help: you might be missing a type parameter: `<CommandBuffer>`
...
121 | pub fn render(&self, g: &mut GfxGraphics<Resources, CommandBuffer>, view: math::Matrix2d) {
| ^^^^^^^^^^^^^ not found in this scope
But I look at the other file's "use" statements and they are identical.
In file a.rs the "graphics" parameter for
self.board_display.render(graphics, center);
is:
&mut GfxGraphics<Resources, CommandBuffer>
which breaks down to:
piston2d-gfx_graphics::back_end::GfxGraphics<gfx_device_gl::Resources,
gfx_device_gl::command::CommandBuffer
but when I add these specifics I get the above errors.
I'm stumped! Any suggestions?