Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow the create-context signal for GLArea to return null #720

Merged
merged 2 commits into from Oct 7, 2018

Conversation

Projects
None yet
3 participants
@ColonelThirtyTwo
Copy link
Contributor

ColonelThirtyTwo commented Oct 6, 2018

The signal should return None if creating the context fails. Optionally set
an error message with GLAreaExt::set_error.

Fixes #703

Allow the create-context signal for GLArea to return null
The signal should return None if creating the context fails. Optionally set
an error message with GLAreaExt::set_error.
@ColonelThirtyTwo

This comment has been minimized.

Copy link
Contributor Author

ColonelThirtyTwo commented Oct 6, 2018

Example program:

extern crate gtk;
extern crate gio;
extern crate gdk;

use std::env::args;
use gio::ApplicationExt;
use gio::ApplicationExtManual;
use gtk::prelude::*;

fn build_ui(application: &gtk::Application) {
	let window = gtk::ApplicationWindow::new(application);
	window.set_title("Test Window");
	window.set_border_width(10);
	window.set_position(gtk::WindowPosition::Center);
	window.set_default_size(350, 70);
	window.connect_delete_event(move |win, _| {
		win.destroy();
		Inhibit(false)
	});
	
	let glarea = gtk::GLArea::new();
	glarea.connect_create_context(|this| {
		this.set_error(Some(&gtk::Error::new(gdk::GLError::NotAvailable, "error happened")));
		None
	});
	window.add(&glarea);
	window.show_all();
}

fn main() {
	let application = gtk::Application::new("com.github.basic",
		gio::ApplicationFlags::empty())
		.expect("Initialization failed...");
	
	application.connect_startup(|app| {
		build_ui(app);
	});
	application.connect_activate(|_| {});
	application.run(&args().collect::<Vec<_>>());
}
@EPashkin

This comment has been minimized.

Copy link
Member

EPashkin commented Oct 6, 2018

Don't forget do make and add generated changes 😉

@EPashkin

This comment has been minimized.

Copy link
Member

EPashkin commented Oct 6, 2018

@ColonelThirtyTwo Thanks, now travis may pass.
Looks good for me.

@EPashkin

This comment has been minimized.

Copy link
Member

EPashkin commented Oct 6, 2018

@GuillaumeGomez 2 travis jobs failed due network, please. restart them.
👍 for merge when CI passed from me.

@GuillaumeGomez

This comment has been minimized.

Copy link
Member

GuillaumeGomez commented Oct 7, 2018

Looks good to me as well, thanks! (Waiting for restarted CIs.)

Also, can you add your example (with whitespaces instead of tabs) into the gtk-rs/examples repository please?

@EPashkin

This comment has been minimized.

Copy link
Member

EPashkin commented Oct 7, 2018

@GuillaumeGomez IMHO this example is useless, but if some drawing added instead, then that it be much better.

@GuillaumeGomez

This comment has been minimized.

Copy link
Member

GuillaumeGomez commented Oct 7, 2018

Well, we can always draw a triangle. :)

@GuillaumeGomez GuillaumeGomez merged commit 7b11383 into gtk-rs:master Oct 7, 2018

2 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@ColonelThirtyTwo

This comment has been minimized.

Copy link
Contributor Author

ColonelThirtyTwo commented Oct 7, 2018

An example would need an OpenGL crate to get the GL functions.

glium unfortunately doesn't work because the GLArea widget does some things with the OpenGL state behind the scenes that glium doesn't know about (mostly setting up a framebuffer for the draw call to render to).

@GuillaumeGomez

This comment has been minimized.

Copy link
Member

GuillaumeGomez commented Oct 7, 2018

Some C code is fine I assume...

vhdirk pushed a commit to vhdirk/gtk-rs that referenced this pull request Jan 16, 2019

Merge pull request gtk-rs#720 from ColonelThirtyTwo/glarea-create-con…
…text-returning-null

Allow the create-context signal for GLArea to return null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.