void QSGNode::setFlag(Flag f, bool enabled) { if (bool(m_nodeFlags & f) == enabled) return; m_nodeFlags ^= f; Q_ASSERT(int(UsePreprocess) == int(DirtyUsePreprocess)); int changedFlag = f & UsePreprocess; if (changedFlag) markDirty(DirtyState(changedFlag)); }
// Initializes the graphics system void _Graphics::Init(const _WindowSettings &WindowSettings) { this->WindowSize = WindowSettings.Size; this->Anisotropy = 0; FramesPerSecond = 0; FrameCount = 0; FrameRateTimer = 0; Context = 0; Window = 0; Enabled = true; DirtyState(); // Set root element Element = new _Element(); Element->Visible = true; Element->Size = WindowSize; Element->CalculateBounds(); // Set video flags Uint32 VideoFlags = SDL_WINDOW_OPENGL; if(WindowSettings.Fullscreen) VideoFlags |= SDL_WINDOW_FULLSCREEN_DESKTOP; // Set opengl attributes SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 1); SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_COMPATIBILITY); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1); // Set video mode Window = SDL_CreateWindow(WindowSettings.WindowTitle.c_str(), WindowSettings.Position.x, WindowSettings.Position.y, WindowSettings.Size.x, WindowSettings.Size.y, VideoFlags); if(Window == nullptr) throw std::runtime_error("SDL_CreateWindow failed"); // Set up opengl context Context = SDL_GL_CreateContext(Window); if(Context == nullptr) throw std::runtime_error("SDL_GL_CreateContext failed"); InitGLFunctions(); int MajorVersion, MinorVersion; SDL_GL_GetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, &MajorVersion); SDL_GL_GetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, &MinorVersion); // Set vsync SDL_GL_SetSwapInterval(WindowSettings.Vsync); // Set up OpenGL SetupOpenGL(); // Setup viewport ChangeViewport(WindowSize); png_init(0, 0); }
void QSGNode::setFlags(Flags f, bool enabled) { Flags oldFlags = m_nodeFlags; if (enabled) m_nodeFlags |= f; else m_nodeFlags &= ~f; Q_ASSERT(int(UsePreprocess) == int(DirtyUsePreprocess)); int changedFlags = (oldFlags ^ m_nodeFlags) & UsePreprocess; if (changedFlags) markDirty(DirtyState(changedFlags)); }