gl: get version at runtime
This commit is contained in:
parent
cb8af115c7
commit
e64b2f3300
|
@ -4,7 +4,7 @@ use crate::framebuffer::{Framebuffer, GlImage, Viewport};
|
||||||
use crate::quad_render::DrawQuad;
|
use crate::quad_render::DrawQuad;
|
||||||
use crate::render_target::RenderTarget;
|
use crate::render_target::RenderTarget;
|
||||||
use crate::util;
|
use crate::util;
|
||||||
use crate::util::{InlineRingBuffer, Texture};
|
use crate::util::{gl_get_version, InlineRingBuffer, Texture};
|
||||||
use crate::error::{FilterChainError, Result};
|
use crate::error::{FilterChainError, Result};
|
||||||
|
|
||||||
use gl::types::{GLenum, GLint, GLsizei, GLsizeiptr, GLuint};
|
use gl::types::{GLenum, GLint, GLsizei, GLsizeiptr, GLuint};
|
||||||
|
@ -368,7 +368,7 @@ impl FilterChain {
|
||||||
// initialize passes
|
// initialize passes
|
||||||
for (index, (config, source, mut reflect)) in passes.into_iter().enumerate() {
|
for (index, (config, source, mut reflect)) in passes.into_iter().enumerate() {
|
||||||
let reflection = reflect.reflect(index, semantics)?;
|
let reflection = reflect.reflect(index, semantics)?;
|
||||||
let glsl = reflect.compile(GlVersion::V4_60)?;
|
let glsl = reflect.compile(gl_get_version())?;
|
||||||
|
|
||||||
let vertex_resources = glsl.context.compiler.vertex.get_shader_resources()?;
|
let vertex_resources = glsl.context.compiler.vertex.get_shader_resources()?;
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
use crate::framebuffer::GlImage;
|
use crate::framebuffer::GlImage;
|
||||||
use gl::types::{GLenum, GLuint};
|
use gl::types::{GLenum, GLuint};
|
||||||
use librashader_common::{FilterMode, Size, WrapMode};
|
use librashader_common::{FilterMode, Size, WrapMode};
|
||||||
|
use librashader_reflect::back::cross::GlVersion;
|
||||||
|
|
||||||
pub fn calc_miplevel(size: Size<u32>) -> u32 {
|
pub fn calc_miplevel(size: Size<u32>) -> u32 {
|
||||||
let mut size = std::cmp::max(size.width, size.height);
|
let mut size = std::cmp::max(size.width, size.height);
|
||||||
|
@ -87,3 +88,34 @@ pub unsafe fn gl_compile_shader(stage: GLenum, source: &str) -> GLuint {
|
||||||
}
|
}
|
||||||
shader
|
shader
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn gl_get_version() -> GlVersion {
|
||||||
|
let mut maj_ver = 0;
|
||||||
|
let mut min_ver = 0;
|
||||||
|
unsafe {
|
||||||
|
gl::GetIntegerv(gl::MAJOR_VERSION, &mut maj_ver);
|
||||||
|
gl::GetIntegerv(gl::MINOR_VERSION, &mut min_ver);
|
||||||
|
}
|
||||||
|
|
||||||
|
match maj_ver {
|
||||||
|
3 => match min_ver {
|
||||||
|
3 => GlVersion::V3_30,
|
||||||
|
2 => GlVersion::V1_50,
|
||||||
|
1 => GlVersion::V1_40,
|
||||||
|
0 => GlVersion::V1_30,
|
||||||
|
_ => GlVersion::V1_50,
|
||||||
|
}
|
||||||
|
4 => match min_ver {
|
||||||
|
6 => GlVersion::V4_60,
|
||||||
|
5 => GlVersion::V4_50,
|
||||||
|
4 => GlVersion::V4_40,
|
||||||
|
3 => GlVersion::V4_30,
|
||||||
|
2 => GlVersion::V4_20,
|
||||||
|
1 => GlVersion::V4_10,
|
||||||
|
0 => GlVersion::V4_00,
|
||||||
|
_ => GlVersion::V1_50
|
||||||
|
}
|
||||||
|
_ => GlVersion::V1_50
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in a new issue