大作业的OPengl怎么弄

OpenGl大作业- 道客巴巴
八大行星与太阳 代码: #include &glut.h& #include &math.h&
// Lighting values GLfloat
whiteLight[] = { 0.2f, 0.2f, 0.2f, 1.0f }; GLfloat
sourceLight[] = { 0.8f, 0.8f, 0.8f, 1.0f }; GLfloat
lightPos[] = { 0.0f, 0.0f, 0.0f, 1.0f };
// Earth and Moon angle of revolution GLfloat fMoonRot = 10.0f; GLfloat fEarthRot = 29.786f; GLfloat fMercuryRot = 47.874f; GLfloat fVenusRot = 35.024f; GLfloat fMarsRot = 24.131f; GLfloat fJupiterRot = 13.059f; GLfloat fSaturnRot = 9.644f; GLfloat fUranusRot = 6.799f; GLfloat fNeptuneRot = 5.433f;
void Neptune() {
glColor3ub(162,56,90);
glutSolidSphere(22.0f,30,30); }
void Uranus() {
glColor3ub(146,48,47);
glutSolidSphere(22.5f,30,30); }
void Saturn() {
glColor3ub(100,190,59);
glutSolidSphere(29.0f,30,30); }
void Jupiter() {
glColor3ub(49,100,112);
glutSolidSphere(30.0f,30,30);
void Mars() {
glColor3ub(40,90,10);
glutSolidSphere(7.50f,30,30); }
void Venus() {
glColor3ub(46,112,12);
glutSolidSphere(7.0f,30,30); }
void Mercury() {
glColor3ub(18,46,19);
glutSolidSphere(5.0f,30,30); }
void Moon() {
glColor3ub(0,200,0);
glutSolidSphere(5.0f,30,30);
void Earth() {
glColor3ub(46,10,0);
glutSolidSphere(15.0f,30,30);
glPushMatrix();
glRotatef(fMoonRot,0.0f,1.0f,0.0f);
glTranslatef(25.0f,0.0f,0.0f);
glPopMatrix(); }
void Solar() {
glColor3ub(255,63,0);
glutSolidSphere(40.0f,30,30);
glPushMatrix();
glRotatef(fMercuryRot,0.0f,1.0f,0.09f);
glTranslatef(48.50f,0.0f,0.0f);
Mercury();
glPopMatrix();
glPushMatrix();
glRotatef(fVenusRot,0.0f,1.0f,0.07f);
glTranslatef(54.0f,0.0f,0.0f);
glPopMatrix();
glPushMatrix();
glRotatef(fEarthRot,0.0f,1.0f,0.05f);
glTranslatef(69.50f,0.0f,0.0f);
glPopMatrix();
glPushMatrix();
glRotatef(fMarsRot,0.0f,1.0f,0.09f);
glTranslatef(118.50f,0.0f,0.0f);
glPopMatrix();
glPushMatrix();
glRotatef(fJupiterRot,0.0f,1.0f,.06f);
glTranslatef(778.0f/2,0.0f,0.0f);
Jupiter();
glPopMatrix();
glPushMatrix();
glRotatef(fSaturnRot,0.0f,1.0f,0.12f);
glTranslatef(,0.0f,0.0f);
glPopMatrix();
glPushMatrix();
glRotatef(fUranusRot,0.0f,1.0f,0.08f);
glTranslatef(,0.0f,0.0f);
glPopMatrix();
glPushMatrix();
glRotatef(fNeptuneRot,0.0f,1.0f,0.14f);
glTranslatef(,0.0f,0.0f);
Neptune();
glPopMatrix(); }
// Called to draw scene void display(void) {
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glTranslatef(0.0f,0.0f,-400.0f);
glPopMatrix();
glutSwapBuffers(); }
// This function does any needed initialization on the rendering // context.
void init()
// Light values and coordinates
glEnable(GL_DEPTH_TEST); // Hidden surface removal
glFrontFace(GL_CCW);
// Counter clock-wise polygons face out
glEnable(GL_CULL_FACE);
// Do not calculate inside of jet
// Enable lighting
glEnable(GL_LIGHTING);
// Setup and enable light 0
glLightModelfv(GL_LIGHT_MODEL_AMBIENT,whiteLight);
glLightfv(GL_LIGHT0,GL_DIFFUSE,sourceLight);
glLightfv(GL_LIGHT0,GL_POSITION,lightPos);
glEnable(GL_LIGHT0);
// Enable color tracking
glEnable(GL_COLOR_MATERIAL);
// Set Material properties to follow glColor values
glColorMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE);
// Black blue background
glClearColor(0.0f, 0.0f, 0.0f, 1.0f );
void move(void) {
fMoonRot+= 0.50f;
if(fMoonRot & 360.0f)
fMoonRot = 0.0f;
// Step earth orbit .25 degrees
fEarthRot += .29786f;
if(fEarthRot & 360.0f)
fEarthRot = 0.0f;
fMercuryRot += .47874f;
if(fMercuryRot & 360.0f)
fMercuryRot = 0.0f;
fVenusRot += .35024f;
if(fVenusRot & 360.0f)
fVenusRot = 0.0f;
fMarsRot += .24131f;
if(fMarsRot & 360.0f)
fMarsRot = 0.0f;
fJupiterRot += .13059f;
if(fJupiterRot & 360.0f)
fJupiterRot = 0.0f;
fSaturnRot += .09644f;
if(fSaturnRot & 360.0f)
fSaturnRot = 0.0f;
fUranusRot += .06799f;
if(fUranusRot & 360.0f)
fUranusRot = 0.0f;
fNeptuneRot += .05433f;
if(fNeptuneRot & 360.0f)
fNeptuneRot = 0.0f;
glutPostRedisplay(); }
void reshape(int w, int h)
GLfloat fA
// Prevent a divide by zero
if(h == 0)
// Set Viewport to window dimensions
glViewport(0, 0, w, h);
// Calculate aspect ratio of the window
fAspect = (GLfloat)w/(GLfloat)h;
// Set the perspective coordinate system
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
// field of view of 90 degrees, near and far planes 1.0 and 425
gluPerspective(90.0f, fAspect, 1.0, 1000.0);
// Modelview matrix reset
glMatrixMode(GL_MODELVIEW);
glLoadIdentity(); }
void InitAWindow(int argc, char **argv) {
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
glutInitWindowSize(800,800);
glutCreateWindow(&Sun System:the eight and the one&); }
int main(int argc, char* argv[]) {
InitAWindow(argc, argv);
glutReshapeFunc(reshape);
glutDisplayFunc(display);
glutIdleFunc(move);
glutMainLoop();opengl怎么和设置字体的大小 - VC/MFC当前位置:& &&&opengl怎么和设置字体的大小opengl怎么和设置字体的大小www.MyException.Cn&&网友分享于:&&浏览:213次opengl如何和设置字体的大小网上找到一段函数
void & CThreeDWnd::DrawText(double & xs, & double & zs, & CString & dis)//标井号文字
wglUseFontBitmaps(wglGetCurrentDC(),0,256,1000); &
& 生成256个字符的显示列表 &
& glListBase(1000); &
& 和前一语句中的1000对应 &
& glRasterPos3d(xs,0.80f,zs); &
& 指定字符串显示的位置 &
& glCallLists(8,GL_UNSIGNED_BYTE, & dis); &
& //显示字符串 &
可字符的大小是固定的 & 如何改变啊------解决方案--------------------#include
&StdAfx.h &
&BitmapFont.h &
CBitmapFont::CBitmapFont(CDC* dc,char* fontname,char* string,long Hight)
m_iCount = strlen(string);
if (dc && fontname && strlen(fontname) &
glColor4f(1.0f,1.0f,1.0f,1.0f);
m_listbase = glGenLists(128);
logfont.lfHeight = H
logfont.lfWidth = 0;
logfont.lfEscapement = 0;
logfont.lfOrientation = logfont.lfE
logfont.lfWeight = FW_NORMAL;
logfont.lfItalic = FALSE;
logfont.lfUnderline = FALSE;
logfont.lfStrikeOut = FALSE;
logfont.lfCharSet = GB2312_CHARSET;//ANSI_CHARSET;
logfont.lfOutPrecision = OUT_DEFAULT_PRECIS;
logfont.lfClipPrecision = CLIP_DEFAULT_PRECIS;
logfont.lfQuality = DEFAULT_QUALITY;
logfont.lfPitchAndFamily = VARIABLE_PITCH | TMPF_TRUETYPE | FF_MODERN;
lstrcpy(logfont.lfFaceName,
&&&U&I& &);
CFont font, OldF
CFont* oldfont = NULL;
oldfont = &OldF
BOOL success = font.CreateFontIndirect(&logfont);
oldfont = dc-& SelectObject(&font);
bb = wglUseFontBitmaps(dc-& m_hDC, 0, 128, m_listbase);
if(!bb)word = GetLastError();
if (!success || !bb)
if(success)oldfont-& DeleteObject();
glDeleteLists(m_listbase, 128);
m_listbase = 0;
dc-& SelectObject(oldfont);
CBitmapFont::~CBitmapFont()
// Class destructor.
glDeleteLists(m_listbase, 128);
m_listbase = 0;
void CBitmapFont::DrawStringAt(GLfloat x,GLfloat y,GLfloat z,char* s)
// Draws the given text string at the given location.
GLsizei len = GLsizei(strlen(s));
if (s && len &
glRasterPos3f(x, y, z);
// Must save/restore the list base.
glPushAttrib(GL_LIST_BIT);
glListBase(m_listbase);
glCallLists(len, GL_UNSIGNED_BYTE, (const GLvoid*)s);
12345678910
12345678910
12345678910 上一篇:下一篇:文章评论相关解决方案 12345678910 Copyright & &&版权所有豆丁微信公众号
君,已阅读到文档的结尾了呢~~
OpenGl大作业OpenGl
扫扫二维码,随身浏览文档
手机或平板扫扫即可继续访问
OpenGl大作业
举报该文档为侵权文档。
举报该文档含有违规或不良信息。
反馈该文档无法正常浏览。
举报该文档为重复文档。
推荐理由:
将文档分享至:
分享完整地址
文档地址:
粘贴到BBS或博客
flash地址:
支持嵌入FLASH地址的网站使用
html代码:
&embed src='http://www.docin.com/DocinViewer-4.swf' width='100%' height='600' type=application/x-shockwave-flash ALLOWFULLSCREEN='true' ALLOWSCRIPTACCESS='always'&&/embed&
450px*300px480px*400px650px*490px
支持嵌入HTML代码的网站使用
您的内容已经提交成功
您所提交的内容需要审核后才能发布,请您等待!
3秒自动关闭窗口 上传我的文档
 下载
 收藏
粉丝量:153
该文档贡献者很忙,什么也没留下。
 下载此文档
C语言程序设计大作业报告-OpenGL——舞动的文字,旋转的校徽
下载积分:2000
内容提示:C语言程序设计大作业报告-OpenGL——舞动的文字,旋转的校徽
文档格式:DOC|
浏览次数:467|
上传日期: 13:28:46|
文档星级:
全文阅读已结束,如果下载本文需要使用
 2000 积分
下载此文档
该用户还上传了这些文档
C语言程序设计大作业报告-OpenGL——舞动的文字,旋转
关注微信公众号当前位置:
在结果中搜索
文件名称:工程大作业1.0
所属分类:
资源属性:
上传时间:
文件大小:
浏览/下载:
352次 / 0次
提 供 者:
相关连接:
下载说明:
别用迅雷下载,失败请重下,重下不扣分!
OpenGL的一个小程序,对初期学习的人们很有帮助哦!-OpenGL a small program of early learning helpful people!
(系统自动生成,下载前可以参看下载内容)下载文件列表
压缩包 : 工程大作业1.0.rar 列表
工程大作业1.0\3ds.dsw
工程大作业1.0\3ds.ncb
工程大作业1.0\FILE_ID.DIZ
工程大作业1.0\3ds.h
工程大作业1.0\main.h
工程大作业1.0\Plane25.3DS
工程大作业1.0\3ds.dsp
工程大作业1.0\3ds.plg
工程大作业1.0\Thumbs.db
工程大作业1.0\3ds.cpp
工程大作业1.0\tank1.3ds
工程大作业1.0\Main.cpp
工程大作业1.0\Init.cpp
工程大作业1.0\3ds.opt
工程大作业1.0
暂无评论内容.
*主  题:
*内  容:
*验 证 码:
资源属性分别代表:系统平台,开发平台,开发语言,文件格式四部分.
请用浏览器直接下载本站软件,用进行解压.
请使用单线程下载,否则可能会被扣除(线程数*积分).
如果您发现此软件无法下载,请稍后再次尝试;或者.
本软件为网上收集或会员上传,若无意中侵犯了您的版权,.
如下载前有疑问,可以通过点击"提供者"的名字,查看对方的联系方式,联系对方咨询.
如下载后发现下载的东东跟说明不相乎,可以联系本站的客服,经确认可以退回消费了的积分.
源码中国 www.ymcn.org
All Rights Reserved.}

我要回帖

更多关于 老爷你的好大弄死我了 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信