From 7c1ca4e7330fc9c3cf260af64ca8245145b057db Mon Sep 17 00:00:00 2001 From: Egor Yusov Date: Fri, 16 Feb 2018 20:03:37 -0800 Subject: Added platform macros in GLSL shaders --- Graphics/GraphicsEngineOpenGL/src/GLContextMacOS.mm | 6 +++--- Graphics/GraphicsEngineOpenGL/src/ShaderGLImpl.cpp | 14 +++++++++++++- 2 files changed, 16 insertions(+), 4 deletions(-) (limited to 'Graphics/GraphicsEngineOpenGL') diff --git a/Graphics/GraphicsEngineOpenGL/src/GLContextMacOS.mm b/Graphics/GraphicsEngineOpenGL/src/GLContextMacOS.mm index 65942afb..378d2d76 100644 --- a/Graphics/GraphicsEngineOpenGL/src/GLContextMacOS.mm +++ b/Graphics/GraphicsEngineOpenGL/src/GLContextMacOS.mm @@ -32,17 +32,17 @@ static void glDrawArraysInstancedBaseInstance_stub(GLenum mode, GLint first, GLsizei count, GLsizei primcount, GLuint baseinstance) { - LOG_ERROR_MESSAGE_ONCE("glDrawArraysInstancedBaseInstance is not supported on MacOS"); + LOG_ERROR_MESSAGE("glDrawArraysInstancedBaseInstance is not supported on MacOS"); } static void glDrawElementsInstancedBaseInstance_stub(GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount, GLuint baseinstance) { - LOG_ERROR_MESSAGE_ONCE("glDrawElementsInstancedBaseInstance is not supported on MacOS"); + LOG_ERROR_MESSAGE("glDrawElementsInstancedBaseInstance is not supported on MacOS"); } static void glDrawElementsInstancedBaseVertexBaseInstance_stub(GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount, GLint basevertex, GLuint baseinstance) { - LOG_ERROR_MESSAGE_ONCE("glDrawElementsInstancedBaseVertexBaseInstance is not supported on MacOS"); + LOG_ERROR_MESSAGE("glDrawElementsInstancedBaseVertexBaseInstance is not supported on MacOS"); } diff --git a/Graphics/GraphicsEngineOpenGL/src/ShaderGLImpl.cpp b/Graphics/GraphicsEngineOpenGL/src/ShaderGLImpl.cpp index cc980b83..bd659d15 100644 --- a/Graphics/GraphicsEngineOpenGL/src/ShaderGLImpl.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/ShaderGLImpl.cpp @@ -52,10 +52,18 @@ ShaderGLImpl::ShaderGLImpl(IReferenceCounters *pRefCounters, RenderDeviceGLImpl "#version 430 core\n" "#define DESKTOP_GL 1\n" ); +# if PLATFORM_WIN32 + Settings.append("#define PLATFORM_WIN32 1\n"); +# elif PLATFORM_LINUX + Settings.append("#define PLATFORM_LINUX 1\n"); +# else +# error Unexpected platform +# endif #elif PLATFORM_MACOS Settings.append( "#version 410 core\n" "#define DESKTOP_GL 1\n" + "#define PLATFORM_MACOS 1\n" ); #elif PLATFORM_IOS Settings.append( @@ -65,6 +73,8 @@ ShaderGLImpl::ShaderGLImpl(IReferenceCounters *pRefCounters, RenderDeviceGLImpl "# define GL_ES 1\n" "#endif\n" + "#define PLATFORM_IOS 1\n" + "precision highp float;\n" "precision highp int;\n" //"precision highp uint;\n" @@ -92,7 +102,7 @@ ShaderGLImpl::ShaderGLImpl(IReferenceCounters *pRefCounters, RenderDeviceGLImpl if(m_Desc.ShaderType == SHADER_TYPE_VERTEX) Settings.append("out vec4 gl_Position;\n"); -#elif defined(ANDROID) +#elif PLATFORM_ANDROID Settings.append( "#version 310 es\n" ); @@ -107,6 +117,8 @@ ShaderGLImpl::ShaderGLImpl(IReferenceCounters *pRefCounters, RenderDeviceGLImpl "#ifndef GL_ES\n" "# define GL_ES 1\n" "#endif\n" + + "#define PLATFORM_ANDROID 1\n" "precision highp float;\n" "precision highp int;\n" -- cgit v1.2.3