diff --git a/src/graphics/framebuffer.nim b/src/graphics/framebuffer.nim index 79054e9..e564e13 100644 --- a/src/graphics/framebuffer.nim +++ b/src/graphics/framebuffer.nim @@ -340,4 +340,4 @@ proc newMainFramebuffer*(engine: MyouEngine): Framebuffer = result.engine = engine result.framebuffer = 0 result.is_complete = true - result.use_sRGB = true + result.use_sRGB = not engine.use_glsl_tone_mapping diff --git a/src/myou_engine.nim b/src/myou_engine.nim index 08c5565..8d67198 100644 --- a/src/myou_engine.nim +++ b/src/myou_engine.nim @@ -64,6 +64,7 @@ proc newMyouEngine*( opengl_version = default_gl_version, opengl_es = default_gl_es, glsl_version = "", + use_glsl_tone_mapping = true, ): MyouEngine proc get_builtin_shader_library*(use_cubemap_prefiltering = true): string proc get_builtin_shader_textures*(): Table[string, Texture] @@ -87,6 +88,7 @@ proc newMyouEngine*( opengl_version = default_gl_version, opengl_es = default_gl_es, glsl_version = "", + use_glsl_tone_mapping = true, ): MyouEngine = ## Creates a Myou Engine instance. You need to call this before you can use ## the engine. You also need to call `run <#run,MyouEngine>`_ at the end of @@ -103,6 +105,10 @@ proc newMyouEngine*( # to override it with per-camera exposure settings if opengl_es: assert opengl_version >= 300, "Minimum supported OpenGL ES version is 3.0" + else: + assert opengl_version >= 330, "Minimum supported OpenGL version is 3.3" + + if opengl_es or use_glsl_tone_mapping: result.tone_mapping_library = dedent """ float linearrgb_to_srgb(float c){ if (c < 0.0031308) return (c < 0.0) ? 0.0 : c * 12.92; @@ -119,8 +125,8 @@ proc newMyouEngine*( #define MYOU_TONE_MAP(x) linearrgb_to_srgb(x) """ result.tone_mapping_function = "MYOU_TONE_MAP" + result.use_glsl_tone_mapping = true else: - assert opengl_version >= 330, "Minimum supported OpenGL version is 3.3" result.tone_mapping_library = "\n#define MYOU_TONE_MAP(x) x\n" echo "assigning renderer" diff --git a/src/types.nim b/src/types.nim index 2afc5e2..d0b9deb 100644 --- a/src/types.nim +++ b/src/types.nim @@ -81,9 +81,8 @@ type renderer*: RenderManager tone_mapping_library*: string tone_mapping_function*: string + use_glsl_tone_mapping*: bool loaders_by_ext*: Table[string, seq[proc(e: MyouEngine): Loader]] - # TODO: remove this and query it when screen is created - width*, height*: int glsl_version*: string all_framebuffers*: seq[Framebuffer] ## private