It's now possible to do the reading operation in one statement.
Previously it was needed to have mutable variable:
Image2D image{ColorFormat::RGBA, ColorType::UnsignedByte};
framebuffer.read(framebuffer.viewport(), image);
Currently:
const Image2D image = framebuffer.read(framebuffer.viewport(),
{ColorFormat::RGBA, ColorType::UnsignedByte});
To make this possible, the two-parameter Image and BufferImage
constructors are now made implicit.
Not sure why I chose to have offset and size in these two function, but
that's probably because I never used them in real code. The original
overloads taking pair of Vector2i are now marked as deprecated and will
be removed in future release.
The indexed binding is allowed for only some types (atomic counters,
uniforms, shader storage and transform feedback), thus we need separate
enum for that. Because the bind() function will be used far more often
than setTargetHint(), the original Target enum is now renamed to
TargetHint and the new Target enum contains (in non-deprecated build)
only three values.
For backwards compatibility, though, we need to have all original Target
values, thus the new Target enum contains also all other values from
TargetHint, but they are marked as deprecated and (at least) run-time
checked in bind() so they aren't accidentaly used for indexed binding.
Similarly there are also deprecated Target overloads of Buffer() and
setTargetHint(). It's ugly, but hopefully will suffice for now. This mess
will be removed as soon as possible in some upcoming version.
There should be no need to use these directly (and in some cases it
might be harmful). The bind()/unbind() names will be used for
glBindBufferBase()/glBindBufferRange() later.
The documentation of ARB_invalidate_subdata mentions that all the
functions are really just a hint for the implementation to make some
performance optimizations and they are not affecting behavior at all. So
it's perfectly fine to do nothing if the extension is not supported.
I didn't do this originally as I mistakenly thought that invalidating
depth buffer would somehow behave the same as clearing it, but that's
not the case.
The only places where they aren't absolute are:
- when header is included from corresponding source file
- when including headers which are not part of final installation (e.g.
test-specific configuration, headers from Implementation/)
Everything what was in src/ is now in src/Corrade, everything from
src/Plugins is now in src/MagnumPlugins, everything from external/ is in
src/MagnumExternal. Added new CMakeLists.txt file and updated the other
ones for the moves, no other change was made. If MAGNUM_BUILD_DEPRECATED
is set, everything compiles and installs like previously except for the
plugins, which are now in MagnumPlugins and not in Magnum/Plugins.
We don't have extension loader for ES yet, thus we need to abort on
these to avoid undefined behavior. The only exception is NaCl, which
provides _some_ extensions without the need for extension loader. These
extensions are implemented in particular:
CHROMIUM_map_sub
EXT_occlusion_query_boolean
Move constructor and move assignment now behaves similarly to Image
(not only the buffer but also size is swapped). Added constructor taking
size + data, reordered setData() parameters to match order in Image. The
old setData() function is now alias to the new one, is marked as
deprecated and will be removed in future release.
Encourages vectorization and generic usage even more. Some functions
were rewritten to make use of the new features, resulting in shorter and
more readable code. This also fixes the annoying naming collision with
WINAPI Rectangle() function.
The old Rectangle is now subclass of Range2D, is marked as deprecated
and will be removed in future release.
Until recently (or maybe not too recently) ES3 extension header was
"currently empty", now the extension header is shared with ES2. It's
nice to finally get rid of all the weird ifndefs.
Buffer usage is used as parameter in many functions, e.g. in
*Framebuffer::read() and *Texture::image(), but they are rather seldom
used and including whole Buffer.h file just for one enum is just
overkill. The old Buffer::Usage is now alias to BufferUsage, it is
marked as deprecated and will be removed in future release.
Makes the lines shorter, the conversions are mainly from strongly-typed
enums to underlying type, so nothing potentially harmful which should be
marked with static_cast.
Passing pointer as function parameter will now mean that it is possible
to pass `nullptr`. Some code examples now look like the parameter is
copied instead of referenced, which is misleading. Updated the
documentation to reflect that more clearly.
Makes some cases less consistent (and some convenience shortcuts
impossible), but goes well with the attitude "don't use pointer when it
can't be null".
Separated EXT_framebuffer_object, EXT_framebuffer_blit,
EXT_framebuffer_multisample and EXT_packed_depth_stencil don't have the
same functionality as ARB_framebuffer_object (e.g. missing
GL_FRAMEBUFFER_UNDEFINED in glCheckFramebufferStatus()) and separated
read/draw binding is only in EXT_framebuffer_blit, which complicates the
internals.
Checked with Mesa 8/9 and OpenGL 2.1, current one has
ARB_framebuffer_object and also all these four, Mesa 7.7 didn't have
EXT_framebuffer_multisample, but that's a long time ago, so not
supporting these separate extensions shouldn't be an issue.
The problem with unavailable separate binding points remains on OpenGL
ES 2.0, there are three different extensions bringing that
functionality, thus the code managing the available binding points
remains there.
Advantages:
* The enums were large (600-800 lines) and they polluted the header,
now they are in separate files (except for BufferTexture, which has
the enum small enough to be left in the same file).
* Image classes now don't need to include OpenGL headers, as they were
needed only for the enum values. With advantage of C++11's forward
enum declarations there is no need to include the enum headers
anywhere in implementation, only when particular values are needed.
* The values are now less verbose:
AbstractTexture::InternalFormat::RGB8 // before
TextureFormat::RGB8 // now
* Resolved another "trivial choice" problem (thanks @JanDupal for
introducing this term to me): how to specify the format if there are
ten ways to do it (some being massively confusing):
Image2D::Format f = AbstractImage::Format::RGB; // too long...
Image2D::Format f = Image3D::Format::RGBA; // why 3D? this works?
Image2D::Format f = BufferImage1D::Format::RGBA; // wat?
It is even worse (and more verbose) with textures:
Texture2D::InternalFormat f =
CubeMapTextureArray::InternalFormat::RGB8; // this is allowed?
To have consistent naming this change was done also with
BufferTexture::InternalFormat (now BufferTextureFormat), although there
were no trivial choice issues and the enum isn't too large. But at least
it is now less typing.
There will be more parameters like row length etc. which would need to
be passed too. This function now expects properly formatted empty image
which it fills with data.
Robust *Framebuffer::read() access, ability to query robust buffer
access behavior in Context::flags(), ability to check graphics reset
status and reset notification policy in Renderer.