|
|
@@ -150,6 +150,7 @@ bool CheckExtension(String& extensions, const String& name)
|
|
|
Graphics::Graphics(Context* context_) :
|
|
|
Object(context_),
|
|
|
impl_(new GraphicsImpl()),
|
|
|
+ windowIcon_(0),
|
|
|
externalWindow_(0),
|
|
|
width_(0),
|
|
|
height_(0),
|
|
|
@@ -212,6 +213,15 @@ void Graphics::SetWindowTitle(const String& windowTitle)
|
|
|
SDL_SetWindowTitle(impl_->window_, windowTitle_.CString());
|
|
|
}
|
|
|
|
|
|
+void Graphics::SetWindowIcon(Image* windowIcon)
|
|
|
+{
|
|
|
+ windowIcon_ = windowIcon;
|
|
|
+ if (impl_->window_)
|
|
|
+ {
|
|
|
+ CreateWindowIcon();
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
void Graphics::SetWindowPosition(const IntVector2& position)
|
|
|
{
|
|
|
if (impl_->window_)
|
|
|
@@ -356,6 +366,8 @@ bool Graphics::SetMode(int width, int height, bool fullscreen, bool resizable, b
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ CreateWindowIcon();
|
|
|
|
|
|
// Create/restore context and GPU objects and set initial renderstate
|
|
|
Restore();
|
|
|
@@ -2386,6 +2398,29 @@ unsigned Graphics::GetFormat(const String& formatName)
|
|
|
return GetRGBFormat();
|
|
|
}
|
|
|
|
|
|
+void Graphics::CreateWindowIcon()
|
|
|
+{
|
|
|
+ if (windowIcon_)
|
|
|
+ {
|
|
|
+ SDL_Surface* surface = SDL_CreateRGBSurface(0, windowIcon_->GetWidth(), windowIcon_->GetHeight(), windowIcon_->GetComponents() * BITS_PER_COMPONENT, 0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000);
|
|
|
+
|
|
|
+ if (windowIcon_->GetMemoryUse() > 0)
|
|
|
+ {
|
|
|
+ SDL_LockSurface(surface);
|
|
|
+ memcpy(surface->pixels, windowIcon_->GetData(), windowIcon_->GetMemoryUse());
|
|
|
+ SDL_UnlockSurface(surface);
|
|
|
+
|
|
|
+ SDL_SetWindowIcon(impl_->window_, surface);
|
|
|
+ }
|
|
|
+
|
|
|
+ SDL_FreeSurface(surface);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ LOGERROR("Unable to load icon windowIcon_ " + windowIcon_->GetName());
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
void Graphics::CheckFeatureSupport(String& extensions)
|
|
|
{
|
|
|
// Check supported features: light pre-pass, deferred rendering and hardware depth texture
|