博文

GE 地形裂缝(2011-07-02 09:42:00)

摘要:虽然早就知道GE的地形裂缝还是经常可见的,但是一般不明显,所以我没怎么抓拍到。   今天无意中发现了很多次。也不知道是网速原因还是什么。可能是旁边的已经变化完毕,而在等待这一块变精细,网速传不来精细数据导致看到裂缝。            ......

阅读全文(2031) | 评论:0

OpenGL Mesa3D(2010-12-14 14:17:00)

摘要: Mesa 3D是一个在MIT许可证下开放源代码的三维计算机图形库,以开源形式实现了OpenGL的应用程序接口。 OpenGL的高效实现一般依赖于显示设备厂商提供的硬件,而Mesa 3D是一个纯基于软件的图形应用程序接口。由于许可证的原因,它只声称是一个“类似”于OpenGL的应用程序接口。(SGI不让它叫OpenGL这个名字)   补充一些其他知识: (1)GTK+是对Xlib的封装,方便在Linux下开发XWindow程序。
打个比方,Xlib相当与Windows下的视窗SDK,GTK+就相当于MFC
(2)OpenGL只是3D编程的一个标准接口,也就是API,是面向应用程序开发人员的。
(3)Mesa3d原来是OpenGL的纯软件实现,后来一些硬件厂商通过DRI/DRI2架构,提供了自己显卡的硬件加速实现,也就是所谓的3D驱动   参考: http://en.wikipedia.org/wiki/Mesa_3D_(OpenGL) http://blog.csdn.net/shallon_luo/archive/2009/10/28/4737622.aspx ......

阅读全文(5545) | 评论:0

OpenGL与Memory DC(2009-01-13 16:15:00)

