Since opengl doesn't support include directives I've had to make my own handler to avoid duplicate shader code (which we all know is a recipe for disaster), somehow I messed up with the cramming into previous file's code part, haven't been able to spot the cause yet so in case someone wants to take a look here's the link to the code, input files and output:
src/libparse/c.c * b4e48aba30297202e2ee2949a84ba320ca9897aa * Lee Shallis / Dragonbuilder * GitLab
spec.glsl
Code:
#version 440
#include "same.glsl"
in vec4 NulPoint;
out VERTEX
{
vec4 DyeColor;
vec4 DyeTexel;
} set;
void main()
{
uint v = gl_InstanceID, c = uint_uniforms.VtxCount, stop = c - 1;
vec4 center = vec4( 0.0, 0.0, 0.0, 1.0 );
gl_Position =
vec4( square_vertices[v % 4], 1.0, 1.0 ) + vec4( NulPoint.xyz, 1.0 );
set.DyeColor = vec4(1.0,1.0,1.0,1.0);
set.DyeTexel = vec4(1.0,1.0,1.0,1.0);
}
same.glsl:
Code:
#ifndef SHARED_H
#define SHARED_H
# if defined(GL_SPIRV) || defined(GL_core_profile) || \
defined(GL_compatibility_profile) || defined(GL_es_profile)
# define IS_OPENGL
# endif
# if defined(IS_OPENGL) || defined(VULKAN)
/* Mappings to CGLM union names */
# define uvec2s uvec2
# define uvec3s uvec3
# define uvec4s uvec4
# define ivec2s ivec2
# define ivec3s ivec3
# define ivec4s ivec4
# define vec2s vec2
# define vec3s vec3
# define vec4s vec4
# define dvec2s dvec2
# define dvec3s dvec3
# define dvec4s dvec4
# else
# include <cglm/struct.h>
# include <cglm/cglm.h>
# include <cglm/call.h>
# define uniform typedef struct
# endif /* IS_OPENGL / VULKAN */
uniform UINTS { uint FlatLine; uint VtxCount; } uint_uniforms;
# define SHARED_UINT_NAMES "VtxCount", "FlatLine"
# define SHARED_UINT_TYPES VFXTYPE_UINT, VFXTYPE_UINT
# define SHARED_UINT_TAKES 1, 1
# define SHARED_UINT_COUNT (1+1)
uniform DINTS
{
ivec2s WinPoint;
ivec3s WinSpace;
} dint_uniforms;
# define SHARED_DINT_NAMES "WinPoint", "WinSpace"
# define SHARED_DINT_TYPES VFXTYPE_IVEC2, VFXTYPE_IVEC3
# define SHARED_DINT_TAKES 1, 1
# define SHARED_DINT_COUNT (2+3)
uniform FNUMS
{
vec3s WinScale;
vec3s RegScale;
vec3s RegPoint;
/* Light emitted */
vec3s RegEmits;
/* Light taken before ray bounces */
vec3s RegTakes;
} fnum_uniforms;
# define SHARED_FNUM_NAMES \
"WinScale", "RegScale", "RegPoint", "RegEmits", "RegTakes"
# define SHARED_FNUM_TYPES \
VFXTYPE_FVEC3, VFXTYPE_FVEC3, VFXTYPE_FVEC3, VFXTYPE_FVEC3, VFXTYPE_FVEC3
# define SHARED_FNUM_TAKES 1, 1, 1, 1, 1
# define SHARED_FNUM_COUNT (3+3+3+3+3)
uniform DNUMS { double dunused; } dnum_uniforms;
# define SHARED_DNUM_NAMES "dunused"
# define SHARED_DNUM_TYPES VFXTYPE_DNUM
# define SHARED_DNUM_TAKES 1
# define SHARED_DNUM_COUNT (1)
# ifndef IS_OPENGL
# undef uniform
# else
const int INT_MAX = int( ~0u >> 1 );
const int INT_MIN = int(~(~0u >> 1));
const uint uqtr = ~0u / 4;
const uint uoct = ~0u / 8;
const double dcap = double(~0u);
const double dqtr = double(~0u / 4);
vec2 square_vertices[] =
{
{ 0.25, 0.25 },
{ 0.25, 0.75 },
{ 0.75, 0.25 },
{ 0.75, 0.75 }
};
vec4 edge_vertex( uint x, uint y )
{
vec4 point;
point.x = (float(double(x) / dqtr) * 2.0) - 1.0;
point.y = (float(double(y) / dqtr) * 2.0) - 1.0;
point.z = 1.0;
point.w = 1.0;
return point;
}
vec4 calc_point( uint v, uint vertices )
{
double aim = double(v);
double max = double(vertices);
uint rotate = uint((aim / max) * dcap);
uint linear = rotate % uqtr;
if ( uint_uniforms.FlatLine != 0 )
return edge_vertex( linear, uqtr - linear );
else
{
uint curved = linear + (linear / 3);
if ( linear < uoct )
return edge_vertex( curved, uqtr - linear );
else
return edge_vertex( linear, uqtr - curved );
}
}
# endif /* IS_OPENGL */
#endif /* SHARED_H */
The output:
Code:
make test
...
cd ../../bin && ./tryextra._x86_64_linux_cc_debug.elf -D APP_DATA=../run
Opened module '~/bin/libvfxglfw._x86_64_linux_cc_debug.so'
Opened module '~/bin/libvfxgl._x86_64_linux_cc_debug.so'
Creating program 'flat'
Generating path for 'spec.glsl'
Path begun as '../run/shaders'
Path ended as '../run/shaders/spec.glsl'
Generating shader 'point' with path '../run/shaders/spec.glsl':
Success
Bound '../run/shaders/spec.glsl' as point shader
Generating path for 'frag.glsl'
Path begun as '../run/shaders'
Path ended as '../run/shaders/frag.glsl'
Generating shader 'color' with path '../run/shaders/frag.glsl':
Success
Bound '../run/shaders/frag.glsl' as color shader
Linking program...
~/src/libextra/viewfx/../../../src/libextra/viewfx/vfxapp.c:499: Error 0xFFFFFFFF (-1) EUNKNOWN
~/src/libextra/viewfx/../../../src/libextra/viewfx/vfxapp.c:119: error: vertex shader lacks `main'
~/src/libextra/viewfx/../../../src/libextra/viewfx/vfxapp.c:133:
In '(null)' shader
../run/shaders/spec.glsl
```
#version 440
#extension GL_ARB_shading_language_include : require
#line 2 17
#line 1 19
#ifndef SHARED_H
#define SHARED_H
# if defined(GL_SPIRV) || defined(GL_core_profile) || \
defined(GL_compatibility_profile) || defined(GL_es_profile)
# define IS_OPENGL
# endif
# if defined(IS_OPENGL) || defined(VULKAN)
/* Mappings to CGLM union names */
# define uvec2s uvec2
# define uvec3s uvec3
# define uvec4s uvec4
# define ivec2s ivec2
# define ivec3s ivec3
# define ivec4s ivec4
# define vec2s vec2
# define vec3s vec3
# define vec4s vec4
# define dvec2s dvec2
# define dvec3s dvec3
# define dvec4s dvec4
# else
# include <cglm/struct.h>
# include <cglm/cglm.h>
# include <cglm/call.h>
# define uniform typedef struct
# endif /* IS_OPENGL / VULKAN */
uniform UINTS { uint FlatLine; uint VtxCount; } uint_uniforms;
# define SHARED_UINT_NAMES "VtxCount", "FlatLine"
# define SHARED_UINT_TYPES VFXTYPE_UINT, VFXTYPE_UINT
# define SHARED_UINT_TAKES 1, 1
# define SHARED_UINT_COUNT (1+1)
uniform DINTS
{
ivec2s WinPoint;
ivec3s WinSpace;
} dint_uniforms;
# define SHARED_DINT_NAMES "WinPoint", "WinSpace"
# define SHARED_DINT_TYPES VFXTYPE_IVEC2, VFXTYPE_IVEC3
# define SHARED_DINT_TAKES 1, 1
# define SHARED_DINT_COUNT (2+3)
uniform FNUMS
{
vec3s WinScale;
vec3s RegScale;
vec3s RegPoint;
/* Light emitted */
vec3s RegEmits;
/* Light taken before ray bounces */
vec3s RegTakes;
} fnum_uniforms;
# define SHARED_FNUM_NAMES \
"WinScale", "RegScale", "RegPoint", "RegEmits", "RegTakes"
# define SHARED_FNUM_TYPES \
VFXTYPE_FVEC3, VFXTYPE_FVEC3, VFXTYPE_FVEC3, VFXTYPE_FVEC3, VFXTYPE_FVEC3
# define SHARED_FNUM_TAKES 1, 1, 1, 1, 1
# define SHARED_FNUM_COUNT (3+3+3+3+3)
uniform DNUMS { double dunused; } dnum_uniforms;
# define SHARED_DNUM_NAMES "dunused"
# define SHARED_DNUM_TYPES VFXTYPE_DNUM
# define SHARED_DNUM_TAKES 1
# define SHARED_DNUM_COUNT (1)
# ifndef IS_OPENGL
# undef uniform
# else
const int INT_MAX = int( ~0u >> 1 );
const int INT_MIN = int(~(~0u >> 1));
const uint uqtr = ~0u / 4;
const uint uoct = ~0u / 8;
const double dcap = double(~0u);
const double dqtr = double(~0u / 4);
vec2 square_vertices[] =
{
{ 0.25, 0.25 },
{ 0.25, 0.75 },
{ 0.75, 0.25 },
{ 0.75, 0.75 }
};
vec4 edge_vertex( uint x, uint y )
{
vec4 point;
point.x = (float(double(x) / dqtr) * 2.0) - 1.0;
point.y = (float(double(y) / dqtr) * 2.0) - 1.0;
point.z = 1.0;
point.w = 1.0;
return point;
}
vec4 calc_point( uint v, uint vertices )
{
double aim = double(v);
double max = double(vertices);
uint rotate = uint((aim / max) * dcap);
uint linear = rotate % uqtr;
if ( uint_uniforms.FlatLine != 0 )
return edge_vertex( linear, uqtr - linear );
else
{
uint curved = linear + (linear / 3);
if ( linear < uoct )
return edge_vertex( curved, uqtr - linear );
else
return edge_vertex( linear, uqtr - curved );
}
}
# endif /* IS_OPENGL */
#endif /* SHARED_H */
```
source = GL_DEBUG_SOURCE_API, defect = GL_DEBUG_TYPE_ERROR, weight = GL_DEBUG_SEVERITY_HIGH, fromid = 1 (GL_ID_UNKOWN)
report = GL_INVALID_OPERATION in glUseProgram(program 1 not linked)
make: *** [../../gnu.mak:40: test] Interrupt
Compilation failed.
I need to do some shopping for food etc so I'll take a break, I'll look back here before I continue investigating