所以我有一个 Triangle 类,我想绘制我的三角形的实例,但由于某些原因,只绘制了一个,它背后的逻辑超出了我的范围。
我一直在环顾四周,但我发现的只是所有三角形都绘制在同一个文件上的示例。
这是三角形类:
 public class Triangle:IGameObject
 {
    Vector3 position;
    int speed;
    public Triangle(int speed, Vector3 vec) {
        this.speed = speed;
        position = new Vector3(vec);
    }
    public void Update() { }
    public void Render()
    {
        Gl.glPushMatrix();
        Gl.glRotated(speed*Time.deltaTime,speed*Time.deltaTime,speed*Time.deltaTime,speed*Time.deltaTime);
        Gl.glBegin(Gl.GL_TRIANGLE_STRIP);
            Gl.glColor3f(1.0f, 0.0f, 0.0f);
            Gl.glVertex3d(position.x, 0, 0);
            Gl.glColor3d(0.0, 1.0, 0.0);
            Gl.glVertex3d(position.y, 0, 0);
            Gl.glColor3d(0.0, 0.0, 1.0);
            Gl.glVertex3d(0, position.z, 0);
        Gl.glEnd();
        Gl.glPopMatrix();
    }
}
这是 Form.cs
public partial class Form1 : Form
{
    Triangle _trA = new Triangle(100, new Vector3(0.1f,-0.2f,0.2f));
    Triangle _trB = new Triangle(50, new Vector3(0.5f, 0.3f, -0.1f));
    public Form1()
    {
        InitializeComponent();
        _openGLControl.InitializeContexts();
        if (_fullscreen)
        {
            FormBorderStyle = FormBorderStyle.None;
            WindowState = FormWindowState.Maximized;
        }
        else {
            ClientSize = new Size(1280,720);
        }
    }
    void GameLoop()
    {
        Gl.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
        Gl.glClear(Gl.GL_COLOR_BUFFER_BIT);
        _trA.Render();
        _trB.Render();
        _openGLControl.Refresh();
    }
}
我想我已经看到我应该在将矩阵用于对象之后(或之前)清除矩阵,但无法弄清楚。
有任何想法吗?