diff --git a/src/Magnum/GL/AbstractShaderProgram.h b/src/Magnum/GL/AbstractShaderProgram.h index b6319cef8..4d18951b5 100644 --- a/src/Magnum/GL/AbstractShaderProgram.h +++ b/src/Magnum/GL/AbstractShaderProgram.h @@ -1458,7 +1458,8 @@ class MAGNUM_GL_EXPORT AbstractShaderProgram: public AbstractObject { /** * @brief Submit for linking * - * The attached shaders must be compiled with @ref Shader::compile() before linking. + * The attached shaders must be compiled with @ref Shader::compile() + * or @ref Shader::submitCompile() before linking. * * @see @fn_gl_keyword{LinkProgram} */ diff --git a/src/Magnum/Shaders/FlatGL.cpp b/src/Magnum/Shaders/FlatGL.cpp index 6fdfdbcd2..fdf5f3cb7 100644 --- a/src/Magnum/Shaders/FlatGL.cpp +++ b/src/Magnum/Shaders/FlatGL.cpp @@ -239,6 +239,8 @@ template typename FlatGL::CompileState FlatG template FlatGL::FlatGL(CompileState&& cs) : FlatGL{static_cast(std::move(cs))} { + if (_id == 0) return; + CORRADE_INTERNAL_ASSERT_OUTPUT(cs._vert.checkCompile()); CORRADE_INTERNAL_ASSERT_OUTPUT(cs._frag.checkCompile()); CORRADE_INTERNAL_ASSERT_OUTPUT(checkLink()); @@ -310,22 +312,6 @@ template FlatGL::FlatGL(CompileState&& cs) static_cast(context); } -template FlatGL::FlatGL(Flags flags - #ifndef MAGNUM_TARGET_GLES2 - , UnsignedInt materialCount, UnsignedInt drawCount - #endif -): - #ifndef MAGNUM_TARGET_GLES2 - FlatGL(compile(flags, materialCount, drawCount)) - #else - FlatGL{compile(flags)} - #endif -{} - -#ifndef MAGNUM_TARGET_GLES2 -template FlatGL::FlatGL(const Flags flags): FlatGL{flags, 1, 1} {} -#endif - template FlatGL& FlatGL::setTransformationProjectionMatrix(const MatrixTypeFor& matrix) { #ifndef MAGNUM_TARGET_GLES2 CORRADE_ASSERT(!(_flags >= Flag::UniformBuffers), diff --git a/src/Magnum/Shaders/FlatGL.h b/src/Magnum/Shaders/FlatGL.h index 55a14a461..6c6fe5d0e 100644 --- a/src/Magnum/Shaders/FlatGL.h +++ b/src/Magnum/Shaders/FlatGL.h @@ -550,7 +550,7 @@ template class MAGNUM_SHADERS_EXPORT FlatGL: public GL:: * @ref FlatGL(Flags, UnsignedInt, UnsignedInt) with @p materialCount * and @p drawCount set to @cpp 1 @ce. */ - explicit FlatGL(Flags flags = {}); + explicit FlatGL(Flags flags = {}) : FlatGL{compile(flags)} {} #ifndef MAGNUM_TARGET_GLES2 /** @@ -586,7 +586,8 @@ template class MAGNUM_SHADERS_EXPORT FlatGL: public GL:: for this might be too confusing); what if some parameters won't be (unsigned) integers? like a string with shader extensions? make a whole Configuration class? */ - explicit FlatGL(Flags flags, UnsignedInt materialCount, UnsignedInt drawCount); + explicit FlatGL(Flags flags, UnsignedInt materialCount, UnsignedInt drawCount): + FlatGL{compile(flags, materialCount, drawCount)} {} #endif /** @@ -613,6 +614,12 @@ template class MAGNUM_SHADERS_EXPORT FlatGL: public GL:: #endif ); + #ifndef MAGNUM_TARGET_GLES2 + static CompileState compile(Flags flags) { + return compile(flags, 1, 1); + } + #endif + /** @brief Copying is not allowed */ FlatGL(const FlatGL&) = delete; @@ -1053,13 +1060,10 @@ template class MAGNUM_SHADERS_EXPORT FlatGL: public GL:: }; template class FlatGL::CompileState : public FlatGL { -public: - using FlatGL::isLinkFinished; - private: friend class FlatGL; - CompileState(NoCreateT) : FlatGL(NoCreate), _vert{NoCreate}, _frag{NoCreate} {} + explicit CompileState(NoCreateT) : FlatGL{NoCreate}, _vert{NoCreate}, _frag{NoCreate} {} CompileState(FlatGL&& shader, GL::Shader&& vert, GL::Shader&& frag, GL::Version version) : FlatGL{std::move(shader)}, _vert{std::move(vert)}, _frag{std::move(frag)}, _version{version} {}