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

Add gl type detection function #104

Closed
sotaroikeda opened this issue Jan 20, 2017 · 1 comment
Closed

Add gl type detection function #104

sotaroikeda opened this issue Jan 20, 2017 · 1 comment

Comments

@sotaroikeda
Copy link
Contributor

sotaroikeda commented Jan 20, 2017

This issue is part of #99. To make runtime gl type selection works, we need to know current GL type is GL or GLES. It could help even when gl type is determined during build time. I assume the function and enum is like the following. Is it OK for gleam?

#[derive(Debug, PartialEq)]
pub enum GlType {
Gl,
Gles,
}

#[cfg(not(target_os="android"))]
pub fn gl_type() -> GlType {
GlType::Gl
}

#[cfg(target_os="android")]
pub fn gl_type() -> GlType {
GlType::Gles
}

More background info could be in https://bugzilla.mozilla.org/show_bug.cgi?id=1325911

@kvark
Copy link
Member

kvark commented Jan 20, 2017

I think we can get away with having the full GlType image that has a default() constructor (implementing Default feature), which defaults to the platform GL (like it does now, but in compile time).
So,

#[derive(Debug, PartialEq)]
pub enum GlType {
  Gl,
  Gles,
}

impl Default for GlType {
  #[cfg(target_os="android")]
  fn default() -> GlType {
    GlType::Gles
  }
  #[cfg(not(target_os="android"))]
  fn default() -> GlType {
    GlType::Gl
  }
}

bors-servo pushed a commit that referenced this issue Jan 27, 2017
Add gl::gl_type()

Fixes #104.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/gleam/105)
<!-- Reviewable:end -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants