void UiRenderPass::render(Renderer* client, const DrawContext& context) { sLock.lock(); myDrawTimeStat->startTiming(); if(context.task == DrawContext::SceneDrawTask) { client->getRenderer()->beginDraw3D(context); glPushAttrib(GL_ALL_ATTRIB_BITS); // This is a bit of a hack. DIsable depth testing for ui stuff. We will take care of ordering. // This may lead to depth inconsistencies wrt the background scene when drawing 3d menus, but we want te // menus to always be visible and unoccluded by geometry. glDisable(GL_DEPTH_TEST); ui::Container* ui = myUiRoot; Renderable* uiRenderable = ui->getRenderable(client); if(uiRenderable != NULL) { uiRenderable->draw(context); } glPopAttrib(); client->getRenderer()->endDraw(); } else if(context.task == DrawContext::OverlayDrawTask) { Vector2i displaySize; // check if the tile is part of a canvas (a multi-tile grid). If it is, // get the canvas resolution. Otherwise simply use the tile resolution. if(context.tile->isInGrid) { DisplaySystem* ds = SystemManager::instance()->getDisplaySystem(); displaySize = ds->getCanvasSize(); } else { displaySize = context.tile->pixelSize; } client->getRenderer()->beginDraw2D(context); glPushAttrib(GL_ALL_ATTRIB_BITS); Renderable* uiRenderable = myUiRoot->getRenderable(client); if(uiRenderable != NULL) { uiRenderable->draw(context); } glPopAttrib(); client->getRenderer()->endDraw(); } myDrawTimeStat->stopTiming(); sLock.unlock(); }
void PortholeCustomDrawApplication::handleEvent(const Event& evt) { if(evt.getServiceType() == Service::Pointer) { // Normalize the mouse position using the total display resolution, // then multiply to get 180 degree rotations DisplaySystem* ds = getEngine()->getDisplaySystem(); Vector2i resolution = ds->getCanvasSize(); myYaw = (evt.getPosition().x() / resolution[0]) * 180; myPitch = (evt.getPosition().y() / resolution[1]) * 180; } }