我试图在窗口上打印一些点,但窗口上没有显示任何内容。窗口背景设置为灰色,就是这样。屏幕上没有点出现。这是我的代码
#include <GL/freeglut.h>
#include <GL/gl.h>
#include<unistd.h>
#include<iostream>
using namespace std;
float a[2]={0,0.7},b[2]={-0.3,-0.5},c[2]={0.5,-0.55};
float m[2]={0.0,0.0};
int roll_die() {
int k= (rand()%6) + 1;
return k;
}
void midpoint(float p[],float q[],float *k )
{
for(int i=0;i<2;i++)
{
k[i]=(p[i]+q[i])/2;
}
}
void displaypoint(float a[])
{
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0,1.0,1.0);
glBegin(GL_POINT);
glVertex2f(a[0], a[1]);
glEnd();
glPointSize(8.0);
glFlush();
}
void setup()
{
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0, 1.0, 1.0);
glBegin(GL_POINTS);
glVertex2f(a[0], a[1]);
glVertex2f(b[0],b[1]);
glVertex2f(c[0],c[1]);
glEnd();
glPointSize(8.0);
glFlush();
}
void chaos()
{
int num;
for(int i=0;i<1000;i++)
{
num=roll_die();
if(num==1 || num==2)
midpoint(m,a,m); …Run Code Online (Sandbox Code Playgroud)