三角形平移旋转与缩放

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

void init(void)
{
	//背景
	glClearColor(0.0, 0.0, 0.0, 0.0);
	glShadeModel(GL_FLAT);
}
void draw_triangle(void)
{ 
	//绘制三角形
	//	glBegin(GL_LINE_LOOP)所有点首尾相接
	glBegin(GL_LINE_LOOP);
	glVertex2f(0.0, 25.0);
	glVertex2f(25.0, -25.0);
	glVertex2f(-25.0, -25.0);
	glEnd();
}
//display
void display(void)
{
	glClear(GL_COLOR_BUFFER_BIT);
	glLoadIdentity();
	glColor3f(1.0, 1.0, 1.0);
	draw_triangle();

	//glEnable用于启用各种功能
	// //void glEnable(GLenum cap)
	//GL_LINE_STIPPLE执行后画虚线;一种cap取值
	glEnable(GL_LINE_STIPPLE);
	glLineStipple(1, 0xF0F0);
	//函数原型:void glLineStipple( GLint factor, GLushort pattern );
	glLoadIdentity();
	//平移 (x,y,z)
	glTranslatef(-20.0, 0.0, 0.0);
	draw_triangle();
	//画线
	glLineStipple(1, 0xF00F);
	//当前矩阵恢复成一个单位矩阵
	glLoadIdentity();
	//缩放xyz
	glScalef(1.5, 0.5, 1.0);
	draw_triangle();

	glLineStipple(1, 0x8888);
	glLoadIdentity();
	//旋转(角度/默认逆时针 旋转方向向量)
	glRotatef(90.0, 0.0, 0.0, 1
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值