AI代码解释 voidLTexture::setColor(Uint8 red,Uint8 green,Uint8 blue){//调制纹理SDL_SetTextureColorMod(mTexture,red,green,blue);} 设置纹理调制就像调用SDL_SetTextureColorMod[1]一样简单。你只需传入你想调制的纹理和你想调制的颜色。 现在颜色调制是如何工作的呢?假设你有这样的纹理: 然后你用红色255...
要设置纹理的透明度,可以使用SDL_SetTextureAlphaMod函数: Uint8 alpha = 128; // 透明度取值范围为0-255,0为完全透明,255为不透明SDL_SetTextureAlphaMod(texture, alpha); 设置纹理颜色调制 要设置纹理的颜色调制,可以使用SDL_SetTextureColorMod函数: Uint8 r = 255, g = 255, b = 255; // 设置纹理颜...
方法/步骤 1 利用上节课的代码和图片,修改部分代码,见下图红色标记。2 第12行:修改了texture渲染的混合模式(添加颜色模式)。第13行:SDL_SetTextureColorMode是设置添加颜色的函数。函数参数:后三个参数分别是r(红red)、g(绿green)、b(蓝blue)的值。3 运行结果。相比之前的图片,确实有些变了颜色。...
Uint8 g, Uint8 b){SDL_SetTextureColorMod(m_Texture, r, g, b);}// 设置纹理透明度voidSetAlpha(Uint8 alpha){SDL_SetTextureAlphaMod(m_Texture, alpha);}// 设置混合模式voidSetBlendMode
Setting the texture scale mode will apply retroactively on that texture to all previous render copy calls up to the previous call to render present. This is illustrated with the below code. Shows comparison between scale mode and other properties. the color mod doesn't act this way. ...
SDL_Color textColor= {255,255,255}; intmain(intargc,char*args[] ) { //Start SDL boolquit=false; SDL_Init( SDL_INIT_EVERYTHING ); if(TTF_Init()==-1) returnfalse; screen=SDL_SetVideoMode(600,480, SCREEN_BPP, SDL_SWSURFACE ); ...
/* Define the SDL renderer structure */struct SDL_Renderer{constvoid*magic;void(*WindowEvent)(SDL_Renderer*renderer,constSDL_WindowEvent*event);int(*GetOutputSize)(SDL_Renderer*renderer,int*w,int*h);int(*CreateTexture)(SDL_Renderer*renderer,SDL_Texture*texture);int(*SetTextureColorMod)(SDL_Re...
SDL_GetTextureAlphaMod y SDL_GetTextureBlendMode y SDL_GetTextureColorMod y SDL_GetTextureScaleMode y 2.0.12 SDL_GetTextureUserData n 2.0.18 SDL_GL_BindTexture y SDL_GL_UnbindTexture y SDL_LockTexture y SDL_LockTextureToSurface n 2.0.12 SDL_QueryTexture y SDL_RenderClear y ...
int (*SetTextureColorMod) (SDL_Renderer * renderer, SDL_Texture * texture); int (*SetTextureAlphaMod) (SDL_Renderer * renderer, SDL_Texture * texture); int (*SetTextureBlendMode) (SDL_Renderer * renderer, SDL_Texture * texture);
SDL_SetSurfaceColorMod(surface, 255, 255, 0);//SDL_BlitSurface(sur1,NULL,surface,&re);SDL_Texture *tex = SDL_CreateTextureFromSurface(ren, surface);SDL_FreeSurface(surface); SDL_RenderClear(ren);//Draw the textureSDL_RenderCopy(ren, tex, NULL, NULL);bool quit = false;//Event handler...