Browse Source

Merge branch 'master' into compatibility

Vladimír Vondruš 13 years ago
parent
commit
824033b964
  1. 5
      doc/best-practices.dox
  2. 3
      src/AbstractShaderProgram.h
  3. 15
      src/Mesh.cpp
  4. 10
      src/Platform/CMakeLists.txt
  5. 51
      src/Platform/NaClApplication.css
  6. 49
      src/Platform/NaClApplication.h
  7. 43
      src/Platform/NaClApplication.js
  8. 9
      src/Platform/WindowlessNaClApplication.h
  9. 62
      src/Platform/magnum-info-nacl.html
  10. 4
      src/SceneGraph/AbstractFeature.h
  11. 2
      src/SceneGraph/MatrixTransformation2D.h
  12. 8
      src/SceneGraph/Object.h
  13. 4
      src/Shaders/DistanceFieldVector.frag
  14. 36
      src/Shaders/FullScreenTriangle.glsl
  15. 3
      src/Shaders/resources.conf
  16. 19
      src/Text/DistanceFieldGlyphCache.cpp
  17. 15
      src/Text/GlyphCache.cpp
  18. 10
      src/Text/GlyphCache.h
  19. 2
      src/Text/TextRenderer.cpp
  20. 1
      src/TextureTools/DistanceField.cpp
  21. 6
      src/TextureTools/DistanceFieldShader.frag
  22. 11
      src/TextureTools/DistanceFieldShader.vert
  23. 4
      src/TextureTools/resources.conf

5
doc/best-practices.dox

@ -57,11 +57,14 @@ information.
As noted in the above link, buffers in NaCl implementation need to be bound
only to one unique target, i.e., Buffer bound to @ref Buffer::Target "Target::Array"
cannot be later rebound to @ref Buffer::Target "Target::Element". However,
cannot be later rebound to @ref Buffer::Target "Target::ElementArray". However,
%Magnum by default uses any sufficient target when binding the buffer
internally (e.g. for setting data or copying). To avoid this, set target hint
to desired target, either in constructor or using Buffer::setTargetHint().
To ease up the development, @ref Mesh checks proper target hint when adding
vertex and index buffers.
@subsection best-practices-powervr PowerVR hardware
- [PowerVR Performance Recommendations](http://www.imgtec.com/powervr/insider/docs/PowerVR.Performance%20Recommendations.1.0.28.External.pdf) [PDF]

3
src/AbstractShaderProgram.h

@ -282,6 +282,9 @@ setUniform() documentation for more information.
To achieve least state changes, set all uniforms in one run -- method chaining
comes in handy.
@todo Compiling and linking more than one shader in parallel, then checking
status, should be faster -- https://twitter.com/g_truc/status/352778836657700866
*/
class MAGNUM_EXPORT AbstractShaderProgram {
friend class Context;

15
src/Mesh.cpp

@ -118,6 +118,11 @@ Mesh& Mesh::operator=(Mesh&& other) {
}
Mesh* Mesh::setIndexBuffer(Buffer* buffer, GLintptr offset, IndexType type, UnsignedInt start, UnsignedInt end) {
#ifdef CORRADE_TARGET_NACL
CORRADE_ASSERT(buffer->targetHint() == Buffer::Target::ElementArray,
"Mesh::setIndexBuffer(): the buffer has unexpected target hint, expected" << Buffer::Target::ElementArray << "but got" << buffer->targetHint(), this);
#endif
indexOffset = offset;
indexType = type;
#ifndef MAGNUM_TARGET_GLES2
@ -235,10 +240,20 @@ void Mesh::destroyImplementationVAO() {
}
void Mesh::attributePointerImplementationDefault(const Attribute& attribute) {
#ifdef CORRADE_TARGET_NACL
CORRADE_ASSERT(attribute.buffer->targetHint() == Buffer::Target::Array,
"Mesh::addVertexBuffer(): the buffer has unexpected target hint, expected" << Buffer::Target::Array << "but got" << attribute.buffer->targetHint(), );
#endif
attributes.push_back(attribute);
}
void Mesh::attributePointerImplementationVAO(const Attribute& attribute) {
#ifdef CORRADE_TARGET_NACL
CORRADE_ASSERT(attribute.buffer->targetHint() == Buffer::Target::Array,
"Mesh::addVertexBuffer(): the buffer has unexpected target hint, expected" << Buffer::Target::Array << "but got" << attribute.buffer->targetHint(), );
#endif
bindVAO(vao);
vertexAttribPointer(attribute);
}

10
src/Platform/CMakeLists.txt

@ -84,6 +84,11 @@ if(WITH_WINDOWLESSNACLAPPLICATION)
install(TARGETS MagnumWindowlessNaClApplication DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR})
endif()
# JavaScript stuff for NaCl
if(WITH_NACLAPPLICATION OR WITH_WINDOWLESSNACLAPPLICATION)
install(FILES NaClApplication.js DESTINATION ${MAGNUM_DATA_INSTALL_DIR})
endif()
# GLX application
if(WITH_GLXAPPLICATION)
set(NEED_ABSTRACTXAPPLICATION 1)
@ -162,10 +167,11 @@ if(WITH_MAGNUMINFO)
add_executable(magnum-info magnum-info.cpp)
if(UNIX AND NOT CORRADE_TARGET_NACL)
target_link_libraries(magnum-info Magnum MagnumWindowlessGlxApplication ${X11_LIBRARIES})
target_link_libraries(magnum-info MagnumWindowlessGlxApplication ${X11_LIBRARIES})
elseif(CORRADE_TARGET_NACL)
target_link_libraries(magnum-info Magnum MagnumWindowlessNaClApplication ppapi_cpp ppapi)
target_link_libraries(magnum-info MagnumWindowlessNaClApplication ppapi_cpp ppapi)
endif()
target_link_libraries(magnum-info Magnum)
install(TARGETS magnum-info DESTINATION ${MAGNUM_BINARY_INSTALL_DIR})
if(CORRADE_TARGET_NACL)

51
src/Platform/NaClApplication.css

@ -0,0 +1,51 @@
body {
margin: 0px;
padding: 0px;
font-family: sans-serif;
background-color: #111111;
color: #aaaaaa;
}
h1 {
text-align: center;
font-size: 20px;
}
#listener {
border-style: solid;
border-color: #333333;
border-width: 1px;
padding: 1px;
width: 640px;
height: 480px;
margin-left: auto;
margin-right: auto;
margin-top: 20px;
margin-bottom: 20px;
position: relative;
}
#module {
width: 640px;
height: 480px;
z-index: 10;
}
#status {
position: absolute;
width: 640px;
text-align: center;
top: 200px;
font-size: 30px;
font-weight: bold;
z-index: 9;
}
#statusDescription {
position: absolute;
width: 640px;
text-align: center;
top: 250px;
font-size: 15px;
z-index: 9;
}

