Results 1 to 2 of 2

Thread: how to access a struct?

  1. #1

    Default how to access a struct?

    I have defined a struct in my shader declaration:

    Code:
    declare shader
    	color	"colTest" (
    		array struct "colStruct" {
    			color	"color"
    		}
    	)
    	version 1
    	apply material
    end declare
    In my shder I try to access it with the usual array approach:


    str
    Code:
    uct colStruct{
    	miColor color;
    };
    
    struct colTest_p{
    
    	int		i_color;
    	int		n_color;	
    	miTag	col[1];	
    
    };
    
    
    miBoolean colTest(
    	miColor                *result,
    	miState                 *state,
    	colTest_p   *paras)
    {
    	int n_color   = *mi_eval_integer(&paras->n_color);
    	int i_color   = *mi_eval_integer(&paras->i_color);
    	miTag *colTag  =  mi_eval_tag(paras->col) + i_color;
    
    	int n;
    	for &#40;n=0; n < n_color; n++, colTag++&#41; 
    	&#123;
    		mi_info&#40;"ColTagP %d colTag %d", colTag, *colTag&#41;;
    		if&#40;*colTag&#41;
    		&#123;
    			colStruct *colS = &#40;colStruct *&#41; mi_db_access&#40; *colTag &#41;;
    			mi_db_unpin&#40;*colTag&#41;;
    			
    			mi_info&#40;" colS %f ", colS->color&#46;r &#41;;
    		&#125;
    	&#125;
    	return miTRUE;
    &#125;
    ----------------

    Unfortunalty it doesnt work.
    It seems that the pointer *colTag contains a null tag.

    Any tips?

  2. #2
    Join Date
    Oct 2006
    Posts
    26

    Default

    struct colStruct{
    miColor color;
    };

    struct colTest_p{

    int i_color;
    int n_color;
    struct colStruct col[1];
    };

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •