OpenGL闪烁,并提取比C 更多的线路



我正在处理三角剖分应用程序,我可以在窗口中单击一个框架三角形内部以3个三角形等细分。因此,每次我添加一个点时,我都会在定义为类三角形的结构中添加两个三角形(请参见Triangle.h和.cpp(。对于每个对象三角形,我跟踪其ID,其3个顶点的索引以及其3个相邻三角形的索引,其中第一个顶点和第一个相邻三角形相反。

然后,我用GL_POINTSGL_LINE_LOOP绘制每个点和每个三角形。

如果我使用glClear(GL_COLOR_BUFFER_BIT),则行会闪烁。如果我不使用它,那就不会发生闪烁。

我的主要问题是三角形图是不一致的。当我单击三角形内部的新点时,应在此点和形成包含该点的三角形的3点之间绘制界限。有时会随之而来,有时会出现其他线条。我检查了我的结构,并且我的班级三角没有错误。我在添加的每个点和三角剖分的每个更新中单独验证了每个属性。

当我使用绘图函数时,我调用3次glVertex2i(x1, y1)正确绘制三角形。我不明白为什么可以同时绘制4-5行。它也不明白为什么有时会发生,有时不会发生。

我认为使用OpenGL存在冲突...就像我要进行计算并更新我的三角剖分结构,并且OpenGL会取得部分结果...带有glutPostRedisplay ...

的图纸

双重缓冲可以解决我的问题吗?有什么方法我可以设法称呼自己以进行图形的更新,而不是依靠glutPostRedisplayglutMainLoop以及此类内容。

/*-----------------------------------------
Name: main
Author: Michael Landry
Description: main program
Date: 2018-02-22
Version: 1.00
-------------------------------------------*/
#include <GL/glut.h>
#include <iostream>
#include <vector>
#include "functions.h"
#include "Point.h"
#include "Triangle.h"
GLfloat BLUE[3] = { 0,0,1 };
std::vector <Point> pointList;
std::vector <Triangle> triangleList;
int main(int argc, char **argv)
{
    // Give directions to user
    std::cout << "*** Welcome to the Delaunay Triangulation tool ***" << std::endl << std::endl;
    std::cout << "Left click to insert a point to the triangulation or right click to exit." << std::endl << std::endl;
    // Create the boundary triangle
    Frame();
    // Initialize GLUT display window
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
    glutInitWindowSize(SCREEN_WIDTH, SCREEN_HEIGHT);
    glutInitWindowPosition(0, 0);
    glutCreateWindow("Delaunay Triangulation");
    // Call the display function for drawing
    glutDisplayFunc(display);
    glutReshapeFunc(reshape);
    // Call the mouse callback function
    glutMouseFunc(mouse);
    glutIdleFunc(spindisplay);
    glutMainLoop();
    return 0;
}
/*-----------------------------------------
Name: functions
Author: Michael Landry
Description: functions for second lab
Date: 2018-02-22
Version: 1.00
-------------------------------------------*/
#ifndef FUNCTIONS_H_
#define FUNCTIONS_H_
#include "Point.h"
#include "Triangle.h"
const int SCREEN_WIDTH = 1366;
const int SCREEN_HEIGHT = 768;
void drawPoint(void);
void drawTriangle(void);
void display(void);
void reshape(int w, int h);
void spindisplay(void);
void mouse(int btn, int state, int x, int y);
void Frame(void);
bool inTriangle(const Point&);
void insert(const int);
int walk(const Point&);
#endif

/*-----------------------------------------
Name: functions
Author: Michael Landry
Description: functions for second lab
Date: 2018-02-22
Version: 1.00
-------------------------------------------*/
#include <GL/glut.h>
#include "Point.h"
#include "Triangle.h"
#include "functions.h"
#include <iostream>
#include <vector>
extern GLfloat BLUE[3];
extern std::vector <Point> pointList;
extern std::vector <Triangle> triangleList;
/*
Name: drawTriangle
Description: draw the triangulation
*/
void drawTriangle(void)
{
    glColor3fv(BLUE);
    glBegin(GL_LINE_LOOP);
    for (size_t i = 0; i < triangleList.size(); i++)
    {
        // Extract the coordinates of the first point of the triangle
        int x1 = pointList[triangleList[i].getS1() - 1].getX(); // -1 because the vector starts at 0
        int y1 = pointList[triangleList[i].getS1() - 1].getY();
        // Extract the coordinates of the second point of the triangle
        int x2 = pointList[triangleList[i].getS2() - 1].getX();
        int y2 = pointList[triangleList[i].getS2() - 1].getY();
        // Extract the coordinates of the third point of the triangle
        int x3 = pointList[triangleList[i].getS3() - 1].getX();
        int y3 = pointList[triangleList[i].getS3() - 1].getY();
        // Draw the triangle formed by the 3 points
        glVertex2i(x1, y1);
        glVertex2i(x2, y2);
        glVertex2i(x3, y3);
    }
    glEnd();
    glFlush();
}
/*
Name: drawPoint
Description: draw points in the window
*/
void drawPoint(void)
{
    glColor3fv(BLUE);
    glBegin(GL_POINTS);
    for (size_t i = 0; i < pointList.size(); i++)
    {
        // Extract the coordinates of the point
        int x = pointList[i].getX();
        int y = pointList[i].getY();
        // Draw the point
        glVertex2i(x, y);
    }
    glEnd();
    glFlush();
}
/*
Name: display
Description: prepare the window for display
*/
void display(void)
{
    glClearColor(0.0, 0.0, 0.0, 1.0);
    // glClear(GL_COLOR_BUFFER_BIT); // command is disabled to stop flickering
    glLoadIdentity();
    glPointSize(5);
    drawPoint();
    drawTriangle();
    glFlush();
}
/*
Name: reshape
Description: reshape the window
*/
void reshape(int w, int h)
{
    glViewport(0, 0, (GLsizei)w, (GLsizei)h);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrtho(0.0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, -1.0, 1.0);
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
}
/*
Name: spindisplay
Description: prepare for a redisplay
*/
void spindisplay(void)
{
    glutPostRedisplay();
}
/*
Name: mouse
Description: detect left button click on mouse
*/
void mouse(int btn, int state, int x, int y)
{
    if (btn == GLUT_LEFT_BUTTON && state == GLUT_DOWN)
    {
        // Generate a new object point with the cursor coordinates on click event
        Point newPoint(x, y, 1);
        // Verify if the point is inside the boundary triangle and if it does not already exists in the list
        if ((inTriangle(newPoint) == 1) && ((newPoint == pointList) == 0))
        {
            // Only add the point to the list if it is inside the boundary triangle
            pointList.push_back(newPoint);
            std::cout << "New point added" << std::endl;
            std::cout << "x : " << x << "   " << "y : " << y << std::endl;
            std::cout << "Total number of points : " << pointList.size() << std::endl << std::endl;
            // Find the triangle containing the new point
            int triangleIndex = walk(newPoint);
            std::cout << "Divide triangle number " << triangleIndex + 1 << std::endl << std::endl;
            // Insert the new point in the triangulation
            insert(triangleIndex);
            std::cout << "ID   S1   S2   S3   T1   T2   T3" << std::endl;
            for (size_t i = 0; i < triangleList.size(); i++)
            {
                std::cout << triangleList[i].getID() << "    " << triangleList[i].getS1() << "    " << triangleList[i].getS2() << "    " << triangleList[i].getS3() << "    " << triangleList[i].getT1() << "    " << triangleList[i].getT2() << "    " << triangleList[i].getT3() << "    " << std::endl;
            }
            std::cout << std::endl;
        }
        glutPostRedisplay();
    }
    if (btn == GLUT_RIGHT_BUTTON && state == GLUT_DOWN)
    {
        exit(1);   // Exit the program
    }
}
/*
Name: Frame
Description: create the initial boundary triangle
*/
void Frame(void)
{
    // First point
    Point myPoint1(SCREEN_WIDTH / 2, 100, 1);
    pointList.push_back(myPoint1);
    // Second point
    Point myPoint2(100, SCREEN_HEIGHT - 100, 1);
    pointList.push_back(myPoint2);
    // Third point
    Point myPoint3(SCREEN_WIDTH - 100, SCREEN_HEIGHT - 100, 1);
    pointList.push_back(myPoint3);
    // Create the first triangle of the list
    Triangle triangleFrame(1, 1, 2, 3, 0, 0, 0);
    triangleList.push_back(triangleFrame);
}
/*
Name: getDeterminant
Description: calculate the determinant of a 3 x 3 matrix
*/
int getDeterminant(const Point &point1, const Point &point2, const Point &point3)
{
    // Form a 5 x 3 matrix containing the 3 triangle points
    std::vector <Point> pointTriangle;
    pointTriangle.push_back(point1);
    pointTriangle.push_back(point2);
    pointTriangle.push_back(point3);
    pointTriangle.push_back(point1);
    pointTriangle.push_back(point2);
    // Calculate the determinant with the shoelace method
    int detTriangle = 0;
    int detTrianglePart;
    for (int j = 0; j < 3; j++)
    {
        detTrianglePart = ((pointTriangle[j].getX() * pointTriangle[j + 1].getY() * pointTriangle[j + 2].getZ()) - (pointTriangle[j + 2].getX() * pointTriangle[j + 1].getY() * pointTriangle[j].getZ()));
        detTriangle = detTriangle + detTrianglePart;
    }
    return detTriangle;
}
/*
Name: inTriangle
Description: test if a point is inside a triangle
*/
bool inTriangle(const Point& newPoint)
{
    // Pre loop conditions
    int k = 0; // counter
    int detTriangle = -1;
    int row = 3; // 3 points
    int col = 3; // 3 coordinates
    // Loop on all the points if the determinant stays negative
    while ((k < row) && (detTriangle < 0))
    {
        // Initialize an object the 3 points
        Point point1;
        Point point2;
        Point point3;
        // Extract 2 points from the list of points
        if (k == row - 1)
        {
            point1 = pointList[k];
            point2 = pointList[k - row + 1];
            point3 = newPoint;
        }
        else
        {
            point1 = pointList[k];
            point2 = pointList[k + 1];
            point3 = newPoint;
        }
        // Get the determinant of the triangle
        detTriangle = getDeterminant(point1, point2, point3);
        // Incrementation of the counter
        k++;
    }
    // Output the position of the point
    bool isInside = 0;
    (detTriangle < 0) ? (isInside = 1) : (isInside = 0);
    return isInside;
}
/*
Name: insert
Description: insert the new point and create 3 new triangles
*/
void insert(const int triangleIndex)
{
    // Extract the Index of the new point
    int newPointIndex = pointList.size();
    // Create the line of the second new triangle
    Triangle triangle2(triangleList.size() + 1, newPointIndex, triangleList[triangleIndex].getS3(), triangleList[triangleIndex].getS1(), triangleList[triangleIndex].getT2(), triangleList.size() + 2, triangleIndex + 1);
    // Create the line of the third new triangle
    Triangle triangle3(triangleList.size() + 2, newPointIndex, triangleList[triangleIndex].getS1(), triangleList[triangleIndex].getS2(), triangleList[triangleIndex].getT3(), triangleIndex + 1, triangleList.size() + 1);
    // Get the adjacent triangles of the base triangle
    int T1 = triangleList[triangleIndex].getT1();
    int T2 = triangleList[triangleIndex].getT2();
    int T3 = triangleList[triangleIndex].getT3();
    // Update the line of first new triangle
    triangleList[triangleIndex].setS1(newPointIndex);
    triangleList[triangleIndex].setT2(triangleList.size() + 1);
    triangleList[triangleIndex].setT3(triangleList.size() + 2);
    // Update the adjacent triangles
    if (T2 != 0 && T3 != 0)
    {
        triangleList[T2 - 1].setT3(triangleList.size() + 1); // T-1 because vector starts at 0
        triangleList[T3 - 1].setT2(triangleList.size() + 2);
    }
    // Insert the new triangles in the triangulation
    triangleList.push_back(triangle2);
    triangleList.push_back(triangle3);
}
/*
Name: inCircle
Description: determine if a point is inside a circle
*/
bool inCircle(const Point& newPoint, const int triangleIndex)
{
    // Get the coordinates of the new point
    int x = newPoint.getX();
    int y = newPoint.getY();
    int z = newPoint.getZ();
    // Get the coordinates of the first point
    int x1 = pointList[triangleList[triangleIndex].getS1()].getX();
    int y1 = pointList[triangleList[triangleIndex].getS1()].getY();
    int z1 = pointList[triangleList[triangleIndex].getS1()].getZ();
    // Get the coordinates of the second point
    int x2 = pointList[triangleList[triangleIndex].getS2()].getX();
    int y2 = pointList[triangleList[triangleIndex].getS2()].getY();
    int z2 = pointList[triangleList[triangleIndex].getS2()].getZ();
    // Get the coordinates of the third point
    int x3 = pointList[triangleList[triangleIndex].getS3()].getX();
    int y3 = pointList[triangleList[triangleIndex].getS3()].getY();
    int z3 = pointList[triangleList[triangleIndex].getS3()].getZ();
    // Create the 4 x 4 matrix
    int pointArray[4][4] = { { x,y,z,1 }, {x1,y1,z1,1}, {x2,y2,z2,1}, {x3,y3,z3,1} };
    // Create the 3 points of the first block A
    Point pointA1(pointArray[1][1], pointArray[1][2], pointArray[1][3]);
    Point pointA2(pointArray[2][1], pointArray[2][2], pointArray[2][3]);
    Point pointA3(pointArray[3][1], pointArray[3][2], pointArray[3][3]);
    // Create the 3 points of the second block B
    Point pointB1(pointArray[1][0], pointArray[1][2], pointArray[1][3]);
    Point pointB2(pointArray[2][0], pointArray[2][2], pointArray[2][3]);
    Point pointB3(pointArray[3][0], pointArray[3][2], pointArray[3][3]);
    // Create the 3 points of the third block C
    Point pointC1(pointArray[1][0], pointArray[3][1], pointArray[1][3]);
    Point pointC2(pointArray[2][0], pointArray[2][1], pointArray[2][3]);
    Point pointC3(pointArray[3][0], pointArray[1][1], pointArray[3][3]);
    // Create the 3 points of the fourth block D
    Point pointD1(pointArray[1][0], pointArray[3][1], pointArray[1][2]);
    Point pointD2(pointArray[2][0], pointArray[2][1], pointArray[2][2]);
    Point pointD3(pointArray[3][0], pointArray[1][1], pointArray[3][2]);
    // Find the determinant
    int determinant = pointArray[0][0] * getDeterminant(pointA1, pointA2, pointA3) - pointArray[0][1] * getDeterminant(pointB1, pointB2, pointB3) + pointArray[0][2] * getDeterminant(pointC1, pointC2, pointC3) - pointArray[0][3] * getDeterminant(pointD1, pointD2, pointD3);
    // Return the test value (1 if the point is inside the circle, 0 if not)
    bool isInside;
    (determinant < 0) ? (isInside = 1) : (isInside = 0);
    return isInside;
}
/*
Name: walk
Description: find the triangle containing the new point
*/
int walk(const Point& newPoint)
{
    // First triangle to test by default
    int triangleToTest = 0;
    int triangleIndex = -1;
    do
    {
    // Define the points forming the first line to test
    Point point1 = pointList[triangleList[triangleToTest].getS1() - 1];
    Point point2 = pointList[triangleList[triangleToTest].getS2() - 1];
    // Get the determinant
    int determinant = getDeterminant(point1, point2, newPoint);
    // Test if the point is on the left side of the line
    if (determinant < 0)
    {
        // Define the points forming the second line to test
        point1 = pointList[triangleList[triangleToTest].getS2() - 1];
        point2 = pointList[triangleList[triangleToTest].getS3() - 1];
        determinant = getDeterminant(point1, point2, newPoint);
        // Test if the point is on the left side of the line
        if (determinant < 0)
        {
            // Define the points forming the third line to test
            point1 = pointList[triangleList[triangleToTest].getS3() - 1];
            point2 = pointList[triangleList[triangleToTest].getS1() - 1];
            determinant = getDeterminant(point1, point2, newPoint);
            // Test if the point is on the left side of the line
            if (determinant < 0)
            {
                triangleIndex = triangleToTest;
            }
            else
            {
                triangleToTest = triangleList[triangleToTest].getT2() - 1;
            }
        }
        else
        {
            triangleToTest = triangleList[triangleToTest].getT1() - 1;
        }
    }
    else
    {
        triangleToTest = triangleList[triangleToTest].getT3() - 1;
    }
    } while (triangleIndex == -1);
    return triangleIndex;
}

/*-----------------------------------------
Name: Point
Author: Michael Landry
Description: Declaration of class Point
Date: 2018-02-15
Version: 1.00
-------------------------------------------*/
#ifndef POINT_H_
#define POINT_H_
#include <iostream>
#include <vector>
class Point
{
public:
    // Default constructor
    Point();
    // Constructor with parameters
    Point(int, int, int);
    // Setters
    void setPoint(int p_X, int p_Y, int p_Z);
    void setX(int p_X);
    void setY(int p_Y);
    void setZ(int p_Z);
    // Getters
    int getX() const;
    int getY() const;
    int getZ() const;
    // Overloaded operator
    bool Point::operator==(const std::vector <Point> & p_pointList) const;
private:
    // 3D coordinates as attributes
    int m_X;
    int m_Y;
    int m_Z;
};
#endif /* POINT_H_ */

/*-----------------------------------------
Name: Point
Author: Michael Landry
Description: Implementation of class Point
Date: 2018-02-15
Version: 1.00
-------------------------------------------*/
#include "Point.h"
#include <iostream>
#include <vector>
// Default constructor initialises (0,0,0) as coordinates
Point::Point() : m_X(0), m_Y(0), m_Z(0)
{
}
// Constructor with parameters
Point::Point(int p_X, int p_Y, int p_Z) : m_X(p_X), m_Y(p_Y), m_Z(p_Z)
{
}
// Setter for the 3 coordinates
void Point::setPoint(int p_X, int p_Y, int p_Z)
{
    m_X = p_X;
    m_Y = p_Y;
    m_Z = p_Z;
}
// Setter for each coordinate
void Point::setX(int p_X)
{
    m_X = p_X;
}
void Point::setY(int p_Y)
{
    m_Y = p_Y;
}
void Point::setZ(int p_Z)
{
    m_Y = p_Z;
}
// Getter for each coordinate
int Point::getX() const
{
    return m_X;
}
int Point::getY() const
{
    return m_Y;
}
int Point::getZ() const
{
    return m_Z;
}
// Overloaded operator
bool Point::operator==(const std::vector <Point> & p_pointList) const
{
    // Initialize a counter
    size_t i = 0;
    bool isEqual = true;
    do
    {
        isEqual = (m_X == p_pointList[i].getX()) && (m_Y == p_pointList[i].getY()) && (m_Z == p_pointList[i].getZ());
        i++;
    } while ((i < p_pointList.size()) && (isEqual == false));
    return isEqual;
}

/*-----------------------------------------
Name: Triangle
Author: Michael Landry
Description: Declaration of class Triangle
Date: 2018-02-23
Version: 1.00
-------------------------------------------*/
#ifndef TRIANGLE_H_
#define TRIANGLE_H_
class Triangle
{
public:
    // Constructor with no parameter
    Triangle::Triangle();
    // Constructor with parameters
    Triangle::Triangle(int, int, int, int, int, int, int);
    // Setters
    void Triangle::setTriangle(int p_ID, int p_S1, int p_S2, int p_S3, int p_T1, int p_T2, int p_T3);
    void Triangle::setID(int p_ID);
    void Triangle::setS1(int p_S1);
    void Triangle::setS2(int p_S2);
    void Triangle::setS3(int p_S3);
    void Triangle::setT1(int p_T1);
    void Triangle::setT2(int p_T1);
    void Triangle::setT3(int p_T1);
    // Getters
    int Triangle::getID() const;
    int Triangle::getS1() const;
    int Triangle::getS2() const;
    int Triangle::getS3() const;
    int Triangle::getT1() const;
    int Triangle::getT2() const;
    int Triangle::getT3() const;
private:
    // The ID of the triangle
    int m_ID;
    // The 3 vertices forming the triangle
    int m_S1;
    int m_S2;
    int m_S3;
    // The 3 adjacent triangles
    int m_T1;
    int m_T2;
    int m_T3;
};
#endif /* TRIANGLE_H_ */

/*-----------------------------------------
Name: Triangle
Author: Michael Landry
Description: Implementation of class Triangle
Date: 2018-02-23
Version: 1.00
-------------------------------------------*/
#include "Triangle.h"
// Constructor with no parameter
Triangle::Triangle() : m_ID(0), m_S1(0), m_S2(0), m_S3(0), m_T1(0), m_T2(0), m_T3(0)
{
}
// Constructor with parameters
Triangle::Triangle(int p_ID, int p_S1, int p_S2, int p_S3, int p_T1, int p_T2, int p_T3) : m_ID(p_ID), m_S1(p_S1), m_S2(p_S2), m_S3(p_S3), m_T1(p_T1), m_T2(p_T2), m_T3(p_T3)
{
}
// Global setter
void Triangle::setTriangle(int p_ID, int p_S1, int p_S2, int p_S3, int p_T1, int p_T2, int p_T3)
{
    m_ID = p_ID;
    m_S1 = p_S1;
    m_S2 = p_S2;
    m_S3 = p_S3;
    m_T1 = p_T1;
    m_T2 = p_T2;
    m_T3 = p_T3;
}
// Setter for each individual parameter
void Triangle::setID(int p_ID)
{
    m_ID = p_ID;
}
void Triangle::setS1(int p_S1)
{
    m_S1 = p_S1;
}
void Triangle::setS2(int p_S2)
{
    m_S2 = p_S2;
}
void Triangle::setS3(int p_S3)
{
    m_S3 = p_S3;
}
void Triangle::setT1(int p_T1)
{
    m_T1 = p_T1;
}
void Triangle::setT2(int p_T2)
{
    m_T2 = p_T2;
}
void Triangle::setT3(int p_T3)
{
    m_T3 = p_T3;
}
// Getter for each individual parameter
int Triangle::getID() const
{
    return m_ID;
}
int Triangle::getS1() const
{
    return m_S1;
}
int Triangle::getS2() const
{
    return m_S2;
}
int Triangle::getS3() const
{
    return m_S3;
}
int Triangle::getT1() const
{
    return m_T1;
}
int Triangle::getT2() const
{
    return m_T2;
}
int Triangle::getT3() const
{
    return m_T3;
}

我建议从整个代码中删除所有glFlushglutPostRedisplay调用。

但是,将glutPostRedisplay调用在空闲函数spindisplay中:

void spindisplay(void)
{
    glutPostRedisplay();
}

使用双重缓冲:

glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);

并将单个glutSwapBuffers调用在主循环函数的末尾display

void display(void)
{
   glClearColor(0.0, 0.0, 0.0, 1.0);
   glClear(GL_COLOR_BUFFER_BIT);
   glLoadIdentity();
   glPointSize(5);
   drawPoint();
   drawTriangle();  
   glutSwapBuffers();
}


如果要保留单个缓冲区,

glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);

