このコードは、2 つの正弦曲線を描く必要があります。ここでは、通常の 2 つの線がシェーダーを介して正弦波線に変換されます。それらの 1 つを回転させるタスクがあります (たとえば、45 度または 90 度)。どうすればよいですか?
void CMyApplication::OnDraw()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glUseProgramObjectARB(m_program);
glUniform1fARB(m_amplitudeUniformLocation, 0.3f);
glUniform1fARB(m_phaseUniformLocation, m_phase);
glUniform1fARB(m_frequencyUniformLocation, M_PI);
glUniform1fARB(m_colourUniformLocation, 0.0f);
//glUniform1fARB(m_rotateUniformLocation, true);
//glLoadIdentity();
//glRotatef(90.0f, 0.0f, 0.0f, 0.0f);
glBegin(GL_LINE_STRIP);
{
for (float x = -1; x <= 1.05; x += 0.01)
{
glVertex3f(x, 0, 0);
glColor3f(0, 0.5, -0.8);
}
}
glEnd();
//glLoadIdentity();
//glRotatef(-90.0f, 0.0f, 0.0f, 0.0f);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glUniform1fARB(m_phaseUniformLocation, m_phase - 0.5);
glUniform1fARB(m_colourUniformLocation, 0.5f);
//glUniform1fARB(m_rotateUniformLocation, false);
glBegin(GL_LINE_STRIP);
{
for (float x = -1; x <= 1.05; x += 0.01)
{
glVertex3f(x, -0.5, 0);
glColor3f(0, -0.5, 0.8);
}
}
glEnd();
__glewMatrixRotatefEXT(GL_MODELVIEW, 45, 0, 0, 1); //THIS STRING HAS BEEN RESOLVED //MY PROBLEM
glUseProgramObjectARB(NULL);
glutSwapBuffers();
}
以下のシェーダー:
uniform float phase;
uniform float amplitude;
uniform float frequency;
void main()
{
vec4 v = gl_Vertex;
v.y += amplitude * sin(frequency * v.x + phase);
gl_Position = gl_ModelViewProjectionMatrix * v;
gl_FrontColor = gl_Color;
}