i want to get four value and I calculate each value in the fragment shader by using glVertex to pass the value to Shader, ande then i want to keep this value in a 2X2 texture.How?
i use fbo to bind a texture ,but it seems that i don’t get the correct texture i want. Why?
The texture Bind to FBO:
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, TEXTURE_WIDTH, TEXTURE_HEIGHT, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
////////////////////////////////////////////////////////////
glViewport(0, 0, TEXTURE_WIDTH, TEXTURE_HEIGHT);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(60.0f, 1, 1.0f, 100.0f);
glMatrixMode(GL_MODELVIEW);
BindShader()
BindFbo()
glBegin()
glVertex3f(…);
glVertex3f(…);
glVertex3f(…);
glVertex3f(…);
glEnd();
UnBindFbo();
UnBindShader();
/////////////////////////////////////////////
Fragment Shader:
void FragmentProgram (
out float4 color0 : COLOR0,
float3 N : TEXCOORD0
)
{
…
color0=float4(value I need , value I need , value I need , value I need);
}