当前位置: 首页>>代码示例>>C++>>正文


C++ SDL_SetTextureColorMod函数代码示例

本文整理汇总了C++中SDL_SetTextureColorMod函数的典型用法代码示例。如果您正苦于以下问题:C++ SDL_SetTextureColorMod函数的具体用法?C++ SDL_SetTextureColorMod怎么用?C++ SDL_SetTextureColorMod使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了SDL_SetTextureColorMod函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: renderRect

void Render_SW_SDL::renderTextureCur(float x, float y, float w, float h, float ani_top, float ani_bottom, float ani_left, float ani_right)
{
    if(!m_currentTexture)
    {
        renderRect(x, y, w, h,
                   (unsigned char)(255.f*color_binded_texture[0]),
                   (unsigned char)(255.f*color_binded_texture[1]),
                   (unsigned char)(255.f*color_binded_texture[2]),
                   (unsigned char)(255.f*color_binded_texture[3]) );
        return;
    }
    SDL_Rect sourceRect = {
        (int)roundf((float)m_currentTextureRect.width()*ani_left),
        (int)roundf((float)m_currentTextureRect.height()*ani_top),
        abs((int)roundf((float)m_currentTextureRect.width()*ani_right)-(int)roundf((float)m_currentTextureRect.width()*ani_left)),
        abs((int)roundf((float)m_currentTextureRect.height()*ani_bottom)-(int)roundf((float)m_currentTextureRect.height()*ani_top))
    };
    SDL_Rect destRect = scaledRect(x, y, w, h);
    SDL_SetTextureColorMod( m_currentTexture,
                            (unsigned char)(255.f*color_binded_texture[0]),
                            (unsigned char)(255.f*color_binded_texture[1]),
                            (unsigned char)(255.f*color_binded_texture[2]));
    SDL_SetTextureAlphaMod( m_currentTexture, (unsigned char)(255.f*color_binded_texture[3]));

    SDL_RenderCopy( m_gRenderer, m_currentTexture, &sourceRect, &destRect );
}
开发者ID:zigurana,项目名称:PGE-Project,代码行数:26,代码来源:render_swsdl.cpp

示例2: _hasTexColor

/**
 * @brief Test to see if can set texture color mode. Helper function.
 *
 * \sa
 * http://wiki.libsdl.org/moin.cgi/SDL_SetTextureColorMod
 * http://wiki.libsdl.org/moin.cgi/SDL_GetTextureColorMod
 * http://wiki.libsdl.org/moin.cgi/SDL_DestroyTexture
 */
static int
_hasTexColor (void)
{
   int fail;
   int ret;
   SDL_Texture *tface;
   Uint8 r, g, b;

   /* Get test face. */
   tface = _loadTestFace();
   if (tface == NULL)
      return 0;

   /* See if supported. */
   fail = 0;
   ret = SDL_SetTextureColorMod( tface, 100, 100, 100 );
   if (!_isSupported(ret))
      fail = 1;
   ret = SDL_GetTextureColorMod( tface, &r, &g, &b );
   if (!_isSupported(ret))
      fail = 1;

   /* Clean up. */
   SDL_DestroyTexture( tface );

   if (fail)
      return 0;
   else if ((r != 100) || (g != 100) || (b != 100))
      return 0;
   return 1;
}
开发者ID:AaronPerl,项目名称:OpenHand,代码行数:39,代码来源:testautomation_render.c

示例3: SDL_SetTextureColorMod

void GfxImage::VSetColor(byte r, byte g, byte b)
{
	m_color.r = r;
	m_color.g = g;
	m_color.b = b;
	SDL_SetTextureColorMod(m_pTexture, r, g, b);
}
开发者ID:Polydash,项目名称:Gomez,代码行数:7,代码来源:GfxImage.cpp

示例4: SDL_SetTextureColorMod

void Sprite::draw()
{
	//scale stuff
    this-> s_width  = this -> width  * this -> scale;
    this-> s_height = this -> height * this -> scale;

	//Set rendering space and render to screen
	this -> rect =
	{ this -> pos . x - ( this -> s_width  / 2 ),
	  this -> pos . y - ( this -> s_height / 2 ),
	  this -> s_width, this -> s_height };

    const SDL_Rect * srcrect2 = & srcrect;
	const SDL_Rect * rect2 = & rect;

	//rotation center stuff
	center = { this -> s_width  / 2,
               this -> s_height / 2};
	SDL_Point * center2 = & center;

	//texture stuff
	SDL_SetTextureColorMod( texture, this -> red, this -> green, this -> blue );
    SDL_SetTextureAlphaMod( this -> texture, this -> alpha );
	//draw
	SDL_RenderCopyEx( renderer, texture, srcrect2, rect2, angle, center2, flip );
}
开发者ID:xianbaum,项目名称:punching-out-cthulhu,代码行数:26,代码来源:Sprite.cpp

