a very simple shader, but it dosent work!!

Hi all,
could anyone please tell me whats wrong with the following:
//the shader code

PARAM mvp[4] = { state.matrix.mvp };
ATTRIB pos = vertex.position;

OUTPUT oPos = result.position;

DP4 oPos.x, pos, mvp[0];
DP4 oPos.y, pos, mvp[1];
DP4 oPos.z, pos, mvp[2];
DP4 oPos.w, pos, mvp[3];

//in main

glVertex3f(0, 0, -20.0f);
glVertex3f(5,0, -20.0f);
glVertex3f(5,5, -20.0f);
glVertex3f(0,5, -20.0f);

nothing appears on the screen. If i dont enable the shader code(by not calling glEnable(GL_VERTEX_PROGRAM_ARB)) it draws the rect fine.

also i did check for errors in the compilation of the shader(using GL_PROGRAM_ERROR_POSITION_ARB) and it didnt return any errors so i know that the shader is valid

does anyone know what im doing wrong? Finding resources on openGL shaders is tuff


Just out of curiosity, what’s your clear color? If you don’t write something to the color result registers, the results are undefined (they don’t “pass through” by default). It’s possible that undefined in your case means “black”, so you might try setting your clear color to something other than black and see if your quad shows up.

Alternatively, write something to the result color register. Adding this line should do it: MOV result.color, 1;

– Ben

Hi Ben

THNAKS ALOT man, thats exactly what it was!
i was clearing to black then i cleared to red and this little black rect appeared on the screen.
i guess i forgot that with shaders you have to do EVERYTHING yourself so glColor3f had no effect(d’oh)

anway thanks again ben

Just a general tip…

When doing research/experimental work never ever clear to black or white. Pick a random colour. It will save you hours of pointless debugging time.

Amen to that Henryj, can you believe id been trying to solve this for over a day