Hello, for the beginning you could try to draw a quad
with glBegin(GL_QUADS) and set the texture coordinates
Shader.SetUniform(1D Texture)
Shader.Enable()
glBegin(GL_QUADS);
glTexCoord2f(0.0f,0.0f); glVertex2f(0.0f,0.0f);
glTexCoord2f(1.0f,0.0f); glVertex2f(1.0f,0.0f);
glTexCoord2f(1.0f,1.0f); glVertex2f(1.0f,1.0f);
glTexCoord2f(0.0f,1.0f); glVertex2f(0.0f,1.0f);
glEnd();
Shader.End()
Actually you can not access a position in a fragment program. but you you have your texture coordinates in your fragment
program. So you can use them as a position.
So you can do some if in your shader.
for example
float4 fp(float2 texcoord: TEXCOORD0) : COLOR0
{
float4 color = float4(0.0f,0.0f,0.0f,1.0f);
if(texcoord.x > 0.2f && texcoord.x < 0.35f)
{
color = float4(1.0f,0.0f,0.0f,1.0f);
}
else if(texcoord.x >= 0.35f && texcoord < 0.5f
{
color = float4(1.0f,0.5f,0.0f,1.0f);
}
...
...
return color;
}
But you could also use a 1D Texture as lookup table in you shader. Then you can change the color values dynamicaly.
Create a 1D Texture and start from blue and go over to red, like in your amplitude and then in you shader do something like this.
float4 fp(uniform sampler1D lookup, float2 texcoord: TEXCOORD0, float) : COLOR0
{
float4 color = tex1D(lookup, texcoord.x);
return color;
}
In the shader above, the texoord are the texture coordinates from your quad. So when you change you amplitude values or range or whatever you only need to change the 1D texture upload it again to gpu emmory and set set the uniform value again.
hope that helped a bit
lobbel