Jump to content
  • Advertisement
Sign in to follow this  
ade-the-heat

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

This topic is 4072 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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]

Share this post


Link to post
Share on other sites
Advertisement
and the problem is?

try setting the frag colour to a literal float to make sure it's not your uniform code?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!