~ Initial SDL2 implementation
Limitation - Dependent projects need to set NAZARA_PLATFORM_SDL2 if nazara has been build with SDL2 since OpenGL.hpp (and maybe some other headers) exposes platform details - SDL2 window doesn't supports async window since the API isn't fitting for now - Contexts parameters can't be changed until we close all the SDL windows (SDL limitation)
This commit is contained in:
49
src/Nazara/Platform/SDL2/IconImpl.cpp
Normal file
49
src/Nazara/Platform/SDL2/IconImpl.cpp
Normal file
@@ -0,0 +1,49 @@
|
||||
// Copyright (C) 2017 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Platform module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/Platform/Debug.hpp>
|
||||
#include <Nazara/Platform/SDL2/IconImpl.hpp>
|
||||
#include <Nazara/Utility/Image.hpp>
|
||||
#include <Nazara/Utility/PixelFormat.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
bool IconImpl::Create(const Image& icon)
|
||||
{
|
||||
m_iconImage = icon;
|
||||
if (!m_iconImage.Convert(PixelFormatType_BGRA8))
|
||||
{
|
||||
NazaraError("Failed to convert icon to BGRA8");
|
||||
return false;
|
||||
}
|
||||
|
||||
m_icon = SDL_CreateRGBSurfaceWithFormatFrom(
|
||||
m_iconImage.GetPixels(),
|
||||
m_iconImage.GetWidth(),
|
||||
m_iconImage.GetHeight(),
|
||||
32,
|
||||
32 * m_iconImage.GetWidth(),
|
||||
SDL_PIXELFORMAT_BGRA8888
|
||||
);
|
||||
|
||||
if (!m_icon)
|
||||
{
|
||||
NazaraError(SDL_GetError());
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void IconImpl::Destroy()
|
||||
{
|
||||
SDL_FreeSurface(m_icon);
|
||||
m_iconImage.Destroy();
|
||||
}
|
||||
|
||||
SDL_Surface* IconImpl::GetIcon()
|
||||
{
|
||||
return m_icon;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user