位置: 编程技术 - 正文

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

  • 个体户开增值税怎么开
  • 金税三期系统的作用
  • 税务稽查最坏结果不知情人员怎么办
  • 销项税额和进项税额发票怎么区别
  • 未休年假补助
  • 金税盘减免账务处理
  • 资产负债表里的存货包括哪些科目
  • 调整以前年度递延收益确认收入账务处理
  • 资产处置收益对应科目
  • 小规模季度超过45万了怎么缴纳
  • 亏损企业能不能无常捐赠
  • 资产报废账务处理资产处置损益
  • 银行现金解款单回单怎么填
  • 商场积分兑换现金怎么用
  • 注册个人独资企业和有限公司哪个好
  • 进出口货物买卖合同
  • 个体工商户地税没有申报罚款多少
  • 航天信息300元是什么费用
  • 小规模纳税人出租不动产税率是5%还是3%
  • 推广费是广告费和业务宣传费吗
  • 土地出让金抵减增值税账务处理
  • 跨区域提供建筑服务个人所得税
  • 个人股权转给公司要交个税吗
  • win11怎么改名
  • 联想lenovo ideapad 320-15AST
  • 材料暂估的会计分录怎么做
  • mysql 数据源
  • php写post接口
  • 个人所得税手续费比例
  • windows 11任务栏没有网络图标
  • 新产品研发费的会计分录
  • php课堂笔记
  • 企业中秋晚会主持词
  • php教程视频
  • ipad air3发布会价格
  • 用人单位未为劳动者缴纳社会保险费
  • 库存现金要设置明细科目吗
  • 从银行提取现金分录
  • 进项税额转出和不抵扣的区别
  • 猪肉税票怎么开
  • 物流公司挂靠会计处理
  • php代码用什么工具
  • python快速检索
  • js中move
  • 期末存货资产结存金额
  • 自来水适用3%税率还是9%税率
  • 以前年度未入账固定资产账务处理
  • 处置固定资产净收益属于利得吗
  • 报废车补贴政策2023
  • 会计上需要结转的科目
  • 增值税进项税额加计抵减政策
  • 税务稽查补缴上年所得税分录
  • 预付款项怎么做分录
  • 预收款开票的会计分录
  • 垫款报销
  • 仓库员工工资
  • 排污费计入管理费用吗
  • 结转销售成本怎么操作
  • 企业如何科学设计产品
  • 记账凭证的基本内容包括制证,审核,记账,会计主管
  • IIS7在Windows Server 2008R2的新改进
  • xp系统安装条件
  • win8更改账户
  • perl 删除文件
  • ExtJS下 Ext.Direct加载和提交过程排错小结
  • 安卓匿名电话软件
  • vue自定义过滤器的语法
  • node.js权威指南
  • NGUI学习:(1)spine导入后图层顺序的问题
  • 谷歌chrome浏览器网页版网址
  • js中类
  • js字段截取
  • adb命令ls
  • 代扣代缴申报表哪里查询
  • 个税完税证明在哪里开具
  • 铁岭医保网上怎么交费
  • 汕头办理社保卡流程
  • 青岛市医保网上办事大厅
  • 个税3月份申报2月的个税?
  • 汽车燃油税每年要交吗
  • 免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

    鄂ICP备2023003026号

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

    友情链接: 武汉网站建设