当前位置:网站首页>OpenGL三维图形绘制
OpenGL三维图形绘制
2022-07-07 06:18:00 【这辈子秃头是不可能的】
#include "stdafx.h"
#include<GL\glut.h>
#include<gl\glut.h>
#include<GL\glaux.h>
static GLsizei iMode = 1;
static GLfloat xRot = 0;
static GLfloat yRot = 0;
GLUquadricObj *obj;
void Initial(){
glClearColor(1, 1, 1, 1);
glColor3f(0, 0, 0);
obj = gluNewQuadric();
gluQuadricDrawStyle(obj, GLU_LINE);
}
void ChangeSize(int w, int h){
glViewport(0, 0, w, h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(-1.5, 1.5, -1.5, 1.5);
}
void Display(){
glClear(GL_COLOR_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glRotatef(xRot, 1, 0, 0);
glRotatef(yRot, 0, 1, 0);
switch (iMode){
case 1:
glutWireTetrahedron(); break;
case 2:
glutSolidTetrahedron(); break;
case 3:
glutWireOctahedron(); break;
case 4:
glutSolidOctahedron(); break;
case 5:
glutWireSphere(1, 15, 15); break;
case 6:
glutSolidSphere(1, 15, 15); break;
case 7:
glutWireTeapot(1); break;
case 8:
glutSolidTeapot(1); break;
case 9:
gluSphere(obj, 1, 15, 15); break;
case 10:
gluCylinder(obj, 1, 0, 1, 15, 15); break;
case 11:
gluPartialDisk(obj, 0.3, 0.8, 15, 15, 30, 260); break;
default: break;
}
glFlush();
}
void ProcessMenu(int value){
iMode = value;
glutPostRedisplay();
}
void SpecialKeys(int key, int x, int y){
if (key == GLUT_KEY_UP) xRot -= 5;
if (key == GLUT_KEY_DOWN) xRot += 5;
if (key == GLUT_KEY_LEFT) yRot -= 5;
if (key == GLUT_KEY_RIGHT) yRot += 5;
if (xRot > 356) xRot = 0;
if (xRot < -1) xRot = 355;
if (yRot > 356) yRot = 0;
if (yRot < -1) yRot = 355;
glutPostRedisplay();
}
int main(int argc, char** argv){
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize(400, 400);
glutInitWindowPosition(100, 100);
glutCreateWindow("Hello");
int nGlutPolyMenu = glutCreateMenu(ProcessMenu);
glutAddMenuEntry("线框正四面体", 1);
glutAddMenuEntry("实体正四面体", 2);
glutAddMenuEntry("线框正八面体", 3);
glutAddMenuEntry("实体正八面体", 4);
int nGlutCurveMenu = glutCreateMenu(ProcessMenu);
glutAddMenuEntry("线框球面", 5);
glutAddMenuEntry("实体球面", 6);
glutAddMenuEntry("线框茶壶", 7);
glutAddMenuEntry("实体茶壶", 8);
int nGluCurveMenu = glutCreateMenu(ProcessMenu);
glutAddMenuEntry("线框球面", 9);
glutAddMenuEntry("线框圆锥面", 10);
glutAddMenuEntry("线框圆环面", 11);
int nMainMenu = glutCreateMenu(ProcessMenu);
glutAddSubMenu("GLUT多面体", nGlutPolyMenu);
glutAddSubMenu("GLUT曲面", nGlutCurveMenu);
glutAddSubMenu("GLU曲面", nGluCurveMenu);
glutAttachMenu(GLUT_RIGHT_BUTTON);
glutDisplayFunc(Display);
glutReshapeFunc(ChangeSize);
glutSpecialFunc(SpecialKeys);
Initial();
glutMainLoop();
}
用vs2013编写,运行后单机右键会展开菜单
边栏推荐
- Selenium automation integration, eight years of testing experience, soft test engineer, an article to teach you
- Test pits - what test points should be paid attention to when adding fields to existing interfaces (or database tables)?
- [Nanjing University] - [software analysis] course learning notes (I) -introduction
- 注解@ConfigurationProperties的三种使用场景
- Mountaineering team (DFS)
- 联想混合云Lenovo xCloud:4大产品线+IT服务门户
- systemd
- With an annual salary of 50W, Alibaba P8 will come out in person to teach you how to advance from testing
- 模拟卷Leetcode【普通】1609. 奇偶树
- Greenplum6.x搭建_安装
猜你喜欢

NCS Chengdu Xindian interview experience

LeetCode 736. LISP syntax parsing

Analysis of using jsonp cross domain vulnerability and XSS vulnerability in honeypot
![Data analysis methodology and previous experience summary 2 [notes dry goods]](/img/e1/643e847a777e1effcbd39f8b009e2b.png)
Data analysis methodology and previous experience summary 2 [notes dry goods]

PPT模板、素材下载网站(纯干货,建议收藏)

数据分析方法论与前人经验总结2【笔记干货】

About using CDN based on Kangle and EP panel

Count sort (diagram)

LeetCode 715. Range 模块

Recommended by Alibaba P8, the test coverage tool - Jacobo is very practical
随机推荐
Explain Huawei's application market in detail, and gradually reduce 32-bit package applications and strategies in 2022
Test pits - what test points should be paid attention to when adding fields to existing interfaces (or database tables)?
let const
opencv之图像分割
Quick sorting (detailed illustration of single way, double way, three way)
Several methods of calculating the average value of two numbers
Shell script for changing the current folder and the file date under the folder
求有符号数的原码、反码和补码【C语言】
Appeler l'interface du moteur de création du service multimédia de jeu Huawei renvoie le Code d'erreur 1002, le message d'erreur: les paramètres sont l'erreur
Routing information protocol rip
Esp32-ulp coprocessor low power mode RTC GPIO interrupt wake up
[Yugong series] February 2022 U3D full stack class 005 unity engine view
测试人一定要会的技能:selenium的三种等待方式解读,清晰明了
最长上升子序列模型 AcWing 1017. 怪盗基德的滑翔翼
[Yu Yue education] higher vocational English reference materials of Nanjing Polytechnic University
Find the original code, inverse code and complement of signed numbers [C language]
【MySQL】数据库进阶之触发器内容详解
[Chongqing Guangdong education] audio visual language reference materials of Xinyang Normal University
为不同类型设备构建应用的三大更新 | 2022 I/O 重点回顾
[Yu Yue education] C language programming reference of Zhongbei College of Nanjing Normal University