示例5: setRenderTexture

void Render_SW_SDL::renderTexture(PGE_Texture *texture, float x, float y, float w, float h, float ani_top, float ani_bottom, float ani_left, float ani_right)
{
    if(!texture) return;

    setRenderTexture( texture->texture );
    m_currentTextureRect.setRect( 0, 0, texture->w, texture->h );

    if(!m_currentTexture)
    {
        renderRect(x, y, w, h,
                   (unsigned char)(255.f*color_binded_texture[0]),
                   (unsigned char)(255.f*color_binded_texture[1]),
                   (unsigned char)(255.f*color_binded_texture[2]),
                   (unsigned char)(255.f*color_binded_texture[3]) );
        return;
    }

    SDL_Rect sourceRect = { (int)roundf((float)texture->w*ani_left), (int)roundf((float)texture->h*ani_top),
                            (int)roundf((float)texture->w*ani_right)-(int)roundf((float)texture->w*ani_left),
                            (int)roundf((float)texture->h*ani_bottom)-(int)roundf((float)texture->h*ani_top)
    };
    SDL_Rect destRect = scaledRect(x, y, w, h);
    SDL_SetTextureColorMod( m_currentTexture,
                            (unsigned char)(255.f*color_binded_texture[0]),
                            (unsigned char)(255.f*color_binded_texture[1]),
                            (unsigned char)(255.f*color_binded_texture[2]));
    SDL_SetTextureAlphaMod( m_currentTexture, (unsigned char)(255.f*color_binded_texture[3]));

    SDL_RenderCopy( m_gRenderer, m_currentTexture, &sourceRect, &destRect );
    setUnbindTexture();
}
开发者ID:zigurana,项目名称:PGE-Project,代码行数:31,代码来源:render_swsdl.cpp

示例6: SDL_GetWindowSize

//-------------------------------------------------------------------------------------------------
void Visuals::DrawSpriteOntoScreenBuffer(Uint16 index)
{
SDL_Rect destinationRect;
int windowWidth;
int windowHeight;
Uint32 textureFormat;
int textureAccess;
int textureWidth;
int textureHeight;

    SDL_GetWindowSize(Window, &windowWidth, &windowHeight);

    SDL_QueryTexture(Sprites[index].Texture, &textureFormat, &textureAccess, &textureWidth, &textureHeight);

    float winWidthFixed;
    float winHeightFixed;
    if (ForceAspectRatio == false)
    {
        winWidthFixed = (float)windowWidth / 640;
        winHeightFixed = (float)windowHeight / 480;
    }
    else
    {
        winWidthFixed = 1;
        winHeightFixed = 1;
    }

    destinationRect.x = ( Sprites[index].ScreenX * (winWidthFixed) )
                        - (  ( (textureWidth * Sprites[index].ScaleX) * (winWidthFixed) ) / 2  );
    destinationRect.y = ( Sprites[index].ScreenY * (winHeightFixed) )
                        - (  ( (textureHeight * Sprites[index].ScaleY) * (winHeightFixed) ) / 2  );
    destinationRect.w = textureWidth * Sprites[index].ScaleX * (winWidthFixed);
    destinationRect.h = textureHeight * Sprites[index].ScaleY * (winHeightFixed);

    SDL_SetTextureColorMod(Sprites[index].Texture, Sprites[index].RedHue, Sprites[index].GreenHue, Sprites[index].BlueHue);
    SDL_SetTextureAlphaMod(Sprites[index].Texture, Sprites[index].Transparency);

    if (Sprites[index].FlipX == false && Sprites[index].FlipY == false)
    {
        SDL_RenderCopyEx(Renderer, Sprites[index].Texture, NULL, &destinationRect, Sprites[index].RotationDegree
                         , NULL, SDL_FLIP_NONE);
    }
    else if (Sprites[index].FlipX == true && Sprites[index].FlipY == false)
    {
        SDL_RenderCopyEx(Renderer, Sprites[index].Texture, NULL, &destinationRect, Sprites[index].RotationDegree
                         , NULL, SDL_FLIP_HORIZONTAL);
    }
    else if (Sprites[index].FlipX == false && Sprites[index].FlipY == true)
    {
        SDL_RenderCopyEx(Renderer, Sprites[index].Texture, NULL, &destinationRect, Sprites[index].RotationDegree
                         , NULL, SDL_FLIP_VERTICAL);
    }
    else if (Sprites[index].FlipX == true && Sprites[index].FlipY == true)
    {
        double flipHorizontallyAndVerticallyDegreeFix = Sprites[index].RotationDegree+180;

        SDL_RenderCopyEx(Renderer, Sprites[index].Texture, NULL, &destinationRect, flipHorizontallyAndVerticallyDegreeFix
                         , NULL, SDL_FLIP_NONE);
    }
}
开发者ID:JeZ-l-Lee,项目名称:LastDefense2100Percent,代码行数:61,代码来源:visuals.cpp

