equal
deleted
inserted
replaced
624 return NULL; |
624 return NULL; |
625 |
625 |
626 MOJOSHADER_glProgram *retval = NULL; |
626 MOJOSHADER_glProgram *retval = NULL; |
627 const GLhandleARB program = ctx->glCreateProgramObject(); |
627 const GLhandleARB program = ctx->glCreateProgramObject(); |
628 int numregs = 0; |
628 int numregs = 0; |
629 int const_count = 0; |
629 int consts = 0; |
630 |
630 |
631 if (vshader != NULL) ctx->glAttachObject(program, vshader->handle); |
631 if (vshader != NULL) ctx->glAttachObject(program, vshader->handle); |
632 if (pshader != NULL) ctx->glAttachObject(program, pshader->handle); |
632 if (pshader != NULL) ctx->glAttachObject(program, pshader->handle); |
633 |
633 |
634 ctx->glLinkProgram(program); |
634 ctx->glLinkProgram(program); |
668 retval->fragment = pshader; |
668 retval->fragment = pshader; |
669 retval->refcount = 1; |
669 retval->refcount = 1; |
670 |
670 |
671 if (vshader != NULL) |
671 if (vshader != NULL) |
672 { |
672 { |
673 if (const_count < vshader->parseData->constant_count) |
673 if (consts < vshader->parseData->constant_count) |
674 const_count = vshader->parseData->constant_count; |
674 consts = vshader->parseData->constant_count; |
675 retval->attributes = (AttributeMap *) Malloc(sizeof (AttributeMap) * |
675 retval->attributes = (AttributeMap *) Malloc(sizeof (AttributeMap) * |
676 vshader->parseData->attribute_count); |
676 vshader->parseData->attribute_count); |
677 if (retval->attributes == NULL) |
677 if (retval->attributes == NULL) |
678 goto link_program_fail; |
678 goto link_program_fail; |
679 |
679 |
683 vshader->refcount++; |
683 vshader->refcount++; |
684 } // if |
684 } // if |
685 |
685 |
686 if (pshader != NULL) |
686 if (pshader != NULL) |
687 { |
687 { |
688 if (const_count < pshader->parseData->constant_count) |
688 if (consts < pshader->parseData->constant_count) |
689 const_count = pshader->parseData->constant_count; |
689 consts = pshader->parseData->constant_count; |
690 |
690 |
691 lookup_uniforms(retval, pshader); |
691 lookup_uniforms(retval, pshader); |
692 lookup_samplers(retval, vshader); |
692 lookup_samplers(retval, vshader); |
693 pshader->refcount++; |
693 pshader->refcount++; |
694 } // if |
694 } // if |
695 |
695 |
696 if (const_count > 0) |
696 if (consts > 0) |
697 { |
697 { |
698 retval->constants = (GLfloat *) Malloc(sizeof (GLfloat) * const_count * 4); |
698 retval->constants = (GLfloat *) Malloc(sizeof (GLfloat) * consts * 4); |
699 if (retval->constants == NULL) |
699 if (retval->constants == NULL) |
700 goto link_program_fail; |
700 goto link_program_fail; |
701 retval->constant_count = (uint32) const_count; |
701 retval->constant_count = (uint32) consts; |
702 } // if |
702 } // if |
703 |
703 |
704 return retval; |
704 return retval; |
705 |
705 |
706 link_program_fail: |
706 link_program_fail: |