Questions tagged [glium]

Safe OpenGL wrapper for the Rust language

30 questions
21
votes
3 answers

How to import macros in Rust?

I'm struggling with how to import macros from an external crate. In my main.rs I'm importing the Glium crate: #![macro_use] extern crate glium; pub use glium::*; // where my actual main function will be done from mod part01drawtriangle; fn main()…
Adityo Pratomo
  • 253
  • 1
  • 2
  • 7
8
votes
1 answer

unconstrained type parameter error

I'm trying to interface glium with cgmath. Following this answer, I have implemented a ToArray trait to convert instances of cgmath::Matrix4 into a format usable by glium: pub trait ToArray { type Output; fn to_array(&self) ->…
Jmb
  • 18,893
  • 2
  • 28
  • 55
6
votes
1 answer

How can I use a cgmath::Matrix as a uniform parameter in glium?

I'm trying to integrate the cgmath library into my first experiments with glium, but I can't figure out how to pass my Matrix4 object to the draw() call. My uniforms object is defined thus: let uniforms = uniform! { matrix:…
JPNotADragon
  • 2,050
  • 2
  • 25
  • 31
5
votes
1 answer

Passing an arbitrarily sized object to a fragment shader using a UniformBuffer in Glium

My question came up while experimenting with a bunch of different techniques, none of which I have much experience with. Sadly, I don't even know whether I'm making a silly logic mistake, whether I'm using the glium crate wrong, whether I'm messing…
Thierry
  • 1,099
  • 9
  • 19
3
votes
0 answers

Is there any way to pass an array to a shader in glium?

I tried to do this with a uniform-block: Rust: #[derive(Copy, Clone)] struct Circle { position: (f32, f32), radius: u32, _padding: u32, } #[derive(Copy, Clone)] struct UniformBlock { map: [Circle;…
aitvann
  • 1,289
  • 2
  • 8
  • 10
3
votes
1 answer

Avoiding dropped frames in glium

I'm using glium as my opengl bindings, but it's impossible to get a reliable 60 FPS. A minimal testcase is #[macro_use] extern crate glium; extern crate clock_ticks; use glium::Surface; use glium::glutin; fn main() { use glium::DisplayBuild; …
Johannes Hoff
  • 3,731
  • 5
  • 31
  • 37
2
votes
1 answer

How to get the width and the height in glium?

I'm using glium in Rust. I want to get the width and the height. I can't write and understand English well, because I'm Japanese. Maybe my English has some problems so I'm sorry.
javaboy
  • 85
  • 7
2
votes
1 answer

How to draw OpenGL triangle from other thread in Rust

I'm learning OpenGL is Rust by this example: https://github.com/glium/glium/blob/84f82d3098fbc75aa22160b47bf0a2bdada01f07/examples/triangle.rs#L141 It uses a window wrapper called glutin, and draws the triangle once like this: let draw = move || { …
Guerlando OCs
  • 1,886
  • 9
  • 61
  • 150
1
vote
1 answer

How to light all faces of rotating cube using glium

I made rotating cube using glium, but only one face is colored. I am using Gouraud shading(from glium tutorial) for lighting. The cube is made by defined 24 vertices and 6 normals. Rotation is made by two matrices: let m = [ …
1
vote
2 answers

Vector of tuples with different size

I am currenly implementing marching cubes algorithm using Rust and I faced a problem. This algorithm requires using triangulation table which I copied from GitHub. But which data structure in Rust allow us to store such a data? Those tuples mean…
1
vote
2 answers

How can I forcibly pass by value rust without deriving the Clone trait?

I'm new to rust and I'm trying to return a Window struct: pub struct Window<'a> { ev_loop: EventLoop<()>, window_builder: WindowBuilder, context_builder: ContextBuilder<'a, NotCurrent>, display: Display } from this function: pub fn…
NaniNoni
  • 155
  • 11
1
vote
1 answer

How to implement Glium's Backend for Android's SurfaceTexture (Render with Rust into SurfaceTexture)

Rust's glium lib is a nice OpenGL wrapper that facilitate slots of stuff. In order to implement a new backend for it, you must implement https://github.com/glium/glium/blob/cacb970c8ed2e45a6f98d12bd7fcc03748b0e122/src/backend/mod.rs#L36 I want to…
Guerlando OCs
  • 1,886
  • 9
  • 61
  • 150
1
vote
0 answers

how do i interpolate keyframes into vectors with structs in Rust?

I started studying Rust and the "Glium" crate to use OpenGL, in the process I was trying to do something I had done before in Python when I needed to animate an asset. In Python to animate an asset I loaded two frames of the same model in two…
Arthur Sally
  • 134
  • 1
  • 10
1
vote
0 answers

Why glium `Headless` can not render an image like normal window context?

I am working on an off-screen render program and I use crate glium to do this. I have followed the example of screenshot.rs and this example worked well. Then I made some change: The orignal code was fn main() { // building the display, ie. the…
DWCarrot
  • 31
  • 2
1
vote
2 answers

Is creating circles from triangles or drawing them with a fragment shader faster?

I use the language Rust and the Glium library. I want to display a large number of circles on the screen, but I can not decide how I'd better do it. There is an option to create circles from triangles, or I can draw them with a fragment shader,…
aitvann
  • 1,289
  • 2
  • 8
  • 10
1
2