位置: 编程技术 - 正文

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

  • 哪些东西要征收消费税
  • 超率累进税率定义
  • 外资企业法最新
  • 管理费用中的税金包括哪些
  • 稽查查补的税款用什么时候的税率表示
  • 应交税费增值税明细账
  • 农业机耕开发票税收分类编码是什么
  • 预算会计工资是应发工资还是实发工资
  • 财政拨款收入年底结转到本期盈余
  • 工程款支付利息依据
  • 运输业增值税专用发票开具要求
  • 单位个人实际困难怎么写
  • 原始凭证谁负责
  • 红字信息表没有编号
  • 销售应税消费品应交的消费税分录
  • 劳务费个人所得税税率
  • 递延收益的账务处理案例
  • 显卡功耗天梯图2023最新版
  • 确认收入入账
  • 弃置费用预计负债的会计处理
  • 消防费用怎么做分录
  • 微信聊天记录备份和恢复
  • 营改增之后账务怎么处理
  • 门诊部需要药品经营许可证吗
  • 大数据可视化前端界面模板
  • 现金流量表期初现金余额本年累计
  • /etc/php-fpm.d/www.conf 配置注意事项
  • element ui停止
  • linux写c++程序
  • 原生js操作数组的方法
  • mla指令
  • 收回多发的工资在上缴财政,可以用应缴财政款科目吗
  • python用途
  • 税金及附加算什么
  • Windows上PostgreSQL安装配置教程
  • 跨年度退回的公共预算支出
  • 商业承兑汇票在网银上怎么查询
  • 公司申请破产后员工有赔偿吗
  • 小规模纳税人能开专票吗2023
  • 外商投资的企业有哪些
  • 企业做税务局迁移应该做哪些事情
  • 外贸出口退税政策
  • 发票冲红的会计怎么处理
  • 做无票收入如何报税
  • 先进先出法实际成本跟成本不一样吗
  • 发票丢失了怎么报销
  • sql server 2012 数据库bak脚本还原
  • sql局部变量标识符
  • ubuntu /opt
  • freebsd操作命令
  • xp系统怎么新建桌面
  • smsmon32.exe - smsmon32是什么进程
  • rundll32exe应用程序错误
  • windows8的word在哪里
  • win8怎么关闭系统自动更新
  • win8怎么禁用更新
  • win10桌面图标无法正常显示
  • 飞行体验设备
  • win10教育版登录
  • cocos creator 碰撞检测
  • js操作list
  • Extjs4 消息框去掉关闭按钮(类似Ext.Msg.alert)
  • shell脚本 定义变量
  • linux shell -s
  • 深入解读我本是高山
  • vue分页组件page
  • unity mesh编程
  • Android网络(4):HttpClient必经之路----使用线程安全的单例模式HttpClient,及HttpClient和Application的融合
  • jQuery提示插件qTip2用法分析(支持ajax及多种样式)
  • python 观察者
  • 青岛税务局领导
  • 财务审计报告出现数据错误怎么处理
  • 税控盘换新盘
  • 第十三个人
  • 开采砂石
  • 东营为什么没有疫情
  • 甲供材备案需要的资料
  • 年税怎么扣
  • 购房税率是多少
  • 土地税是怎么缴纳按什么缴纳
  • 免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

    鄂ICP备2023003026号

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

    友情链接: 武汉网站建设