示例7: CBlock

void CApp::ResetMap(int mapIndex) {
    // remove all blocks
    for (auto itr = CBlock::BlockList.begin(); itr != CBlock::BlockList.end(); itr++) {
        CBlock* pBlock = *itr;
        if (pBlock) {
            pBlock->OnMove(-MAP_W, -MAP_H); // this will reset the tile if it was on its home
            delete pBlock;
        }
    }
    CBlock::BlockList.clear();

    CurrentMap = mapIndex;
    if (CurrentMap > highestLevel)
        highestLevel = CurrentMap;
    CMap* pMap = maps[mapIndex];
    ActionJackson.SetLoc(pMap->startX, pMap->startY);
    ActionJackson.map = pMap;
    ActionJackson.ClearUndoList();

    // place all blocks
    for (int i = 0; i < pMap->startBlocks.size(); i++) {
        SDL_Point p = pMap->startBlocks[i];
        CBlock* pBlock = new CBlock(p.x, p.y, pMap);
        pBlock->SetSpriteSheet(block);
        pBlock->OnMove(0, 0); // this will make the tile change to HOMEWITHBLOCK if applicable
        CBlock::BlockList.push_back(pBlock);
    }

    // add some flavor
    Uint8 redness = 2*(Uint8)CurrentMap;
    SDL_SetTextureColorMod(Texture, 255, 255 - redness, 255 - redness);
}
开发者ID:RKJokela,项目名称:rjSokoban,代码行数:32,代码来源:CApp.cpp

示例8: SDL_SetTextureColorMod

 void Sprite::setColor(int newR, int newG, int newB)
 {
     r = newR;
     g = newG;
     b = newB;
     SDL_SetTextureColorMod(texture, r, g, b);
 }
开发者ID:Sourec,项目名称:Infscroll-Comic,代码行数:7,代码来源:Sprite.cpp

示例9: IMG_Load

    void Sprite::loadFromFile(string path, bool blending)
    {
        SDL_Surface* surface = IMG_Load(path.c_str());
        if (surface == NULL)
        {
            cout << "ERROR: " << IMG_GetError() << endl;
            return;
        }
        texture = SDL_CreateTextureFromSurface(renderer, surface);
        if (texture == NULL)
            cout << "ERROR: " << SDL_GetError() << endl;

        SDL_QueryTexture(texture, NULL, NULL, &w, &h);
        scale.w = w;
        scale.h = h;
        clip.x = 0;
        clip.y = 0;
        clip.h = h;
        clip.w = w;
        angle = 0;
        center.x = w / 2;
        center.y = h / 2;
        SDL_SetTextureColorMod(texture, r, g, b);
        setBlending(blending);
        SDL_FreeSurface(surface);
    }
开发者ID:Sourec,项目名称:Infscroll-Comic,代码行数:26,代码来源:Sprite.cpp

示例10: CPNullCheck

