修改OpenGl渲染底层之前
This commit is contained in:
@@ -33,6 +33,8 @@ Texture::Texture(std::string PngPath)
|
||||
|
||||
Texture::Texture(std::string imgPath, int Index)
|
||||
{
|
||||
this->ImgPath = imgPath;
|
||||
this->Index = Index;
|
||||
Asset_ImagePack::IMG *Info = Asset_ImagePack::GetInstance().GetIMG(imgPath);
|
||||
if (Info->lpImgName == "sprite/interface/base.img")
|
||||
return;
|
||||
@@ -50,7 +52,7 @@ Texture::Texture(std::string imgPath, int Index)
|
||||
int pitch = Buf.Width * 4;
|
||||
SDL_UpdateTexture(m_texture, NULL, Buf.PNGdata, pitch);
|
||||
SDL_SetTextureBlendMode(m_texture, SDL_BLENDMODE_BLEND);
|
||||
SDL_SetTextureScaleMode(m_texture, SDL_ScaleModeBest);
|
||||
SDL_SetTextureScaleMode(m_texture, SDL_ScaleModeNearest);
|
||||
|
||||
this->TexturePos.x = Buf.Xpos;
|
||||
this->TexturePos.y = Buf.Ypos;
|
||||
@@ -70,6 +72,12 @@ SDL_Texture *Texture::GetTexture()
|
||||
return m_texture;
|
||||
}
|
||||
|
||||
RefPtr<Texture> Texture::GetTextureCopy()
|
||||
{
|
||||
RefPtr<Texture> nt = new Texture(this->ImgPath, this->Index);
|
||||
return nt;
|
||||
}
|
||||
|
||||
void Texture::SetBlendMode(SDL_BlendMode blendMode)
|
||||
{
|
||||
SDL_SetTextureBlendMode(m_texture, blendMode);
|
||||
|
||||
@@ -9,7 +9,8 @@ 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}; // 纹理位置
|
||||
@@ -25,5 +26,8 @@ public:
|
||||
void SetBlendMode(SDL_BlendMode blendMode);
|
||||
// 获取混合模式
|
||||
SDL_BlendMode GetBlendMode();
|
||||
SDL_Texture *GetTexture(); // 获取纹理
|
||||
// 获取纹理
|
||||
SDL_Texture *GetTexture();
|
||||
// 获取一个拷贝的纹理
|
||||
RefPtr<Texture> GetTextureCopy();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user