60 lines
1.5 KiB
C++
60 lines
1.5 KiB
C++
#pragma once
|
|
#include <SDL.h>
|
|
#include <SDL_image.h>
|
|
#include <glad/glad.h>
|
|
#include <string>
|
|
#include "Tool/Common.h"
|
|
#include "Tool/RefObject.h"
|
|
#include "Tool/RefPtr.h"
|
|
#include "Tool/IntrusiveList.hpp"
|
|
|
|
class Texture : public RefObject
|
|
{
|
|
private:
|
|
// OpenGL 纹理ID
|
|
GLuint m_TextureID;
|
|
// 纹理大小
|
|
VecSize m_TextureSize;
|
|
// 帧域大小
|
|
VecSize m_FrameSize;
|
|
// 纹理坐标
|
|
VecPos m_TexturePos;
|
|
// 纹理透明度
|
|
float m_Alpha = 1.0f;
|
|
|
|
// 纹理路径
|
|
std::string m_Path;
|
|
// 纹理编号(可选 在使用img构造时才会有编号)
|
|
int m_TextureIndex = -1;
|
|
|
|
public:
|
|
Texture(/* args */);
|
|
~Texture();
|
|
Texture(const Texture &) = delete;
|
|
Texture &operator=(const Texture &) = delete;
|
|
|
|
public:
|
|
// 获取纹理ID
|
|
GLuint getID() const { return m_TextureID; }
|
|
// 设置纹理透明度
|
|
void setAlpha(float alpha) { m_Alpha = alpha; }
|
|
// 获取纹理透明度
|
|
float getAlpha() const { return m_Alpha; }
|
|
// 获取纹理大小
|
|
VecSize getSize() const { return m_TextureSize; }
|
|
// 获取纹理坐标
|
|
VecPos getPos() const { return m_TexturePos; }
|
|
// 获取纹理路径
|
|
std::string getPath() const { return m_Path; }
|
|
// 获取纹理编号
|
|
int getIndex() const { return m_TextureIndex; }
|
|
// 获取帧域大小
|
|
VecSize getFrameSize() const { return m_FrameSize; }
|
|
|
|
public:
|
|
bool Init(std::string PngPath);
|
|
bool Init(std::string ImgPath, int index);
|
|
bool Init(SDL_Surface *surface);
|
|
bool Init(VecSize size);
|
|
};
|