mirror of
https://github.com/Kiritow/MiniEngine.git
synced 2024-03-22 13:11:22 +08:00
Add Texture-like functions in class Surface
This commit is contained in:
parent
a2a3e493c5
commit
3043ae0684
|
@ -295,6 +295,75 @@ namespace MiniEngine
|
|||
return SDL_BlitSurface(s._get(),NULL,_get(),NULL);
|
||||
}
|
||||
|
||||
int Surface::setAlphaMode(int alpha)
|
||||
{
|
||||
return SDL_SetSurfaceAlphaMod(_get(),alpha);
|
||||
}
|
||||
|
||||
int Surface::getAlphaMode()
|
||||
{
|
||||
Uint8 al;
|
||||
SDL_GetSurfaceAlphaMod(_get(),&al);
|
||||
return al;
|
||||
}
|
||||
|
||||
int Surface::setColorMode(ColorMode mode)
|
||||
{
|
||||
return SDL_SetSurfaceColorMod(_get(),mode.r,mode.g,mode.b);
|
||||
}
|
||||
|
||||
ColorMode Surface::getColorMode()
|
||||
{
|
||||
Uint8 r,g,b;
|
||||
SDL_GetSurfaceColorMod(_get(),&r,&g,&b);
|
||||
ColorMode mode;
|
||||
mode.r=r;
|
||||
mode.g=g;
|
||||
mode.b=b;
|
||||
return mode;
|
||||
}
|
||||
|
||||
void Surface::setRGBA(RGBA pack)
|
||||
{
|
||||
setColorMode(pack.toColorMode());
|
||||
setAlphaMode(pack.a);
|
||||
}
|
||||
|
||||
RGBA Surface::getRGBA()
|
||||
{
|
||||
return RGBA(getColorMode(),getAlphaMode());
|
||||
}
|
||||
|
||||
bool Surface::mustlock()
|
||||
{
|
||||
return SDL_MUSTLOCK(_get());
|
||||
}
|
||||
|
||||
int Surface::lock()
|
||||
{
|
||||
return SDL_LockSurface(_get());
|
||||
}
|
||||
|
||||
void Surface::unlock()
|
||||
{
|
||||
SDL_UnlockSurface(_get());
|
||||
}
|
||||
|
||||
//static
|
||||
Surface Surface::createSurface(int width,int height,int depth,int Rmask,int Gmask,int Bmask,int Amask) throw(ErrorViewer)
|
||||
{
|
||||
SDL_Surface* temp=SDL_CreateRGBSurface(0,width,height,depth,Rmask,Gmask,Bmask,Amask);
|
||||
if(temp==nullptr)
|
||||
{
|
||||
ErrorViewer e;
|
||||
e.fetch();
|
||||
throw e;
|
||||
}
|
||||
Surface surf;
|
||||
surf._set(temp);
|
||||
return surf;
|
||||
}
|
||||
|
||||
void Texture::_set(SDL_Texture* p)//private
|
||||
{
|
||||
_text.reset(p,SDL_DestroyTexture);
|
||||
|
|
15
MiniEngine.h
15
MiniEngine.h
|
@ -106,6 +106,21 @@ namespace MiniEngine
|
|||
int blitTo(Surface t, Point lupoint);
|
||||
int blitFill(Surface t, Rect src);
|
||||
int blitFullFill(Surface t);
|
||||
|
||||
int setAlphaMode(int alpha);
|
||||
int getAlphaMode();
|
||||
|
||||
ColorMode getColorMode();
|
||||
int setColorMode(ColorMode mode);
|
||||
RGBA getRGBA();
|
||||
void setRGBA(RGBA pack);
|
||||
|
||||
bool mustlock();
|
||||
int lock();
|
||||
void unlock();
|
||||
|
||||
static Surface createSurface(int width,int height,int depth,int Rmask,int Gmask,int Bmask,int Amask) throw(ErrorViewer);
|
||||
|
||||
protected:
|
||||
Surface() = default;
|
||||
private:
|
||||
|
|
Loading…
Reference in New Issue
Block a user