Commit 85d886a0 authored by hybrid's avatar hybrid

Added a new device creation parameter to choose alpha channel support for the color buffer.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@1372 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 6b09fabb
......@@ -7,29 +7,31 @@
namespace irr
{
//! Structure for holding advanced Irrlicht Device creation parameters.
/** This structure is only used in the createDeviceEx() function. */
//! Structure for holding Irrlicht Device creation parameters.
/** This structure is used in the createDeviceEx() function. */
struct SIrrlichtCreationParameters
{
//! Constructs a SIrrlichtCreationParameters structure with default values.
SIrrlichtCreationParameters()
SIrrlichtCreationParameters() :
DriverType(video::EDT_BURNINGSVIDEO),
WindowSize(core::dimension2d<s32>(800, 600)),
Bits(16),
Fullscreen(false),
Stencilbuffer(false),
Vsync(false),
AntiAlias(false),
WithAlphaChannel(false),
HighPrecisionFPU(false),
EventReceiver(0),
WindowId(0),
SDK_version_do_not_use(IRRLICHT_SDK_VERSION)
{
DriverType = video::EDT_BURNINGSVIDEO;
WindowSize = core::dimension2d<s32>(800, 600);
Bits = 16;
Fullscreen = false;
Stencilbuffer = false;
Vsync = false;
AntiAlias = false;
HighPrecisionFPU = false;
EventReceiver = 0;
WindowId = 0;
SDK_version_do_not_use = IRRLICHT_SDK_VERSION;
}
//! Type of the device.
/** This can currently be video::EDT_NULL,
video::EDT_SOFTWARE, video::EDT_DIRECT3D8, video::EDT_DIRECT3D9 and video::EDT_OPENGL.
/** This can currently be video::EDT_NULL, video::EDT_SOFTWARE,
video::EDT_BURNINGSVIDEO, video::EDT_DIRECT3D8,
video::EDT_DIRECT3D9, and video::EDT_OPENGL.
Default: Software. */
video::E_DRIVER_TYPE DriverType;
......@@ -44,33 +46,45 @@ namespace irr
bool Fullscreen;
//! Specifies if the stencil buffer should be enabled.
/** Set this to true,
if you want the engine be able to draw stencil buffer shadows. Note that not all
devices are able to use the stencil buffer. If they don't no shadows will be drawn.
/** Set this to true, if you want the engine be able to draw
stencil buffer shadows. Note that not all devices are able to
use the stencil buffer. If they don't no shadows will be drawn.
Default: false. */
bool Stencilbuffer;
//! Specifies vertical syncronisation.
/** If set to true, the driver will wait for the vertical retrace period, otherwise not.
/** If set to true, the driver will wait for the vertical
retrace period, otherwise not.
Default: false */
bool Vsync;
//! Specifies if the device should use fullscreen anti aliasing
/** Makes sharp/pixelated edges softer, but requires more performance. Also, 2D
elements might look blurred with this switched on. The resulting rendering quality
also depends on the hardware and driver you are using, your program might look
different on different hardware with this. So if you are writing a
game/application with antiAlias switched on, it would be a good idea to make it
possible to switch this option off again by the user.
This is only supported in D3D9 and D3D8. In D3D9, both sample types are supported,
D3DMULTISAMPLE_X_SAMPLES and D3DMULTISAMPLE_NONMASKABLE. Default value: false */
/** Makes sharp/pixelated edges softer, but requires more
performance. Also, 2D elements might look blurred with this
switched on. The resulting rendering quality also depends on
the hardware and driver you are using, your program might look
different on different hardware with this. So if you are
writing a game/application with AntiAlias switched on, it would
be a good idea to make it possible to switch this option off
again by the user.
This is curently not supported in OpenGL under Windows.
Default value: false */
bool AntiAlias;
//! Whether the main framebuffer uses an alpha channel.
/** In some situations it might be desireable to get a color
buffer with an alpha channel, e.g. when rendering into a
transparent window or overlay. If this flag is set the device
tries to create a framebuffer with alpha channel.
Default value: false */
bool WithAlphaChannel;
//! Specifies if the device should use high precision FPU setting
/** This is only relevant for DirectX Devices, which switch to low FPU precision
by default for performance reasons. However, this may lead to problems with the
other computations of the application. In this case setting this flag to true
should help - on the expense of performance loss, though.
/** This is only relevant for DirectX Devices, which switch to
low FPU precision by default for performance reasons. However,
this may lead to problems with the other computations of the
application. In this case setting this flag to true should help
- on the expense of performance loss, though.
Default value: false */
bool HighPrecisionFPU;
......@@ -78,12 +92,14 @@ namespace irr
IEventReceiver* EventReceiver;
//! Window Id.
/** If this is set to a value other than 0, the Irrlicht Engine will be created in
an already existing window. For windows, set this to the HWND of the window you want.
The windowSize and FullScreen options will be ignored when using the WindowId parameter.
Default this is set to 0.
To make Irrlicht run inside the custom window, you still will have to draw Irrlicht
on your own. You can use this loop, as usual:
/** If this is set to a value other than 0, the Irrlicht Engine
will be created in an already existing window. For windows, set
this to the HWND of the window you want. The windowSize and
FullScreen options will be ignored when using the WindowId
parameter. Default this is set to 0.
To make Irrlicht run inside the custom window, you still will
have to draw Irrlicht on your own. You can use this loop, as
usual:
\code
while (device->run())
{
......@@ -94,13 +110,14 @@ namespace irr
\endcode
Instead of this, you can also simply use your own message loop
using GetMessage, DispatchMessage and whatever. Calling
IrrlichtDevice::run() will cause Irrlicht to dispatch messages internally too.
You need not call Device->run() if you want to do your own message
dispatching loop, but Irrlicht will not be able to fetch
user input then and you have to do it on your own using the window
messages, DirectInput, or whatever. Also, you'll have to increment the Irrlicht timer.
An alternative, own message dispatching loop without device->run() would
look like this:
IrrlichtDevice::run() will cause Irrlicht to dispatch messages
internally too. You need not call Device->run() if you want to
do your own message dispatching loop, but Irrlicht will not be
able to fetch user input then and you have to do it on your own
using the window messages, DirectInput, or whatever. Also,
you'll have to increment the Irrlicht timer.
An alternative, own message dispatching loop without
device->run() would look like this:
\code
MSG msg;
while (true)
......@@ -123,8 +140,8 @@ namespace irr
driver->endScene();
}
\endcode
However, there is no need to draw the picture this often. Just do it how you like.
*/
However, there is no need to draw the picture this often. Just
do it how you like. */
void* WindowId;
//! Don't use or change this parameter.
......
......@@ -42,7 +42,7 @@ CIrrDeviceLinux::CIrrDeviceLinux(const SIrrlichtCreationParameters& param)
#ifdef _IRR_COMPILE_WITH_X11_
display(0), visual(0), screennr(0), window(0), StdHints(0), SoftwareImage(0),
#endif
Width(param.WindowSize.Width), Height(param.WindowSize.Height), Depth(24),
Width(param.WindowSize.Width), Height(param.WindowSize.Height),
Close(false), WindowActive(false), WindowMinimized(false), UseXVidMode(false), UseXRandR(false), UseGLXWindow(false), AutorepeatSupport(0)
{
#ifdef _DEBUG
......@@ -282,11 +282,11 @@ bool CIrrDeviceLinux::createWindow()
GLX_RED_SIZE, 4,
GLX_GREEN_SIZE, 4,
GLX_BLUE_SIZE, 4,
GLX_ALPHA_SIZE, 0,
GLX_ALPHA_SIZE, CreationParams.WithAlphaChannel?1:0,
GLX_DEPTH_SIZE, 16,
GLX_DOUBLEBUFFER, GL_TRUE,
GLX_STENCIL_SIZE, 1,
GLX_SAMPLE_BUFFERS_ARB, GL_TRUE,
GLX_SAMPLE_BUFFERS_ARB, 1,
GLX_SAMPLES_ARB, MAX_SAMPLES,
None
};
......@@ -295,7 +295,7 @@ bool CIrrDeviceLinux::createWindow()
int nitems=0;
if (!CreationParams.AntiAlias)
{
visualAttrBuffer[17] = GL_FALSE;
visualAttrBuffer[17] = 0;
visualAttrBuffer[19] = 0;
}
if (CreationParams.Stencilbuffer)
......@@ -310,7 +310,7 @@ bool CIrrDeviceLinux::createWindow()
}
if (!configList)
{
visualAttrBuffer[17] = GL_FALSE;
visualAttrBuffer[17] = 0;
visualAttrBuffer[19] = 0;
configList=glXChooseFBConfig(display, screennr, visualAttrBuffer,&nitems);
if (configList)
......@@ -321,7 +321,7 @@ bool CIrrDeviceLinux::createWindow()
else
{
//reenable multisampling
visualAttrBuffer[17] = GL_TRUE;
visualAttrBuffer[17] = 1;
visualAttrBuffer[19] = MAX_SAMPLES;
}
}
......@@ -345,7 +345,7 @@ bool CIrrDeviceLinux::createWindow()
}
if (!configList)
{
visualAttrBuffer[17] = GL_FALSE;
visualAttrBuffer[17] = 0;
visualAttrBuffer[19] = 0;
configList=glXChooseFBConfig(display, screennr, visualAttrBuffer,&nitems);
if (configList)
......@@ -356,7 +356,7 @@ bool CIrrDeviceLinux::createWindow()
else
{
//reenable multisampling
visualAttrBuffer[17] = GL_TRUE;
visualAttrBuffer[17] = 1;
visualAttrBuffer[19] = MAX_SAMPLES;
}
}
......@@ -377,7 +377,7 @@ bool CIrrDeviceLinux::createWindow()
}
if (!configList)
{
visualAttrBuffer[17] = GL_FALSE;
visualAttrBuffer[17] = 0;
visualAttrBuffer[19] = 0;
configList=glXChooseFBConfig(display, screennr, visualAttrBuffer,&nitems);
if (configList)
......@@ -388,7 +388,7 @@ bool CIrrDeviceLinux::createWindow()
else
{
//reenable multisampling
visualAttrBuffer[17] = GL_TRUE;
visualAttrBuffer[17] = 1;
visualAttrBuffer[19] = MAX_SAMPLES;
}
}
......@@ -411,7 +411,7 @@ bool CIrrDeviceLinux::createWindow()
GLX_RED_SIZE, 4,
GLX_GREEN_SIZE, 4,
GLX_BLUE_SIZE, 4,
GLX_ALPHA_SIZE, 0,
GLX_ALPHA_SIZE, CreationParams.WithAlphaChannel?1:0,
GLX_DEPTH_SIZE, 16,
GLX_DOUBLEBUFFER, GL_TRUE,
GLX_STENCIL_SIZE, 1,
......@@ -585,7 +585,7 @@ bool CIrrDeviceLinux::createWindow()
u32 borderWidth;
int x,y;
XGetGeometry(display, window, &tmp, &x, &y, &Width, &Height, &borderWidth, &Depth);
XGetGeometry(display, window, &tmp, &x, &y, &Width, &Height, &borderWidth, &CreationParams.Bits);
StdHints = XAllocSizeHints();
long num;
XGetWMNormalHints(display, window, StdHints, &num);
......@@ -853,6 +853,7 @@ void CIrrDeviceLinux::yield()
nanosleep(&ts, NULL);
}
//! Pause execution and let other processes to run for a specified amount of time.
void CIrrDeviceLinux::sleep(u32 timeMs, bool pauseTimer=false)
{
......@@ -871,6 +872,7 @@ void CIrrDeviceLinux::sleep(u32 timeMs, bool pauseTimer=false)
Timer->start();
}
//! sets the caption of the window
void CIrrDeviceLinux::setWindowCaption(const wchar_t* text)
{
......@@ -887,7 +889,6 @@ void CIrrDeviceLinux::setWindowCaption(const wchar_t* text)
}
//! presents a surface in the client area
void CIrrDeviceLinux::present(video::IImage* image, void* windowId, core::rect<s32>* src )
{
......@@ -919,7 +920,7 @@ void CIrrDeviceLinux::present(video::IImage* image, void* windowId, core::rect<s
s32* srcdata = (s32*)image->lock();
if ((Depth == 32)||(Depth == 24))
if ((CreationParams.Bits == 32)||(CreationParams.Bits == 24))
{
int destPitch = SoftwareImage->bytes_per_line;
u8* destData = reinterpret_cast<u8*>(SoftwareImage->data);
......@@ -932,7 +933,7 @@ void CIrrDeviceLinux::present(video::IImage* image, void* windowId, core::rect<s
}
}
else
if (Depth == 16)
if (CreationParams.Bits == 16)
{
// convert to R5G6B6
......@@ -957,7 +958,7 @@ void CIrrDeviceLinux::present(video::IImage* image, void* windowId, core::rect<s
s16* srcdata = (s16*)image->lock();
if (Depth == 16)
if (CreationParams.Bits == 16)
{
// convert from A1R5G5B5 to R5G6B6
......@@ -972,7 +973,7 @@ void CIrrDeviceLinux::present(video::IImage* image, void* windowId, core::rect<s
}
}
else
if ((Depth == 32)||(Depth == 24))
if ((CreationParams.Bits == 32)||(CreationParams.Bits == 24))
{
// convert from A1R5G5B5 to X8R8G8B8
......@@ -998,7 +999,6 @@ void CIrrDeviceLinux::present(video::IImage* image, void* windowId, core::rect<s
}
//! notifies the device that it should close itself
void CIrrDeviceLinux::closeDevice()
{
......@@ -1006,7 +1006,6 @@ void CIrrDeviceLinux::closeDevice()
}
//! returns if window is active. if not, nothing need to be drawn
bool CIrrDeviceLinux::isWindowActive() const
{
......@@ -1014,7 +1013,6 @@ bool CIrrDeviceLinux::isWindowActive() const
}
//! Sets if the window should be resizeable in windowed mode.
void CIrrDeviceLinux::setResizeAble(bool resize)
{
......@@ -1043,8 +1041,7 @@ void CIrrDeviceLinux::setResizeAble(bool resize)
}
//! \return Returns a pointer to a list with all video modes supported
//! by the gfx adapter.
//! Return pointer to a list with all video modes supported by the gfx adapter.
video::IVideoModeList* CIrrDeviceLinux::getVideoModeList()
{
#ifdef _IRR_COMPILE_WITH_X11_
......@@ -1120,7 +1117,6 @@ video::IVideoModeList* CIrrDeviceLinux::getVideoModeList()
}
void CIrrDeviceLinux::createKeyMap()
{
// I don't know if this is the best method to create
......@@ -1128,6 +1124,7 @@ void CIrrDeviceLinux::createKeyMap()
// I find a better version.
#ifdef _IRR_COMPILE_WITH_X11_
KeyMap.reallocate(84);
KeyMap.push_back(SKeyMap(XK_BackSpace, KEY_BACK));
KeyMap.push_back(SKeyMap(XK_Tab, KEY_TAB));
KeyMap.push_back(SKeyMap(XK_Linefeed, 0)); // ???
......
......@@ -270,15 +270,15 @@ namespace irr
#endif
}
core::position2d<s32> CursorPos;
CIrrDeviceLinux* Device;
bool IsVisible;
bool Null;
bool UseReferenceRect;
core::position2d<s32> CursorPos;
core::rect<s32> ReferenceRect;
#ifdef _IRR_COMPILE_WITH_X11_
Cursor invisCursor;
#endif
bool IsVisible;
bool Null;
bool UseReferenceRect;
};
friend class CCursorControl;
......@@ -303,7 +303,7 @@ namespace irr
GLXContext Context;
#endif
#endif
u32 Width, Height, Depth;
u32 Width, Height;
bool Close;
bool WindowActive;
bool WindowMinimized;
......
......@@ -116,15 +116,17 @@ bool CIrrDeviceSDL::createWindow()
{
if (CreationParams.Bits==16)
{
SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 5 );
SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 5 );
SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 5 );
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.Bits);
SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment