SDL_RenderCopy issues on Mac OS X

Hey all! First time poster here, so please show a little bit of mercy

I have a game project that I’m developing on Mac OS X (10.8.5, Mountain Lion) with Xcode 5 in which I’m having some rendering issues. What’s happening is that every so many executions (when I re-build and run), some of the textures (sprites) aren’t rendering on-screen. What’s very odd is the Load_IMG() calls never throw an error on the times they don’t appear.

Thinking that maybe it was a problem with me making multiple SDL_RenderCopy(Ex) calls against the primary rendering target each frame, I changed my code to set the target to a backbuffer SDL_Texture, render everything against that, and switch the target back before calling SDL_RenderPresent and giving it my buffer.

For the sake of context, this is the Draw() method’s implementation:

Code:
// Set the canvas as our primary rendering target
if (SDL_SetRenderTarget(this->pRenderer, this->pBackBuffer) != 0)
{
std::cout << "SDL_SetRenderTarget(a) Error: " << SDL_GetError() << std::endl;
}

// Begin drawing by clearing the screen
SDL_SetRenderDrawColor(this->pRenderer, 0, 0, 0, 255);
SDL_RenderClear(this->pRenderer);

// Draw Tilemaps
for (std::vector<Tilemap *>::iterator tIter=this->pTilemaps.begin(); tIter != this->pTilemaps.end(); ++tIter)
{
    // Get the dimensions of the Tilemap
    int rows = (*tIter)->GetNumRows();
    int columns = (*tIter)->GetNumColumns();
    
    // Get the Tilesheet and some of its attributes
    Tilesheet *tilesheet = (*tIter)->GetTilesheet();
    SDL_Texture *tilesheetTex = tilesheet->GetTexture();
    int tileSize = tilesheet->GetTileSize();
    
    for (int r=0; r < rows; r++)
    {
        for (int c=0; c < columns; c++)
        {
            int tileIndex = (*tIter)->GetTileKeyAtIntersection(r, c);
            Tile *tile = tilesheet->GetTileAtIndex(tileIndex);
            
            // the source SDL_Rect structure or NULL for the entire texture
            SDL_Rect srcRect;
            srcRect.x = (tile->GetColumn() * tileSize);
            srcRect.y = (tile->GetRow() * tileSize);
            srcRect.w = tileSize;
            srcRect.h = tileSize;
            
            // the destination SDL_Rect structure or NULL for the entire rendering target
            SDL_Rect dstRect;
            dstRect.x = (c * tileSize);
            dstRect.y = (r * tileSize);
            dstRect.w = tileSize;
            dstRect.h = tileSize;
            
            if (SDL_RenderCopy(this->pRenderer, tilesheetTex, &srcRect, &dstRect) != 0)
            {
                std::cout << "(Tilemap) SDL_RenderCopy Error: " << SDL_GetError() << std::endl;
            }
        }
    }
}

// Draw active Sprites
for (std::vector<Sprite *>::iterator sIter=this->pSprites.begin(); sIter != this->pSprites.end(); ++sIter)
{
    // Get the Sprite's positional and texture rects
    SDL_Rect texRect = (*sIter)->GetTexRect();
    SDL_Rect srcRect = (*sIter)->GetSrcRect();
    
    // Render a texture to the screen
    if (SDL_RenderCopyEx(this->pRenderer, (*sIter)->GetTexture(), &texRect, &srcRect, (*sIter)->GetAngle(), NULL, SDL_FLIP_NONE) != 0)
    {
        std::cout << "(Sprite) SDL_RenderCopy Error: " << SDL_GetError() << std::endl;
    }
}


if (SDL_SetRenderTarget(this->pRenderer, NULL) != 0)
{
    std::cout << "SDL_SetRenderTarget(b) Error: " << SDL_GetError() << std::endl;
}

SDL_RenderCopy(this->pRenderer, this->pBackBuffer, NULL, NULL);

// Flip the frame buffer
SDL_RenderPresent(this->pRenderer);

Have I encountered a known bug with SDL_RenderCopyEx or SDL_RenderCopy on Mac with textures from PNG files that have transparent backgrounds? Or am I just a poor, unlucky chump? :frowning: