用opengl和VC++实现的地球仪


用opengl和Visual C++实现的三维地球仪,立体贴图,地球仪旋转,添加了光照
资源截图
代码片段和文件信息

/*********************包含链接的库文件*******************************************************************************************/
#pragma comment( lib “opengl32.lib“ )
#pragma comment( lib “glu32.lib“ )
#pragma comment( lib “glut32.lib“)
#pragma comment( lib “glew32.lib“)
#pragma comment( lib “glaux.lib“)
#pragma comment( lib “vfw32.lib“ )
/********************************************************************************************************************************/

/*#include */
#include “glut.h“
#include 
/*#include */
#include “glaux.h“
#include 
#include 

#define PI 3.14159265358979323846

GLfloat  corner=0.0;

GLUquadricObj* qobj; //二次方程对象   a1x^2 + a2y^2 + a3z^2 + a4xy + a6xz + a7x + a8y + a9z + a10 = 0

GLuint texName texName1 texName2;

GLuint flag=1;

GLfloat bracket_diffuseCoeff[]={0.53 0.37 0.10 1.0};
GLfloat bracket_specularCoeff[]={0.53 0.37 0.10 1.0};
GLfloat bracket_surfEmissionCoeff[]={0.2 0.2 0.2 1.0};

GLfloat underpan_diffuseCoeff[]={0.5 0.5 0.0 1.0};
GLfloat underpan_specularCoeff[]={0.5 0.5 0.0 1.0};
GLfloat underpan_surfEmissionCoeff[]={0.2 0.2 0.2 1.0};

GLfloat wall_mat[]={0.60.60.61};
GLfloat wall_mat1[]={1001};
GLfloat wall_mat2[]={0.60.60.61};

GLfloat shininess[]={25.0};

void draw_semi_circle(float r)             //中心在(xy0),半径为r的半圆
{
   float angle;

   glBegin(GL_LINE_STRIP);

   for(angle = 2*PI; angle >= PI; angle -= PI/100)
  
   {
      glVertex3f(r*cos(angle)r*sin(angle)0);
   }
   glEnd();   
}


void  draw_salver(float x float y float a float b)   //中心在(xy0),长半轴为a,短半轴为b的椭圆
{
   float angle;
   glTranslatef(xy0);

   glBegin(GL_TRIANGLE_FAN);

   for(angle = 2*PI; angle >= 0; angle -= PI/360)
   {
      glVertex3f(a*cos(angle)b*sin(angle)0);
   }
   glEnd();   
}

void draw_tellurion()//地球仪
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    glLoadIdentity();

glPushMatrix();
GLfloat light0_ambient[] = { 0.3 0.4 0.6 1};
    GLfloat light0_diffuse[] = { 0.5 0.4 0.4 1 };
    GLfloat light0_specular[] = { 0.5 0.5 0.5 1};
    GLfloat light0_position[] = { 1 1 1 0 };   //方向性光源,类似太阳 
    glEnable(GL_LIGHTING);
    glEnable(GL_LIGHT0);
    glLightfv(GL_LIGHT0 GL_SPECULAR light0_specular);
    glLightfv(GL_LIGHT0 GL_DIFFUSE light0_diffuse);
    glLightfv(GL_LIGHT0 GL_AMBIENT light0_ambient);   
    glLightfv(GL_LIGHT0 GL_POSITION light0_position);   
    glPopMatrix();

glPushMatrix();
    GLfloat light1_diffuse[] = { 0.3 1 0 1};
    GLfloat light1_position[] = {0.8 1 0.4 1 };   
    glEnable(GL_LIGHTING);
    glEnable(GL_LIGHT1);
    glLightfv(GL_LIGHT1 GL_DIFFUSE light1_diffuse);  
    glLightfv(GL_LIGHT1 GL_POSITION light1_position);   
    glPopMatrix();

glPushMatrix();
    GLfloat light2_diffuse[] = { 1 0.2 0 1 };
    GLfloat light2_position[] = {0.5 0.2 1 1 };  

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件   28856320  2013-12-17 21:17  01_baseframe1_baseframe.sdf

     文件        885  2012-10-25 16:56  01_baseframe1_baseframe.sln

    ..A..H.     18944  2013-12-17 21:17  01_baseframe1_baseframe.suo

     文件       3393  2006-08-03 02:59  01_baseframe1_baseframe.vcproj

     文件       5305  2013-12-16 22:04  01_baseframe1_baseframe.vcxproj

     文件        920  2012-10-25 16:56  01_baseframe1_baseframe.vcxproj.filters

     文件        143  2012-10-25 16:56  01_baseframe1_baseframe.vcxproj.user

     文件      11774  2013-12-16 22:06  01_baseframease.cpp

     文件       1946  2013-12-17 21:15  01_baseframeDebug1_baseframe.Build.CppClean.log

     文件     509952  2013-12-17 21:15  01_baseframeDebug1_baseframe.exe

     文件        406  2013-12-17 21:15  01_baseframeDebug1_baseframe.exe.embed.manifest

     文件        472  2013-12-17 21:15  01_baseframeDebug1_baseframe.exe.embed.manifest.res

     文件        381  2013-12-17 21:15  01_baseframeDebug1_baseframe.exe.intermediate.manifest

     文件    1339428  2013-12-17 21:15  01_baseframeDebug1_baseframe.ilk

     文件         65  2013-12-17 21:15  01_baseframeDebug1_baseframe.lastbuildstate

     文件       3649  2013-12-17 21:15  01_baseframeDebug1_baseframe.log

     文件    2083840  2013-12-17 21:15  01_baseframeDebug1_baseframe.pdb

     文件        707  2013-12-17 21:15  01_baseframeDebug1_baseframe.vcxprojResolveAssemblyReference.cache

     文件          0  2013-12-17 21:15  01_baseframeDebug1_baseframe.write.1.tlog

     文件        214  2013-12-17 21:15  01_baseframeDebug1_baseframe_manifest.rc

     文件      64008  2013-12-17 21:15  01_baseframeDebugase.obj

     文件        610  2013-12-17 21:15  01_baseframeDebugcl.command.1.tlog

     文件      12700  2013-12-17 21:15  01_baseframeDebugCL.read.1.tlog

     文件        318  2013-12-17 21:15  01_baseframeDebugCL.write.1.tlog

     文件     192512  2006-03-04 03:19  01_baseframeDebugglew32.dll

     文件     121856  2004-08-04 08:52  01_baseframeDebugglu32.dll

     文件     169984  1998-08-18 23:25  01_baseframeDebugglut32.dll

     文件          2  2013-12-17 21:15  01_baseframeDebuglink-cvtres.read.1.tlog

     文件          2  2013-12-17 21:15  01_baseframeDebuglink-cvtres.write.1.tlog

     文件          2  2013-12-17 21:15  01_baseframeDebuglink.44-cvtres.read.1.tlog

............此处省略41个文件信息

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。

发表评论

评论列表(条)