fwilliams / fgfx Goto Github PK
View Code? Open in Web Editor NEWA typesafe OpenGL abstraction
License: GNU General Public License v2.0
A typesafe OpenGL abstraction
License: GNU General Public License v2.0
This is to be a static solution based on types. The strength of this approach is correctness can be achieved mostly at compile time. Run-time checks can also be implemented with minimal overhead.
The workflow this works well for is as follows:
If new vertex attributes are added to the shader, a recompile could be necessary if the type of vertex isn't available.
Currently, we take the types in a tuple and assume each entry will be used in order in a shader. That is, for a Tuple<T1, T2, ... TN>
the i
th value of type Ti
is bound to location i
in the shader program. This may not be the case because:
Tuple
without layout
parameters to specify locationSome possible solutions (Note this is an Idea dump):
Tuple<T1, ...., TN>
for shader type Tuple<T1,N1,...,TN, NN>
where Ni
is the name of Ti
.The offset of the tuple element is computed as 0 which is not correct. ListElement<0, C>
treats C
as the first element of a list whose offset in that list will always be zero. A naive solution is to pass the recursively through the EnableAttribArrayAOS
metafunction, but its worth investigating a better way.
template <size_t I, class ConsCell>
struct EnableAttribArrayAOS {
inline static void enable(size_t stride) {
typedef typename ConsCell::HeadType HT;
typedef typename ConsCell::TailType TT;
typedef ListElement<0, ConsCell> LE; // <=== The offset of this list element will always be 0 because of the 0 parameter cause ListElement to trea ConsCell as the head of the list
glEnableVertexAttribArray(I);
glVertexAttribPointer(I, utils::dim<HT>(), utils::gl_value_type_id<HT>(), GL_FALSE, stride, (void*)LE::offset());
EnableAttribArrayAOS<LE::offset() + OFF + sizeof(HT), I+1, TT>::enable(stride);
}
};
Ensure move semantics exist for gfx::Tuple
objects and are recursively applied to all members.
Design classes to wrap textures of type:
setCurrentTexture()
methodgetCurrentTexture()
methodImplement
is_glsl_type<T>
dim<T>
value_type_id<T>
gl_type_id<T>
container_type<T>
such that T
can be any glm
or fgfx
type with a corresponding GLSL type supported by OpenGL 3.3
Look into BOOST MPL to do this easily
Padding<size_t N>
type such that sizeof(Padding<N>)
is N
bytesPadding
structs. That is, for a tuple of type Tuple<int, Padding<2>, float>
, the 2nd item (get<1>()
) is of type float.See if gl_traits code can be reduced with boost MPL
\#pragma include
should work for multiple files.
Call preprocess
every time a new file is included up to some maximum recursion depth
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.