Thread: insertion bug

  1. #1
    Registered User awsdert's Avatar
    Join Date
    Jan 2015
    Posts
    1,565

    insertion bug

    I'll start with links for what this is connected to:

    Have a cross-language bug I need help with - OpenGL - Khronos Forums
    Files * 8bdff7736ba737a966e101401635d2d86ee0416d * Lee Shallis / Dragonbuilder * GitLab

    Next my output:
    Code:
    make debug=1 run (in directory: /mnt/MEDIA/HOME/gitlab/dragonbuilder/src/extra/viewfx)
    include ../makefile
    include ../../makefile
    include ../../../makefile
    cd ../../../ && make run --no-print-directory
    make -f gnu.mak run check=extra
    cc   -ggdb -D _DEBUG -Wall -Wextra -fPIC   -o src/extra/viewfx/vfxapp.c.o -c src/extra/viewfx/vfxapp.c
    cc  -ggdb -Wl,-rpath,. -fPIC -shared -o bin/libd-extra.so src/extra/viewfx/shader.c.o src/extra/viewfx/vfxapi.c.o src/extra/viewfx/vfxapp.c.o src/extra/viewfx/vfxbuf.c.o src/extra/viewfx/vfxcfg.c.o src/extra/viewfx/vfxdef.c.o src/extra/viewfx/vfxvar.c.o src/extra/viewfx/vfxwin.c.o  -l d-basic
    cc -fPIC -shared  -ggdb -Wl,-rpath,. -o bin/libd-vfxglfw.so src/extra/viewfx/glfw/glfw_api.c.o src/extra/viewfx/glfw/glfw_eio.c.o -l glfw -l GLEW
    cc -fPIC -shared  -o bin/libd-vfxgl.so src/extra/viewfx/gl/opengl_api.c.o src/extra/viewfx/gl/opengl_app.c.o src/extra/viewfx/gl/opengl_def.c.o src/extra/viewfx/gl/opengl_err.c.o src/extra/viewfx/gl/opengl_shader.c.o src/extra/viewfx/gl/opengl_vfxbuf.c.o src/extra/viewfx/gl/opengl_vfxcfg.c.o src/extra/viewfx/gl/opengl_vfxvar.c.o -l d-basic -l d-extra -l GLEW
    cc  -ggdb -Wl,-rpath,. -o bin/d-check_extra.elf test/extra/create.c.o test/extra/debug.c.o test/extra/events.c.o test/extra/launch.c.o test/extra/lib.c.o test/extra/main.c.o -l d-basic -l d-extra src/extra/viewfx/shader.c.o src/extra/viewfx/vfxapi.c.o src/extra/viewfx/vfxapp.c.o src/extra/viewfx/vfxbuf.c.o src/extra/viewfx/vfxcfg.c.o src/extra/viewfx/vfxdef.c.o src/extra/viewfx/vfxvar.c.o src/extra/viewfx/vfxwin.c.o  -l d-basic src/basic/branch.c.o src/basic/buffer.c.o src/basic/defect.c.o src/basic/encode.c.o src/basic/moment.c.o src/basic/pipefd.c.o src/basic/shared.c.o src/basic/thread.c.o src/basic/vector.c.o src/basic/string/achs.c.o src/basic/string/c16s.c.o src/basic/string/c32s.c.o src/basic/string/tchs.c.o src/basic/string/uchs.c.o src/basic/string/wchs.c.o -l pthread -l dl
    cd bin && ./d-check_extra.elf
    Attempting to open 'libd-vfxglfw.so' & 'libd-vfxgl.so'
    Creating program '[vfxapp.flat]'
    Bound shader 'shaders/null.glsl' as point shader
    Bound shader 'shaders/flat.glsl' as basic shader
    Bound shader 'shaders/frag.glsl' as color shader
    Linking program...
    src/extra/viewfx/vfxapp.c:624: Error 0xFFFFFFFF (-1) EUNKNOWN
    src/extra/viewfx/vfxapp.c:127: error: vertex shader lacks `main'
    src/extra/viewfx/vfxapp.c:137: In shader 'point', path = 'shaders/null.glsl'
    ```
    #version 440
    #extension GL_ARB_shading_language_include : require
    #line 1 "shaders/null.glsl"
    #line 0 "shaders/same.glsl"
    #ifndef SHARED_H
    #define SHARED_H
    #if defined(GL_core_profile) || \
    	defined(GL_compatibility_profile) || defined(GL_es_profile)
    #define IS_OPENGL
    /* 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
    #define uniform typedef struct
    #endif
    uniform UINTS { uint uunused; } uints;
    uniform DINTS
    {
    	int		FlatLine;
    	int		VtxCount;
    	ivec2s	WinPoint;
    	ivec3s	WinSpace;
    } dints;
    uniform FNUMS
    {
    	float	funused;
    	vec3s	WinScale;
    	vec3s	RegScale;
    	vec3s	RegPoint;
    	/* Light emitted */
    	vec3s	RegEmits;
    	/* Light taken before ray bounces */
    	vec3s	RegTakes;
    } fnums;
    uniform DNUMS { double dunused; } dnums;
    #ifndef IS_OPENGL
    #undef uniform
    #endif
    #endif
    ```
    test/extra/launch.c:22: Error 0xFFFFFFFF (-1) EUNKNOWN
    test/extra/main.c:108: Error 0xFFFFFFFF (-1) EUNKNOWN
    Compilation finished successfully.
    Next the specific function:
    Code:
    EXTRA_EXP dint makeShaderCode
    	( SRC *src, achs _path, VFXAPP *vfxapp, SHADER *shader, uint i )
    {
    	ACHS *Path = NULL, *Code = vfxapp->code, *Temp = vfxapp->temp;
    	dint err = readWholeTextFile( src, _path, Temp );
    	ach *code, *path, *text;
    	achs segs[] = { shader->code->array, "/", NULL, NULL };
    	uint t, j = 1, k, line = 0, count, stop;
    
    	if ( err )
    	{
    		PRINT_ERRNO( stdout, err );
    		return err;
    	}
    
    	code = Temp->array;
    	stop = Temp->count - 1;
    	k = (stop + !stop) - 1;
    	j = achsnlchn( code, Temp->count );
    	j += (j < k);
    	err = cramLineCommand( src, Temp, i ? 0 : j, _path, !i );
    	if ( err )
    	{
    		PRINT_ERRNO( stdout, err );
    		return err;
    	}
    
    	code = Temp->array;
    	stop = Temp->count;
    	k = (stop + !stop) - 1;
    	code = cramBeforeAchn( src, Code, i, code, k );
    	if ( !code )
    	{
    		err = ENOMEM;
    		PRINT_ERRNO( stdout, err );
    		return err;
    	}
    
    	stop += i;
    	count = Code->count;
    
    	err = makeAchs( src, &Path );
    	if ( err )
    	{
    		PRINT_ERRNO( stdout, err );
    		return err;
    	}
    
    	for ( i = 0; i < stop; i += j, ++line )
    	{
    		text = code + i;
    		k = Code->count - i;
    		j = achsnlchn( text, k );
    		j += (j < k);
    
    		if ( *text != '#' )
    			continue;
    
    		for ( k = 1; k < j; ++k )
    		{
    			text = code + i + k;
    			if ( !isspace(*text) )
    				break;
    		}
    
    		if ( achsfindn( text, j - k, "include", 7 ) == text )
    		{
    			for ( ; k < j; ++k )
    			{
    				text = code + i + k;
    				if ( *text == '"' )
    					break;
    			}
    
    			if ( *text != '"' )
    			{
    				err = EILSEQ;
    				PrintErrno( stdout, path, line, err );
    				break;
    			}
    
    			*text = ' ';
    			segs[2] = text + 1;
    
    			for ( ++k; k < j; ++k )
    			{
    				text = code + i + k;
    				if ( *text == '"' )
    					break;
    			}
    
    			if ( *text != '"' )
    			{
    				err = EILSEQ;
    				PrintErrno( stdout, _path, line, err );
    				break;
    			}
    
    			*text = 0;
    			termAchs( Path );
    			err = initAchsn( src, Path, "", 0 );
    
    			if ( err )
    			{
    				PRINT_ERRNO( stdout, err );
    				break;
    			}
    
    			path = Path->array;
    			for ( t = 0; segs[t]; ++t )
    			{
    				path = growAchsArray( src, Path, segs[t] );
    				if ( !path )
    				{
    					err = ENOMEM;
    					PRINT_ERRNO( stdout, err );
    					break;
    				}
    			}
    
    			if ( err )
    				break;
    
    			memset( code + i, ' ', j - 1 );
    			memmove( code + i, code + i + j, (count - i) - j );
    			count -= j;
    			stop -= j;
    			err = makeShaderCode( src, path, vfxapp, shader, i );
    			if ( err )
    			{
    				PRINT_ERRNO( stdout, err );
    				printf( "Failed to make shader code from path '%s'\n", path );
    				break;
    			}
    
    			code = Code->array;
    			k = Code->count - count;
    			count = Code->count;
    
    			termAchs( Temp );
    			initAchsn( src, Temp, "", 0 );
    			err = cramLineCommand( src, Temp, 0, path, line );
    			if ( err )
    			{
    				PRINT_ERRNO( stdout, err );
    				break;
    			}
    
    			t = Temp->count - 1;
    			code = cramBeforeAchn( src, Code, i + k, Temp->array, t );
    			if ( !code )
    			{
    				err = ENOMEM;
    				PRINT_ERRNO( stdout, err );
    				break;
    			}
    
    			stop += t + k;
    			j = t + k + (!t && !k);
    		}
    	}
    
    	voidAchs( src, &Path );
    	return err;
    }
    Somehow the code after an #include is being chopped off, need help getting it to not be so, currently lacking ideas on how identify the source problem, hoping maybe someone here will either spot the cause or at least potential causes that I've yet to spot.

  2. #2
    Registered User awsdert's Avatar
    Join Date
    Jan 2015
    Posts
    1,565
    Never mind, I somehow managed to fix it, can't pinpoint what the problem was though as I made many changes, if I remember rightly it ended up being just an offset being 1 too far near the start of the function

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Insertion Sort
    By ncode in forum C Programming
    Replies: 1
    Last Post: 02-28-2012, 06:37 AM
  2. Insertion sort
    By UserName112 in forum C++ Programming
    Replies: 2
    Last Post: 10-11-2011, 03:47 AM
  3. AVL tree insertion
    By nik in forum C++ Programming
    Replies: 0
    Last Post: 12-04-2010, 12:14 PM
  4. AVL Insertion tree
    By lordofdarkness in forum C Programming
    Replies: 0
    Last Post: 04-16-2009, 02:32 AM
  5. Insertion into a Random BST
    By BigDaddyDrew in forum C++ Programming
    Replies: 2
    Last Post: 04-05-2003, 05:21 PM

Tags for this Thread