初学计算机图形学——OpenGL实现二维图形平移,旋转(不使用opengl自带的函数,齐次方程实现)

要求:1.给定窗口中绘制坐标系
2.给定坐标系内绘制三角形
3.完成平移、旋转等变换后的三角形绘制
4.采用OpenGL绘制
在这里插入图片描述

代码:


#include<windows.h>
#include <GL/glut.h>
#include <stdlib.h>
#include<iostream>
#include<cmath>
#include<math.h>
using namespace std;
GLfloat a, b, n;
GLdouble c;

class wcPt2D
{
   
public:
    GLfloat x, y;
};
typedef GLfloat Matrix3x3[3][3];
Matrix3x3 matComposite;
const GLdouble pi = 3.1415926;
void init(void)
{
   
    glClearColor(0.0, 0.0, 0.0, 0.0);
    glShadeModel(GL_SMOOTH);
}
void matrix3x3SetIdentity(Matrix3x3 matIdent3x3)
{
   
    GLint row, col;
    for (row = 0; row < 3; row++)
        for (col = 0; col < 3; col++)
            matIdent3x3[row][col] = (row == col);

}

void matrix3x3PreMultiply(Matrix3x3 m1, Matrix3x3 m2)
{
   
    GLint row, col;
    Matrix3x3 matTemp;
    for (row = 0; row < 3; row++)
        for (col = 0; col < 3; col++)
            matTemp[row][col] = m1
  • 3
    点赞
  • 31
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值