Thats not really an irrlicht issue. Its a OS issue. How you would go about doing that would change on every OS. The same method might not even work on different versions of Windows.
If you dive into the Windows API, there is a function called GetWindowRect (https://learn.microsoft.com/en-us/windo ... windowrect) and GetClientRect(https://learn.microsoft.com/en-us/windo ... clientrect). If you subtract those 2 you should get the size of the title bar. It may not be something your application can change.
This is something that you would need to research for different OSes as it has nothing to do with Irrlicht.
[VISUAL STUDIO] How to change the height of a title bar?
Re: [VISUAL STUDIO] How to change the height of a title bar?
Tiny bit Irrlicht as you need the HWND for the Windows API functions. You can get that with IVideoDriver::getExposedVideoData().
And maybe Irrlicht should start offering a new fullscreen-mode with hidden title-bar. I read just a few days ago most fullscreen games do that by now as the old style Irrlicht still does for fullscreen isn't really working that well anymore with modern systems.
And maybe Irrlicht should start offering a new fullscreen-mode with hidden title-bar. I read just a few days ago most fullscreen games do that by now as the old style Irrlicht still does for fullscreen isn't really working that well anymore with modern systems.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Re: [VISUAL STUDIO] How to change the height of a title bar?
That was my mistake. Thanks for the clarification.CuteAlien wrote: ↑Sun May 05, 2024 10:33 am Tiny bit Irrlicht as you need the HWND for the Windows API functions. You can get that with IVideoDriver::getExposedVideoData().
And maybe Irrlicht should start offering a new fullscreen-mode with hidden title-bar. I read just a few days ago most fullscreen games do that by now as the old style Irrlicht still does for fullscreen isn't really working that well anymore with modern systems.
As a note on the fullscreen, SDL2 has this feature. You just need to set SDL_WINDOW_FULLSCREEN_DESKTOP as one of your window flags. Here is the SDL2 device I am using. You can see the flag when the contructor is called.
(Its a pretty lazy conversion from the SDL1 device. I just changed the SDL_SetVideoMode() lines to SDL_CreateWindow() and added the SDL_Window and SDL_GLContext fields to the header. I added 1 line to the OpenGL driver to create the SDL_GLContext there but I probably should have just made it here.)
CIrrDeviceSDL.cpp
Code: Select all
// Copyright (C) 2002-2012 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#include "IrrCompileConfig.h"
#ifdef _IRR_COMPILE_WITH_SDL_DEVICE_
#include "CIrrDeviceSDL.h"
#include "IEventReceiver.h"
#include "irrList.h"
#include "os.h"
#include "CTimer.h"
#include "irrString.h"
#include "Keycodes.h"
#include "COSOperator.h"
#include <stdio.h>
#include <stdlib.h>
#include "SIrrCreationParameters.h"
#include <SDL2/SDL.h>
#include <SDL2/SDL_syswm.h>
#include <SDL2/SDL_video.h>
#ifdef _MSC_VER
#pragma comment(lib, "SDL.lib")
#endif // _MSC_VER
namespace irr
{
namespace video
{
#ifdef _IRR_COMPILE_WITH_DIRECT3D_8_
IVideoDriver* createDirectX8Driver(const irr::SIrrlichtCreationParameters& params,
io::IFileSystem* io, HWND window);
#endif
#ifdef _IRR_COMPILE_WITH_DIRECT3D_9_
IVideoDriver* createDirectX9Driver(const irr::SIrrlichtCreationParameters& params,
io::IFileSystem* io, HWND window);
#endif
#ifdef _IRR_COMPILE_WITH_OPENGL_
IVideoDriver* createOpenGLDriver(const SIrrlichtCreationParameters& params,
io::IFileSystem* io, CIrrDeviceSDL* device);
#endif
} // end namespace video
} // end namespace irr
namespace irr
{
//! constructor
CIrrDeviceSDL::CIrrDeviceSDL(const SIrrlichtCreationParameters& param)
: CIrrDeviceStub(param),
window((SDL_Window*)param.WindowId), SDL_Flags(SDL_WINDOW_SHOWN),
MouseX(0), MouseY(0), MouseButtonStates(0),
Width(param.WindowSize.Width), Height(param.WindowSize.Height),
Resizable(false), WindowMinimized(false)
{
//os::Printer::Logger->setLogLevel(ELL_NONE);
#ifdef _DEBUG
setDebugName("CIrrDeviceSDL");
#endif
// Initialize SDL... Timer for sleep, video for the obvious, and
// noparachute prevents SDL from catching fatal errors.
if (SDL_Init( SDL_INIT_TIMER|SDL_INIT_VIDEO|
#if defined(_IRR_COMPILE_WITH_JOYSTICK_EVENTS_)
SDL_INIT_JOYSTICK|
#endif
SDL_INIT_NOPARACHUTE ) < 0)
{
os::Printer::log( "Unable to initialize SDL!", SDL_GetError());
Close = true;
}
#if defined(_IRR_WINDOWS_)
SDL_setenv("SDL_VIDEODRIVER", "directx", 1);
#elif defined(_IRR_OSX_PLATFORM_)
SDL_setenv("SDL_VIDEODRIVER", "Quartz", 1);
#else
SDL_setenv("SDL_VIDEODRIVER", "x11", 1);
#endif
// SDL_putenv("SDL_WINDOWID=");
SDL_version version_info;
SDL_GetVersion(&version_info);
core::stringc sdlversion = "SDL Version ";
sdlversion += version_info.major;
sdlversion += ".";
sdlversion += version_info.minor;
sdlversion += ".";
sdlversion += version_info.patch;
Operator = new COSOperator(sdlversion);
os::Printer::log(sdlversion.c_str(), ELL_INFORMATION);
// create keymap
createKeyMap();
// enable key to character translation
//SDL_EnableUNICODE(1);
//(void)SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
if ( CreationParams.Fullscreen )
SDL_Flags |= SDL_WINDOW_FULLSCREEN_DESKTOP;
if (CreationParams.DriverType == video::EDT_OPENGL)
SDL_Flags |= SDL_WINDOW_OPENGL;
// create window
if (CreationParams.DriverType != video::EDT_NULL)
{
// create the window, only if we do not use the null device
createWindow();
}
// create cursor control
CursorControl = new CCursorControl(this);
// create driver
createDriver();
if (VideoDriver)
createGUIAndScene();
}
//! destructor
CIrrDeviceSDL::~CIrrDeviceSDL()
{
#if defined(_IRR_COMPILE_WITH_JOYSTICK_EVENTS_)
const u32 numJoysticks = Joysticks.size();
for (u32 i=0; i<numJoysticks; ++i)
SDL_JoystickClose(Joysticks[i]);
#endif
SDL_Quit();
}
bool CIrrDeviceSDL::createWindow()
{
os::Printer::log("Create SDL2 Window" );
if ( Close )
return false;
if (CreationParams.DriverType == video::EDT_OPENGL)
{
SDL_GL_SetAttribute( SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE );
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 1);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2);
if (CreationParams.Bits==16)
{
SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 4 );
SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 4 );
SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 4 );
SDL_GL_SetAttribute( SDL_GL_ALPHA_SIZE, CreationParams.WithAlphaChannel?1:0 );
}
else
{
SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 8 );
SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 8 );
SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 8 );
SDL_GL_SetAttribute( SDL_GL_ALPHA_SIZE, CreationParams.WithAlphaChannel?8:0 );
}
SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, CreationParams.ZBufferBits);
if (CreationParams.Doublebuffer)
SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );
if (CreationParams.Stereobuffer)
SDL_GL_SetAttribute( SDL_GL_STEREO, 1 );
if (CreationParams.AntiAlias>1)
{
SDL_GL_SetAttribute( SDL_GL_MULTISAMPLEBUFFERS, 1 );
SDL_GL_SetAttribute( SDL_GL_MULTISAMPLESAMPLES, CreationParams.AntiAlias );
}
if ( !window )
window = SDL_CreateWindow("", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, Width, Height, SDL_Flags);
if ( !window && CreationParams.AntiAlias>1)
{
while (--CreationParams.AntiAlias>1)
{
SDL_GL_SetAttribute( SDL_GL_MULTISAMPLESAMPLES, CreationParams.AntiAlias );
window = SDL_CreateWindow("", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, Width, Height, SDL_Flags);
if (window)
break;
}
if ( !window )
{
SDL_GL_SetAttribute( SDL_GL_MULTISAMPLEBUFFERS, 0 );
SDL_GL_SetAttribute( SDL_GL_MULTISAMPLESAMPLES, 0 );
window = SDL_CreateWindow("", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, Width, Height, SDL_Flags);
if (window)
os::Printer::log("AntiAliasing disabled due to lack of support!" );
}
}
}
else if ( !window )
window = SDL_CreateWindow("", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, Width, Height, SDL_Flags);
if ( !window && CreationParams.Doublebuffer)
{
// Try single buffer
if (CreationParams.DriverType == video::EDT_OPENGL)
SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );
//SDL_Flags &= ~SDL_DOUBLEBUF;
window = SDL_CreateWindow("", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, Width, Height, SDL_Flags);
}
if ( !window )
{
os::Printer::log( "Could not initialize display!" );
return false;
}
os::Printer::log( "SDL Device Initialized", SDL_GetError());
return true;
}
//! create the driver
void CIrrDeviceSDL::createDriver()
{
switch(CreationParams.DriverType)
{
case video::EDT_DIRECT3D8:
#ifdef _IRR_COMPILE_WITH_DIRECT3D_8_
os::Printer::log("SDL device does not support DIRECT38 driver. Try another one.", ELL_ERROR);
#else
os::Printer::log("DIRECT3D8 Driver was not compiled into this dll. Try another one.", ELL_ERROR);
#endif // _IRR_COMPILE_WITH_DIRECT3D_8_
break;
case video::EDT_DIRECT3D9:
#ifdef _IRR_COMPILE_WITH_DIRECT3D_9_
os::Printer::log("SDL device does not support DIRECT3D9 driver. Try another one.", ELL_ERROR);
#else
os::Printer::log("DIRECT3D9 Driver was not compiled into this dll. Try another one.", ELL_ERROR);
#endif // _IRR_COMPILE_WITH_DIRECT3D_9_
break;
case video::EDT_SOFTWARE:
#ifdef _IRR_COMPILE_WITH_SOFTWARE_
VideoDriver = video::createSoftwareDriver(CreationParams.WindowSize, CreationParams.Fullscreen, FileSystem, this);
#else
os::Printer::log("No Software driver support compiled in.", ELL_ERROR);
#endif
break;
case video::EDT_BURNINGSVIDEO:
#ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_
VideoDriver = video::createBurningVideoDriver(CreationParams, FileSystem, this);
#else
os::Printer::log("Burning's video driver was not compiled in.", ELL_ERROR);
#endif
break;
case video::EDT_OPENGL:
#ifdef _IRR_COMPILE_WITH_OPENGL_
VideoDriver = video::createOpenGLDriver(CreationParams, FileSystem, this);
#else
os::Printer::log("No OpenGL support compiled in.", ELL_ERROR);
#endif
break;
case video::EDT_NULL:
VideoDriver = video::createNullDriver(FileSystem, CreationParams.WindowSize);
break;
default:
os::Printer::log("Unable to create video driver of unknown type.", ELL_ERROR);
break;
}
}
//! runs the device. Returns false if device wants to be deleted
bool CIrrDeviceSDL::run()
{
//This is a place holder. RCBasic takes care of events during update().
os::Timer::tick();
return true;
}
//! Activate any joysticks, and generate events for them.
bool CIrrDeviceSDL::activateJoysticks(core::array<SJoystickInfo> & joystickInfo)
{
//This is a place holder. RCBasic will init joysticks during its init phase.
return true;
}
//! pause execution temporarily
void CIrrDeviceSDL::yield()
{
SDL_Delay(0);
}
//! pause execution for a specified time
void CIrrDeviceSDL::sleep(u32 timeMs, bool pauseTimer)
{
const bool wasStopped = Timer ? Timer->isStopped() : true;
if (pauseTimer && !wasStopped)
Timer->stop();
SDL_Delay(timeMs);
if (pauseTimer && !wasStopped)
Timer->start();
}
//! sets the caption of the window
void CIrrDeviceSDL::setWindowCaption(const wchar_t* text)
{
core::stringc textc = text;
SDL_SetWindowTitle(window, textc.c_str( ) );
}
//! presents a surface in the client area
bool CIrrDeviceSDL::present(video::IImage* surface, void* windowId, core::rect<s32>* srcClip)
{
return true;
}
//! notifies the device that it should close itself
void CIrrDeviceSDL::closeDevice()
{
Close = true;
}
//! \return Pointer to a list with all video modes supported
video::IVideoModeList* CIrrDeviceSDL::getVideoModeList()
{
return VideoModeList;
}
//! Sets if the window should be resizable in windowed mode.
void CIrrDeviceSDL::setResizable(bool resize)
{
}
//! Minimizes window if possible
void CIrrDeviceSDL::minimizeWindow()
{
}
//! Maximize window
void CIrrDeviceSDL::maximizeWindow()
{
// do nothing
}
//! Restore original window size
void CIrrDeviceSDL::restoreWindow()
{
// do nothing
}
//! returns if window is active. if not, nothing need to be drawn
bool CIrrDeviceSDL::isWindowActive() const
{
return true;
}
//! returns if window has focus.
bool CIrrDeviceSDL::isWindowFocused() const
{
return true;
}
//! returns if window is minimized.
bool CIrrDeviceSDL::isWindowMinimized() const
{
return WindowMinimized;
}
//! Set the current Gamma Value for the Display
bool CIrrDeviceSDL::setGammaRamp( f32 red, f32 green, f32 blue, f32 brightness, f32 contrast )
{
/*
// todo: Gamma in SDL takes ints, what does Irrlicht use?
return (SDL_SetGamma(red, green, blue) != -1);
*/
return false;
}
//! Get the current Gamma Value for the Display
bool CIrrDeviceSDL::getGammaRamp( f32 &red, f32 &green, f32 &blue, f32 &brightness, f32 &contrast )
{
/* brightness = 0.f;
contrast = 0.f;
return (SDL_GetGamma(&red, &green, &blue) != -1);*/
return false;
}
//! returns color format of the window.
video::ECOLOR_FORMAT CIrrDeviceSDL::getColorFormat() const
{
return CIrrDeviceStub::getColorFormat();
}
void CIrrDeviceSDL::createKeyMap()
{
}
} // end namespace irr
#endif // _IRR_COMPILE_WITH_SDL_DEVICE_
CIrrDeviceSDL.h
Code: Select all
// Copyright (C) 2002-2012 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
// This device code is based on the original SDL device implementation
// contributed by Shane Parker (sirshane).
#ifndef __C_IRR_DEVICE_SDL_H_INCLUDED__
#define __C_IRR_DEVICE_SDL_H_INCLUDED__
#include "IrrCompileConfig.h"
#ifdef _IRR_COMPILE_WITH_SDL_DEVICE_
#include "IrrlichtDevice.h"
#include "CIrrDeviceStub.h"
#include "IImagePresenter.h"
#include "ICursorControl.h"
#include <SDL2/SDL.h>
#include <SDL2/SDL_syswm.h>
namespace irr
{
class CIrrDeviceSDL : public CIrrDeviceStub, video::IImagePresenter
{
public:
SDL_Window* window;
SDL_GLContext context;
//! constructor
CIrrDeviceSDL(const SIrrlichtCreationParameters& param);
//! destructor
virtual ~CIrrDeviceSDL();
//! runs the device. Returns false if device wants to be deleted
virtual bool run();
//! pause execution temporarily
virtual void yield();
//! pause execution for a specified time
virtual void sleep(u32 timeMs, bool pauseTimer);
//! sets the caption of the window
virtual void setWindowCaption(const wchar_t* text);
//! returns if window is active. if not, nothing need to be drawn
virtual bool isWindowActive() const;
//! returns if window has focus.
bool isWindowFocused() const;
//! returns if window is minimized.
bool isWindowMinimized() const;
//! returns color format of the window.
video::ECOLOR_FORMAT getColorFormat() const;
//! presents a surface in the client area
virtual bool present(video::IImage* surface, void* windowId=0, core::rect<s32>* src=0);
//! notifies the device that it should close itself
virtual void closeDevice();
//! \return Returns a pointer to a list with all video modes supported
video::IVideoModeList* getVideoModeList();
//! Sets if the window should be resizable in windowed mode.
virtual void setResizable(bool resize=false);
//! Minimizes the window.
virtual void minimizeWindow();
//! Maximizes the window.
virtual void maximizeWindow();
//! Restores the window size.
virtual void restoreWindow();
//! Activate any joysticks, and generate events for them.
virtual bool activateJoysticks(core::array<SJoystickInfo> & joystickInfo);
//! Set the current Gamma Value for the Display
virtual bool setGammaRamp( f32 red, f32 green, f32 blue, f32 brightness, f32 contrast );
//! Get the current Gamma Value for the Display
virtual bool getGammaRamp( f32 &red, f32 &green, f32 &blue, f32 &brightness, f32 &contrast );
//! Get the device type
virtual E_DEVICE_TYPE getType() const
{
return EIDT_SDL;
}
virtual void renderSwap()
{
SDL_GL_SwapWindow(this->window);
}
//! Implementation of the linux cursor control
class CCursorControl : public gui::ICursorControl
{
public:
CCursorControl(CIrrDeviceSDL* dev)
: Device(dev), IsVisible(true)
{
}
//! Changes the visible state of the mouse cursor.
virtual void setVisible(bool visible)
{
IsVisible = visible;
if ( visible )
SDL_ShowCursor( SDL_ENABLE );
else
SDL_ShowCursor( SDL_DISABLE );
}
//! Returns if the cursor is currently visible.
virtual bool isVisible() const
{
return IsVisible;
}
//! Sets the new position of the cursor.
virtual void setPosition(const core::position2d<f32> &pos)
{
setPosition(pos.X, pos.Y);
}
//! Sets the new position of the cursor.
virtual void setPosition(f32 x, f32 y)
{
setPosition((s32)(x*Device->Width), (s32)(y*Device->Height));
}
//! Sets the new position of the cursor.
virtual void setPosition(const core::position2d<s32> &pos)
{
setPosition(pos.X, pos.Y);
}
//! Sets the new position of the cursor.
virtual void setPosition(s32 x, s32 y)
{
SDL_WarpMouseInWindow( Device->window, x, y );
}
//! Returns the current position of the mouse cursor.
virtual const core::position2d<s32>& getPosition()
{
updateCursorPos();
return CursorPos;
}
//! Returns the current position of the mouse cursor.
virtual core::position2d<f32> getRelativePosition()
{
updateCursorPos();
return core::position2d<f32>(CursorPos.X / (f32)Device->Width,
CursorPos.Y / (f32)Device->Height);
}
virtual void setReferenceRect(core::rect<s32>* rect=0)
{
}
private:
void updateCursorPos()
{
CursorPos.X = Device->MouseX;
CursorPos.Y = Device->MouseY;
if (CursorPos.X < 0)
CursorPos.X = 0;
if (CursorPos.X > (s32)Device->Width)
CursorPos.X = Device->Width;
if (CursorPos.Y < 0)
CursorPos.Y = 0;
if (CursorPos.Y > (s32)Device->Height)
CursorPos.Y = Device->Height;
}
CIrrDeviceSDL* Device;
core::position2d<s32> CursorPos;
bool IsVisible;
};
private:
//! create the driver
void createDriver();
bool createWindow();
void createKeyMap();
SDL_Surface* Screen;
int SDL_Flags;
#if defined(_IRR_COMPILE_WITH_JOYSTICK_EVENTS_)
core::array<SDL_Joystick*> Joysticks;
#endif
s32 MouseX, MouseY;
u32 MouseButtonStates;
u32 Width, Height;
bool Resizable;
bool WindowHasFocusDeprecated; // TODO: variable only kept to avoid breaking binary compatibility in 1.8. Will be removed in 1.9
bool WindowMinimized;
struct SKeyMap
{
SKeyMap() {}
SKeyMap(s32 x11, s32 win32)
: SDLKey(x11), Win32Key(win32)
{
}
s32 SDLKey;
s32 Win32Key;
bool operator<(const SKeyMap& o) const
{
return SDLKey<o.SDLKey;
}
};
core::array<SKeyMap> KeyMap;
SDL_SysWMinfo Info;
};
} // end namespace irr
#endif // _IRR_COMPILE_WITH_SDL_DEVICE_
#endif // __C_IRR_DEVICE_SDL_H_INCLUDED__
Re: [VISUAL STUDIO] How to change the height of a title bar?
Cool, didn't know SDL2 has this flag already.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm