小编Riz*_*wan的帖子

在鼠标位置的opengl中绘制一个正方形

我试图绘制一个简单的方块,无论我使用opengl/glut按下鼠标左键.我的程序运行完美,除了它没有绘制正方形的部分,我点击鼠标左键:).有人可以指出我做错了什么吗?

#include <stdlib.h> 
#include <glut.h>

GLsizei WIDTH = 1300, HEIGHT = 700;
GLsizei MOUSEx, MOUSEy;
GLfloat SIDE=1;

GLfloat RED[3] = {1,0,0};
GLfloat GREEN[3] = {0,1,0};
GLfloat BLUE[3] = {0,0,1};
GLfloat WHITE[3] = {1,1,1};
GLfloat BLACK[3] = {0,0,0};
GLfloat YELLOW[3] = {1,1,0};
GLfloat CYAN[3] = {0,1,1};
GLfloat MAGENTA[3] = {1,0,1};

void drawSquare(int x, int y)
{
    glColor3fv(YELLOW);
    glBegin(GL_POLYGON);
        glVertex3f(x+SIDE, y+SIDE,0);
        glVertex3f(x-SIDE, y+SIDE,0);
        glVertex3f(x-SIDE, y-SIDE,0);
        glVertex3f(x+SIDE, y-SIDE,0);
    glEnd();
    glFlush();
}

void drawSquare1()
{
    int x=0,y=0;
    glColor3fv(BLUE);
    glBegin(GL_POLYGON);
        glVertex3f(x+SIDE, y+SIDE,0);
        glVertex3f(x-SIDE, …
Run Code Online (Sandbox Code Playgroud)

opengl glut

2
推荐指数
1
解决办法
2万
查看次数

标签 统计

glut ×1

opengl ×1