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 creating pure window context without GL init #56

Open
kvark opened this issue Apr 9, 2015 · 10 comments
Open

Allow creating pure window context without GL init #56

kvark opened this issue Apr 9, 2015 · 10 comments

Comments

@kvark
Copy link
Member

kvark commented Apr 9, 2015

When working with gfx_device_gl (maybe glium too?), the GL function pointers are initialized twice

  1. On window creation, using gl:: namespace
  2. On gfx_device_gl::create(), using the internal gl struct

These seem to be in conflict sometimes (PistonDevelopers/piston-examples#200), not to mention the amount of wasted work, which slows down the start time.

I do realize that it might be simpler to add another init method for gfx_device_gl, but that goes against the safety guarantees of gfx. Besides, that would require all the gfx_device_gl code to use the global gl:: instead of a struct.

Ideally, I'd like it to be a compile time flag for things that implement piston-window. Thus, gfx_cube example would compile glfw_window (or sdl2_window) in a "detached" state that doesn't touch OpenGL and only initializes GLFW (or SDL).

@Potpourri
Copy link
Member

Compile time flag sounds nice.

@Potpourri
Copy link
Member

I think we should remove GL init from window back-ends. It was added only for opengl_graphics back-end. Now GL init worth move to opengl_graphics, this will be correct.

@kvark
Copy link
Member Author

kvark commented Apr 9, 2015

Oh that would be great!

@bvssvni
Copy link
Member

bvssvni commented Apr 10, 2015

Alternative is to add a flag to WindowSettings of whether to initialize OpenGL or not.

@bvssvni
Copy link
Member

bvssvni commented Apr 10, 2015

@Potpourri Are you on IRC #rust-gamedev?

@bvssvni
Copy link
Member

bvssvni commented Apr 10, 2015

This discussion got mixed up a bit between two issues.

It seems that since Gfx uses a different library for gl, it makes sense with a Cargo feature like @kvark suggested.

@bvssvni
Copy link
Member

bvssvni commented Apr 10, 2015

Ideally I would like to make it explicit in code what is happening. Easier to debug problems.

@bvssvni
Copy link
Member

bvssvni commented Apr 10, 2015

I've tried overriding sdl2_window, removing the OpenGL initialization and measure the build time. No difference. On my machine, it takes a approximately 1 minute to build the gfx_cube example.

cargo clean
cargo build
real    1m6.963s
user    4m2.679s
sys 0m11.315s

@bvssvni
Copy link
Member

bvssvni commented Apr 10, 2015

So far I have not experienced any problems with running Gfx and OpenGL side by side, so this seems to be an issue with 3.1.

@bvssvni
Copy link
Member

bvssvni commented May 18, 2017

Todo list for window backends:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants