Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8690107
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T23:49:57+00:00 2026-06-12T23:49:57+00:00

I’ve created a structure called panel which render in OpenGL,works fine,but I want to

  • 0

I’ve created a structure called panel which render in OpenGL,works fine,but I want to add this to panel:

int flags;

then I define this in header :

#define PANEL_TITLE    0x0001
#define PANEL_MOVEABLE 0x0002
#define PANEL_SHADOW   0x0003

to use the flags value like this:

panel.flags = PANEL_TITLE | PANEL_MOVEABLE;

instead of have a lot :(which looks not good)

bool panel_has_title;
bool panel_moveable;
bool panel_shadow;

then check bool value,instead I can just have single int to achieve same result.I have read a lot open source stuff,that use flags,like the code above.
however my problem is it doesn’t work,when I check the flags with:

panel.flags = PANEL_TITLE | PANEL_MOVEABLE;
if(panel.flags & PANEL_TITLE) //this one works
{

}
if(panel.flags & PANEL_MOVEABLE) //this one doesn't work
{
  //not gets called
}

edit:
ok,now I’ve change it to

#define PANEL_TITLE    0x0002
#define PANEL_MOVEABLE 0x0004
#define PANEL_SHADOW   0x0008

are they intersect with each other again?
the new problem is if I set

panel.flags = PANEL_TITLE;

then every functions inside of it gets called

if(panel.flags & PANEL_TITLE)  
{
  //called which is normal
}
if(panel.flags & PANEL_MOVEABLE)  
{
  //called ..
}
if(panel.flags & PANEL_SHADOW)  
{
  //called ..
}

is it normal?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T23:49:58+00:00Added an answer on June 12, 2026 at 11:49 pm

    The problem here is that the bitmasks intersect with each other.
    e.g. (simplefied for 8 bit)

    #define PANEL_TITLE    0x0001 // 0b00000001
    #define PANEL_MOVEABLE 0x0002 // 0b00000010
    #define PANEL_SHADOW   0x0003 // 0b00000011
    

    What you want is this:

    #define PANEL_TITLE    0x0001 // 0b00000001
    #define PANEL_MOVEABLE 0x0002 // 0b00000010
    #define PANEL_SHADOW   0x0004 // 0b00000100
    

    edit to your edit:

    you don’t set them like that, you set them with:

    panel.flags |= PANEL_TITLE;
    

    And for the last problem, I can’t see anything wrong at first sight, try to step over it with a debugger and output the variable, that will give you a much clearer view of the problem

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to count how many characters a certain string has in PHP, but
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
This could be a duplicate question, but I have no idea what search terms
I want to construct a data frame in an Rcpp function, but when I
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I used javascript for loading a picture on my website depending on which small

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.