I am having a little trouble getting my values to output correctly. For some reason my output is all white regardless of the fragment shader code. If I do a readpixels I get (1.0, 1.0, 1.0, 1.0) for each pixel.
my fragment shader looks like this:
(I know it doesn’t do much but it’s only to see if it’s writing correctly.)
void shader(in float2 texCoord: TEXCOORD0,
out float4 color : COLOR)
{
color.r = 1.0f;
color.g = 0.0f;
color.b = 0.0f;
color.a = 0.0f;
}
Theoretically this output should be all red right? But for some reason it is white.
I am not getting any Cg errors or OpenGL errors. I have a valid context, profile, program, etc. My draw function looks like this:
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // clear screen and depth buffer
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
bool drawError(false), readError(false);
const unsigned char *cgExt;
cgExt = glGetString(GL_EXTENSIONS);
fprintf(stderr, "%s
", cgExt);
cgGLEnableProfile(fragmentProfile);
cgErrorCallback();
cgGLBindProgram(fragmentProgram);
cgErrorCallback();
cgGLEnableTextureParameter(baseTexture);
cgErrorCallback();
glPushMatrix();
//glColor3f(1.0, 0.0, 0.0);
glBegin(GL_QUADS);
glTexCoord2f(0, 0); glVertex2f(0, 0);
glTexCoord2f(float(size), 0); glVertex2f(float(size), 0);
glTexCoord2f(float(size), float(size)); glVertex2f(float(size), float(size));
glTexCoord2f(0, float(size)); glVertex2f(0, float(size));
glEnd();
glPopMatrix();
if(PrintGLerror())
drawError = true;
glReadPixels(0,0, size, size, GL_RGBA, GL_FLOAT, dataOut);
if(PrintGLerror())
readError = true;
cgGLDisableProfile(fragmentProfile);
cgGLDisableTextureParameter(baseTexture);
SwapBuffers(hDC);
if I uncomment the glColor3f and comment out fragment stuff I get correct rendering of a red quad. I have written fragment shaders successfully before and it’s hard for me to see the difference with what I have here and what has worked in the past.
Any help would be greatly appreciated.
thanks.