void
SDLRenderer::renderTexture(TextureProtocol* texture,
                           const vec2& position,
                           const vec2& anchor,
                           const vec2& scale,
                           float angle) {
    
    SDLTexture* _sdl = (SDLTexture*)texture;
    CPNullCheck(_sdl);
    
    // process source and destination rectangles.
    
    
    auto _rot = AffineTransform::rotationFromMatrix(_origin);
    auto _scale = AffineTransform::scaleFromMatrix(_origin);
    auto _pos = AffineTransform::applyTransform(_origin *
                                                AffineTransform::translate2D(position),
                                                vec2{0, 0});
    
    auto t = AffineTransform::translate2D(_pos) *
             AffineTransform::scale2D(_scale * vec2{fabsf(scale.x), fabsf(scale.y)});
    
    Rect destination = AffineTransform::applyTransform(t, Rect{
        -anchor.x * float(texture->clippingQuad().w),
        -anchor.y * float(texture->clippingQuad().h),
        float(texture->clippingQuad().w),
        float(texture->clippingQuad().h),
    });
    
    // prepare SDL types
    SDL_Rect srcRect = rectToSDL(_sdl->clippingQuad());
    SDL_Rect dstRect = rectToSDL(destination);
    SDL_Point center = {int(destination.w * anchor.x), int(destination.h * anchor.y)};
    
    // flip according to scale.
    int flip = SDL_FLIP_NONE;
    if(scale.x < 0) {
        flip |= SDL_FLIP_HORIZONTAL;
    }
    if(scale.y < 0) {
        flip |= SDL_FLIP_VERTICAL;
    }
    
    // SDL_Renderer calls
    SDL_SetTextureAlphaMod(_sdl->_hwTexture->raw(), _sdl->alpha() * 255);
    SDL_SetTextureColorMod(_sdl->_hwTexture->raw(),
                           _sdl->color().red * 255,
                           _sdl->color().green * 255,
                           _sdl->color().blue * 255);
    SDL_SetTextureBlendMode(_sdl->_hwTexture->raw(), sdlBlendMode(_sdl->blendMode()));
    
    SDL_RenderCopyEx(_renderer,
                     _sdl->_hwTexture->raw(),
                     &srcRect,
                     &dstRect,
                     -degrees(angle-_rot),
                     &center,
                     (SDL_RendererFlip)flip);
}
开发者ID:cesarparent,项目名称:Meteor,代码行数:59,代码来源:SDLRenderer.cpp

示例11: Item

Pill::Pill(Field* field, Vector2 position, SDL_Color color) : Item(field, position)
{
	SDL_Texture* texture = FWApplication::GetInstance()->LoadTexture("pill.png");
	SDL_SetTextureColorMod(texture, color.r, color.g, color.b);

	SetTexture(texture);
	SetSize(50, 50);
}
开发者ID:engineer-murataydin,项目名称:Kunstmatige-Inelligentie-KMINT-,代码行数:8,代码来源:Pill.cpp

示例12: apply_texture

void apply_texture( int x, int y, int width, int height, SDL_Texture* source, double angle, Color color)
{
    //Make a temporary rectangle to hold the offsets
  SDL_Rect renderQuad = {x, y, width, height};
  //add the texture
  SDL_SetTextureColorMod(source, color.r, color.g, color.b); 
  SDL_RenderCopyEx( renderer, source, NULL, &renderQuad, angle, NULL, SDL_FLIP_NONE);
}
开发者ID:nrs02004,项目名称:planeGame,代码行数:8,代码来源:display.cpp

示例13: int

void Enemy::Render()
{
    SDL_Rect r = { int(x)*SCREEN_MUL, int(y)*SCREEN_MUL,
                   width*SCREEN_MUL, height*SCREEN_MUL };
    Color c = level.Color();
    SDL_SetTextureColorMod(text.get(), c.r, c.g, c.b);
    SDL_RenderCopy(renderer, text.get(), nullptr, &r);
}
开发者ID:DirtYiCE,项目名称:mmmmmm,代码行数:8,代码来源:enemy.cpp

示例14: d_define_method_override

d_define_method_override(label, set_maskRGB)(struct s_object *self, unsigned int red, unsigned int green, unsigned int blue) {
	d_using(label);
	label_attributes->last_mask_R = red;
	label_attributes->last_mask_G = green;
	label_attributes->last_mask_B = blue;
	SDL_SetTextureColorMod(label_attributes->image, red, green, blue);
	return self;
}
开发者ID:haifenghuang,项目名称:miranda,代码行数:8,代码来源:label.obj.c

示例15: SDL_SetTextureColorMod

void StationSprite::render(SDL_Renderer* sdl_renderer, const Camera& camera, const Station& station) const
{
	SDL_Rect station_rect = 
	{ 
		renderutil::getScreenXForEntityByCameraAndDistance(station.current_state.pos.x*_scaling, _station_texture.rect.w*_scaling, renderer->width, camera, 1.0), 
		world->ship_limits.h * _scaling - _station_texture.rect.h * _scaling,
		_station_texture.rect.w*_scaling,
		_station_texture.rect.h*_scaling
	};

	if (station.is_docked)
		SDL_SetTextureColorMod(_station_texture.texture, 0, 0, 0);
	else
		SDL_SetTextureColorMod(_station_texture.texture, 255, 255, 255);

	SDL_RenderCopy(sdl_renderer, _station_texture.texture, &_station_texture.rect, &station_rect);
}
开发者ID:gavinschultz,项目名称:starblaze2013,代码行数:17,代码来源:StationSprite.cpp


注:本文中的SDL_SetTextureColorMod函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。