mirror of https://github.com/mosra/magnum.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
122 lines
4.4 KiB
122 lines
4.4 KiB
|
12 years ago
|
/*
|
||
|
|
This file is part of Magnum.
|
||
|
|
|
||
|
8 years ago
|
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018
|
||
|
12 years ago
|
Vladimír Vondruš <mosra@centrum.cz>
|
||
|
|
|
||
|
|
Permission is hereby granted, free of charge, to any person obtaining a
|
||
|
|
copy of this software and associated documentation files (the "Software"),
|
||
|
|
to deal in the Software without restriction, including without limitation
|
||
|
|
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||
|
|
and/or sell copies of the Software, and to permit persons to whom the
|
||
|
|
Software is furnished to do so, subject to the following conditions:
|
||
|
|
|
||
|
|
The above copyright notice and this permission notice shall be included
|
||
|
|
in all copies or substantial portions of the Software.
|
||
|
|
|
||
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||
|
|
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||
|
|
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||
|
|
DEALINGS IN THE SOFTWARE.
|
||
|
|
*/
|
||
|
|
|
||
|
|
#include "RendererState.h"
|
||
|
|
|
||
|
8 years ago
|
#include "Magnum/GL/Context.h"
|
||
|
|
#include "Magnum/GL/Extensions.h"
|
||
|
12 years ago
|
|
||
|
|
namespace Magnum { namespace Implementation {
|
||
|
|
|
||
|
11 years ago
|
RendererState::RendererState(Context& context, std::vector<std::string>& extensions)
|
||
|
|
#ifndef MAGNUM_TARGET_WEBGL
|
||
|
|
: resetNotificationStrategy()
|
||
|
|
#endif
|
||
|
|
{
|
||
|
12 years ago
|
/* Float depth clear value implementation */
|
||
|
12 years ago
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
if(context.isExtensionSupported<Extensions::GL::ARB::ES2_compatibility>())
|
||
|
|
#endif
|
||
|
|
{
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
9 years ago
|
extensions.emplace_back(Extensions::GL::ARB::ES2_compatibility::string());
|
||
|
12 years ago
|
#endif
|
||
|
|
|
||
|
|
clearDepthfImplementation = &Renderer::clearDepthfImplementationES;
|
||
|
|
}
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
else clearDepthfImplementation = &Renderer::clearDepthfImplementationDefault;
|
||
|
|
#endif
|
||
|
|
|
||
|
11 years ago
|
#ifndef MAGNUM_TARGET_WEBGL
|
||
|
12 years ago
|
/* Graphics reset status implementation */
|
||
|
12 years ago
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
if(context.isExtensionSupported<Extensions::GL::ARB::robustness>())
|
||
|
|
#else
|
||
|
|
if(context.isExtensionSupported<Extensions::GL::EXT::robustness>())
|
||
|
|
#endif
|
||
|
|
{
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
9 years ago
|
extensions.emplace_back(Extensions::GL::ARB::robustness::string());
|
||
|
12 years ago
|
#else
|
||
|
|
extensions.push_back(Extensions::GL::EXT::robustness::string());
|
||
|
|
#endif
|
||
|
|
|
||
|
|
graphicsResetStatusImplementation = &Renderer::graphicsResetStatusImplementationRobustness;
|
||
|
|
} else graphicsResetStatusImplementation = &Renderer::graphicsResetStatusImplementationDefault;
|
||
|
11 years ago
|
#else
|
||
|
|
static_cast<void>(context);
|
||
|
|
static_cast<void>(extensions);
|
||
|
|
#endif
|
||
|
11 years ago
|
|
||
|
|
/* In case the extensions are not supported on ES2, row length is
|
||
|
|
constantly 0 to avoid modifying that state */
|
||
|
|
#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
|
||
|
|
unpackPixelStorage.disengagedRowLength = PixelStorage::DisengagedValue;
|
||
|
|
packPixelStorage.disengagedRowLength = PixelStorage::DisengagedValue;
|
||
|
|
#ifdef MAGNUM_TARGET_GLES2
|
||
|
|
if(!context.isExtensionSupported<Extensions::GL::EXT::unpack_subimage>())
|
||
|
|
unpackPixelStorage.disengagedRowLength = 0;
|
||
|
|
if(!context.isExtensionSupported<Extensions::GL::NV::pack_subimage>())
|
||
|
|
packPixelStorage.disengagedRowLength = 0;
|
||
|
|
#endif
|
||
|
|
#endif
|
||
|
|
}
|
||
|
|
|
||
|
|
RendererState::PixelStorage::PixelStorage():
|
||
|
|
alignment{4}
|
||
|
|
#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
|
||
|
|
, rowLength{0}
|
||
|
|
#endif
|
||
|
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
, imageHeight{0},
|
||
|
|
skip{0}
|
||
|
|
#endif
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
, compressedBlockSize{0},
|
||
|
|
compressedBlockDataSize{0}
|
||
|
|
#endif
|
||
|
|
{}
|
||
|
|
|
||
|
|
void RendererState::PixelStorage::reset() {
|
||
|
|
alignment = DisengagedValue;
|
||
|
|
#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
|
||
|
|
/* Resets to 0 instead of DisengagedValue in case the EXT_unpack_subimage/
|
||
|
|
NV_pack_image ES2 extension is not supported to avoid modifying that
|
||
|
|
state */
|
||
|
|
rowLength = disengagedRowLength;
|
||
|
|
#endif
|
||
|
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
imageHeight = DisengagedValue;
|
||
|
|
skip = Vector3i{DisengagedValue};
|
||
|
|
#endif
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
compressedBlockSize = Vector3i{DisengagedValue};
|
||
|
|
compressedBlockDataSize = DisengagedValue;
|
||
|
|
#endif
|
||
|
12 years ago
|
}
|
||
|
|
|
||
|
|
}}
|