当前位置:网站首页>OpenGL 3D graphics rendering
OpenGL 3D graphics rendering
2022-07-07 08:54:00 【Baldness is impossible in this life】
#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(" Wire frame tetrahedron ", 1);
glutAddMenuEntry(" Solid tetrahedron ", 2);
glutAddMenuEntry(" Wireframe regular octahedron ", 3);
glutAddMenuEntry(" Solid regular octahedron ", 4);
int nGlutCurveMenu = glutCreateMenu(ProcessMenu);
glutAddMenuEntry(" Wireframe sphere ", 5);
glutAddMenuEntry(" Solid sphere ", 6);
glutAddMenuEntry(" Wireframe teapot ", 7);
glutAddMenuEntry(" Solid teapot ", 8);
int nGluCurveMenu = glutCreateMenu(ProcessMenu);
glutAddMenuEntry(" Wireframe sphere ", 9);
glutAddMenuEntry(" Wireframe cone ", 10);
glutAddMenuEntry(" Wireframe torus ", 11);
int nMainMenu = glutCreateMenu(ProcessMenu);
glutAddSubMenu("GLUT Polyhedron ", nGlutPolyMenu);
glutAddSubMenu("GLUT Surfaces ", nGlutCurveMenu);
glutAddSubMenu("GLU Surfaces ", nGluCurveMenu);
glutAttachMenu(GLUT_RIGHT_BUTTON);
glutDisplayFunc(Display);
glutReshapeFunc(ChangeSize);
glutSpecialFunc(SpecialKeys);
Initial();
glutMainLoop();
}
use vs2013 To write , After running, right-click the stand-alone to expand the menu
边栏推荐
- Tronapi wave field interface - source code without encryption - can be opened twice - interface document attached - package based on thinkphp5 - detailed guidance of the author - July 6, 2022 - Novice
- 数据库存储---表分区
- Oracle makes it clear at one time that a field with multiple separators will be split into multiple rows, and then multiple rows and columns. Multiple separators will be split into multiple rows, and
- JS的操作
- Interpolation lookup (two methods)
- channel. Detailed explanation of queuedeclare parameters
- Markdown编辑器Editor.md插件的使用
- Greenplum 6.x monitoring software setup
- 最长上升子序列模型 AcWing 1017. 怪盗基德的滑翔翼
- let const
猜你喜欢

let const

leetcode135. Distribute candy

Oracle makes it clear at one time that a field with multiple separators will be split into multiple rows, and then multiple rows and columns. Multiple separators will be split into multiple rows, and

The longest ascending subsequence model acwing 1017 Strange thief Kidd's glider
![[南京大学]-[软件分析]课程学习笔记(一)-introduction](/img/57/bf652b36389d2bf95388d2eb4772a1.png)
[南京大学]-[软件分析]课程学习笔记(一)-introduction

Greenplum6.x常用语句

数字三角形模型 AcWing 275. 传纸条

最长上升子序列模型 AcWing 1017. 怪盗基德的滑翔翼

面板显示技术:LCD与OLED

Greenplum 6.x reinitialization
随机推荐
Markdown编辑器Editor.md插件的使用
Image segmentation in opencv
Greenplum6.x-版本变化记录-常用手册
【ChaosBlade:节点 CPU 负载、节点网络延迟、节点网络丢包、节点域名访问异常】
UnityShader入门精要个人总结--基础篇(一)
Analysis of using jsonp cross domain vulnerability and XSS vulnerability in honeypot
Selenium automation integration, eight years of testing experience, soft test engineer, an article to teach you
Speaking of a software entrepreneurship project, is there anyone willing to invest?
Output a spiral matrix C language
硬件大熊原创合集(2022/06更新)
The longest ascending subsequence model acwing 1017 Strange thief Kidd's glider
opencv之图像分割
【MySQL】数据库进阶之触发器内容详解
OpenGL帧缓冲
Greenplum 6.x common statements
FPGA knowledge accumulation [6]
Shell script for changing the current folder and the file date under the folder
Greenplum 6.x reinitialization
Alibaba P8 teaches you how to realize multithreading in automated testing? Hurry up and stop
[Yugong series] February 2022 U3D full stack class 006 unity toolbar