Coder Social home page Coder Social logo

opengl_graphics's Introduction

opengl_graphics Build Status Crates.io Crates.io

An OpenGL 2D back-end for the Piston game engine

Maintainers: @Potpourri, @bvssvni, @mitchmindtree

Important!

OpenGL needs to load function pointers before use. If you are experiencing strange error messages like "X not loaded" this is likely the case. This is done automatically for you in the SDL2 and GLFW window back-ends for Piston. To do this manually, see the README in gl-rs

Dependencies

dependencies

How to contribute

opengl_graphics's People

Contributors

0e4ef622 avatar 3c1u avatar abonander avatar bombless avatar bvssvni avatar coeuvre avatar danslocombe avatar ebfull avatar gifnksm avatar indiv0 avatar jakerr avatar jeffparsons avatar kjav avatar kvark avatar leonkunert avatar mitchmindtree avatar nulldatamap avatar otremblay avatar potpourri avatar qaqtutu avatar ryman avatar samestep avatar seeday avatar sphereflow avatar steveklabnik avatar tdaffin avatar tormol avatar tyoverby avatar zoomulator avatar zummenix avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

opengl_graphics's Issues

Revert default shaders to OpenGL 1.3

Having the default shaders require glsl 3.30 removes the ability for developers to use virtual machines (which is how I do all of my development).

Autodetect OpenGL and GLSL

By the current design, the window back-end is initialized before the OpenGL context, which means we need to know the OpenGL version before creating the context.

"No OpenGL support in video driver" but there is! (Ubuntu 14.04)

I'm trying to get the getting-started to run.

cargo build went right through without any errormessages or warnings, but trying cargo run or ./target/game I get the following:

thread '<main>' panicked at 'called `Result::unwrap()` on an `Err` value: "No OpenGL support in video driver"', /home/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libcore/result.rs:743

But OpenGL works for Steam and for many other games, also glxinfo | grep direct tells me that direct rendering: Yes and glxdemo, glxheads, and glxgears do work.

Just for completeness:

$ rustc --version
rustc 1.0.0-nightly (6c065fc8c 2015-02-17) (built 2015-02-18)

$ cargo --version
cargo 0.0.1-pre-nightly (918a415 2015-02-17) (built 2015-02-17)

$ uname --all
Linux nobbz-laptop 3.13.0-45-generic #74-Ubuntu SMP Tue Jan 13 19:36:28 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

$ glxinfo | head -5
name of display: :0
display: :0  screen: 0
direct rendering: Yes
server glx vendor string: SGI
server glx version string: 1.4

Please let me know if you need to know more details or if I need to re-report this behaviour somewhere else.

How to fix problem when function pointer is not loaded

OpenGL uses a function pointer loader system to enable the API for use in applications. This means you need to call gl::load_with(|s| window.get_proc_address(s)); or similar.

The SDL2 and GLFW back-ends for Piston loads the functions when initializing a new window. You are most likely getting this error because you attempt to call an OpenGL function before the window is created, or you are working directly against the back-end. It might also be the case that you are using another back-end where what is happening is uncertain. In any case, the problem is that the gl-rs library must load the function pointers before you can use it.

Try to initialize the window first, or load the function pointers manually.

For SDL2 you call:

// Load the OpenGL function pointers
gl::load_with(|s| unsafe {
    transmute(sdl2::video::gl_get_proc_address(s))
});

For GLFW you call:

// Load the OpenGL function pointers
gl::load_with(|s| window.get_proc_address(s));

Running an old version of OpenGL

It might be the case that you are loading an old version of OpenGL that does not support shaders. In that case, you can not use opengl_graphics because it requires GLSL shader support to work. You can fork opengl_graphics and modify the source to use the old fixed rendering pipeline. If there is a way to make this work with opengl_graphics, then contributions are welcome.

Setting the wrong version of OpenGL

If you pass a shader_version::OpenGL to the constructor, the window must be initialized with the same version, as seen here. The major and minor version must match the ones that is used to pick the compatible shader. Make sure that the same shader_version::OpenGL is passed to the window.

compile_shader: ERROR: 0:1: '' : version '120' is not supported

When trying to convert a working example from using opengl 3.2 to 1.2.0, I get this error immediately.

task '<main>' failed at 'compile_shader: ERROR: 0:1: '' :  version '120' is not supported
ERROR: 0:2: '' :  #version required and missing.
ERROR: 0:2: 'attribute' : syntax error syntax error
', src/gl_back_end.rs:168

My computer does in fact support 1.2.0, so I am guessing that the issue that I'm running into is the same as the one found here: http://gamedev.stackexchange.com/questions/22958/why-does-my-glsl-1-20-shader-not-work-with-an-opengl-4-0-driver

Cull face is wrong

gl::CullFace(gl::FRONT_AND_BACK); disables rendering for front and back when culling is enabled.

Instead, we should disable cull facing.

