修改底层渲染为OpenGL
This commit is contained in:
@@ -1,33 +1,59 @@
|
||||
#pragma once
|
||||
|
||||
#include <SDL.h>
|
||||
#include <SDL_image.h>
|
||||
#include <glad/glad.h>
|
||||
#include <string>
|
||||
#include "Tool/RefPtr.h"
|
||||
#include "Tool/Common.h"
|
||||
#include "Tool/RefObject.h"
|
||||
#include "Tool/RefPtr.h"
|
||||
#include "Tool/IntrusiveList.hpp"
|
||||
|
||||
class Texture : public RefObject
|
||||
{
|
||||
private:
|
||||
SDL_Texture *m_texture = nullptr;
|
||||
std::string ImgPath = "";
|
||||
int Index = 0;
|
||||
public:
|
||||
VecSize TextureSize = {0, 0}; // 纹理大小
|
||||
VecPos TexturePos = {0, 0}; // 纹理位置
|
||||
VecSize TextureFramepos = {0, 0}; // 帧域宽高
|
||||
// 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(std::string PngPath);
|
||||
Texture(std::string imgPath, int Index);
|
||||
~Texture();
|
||||
Texture(const Texture &) = delete;
|
||||
Texture &operator=(const Texture &) = delete;
|
||||
|
||||
public:
|
||||
void SetBlendMode(SDL_BlendMode blendMode);
|
||||
// 获取混合模式
|
||||
SDL_BlendMode GetBlendMode();
|
||||
// 获取纹理
|
||||
SDL_Texture *GetTexture();
|
||||
// 获取一个拷贝的纹理
|
||||
RefPtr<Texture> GetTextureCopy();
|
||||
// 获取纹理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);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user