rust-windowing / glutin Goto Github PK
View Code? Open in Web Editor NEWA low-level library for OpenGL context creation, written in pure Rust.
License: Apache License 2.0
A low-level library for OpenGL context creation, written in pure Rust.
License: Apache License 2.0
Is this planned?
The code that selects the appropriate display mode looks wrong.
...preventing the user from resizing it
...which leads to the program continuing to run even when the main
function has finished.
Need to implement the resized, moved, closed and focused events.
GetMessage
and PeekMessage
must be called in the same o/s thread as the one where we called CreateWindow
.
For the moment, win32's Window
struct has a NoSend
marker, but this is only correct for native threads. In case of green threads, it is possible that a task switches from an o/s thread to another.
Allow creating a window from an existing window, so that both share the same GL objects.
This is especially important for switching between fullscreen and window.
Because of cocoa support, compiling glutin now requires calling a makefile. This is bad. Remove this requirement ASAP.
cc #4
WindowBuilder::visible
, Window::show
and Window::hide
Let's sum up everything related to multithreading.
GetMessage
in the same thread as the one where you create the window.XInitThreads
before any other xlib function, or the library is not thread-safe.GLFW and the SDL just assume that you do everything in the main thread. GLFW calls XInitThreads
but the SDL does not.
Needs more informations here
XInitThreads
is called behind a Once
(#65).See #2
WindowBuilder::visible
, Window::show
and Window::hide
Reading the list of monitors on X11 opens a Display
just for this. The API needs to be changed to prevent this from happening.
To reproduce, clone https://github.com/tomaka/glium/ and run cargo test
.
I don't know if it's some kind of race-condition, or just events not being processed correctly.
An easy fix but API breaking change.
I've started a new project under the Piston umbrella https://github.com/PistonDevelopers/ui
Do you want to work on a such project?
I checked out the gl-init-rs project and built the test suite with cargo test
. Any of the test applications such as window.exe start up and run, but do not show any output (only a black window). When the window is closed, a single frame briefly flashes on the window before it disappears.
The same applies to the gfx-rs triangle demo running with gl-init.
rustc 0.12.0-pre-nightly (c4a63fabe 2014-08-10 21:56:11 +0000)
gl-init-rs.git#87d62e5b6f38ab34586c0c9b5f41f1558e51cd1
Not really an issue as such, just rather spammy/verbose and Win32 and EGL don't do this.
I'm guessing it just needs suppressing? Windows uses GetProcaddress() if wglGetProcAddress() fails, so the equivalent is to use dlsym() I think, but should be unnecessary on X11. I can throw a pull request together for whichever if you want.
Currently we build everything, then put everything in a RAII struct.
However if an error happens during the building, the clean-up code is missing.
Return a proper enum instead of a String during window creation.
Waiting for the new errors RFC to be implemented.
On X11, the middle mouse button is Button2
. On Win32, it's Button3
.
Similarly, the right mouse button is Button3
on X11 and Button2
on Win32.
Either fail if not on the main thread, or redirect the creation to the main thread somehow. The second solution is preferred.
cc #4
Obviously it shouldn't, since it's "headless"
wait_events
and poll_events
should return permanent iterators, ie. iterators that can be reused later.
wait_events
should not block but instead return an iterator that blocks when next
is called.
Hi,
I'm using Linux (Fedora) on a virtual machine, so that might be why I get this error (checked on dual boot with another machine and it worked fine).
It seems that the errors are due to the settings of GLX_X_RENDERABLE and GLX_X_VISUAL_TYPE.
If I set them both to GLX_DONT_CARE (default values), I can run the test and open the window (i.e. ./target/test/window).
Obviously this solution is not optimal, as GLX_X_RENDERABLE should be set to true, so I didn't create a pull request for that.
I am attempting to compile and run a minimal program from the gfx-rs triangle example. I have modified the source to only use gl-init-rs and no glfw code. When running the output program, a window appears and the program immediately segfaults:
0x00007ffff77a5ae8 in XQueryExtension () from /usr/lib/x86_64-linux-gnu/libX11.so.6
I am using rustc 0.12.0-pre-nightly (c4a63fabe 2014-08-10 21:56:11 +0000)
. From my Cargo.lock I can see I am running against gl-init-rs.git#87d62e5b6f38ab34586c0c9b5f41f1558e51cd14
.
uname --all: Linux Luna 3.10.6-031006-generic #201308112316 SMP Mon Aug 12 03:17:33 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
.
And the full source code to reproduce the crash:
#![feature(phase)]
#![crate_name = "shiny"]
#[phase(plugin)]
extern crate gfx_macros;
extern crate getopts;
extern crate gfx;
extern crate glinit = "gl-init-rs";
extern crate gl_init_platform;
extern crate native;
#[vertex_format]
struct Vertex {
pos: [f32, ..2],
color: [f32, ..3],
}
static VERTEX_SRC: gfx::ShaderSource = shaders! {
GLSL_120: b"
#version 120
attribute vec2 pos;
attribute vec3 color;
varying vec4 v_Color;
void main() {
v_Color = vec4(color, 1.0);
gl_Position = vec4(pos, 0.0, 1.0);
}
"
GLSL_150: b"
#version 150 core
in vec2 pos;
in vec3 color;
out vec4 v_Color;
void main() {
v_Color = vec4(color, 1.0);
gl_Position = vec4(pos, 0.0, 1.0);
}
"
};
static FRAGMENT_SRC: gfx::ShaderSource = shaders! {
GLSL_120: b"
#version 120
varying vec4 v_Color;
void main() {
gl_FragColor = v_Color;
}
"
GLSL_150: b"
#version 150 core
in vec4 v_Color;
out vec4 o_Color;
void main() {
o_Color = v_Color;
}
"
};
// We need to run on the main thread for GLFW, so ensure we are using the `native` runtime. This is
// technically not needed, since this is the default, but it's not guaranteed.
#[start]
fn start(argc: int, argv: *const *const u8) -> int {
native::start(argc, argv, main)
}
fn main() {
let window = gl_init_platform::Window::new().unwrap();
window.set_title("[gl-init] Triangle example #gfx-rs!");
unsafe { window.make_current() };
let (w, h) = window.get_inner_size().unwrap();
let mut device = gfx::build()
.with_context(&window)
.with_provider(&window)
.with_queue_size(1)
.spawn(proc(r) render(r, w as u16, h as u16))
.unwrap();
'main: loop {
// quit when Esc is pressed.
for event in window.poll_events() {
match event {
glinit::Pressed(glinit::Escape) => break 'main,
glinit::Closed => break 'main,
_ => {},
}
}
device.update();
}
}
fn render(mut renderer: gfx::Renderer, width: u16, height: u16) {
let frame = gfx::Frame::new(width as u16, height as u16);
let state = gfx::DrawState::new();
let vertex_data = vec![
Vertex { pos: [ -0.5, -0.5 ], color: [1.0, 0.0, 0.0] },
Vertex { pos: [ 0.5, -0.5 ], color: [0.0, 1.0, 0.0] },
Vertex { pos: [ 0.0, 0.5 ], color: [0.0, 0.0, 1.0] }
];
let mesh = renderer.create_mesh(vertex_data);
let program = renderer.create_program(VERTEX_SRC.clone(), FRAGMENT_SRC.clone());
let clear = gfx::ClearData {
color: Some(gfx::Color([0.3, 0.3, 0.3, 1.0])),
depth: None,
stencil: None,
};
while !renderer.should_finish() {
renderer.clear(clear, frame);
renderer.draw(&mesh, mesh.get_slice(), &frame, &program, &state)
.unwrap();
renderer.end_frame();
for err in renderer.errors() {
println!("Renderer error: {}", err);
}
}
}
Maybe fixed by 5f1d8db
Relative mouse motion event, for use with FPS games.
For the moment, calls to wglMakeCurrent
, glXMakeCurrent
, etc. can silently fail.
The return type of make_current
should be a Result<(), MakeCurrentError>
.
Thanks to brendanzab/gl-rs#166 it's possible now
The x11, win32 and android ffis should be placed in separate repositories and added as dependencies.
As gl-init-rs
provides not only an OpenGL context, but also input, it could (should IMO) become the default Piston backend.
That being the case, I find the current name lacking.
I propose glutin-rs
(OpenGL, utilities and input), but I am looking forward to a proper bikeshed.
Many keys have poor names and no documentation
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.