Investigate thread-safety of `GlyphCache`

  • Decide whether GlyphCache should be Send/Sync or NoSend/NoSync
    • Investigate thread safety/possible concurrency issues in FreeType
  • Implement SharedGlyphCache wrapping an Arc<RWLock<GlyphCache>> that implements CharacterCache
    • Benchmark concurrent access (with and without preload)

Wait for #100, #101

rustc 706be5ba1 nightly breakage

Today's rustc is causing below compiler errors (with e.g. cargo build);

$ rustc --version
rustc 1.0.0-nightly (706be5ba1 2015-02-05 23:14:28 +0000)
src/texture.rs:71:17: 71:49 error: mismatched types:
 expected `*const libc::types::common::c95::c_void`,
    found `*const libc::types::common::c95::c_void`
(expected enum `libc::types::common::c95::c_void`,
    found a different enum `libc::types::common::c95::c_void`) [E0308]
src/texture.rs:71                 pixels.as_ptr() as *const c_void
                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/texture.rs:116:17: 116:57 error: mismatched types:
 expected `*const libc::types::common::c95::c_void`,
    found `*const libc::types::common::c95::c_void`
(expected enum `libc::types::common::c95::c_void`,
    found a different enum `libc::types::common::c95::c_void`) [E0308]
src/texture.rs:116                 img.as_slice().as_ptr() as *const c_void
                                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/texture.rs:150:17: 150:57 error: mismatched types:
 expected `*const libc::types::common::c95::c_void`,
    found `*const libc::types::common::c95::c_void`
(expected enum `libc::types::common::c95::c_void`,
    found a different enum `libc::types::common::c95::c_void`) [E0308]
src/texture.rs:150                 img.as_slice().as_ptr() as *const c_void
                                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/texture.rs:172:17: 172:57 error: mismatched types:
 expected `*const libc::types::common::c95::c_void`,
    found `*const libc::types::common::c95::c_void`
(expected enum `libc::types::common::c95::c_void`,
    found a different enum `libc::types::common::c95::c_void`) [E0308]
src/texture.rs:172                 img.as_slice().as_ptr() as *const c_void
                                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
error: aborting due to 4 previous errors

I don't really see the error here, but maybe it's just bad/misleading error reporting.

`GlyphCache` improvements

  • Method to pre-load all characters for a given font size, perhaps preload(&mut self, &[char])
  • preload_printable_ascii(&mut self)
  • opt_character method that returns Option<&Character> and takes &self
  • Implement Clone (so it doesn't have to be reloaded from a file to get another copy, not sure how this would interact with the FFI parts)
  • Consider thread-safety when contained in a Mutex or RWLock; the latter would be great with preloading so cached characters can be fetched with a concurrent read lock (if that's safe)

Failing to read images from mtpaint: RGB(8) unsupported and eof

I tried to mimic the example code by loading an image:

gl.viewport(0, 0, args.width as i32, args.height as i32);

let c = Context::abs(args.width as f64, args.height as f64);
c.color([1.0, 1.0, 1.0, 1.0]).draw(&mut self.gl);

let image = Path::new("./bin/assets/unsupported.jpg");
let image = Texture::from_path(&image).unwrap();

c.image(&image).draw(&mut self.gl);

And I get

task '<main>' panicked at 'called `Result::unwrap()` on an `Err` value: Unsupported color type RGB(8)', /home/tree/code/rust/src/libcore/result.rs:743

With this as unsupported.jpg: unsupported

According to

c => return Err(format!("Unsupported color type {}", c)),
only RGBA(8) is supported, not RGB(8).

I also tried various formats/types of saves. Here's another error:

task '<main>' panicked at 'called `Result::unwrap()` on an `Err` value: Could not load 'eof.png': IoError(couldn't read file (end of file; path=bin/assets/eof.png))', /home/tree/code/rust/src/libcore/result.rs:743

Using this as eof.png: eof

I used mtpaint to generate the images. From what I can see the images look fine. If I use rust-log.png which came in piston-examples things work fine.

Mismatched Types: Expected `i32` but found `i64`

I'm trying to compile my project with opengl_graphics as a dependency in Cargo.toml, but cargo build fails with the following output:

Compiling opengl_graphics v0.0.0 (https://github.com/PistonDevelopers/opengl_graphics)
Could not execute process `rustc src/lib.rs --crate-type lib --out-dir /vagrant/target/deps -L /vagrant/target/deps -L /vagrant/target/deps` (status=101)
--- stderr
src/shader_utils.rs:110:13: 110:59 error: mismatched types: expected `i32` but found `i64` (expected i32 but found i64)
src/shader_utils.rs:110             data.len() as i64 * mem::size_of::<T>() as i64,
                                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
error: aborting due to previous error

Rename `Gl` to `G2D`

The only purpose Gl serves is as a graphics back-end, which might be confusing for people believing it exposes the entire OpenGL API.

Could use G2D like in the gfx_graphics back-end.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.