PDA

View Full Version : FP related problem



vivek vyas
07-19-2009, 06:53 AM
i was try to begin with GL_FRAGMENT_PROGRAM_ARB but my code show black on screen but slow down the speed of processing
here some part of code i made

i declared a object which is
(i insist myself here something wrong)


GLfloat TriVert[] = {

0.0f,0.5f,0.0f,
-0.5f,0.0f,0.0f,
0.5f,0.0f,0.0f,


1.0f,0.0f,0.0f,
0.0f,1.0f,0.0f,
0.0f,0.0f,1.0f
},theta = 0.0f;

const char *thatsit = "\
!!ARBfp1.0\
PARAMS vert = {0.0f,0.5f,0.0f,\
-0.5f,0.0f,0.0f,\
0.5f,0.0f,0.0f,\
};\
MUL vert, TriVert\
END";

and display function


glVertexPointer(3,GL_FLOAT,NULL,0);
glColorPointer(3,GL_FLOAT,NULL,(int*)36);
glBindBufferARB(GL_ARRAY_BUFFER_ARB,Vertex);
/*NOTE program bind at rendring time*/
glBindProgramARB (GL_FRAGMENT_PROGRAM_ARB, nitspro);


glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_COLOR_ARRAY);

glDrawArrays(GL_TRIANGLES,0,3);
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_COLOR_ARRAY);
//Destroy it

glPopMatrix();


and when i know that i have extension


if(GLEW_ARB_fragment_program)
{
fprintf(stdout,"Lets do some Fragment program job\n");
glEnable(GL_FRAGMENT_PROGRAM_ARB);
glGenProgramsARB(2,&nitspro);
glBindProgramARB (GL_FRAGMENT_PROGRAM_ARB, nitspro);
glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, strlen(thatsit),
thatsit);
}
else fprintf(stdout,"Hardware not supporting the fragment program job so leave it ");


please help me regarding this

i read the specs of fragment_program.txt
and these of dot product textures attribute
please help me in these things
any link lecture on these DP3,HDP..,etc
(Here i want to say i am 17 years that mean i am really beginner to these type of programming(not C/C++)
so please reply)

thanks for just reading it and think on this Q
thanks in advance

Ilian Dinev
07-19-2009, 07:39 AM
Make cgc.exe generate ARB-asm code for you. The string in "thatsit" must not start with new-line. A shader program cannot access "TriVert". Multiplying 3x3 matrices cannot be done in one instruction. ARB-asm opcodes take at least 3 parameters: dest,src1,src2.
Write in GLSL, compile to arb-asm, view the asm code and line-by-line study each expression used there by looking at the specs.

glGenProgramsARB(2,&nitspro); // change 2 to 1


Quite an odd case, this kid.

vivek vyas
07-19-2009, 10:05 AM
thank u very much for reply
but i am using linux Distros (Suse 11)
and i have i915 with Mesa 7.4.4
so i cannot use GLSL(perhaps)
and alos i had BindBuffer(VBO) with 1 so can give problem

i had insalled Specs(fragment and vertex programs)
and just started reading it :D

Ilian Dinev
07-19-2009, 11:45 AM
No, download cgc.exe . That's in the nVidia Cg Toolkit. It's the only real compiler that produces ARB-asm.
You won't be sending that GLSL code to the gpu, but to the compiler.

vivek vyas
07-20-2009, 03:14 AM
Hey thanks and find that Cg toolkit also available for linux platform so i installed both Window and Linux toolkit and

now
as if i used toolkit to make GLSL ARB-asm opcodes so can i understand the meaning of these variable,parameters etc so that i can codes with my own hands also got in my mind that what results should come out from code
or
i not need to care the Cg do all for me