Added Win32 fullscreen enhancement, now trying to get a better refresh rate. Some minor changes, mainly to comments and indentation.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@819 dfc29bdd-3216-0410-991c-e03cc46cb475
master
hybrid 2007-08-02 14:39:14 +00:00
parent ebb6f460b4
commit f42fdc4a15
7 changed files with 84 additions and 96 deletions

View File

@ -961,7 +961,7 @@ namespace scene
how big the radius should be, you could use the following code to determine
it:
\code
core::aabbox<f32> box = yourSceneNode->getBoundingBox();
const core::aabbox<f32>& box = yourSceneNode->getBoundingBox();
core::vector3df radius = box.MaxEdge - box.getCenter();
\endcode
\param gravityPerSecond: Sets the gravity of the environment. A good example value would be

View File

@ -116,43 +116,28 @@ namespace video
virtual const core::matrix4& getTransform(E_TRANSFORMATION_STATE state) = 0;
//! Sets a material.
/** All 3d drawing functions draw geometry now
using this material.
/** All 3d drawing functions will draw geometry using this material.
\param material: Material to be used from now on. */
virtual void setMaterial(const SMaterial& material) = 0;
//! Returns a pointer to a texture.
/** Loads the texture if it is not
already loaded, and generates mipmap levels if desired.
You can influence how the texture is loaded using the setTextureCreationFlag()
method.
/** Loads the texture from disk if it is not
already loaded and generates mipmap levels if desired.
Texture loading can be influenced using the setTextureCreationFlag() method.
The texture can be in BMP, JPG, TGA, PCX, PNG, and PSD format.
For loading BMP, TGA, PCX, and PSD files the engine uses its own methods.
PCX loading is based on some code by Dean P. Macri, PNG loading
is done using a loader by rt.
For loading JPG-Files the JPEG LIB 6b, written by
The Independent JPEG Group is used. For PNG loading,
libPNG is used. Thanx for such great libraries!
\param filename: Filename of the texture to be loaded.
\return Returns a pointer to the texture and 0 if the texture
\return Returns a pointer to the texture or 0 if the texture
could not be loaded.
This pointer should not be dropped. See IUnknown::drop() for more information.*/
virtual ITexture* getTexture(const c8* filename) = 0;
//! Returns a pointer to a texture.
/** Loads the texture if it is not
already loaded, and generates mipmap levels if desired.
You can influence how the texture is loaded using the setTextureCreationFlag()
method.
/** Loads the texture from disk if it is not
already loaded and generates mipmap levels if desired.
Texture loading can be influenced using the setTextureCreationFlag() method.
The texture can be in BMP, JPG, TGA, PCX, PNG, and PSD format.
For loading BMP, TGA, PCX, and PSD files the engine uses its own methods.
PCX loading is based on some code by Dean P. Macri, PNG loading
is done using a loader by rt.
For loading JPG-Files the JPEG LIB 6b, written by
The Independent JPEG Group is used. For PNG loading,
libPNG is used. Thanx for such great libraries!
\param file: Pointer to an already opened file.
\return Returns a pointer to the texture and 0 if the texture
\return Returns a pointer to the texture or 0 if the texture
could not be loaded.
This pointer should not be dropped. See IUnknown::drop() for more information.*/
virtual ITexture* getTexture(io::IReadFile* file) = 0;
@ -175,7 +160,7 @@ namespace video
will return this texture
\param format: Desired color format of the texture. Please note that
the driver may choose to create the texture in another color format.
\return Returns a pointer to the new created Texture.
\return Returns a pointer to the newly created texture.
This pointer should not be dropped. See IUnknown::drop() for more information. */
virtual ITexture* addTexture(const core::dimension2d<s32>& size,
const c8* name, ECOLOR_FORMAT format = ECF_A8R8G8B8) = 0;
@ -202,47 +187,45 @@ namespace video
/** Please note that after calling this, the pointer to the ITexture
may not be longer valid, if it was not grabbed before by other parts of
the engine for storing it longer. So it would be a good idea to set all
materials which are using this texture to null or another texture first.
\param texture: Texture to delete from the engines cache. */
materials which are using this texture to 0 or another texture first.
\param texture: Texture to delete from the engine cache. */
virtual void removeTexture(ITexture* texture) = 0;
//! Removes all texture from the texture cache and deletes them, freeing lot of memory.
//! Removes all textures from the texture cache and deletes them, freeing lot of memory.
/** Please note that after calling this, the pointer to all ITextures
may not be longer valid, if they were not grabbed before by other parts of
the engine for storing them longer. So it would be a good idea to set all
materials which are using textures to null first. */
materials which are using textures to 0 first. */
virtual void removeAllTextures() = 0;
//! Creates an 1bit alpha channel of the texture based of an color key.
//! Creates a 1bit alpha channel of the texture based of an color key.
/** This makes the texture transparent at the regions where this color
key can be found when using for example draw2DImage with useAlphachannel
= true.
\param texture: Texture of which its alpha channel is modified.
\param color: Color key color. Every pixel with this color will get transparent
like described above. Please note that the colors of a texture may get
\param texture: Texture whose alpha channel is modified.
\param color: Color key color. Every pixel with this color will become transparent
as described above. Please note that the colors of a texture may be
converted when loading it, so the color values may not be exactly the same
in the engine and for example in picture edit programs. To avoid this
problem, you could use the makeColorKeyTexture method, which takes the position
of a pixel instead a color value. */
virtual void makeColorKeyTexture(video::ITexture* texture, video::SColor color) = 0;
//! Creates an 1bit alpha channel of the texture based of an color key position.
//! Creates a 1bit alpha channel of the texture based of an color key position.
/** This makes the texture transparent at the regions where this color
key can be found when using for example draw2DImage with useAlphachannel
= true.
\param texture: Texture of which its alpha channel is modified.
key can be found when using for example draw2DImage with useAlphachannel=true.
\param texture: Texture whose alpha channel is modified.
\param colorKeyPixelPos: Position of a pixel with the color key color.
Every pixel with this color will get transparent
like described above. */
Every pixel with this color will become transparent as described above. */
virtual void makeColorKeyTexture(video::ITexture* texture,
core::position2d<s32> colorKeyPixelPos) = 0;
//! Creates a normal map from a height map texture.
/** If the target texture
has 32 bit, the height value is stored in the alpha component of the texture as
addition. This value will be used by the video::EMT_PARALLAX_MAP_SOLID
material and similar materials.
\param texture: Texture of which its alpha channel is modified.
addition. This value is used by the video::EMT_PARALLAX_MAP_SOLID
material and similar materials.
\param texture: Texture whose alpha channel is modified.
\param amplitude: Constant value by which the height information is multiplied.*/
virtual void makeNormalMapTexture(video::ITexture* texture, f32 amplitude=1.0f) = 0;
@ -286,7 +269,7 @@ namespace video
virtual void setViewPort(const core::rect<s32>& area) = 0;
//! Gets the area of the current viewport.
/** \return Returns rectangle of the current vieport. */
/** \return Returns rectangle of the current viewport. */
virtual const core::rect<s32>& getViewPort() const = 0;
//! draws a vertex primitive list
@ -367,7 +350,7 @@ namespace video
u32 vertexCount, const u16* indexList, u32 triangleCount) = 0;
//! Draws a 3d line.
/** For some implementations, this method simply calls drawIndexedTriangles with some
/** For some implementations, this method simply calls drawIndexedTriangles for some
triangles. Note that the line is drawn using the current transformation
matrix and material. So if you need to draw the 3D line independently of the
current transformation, use
@ -375,7 +358,6 @@ namespace video
driver->setTransform(video::ETS_WORLD, core::matrix4());
\endcode
before drawing the line.
This method was created for making culling debugging easier.
\param start: Start of the 3d line.
\param end: End of the 3d line.
\param color: Color of the line. */
@ -383,30 +365,26 @@ namespace video
const core::vector3df& end, SColor color = SColor(255,255,255,255)) = 0;
//! Draws a 3d triangle.
/** This method usually simply calls drawIndexedTriangles with some
triangles. Note that the line is drawn using the current transformation
matrix and material.
This method was created for making collision debugging easier. It works with
all drivers because it does simply a call to drawIndexedTriangleList and
hence is not very fast but it might be useful for further development.
/** This method calls drawIndexedTriangles for some triangles.
Note that the line is drawn using the current transformation matrix and material.
This method works with all drivers because it simply calls drawIndexedTriangleList but
is hence not very fast.
\param triangle: The triangle to draw.
\param color: Color of the line. */
virtual void draw3DTriangle(const core::triangle3df& triangle,
SColor color = SColor(255,255,255,255)) = 0;
//! Draws a 3d axis aligned box.
/** This method usually simply calls drawIndexedTriangles with some
triangles. Note that the line is drawn using the current transformation
matrix and material.
This method was created for making culling debugging easier. It works with
all drivers because it does simply a call to drawIndexedTriangleList and
hence is not very fast but it might be useful for further development.
/** This method simply calls drawIndexedTriangles for some triangles.
Note that the line is drawn using the current transformation matrix and material.
This method works with all drivers because it simply calls drawIndexedTriangleList but
is hence not very fast.
\param box: The axis aligned box to draw
\param color: Color to use while drawing the box. */
virtual void draw3DBox(const core::aabbox3d<f32>& box,
SColor color = SColor(255,255,255,255)) = 0;
//! Simply draws a 2d image without any special effects
//! Draws a 2d image without any special effects
/** \param texture: Pointer to texture to use.
\param destPos: upper left 2d destination position where the image will be drawn. */
virtual void draw2DImage(video::ITexture* texture,
@ -587,7 +565,7 @@ namespace video
virtual void deleteAllDynamicLights() = 0;
//! Adds a dynamic light.
/** \param light: Data specifing the dynamic light. */
/** \param light: Data specifying the dynamic light. */
virtual void addDynamicLight(const SLight& light) = 0;
//! Sets the dynamic ambient light color.
@ -604,7 +582,7 @@ namespace video
/** \return Current amount of dynamic lights set */
virtual u32 getDynamicLightCount() = 0;
//! Returns light data which was previously set with IVideDriver::addDynamicLight().
//! Returns light data which was previously set by IVideoDriver::addDynamicLight().
/** \param idx: Zero based index of the light. Must be greater than 0 and smaller
than IVideoDriver()::getDynamicLightCount.
\return Light data. */

View File

@ -1737,7 +1737,7 @@ void CD3D9Driver::setAmbientLight(const SColorf& color)
//! \return Returns the name of the video driver. Example: In case of the DIRECT3D9
//! driver, it would return "Direct3D9.1".
//! driver, it would return "Direct3D9.0".
const wchar_t* CD3D9Driver::getName()
{
return L"Direct3D 9.0";

View File

@ -696,18 +696,25 @@ bool CIrrDeviceWin32::isWindowActive()
//! switchs to fullscreen
//! switches to fullscreen
bool CIrrDeviceWin32::switchToFullScreen(s32 width, s32 height, s32 bits)
{
DEVMODE dm;
memset(&dm, 0, sizeof(dm));
dm.dmSize = sizeof(dm);
// use default values from current setting
EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &dm);
dm.dmPelsWidth = width;
dm.dmPelsHeight = height;
dm.dmBitsPerPel = bits;
dm.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
dm.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT | DM_DISPLAYFREQUENCY;
LONG ret = ChangeDisplaySettings(&dm, CDS_FULLSCREEN);
if (ret != DISP_CHANGE_SUCCESSFUL)
{ // try again without forcing display frequency
dm.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
ret = ChangeDisplaySettings(&dm, CDS_FULLSCREEN);
}
switch(ret)
{

View File

@ -38,9 +38,9 @@ CLightSceneNode::~CLightSceneNode()
//! pre render event
void CLightSceneNode::OnRegisterSceneNode()
{
doLightRecalc ();
doLightRecalc();
if (IsVisible )
if (IsVisible)
{
SceneManager->registerNodeForRendering(this, ESNRP_LIGHT);
ISceneNode::OnRegisterSceneNode();
@ -69,8 +69,8 @@ void CLightSceneNode::render()
break;
case video::ELT_DIRECTIONAL:
driver->draw3DLine(core::vector3df ( 0.f, 0.f, 0.f ),
core::vector3df ( 0.f, 0.f, 0.f ) + (LightData.Position * 10.f ),
driver->draw3DLine(core::vector3df( 0.f, 0.f, 0.f ),
core::vector3df( 0.f, 0.f, 0.f ) + (LightData.Position * 10.f ),
LightData.DiffuseColor.toSColor()
);
break;
@ -81,12 +81,12 @@ void CLightSceneNode::render()
}
//! returns the light data
//! sets the light data
void CLightSceneNode::setLightData(const video::SLight& light)
{
LightData = light;
ISceneNode::setPosition(light.Position);
ISceneNode::updateAbsolutePosition ();
ISceneNode::updateAbsolutePosition();
}
@ -111,24 +111,24 @@ void CLightSceneNode::doLightRecalc()
case video::ELT_POINT:
{
f32 r = LightData.Radius * LightData.Radius * 0.5f;
BBox.MaxEdge.set ( r, r, r );
BBox.MinEdge.set ( -r, -r, -r );
setAutomaticCulling ( scene::EAC_BOX );
BBox.MaxEdge.set( r, r, r );
BBox.MinEdge.set( -r, -r, -r );
setAutomaticCulling( scene::EAC_BOX );
LightData.Position = getAbsolutePosition();
} break;
case video::ELT_DIRECTIONAL:
BBox.reset ( 0, 0, 0 );
setAutomaticCulling ( scene::EAC_OFF );
BBox.reset( 0, 0, 0 );
setAutomaticCulling( scene::EAC_OFF );
// misuse Position as direction..
LightData.Position = getAbsolutePosition();
LightData.Position.invert();
if ( LightData.Position.getLengthSQ() == 0.0 )
{
LightData.Position.set ( 0.f, -1.f, 0.f );
os::Printer::log ( "Invalid Directional Light Direction" );
LightData.Position.set( 0.f, -1.f, 0.f );
os::Printer::log( "Invalid Directional Light Direction" );
}
else
{
@ -171,8 +171,10 @@ void CLightSceneNode::deserializeAttributes(io::IAttributes* in, io::SAttributeR
//! Creates a clone of this scene node and its children.
ISceneNode* CLightSceneNode::clone(ISceneNode* newParent, ISceneManager* newManager)
{
if (!newParent) newParent = Parent;
if (!newManager) newManager = SceneManager;
if (!newParent)
newParent = Parent;
if (!newManager)
newManager = SceneManager;
CLightSceneNode* nb = new CLightSceneNode(newParent,
newManager, ID, RelativeTranslation, LightData.DiffuseColor, LightData.Radius);

View File

@ -63,7 +63,7 @@ IImageWriter* createImageWriterPPM();
//! constructor
CNullDriver::CNullDriver(io::IFileSystem* io, const core::dimension2d<s32>& screenSize)
: FileSystem(io), ViewPort(0,0,0,0), ScreenSize(screenSize),
PrimitivesDrawn(0), TextureCreationFlags(0)
PrimitivesDrawn(0), TextureCreationFlags(0)
{
#ifdef _DEBUG
setDebugName("CNullDriver");
@ -406,7 +406,7 @@ ITexture* CNullDriver::addTexture(const c8* name, IImage* image)
//! creates a Texture
ITexture* CNullDriver::addTexture(const core::dimension2d<s32>& size,
const c8* name, ECOLOR_FORMAT format)
const c8* name, ECOLOR_FORMAT format)
{
if (!name)
return 0;
@ -439,7 +439,7 @@ ITexture* CNullDriver::createDeviceDependentTexture(IImage* surface, const char*
//! sets a render target
bool CNullDriver::setRenderTarget(video::ITexture* texture, bool clearBackBuffer,
bool clearZBuffer, SColor color)
bool clearZBuffer, SColor color)
{
return false;
}
@ -587,7 +587,7 @@ void CNullDriver::draw2DImage(video::ITexture* texture,
bool useAlphaChannelOfTexture)
{
core::position2d<s32> target(pos);
for (u32 i=0; i<indices.size(); ++i)
{
draw2DImage(texture, target, sourceRects[indices[i]],
@ -610,9 +610,9 @@ void CNullDriver::draw2DImage(video::ITexture* texture, const core::rect<s32>& d
//! draws an 2d image, using a color (if color is other then Color(255,255,255,255)) and the alpha channel of the texture if wanted.
void CNullDriver::draw2DImage(video::ITexture* texture, const core::position2d<s32>& destPos,
const core::rect<s32>& sourceRect,
const core::rect<s32>* clipRect, SColor color,
bool useAlphaChannelOfTexture)
const core::rect<s32>& sourceRect,
const core::rect<s32>* clipRect, SColor color,
bool useAlphaChannelOfTexture)
{
}
@ -678,7 +678,7 @@ core::dimension2d<s32> CNullDriver::getScreenSize()
return ScreenSize;
}
//! returns the current render target size,
//! returns the current render target size,
//! or the screen size if render targets are not implemented
core::dimension2d<s32> CNullDriver::getCurrentRenderTargetSize()
{
@ -732,8 +732,9 @@ void CNullDriver::drawStencilShadowVolume(const core::vector3df* triangles, s32
//! Fills the stencil shadow with color. After the shadow volume has been drawn
//! into the stencil buffer using IVideoDriver::drawStencilShadowVolume(), use this
//! to draw the color of the shadow.
void CNullDriver::drawStencilShadow(bool clearStencilBuffer, video::SColor leftUpEdge,
video::SColor rightUpEdge, video::SColor leftDownEdge, video::SColor rightDownEdge)
void CNullDriver::drawStencilShadow(bool clearStencilBuffer,
video::SColor leftUpEdge, video::SColor rightUpEdge,
video::SColor leftDownEdge, video::SColor rightDownEdge)
{
}
@ -745,7 +746,6 @@ void CNullDriver::deleteAllDynamicLights()
}
//! adds a dynamic light
void CNullDriver::addDynamicLight(const SLight& light)
{
@ -760,6 +760,7 @@ u32 CNullDriver::getMaximalDynamicLightAmount()
return 0;
}
//! Returns current amount of dynamic lights set
//! \return Current amount of dynamic lights set
u32 CNullDriver::getDynamicLightCount()
@ -767,16 +768,17 @@ u32 CNullDriver::getDynamicLightCount()
return Lights.size();
}
//! Returns light data which was previously set with IVideDriver::addDynamicLight().
//! Returns light data which was previously set by IVideoDriver::addDynamicLight().
//! \param idx: Zero based index of the light. Must be greater than 0 and smaller
//! than IVideoDriver()::getDynamicLightCount.
//! \return Light data.
const SLight& CNullDriver::getDynamicLight(u32 idx)
{
if ( idx < Lights.size() )
return Lights[idx];
return *((SLight*)0);
return Lights[idx];
else
return *((SLight*)0);
}
@ -853,7 +855,7 @@ void CNullDriver::makeColorKeyTexture(video::ITexture* texture, video::SColor co
//! Creates an 1bit alpha channel of the texture based of an color key position.
void CNullDriver::makeColorKeyTexture(video::ITexture* texture,
core::position2d<s32> colorKeyPixelPos)
core::position2d<s32> colorKeyPixelPos)
{
if (!texture)
return;

View File

@ -1632,7 +1632,6 @@ void COpenGLDriver::setRenderStates2DMode(bool alpha, bool texture, bool alphaCh
glDisable(GL_BLEND);
}
}
}
else
{