摘要:   用GDI绘图时,双缓冲是经常采用的技术。其中关键的一步,就是要先把图形绘制到内存设备环境中,然后拷贝到屏幕上。        OpenGL本身已经有双缓冲的功能了。但是因为开发需要,在采用OpenGL的绘图程序中,我还是需要首先在内存设备环境上绘制一个物体,然后保存为bmp图像。但是采用类似于GDI相似的方法,却发现图像是一片空白。     代码如下:   HBITMAP  GetObjBitmap(LPRECT lpRect, BOOL bSave, CString filename)     { // 屏幕和内存设备描述表     HDC  hScrDC, hMemDC;          // 为屏幕创建设备描述表     hScrDC = CreateDC("DISPLAY", NULL, NULL, NULL);         // 为屏幕设备描述表创建兼容的内存设备描述表     hMemDC = CreateCompatibleDC(hScrDC);   // 图像宽度和高度     int nBMPWidth,nBMPHeight;     nBMPWidth = nBMPHeight = 128;       // 图像格式参数 int iPixel = 32;     LPBITMAPINFO lpbmih = new BITMAPINFO;     lpbmih->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);     lpbmih->bmiHeader.biWidt......

阅读全文(7289) | 评论:5

(OPENGL编程指南第四版)OPENGL范例程序9.3(2008-04-04 13:16:00)

摘要:// 范例P257.cpp : Defines the entry point for the console application.
// #include "stdafx.h"
#include <gl/glut.h> #define checkImageWidth 64
#define checkImageHeight 64
#define subImageWidth 16
#define subImageHeight 16 static GLubyte subImage[subImageWidth][subImageHeight][4];
static GLubyte checkImage[checkImageWidth][checkImageHeight][4]; static GLuint texName; static GLuint CoordX,CoordY; void makeCheckImage(void)
{
 int i,j,k,c;  for(i=0;i<checkImageWidth;i++)
  for(j=0;j<checkImageHeight;j++)
  {
   c=(((i&0x8)==0)^((j&0x8)==0))*255;
   for(k=0;k<3;k++)
    checkImage[i][j][k]=(GLubyte)c;
   checkImage[i][j][3]=(GLubyte)255;
  }  for(i=0;i<subImageWidth;i++)
  for(j=0;j<subImageHeight;j++)
  {
   c=(((i&0x4)==0)^((j&0x4)==0))*255;
 &......

阅读全文(3419) | 评论:0

(OPENGL编程指南第四版)OPENGL范例程序9.1(2008-04-03 21:11:00)

摘要:// 范例P250.cpp : Defines the entry point for the console application.
// #include "stdafx.h"
#include <gl/glut.h> #define checkImageWidth 64
#define checkImageHeight 64
static GLubyte checkImage[checkImageWidth][checkImageHeight][4]; static GLuint texName; void makeCheckImage(void)
{
 int i,j,c;  for(i=0;i<checkImageWidth;i++)
  for(j=0;j<checkImageHeight;j++)
  {
   c=(((i&0x8)==0)^((j&0x8)==0))*255;
   for(int k=0;k<3;k++)
    checkImage[i][j][k]=(GLubyte)c;
   checkImage[i][j][3]=(GLubyte)255;
  }
}
void display()
{
 glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
 glColor3f(1.0,1.0,1.0);       //设置画笔白色
 
 glEnable(GL_TEXTURE_2D);
 glTexEnvf(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_DECAL);
 glBindTexture(GL_TEXTURE_2D,texNa......

阅读全文(2565) | 评论:0

(OPENGL编程指南第四版)OPENGL范例程序7.5(2008-03-30 20:02:00)

摘要:// 范例P195.cpp : Defines the entry point for the console application.
// #include "stdafx.h"
#include "string.h"
#include <gl/glut.h> #define PT 1          //一点
#define STROKE 2         //一画
#define END 3          //结束 // 字体结构体
typedef struct charpoint{
 GLfloat x,y;
 int type;
}CP; //具体字体描述笔画 CP Adata[]={
 {0,0,PT},{0,9,PT},{1,10,PT},{4,10,PT},{5,9,PT},
 {5,0,STROKE},{0,5,PT},{5,5,END}
}; CP Cdata[]={
 {5,0,PT},{1,0,PT},{0,1,PT},{0,9,PT},{1,10,PT},{5,10,END}
}; CP Ddata[]={
 {0,0,PT},{0,10,PT},{3,10,PT},{4,8,PT},{4,2,PT},{3,0,PT},{0,0,END}
}; CP Edata[]={
 {5,0,PT},{0,0,PT},{0,10,PT},{5,10,STROKE},
 {0,5,PT},{4,5,END}
}; CP Pdata[]={
 {0,0,PT},{0,10,PT},{4,10,PT},{5,9,PT},{5,6,PT},
 {4,5,PT},{0,5,END}
}; CP Rdata[......

阅读全文(2863) | 评论:0

(OPENGL编程指南第四版)OPENGL范例程序7.1(2008-03-27 13:17:00)

摘要:// 范例P185.cpp : Defines the entry point for the console application.
// #include "stdafx.h"
#include <gl/glut.h>
#include <math.h>
#include <conio.h>
#include <stdlib.h> #define M_PI 3.1415926 GLuint theTorus; /*绘制一个圆环*/
static void torus(int numc,int numt)
{
 int i,j,k;
 double s,t,x,y,z,twopi;
 
 twopi=2*(double)M_PI;
 for(i=0;i<numc;i++)
 {
  glBegin(GL_QUAD_STRIP);
  for(j=0;j<=numt;j++)
  {
   for(k=1;k>=0;k--)
   {
    s=(i+k)%numc+0.5;
    t=j%numt;     x=(1+0.1*cos(s*twopi/numc))*cos(t*twopi/numt);
    y=(1+0.1*cos(s*twopi/numc))*sin(t*twopi/numt);
    z=0.1*sin(s*twopi/numc);
    glVertex3f(x,y,z);
   }
  }
  glEnd();
&......

阅读全文(2184) | 评论:0

(OPENGL编程指南第四版)OPENGL范例程序5.8(2008-03-24 20:04:00)

摘要:// 范例P140.cpp : Defines the entry point for the console application.
// #include "stdafx.h"
#include <gl/glut.h> void display()
{
 glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);     //清除所有像素
 
 //材质设置  //四列之间的镜面反射色不同
 GLfloat mat_specular[][4]={1.0,1.0,1.0,1.0, 0.0,0.0,0.0,1.0};
 //四列之间的光洁度不同
 GLfloat mat_shininess[3]={0,5,100};
 //三行之间的环境光反射不同
 GLfloat mat_ambient[][4]={0.0,0.0,0.0,1.0, 0.7,0.7,0.7,1.0, 0.8,0.8,0.2,1.0};
 //散射光颜色全部相同
 GLfloat mat_diffuse[]={0.1,0.5,0.8,1.0};
 //第四列能够发光
 GLfloat mat_emission[][4]={0.3,0.2,0.2,0.0, 0.0,0.0,0.0,1.0};  glMaterialfv(GL_FRONT,GL_DIFFUSE,mat_diffuse);
 for(int i=0;i<3;i++)
 {
  glMaterialfv(GL_FRONT,GL_AMBIENT,mat_ambient[i]);
  for(int j=0;j<4;j++)
  {
   if(j==0||j==4)
    glMaterialfv(GL_FRONT......

阅读全文(2677) | 评论:0

(OPENGL编程指南第四版)OPENGL范例程序5.3(扩展版)(2008-03-23 21:24:00)

摘要:// 范例P124.cpp : Defines the entry point for the console application.
// #include "stdafx.h"
#include <gl/glut.h> static int spin=0; void display()
{
 glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);     //清除所有像素  GLfloat light_position[]={5,5,10,1.0};//光源1位置  glPushMatrix();
 glRotated((GLdouble)spin,1.0, 0.0, 0.0);
 glLightfv(GL_LIGHT0,GL_POSITION,light_position);
 glPopMatrix();
 glLoadIdentity();
 glTranslated(0,0,-3);
 glutSolidSphere(1.0,20,16);
 /*在缓存中绘制4对顶点坐标的矩形*/  glFlush();          //立即显示出来
} void init()
{
 glClearColor(0.0,0.0,0.0,0.0);     //用黑色清除背景
 
 
 GLfloat mat_specular[]={1.0, 1.0, 1.0, 1.0}; //材质镜面反射色
 GLfloat mat_shininess[]={50.0};     //光洁度,即物体反射比率
 GLfloat lmodel_ambient[]={0.2,0.2,......

阅读全文(2409) | 评论:0

(OPENGL编程指南第四版)OPENGL范例程序5.3(2008-03-22 19:43:00)

摘要:// 范例P124.cpp : Defines the entry point for the console application.
// #include "stdafx.h"
#include <gl/glut.h> void display()
{
 glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);     //清除所有像素
 glutSolidSphere(1.0,20,6);
 /*在缓存中绘制4对顶点坐标的矩形*/
 
 glFlush();          //立即显示出来
} void init()
{
 glClearColor(0.0,0.0,0.0,0.0);     //用黑色清除背景
 
 GLfloat mat_specular[]={1.0, 1.0, 1.0, 1.0};
 GLfloat mat_shininess[]={50.0};
 GLfloat light_position[]={1.0,1.0,1.0,0.0};
 GLfloat white_light[]={1.0,1.0,1.0,1.0};
 GLfloat lmodel_ambient[]={0.1,0.1,0.1,1.0
 };  glShadeModel(GL_SMOOTH);
 glMaterialfv(GL_FRONT,GL_SPECULAR,mat_specular);
 glMaterialfv(GL_FRONT,GL_SHININESS,mat_shininess);
 glLightfv(GL_LIGHT0,GL_POSITION,light_position);
 glL......

阅读全文(2671) | 评论:0