opengl_x11

Playing with OpenGL
git clone git://bsandro.tech/opengl_x11
Log | Files | Refs | README | LICENSE

commit 92208d06cfc5ff379ee948d6f88d9a48b64c9d18
parent 307762b2b5e5c7561a8bf7f43e23cd64b855ca54
Author: bsandro <email@bsandro.tech>
Date:   Sat, 25 Oct 2025 14:14:47 +0300

using gnu23 raw string literals for shaders

Diffstat:
Mshaders.c | 44++++++++++++++++++++++----------------------
Mtesselating.c | 20++++++++++----------
2 files changed, 32 insertions(+), 32 deletions(-)

diff --git a/shaders.c b/shaders.c @@ -30,28 +30,28 @@ static const double current_ts() { static double t_started; //@todo move shaders to separate files -static const GLchar *vertexSrc = " \n\ -#version 420 \n\ -in vec2 position; \n\ -in vec3 inColor; \n\ -out vec3 color; \n\ -void main() { \n\ - gl_Position = vec4(position, 0.0, 1.0); \n\ - color = inColor; \n\ -} \n\ -"; - -static const GLchar *fragmentSrc = " \n\ -#version 420 \n\ -uniform double iTime; \n\ -in vec3 color; \n\ -out vec4 outColor; \n\ -void main() { \n\ - float c1 = abs(sin(float(iTime))); \n\ - float c2 = abs(cos(float(iTime))); \n\ - outColor = vec4(color+c1-c2, 1.0); \n\ -} \n\ -"; +static const GLchar *vertexSrc = R"( +#version 420 +in vec2 position; +in vec3 inColor; +out vec3 color; +void main() { + gl_Position = vec4(position, 0.0, 1.0); + color = inColor; +} +)"; + +static const GLchar *fragmentSrc = R"( +#version 420 +uniform double iTime; +in vec3 color; +out vec4 outColor; +void main() { + float c1 = abs(sin(float(iTime))); + float c2 = abs(cos(float(iTime))); + outColor = vec4(color+c1-c2, 1.0); +} +)"; static GLuint mkShader(GLenum type, const GLchar *src) { GLuint shader = glCreateShader(type); diff --git a/tesselating.c b/tesselating.c @@ -60,16 +60,16 @@ static void tessCbCombine(GLdouble coords[3], GLdouble *data[4], GLfloat weight[ } //@todo move shaders to separate files -static const GLchar *vertexSrc = " \n\ -#version 420 \n\ -in vec2 position; \n\ -in vec3 inColor; \n\ -out vec3 color; \n\ -void main() { \n\ - gl_Position = vec4(position, 0.0, 1.0); \n\ - color = inColor; \n\ -} \n\ -"; +static const GLchar *vertexSrc = R"( +#version 420 +in vec2 position; +in vec3 inColor; +out vec3 color; +void main() { + gl_Position = vec4(position, 0.0, 1.0); + color = inColor; +} +)"; static const GLchar *fragmentSrc = " \n\ #version 420 \n\