Johannes Brunen
2017-02-17 10:12:24 UTC
Hello,
I'm currently writing a chunk class and I'm a little puzzled about the 'whichField' and its usage that is provided to the 'changed' procedure.
I have found the following code in a number of classes:
void TextureChunk::changed(ConstFieldMaskArg whichField,...)
{
// Only filter changed? Mipmaps need reinit.
if((whichField & ~(MinFilterFieldMask | MagFilterFieldMask)) == 0)
{...
void TextureObjChunk::changed(ConstFieldMaskArg whichField,...)
{ ...
// Only filter changed? Mipmaps need reinit.
if((whichField & ~(MinFilterFieldMask | MagFilterFieldMask)) == 0)
{...
void GeoProperty::changed(ConstFieldMaskArg whichField, ...)
{
Inherited::changed(whichField, origin, details);
if(0x0000 != (whichField & ~UsageFieldMask))
{...
void UniformBufferObjStd140Chunk::changed(ConstFieldMaskArg whichField,...)
{...
if((whichField & ~(UsageFieldMask | BufferFieldMask)) == 0)
{
Window::reinitializeGLObject(id);
...
and some more. The last one is created by myself :-(
After thinking about it, I come to the conclusion that this usage pattern is not correct. If I understand correctly the whichField contains a bit pattern that has a 1 for each field that has changed. Then if I would like to test if that bit is set, I have to do a bit wise & operation to that bit. So for instance the TextureObjChunk code should read:
void TextureObjChunk::changed(ConstFieldMaskArg whichField,...)
{ ...
// Only filter changed? Mipmaps need reinit.
if((whichField & (MinFilterFieldMask | MagFilterFieldMask)) != 0)
{...
Could someone check that please or give me some lecturing so that I understand correctly and do it right in the first place next time.
In the context of the my new chunk class I do have an additional questions:
My chunk is derived from another chunk class that manages some OpenGL state. What is the correct way so that the parent chunk works correctly. What I mean is how can I force that the parent's 'activate', 'handleGL', etc. functions are properly called?
Is this allowed at all?
Best,
Johannes
I'm currently writing a chunk class and I'm a little puzzled about the 'whichField' and its usage that is provided to the 'changed' procedure.
I have found the following code in a number of classes:
void TextureChunk::changed(ConstFieldMaskArg whichField,...)
{
// Only filter changed? Mipmaps need reinit.
if((whichField & ~(MinFilterFieldMask | MagFilterFieldMask)) == 0)
{...
void TextureObjChunk::changed(ConstFieldMaskArg whichField,...)
{ ...
// Only filter changed? Mipmaps need reinit.
if((whichField & ~(MinFilterFieldMask | MagFilterFieldMask)) == 0)
{...
void GeoProperty::changed(ConstFieldMaskArg whichField, ...)
{
Inherited::changed(whichField, origin, details);
if(0x0000 != (whichField & ~UsageFieldMask))
{...
void UniformBufferObjStd140Chunk::changed(ConstFieldMaskArg whichField,...)
{...
if((whichField & ~(UsageFieldMask | BufferFieldMask)) == 0)
{
Window::reinitializeGLObject(id);
...
and some more. The last one is created by myself :-(
After thinking about it, I come to the conclusion that this usage pattern is not correct. If I understand correctly the whichField contains a bit pattern that has a 1 for each field that has changed. Then if I would like to test if that bit is set, I have to do a bit wise & operation to that bit. So for instance the TextureObjChunk code should read:
void TextureObjChunk::changed(ConstFieldMaskArg whichField,...)
{ ...
// Only filter changed? Mipmaps need reinit.
if((whichField & (MinFilterFieldMask | MagFilterFieldMask)) != 0)
{...
Could someone check that please or give me some lecturing so that I understand correctly and do it right in the first place next time.
In the context of the my new chunk class I do have an additional questions:
My chunk is derived from another chunk class that manages some OpenGL state. What is the correct way so that the parent chunk works correctly. What I mean is how can I force that the parent's 'activate', 'handleGL', etc. functions are properly called?
Is this allowed at all?
Best,
Johannes