Skip to content

Commit 7c1ca4e

Browse files
Added platform macros in GLSL shaders
1 parent 02632fd commit 7c1ca4e

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

Graphics/GraphicsEngineOpenGL/src/GLContextMacOS.mm

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,17 @@
3232

3333
static void glDrawArraysInstancedBaseInstance_stub(GLenum mode, GLint first, GLsizei count, GLsizei primcount, GLuint baseinstance)
3434
{
35-
LOG_ERROR_MESSAGE_ONCE("glDrawArraysInstancedBaseInstance is not supported on MacOS");
35+
LOG_ERROR_MESSAGE("glDrawArraysInstancedBaseInstance is not supported on MacOS");
3636
}
3737

3838
static void glDrawElementsInstancedBaseInstance_stub(GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount, GLuint baseinstance)
3939
{
40-
LOG_ERROR_MESSAGE_ONCE("glDrawElementsInstancedBaseInstance is not supported on MacOS");
40+
LOG_ERROR_MESSAGE("glDrawElementsInstancedBaseInstance is not supported on MacOS");
4141
}
4242

4343
static void glDrawElementsInstancedBaseVertexBaseInstance_stub(GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount, GLint basevertex, GLuint baseinstance)
4444
{
45-
LOG_ERROR_MESSAGE_ONCE("glDrawElementsInstancedBaseVertexBaseInstance is not supported on MacOS");
45+
LOG_ERROR_MESSAGE("glDrawElementsInstancedBaseVertexBaseInstance is not supported on MacOS");
4646
}
4747

4848

Graphics/GraphicsEngineOpenGL/src/ShaderGLImpl.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,18 @@ ShaderGLImpl::ShaderGLImpl(IReferenceCounters *pRefCounters, RenderDeviceGLImpl
5252
"#version 430 core\n"
5353
"#define DESKTOP_GL 1\n"
5454
);
55+
# if PLATFORM_WIN32
56+
Settings.append("#define PLATFORM_WIN32 1\n");
57+
# elif PLATFORM_LINUX
58+
Settings.append("#define PLATFORM_LINUX 1\n");
59+
# else
60+
# error Unexpected platform
61+
# endif
5562
#elif PLATFORM_MACOS
5663
Settings.append(
5764
"#version 410 core\n"
5865
"#define DESKTOP_GL 1\n"
66+
"#define PLATFORM_MACOS 1\n"
5967
);
6068
#elif PLATFORM_IOS
6169
Settings.append(
@@ -65,6 +73,8 @@ ShaderGLImpl::ShaderGLImpl(IReferenceCounters *pRefCounters, RenderDeviceGLImpl
6573
"# define GL_ES 1\n"
6674
"#endif\n"
6775

76+
"#define PLATFORM_IOS 1\n"
77+
6878
"precision highp float;\n"
6979
"precision highp int;\n"
7080
//"precision highp uint;\n"
@@ -92,7 +102,7 @@ ShaderGLImpl::ShaderGLImpl(IReferenceCounters *pRefCounters, RenderDeviceGLImpl
92102
if(m_Desc.ShaderType == SHADER_TYPE_VERTEX)
93103
Settings.append("out vec4 gl_Position;\n");
94104

95-
#elif defined(ANDROID)
105+
#elif PLATFORM_ANDROID
96106
Settings.append(
97107
"#version 310 es\n"
98108
);
@@ -107,6 +117,8 @@ ShaderGLImpl::ShaderGLImpl(IReferenceCounters *pRefCounters, RenderDeviceGLImpl
107117
"#ifndef GL_ES\n"
108118
"# define GL_ES 1\n"
109119
"#endif\n"
120+
121+
"#define PLATFORM_ANDROID 1\n"
110122

111123
"precision highp float;\n"
112124
"precision highp int;\n"

0 commit comments

Comments
 (0)