计算机图形学Opengl——爱心痣

#include <iostream>

#include"glut.h"



void display()

{



glClearColor(1, 1, 0.9, 0.3);

glClear(GL_COLOR_BUFFER_BIT);





glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);

glBegin(GL_POLYGON);



    glColor3ub(0, 191, 255);

glVertex2f(10, 40);

glVertex2f(15, 65);

glVertex2f(30, 50);

glEnd();



glBegin(GL_POLYGON);

glColor3ub(250, 20, 147);

glVertex2f(15, 65);

glVertex2f(38, 67);

glVertex2f(30, 50);

glEnd();



glBegin(GL_POLYGON);

glColor3ub(250, 20, 147);

glVertex2f(10, 40);

glVertex2f(30, 30);

glVertex2f(30, 50);

glEnd();



glBegin(GL_POLYGON);

glColor3ub(255, 182, 193);

glVertex2f(30, 50);

glVertex2f(50, 60);

glVertex2f(38, 67);

glEnd();



glBegin(GL_POLYGON);

glColor3ub(219, 112, 147);

glVertex2f(30, 50);

glVertex2f(50, 60);

glVertex2f(50, 35);

glEnd();



glBegin(GL_POLYGON);

glColor3ub(218, 112, 214);

glVertex2f(30, 50);

glVertex2f(30, 30);

glVertex2f(50, 35);

glEnd();



glBegin(GL_POLYGON);

glColor3ub(255, 105, 180);

glVertex2f(50, 20);

glVertex2f(30, 30);

glVertex2f(50, 35);

glEnd();

//1

glBegin(GL_POLYGON);

glColor3ub(255, 230, 245);

glVertex2f(50, 20);

glVertex2f(70, 30);

glVertex2f(50, 35);

glEnd();

//2

glBegin(GL_POLYGON);

glColor3ub(218, 112, 214);

glVertex2f(70, 50);

glVertex2f(70, 30);

glVertex2f(50, 35);

glEnd();

//3

glBegin(GL_POLYGON);

glColor3ub(100, 205, 236);

glVertex2f(70, 50);

glVertex2f(50, 60);

glVertex2f(50, 35);

glEnd();

//4

glBegin(GL_POLYGON);

glColor3ub(255, 182, 193);

glVertex2f(70, 50);

glVertex2f(50, 60);

glVertex2f(55, 67);

glEnd();

//5

glBegin(GL_POLYGON);

glColor3ub(250, 20, 147);

glVertex2f(70, 50);

glVertex2f(80, 67);

glVertex2f(55, 67);

glEnd();

//6



glBegin(GL_POLYGON);

glColor3ub(30, 144, 255);

glVertex2f(70, 50);

glVertex2f(80, 67);

glVertex2f(88, 45);

glEnd();

//7

glBegin(GL_POLYGON);

glColor3ub(186, 85, 211);

glVertex2f(70, 30);

glVertex2f(70, 50);

glVertex2f(88, 45);

glEnd();



glPointSize(10);

glBegin(GL_POINTS);

glColor3ub(255, 165, 0);

glVertex2f(75, 20);

glEnd();



glFlush();//显示刷新

}

void init()

{

glMatrixMode(GL_PROJECTION);

glLoadIdentity();

glOrtho(0, 100, 0, 100, -1, 1);

}

void main()

{

glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);//设置初始化的显示模式single单缓冲模式

glutInitWindowSize(500, 500);//窗口大小

glutInitWindowPosition(100, 200);//窗口位置

glutCreateWindow("hello");//创建窗口

init();

glutDisplayFunc(display);//显示的回调,函数指针

glutMainLoop();//刷新效果显示,图形从显存放到内存

system("pause");

}

效果图如下:

  • 0
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值