49
src/Platform/NaClApplication.h

@ -73,12 +73,53 @@ to simplify porting.
@section NaClApplication-html HTML markup and NMF file
You need to provide HTML markup containing `&lt;embed&gt;` pointing to `*.nmf`
file describing the application.
You need to provide HTML markup for your application. Template one is below,
you can modify it to your liking. The markup references two files,
`NaClApplication.js` and `NaClApplication.css`, both are in `Platform/`
directory in the source tree and are also installed into `share/magnum/` inside
your NaCl toolchain.
@code
<!DOCTYPE html>
<html>
<head>
<title>Magnum NaCl Application</title>
<link rel="stylesheet" href="NaClApplication.css" />
</head>
<body>
<h1>Magnum NaCl Application</h1>
<div id="listener">
<script type="text/javascript" src="NaClApplication.js"></script>
<embed name="nacl" id="module" type="application/x-nacl" src="application.nmf" />
<div id="status">Initialization...</div>
<div id="statusDescription"></div>
</div>
</body>
</html>
@endcode
You can modify all the files to your liking, but the HTML file must contain at
least the `&lt;embed&gt;` enclosed in listener `&lt;div&gt;`. The JavaScript
file contains event listeners which print loading status on the page. The
status displayed in the remaining two `&lt;div&gt;`s, if they are available.
The CSS file contains rudimentary style to avoid eye bleeding.
The `&lt;embed&gt;` file references NMF file which you need to provide too. If
you target @ref CORRADE_TARGET_NACL_NEWLIB_ "newlib", the file is pretty
simple, for example:
@code
{
"program": {
"x86-32": {"url": "application-x86-32.nexe"},
"x86-64": {"url": "application-x86-64.nexe"}
}
}
@endcode
@todoc Document this better, add "bootstrap" examples
If you target @ref CORRADE_TARGET_NACL_GLIBC_ "glibc", you need to specify also
all additional dependencies. See [Native Client](https://developers.google.com/native-client/)
documentation for more information.
@subsection NaClApplication-html-console Redirecting output to Chrome's JavaScript console
@section NaClApplication-console Redirecting output to Chrome's JavaScript console
The application redirects @ref Corrade::Utility::Debug "Debug",
@ref Corrade::Utility::Warning "Warning" and @ref Corrade::Utility::Error "Error"

43
src/Platform/NaClApplication.js

@ -0,0 +1,43 @@
function setStatus(message) {
var status = document.getElementById('status');
if(status) status.innerHTML = message;
}
function setStatusDescription(message) {
var statusDescription = document.getElementById('statusDescription');
if(statusDescription) statusDescription.innerHTML = message;
}
var listener = document.getElementById('listener');
listener.addEventListener('loadstart', function() {
setStatus('Loading...');
}, true);
listener.addEventListener('progress', function(event) {
setStatus('Downloading...');
/* Show progress */
if(event.lengthComputable && event.total > 0)
setStatusDescription(Math.round(event.loaded*100/event.total) + '% of '
+ Math.round(event.total/1024) + ' kB');
/* Unknown total size */
else setStatusDescription(Math.round(event.loaded/1024) + ' kB');
}, true);
listener.addEventListener('error', function() {
setStatus('Loading failed');
setStatusDescription(document.getElementById('module').lastError + '<br />Check JavaScript console for more information.');
}, true);
listener.addEventListener('abort', function() {
setStatus('Loading aborted');
setStatusDescription('');
}, true);
listener.addEventListener('load', function() {
setStatus('');
setStatusDescription('');
}, true);

9
src/Platform/WindowlessNaClApplication.h

@ -71,11 +71,12 @@ If no other application header is included this class is also aliased to
@section WindowlessNaClApplication-html HTML markup and NMF file
You need to provide HTML markup containing `&lt;embed&gt;` pointing to `*.nmf`
file describing the application.
file describing the application. See @ref NaClApplication for more information.
You may want to hide the `&lt;embed&gt;` (for example using CSS
`visibility: hidden;`), as it probably won't display anything to default
framebuffer.
@todoc Document this better, add "bootstrap" examples
@subsection WindowlessNaClApplication-html-console Redirecting output to Chrome's JavaScript console
@section WindowlessNaClApplication-console Redirecting output to Chrome's JavaScript console
The application redirects @ref Corrade::Utility::Debug "Debug",
@ref Corrade::Utility::Warning "Warning" and @ref Corrade::Utility::Error "Error"

62
src/Platform/magnum-info-nacl.html

@ -2,37 +2,10 @@
<html>
<head>
<title>Magnum Info</title>
<link rel="stylesheet" href="NaClApplication.css" />
<style type="text/css">
body {
margin: 0px;
padding: 0px;
font-family: sans-serif;
background-color: #111111;
color: #aaaaaa;
}
h1 {
text-align: center;
font-size: 20px;
}
#listener {
border-style: solid;
border-color: #333333;
border-width: 1px;
padding: 1px;
width: 640px;
height: 480px;
margin-left: auto;
margin-right: auto;
margin-top: 20px;
margin-bottom: 20px;
position: relative;
}
#module {
visibility: hidden;
position: absolute;
visibility: hidden; /* The module doesn't display anything */
}
#info {
@ -42,49 +15,24 @@ h1 {
font-family: monospace;
white-space: pre-wrap;
}
#status {
position: absolute;
width: 640px;
text-align: center;
top: 200px;
font-size: 30px;
font-weight: bold;
z-index: 9;
}
</style>
</head>
<body onload="pageLoaded();">
<body>
<h1>Magnum Info</h1>
<div id="listener">
<script type="text/javascript" src="NaClApplication.js"></script>
<script type="text/javascript">
var module = null;
function pageLoaded() {
if(!module) setStatus('Loading...');
}
function moduleLoaded() {
module = document.getElementById('module');
setStatus('');
}
function messageReceived(message) {
var info = document.getElementById('info');
info.innerHTML += message.data;
}
function setStatus(message) {
var status = document.getElementById('status');
if(status) status.innerHTML = message;
}
var listener = document.getElementById('listener');
listener.addEventListener('load', moduleLoaded, true);
listener.addEventListener('message', messageReceived, true);
</script>
<embed name="nacl" id="module" type="application/x-nacl" src="magnum-info.nmf" />
<div id="status">Initialization...</div>
<div id="statusDescription"></div>
<div id="info"></div>
</div>
</body>

