#include "pch.h"
#include <stdlib.h>
#include <GL/glut.h>
#include<iostream>
#pragma comment(lib, "glut32.lib")
using namespace std;
GLfloat roate = 0.0;// set rote of roate ying yu bu hao bu zhuang le 设置旋转速率
GLfloat rote = 0.0;//shezhi旋转角度
GLfloat anglex = 0.0;//X 轴旋转
GLfloat angley = 0.0;//Y 轴旋转
GLfloat anglez = 0.0;//Z 轴旋转
GLint WinW = 400;
GLint WinH = 400;
GLfloat oldx;//当左键按下时记录鼠标坐标
GLfloat oldy;
void init(void)
{
glClearColor(1.0, 1.0, 1.0, 1.0); //背景黑色
}
void display(void)
{
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0, 0.0, 0.0); //画笔红色
glLoadIdentity(); //加载单位矩阵
gluLookAt(0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);
glRotatef(rote, 0.0f, 1.0f, 0.0f);
glRotatef(anglex, 1.0, 0.0, 0.0);
glRotatef(angley, 0.0, 1.0, 0.0);
glRotatef(anglez, 0.0, 0.0, 1.0);
glutWireTeapot(2);
rote += roate;
//glRotatef(angle, 0.0, 1.0, 0.0);
//angle += 1.0f;
glutSwapBuffers();
}
void
OpenGL鼠标控制旋转
最新推荐文章于 2025-03-24 17:47:16 发布