UPDATED ! pls read again can't get the simplest shader working

Started by
2 comments, last by ade-the-heat 16 years, 11 months ago
I'm using texture rectangles and doing GPGPU (not that makes much difference). The shader I'm doing is so simple that I can't see why it's not working. All i want to do is to set each rgba value to a number I pass in. In this case = 2.0f. All I do is set viewport, enable shader, pass in param, draw quad, get back data

//SET UP VIEWPORT
glEnable(iTextureType);
glViewport(0, 0, itexSizeW, itexSizeH);
glMatrixMode(GL_PROJECTION);    
glLoadIdentity();               
gluOrtho2D(0.0, itexSizeW, 0.0, itexSizeH);
glMatrixMode(GL_MODELVIEW);     
glLoadIdentity(); 

//ENABLE SHADER
glUseProgram(m_shaders[shaderHandle].program);
//set uniforms
GLint location = fglGetUniformLocation(m_shaders[shaderHandle].program,"value");
fglUniform1f(location, 0.5f);
//DRAW A QUAD
// make quad filled to hit every pixel/texel
glPolygonMode(GL_FRONT,GL_FILL);
// and render quad
glBegin(GL_QUADS);
    glTexCoord2f(0.0, 0.0); 
    glVertex2f(0.0, 0.0);
    glTexCoord2f(itexSizeW, 0.0); 
    glVertex2f(itexSizeW, 0.0);
    glTexCoord2f(itexSizeW, itexSizeH); 
    glVertex2f(itexSizeW, itexSizeH);
    glTexCoord2f(0.0, itexSizeH); 
    glVertex2f(0.0, itexSizeH);
glEnd();

//GET DATA BACK
glBindTexture(iTextureType, mTextures[TEX_TMP2]);
float *textureData = (float*)malloc( ((int)mVoxelFaceCount*4)*sizeof(float) );
//copy frame
glCopyTexSubImage2D(iTextureType, 0, 0, 0, 0, 0, itexSizeW, itexSizeH);
glGetTexImage(iTextureType, 0, GL_RGBA, GL_FLOAT,  (void*)textureData );
CHECK_OPENGL_ERR;

float data;
for (unsigned int i=0; i<mVoxelFaceCount; i++)
{
     data=textureData;  //everything is junk !!!
}

free(textureData);
CHECK_OPENGL_ERR;



The shade itself is just:

uniform float value;
void main (void)
{
	gl_FragColor = vec4(value);
}




[Edited by - ade-the-heat on May 23, 2007 7:20:20 AM]
Advertisement
I've rewritten the whole msg now. This has got to be easy for someone who knows the answer. cheers
and the problem is?

try setting the frag colour to a literal float to make sure it's not your uniform code?
[size="1"]
I'm getting junk out. Tried what you said and still got junk back.

This topic is closed to new replies.

Advertisement