void ColorTimeCache::addSample(double t, Color col) { if (isValidTime(t)) { samples[offset(t)].color += col; } }
void iMinimapView::ScrollMap(iPoint pos) { pos.x -= 20; pos.y -= 25; SCROLLINFO si; iRect clRect = iWMetrics::GetClRect(this->m_hWnd); //this->ClientToScreen( int left; int width; int top = 0; int height = 100; left = 24; width = 128; top = -8; height = 128; iRect frc(Screen2Map(m_frameLT, m_pMap->GetWidth()), Screen2Map(m_frameRB, m_pMap->GetWidth())); if (m_dibMap.GetWidth() > clRect.w || m_dibMap.GetHeight() > clRect.h){ uint32 factor = iMAX<uint32>(m_dibMap.GetWidth()/clRect.w, m_dibMap.GetHeight()/clRect.h )+1; iDib ndib(iSize(m_dibMap.GetWidth()/factor,m_dibMap.GetHeight()/factor)); iPoint offset(clRect.w/2 - ndib.GetSize().w/2, clRect.h/2 - ndib.GetSize().h/2); frc.x /= factor; frc.y /= factor; frc.w /= factor; frc.h /= factor; frc.Move(offset.x, offset.y); } else { uint32 factor = iMIN<uint32>(clRect.w / m_dibMap.GetWidth(), clRect.h / m_dibMap.GetHeight()); if (factor > 1) { iDib ndib(m_dibMap); iDibTransformer::MultiplySize(ndib, factor); iPoint offset(clRect.w/2 - ndib.GetSize().w/2, clRect.h/2 - ndib.GetSize().h/2); ndib.CopyToDibXY(&m_outBuff.m_Dib, offset, BLEND_ALPHABLEND); frc.x *= factor; frc.y *= factor; frc.w *= factor; frc.h *= factor; frc.Move(offset.x, offset.y); } else { iPoint offset(clRect.w/2 - m_dibMap.GetSize().w/2, clRect.h/2 - m_dibMap.GetSize().h/2); frc.Move(offset.x, offset.y); } } pos.x -= frc.w / 2; pos.y -= frc.h / 2; double hrz = 0, vrt = 0; if(pos.x <= left) hrz = 0.0; else if((unsigned)(pos.x) >= left + width) hrz = 1.0; else hrz = (double)(pos.x - left) / (double)width; if(pos.y <= top) vrt = 0.0; else if((unsigned)(pos.y) >= top + height) vrt = 1.0; else vrt = (double)(pos.y - top) / (double)height; if(pos.y < 0) vrt = 0.0; si.cbSize = sizeof(SCROLLINFO); si.fMask = SIF_RANGE; m_pMainView->GetScrollInfo(SB_HORZ, &si); m_pMainView->SendMessage(WM_HSCROLL, MAKEWPARAM(SB_THUMBPOSITION, (int)((double)si.nMax * hrz))); si.cbSize = sizeof(SCROLLINFO); si.fMask = SIF_RANGE; m_pMainView->GetScrollInfo(SB_VERT, &si); m_pMainView->SendMessage(WM_VSCROLL, MAKEWPARAM(SB_THUMBPOSITION, si.nMax * vrt)); }
struct **mpdochdod[docMax]; int fnMac = 1; struct **mpfnhfcb[fnMax]; int wwMac = 1; struct **mpwwhwwd[wwMax]; int mwMac = 1; struct **mpmwhmwd[mwMax]; #ifdef WIN int dclMac = 1; struct **mpdclhdcld[dclMax]; #endif extern struct MERR vmerr; struct CLSE dncls[clsMax] = { { &mpdochdod, &docMac, docMax, cwDOD, offset(MERR, fDocFull) }, { &mpfnhfcb, &fnMac, fnMax, cwFCB, offset(MERR, fFnFull) }, { &mpwwhwwd, &wwMac, wwMax, cwWWD, offset(MERR, fWwFull) }, { &mpmwhmwd, &mwMac, mwMax, cwMWD, offset(MERR, fMwFull) } #ifdef WIN ,{ &mpdclhdcld, &dclMac, dclMax, cwDCLD, offset(MERR, fDclFull) } #endif }; int vfUrgentAlloc = fTrue;
static float defaultsnapsize = DefaultSnapSize; static float defaultxmin = DefaultXMin; static float defaultxmax = DefaultXMax; static float defaultymin = DefaultYMin; static float defaultymax = DefaultYMax; static float defaultxscale = DefaultXScale; static float defaultyscale = DefaultYScale; /* Resources */ # define offset(field) XtOffsetOf(DrawingRec, field) static XtResource resources[] = { {XtNforeground, XtCForeground, XtRPixel, sizeof (Pixel), offset(drawing.foreground), XtRString, (XtPointer) XtDefaultForeground}, {XtNfont, XtCFont, XtRFontStruct, sizeof (XFontStruct *), offset(drawing.font), XtRString, (XtPointer) XtDefaultFont}, {XtNcoordinates, XtCCoordinates, XtRWidget, sizeof (Widget), offset(drawing.coord), XtRWidget, (XtPointer) NULL}, {XtNgrid, XtCGrid, XtRBoolean, sizeof (Boolean), offset(drawing.grid), XtRImmediate, (XtPointer) DefaultGrid}, {XtNgridSize, XtCGridSize, XtRFloat, sizeof (float), offset(drawing.gridSize), XtRFloat, (XtPointer) &defaultgridsize}, {XtNsnap, XtCSnap, XtRBoolean, sizeof (Boolean), offset(drawing.snap), XtRImmediate, (XtPointer) DefaultSnap}, {XtNsnapSize, XtCSnapSize, XtRFloat, sizeof (float), offset(drawing.snapSize), XtRFloat, (XtPointer) &defaultsnapsize}, {XtNxMin, XtCXMin, XtRFloat, sizeof (float), offset(drawing.xMin), XtRFloat, (XtPointer) &defaultxmin}, {XtNxMax, XtCXMax, XtRFloat, sizeof (float),
//-------------------------------------------------------------- void ofApp::setup(){ ofSetVerticalSync(true); ofSetFrameRate(60); ofDisableArbTex(); ofLoadImage(heightMap,"coral.jpg"); normalFbo.allocate(ofGetWidth(), ofGetHeight()); ofEnableArbTex(); normalShader.load("","normal.frag"); terrainShader.load("terrain"); mesh.setMode(OF_PRIMITIVE_TRIANGLE_STRIP); int rings = 32, resolution = 32; float length = 512, maxRadius = 128; for(int i = 0; i < rings; i++) { float radius = ofNoise(i / 5.) * maxRadius; ofVec3f offset(0, 0, ofMap(i, 0, rings, -length, length) / 2); for(int j = 0; j < resolution; j++) { float theta = ofMap(j, 0, resolution, 0, 360); //j/PI * 32; ofVec2f cur(radius, 0); cur.rotate(theta); mesh.addColor(j*255); mesh.addVertex(offset + cur*2); } } for(int i = 0; i < rings - 1; i++) { for(int j = 0; j < resolution; j++) { int sw = i * resolution + j, se = sw + 1; if(j + 1 == resolution) { se -= resolution; } int nw = sw + resolution, ne = se + resolution; mesh.addTriangle(sw, se, nw); mesh.addTriangle(nw, se, ne); mesh.addTriangle(nw, sw, se); int t = (i+j*resolution); int n = resolution - 1; int m = resolution + 1; mesh.addTexCoord(ofPoint(t % 2 == 0 ? 0 : rings )); mesh.addTexCoord(ofPoint(rings % 2 == 0 ? 0 : n )); mesh.addTexCoord(ofPoint(rings % 2 == 0 ? 0 : m )); mesh.addNormal(ofPoint(1,0,0)); if(j%2==0){ mesh.addIndex(j+i*resolution); // a mesh.addIndex((j+1)+i*resolution); // b mesh.addIndex(j+(i+1)*resolution); // d mesh.addIndex((j+1)+i*resolution); // b mesh.addIndex((j+1)+(i+1)*resolution); // c mesh.addIndex(j+(i+1)*resolution); // d }else{ mesh.addIndex((j+1)+i*resolution); // b mesh.addIndex(j+i*resolution); // a mesh.addIndex((j+1)+(j+1)*resolution); // c mesh.addIndex(j+i*resolution); // a mesh.addIndex(j+(i+1)*resolution); // d mesh.addIndex((j+1)+(i+1)*resolution); // c } } } light.enable(); bWireframe = true; }
void set_boundary(BndryData& bd, const MultiFab& rhs, int comp) { BL_PROFILE("set_boundary()"); Real bc_value = 0.0; for (int n=0; n<BL_SPACEDIM; ++n) { for (MFIter mfi(rhs); mfi.isValid(); ++mfi ) { int i = mfi.index(); const Box& bx = mfi.validbox(); // Our default will be that the face of this grid is either touching another grid // across an interior boundary or a periodic boundary. We will test for the other // cases below. { // Define the type of boundary conditions to be Dirichlet (even for periodic) bd.setBoundCond(Orientation(n, Orientation::low) ,i,comp,LO_DIRICHLET); bd.setBoundCond(Orientation(n, Orientation::high),i,comp,LO_DIRICHLET); // Set the boundary conditions to the cell centers outside the domain bd.setBoundLoc(Orientation(n, Orientation::low) ,i,0.5*dx[n]); bd.setBoundLoc(Orientation(n, Orientation::high),i,0.5*dx[n]); } // Now test to see if we should override the above with Dirichlet or Neumann physical bc's if (bc_type != Periodic) { int ibnd = static_cast<int>(bc_type); // either LO_DIRICHLET or LO_NEUMANN const Geometry& geom = bd.getGeom(); // We are on the low side of the domain in coordinate direction n if (bx.smallEnd(n) == geom.Domain().smallEnd(n)) { // Set the boundary conditions to live exactly on the faces of the domain bd.setBoundLoc(Orientation(n, Orientation::low) ,i,0.0 ); // Set the Dirichlet/Neumann boundary values bd.setValue(Orientation(n, Orientation::low) ,i, bc_value); #if 1 Array<Real> offset(BL_SPACEDIM,0.5); Orientation face(n,Orientation::low); offset[n] = (face.isHigh() ? 0 : 1); const BoxArray& ba = bd[face].boxArray(); MultiFab b(ba,1,0); compute_analyticSolution(b,offset); bd[face].copyFrom(b,0,0,0,1); #endif // Define the type of boundary conditions bd.setBoundCond(Orientation(n, Orientation::low) ,i,comp,ibnd); } // We are on the high side of the domain in coordinate direction n if (bx.bigEnd(n) == geom.Domain().bigEnd(n)) { // Set the boundary conditions to live exactly on the faces of the domain bd.setBoundLoc(Orientation(n, Orientation::high) ,i,0.0 ); // Set the Dirichlet/Neumann boundary values bd.setValue(Orientation(n, Orientation::high) ,i, bc_value); #if 1 Array<Real> offset(BL_SPACEDIM,0.5); Orientation face(n,Orientation::high); offset[n] = (face.isHigh() ? 0 : 1); const BoxArray& ba = bd[face].boxArray(); MultiFab b(ba,1,0); compute_analyticSolution(b,offset); bd[face].copyFrom(b,0,0,0,1); #endif // Define the type of boundary conditions bd.setBoundCond(Orientation(n, Orientation::high) ,i,comp,ibnd); } } } } }
Animation* CreateGridTexture(World* _world, Vector2i _grid_size) { bool fill = true; Vector2i offset(2, 2); Vector2i size = _grid_size * _world->GetSize() + Vector2i(4, 4); SDL_Surface* p_checkerboard = SDL_CreateRGBSurface(SDL_SWSURFACE, size.x, size.y, 32, rmask, gmask, bmask, amask); SDL_Surface* old_checkboard = p_checkerboard; p_checkerboard = SDL_DisplayFormatAlpha(p_checkerboard); SDL_FreeSurface(old_checkboard); SDL_SetAlpha(p_checkerboard, 0, 255); SDL_FillRect(p_checkerboard, NULL, SDL_MapRGB(p_checkerboard->format, 255, 255, 255)); SDL_Surface* old_screen = SDLAnimationFrame::screen_; SDLAnimationFrame::screen_ = p_checkerboard; for(int y = 0; y < _world->GetSize().y; y++) { fill = y % 2 == 0; for(int x = 0; x < _world->GetSize().x; x++) { fill = !fill; if(fill) StandardTextures::tile_a_animation->GetCurrentFrame()->Draw(offset + Vector2f(static_cast<float>(x * _grid_size.x), static_cast<float>(y * _grid_size.y))); else StandardTextures::tile_b_animation->GetCurrentFrame()->Draw(offset + Vector2f(static_cast<float>(x * _grid_size.x), static_cast<float>(y * _grid_size.y))); } } for(int y = 0; y < _world->GetSize().y; y++) { for(int x = 0; x < _world->GetSize().x; x++) { if(_world->GetGridSquare(Vector2i(x,y)).GetNorth()) { StandardTextures::wall_horz_animation->GetCurrentFrame()->Draw(Vector2f(static_cast<float>(x * _grid_size.x), static_cast<float>(y * _grid_size.y))); if(y == 0) { StandardTextures::wall_horz_animation->GetCurrentFrame()->Draw(Vector2f(static_cast<float>(x * _grid_size.x), static_cast<float>(_world->GetSize().y * _grid_size.y))); } } if(_world->GetGridSquare(Vector2i(x,y)).GetWest()) { StandardTextures::wall_vert_animation->GetCurrentFrame()->Draw(Vector2f(static_cast<float>(x * _grid_size.x), static_cast<float>(y * _grid_size.y))); if(x == 0) { StandardTextures::wall_vert_animation->GetCurrentFrame()->Draw(Vector2f(static_cast<float>(_world->GetSize().x * _grid_size.x), static_cast<float>(y * _grid_size.y))); } } } } SDLAnimationFrame::screen_ = old_screen; /* for(int y = 0; y < _world->GetSize().y; y++) { fill = y % 2 == 0; for(int x = 0; x < _world->GetSize().x; x++) { SDL_Rect area; area.x = x * _grid_size.x; area.y = y * _grid_size.y; area.w = _grid_size.x; area.h = _grid_size.y; if(fill) SDL_FillRect(p_checkerboard, &area, SDL_MapRGB(p_checkerboard->format, Settings::GetGridColorA().r, Settings::GetGridColorA().g, Settings::GetGridColorA().b)); else SDL_FillRect(p_checkerboard, &area, SDL_MapRGB(p_checkerboard->format, Settings::GetGridColorB().r, Settings::GetGridColorB().g, Settings::GetGridColorB().b)); fill = !fill; } } for(int y = 0; y < _world->GetSize().y; y++) { for(int x = 0; x < _world->GetSize().x; x++) { if(_world->GetGridSquare(Vector2i(x,y)).GetNorth()) { SDL_Rect area; area.x = x * _grid_size.x - 1; area.y = y * _grid_size.y - 1; area.w = _grid_size.x + 2; area.h = 2; SDL_FillRect(p_checkerboard, &area, SDL_MapRGB(p_checkerboard->format, 255, 0, 0)); if(y == 0) { area.y = _grid_size.y * _world->GetSize().y; SDL_FillRect(p_checkerboard, &area, SDL_MapRGB(p_checkerboard->format, 255, 0, 0)); } } if(_world->GetGridSquare(Vector2i(x,y)).GetWest()) { SDL_Rect area; area.x = x * _grid_size.x - 1; area.y = y * _grid_size.y - 1; area.w = 2; area.h = _grid_size.y + 2; SDL_FillRect(p_checkerboard, &area, SDL_MapRGB(p_checkerboard->format, 255, 0, 0)); if(x == 0) { area.x = _grid_size.x * _world->GetSize().x; SDL_FillRect(p_checkerboard, &area, SDL_MapRGB(p_checkerboard->format, 255, 0, 0)); } } } }*/ Animation* g_animation = new Animation(); SDLAnimationFrame* af = new SDLAnimationFrame(0, 0, Vector2i(0, 0), p_checkerboard); g_animation->AddFrame(af); return g_animation; }
void wxRibbonButtonBar::OnMouseMove(wxMouseEvent& evt) { wxPoint cursor(evt.GetPosition()); wxRibbonButtonBarButtonInstance* new_hovered = NULL; wxRibbonButtonBarButtonInstance* tooltipButton = NULL; long new_hovered_state = 0; wxRibbonButtonBarLayout* layout = m_layouts.Item(m_current_layout); size_t btn_count = layout->buttons.Count(); size_t btn_i; for(btn_i = 0; btn_i < btn_count; ++btn_i) { wxRibbonButtonBarButtonInstance& instance = layout->buttons.Item(btn_i); wxRibbonButtonBarButtonSizeInfo& size = instance.base->sizes[instance.size]; wxRect btn_rect; btn_rect.SetTopLeft(m_layout_offset + instance.position); btn_rect.SetSize(size.size); if(btn_rect.Contains(cursor)) { if((instance.base->state & wxRIBBON_BUTTONBAR_BUTTON_DISABLED) == 0) { tooltipButton = &instance; new_hovered = &instance; new_hovered_state = instance.base->state; new_hovered_state &= ~wxRIBBON_BUTTONBAR_BUTTON_HOVER_MASK; wxPoint offset(cursor); offset -= btn_rect.GetTopLeft(); if(size.normal_region.Contains(offset)) { new_hovered_state |= wxRIBBON_BUTTONBAR_BUTTON_NORMAL_HOVERED; } if(size.dropdown_region.Contains(offset)) { new_hovered_state |= wxRIBBON_BUTTONBAR_BUTTON_DROPDOWN_HOVERED; } break; } else if (m_show_tooltips_for_disabled) { tooltipButton = &instance; } } } #if wxUSE_TOOLTIPS if(tooltipButton == NULL && GetToolTip()) { UnsetToolTip(); } if(tooltipButton) { SetToolTip(tooltipButton->base->help_string); } #endif if(new_hovered != m_hovered_button || (m_hovered_button != NULL && new_hovered_state != m_hovered_button->base->state)) { if(m_hovered_button != NULL) { m_hovered_button->base->state &= ~wxRIBBON_BUTTONBAR_BUTTON_HOVER_MASK; } m_hovered_button = new_hovered; if(m_hovered_button != NULL) { m_hovered_button->base->state = new_hovered_state; } Refresh(false); } if(m_active_button && !m_lock_active_state) { long new_active_state = m_active_button->base->state; new_active_state &= ~wxRIBBON_BUTTONBAR_BUTTON_ACTIVE_MASK; wxRibbonButtonBarButtonSizeInfo& size = m_active_button->base->sizes[m_active_button->size]; wxRect btn_rect; btn_rect.SetTopLeft(m_layout_offset + m_active_button->position); btn_rect.SetSize(size.size); if(btn_rect.Contains(cursor)) { wxPoint offset(cursor); offset -= btn_rect.GetTopLeft(); if(size.normal_region.Contains(offset)) { new_active_state |= wxRIBBON_BUTTONBAR_BUTTON_NORMAL_ACTIVE; } if(size.dropdown_region.Contains(offset)) { new_active_state |= wxRIBBON_BUTTONBAR_BUTTON_DROPDOWN_ACTIVE; } } if(new_active_state != m_active_button->base->state) { m_active_button->base->state = new_active_state; Refresh(false); } } }
LTBOOL CMenuMgr::Init() { //build menu array m_MenuArray.reserve(MENU_ID_UNASSIGNED); //add menus here m_MenuArray.push_back(&m_MenuSystem); m_MenuArray.push_back(&m_MenuMission); m_MenuArray.push_back(&m_MenuInventory); m_MenuArray.push_back(&m_MenuKeys); m_MenuArray.push_back(&m_MenuIntel); m_MenuArray.push_back(&m_MenuPlayer); //init menus MenuArray::iterator iter = m_MenuArray.begin(); while (iter != m_MenuArray.end()) { if (!(*iter)->Init()) return LTFALSE; iter++; } m_fSlideInTime = g_pLayoutMgr->GetMenuSlideInTime(); m_fSlideOutTime = g_pLayoutMgr->GetMenuSlideOutTime(); m_nMenuPos = g_pLayoutMgr->GetMenuPosition(); char szTemp[128]; char *pTag = "Menu"; g_pLayoutMgr->GetString(pTag,"SlideInSound",szTemp,sizeof(szTemp)); m_sSlideInSound = szTemp; g_pLayoutMgr->GetString(pTag,"SlideOutSound",szTemp,sizeof(szTemp)); m_sSlideOutSound = szTemp; g_pLayoutMgr->GetString(pTag,"Bar",szTemp,sizeof(szTemp)); HTEXTURE hBar = g_pInterfaceResMgr->GetTexture(szTemp); g_pLayoutMgr->GetString(pTag,"BarTip",szTemp,sizeof(szTemp)); HTEXTURE hBarTip = g_pInterfaceResMgr->GetTexture(szTemp); LTIntPt size = g_pLayoutMgr->GetPoint(pTag,"BarSize"); uint8 fontFace = (uint8)g_pLayoutMgr->GetInt(pTag,"BarFont"); uint8 fontSize = (uint8)g_pLayoutMgr->GetInt(pTag,"BarFontSize"); m_nBarPos = g_pLayoutMgr->GetInt(pTag,"BarPosition"); int nBarSpacing = g_pLayoutMgr->GetInt(pTag,"BarSpacing"); LTVector vCol = g_pLayoutMgr->GetVector(pTag,"BarSelectColor"); uint8 nR = (uint8)vCol.x; uint8 nG = (uint8)vCol.y; uint8 nB = (uint8)vCol.z; g_nSelectColor = SET_ARGB(0xFF,nR,nG,nB); m_MenuBar.Init(hBar,hBarTip,size); m_MenuBar.SetBasePos(LTIntPt(0,m_nBarPos)); CUIFont* pFont = g_pInterfaceResMgr->GetFont(fontFace); LTIntPt offset(nBarSpacing,(size.y-fontSize)/2); for (uint8 i =0; i < m_MenuArray.size(); i++) { CLTGUITextCtrl *pCtrl = debug_new(CLTGUITextCtrl); CBaseMenu *pMenu = m_MenuArray[i]; pCtrl->Create(pMenu->GetTitle(),i,NULL,pFont,fontSize,&m_MenuBar); pCtrl->SetColors(g_nSelectColor,argbBlack,argbWhite); pCtrl->SetParam1(pMenu->GetMenuID()); m_MenuBar.AddControl(pCtrl,offset); offset.x += nBarSpacing + pCtrl->GetWidth(); } return LTTRUE; }
// Move object to location, specifying (optional) vertex to be positioned at pos void Geometry::moveTo(const Point &pos, S32 vertexIndexToBePositionedAtPos) { offset(pos - getVert(vertexIndexToBePositionedAtPos)); }
Offset(left), XtRImmediate, (XtPointer) 0 }, { XtNright, XtCFraction, XtRInt, sizeof(int), Offset(right), XtRImmediate, (XtPointer) 100 } }; #undef Offset #define offset(name) XtOffsetOf(FrameRec, frame.name) static XtResource resources[] = { { XtNhSpace, XtCHSpace, XtRDimension, sizeof(Dimension), offset(h_space), XtRImmediate, (XtPointer)4 }, { XtNvSpace, XtCVSpace, XtRDimension, sizeof(Dimension), offset(v_space), XtRImmediate, (XtPointer)4 }, { XtNshadowWidth, XtCShadowWidth, XtRDimension, sizeof(Dimension), XtOffsetOf(FrameRec, container.shadow_thickness), XtRImmediate, (XtPointer) 2 }, { XtNframeType, XtCFrameType, XtRFrameType, sizeof(XawFrameType), offset(frame_type), XtRImmediate, (XtPointer) XawCHISELED }, {
void Hud::drawLuaElements(v3s16 camera_offset) { for (size_t i = 0; i != player->hud.size(); i++) { HudElement *e = player->hud[i]; if (!e) continue; v2s32 pos(floor(e->pos.X * (float) m_screensize.X + 0.5), floor(e->pos.Y * (float) m_screensize.Y + 0.5)); switch (e->type) { case HUD_ELEM_IMAGE: { video::ITexture *texture = tsrc->getTexture(e->text); if (!texture) continue; const video::SColor color(255, 255, 255, 255); const video::SColor colors[] = {color, color, color, color}; core::dimension2di imgsize(texture->getOriginalSize()); v2s32 dstsize(imgsize.Width * e->scale.X, imgsize.Height * e->scale.Y); if (e->scale.X < 0) dstsize.X = m_screensize.X * (e->scale.X * -0.01); if (e->scale.Y < 0) dstsize.Y = m_screensize.Y * (e->scale.Y * -0.01); v2s32 offset((e->align.X - 1.0) * dstsize.X / 2, (e->align.Y - 1.0) * dstsize.Y / 2); core::rect<s32> rect(0, 0, dstsize.X, dstsize.Y); rect += pos + offset + v2s32(e->offset.X, e->offset.Y); driver->draw2DImage(texture, rect, core::rect<s32>(core::position2d<s32>(0,0), imgsize), NULL, colors, true); break; } case HUD_ELEM_TEXT: { video::SColor color(255, (e->number >> 16) & 0xFF, (e->number >> 8) & 0xFF, (e->number >> 0) & 0xFF); core::rect<s32> size(0, 0, e->scale.X, text_height * e->scale.Y); std::wstring text = narrow_to_wide(e->text); core::dimension2d<u32> textsize = font->getDimension(text.c_str()); v2s32 offset((e->align.X - 1.0) * (textsize.Width / 2), (e->align.Y - 1.0) * (textsize.Height / 2)); v2s32 offs(e->offset.X, e->offset.Y); font->draw(text.c_str(), size + pos + offset + offs, color); break; } case HUD_ELEM_STATBAR: { v2s32 offs(e->offset.X, e->offset.Y); drawStatbar(pos, HUD_CORNER_UPPER, e->dir, e->text, e->number, offs, e->size); break; } case HUD_ELEM_INVENTORY: { InventoryList *inv = inventory->getList(e->text); drawItems(pos, e->number, 0, inv, e->item, e->dir); break; } case HUD_ELEM_WAYPOINT: { v3f p_pos = player->getPosition() / BS; v3f w_pos = e->world_pos * BS; float distance = floor(10 * p_pos.getDistanceFrom(e->world_pos)) / 10; scene::ICameraSceneNode* camera = smgr->getActiveCamera(); w_pos -= intToFloat(camera_offset, BS); core::matrix4 trans = camera->getProjectionMatrix(); trans *= camera->getViewMatrix(); f32 transformed_pos[4] = { w_pos.X, w_pos.Y, w_pos.Z, 1.0f }; trans.multiplyWith1x4Matrix(transformed_pos); if (transformed_pos[3] < 0) break; f32 zDiv = transformed_pos[3] == 0.0f ? 1.0f : core::reciprocal(transformed_pos[3]); pos.X = m_screensize.X * (0.5 * transformed_pos[0] * zDiv + 0.5); pos.Y = m_screensize.Y * (0.5 - transformed_pos[1] * zDiv * 0.5); video::SColor color(255, (e->number >> 16) & 0xFF, (e->number >> 8) & 0xFF, (e->number >> 0) & 0xFF); core::rect<s32> size(0, 0, 200, 2 * text_height); std::wstring text = narrow_to_wide(e->name); font->draw(text.c_str(), size + pos, color); std::ostringstream os; os<<distance<<e->text; text = narrow_to_wide(os.str()); pos.Y += text_height; font->draw(text.c_str(), size + pos, color); break; } default: infostream << "Hud::drawLuaElements: ignoring drawform " << e->type << " of hud element ID " << i << " due to unrecognized type" << std::endl; } } }
* the colormap, we allow it to allocate the default one, since we have * not yet determined the appropriate visual (which is determined from * resources parsed after the colormap). We also let it allocate colors * in that default colormap. * * In the initialize proc we calculate the actual visual. Then, we * reobtain the colormap resource using XtGetApplicationResources in * the initialize proc. If requested, we also reallocate colors in * that colormap using the same method. */ static XtResource resources[] = { /* the visual info is the only GL resource we allow */ {SoGLwNvisualInfo, SoGLwCVisualInfo, SoGLwRVisualInfo, sizeof (XVisualInfo *), offset(visualInfo), XtRImmediate, (XtPointer) NULL}, /* miscellaneous resources */ {SoGLwNinstallColormap, SoGLwCInstallColormap, XtRBoolean, sizeof (Boolean), offset(installColormap), XtRImmediate, (XtPointer) TRUE}, {SoGLwNallocateBackground, SoGLwCAllocateColors, XtRBoolean, sizeof (Boolean), offset(allocateBackground), XtRImmediate, (XtPointer) FALSE}, {SoGLwNallocateOtherColors, SoGLwCAllocateColors, XtRBoolean, sizeof (Boolean), offset(allocateOtherColors), XtRImmediate, (XtPointer) FALSE}, {SoGLwNinstallBackground, SoGLwCInstallBackground, XtRBoolean, sizeof (Boolean), offset(installBackground), XtRImmediate, (XtPointer) TRUE}, {SoGLwNginitCallback, SoGLwCCallback, XtRCallback, sizeof (XtCallbackList),
bool PixelsToPositions(const String& filename, Vector2List &positions, float gridSize, const Color& pixelColor, float tolerance) { #if _ANGEL_DISABLE_DEVIL png_byte* pngData; float* rawData; png_uint_32 width, height; if (!LoadPNG(filename, pngData, width, height, true)) { //error was output by the load return false; } // convert png ubyte data to float array rawData = (float*)malloc(3 * width * height * sizeof(float)); int j = 0; for (int i = 0; i < (4 * width * height); i++) { if ((i+1) % 4) { rawData[j] = (float)pngData[i] / 255.0f; j++; } } free(pngData); #else ILuint imgRef; ilGenImages(1, &imgRef); ilBindImage(imgRef); // load image into DevIL if (!ilLoadImage(filename.c_str())) { HandleDevILErrors(filename); return false; } // get image datums unsigned int width = ilGetInteger(IL_IMAGE_WIDTH); unsigned int height = ilGetInteger(IL_IMAGE_HEIGHT); // convert it to RGB floats for easy comparison ilConvertImage(IL_RGB, IL_FLOAT); // flip it if we need to if (ilGetInteger(IL_IMAGE_ORIGIN) != IL_ORIGIN_LOWER_LEFT) { iluFlipImage(); } // grab the raw data ILfloat* rawData = (ILfloat*)ilGetData(); #endif //_ANGEL_DISABLE_DEVIL // check every pixel, see if it's within the tolerance of the target float w = -((float)width)*gridSize/2.f; float h = -((float)height)*gridSize/2.f; Vector2 offset(w, h); float pixR, pixG, pixB; unsigned int pixOffset = 0; for (int y=0; y < height; y++) { for (int x=0; x < width; x++) { pixOffset = (y * width * 3) + (x * 3); pixR = rawData[pixOffset]; pixG = rawData[pixOffset + 1]; pixB = rawData[pixOffset + 2]; if ( fabs(pixR - pixelColor.R) <= tolerance && fabs(pixG - pixelColor.G) <= tolerance && fabs(pixB - pixelColor.B) <= tolerance ) { positions.push_back(offset + Vector2(x * gridSize, y * gridSize)); } } } // cleanup and return #if _ANGEL_DISABLE_DEVIL free(rawData); #else ilDeleteImages(1, &imgRef); #endif return true; }
std::string SrcKey::showInst() const { auto const u = unit(); return instrToString(u->at(offset()), u); }
void json_parser<_Handler>::object() { assert(cur_char() == '{'); m_handler.begin_object(); for (next(); has_char(); next()) { skip_blanks(); if (!has_char()) throw json::parse_error("object: stream ended prematurely before reaching a key.", offset()); switch (cur_char()) { case '}': m_handler.end_object(); next(); skip_blanks(); return; case '"': break; default: json::parse_error::throw_with( "object: '\"' was expected, but '", cur_char(), "' found.", offset()); } parse_quoted_string_state res = parse_string(); if (!res.str) { // Parsing was unsuccessful. if (res.length == parse_quoted_string_state::error_no_closing_quote) throw json::parse_error("object: stream ended prematurely before reaching the closing quote of a key.", offset()); else if (res.length == parse_quoted_string_state::error_illegal_escape_char) json::parse_error::throw_with( "object: illegal escape character '", cur_char(), "' in key value.", offset()); else throw json::parse_error("object: unknown error while parsing a key value.", offset()); } m_handler.object_key(res.str, res.length, res.transient); skip_blanks(); if (cur_char() != ':') json::parse_error::throw_with( "object: ':' was expected, but '", cur_char(), "' found.", offset()); next(); skip_blanks(); if (!has_char()) throw json::parse_error("object: stream ended prematurely before reaching a value.", offset()); value(); skip_blanks(); if (!has_char()) throw json::parse_error("object: stream ended prematurely before reaching either ']' or ','.", offset()); switch (cur_char()) { case '}': m_handler.end_object(); next(); skip_blanks(); return; case ',': continue; default: json::parse_error::throw_with( "object: either ']' or ',' expected, but '", cur_char(), "' found.", offset()); } } throw json::parse_error("object: closing '}' was never reached.", offset()); }
void Piano::draw(QPainter& p, const QRect& r) { QPoint offset(0, KH*2); p.drawTiledPixmap(r, *octave, r.topLeft()+offset); if (_curSelectedPitch != -1 && _curSelectedPitch != curPitch) { int y = pitch2y(_curSelectedPitch); QPixmap* pm; switch(_curSelectedPitch % 12) { case 0: case 5: pm = mk7; break; case 2: case 7: case 9: pm = mk6; break; case 4: case 11: pm = mk5; break; default: pm = mk8; break; } p.drawPixmap(0, y, *pm); } if (curPitch != -1) { int y = pitch2y(curPitch); QPixmap* pm; switch(curPitch % 12) { case 0: case 5: pm = mk3; break; case 2: case 7: case 9: pm = mk2; break; case 4: case 11: pm = mk1; break; default: pm = mk4; break; } p.drawPixmap(0, y, *pm); } // draw C notes for (int drawKey = 0; drawKey < 9;drawKey++) { int octaveSize=91; int drawY = octaveSize * drawKey + 82 - KH*2; if (drawY > r.y() && drawY < r.y() + r.height()) { p.drawPixmap(0,drawY,*c_keys[drawKey]); } } if(!_midiEditor) return; MusECore::PartList* part_list = _midiEditor->parts(); MusECore::Part* cur_part = _midiEditor->curCanvasPart(); if(!part_list || !cur_part) return; MusECore::MidiTrack* track = (MusECore::MidiTrack*)(cur_part->track()); int channel = track->outChannel(); MusECore::MidiPort* port = &MusEGlobal::midiPorts[track->outPort()]; MusECore::MidiCtrlValListList* cll = port->controller(); const int min = channel << 24; const int max = min + 0x1000000; for(MusECore::ciMidiCtrlValList it = cll->lower_bound(min); it != cll->lower_bound(max); ++it) { MusECore::MidiCtrlValList* cl = it->second; MusECore::MidiController* c = port->midiController(cl->num()); if(!c->isPerNoteController()) continue; int cnum = c->num(); int num = cl->num(); int pitch = num & 0x7f; bool used = false; for (MusECore::ciEvent ie = cur_part->events().begin(); ie != cur_part->events().end(); ++ie) { MusECore::Event e = ie->second; if(e.type() != MusECore::Controller) continue; int ctl_num = e.dataA(); if((ctl_num | 0xff) == cnum && (ctl_num & 0x7f) == pitch) { used = true; break; } } bool off = cl->hwVal() == MusECore::CTRL_VAL_UNKNOWN; // Does it have a value or is it 'off'? int y = pitch2y(pitch) + 3; if(used) { if(off) p.drawPixmap(0, y, 6, 6, *greendot12x12Icon); else p.drawPixmap(0, y, 6, 6, *orangedot12x12Icon); } else { if(off) p.drawPixmap(0, y, 6, 6, *graydot12x12Icon); else p.drawPixmap(0, y, 6, 6, *bluedot12x12Icon); } } }
void json_parser<_Handler>::root_value() { char c = cur_char(); switch (c) { case '[': array(); break; case '{': object(); break; default: json::parse_error::throw_with( "root_value: either '[' or '{' was expected, but '", cur_char(), "' was found.", offset()); } }
PassOwnPtrWillBeRawPtr<Keyframe::PropertySpecificKeyframe> AnimatableValueKeyframe::createPropertySpecificKeyframe(CSSPropertyID property) const { return adoptPtrWillBeNoop(new PropertySpecificKeyframe(offset(), easing(), propertyValue(property), composite())); }
void json_parser<_Handler>::value() { char c = cur_char(); if (is_numeric(c)) { number(); return; } switch (c) { case '-': number(); break; case '[': array(); break; case '{': object(); break; case 't': parse_true(); m_handler.boolean_true(); break; case 'f': parse_false(); m_handler.boolean_false(); break; case 'n': parse_null(); m_handler.null(); break; case '"': string(); break; default: json::parse_error::throw_with("value: failed to parse '", cur_char(), "'.", offset()); } }
int main(int argc, char ** argv) { int nLevels = 10; int levelCube = 8; vmml::vector<3,int> offset(0,0,0); lunchbox::Clock clock; std::vector<std::string> parameters; parameters.push_back(std::string(argv[1])); parameters.push_back(std::string(argv[2])); if (argc == 4) { std::string n(argv[3]); mO = boost::lexical_cast<double>(n); } hdf5File.init(parameters); if (!ccc.initParameter(parameters, mO)) { std::cerr<<"Error init control cube cpu cache"<<std::endl; } vmml::vector<3, int> dim = hdf5File.getRealDimension(); std::cout<<"Checking errors........."<<std::endl; bool error = false; for(int i=0; i<10 && !error; i++) { vmml::vector<3,int> s; vmml::vector<3,int> e; int nLevels = 0; int dimA = 0; int dimV = 0; do { s.set(rand() % dim.x(), 0, rand() % dim.z()); do { e.set(rand() % (dim.x() - s.x()) + s.x(), rand() % (dim.y() - s.y()) + s.y(), rand() % (dim.z() - s.z()) + s.z()); } while(s.x() >= e.x() || s.y() >= e.y() || s.z() >= e.z()); /* Calcular dimension del árbol*/ dimA = fmin(e.x()-s.x(), fmin(e.y() - s.y(), e.z() - s.z())); float aux = logf(dimA)/logf(2.0); float aux2 = aux - floorf(aux); nLevels = aux2>0.0 ? aux+1 : aux; dimV = exp2(nLevels); } while(nLevels <= 1 || s.x()+dimV >= dim.x() || s.y()+dimV >= dim.y() || s.z()+dimV >= dim.z()); int levelCube = rand() % (nLevels - 1) + 1; std::cout<<"Test "<<i<<" nLevels "<<nLevels<<" levelCube "<<levelCube<<" dimension "<<exp2(nLevels - levelCube)<<" offset "<<s<<" : "<<std::endl; error = test(nLevels, levelCube, s); if (error) std::cout<<"Test Fail!"<<std::endl; else { std::cout<<"Test OK"<<std::endl; } } std::cout<<"Checking performance........."<<std::endl; for(int i=0; i<10 && !error; i++) { vmml::vector<3,int> s; vmml::vector<3,int> e; int nLevels = 0; int dimA = 0; int dimV = 0; do { s.set(rand() % dim.x(), 0, rand() % dim.z()); do { e.set(rand() % (dim.x() - s.x()) + s.x(), rand() % (dim.y() - s.y()) + s.y(), rand() % (dim.z() - s.z()) + s.z()); } while(s.x() >= e.x() || s.y() >= e.y() || s.z() >= e.z()); dimA = fmin(e.x()-s.x(), fmin(e.y() - s.y(), e.z() - s.z()));; /* Calcular dimension del árbol*/ float aux = logf(dimA)/logf(2.0); float aux2 = aux - floorf(aux); nLevels = aux2>0.0 ? aux+1 : aux; dimV = exp2(nLevels); } while(nLevels <= 1 || s.x()+dimV >= dim.x() || s.y()+dimV >= dim.y() || s.z()+dimV >= dim.z()); int levelCube = rand() % (nLevels - 1) + 1; std::cout<<"Test "<<i<<" nLevels "<<nLevels<<" levelCube "<<levelCube<<" dimension "<<exp2(nLevels - levelCube)<<" offset "<<s<<" : "<<std::endl; double time = 0.0; clock.reset(); testPerf(nLevels, levelCube, s); time = clock.getTimed()/1000.0; double bw = ((((dimV-s.x())*(dimV-s.y())*(dimV-s.z()))*sizeof(float))/1204.0/1024.0)/time; std::cout<<"Test "<<s<<" "<<e<<": "<<time<<" seconds ~ "<<bw<<" MB/s"<<std::endl; } if (!error) { int dimA = fmax(dim.x(), fmaxf(dim.y(), dim.z())); nLevels = 0; /* Calcular dimension del árbol*/ float aux = logf(dimA)/logf(2.0); float aux2 = aux - floorf(aux); nLevels = aux2>0.0 ? aux+1 : aux; levelCube = rand() % (nLevels - 4) + 4; std::cout<<"Test reading complete volume"<<std::endl; if (test(nLevels, levelCube, vmml::vector<3,int>(0,0,0))) { std::cerr<<"Test Fail!!"<<std::endl; } else { double time = 0.0; clock.reset(); testPerf(nLevels, levelCube, vmml::vector<3,int>(0,0,0)); time = clock.getTimed()/1000.0; double bw = (((dim.x()*dim.y()*dim.z())*sizeof(float))/1204.0/1024.0)/time; std::cout<<"Read complete volume "<<dim<<" : "<<time<<" seconds ~ "<<bw<<" MB/s"<<std::endl; } } ccc.stopCache(); hdf5File.close(); return 0; }
const Dtype* Blob<Dtype>::cpu_data_at(const int n, const int c, const int h, const int w) const { CHECK(data_); return (const Dtype*)data_->cpu_data() + offset(n, c, h, w); }
static typename result_of::end_value< T >::type end_value( Id& id ) { return bindings::begin_value( id.get() ) + offset( id.get(), size1(id), id.m_index ); }
const Dtype* Blob<Dtype>::gpu_diff_at(const int n, const int c, const int h, const int w) const { CHECK(diff_); return (const Dtype*)diff_->gpu_data() + offset(n, c, h, w); }
void RViewportEntity::exportEntity(RExporter& e, bool preview, bool forceSelected) const { Q_UNUSED(preview); Q_UNUSED(forceSelected); RDocument* doc = (RDocument*)getDocument(); if (doc==NULL) { return; } RBox viewportBox(data.position, data.width, data.height); // if layer is visible, export viewport frame // viewport contents is always exported (unless viewport if off): if (isVisible()) { // export viewport frame to layer of viewport: e.setBrush(Qt::NoBrush); QList<RLine> lines = viewportBox.getLines2d(); for (int i=0; i<lines.length(); i++) { e.exportLine(lines[i]); } } // if viewport is off, we're done: if (isOff()) { return; } // clip rectangle export e.exportClipRectangle(viewportBox); RVector offset(0,0); offset -= data.viewCenter * data.scale; offset -= data.viewTarget * data.scale; // create temporary block reference to model space block: RBlockReferenceData modelSpaceData( doc, RBlockReferenceData( doc->getModelSpaceBlockId(), data.position + offset, RVector(data.scale, data.scale), 0.0 ) ); modelSpaceData.update(); // start clipping from here: e.setClipping(true); // render model space block reference into viewport: QSet<REntity::Id> ids = doc->queryBlockEntities(doc->getModelSpaceBlockId()); QList<REntity::Id> list = doc->getStorage().orderBackToFront(ids); int i; QList<REntity::Id>::iterator it; for (it = list.begin(), i = 0; it != list.end(); it++) { if (preview && i>RSettings::getPreviewEntities()) { break; } QSharedPointer<REntity> entity = modelSpaceData.queryEntity(*it); if (entity.isNull()) { continue; } entity->rotate(data.rotation, data.position); // prevent recursions: if (entity->getType()==RS::EntityViewport) { continue; } RBox bb = entity->getBoundingBox(); if (!viewportBox.intersects(bb)) { continue; } entity->scaleVisualProperties(data.scale); e.exportEntity(*entity, preview, true); i++; } e.setClipping(false); }
Dtype* Blob<Dtype>::mutable_gpu_data_at(const int n, const int c, const int h, const int w) { CHECK(data_); return static_cast<Dtype*>(data_->mutable_gpu_data()) + offset(n, c, h, w); }
void QVFbScreen::setDirty(const QRect& rect) { const QRect r = rect.translated(-offset()); d_ptr->hdr->dirty = true; d_ptr->hdr->update = d_ptr->hdr->update.united(r); }
void FileSystemActor::onRender(uint flags) { #ifdef TESTING_ALTERNATE_RENDERING if (isActorType(Invisible)) return; // _isAnimatedTexture is always false right now since we don't robustly support animated gifs if (_isAnimatedTexture) { bool successful = true; // if this is an animated texture and we've never loaded the animation // then do so now if (!_animatedTextureSource.load()) _isAnimatedTexture = false; if (_animatedTextureSource.numFrames() <= 1) successful = false; else { AnimatedTextureFrame * frame = _animatedTextureSource.getCurrentTextureFrame(); Vec3 sz = getDims(); glPushAttribToken token(GL_ENABLE_BIT); glEnable(GL_DEPTH_TEST); glEnable(GL_BLEND); glEnable(GL_TEXTURE_2D); // Conditionals if (isSelected() || isActorType(Temporary)) glDisable(GL_DEPTH_TEST); if (isActorType(Invisible)) return; //transform our unit cube: glPushMatrix(); ShapeVis::setupGLMatrix(getGlobalPosition(), getGlobalOrientation()); glScaled(sz.x, sz.y, sz.z); // render the current index glBindTexture(GL_TEXTURE_2D, _animatedTextureSource.GLId()); glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, frame->width, frame->height, GL_BGRA, GL_UNSIGNED_BYTE, frame->pixelData); // Set the Texture glColor4f(1, 1, 1, getAlpha()); // Scale the image uint squareSize = closestPowerOfTwo(NxMath::max(frame->width, frame->height)); float w = (float) frame->width / squareSize; float h = (float) frame->height / squareSize; h = 1.0f - (h * w); glBegin(GL_QUADS); glNormal3f(0,0,1); glTexCoord2f(w,0); glVertex3f(1,1,1); glTexCoord2f(0,0); glVertex3f(-1,1,1); glTexCoord2f(0,h); glVertex3f(-1,-1,1); glTexCoord2f(w,h); glVertex3f(1,-1,1); glNormal3f(0,0,-1); glTexCoord2f(0,h); glVertex3f(1,-1,-1); glTexCoord2f(w,h); glVertex3f(-1,-1,-1); glTexCoord2f(w,0); glVertex3f(-1,1,-1); glTexCoord2f(0,0); glVertex3f(1,1,-1); glEnd(); glPopMatrix(); } // skip the normal rendering routine if (successful) return; } // Render the previous actor first Actor::onRender(flags); // Render an overlay bool isLinkOverlay = (isFileSystemType(Link) || isFileSystemType(DeadLink)) && GLOBAL(settings).manualArrowOverlay; bool isFileTypeOverlay = !getTextIcon().isEmpty(); if (isLinkOverlay || isFileTypeOverlay) { glPushAttribToken token(GL_ENABLE_BIT); glDisable(GL_DEPTH_TEST); glEnable(GL_BLEND); glEnable(GL_TEXTURE_2D); // Render the shortcut/file type icon Arrow QString renderTextureId = QT_NT("icon.linkOverlay"); Vec3 renderPos = getGlobalPosition(); Vec3 renderDims = getDims(); bool shouldScaleIcon = false; if (isFileTypeOverlay) { renderTextureId = getTextIcon(); shouldScaleIcon = true; } else if (isLinkOverlay) { // If the creator of the theme has a bad icon link overlay, we need to re-size it so it does not take up the entire actor // A "good" icon link overlay is 256x255; with the actual overlay part taking up 77x75 in the bottom-left corner Vec3 dimensions = texMgr->getTextureDims(renderTextureId); if (dimensions.x > 0 && dimensions.y > 0) { if ((closestPowerOfTwo(dimensions.x) != 256) || (closestPowerOfTwo(dimensions.y) != 256)) { shouldScaleIcon = true; // position the link icon to the corner of the actual actor (instead of scaling/stretching it) float maxSide = max(dimensions.x, dimensions.y); renderDims.x = renderDims.y = maxSide; } } } if (shouldScaleIcon) { Vec3 offset(getDims().x, -getDims().y, 0); // Scale the actor to proper size (256/77 =~ 3.4; 255/75 = 3.4) renderDims.x /= 3.4f; renderDims.y /= 3.4f; offset += Vec3(-renderDims.x - 0.25f, renderDims.y + 0.25f, 0); offset = getGlobalOrientation() * offset; renderPos += offset; } glBindTexture(GL_TEXTURE_2D, texMgr->getGLTextureId(renderTextureId)); glColor4f(1, 1, 1, getAlpha()); ShapeVis::renderSideLessBox(renderPos, getGlobalOrientation(), renderDims); } #elif !defined DXRENDER // _isAnimatedTexture is always false right now since we don't robustly support animated gifs if (_isAnimatedTexture) { bool successful = true; // if this is an animated texture and we've never loaded the animation // then do so now if (!_animatedTextureSource.load()) _isAnimatedTexture = false; if (_animatedTextureSource.numFrames() <= 1) successful = false; else { AnimatedTextureFrame * frame = _animatedTextureSource.getCurrentTextureFrame(); Vec3 sz = getDims(); glPushAttribToken token(GL_ENABLE_BIT); glEnable(GL_DEPTH_TEST); glEnable(GL_BLEND); glEnable(GL_TEXTURE_2D); // Conditionals if (isSelected() || isActorType(Temporary)) glDisable(GL_DEPTH_TEST); if (isActorType(Invisible)) return; //transform our unit cube: glPushMatrix(); ShapeVis::setupGLMatrix(getGlobalPosition(), getGlobalOrientation()); glScaled(sz.x, sz.y, sz.z); // render the current index glBindTexture(GL_TEXTURE_2D, _animatedTextureSource.GLId()); glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, frame->width, frame->height, GL_BGRA, GL_UNSIGNED_BYTE, frame->pixelData); // Set the Texture glColor4f(1, 1, 1, getAlpha()); // Scale the image uint squareSize = closestPowerOfTwo(NxMath::max(frame->width, frame->height)); float w = (float) frame->width / squareSize; float h = (float) frame->height / squareSize; h = 1.0f - (h * w); glBegin(GL_QUADS); glNormal3f(0,0,1); glTexCoord2f(w,0); glVertex3f(1,1,1); glTexCoord2f(0,0); glVertex3f(-1,1,1); glTexCoord2f(0,h); glVertex3f(-1,-1,1); glTexCoord2f(w,h); glVertex3f(1,-1,1); glNormal3f(0,0,-1); glTexCoord2f(0,h); glVertex3f(1,-1,-1); glTexCoord2f(w,h); glVertex3f(-1,-1,-1); glTexCoord2f(w,0); glVertex3f(-1,1,-1); glTexCoord2f(0,0); glVertex3f(1,1,-1); glEnd(); glPopMatrix(); } // skip the normal rendering routine if (successful) return; } // Render the previous actor first Actor::onRender(flags); // Render a link overlay arrow if ((isFileSystemType(Link) || isFileSystemType(DeadLink)) && !isActorType(Invisible)) { glPushAttribToken token(GL_ENABLE_BIT); glDisable(GL_DEPTH_TEST); glEnable(GL_BLEND); glEnable(GL_TEXTURE_2D); // Render the shortcut Arrow if (GLOBAL(settings).manualArrowOverlay) { glBindTexture(GL_TEXTURE_2D, texMgr->getGLTextureId("icon.linkOverlay")); bool scaleOverlayActor = false; //If the creator of the theme has a bad icon link overlay, we need to re-size it so it does not take up the entire actor Vec3 dimensions = texMgr->getTextureDims("icon.linkOverlay"); //A "good" icon link overlay is 256x255; with the actual overlay part taking up 77x75 in the bottom-left corner if(dimensions.x > 0 && dimensions.y > 0) { if((closestPowerOfTwo(dimensions.x) != 256)||(closestPowerOfTwo(dimensions.y) != 256)) scaleOverlayActor = true; } glColor4f(1, 1, 1, getAlpha()); // Render Shape Vec3 pos = getGlobalPosition(); Vec3 dims = getDims(); Vec3 normalizedDims = dims; // position the link icon to the corner of the actual actor (instead of scaling/stretching it) float maxSide = max(dims.x, dims.y); normalizedDims.x = normalizedDims.y = maxSide; // Scale the actor to proper size (256/77 =~ 3.4; 255/75 = 3.4) if(scaleOverlayActor){ normalizedDims.x /= 3.4f; normalizedDims.y /= 3.4f; } if(scaleOverlayActor) { Vec3 offset(dims.x, -dims.y, 0); offset = getGlobalOrientation() * offset; pos += offset; } else { pos.x -= normalizedDims.x - dims.x; pos.z += normalizedDims.y - dims.y; } ShapeVis::renderSideLessBox(pos, getGlobalOrientation(), normalizedDims); } } #elif defined DXRENDER // Render the previous actor first Actor::onRender(flags); // Render a link overlay arrow if ((isFileSystemType(Link) || isFileSystemType(DeadLink)) && !isActorType(Invisible)) { // Render the shortcut Arrow if (GLOBAL(settings).manualArrowOverlay) { bool scaleOverlayActor = false; //If the creator of the theme has a bad icon link overlay, we need to re-size it so it does not take up the entire actor Vec3 dimensions = texMgr->getTextureDims("icon.linkOverlay"); //A "good" icon link overlay is 256x255; with the actual overlay part taking up 77x75 in the bottom-left corner if(dimensions.x > 0 && dimensions.y > 0) { if((closestPowerOfTwo(dimensions.x) != 256)||(closestPowerOfTwo(dimensions.y) != 256)) scaleOverlayActor = true; } // Render Shape Vec3 pos = getGlobalPosition(); Vec3 dims = getDims(); Vec3 normalizedDims = dims; // position the link icon to the corner of the actual actor (instead of scaling/stretching it) float maxSide = max(dims.x, dims.y); normalizedDims.x = normalizedDims.y = maxSide; // Scale the actor to proper size (256/77 =~ 3.4; 255/75 = 3.4) if(scaleOverlayActor){ normalizedDims.x /= 3.4f; normalizedDims.y /= 3.4f; } if(scaleOverlayActor) { Vec3 offset(dims.x, -dims.y, 0); offset = getGlobalOrientation() * offset; pos += offset; } else { pos.x -= normalizedDims.x - dims.x; pos.z += normalizedDims.y - dims.y; } dxr->device->SetRenderState(D3DRS_ZENABLE, false); dxr->renderSideLessBox(pos, getGlobalOrientation(), normalizedDims, texMgr->getGLTextureId("icon.linkOverlay")); dxr->device->SetRenderState(D3DRS_ZENABLE, true); } } #endif }
bool VerifyObject(flatbuffers::Verifier &v, const reflection::Schema &schema, const reflection::Object &obj, const flatbuffers::Table *table, bool required) { if (!table) { if (!required) return true; else return false; } if (!table->VerifyTableStart(v)) return false; for (uoffset_t i = 0; i < obj.fields()->size(); i++) { auto field_def = obj.fields()->Get(i); switch (field_def->type()->base_type()) { case reflection::None: assert(false); break; case reflection::UType: if (!table->VerifyField<uint8_t>(v, field_def->offset())) return false; break; case reflection::Bool: case reflection::Byte: case reflection::UByte: if (!table->VerifyField<int8_t>(v, field_def->offset())) return false; break; case reflection::Short: case reflection::UShort: if (!table->VerifyField<int16_t>(v, field_def->offset())) return false; break; case reflection::Int: case reflection::UInt: if (!table->VerifyField<int32_t>(v, field_def->offset())) return false; break; case reflection::Long: case reflection::ULong: if (!table->VerifyField<int64_t>(v, field_def->offset())) return false; break; case reflection::Float: if (!table->VerifyField<float>(v, field_def->offset())) return false; break; case reflection::Double: if (!table->VerifyField<double>(v, field_def->offset())) return false; break; case reflection::String: if (!table->VerifyField<uoffset_t>(v, field_def->offset()) || !v.Verify(flatbuffers::GetFieldS(*table, *field_def))) { return false; } break; case reflection::Vector: if (!VerifyVector(v, schema, *table, *field_def)) return false; break; case reflection::Obj: { auto child_obj = schema.objects()->Get(field_def->type()->index()); if (child_obj->is_struct()) { if (!VerifyStruct(v, *table, field_def->offset(), *child_obj, field_def->required())) { return false; } } else { if (!VerifyObject(v, schema, *child_obj, flatbuffers::GetFieldT(*table, *field_def), field_def->required())) { return false; } } break; } case reflection::Union: { // get union type from the prev field voffset_t utype_offset = field_def->offset() - sizeof(voffset_t); auto utype = table->GetField<uint8_t>(utype_offset, 0); if (utype != 0) { // Means we have this union field present auto fb_enum = schema.enums()->Get(field_def->type()->index()); auto child_obj = fb_enum->values()->Get(utype)->object(); if (!VerifyObject(v, schema, *child_obj, flatbuffers::GetFieldT(*table, *field_def), field_def->required())) { return false; } } break; } default: assert(false); break; } } return true; }
inline Dtype diff_at(const vector<int>& index) const { return cpu_diff()[offset(index)]; }