Discussion:
[Opensg-users] OpenSG2: Clarification wrpt. to changed notification...
Johannes Brunen
2017-02-17 10:12:24 UTC
Permalink
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
Marcus Lindblom Sonestedt
2017-02-17 12:11:50 UTC
Permalink
Hi Johannes,

FWIW, Doing & and checking != 0 to detect which fields did changed sounds
reasonable to me.
It's what we're doing in our custom FCs.

Doing it via ~ and == 0 means checking "did only these fields change?",
which is also a valid use case, since one could optimize for that case (not
reupload texture, just change mipmap status?).

But one does need to do something in the "else" section, and I haven't
looked at those classes to see if that is so.

Cheers
/Marcus
Post by Johannes Brunen
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.
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
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
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
------------------------------------------------------------
------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Opensg-users mailing list
https://lists.sourceforge.net/lists/listinfo/opensg-users
--
Med vÀnliga hÀlsningar,
Marcus Lindblom Sonestedt
*Systemarkitekt*
*BIT ADDICT *- Passion för utveckling
+46 (0)706 43 63 28
***@bitaddict.se
www.bitaddict.se
Loading...