位置: 编程技术 - 正文

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

  • 借款利息收入是企业收入吗
  • 个人独资企业需要监事吗
  • 药店的主营业务是什么
  • 用房租入股
  • 新成立的公司企业所得税怎么申报
  • 框架合同有合同金额吗
  • 购进石料再加工算自产吗
  • 支付费用可以通过应收账款
  • 代扣个人社保的账务处理
  • 本金加收入减支出等于的是利润吗
  • 挂失的存单还有记录吗
  • 可供出售金融资产和交易性金融资产
  • 合伙企业转让股权需要其他股东同意吗
  • 固定资产折旧提完了之后还要怎么处理吗
  • 制造费用的核算程序是什么
  • 增值税专用发票电子版
  • 加权平均数是什么意思的权
  • 娱乐行业缴税
  • 新手会计怎么入门做账
  • 如何正确安装和使用电脑
  • 系统设置自动还原
  • 农产品成本法计算抵扣
  • 怎么隐藏单元
  • php变量定义的规则
  • linux运维有前景吗
  • win10开机强制进入高级选项怎么退出
  • php socket_read
  • .exe是什么文件
  • 职工住院的护理费标准
  • 房屋赠与双方办理流程
  • 增值税专用发票有几联?
  • 二连浩特老照片
  • vue 实战
  • 拔缴经费收入
  • php 替换函数
  • 公链dapp
  • 错账的类型及对应的更正方法
  • SQL Server 2016 CTP2.2安装配置方法图文教程
  • 退回股东投资款现金流怎么选
  • 新公司第一年年度总结
  • 以前年度应收账款错误如何调整
  • 制造费用怎么摊销到成本?
  • 可供出售金融资产名词解释
  • 如何查询工商局每天入驻情况
  • 销售提成如何入账
  • 无法收回的应收账款怎么做分录
  • 收到红字发票账务处理应附哪些资料呢
  • 当月暂估入账跨月怎么算
  • 库存和结存
  • 技术服务行业增值税税负率
  • 如何计算税前工资
  • 融资租出固定资产的账务处理
  • 通信地址需要写什么
  • 劳务费发票可以抵扣进项税吗
  • 会计记账的方法是如何发展的
  • kvm虚拟机是什么
  • DxO Optics Pro 9 激活破解安装详细图文教程
  • win10怎么安装网络驱动程序
  • linux,Centos5,Ubuntu关掉ipv6的方法
  • linux ls常用命令
  • linux重启shell
  • win8如何设置默认输入法
  • win7的语言栏不见了
  • win10 升级系统
  • unity3d怎么用
  • 如何在unity里设置碰撞体积
  • Javascript Throttle & Debounce应用介绍
  • python winreg
  • jquery图片自动滚动
  • u3d unity3d
  • 请问在javascript程序中
  • javascript编程基础
  • 电子税务局申报表在哪里查询
  • 成都税务企业号公众号
  • A级纳税人和一般纳税人区别
  • 请问到税务局办里退税都需要什么手续
  • 贵州社保在线年审官网
  • 中国税务网官网1732171695993732.2418.61431871
  • 国家税务局宝鸡市税务局
  • 福建泉州电子税务局
  • 免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

    鄂ICP备2023003026号

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

    友情链接: 武汉网站建设