Finally got past a number of bugs after re-thinking the names & arrangement of my wrapper api for opengl, vulkan etc (haven’t plugged in anything other than opengl yet, want to render models, scenes & physics 1st so that I know any issues that crop up with other APIs will be an issue with how I’m using them), aside from some window & canvas related bugs (probably a result of the re-think) I’m not getting the expected triangle on screen so before I attribute it down to poorly made shader code I’d like to check that the calls my api made were correct for the uniforms in question.
First the section of shader code that matters (included by shaders that need the uniforms):
#ifndef STATIC_H
#define STATIC_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 STATIC_UINT_NAMES "VtxCount", "FlatLine"
# define STATIC_UINT_TYPES VFXDATA_UINT, VFXDATA_UINT
# define STATIC_UINT_TAKES 1, 1
# define STATIC_UINT_COUNT (1+1)
uniform DINTS
{
ivec2s WinPoint;
ivec3s WinSpace;
} dint_uniforms;
# define STATIC_DINT_NAMES "WinPoint", "WinSpace"
# define STATIC_DINT_TYPES VFXDATA_IVEC2, VFXDATA_IVEC3
# define STATIC_DINT_TAKES 1, 1
# define STATIC_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 STATIC_FNUM_NAMES \
"WinScale", "RegScale", "RegPoint", "RegEmits", "RegTakes"
# define STATIC_FNUM_TYPES \
VFXDATA_FVEC3, VFXDATA_FVEC3, VFXDATA_FVEC3, VFXDATA_FVEC3, VFXDATA_FVEC3
# define STATIC_FNUM_TAKES 1, 1, 1, 1, 1
# define STATIC_FNUM_COUNT (3+3+3+3+3)
uniform DNUMS { double dunused; } dnum_uniforms;
# define STATIC_DNUM_NAMES "dunused"
# define STATIC_DNUM_TYPES VFXDATA_DNUM
# define STATIC_DNUM_TAKES 1
# define STATIC_DNUM_COUNT (1)
My output (cleaned out the paths since they’re irrelevant):
make test
...
cd ../../bin && ./tryextra._x86_64_linux_cc_debug.elf -D APP_DATA=../run
Attempting to open module './libvfxglfw._x86_64_linux_cc_debug.so'... Success!
Attempting to open module './libvfxgl._x86_64_linux_cc_debug.so'... Success!
Creating program 'flat'
~/.../opengl_vfxapp.c: 42: glCreateProgram();
Creating/seeking shader with path '../run/shaders/spec.glsl'...
~/.../opengl_shader.c: 86: glCreateShader( GL_VERTEX_SHADER );
~/.../opengl_shader.c: 97: glShaderSource( 2, 1, [0x56067e991a40], (nil) );
~/.../opengl_shader.c: 105: glCompileShader( 2 );
~/.../opengl_shader.c: 106: glGetShaderiv( 2, GL_COMPILE_STATUS, 0x7ffc86d0b428 );
~/.../opengl_vfxapp.c: 62: glAttachShader( 1, 2 );
Success
Creating/seeking shader with path '../run/shaders/frag.glsl'...
~/.../opengl_shader.c: 86: glCreateShader( GL_FRAGMENT_SHADER );
~/.../opengl_shader.c: 97: glShaderSource( 3, 1, [0x56067ef13710], (nil) );
~/.../opengl_shader.c: 105: glCompileShader( 3 );
~/.../opengl_shader.c: 106: glGetShaderiv( 3, GL_COMPILE_STATUS, 0x7ffc86d0b428 );
~/.../opengl_vfxapp.c: 62: glAttachShader( 1, 3 );
Success
Linking program...
~/.../opengl_vfxapp.c: 81: glLinkProgram( 1 );
~/.../opengl_vfxapp.c: 82: glGetProgramiv( 1, GL_LINK_STATUS, 0x7ffc86d0b5dc );
Success
Testing program...
~/.../opengl_vfxapp.c: 97: glValidateProgram( 1 );
~/.../opengl_vfxapp.c: 98: glGetProgramiv( 1, GL_VALIDATE_STATUS, 0x7ffc86d0b5dc );
Success
~/.../opengl_vfxapp.c: 145: glUseProgram( 1 );
~/.../opengl_vfxcfg.c: 23: glGenVertexArrays( 1, &ref );
=====================================[0] '(null)' vec4, name count = 1
~/.../opengl_vfxbuf.c: 27: glGenBuffers( 1, &ref );
~/.../opengl_vfxcfg.c: 6: glBindVertexArray( 1 );
~/.../opengl_vfxbuf.c: 94: glBindBuffer( GL_ARRAY_BUFFER, 1 );
~/.../opengl_vfxbuf.c: 97: glBufferData( GL_ARRAY_BUFFER, 112, 0x56067ef11c20, GL_STATIC_DRAW );
> [0][0] 'NulPoint' uint
~/.../opengl_vfxbuf.c: 27: glGenBuffers( 1, &ref );
~/.../opengl_vfxsym.c: 21: sym->loc = (GLint)glGetAttribLocation( 1, 'NulPoint' );
~/.../opengl_vfxcfg.c: 6: glBindVertexArray( 1 );
~/.../opengl_vfxbuf.c: 94: glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, 2 );
~/.../opengl_vfxbuf.c: 97: glBufferData( GL_ELEMENT_ARRAY_BUFFER, 28, 0x56067ef141e0, GL_STATIC_DRAW );
~/.../opengl_vfxcfg.c: 6: glBindVertexArray( 1 );
~/.../opengl_vfxbuf.c: 47: glBindBuffer( GL_ARRAY_BUFFER, 1 );
~/.../opengl_vfxsym.c: 114: glVertexAttribPointer( 0, 1, GL_UNSIGNED_INT, GL_FALSE, 4, (nil) );
=====================================[1] 'UINTS' uint, name count = 2
~/.../opengl_vfxbuf.c: 27: glGenBuffers( 1, &ref );
~/.../opengl_vfxcfg.c: 6: glBindVertexArray( 1 );
~/.../opengl_vfxbuf.c: 94: glBindBuffer( GL_UNIFORM_BUFFER, 3 );
~/.../opengl_vfxbuf.c: 97: glBufferData( GL_UNIFORM_BUFFER, 12, 0x56067eef55b0, GL_DYNAMIC_DRAW );
~/.../opengl_vfxsym.c: 29: sym->loc = (GLint)glGetUniformBlockIndex( 1, 'UINTS' );
~/.../opengl_vfxcfg.c: 6: glBindVertexArray( 1 );
~/.../opengl_vfxbuf.c: 47: glBindBuffer( GL_UNIFORM_BUFFER, 3 );
> [1][0] 'VtxCount' uint
~/.../opengl_vfxcfg.c: 6: glBindVertexArray( 1 );
~/.../opengl_vfxbuf.c: 47: glBindBuffer( GL_UNIFORM_BUFFER, 3 );
~/.../opengl_vfxsym.c: 174: glBufferSubData( GL_UNIFORM_BUFFER, 0, 4, (nil) );
> [1][1] 'FlatLine' uint
~/.../opengl_vfxcfg.c: 6: glBindVertexArray( 1 );
~/.../opengl_vfxbuf.c: 47: glBindBuffer( GL_UNIFORM_BUFFER, 3 );
~/.../opengl_vfxsym.c: 174: glBufferSubData( GL_UNIFORM_BUFFER, 4, 4, (nil) );
=====================================[2] 'DINTS' uint, name count = 2
~/.../opengl_vfxbuf.c: 27: glGenBuffers( 1, &ref );
~/.../opengl_vfxcfg.c: 6: glBindVertexArray( 1 );
~/.../opengl_vfxbuf.c: 94: glBindBuffer( GL_UNIFORM_BUFFER, 4 );
~/.../opengl_vfxbuf.c: 97: glBufferData( GL_UNIFORM_BUFFER, 24, 0x56067ef1ef20, GL_DYNAMIC_DRAW );
~/.../opengl_vfxsym.c: 29: sym->loc = (GLint)glGetUniformBlockIndex( 1, 'DINTS' );
~/.../opengl_vfxcfg.c: 6: glBindVertexArray( 1 );
~/.../opengl_vfxbuf.c: 47: glBindBuffer( GL_UNIFORM_BUFFER, 4 );
> [2][0] 'WinPoint' ivec2
~/.../opengl_vfxcfg.c: 6: glBindVertexArray( 1 );
~/.../opengl_vfxbuf.c: 47: glBindBuffer( GL_UNIFORM_BUFFER, 4 );
~/.../opengl_vfxsym.c: 174: glBufferSubData( GL_UNIFORM_BUFFER, 0, 8, (nil) );
> [2][1] 'WinSpace' ivec3
~/.../opengl_vfxcfg.c: 6: glBindVertexArray( 1 );
~/.../opengl_vfxbuf.c: 47: glBindBuffer( GL_UNIFORM_BUFFER, 4 );
~/.../opengl_vfxsym.c: 174: glBufferSubData( GL_UNIFORM_BUFFER, 4, 12, (nil) );
=====================================[3] 'FNUMS' uint, name count = 5
~/.../opengl_vfxbuf.c: 27: glGenBuffers( 1, &ref );
~/.../opengl_vfxcfg.c: 6: glBindVertexArray( 1 );
~/.../opengl_vfxbuf.c: 94: glBindBuffer( GL_UNIFORM_BUFFER, 5 );
~/.../opengl_vfxbuf.c: 97: glBufferData( GL_UNIFORM_BUFFER, 64, 0x56067ef0c5f0, GL_DYNAMIC_DRAW );
~/.../opengl_vfxsym.c: 29: sym->loc = (GLint)glGetUniformBlockIndex( 1, 'FNUMS' );
~/.../opengl_vfxcfg.c: 6: glBindVertexArray( 1 );
~/.../opengl_vfxbuf.c: 47: glBindBuffer( GL_UNIFORM_BUFFER, 5 );
> [3][0] 'WinScale' vec3
~/.../opengl_vfxcfg.c: 6: glBindVertexArray( 1 );
~/.../opengl_vfxbuf.c: 47: glBindBuffer( GL_UNIFORM_BUFFER, 5 );
~/.../opengl_vfxsym.c: 174: glBufferSubData( GL_UNIFORM_BUFFER, 0, 12, (nil) );
> [3][1] 'RegScale' vec3
~/.../opengl_vfxcfg.c: 6: glBindVertexArray( 1 );
~/.../opengl_vfxbuf.c: 47: glBindBuffer( GL_UNIFORM_BUFFER, 5 );
~/.../opengl_vfxsym.c: 174: glBufferSubData( GL_UNIFORM_BUFFER, 4, 12, (nil) );
> [3][2] 'RegPoint' vec3
~/.../opengl_vfxcfg.c: 6: glBindVertexArray( 1 );
~/.../opengl_vfxbuf.c: 47: glBindBuffer( GL_UNIFORM_BUFFER, 5 );
~/.../opengl_vfxsym.c: 174: glBufferSubData( GL_UNIFORM_BUFFER, 8, 12, (nil) );
> [3][3] 'RegEmits' vec3
~/.../opengl_vfxcfg.c: 6: glBindVertexArray( 1 );
~/.../opengl_vfxbuf.c: 47: glBindBuffer( GL_UNIFORM_BUFFER, 5 );
~/.../opengl_vfxsym.c: 174: glBufferSubData( GL_UNIFORM_BUFFER, 12, 12, (nil) );
> [3][4] 'RegTakes' vec3
~/.../opengl_vfxcfg.c: 6: glBindVertexArray( 1 );
~/.../opengl_vfxbuf.c: 47: glBindBuffer( GL_UNIFORM_BUFFER, 5 );
~/.../opengl_vfxsym.c: 174: glBufferSubData( GL_UNIFORM_BUFFER, 16, 12, (nil) );
=====================================[4] 'DNUMS' uint, name count = 1
~/.../opengl_vfxbuf.c: 27: glGenBuffers( 1, &ref );
~/.../opengl_vfxcfg.c: 6: glBindVertexArray( 1 );
~/.../opengl_vfxbuf.c: 94: glBindBuffer( GL_UNIFORM_BUFFER, 6 );
~/.../opengl_vfxbuf.c: 97: glBufferData( GL_UNIFORM_BUFFER, 8, 0x56067eef6140, GL_DYNAMIC_DRAW );
~/.../opengl_vfxsym.c: 29: sym->loc = (GLint)glGetUniformBlockIndex( 1, 'DNUMS' );
~/.../opengl_vfxcfg.c: 6: glBindVertexArray( 1 );
~/.../opengl_vfxbuf.c: 47: glBindBuffer( GL_UNIFORM_BUFFER, 6 );
> [4][0] 'dunused' double
~/.../opengl_vfxcfg.c: 6: glBindVertexArray( 1 );
~/.../opengl_vfxbuf.c: 47: glBindBuffer( GL_UNIFORM_BUFFER, 6 );
~/.../opengl_vfxsym.c: 174: glBufferSubData( GL_UNIFORM_BUFFER, 0, 8, (nil) );
===========Entering draw loop==========
~/.../opengl_vfxapp.c: 145: glUseProgram( 1 );
~/.../opengl_vfxcfg.c: 6: glBindVertexArray( 1 );
~/.../opengl_vfxbuf.c: 94: glBindBuffer( GL_UNIFORM_BUFFER, 6 );
~/.../opengl_vfxbuf.c: 97: glBufferData( GL_UNIFORM_BUFFER, 8, 0x56067eef6140, GL_DYNAMIC_DRAW );
~/.../opengl_vfxcfg.c: 6: glBindVertexArray( 1 );
~/.../opengl_vfxbuf.c: 94: glBindBuffer( GL_UNIFORM_BUFFER, 5 );
~/.../opengl_vfxbuf.c: 97: glBufferData( GL_UNIFORM_BUFFER, 64, 0x56067ef0c5f0, GL_DYNAMIC_DRAW );
~/.../opengl_vfxcfg.c: 6: glBindVertexArray( 1 );
~/.../opengl_vfxbuf.c: 94: glBindBuffer( GL_UNIFORM_BUFFER, 4 );
~/.../opengl_vfxbuf.c: 97: glBufferData( GL_UNIFORM_BUFFER, 24, 0x56067ef1ef20, GL_DYNAMIC_DRAW );
~/.../opengl_vfxcfg.c: 6: glBindVertexArray( 1 );
~/.../opengl_vfxbuf.c: 94: glBindBuffer( GL_UNIFORM_BUFFER, 3 );
~/.../opengl_vfxbuf.c: 97: glBufferData( GL_UNIFORM_BUFFER, 12, 0x56067eef55b0, GL_DYNAMIC_DRAW );
> Enabling VfxSym 'NulPoint'
~/.../opengl_vfxcfg.c: 6: glBindVertexArray( 1 );
~/.../opengl_vfxbuf.c: 47: glBindBuffer( GL_ARRAY_BUFFER, 1 );
~/.../opengl_vfxbuf.c: 66: glVertexArrayElementBuffer( 1, 2 );
~/.../opengl_vfxbuf.c: 120: glDrawElementsInstanced( GL_TRIANGLE_STRIP, 7, GL_UNSIGNED_INT, 0x56067ef141e0, 4 );
> Disabled VfxSym 'NulPoint'
-------------------------------
...
-------------------------------
~/.../opengl_vfxapp.c: 145: glUseProgram( 1 );
~/.../opengl_vfxcfg.c: 6: glBindVertexArray( 1 );
~/.../opengl_vfxbuf.c: 94: glBindBuffer( GL_UNIFORM_BUFFER, 6 );
~/.../opengl_vfxbuf.c: 97: glBufferData( GL_UNIFORM_BUFFER, 8, 0x56067eef6140, GL_DYNAMIC_DRAW );
~/.../opengl_vfxcfg.c: 6: glBindVertexArray( 1 );
~/.../opengl_vfxbuf.c: 94: glBindBuffer( GL_UNIFORM_BUFFER, 5 );
~/.../opengl_vfxbuf.c: 97: glBufferData( GL_UNIFORM_BUFFER, 64, 0x56067ef0c5f0, GL_DYNAMIC_DRAW );
~/.../opengl_vfxcfg.c: 6: glBindVertexArray( 1 );
~/.../opengl_vfxbuf.c: 94: glBindBuffer( GL_UNIFORM_BUFFER, 4 );
~/.../opengl_vfxbuf.c: 97: glBufferData( GL_UNIFORM_BUFFER, 24, 0x56067ef1ef20, GL_DYNAMIC_DRAW );
~/.../opengl_vfxcfg.c: 6: glBindVertexArray( 1 );
~/.../opengl_vfxbuf.c: 94: glBindBuffer( GL_UNIFORM_BUFFER, 3 );
~/.../opengl_vfxbuf.c: 97: glBufferData( GL_UNIFORM_BUFFER, 12, 0x56067eef55b0, GL_DYNAMIC_DRAW );
> Enabling VfxSym 'NulPoint'
~/.../opengl_vfxcfg.c: 6: glBindVertexArray( 1 );
~/.../opengl_vfxbuf.c: 47: glBindBuffer( GL_ARRAY_BUFFER, 1 );
~/.../opengl_vfxbuf.c: 66: glVertexArrayElementBuffer( 1, 2 );
~/.../opengl_vfxbuf.c: 120: glDrawElementsInstanced( GL_TRIANGLE_STRIP, 7, GL_UNSIGNED_INT, 0x56067ef141e0, 4 );
> Disabled VfxSym 'NulPoint'
-------------------------------
make: *** [../../gnu.mak:40: test] Killed
Compilation failed.
Edit: Noticed I had failed to correct some code that decided what to send and what to bind in the draw loop, corrected it and replaced the above output with the new output, still need someone to check over the calls