blender
September 25, 2004, 2:27am
1
I cant compile this program:
!!ARBvp1.0
PARAM mvp[4] = { state.matrix.mvp };
OUTPUT oPos = result.position;
DP4 oPos.x, mvp[0], vertex.position; # Compute position.
DP4 oPos.y, mvp[1], vertex.position;
DP4 oPos.z, mvp[2], vertex.position;
DP4 oPos.w, mvp[3], vertex.position;
MOV result.texcoord, vertex.texcoord;
MOV result.color, vertex.color;
END
Just to see if the thing even works… but it won’t pass with the following:
</font><blockquote><font size=“1” face=“Verdana, Arial”>code:</font><hr /><pre style=“font-size:x-small; font-family: monospace;”>glEnable(GL_VERTEX_PROGRAM_ARB);
glGenProgramsARB(1, &ID);
glBindProgramARB(GL_VERTEX_PROGRAM_ARB, ID);
glProgramStringARB(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
File.GetSize(), File.GetBuffer());
if( !glIsProgramARB(ID)
add this here instead of the !isProgramARB
it will give you the error.
err = (char*)glGetString(GL_PROGRAM_ERROR_STRING_ARB);
if (strcmp(err,"")!=0){
glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &i);
printf("ERROR gpuprog: %s (pos %d)
", err,i);
}
now to the program itself, you need to specify the vertex attribs before
and you also need to stick to what you define as output
so first you would define the attribs like
ATTRIB inPos = vertex.position;
ATTRIB inTex = vertex.texcoord;
ATTRIB inColor = vertex.color;
you also need to define all outputs
OUTPUT oPos = result.position;
OUTPUT oTex = result.texcoord;
OUTPUT oColor = result.color;
then in the code itself you will purely use the variables defined as attrib/param/output/temp/address
so instead of vertex.position you will use inPos
and instead of the result.texcoord / result.color
you use oTex and oColor
the variable names of course are up to you…
however you can not read from a output variable, and you cannot write to attrib or param.
hope that is somewhat correct
blender
September 25, 2004, 5:30am
3
Thanks CrazyButcher, it compiled now. Though I got an error with my basic fragment program:
!!ARBfp1.0
ATTRIB iTexcoord = fragment.texcoord;
ATTRIB iColor = fragment.color;
OUTPUT oColor = result.color;
TEMP temp;
TEX temp, iTexcoord, texture[0], 2D;
MUL oColor, temp, iColor;
END
It gives: line 11: invalid character
blender
September 25, 2004, 5:55am
4
Ok I think it wasn’t the shader, but i guess there shouldn’t be a terminating \0 at the end.
Now it works.