然后,您必须在display函数末尾进行glFinish调用:

void display(void)
{
    .....
    glFinish(); 
}

首先,谢谢Rabbid76。我遵循您的建议,开始使用双重缓冲而不是单个缓冲区。

这无法解决绘制不需要的其他线路的问题。我发现问题:命令GlBegin(GL_Line_loop(和Glend((在我的循环之外(对于我...(。因此,OpenGL未考虑在每次迭代后完成线路循环。因此,我将命令glbegin(gl_line_loop(和glend((放在(for i ...(循环中,以便我可以更改每次迭代的线路循环。更改之后,每当我单击三角形内,我都会将其细分为3个三角形,依此类推,也没有绘制额外的行。

/*
Name: drawTriangle
Description: draw the triangulation
*/
void drawTriangle(void)
{
    glColor3fv(BLUE);
    for (size_t i = 0; i < triangleList.size(); i++)
    {
        glBegin(GL_LINE_LOOP);
        // Extract the coordinates of the first point of the triangle
        int x1 = pointList[triangleList[i].getS1() - 1].getX(); // -1 because the vector starts at 0
        int y1 = pointList[triangleList[i].getS1() - 1].getY();
        // Extract the coordinates of the second point of the triangle
        int x2 = pointList[triangleList[i].getS2() - 1].getX();
        int y2 = pointList[triangleList[i].getS2() - 1].getY();
        // Extract the coordinates of the third point of the triangle
        int x3 = pointList[triangleList[i].getS3() - 1].getX();
        int y3 = pointList[triangleList[i].getS3() - 1].getY();
        // Draw the triangle formed by the 3 points
        glVertex2i(x1, y1);
        glVertex2i(x2, y2);
        glVertex2i(x3, y3);
        glEnd();
    }
}

最新更新