位置: 编程技术 - 正文

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纹理)

  • 检查记账凭证的主要方法有哪些?
  • 医院这么开发票
  • 签劳务合同需要什么资质
  • 工资可以直接进管理费用吗
  • 已贴花的凭证凡修改后所载金额增加的部分应补贴印花
  • 纳税人提供应税服务的价格明显偏低
  • 纳税人选择简易办法一经选择
  • 免税农产品如何填报企业所得税季报
  • 纳税调整税收金额
  • 员工借款可以直接转账吗
  • 白条确认收款后还能分期吗
  • 个人出租房屋应该注意什么
  • 商品已发出未开票未收款怎么做账
  • 担保公司做担保怎么收费
  • 公司名下的车怎么报废
  • 进口是关税不得抵扣吗?
  • 糖类计算公式
  • 保险代理的佣金怎么算
  • 个人所得税生产经营所得投资者减除费用
  • 汇票贴息会计分录
  • 研发企业退税
  • 发票开了收不到钱
  • 小型微利企业普惠性企业所得税减免政策解读
  • 收到投资款如何记账
  • linux -pv
  • 如何计算每个月的天数
  • PHP:xml_get_current_line_number()的用法_XML解析器函数
  • php压缩包
  • php怎么把数组变成字符串
  • mac catalina系统怎么样
  • php双冒号和箭头
  • 调整系统保留带宽的命令
  • thinkphp5 ajax
  • php分类
  • 往来款的账务处理
  • 所得税汇算清缴报告在哪查
  • 购进农产品直接销售核定农产品增值税进项税额计算表
  • 现代服务增值税纳税义务发生时间
  • SQL中print、sp_helptext的限制与扩展
  • 小规模季度免税政策
  • 月度合并报表与年度合并区别
  • 销货退回的账务如何处理
  • 营改增抵减的销项税额是什么意思
  • 长期待摊费用在注会哪一章
  • 进项税额不允许抵扣
  • 捐赠支出税前扣除标准
  • 广告发票能抵扣吗
  • 母公司孙子公司
  • 记账凭证错误要重开吗
  • 收到科技局补贴金费怎么入账
  • 化妆品消费税纳税标准
  • 小规模注销时盈余怎么算
  • 为什么设置辅警
  • mac os x 10.12.2 Beta1怎么升级?macOS Sierra 10.12.2 Beta升级图文教程
  • linux 主力机
  • ffplay播放视频命令
  • 桌面上的软件是什么
  • Win10 Mobile 10572升级后QQ/微信无法发送图片
  • Linux系统防火墙的命令
  • wincomm.exe - wincomm是什么进程
  • win8系统怎么设置
  • win10mobile下载官网
  • 天气应用程序(weather)app免费下载
  • win7怎么看磁盘
  • windows8音频服务尚未启用 怎么解决
  • opengl入门教程
  • emulator: ERROR: no search paths found in this AVD's configuration. Weird, the AVD's config.ini file
  • jquery序列化json
  • jquery图片轮播无缝连接
  • python toad
  • 公路局有钱吗
  • 金税三期个税下载官网手机版
  • 什么是财务审计
  • 物业收取水电费的通知范文
  • 一般纳税人的进项票必须当月认证吗?
  • 税务稽查会打电话吗
  • 什么是党建工作一体化
  • 会计专业有必要读博士吗
  • 湖南地方税务局网上办税大厅
  • 企业将持有的交易性金融资产售出,实际收到出售价款
  • 免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

    鄂ICP备2023003026号

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

    友情链接: 武汉网站建设