4
src/SceneGraph/AbstractFeature.h

@ -143,8 +143,8 @@ class TransformingFeature: public SceneGraph::AbstractFeature3D {
If we take for example @ref Object "Object<MatrixTransformation3D>", it is
derived from @ref AbstractBasicObject "AbstractObject3D" and
@ref BasicMatrixTransformation3D "MatrixTransformation3D", which is derived
from @ref BasicAbstractTranslationRotationScaling3D "AbstractTranslationRotationScaling3D",
which is derived from @ref BasicAbstractTranslationRotation3D "AbstractTranslationRotation3D",
from @ref AbstractBasicTranslationRotationScaling3D "AbstractTranslationRotationScaling3D",
which is derived from @ref AbstractBasicTranslationRotation3D "AbstractTranslationRotation3D",
which is automatically extracted from the pointer in our constructor.
@section AbstractFeature-explicit-specializations Explicit template specializations

2
src/SceneGraph/MatrixTransformation2D.h

@ -38,7 +38,7 @@ namespace Magnum { namespace SceneGraph {
@brief Two-dimensional transformation implemented using matrices
Uses Math::Matrix3 as underlying type.
@see @ref MatrixTransformation2D, @ref scenegraph, @ref RigidBasicMatrixTransformation2D, @ref BasicMatrixTransformation3D
@see @ref MatrixTransformation2D, @ref scenegraph, @ref BasicRigidMatrixTransformation2D, @ref BasicMatrixTransformation3D
*/
template<class T> class BasicMatrixTransformation2D: public AbstractBasicTranslationRotationScaling2D<T> {
public:

8
src/SceneGraph/Object.h

@ -129,7 +129,7 @@ template<class Transformation> class MAGNUM_SCENEGRAPH_EXPORT Object: public Abs
* See @ref scenegraph-hierarchy for more information.
*/
/** @copydoc AbstractObject::scene() */
/** @copydoc AbstractBasicObject::scene() */
Scene<Transformation>* scene();
const Scene<Transformation>* scene() const; /**< @overload */
@ -271,13 +271,13 @@ template<class Transformation> class MAGNUM_SCENEGRAPH_EXPORT Object: public Abs
/* `objects` passed by copy intentionally (to avoid copy internally) */
static void setClean(std::vector<Object<Transformation>*> objects);
/** @copydoc AbstractObject::isDirty() */
/** @copydoc AbstractBasicObject::isDirty() */
bool isDirty() const { return !!(flags & Flag::Dirty); }
/** @copydoc AbstractObject::setDirty() */
/** @copydoc AbstractBasicObject::setDirty() */
void setDirty();
/** @copydoc AbstractObject::setClean() */
/** @copydoc AbstractBasicObject::setClean() */
void setClean();
/*@}*/

4
src/Shaders/DistanceFieldVector.frag

@ -68,7 +68,7 @@ void main() {
/* Outline */
if(outlineRange.x > outlineRange.y) {
lowp float mid = (outlineRange.x + outlineRange.y)/2.0;
lowp float half = (outlineRange.x - outlineRange.y)/2.0;
fragmentColor += smoothstep(half+smoothness, half-smoothness, distance(mid, intensity))*outlineColor;
lowp float halfRange = (outlineRange.x - outlineRange.y)/2.0;
fragmentColor += smoothstep(halfRange+smoothness, halfRange-smoothness, distance(mid, intensity))*outlineColor;
}
}

36
src/Shaders/FullScreenTriangle.glsl

@ -0,0 +1,36 @@
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013 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.
*/
#ifndef NEW_GLSL
attribute lowp vec4 position;
#endif
void fullScreenTriangle() {
#ifdef NEW_GLSL
gl_Position = vec4((gl_VertexID == 2) ? 3.0 : -1.0,
(gl_VertexID == 1) ? -3.0 : 1.0, 0.0, 1.0);
#else
gl_Position = position;
#endif
}

3
src/Shaders/resources.conf

@ -15,6 +15,9 @@ filename=Flat3D.vert
[file]
filename=Flat.frag
[file]
filename=FullScreenTriangle.glsl
[file]
filename=MeshVisualizer.vert

19
src/Text/DistanceFieldGlyphCache.cpp

@ -38,6 +38,7 @@ DistanceFieldGlyphCache::DistanceFieldGlyphCache(const Vector2i& originalSize, c
#if !defined(MAGNUM_TARGET_GLES) || defined(MAGNUM_TARGET_GLES3)
GlyphCache(TextureFormat::R8, originalSize, size, Vector2i(radius)),
#else
/* Luminance is not renderable in most cases */
GlyphCache(Context::current()->isExtensionSupported<Extensions::GL::EXT::texture_rg>() ?
TextureFormat::Red : TextureFormat::RGB, originalSize, size, Vector2i(radius)),
#endif
@ -48,16 +49,13 @@ DistanceFieldGlyphCache::DistanceFieldGlyphCache(const Vector2i& originalSize, c
#endif
#ifdef MAGNUM_TARGET_GLES2
/* Luminance is not renderable in most cases */
if(!Context::current()->isExtensionSupported<Extensions::GL::EXT::texture_rg>())
Warning() << "Text::DistanceFieldGlyphCache:" << Extensions::GL::EXT::texture_rg::string() << "not supported, using inefficient RGB format for glyph cache texture";
#endif
}
void DistanceFieldGlyphCache::setImage(const Vector2i& offset, const ImageReference2D& image) {
#ifndef MAGNUM_TARGET_GLES
MAGNUM_ASSERT_EXTENSION_SUPPORTED(Extensions::GL::ARB::texture_rg);
#endif
#if !defined(MAGNUM_TARGET_GLES) || defined(MAGNUM_TARGET_GLES3)
const TextureFormat internalFormat = TextureFormat::R8;
CORRADE_ASSERT(image.format() == ImageFormat::Red,
@ -86,6 +84,19 @@ void DistanceFieldGlyphCache::setImage(const Vector2i& offset, const ImageRefere
}
void DistanceFieldGlyphCache::setDistanceFieldImage(const Vector2i& offset, const ImageReference2D& image) {
#if !defined(MAGNUM_TARGET_GLES) || defined(MAGNUM_TARGET_GLES3)
CORRADE_ASSERT(image.format() == ImageFormat::Red,
"Text::DistanceFieldGlyphCache::setDistanceFieldImage(): expected" << ImageFormat::Red << "but got" << image.format(), );
#else
if(Context::current()->isExtensionSupported<Extensions::GL::EXT::texture_rg>())
CORRADE_ASSERT(image.format() == ImageFormat::Red,
"Text::DistanceFieldGlyphCache::setDistanceFieldImage(): expected" << ImageFormat::Red << "but got" << image.format(), );
/* Luminance is not renderable in most cases */
else CORRADE_ASSERT(image.format() == ImageFormat::RGB,
"Text::DistanceFieldGlyphCache::setDistanceFieldImage(): expected" << ImageFormat::RGB << "but got" << image.format(), );
#endif
texture()->setSubImage(0, offset, image);
}

15
src/Text/GlyphCache.cpp

@ -31,6 +31,8 @@
namespace Magnum { namespace Text {
/** @todo Do this using delegating constructors when support for GCC 4.6 is dropped */
GlyphCache::GlyphCache(const TextureFormat internalFormat, const Vector2i& originalSize, const Vector2i& size, const Vector2i& padding): _size(originalSize), _padding(padding) {
initialize(internalFormat, size);
}
@ -39,7 +41,17 @@ GlyphCache::GlyphCache(const TextureFormat internalFormat, const Vector2i& size,
initialize(internalFormat, size);
}
GlyphCache::GlyphCache(const Vector2i& originalSize, const Vector2i& size, const Vector2i& padding): _size(originalSize), _padding(padding) {
initialize(size);
}
GlyphCache::GlyphCache(const Vector2i& size, const Vector2i& padding): _size(size), _padding(padding) {
initialize(size);
}
GlyphCache::~GlyphCache() = default;
void GlyphCache::initialize(const Vector2i& size) {
#ifndef MAGNUM_TARGET_GLES
MAGNUM_ASSERT_EXTENSION_SUPPORTED(Extensions::GL::ARB::texture_rg);
#endif
@ -55,8 +67,6 @@ GlyphCache::GlyphCache(const Vector2i& size, const Vector2i& padding): _size(siz
initialize(internalFormat, size);
}
GlyphCache::~GlyphCache() = default;
void GlyphCache::initialize(const TextureFormat internalFormat, const Vector2i& size) {
/* Initialize texture */
_texture.setWrapping(Sampler::Wrapping::ClampToEdge)
@ -90,6 +100,7 @@ void GlyphCache::insert(const UnsignedInt glyph, Vector2i position, Rectanglei r
}
void GlyphCache::setImage(const Vector2i& offset, const ImageReference2D& image) {
/** @todo some internalformat/format checking also here (if querying internal format is not slow) */
_texture.setSubImage(0, offset, image);
}

10
src/Text/GlyphCache.h

@ -70,7 +70,7 @@ class MAGNUM_TEXT_EXPORT GlyphCache {
* although the actual glyph cache texture has @p size. Glyph
* @p padding can be used to account for e.g. glyph shadows.
*/
explicit GlyphCache(TextureFormat internalFormat, const Vector2i& originalSize, const Vector2i& size, const Vector2i& padding);
explicit GlyphCache(TextureFormat internalFormat, const Vector2i& originalSize, const Vector2i& size, const Vector2i& padding = Vector2i());
/**
* @brief Constructor
@ -87,6 +87,13 @@ class MAGNUM_TEXT_EXPORT GlyphCache {
* ES2 uses @es_extension{EXT,texture_rg}, if available, or
* @ref TextureFormat "TextureFormat::Luminance" as fallback.
*/
explicit GlyphCache(const Vector2i& originalSize, const Vector2i& size, const Vector2i& padding = Vector2i());
/**
* @brief Constructor
*
* Same as calling the above with @p originalSize and @p size the same.
*/
explicit GlyphCache(const Vector2i& size, const Vector2i& padding = Vector2i());
virtual ~GlyphCache();
@ -178,6 +185,7 @@ class MAGNUM_TEXT_EXPORT GlyphCache {
virtual void setImage(const Vector2i& offset, const ImageReference2D& image);
private:
void MAGNUM_LOCAL initialize(const Vector2i& size);
void MAGNUM_LOCAL initialize(TextureFormat internalFormat, const Vector2i& size);
Vector2i _size, _padding;

2
src/Text/TextRenderer.cpp

@ -218,7 +218,7 @@ void* AbstractTextRenderer::bufferMapImplementationSub(Buffer& buffer, GLsizeipt
}
void AbstractTextRenderer::bufferUnmapImplementationSub(Buffer& buffer) {
buffer.unmap();
buffer.unmapSub();
}
#endif

1
src/TextureTools/DistanceField.cpp

@ -79,6 +79,7 @@ DistanceFieldShader::DistanceFieldShader(): radiusUniform(0), scalingUniform(1)
Shader vert(v, Shader::Type::Vertex);
vert.addSource(rs.get("compatibility.glsl"))
.addSource(rs.get("FullScreenTriangle.glsl"))
.addSource(rs.get("DistanceFieldShader.vert"));
CORRADE_INTERNAL_ASSERT_OUTPUT(vert.compile());
attachShader(vert);

6
src/TextureTools/DistanceFieldShader.frag

@ -36,10 +36,14 @@
#ifdef EXPLICIT_UNIFORM_LOCATION
layout(location = 0) uniform int radius;
layout(location = 1) uniform vec2 scaling;
layout(binding = 8) uniform sampler2D textureData;
#else
uniform lowp int radius;
uniform mediump vec2 scaling;
#endif
#ifdef EXPLICIT_TEXTURE_LAYER
layout(binding = 8) uniform sampler2D textureData;
#else
uniform lowp sampler2D textureData;
#endif

11
src/TextureTools/DistanceFieldShader.vert

@ -22,15 +22,6 @@
DEALINGS IN THE SOFTWARE.
*/
#ifndef NEW_GLSL
attribute lowp vec4 position;
#endif
void main() {
#ifdef NEW_GLSL
gl_Position = vec4((gl_VertexID == 2) ? 3.0 : -1.0,
(gl_VertexID == 1) ? -3.0 : 1.0, 0.0, 1.0);
#else
gl_Position = position;
#endif
fullScreenTriangle();
}

4
src/TextureTools/resources.conf

@ -1,5 +1,9 @@
group=MagnumTextureTools
[file]
filename=../Shaders/FullScreenTriangle.glsl
alias=FullScreenTriangle.glsl
[file]
filename=DistanceFieldShader.vert

Loading…
Cancel
Save