现在来试试 球纹理(=720度全景图)转换为天空盒图(6张,前,后,左,右,顶,底)
先找一张全景图:
流程:
1。载入全景图到opengl 中并贴到天空球上
2。把视线分别转到前,后,左,右,顶,底
3。截屏保存为文件
具体看代码吧:
//53 全景球贴图 切分6图
//左键(+ 移动)旋转,右键(+ 移动)缩放 1,2,3,4 切换地图,回车键(enter)全屏切换,按w、a、s、d、f、x、切换视角并截图
#pragma comment( lib, "opengl32.lib" )
#pragma comment( lib, "glut32.lib")
#include <GL/glut.h>
#include <GL/glu.h>
#include <math.h>
#include <cstdlib>
#include <string>
#include "ArcBall.h"
#include "Sky.h"
CSky m_sky;
void setWidthHeight(GLint width ,GLint height);
void screenshot(char* FileName); //全窗口
int BuildTexture(char *szPathName, GLuint &texid);
//初始化,必须用全局变量的方式,不能用new
ArcBallT arcBall(600.0f,400.0f);
ArcBallT* ArcBall =&arcBall;// new ArcBallT(600.0f,400.0f);//&arcBall;
#define PI 3.141592654
GLuint SkyTexture[10];//纹理
int width,height;//屏幕宽高
int R=100;//地图球半径
std::string direction;//方向
void reshape(int w, int h){
glViewport(0,0, w, h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
//GLdouble zNear=R*cos(PI/2);
gluPerspective(90