Game Development Reference
In-Depth Information
some axis and plot a particular graph. You don't need to create a new project.
You can just add this state to your existing code and then set it as the default
state.
class WaveformGraphState : IGameObject
{
double _xPosition = -100;
double _yPosition = -100;
double _xLength = 200;
double _yLength = 200;
double _sampleSize = 100;
double _frequency = 2;
public delegate double WaveFunction(double value);
public WaveformGraphState()
{
Gl.glLineWidth(3);
Gl.glDisable(Gl.GL_TEXTURE_2D);
}
public void DrawAxis()
{
Gl.glColor3f(1, 1, 1);
Gl.glBegin(Gl.GL_LINES);
{
// X axis
Gl.glVertex2d(_xPosition, _yPosition);
Gl.glVertex2d(_xPosition + _xLength, _yPosition);
// Y axis
Gl.glVertex2d(_xPosition, _yPosition);
Gl.glVertex2d(_xPosition, _yPosition + _yLength);
}
Gl.glEnd();
}
public void DrawGraph(WaveFunction waveFunction, Color color)
{
double xIncrement = _xLength / _sampleSize;
double previousX = _xPosition;
double previousY = _yPosition + (0.5 * _yLength);
Search WWH ::




Custom Search