📄 imageload.h
字号:
#ifndef IMAGE_LOAD_H
#define IMAGE_LOAD_H
#include <iostream>
#include <string>
#include <mbstring.h>
#include <SDL.h>
#include <SDL_image.h>
#include <gl\glut.h>
#pragma comment(lib,"SDL.lib")
#pragma comment(lib,"SDLmain.lib")
#pragma comment(lib,"SDL_image.lib")
#pragma warning(disable : 4996)
using std::cout;
using std::endl;
using std::string;
// 类声明
class HeightMap;
//------------------------
// ImageLoad纹理文件载入类
//------------------------
class ImageLoad
{
// 友元声明
//friend GLboolean HeightMap::LoadTerrainTextureTile(const string &texturePath);
friend class HeightMap;
public:
// 文件类型
enum FileType{ PCX, BMP, TGA, JPG, INVALID };
// 缺省构造函数
ImageLoad();
// 复制构造函数
ImageLoad(const ImageLoad &rhs);
// "="操作符
ImageLoad &operator =(const ImageLoad &rhs);
// 析构函数
~ImageLoad()
{
CleanUp();
}
// 生成TGA纹理
GLboolean GenerateTexture(const string &texturePath);
// 释放资源
GLvoid CleanUp();
// 设置指定位置纹理像素的颜色值
GLvoid SetPositionPixelColor(GLint x, GLint y, GLubyte red, GLubyte green, GLubyte blue);
// 返回指定位置纹理像素的颜色值
GLvoid GetPositionPixelColor(GLint x, GLint y, GLubyte &red, GLubyte &green, GLubyte &blue) const;
// 返回纹理标识
GLuint GetTextureID() const
{
return m_uiTextureID;
}
// 返回纹理宽度
GLint GetWidth() const;
// 返回纹理高度
GLint GetHeight() const;
private:
// 私有操作
// 检测纹理文件类型
GLboolean CheckFileType();
// 载入纹理文件
GLboolean LoadTexture();
// 载入Pcx纹理文件
GLboolean LoadPcxTexture();
// 拷贝控制辅助函数
GLvoid CopyCnotrol(const ImageLoad &rhs);
string m_strTexturePath; // 纹理文件路径
GLuint m_uiTextureID; // 纹理标识
FileType m_FileType; // 纹理文件类型
// 如果当纹理文件类型为Bmp,Tga,Jpg时此成员才起作用
SDL_Surface *m_pTextureSurface; // 纹理表面
// 如果当纹理文件类型为PCX时下列成员才起作用
GLubyte *m_pData; // 纹理数据
GLint m_iWidth; // 纹理的宽度(以像素为单位)
GLint m_iHeight; // 纹理的高度(以像素为单位)
};
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -