位置: 编程技术 - 正文

opengl 绘制实心圆柱体(opengl画实体)

编辑:rootadmin

推荐整理分享opengl 绘制实心圆柱体(opengl画实体),希望有所帮助,仅作参考,欢迎阅读内容。

文章相关热门搜索词:opengl绘制虚线,opengl绘制任意图形,opengl画心形曲线,opengl画心形曲线,opengl绘制实心圆,opengl画实体,opengl画实心圆,opengl绘制实心三角形,内容如对您有帮助,希望把文章链接给更多的朋友!

glu中提供了一个绘制圆柱体的函数:

void gluCylinder( GLUquadric* quad, GLdouble base, GLdouble top, GLdouble height, GLint slices, GLint stacks )使用方法是:

GLUquadric *pObj; pObj = gluNewQuadric();

调用gluCylinder函数时,将pObj作为第一个参数传入。gluDeleteQuadric(pObj);

opengl 绘制实心圆柱体(opengl画实体)

这样子绘制出的圆柱体是空心的:

我根据gluCylinder函数写了个函数,将两边封顶。

[cpp] view plaincopyvoid mySolidCylinder( GLUquadric* quad, GLdouble base, GLdouble top, GLdouble height, GLint slices, GLint stacks ) { glColor3f(.0/, 0.0, .0/.0); gluCylinder(quad, base, top, height, slices, stacks); //top DrawCircleArea(0.0, 0.0, height, top, slices); //base DrawCircleArea(0.0, 0.0, 0.0, base, slices); } GLvoid DrawCircleArea(float cx, float cy, float cz, float r, int num_segments) { GLfloat vertex[4]; const GLfloat delta_angle = 2.0*M_PI/num_segments; glBegin(GL_TRIANGLE_FAN); vertex[0] = cx; vertex[1] = cy; vertex[2] = cz; vertex[3] = 1.0; glVertex4fv(vertex); //draw the vertex on the contour of the circle for(int i = 0; i < num_segments ; i&#;&#;) { vertex[0] = std::cos(delta_angle*i) * r &#; cx; vertex[1] = std::sin(delta_angle*i) * r &#; cy; vertex[2] = cz; vertex[3] = 1.0; glVertex4fv(vertex); } vertex[0] = 1.0 * r &#; cx; vertex[1] = 0.0 * r &#; cy; vertex[2] = cz; vertex[3] = 1.0; glVertex4fv(vertex); glEnd(); } [cpp] view plaincopyvoid mySolidCylinder( GLUquadric* quad, GLdouble base, GLdouble top, GLdouble height, GLint slices, GLint stacks ) { glColor3f(.0/, 0.0, .0/.0); gluCylinder(quad, base, top, height, slices, stacks); //top DrawCircleArea(0.0, 0.0, height, top, slices); //base DrawCircleArea(0.0, 0.0, 0.0, base, slices); } GLvoid DrawCircleArea(float cx, float cy, float cz, float r, int num_segments) { GLfloat vertex[4]; const GLfloat delta_angle = 2.0*M_PI/num_segments; glBegin(GL_TRIANGLE_FAN); vertex[0] = cx; vertex[1] = cy; vertex[2] = cz; vertex[3] = 1.0; glVertex4fv(vertex); //draw the vertex on the contour of the circle for(int i = 0; i < num_segments ; i&#;&#;) { vertex[0] = std::cos(delta_angle*i) * r &#; cx; vertex[1] = std::sin(delta_angle*i) * r &#; cy; vertex[2] = cz; vertex[3] = 1.0; glVertex4fv(vertex); } vertex[0] = 1.0 * r &#; cx; vertex[1] = 0.0 * r &#; cy; vertex[2] = cz; vertex[3] = 1.0; glVertex4fv(vertex); glEnd(); }

最终绘制出的圆柱体:

Opengl 添加纹理 #includestdio.h#includewindows.h//HeaderFileForWindows#includeglgl.h//HeaderFileForTheOpenGLLibrary#includeglglu.h//HeaderFileForTheGLuLibrary#includeglglut.h//HeaderFileForTheGlauxLibrary#incl

cocos2dx吸蓝效果实现opengl绘制 cocos2dx想做一些比较炫的效果,单纯依靠引擎封装提供的一些东西毕竟有限,最近项目是用opengl绘制一些效果出来,代码如下:封装类效果类GoodDropEffects

错误error LNK: 无法解析的外部符号 _auxDIBImageLoadW@4 OpenGL编程时VS编译器报错:错误1errorLNK:无法解析的外部符号_auxDIBImageLoadW@4,该符号在函数p0解决办法:在cpp头部加入如下代码:#includeglaux.h#pragmacomment(li

标签: opengl画实体

本文链接地址:https://www.jiuchutong.com/biancheng/369467.html 转载请保留说明!

上一篇:Cocos2dx 3.2 + vs2012 + win7 改变面黑色背景的大小

下一篇:Opengl 添加纹理(opengl oes纹理)

  • 小规模收到专票怎么处理
  • 小规模增值税附表一怎么填
  • 土地税税额标准
  • 我国的税种有哪些种类
  • 个人微信转账可以认定劳动关系吗
  • 贴现利息应计入什么费用
  • 税收优惠抵扣
  • 购买车位需要交哪些税
  • 出口免税进项税额转出会计分录
  • 税控盘全额抵减申报
  • 营改增后餐饮业税率
  • 单位收到社保补缴通知书后怎么办
  • 免税企业土地税怎么交
  • 增值税扣税项目
  • 普通增值税发票查询结果不一致是什么原因?
  • 清算所得计算例题
  • 万元的票可以开到多大金额
  • 银行存款缴税
  • 长期驻扎外地的员工
  • 预收账款预提费用
  • 适用增值税简易计税的项目
  • 用人单位垫付生育津贴的凭证怎么做
  • 交换房产土地如何交税
  • 不同方式的融资租赁业务如何贴花?
  • 老板请客吃饭拿餐饮发票公司报销怎么账务处理?
  • 资本的不同形态
  • w11系统激活码
  • 劳务公司发放农民工工资要开发票吗?
  • mysqld-nt.exe - mysqld-nt是什么进程 有什么用
  • 酒店的啤酒
  • php字符串变量
  • 已认证留抵待抵扣税额分录
  • 欧罗巴山脉自驾
  • php addslashes函数
  • 商品销售税金及附加包括哪些
  • axios入门
  • 企业借给个人钱合法吗
  • 即插即用是什么意思?
  • JavaScript DOM API的使用
  • lvm命令详解
  • 2022最好用的港澳台电视直播
  • 加班补贴费
  • 银行账户管理的直接责任人是共享中心核算会计
  • db2数据库管理最佳实践
  • 公司开电费发票该怎么入账?
  • 未确认融资费用账务处理
  • db2 -968
  • 公允价值变动是一级科目吗
  • 如何理解合并报表编制程序中的调整与抵消处理
  • 一般纳税人报税时间每月的多少号
  • 有形动产租赁属于经营租赁吗
  • 进项发票做账了可以不认证吗
  • 进口葡萄酒政策
  • 行政单位基建账地质灾害评估报告计哪个科目
  • 折价购买股权账务处理
  • 坏账准备的计提分录
  • 酒店租金计入什么会计科目
  • 企业管理费的计算基础
  • 工程类发票账务后面需附什么单据呢
  • 其他费用包括哪些内容
  • centos6.2安装教程
  • 该程序无法正常启动
  • win8不好吗
  • 正常关机开机后爱奇艺自动卸载
  • centos 操作日志
  • win10设置回收站位置
  • hdaudpropshortcut.exe是什么进程 作用是什么 hdaudpropshortcut进程查询
  • 关闭windows怎么关
  • w10系统音量图标不能用了
  • html5仿微博代码
  • jQuery EasyUI tree 使用拖拽时遇到的错误小结
  • 怎么做一个扇形图
  • 函数 python
  • jquery基础教程详解
  • bootstrap需要学多久
  • Android屏幕适配分屏
  • android图片压缩到200-300kb
  • 开票信息不一致怎么回事
  • 动态简报和工作总结
  • 什么是专案审计
  • 免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

    鄂ICP备2023003026号

    网站地图: 企业信息 工商信息 财税知识 网络常识 编程技术

    友情链接: 武汉网站建设