Comments (3)
Ah, I didn't realize that default member initialization prevented it being an aggregate until C++14. In my project I am using C++20 to see how the modern features would play with low level graphics. Luckily most of the large descriptors (e.g. GraphicsPipelineDescriptor
) are considered aggregates and allow for greater readability if I am constructing the descriptor within the function call.
The descriptors I noted not having aggregation in C++20 were ResourceHeapDescriptor
, BindingDescriptor
, and ShaderDescriptor
; although none of them were much of a bother.
Using explicit constructors to specify how many members should be initialized at once is a good idea, however, to keep with aggregate initialization with this constraint, you could make helper utility functions to construct it so designated initializers can still be made to whoever wants to (much like VertexBufferDesc
and similar).
Overall I think the library is great and thanks for making it.
from llgl.
It's true there are several constructors to emulate aggregate initialization, but the reason is that aggregate initialization does not work in conjunction with default initializers, at least not in C++11. According to cppreference.com, a struct with default member initializers is not an aggregate until C++14:
https://en.cppreference.com/w/cpp/language/aggregate_initialization
The idea for default initializers in the public interfaces is purely for stability.
Are there any particular structs that bother you to have such constructors or are there any structs missing such constructors?
Perhaps utilizing C++14 feature __cpp_aggregate_nsdmi is worth considering. On the other hand, though, explicit constructors allow to specify how many members should be initialized at once, for instance Viewport v = { x, y, width }
with a default value for height
would make no sense, but with a constructor you can declare that all four members have to be initialized at once.
Having said that, some structs would definitely benefit from C++20's designed initialization (a feature that exists since C99 btw), like ClearValue
or TextureDescriptor
for instance.
from llgl.
Thank you for your feedback.
VertexBufferDesc
is one of the utiliy functions, but perhaps it's not a bad idea to switch to more of those instead of holding aggregate initialization for C++20 compilers back. I might also consider just bumping up the minimum C++ version to C++14 at some point.
from llgl.
Related Issues (20)
- What's the minimum OpenGL version supported? HOT 4
- Can't run the examples HOT 6
- Multithreading example crash using DX12 renderer HOT 4
- ShaderReflection without shader initialization HOT 3
- Question: LLGL_OpenGL , WriteTexture HOT 5
- Hosting surfaces on non-Window, and factoring out message loop HOT 7
- vcpkg: LLGL installs header files in the wrong directory HOT 3
- WebGPU support? HOT 2
- A suggestion, or bug... HOT 2
- build fails on arch-based distro HOT 2
- Error creating custom surface classes in Mac OS BigSur and Xcode 12.4 HOT 11
- Mac OpenGL requires fragment shader HOT 2
- Primitive restart index not working on Mac OpenGL HOT 1
- CreateBuffer w. > 1MB bind=VertexBuffer on static build crashes HOT 2
- Multi submission of command buffer results in flickering HOT 3
- Vulkan swapChainImages and swapChainFrameBuffers not being properly deleted when SwapChain is recreated. HOT 4
- Vulkan Examples Issues HOT 1
- MacOSDisplay.mm: error: 'CVDisplayLinkRef' was not declared in this scope (and other related errors) HOT 21
- Support MSYS2 MINGW64 on Windows HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from llgl.