GLPresenter::GLPresenter(DeckLinkCapture &capture, int w, int h, int hz) : data_size(w*h*2), capture(capture), running(true), fullscreen(false), useVsync(false), rgbFull(false), texId(0), displayList(0), convertUYVY(NULL), buffer(NULL), buffer2(NULL), reqW(w), reqH(h), reqHz(hz), frameIndex(0), drawnFrameIndex(0), aspect(16.0/9.0), oneToNScaleFactor(-1.0) { self = this; sprintf(prepend, "#define FRAME_WIDTH %d\n#define FRAME_HEIGHT %d\n", reqW, reqH); RT_ASSERT(glfwInit() == GL_TRUE, "Failed to initalize GLFW."); RT_ASSERT(glfwOpenWindow(w, h, 0, 0, 0, 0, 0, 0, GLFW_WINDOW) == GL_TRUE, "Failed to open GLFW window."); string title("PtBi "); title += VER_STRING; glfwSetWindowTitle(title.c_str()); glfwSetWindowPos(10, 10); dataPointers[0] = malloc(data_size); dataPointers[1] = malloc(data_size); glewInit(); checkExtensions(); ilInit(); glfwDisable(GLFW_AUTO_POLL_EVENTS); glfwSwapInterval(0); glfwSetWindowCloseCallback(closeCallback); glfwSetWindowSizeCallback(resizeCallback); glfwSetMousePosCallback(mousePosCallback); glfwSetKeyCallback(keyCallback); hdc = wglGetCurrentDC(); hrc = wglGetCurrentContext(); initGL(); convertUYVY = new GLFragmentProgram("shaders/uyvy_to_rgb_smooth.glsl", getShaderPrependString()); buffer = new GLRenderTexture(getW(), getH(), GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE); buffer->setFilterMode(GL_LINEAR); buffer2 = new GLRenderTexture(getW(), getH(), GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE); buffer2->setFilterMode(GL_LINEAR); scalingManager = new ScalingManager(*this); aaManager = new AAManager(*this); ipManager = new IPManager(*this); keyBinding = new KeyBinding(this); capture.registerDisplayListener(this); hwnd = GetForegroundWindow(); RT_GL_ASSERT("Error during GL initialization."); reshape(reqW, reqH); }
void Objets::genererModelisation() { clear(modelisation); clear_to_color(modelisation,q_c); line(modelisation,0,0,getW()-1,0,0); line(modelisation,getW()-1,0,getW()-1,getH()-1,0); line(modelisation,getW()-1,getH()-1,0,getH()-1,0); line(modelisation,0,getH()-1,0,0,0); /*if (w > 50) { int i=0,j=sizeof(nom); char *t = (char*)malloc(1); while (nom[i] != '\0') { t[0]=nom[i]; t[1]='\0'; textprintf_ex(modelisation,font,(w/2)-(j*9),h/2,makecol(0,0,0),makecol(255,255,255),t); i++;j--; } delete t; } else { int i=0,j=sizeof(nom); char *t = (char*)malloc(1); while (nom[i] != '\0') { t[0]=nom[i]; t[1]='\0'; textprintf_ex(modelisation,font,w/2,(h/2)-(9*j),makecol(0,0,0),makecol(255,255,255),t); i++;j--; } delete t; } */ }
void Outils::ajouterBouton(Boutons *b) { lesBoutons.push_back(b); blit(b->getBouton(),lesOutils,0,0,b->getX(),b->getY(),b->getW(),b->getH()); setH(b->getY()+b->getH()); line(lesOutils,getW()-1,0,getW()-1,getH(),0); line(lesOutils,getW(),getH(),0,getH(),0); line(lesOutils,0,getH(),0,0,0); }
Vector3 HomogenusPosition::normalizeToVector3() const { Vector3 result; result.setX(getX()/getW()); result.setY(getY()/getW()); result.setZ(getZ()/getW()); return result; }
Objets::Objets(int _x, int _y, int _z, int _w, int _h, int _d) : Volume(_x,_y,_z,_w,_h,_d,0) { sens=""; q_c=makecol(255,255,255); p_c=makecol(0,0,0); nom="objet"; modelisation=create_bitmap(getW(),getH()); proprietes = create_bitmap(150,200); Tx = new TextBox(40,42,40,12,makecol(255,255,255),makecol(124,124,124),getX()); Ty = new TextBox(40,57,40,12,makecol(255,255,255),makecol(124,124,124),getY()); Tz = new TextBox(40,72,40,12,makecol(255,255,255),makecol(124,124,124),getZ()); Tw = new TextBox(95,87,40,12,makecol(255,255,255),makecol(124,124,124),getW()); Th = new TextBox(90,102,40,12,makecol(255,255,255),makecol(124,124,124),getH()); Td = new TextBox(90,117,40,12,makecol(255,255,255),makecol(124,124,124),getD()); }
bool Bounds::deferedHasColidedWith(Bounds otherobj) { //al_draw_filled_rectangle(getX(),getY(),getX() + getW(),getY() + getH(),al_map_rgb(255,255,255)); //al_draw_filled_rectangle(otherobj.getX(),otherobj.getY(),otherobj.getX() + otherobj.getW(),otherobj.getY() + otherobj.getH(),al_map_rgb(255,255,255)); if( getX() - (getW() / 2) < otherobj.getX() + (otherobj.getW() / 2) && getX() + (getW() / 2) > otherobj.getX() - (otherobj.getW() / 2) && getY() - (getH() / 2) < otherobj.getY() + (otherobj.getH() / 2) && getY() + (getH() / 2) > otherobj.getY() - (otherobj.getH() / 2)) { //cout << "HIT:{" << getX() << "|" << getY() << "|" << getW() << "|" << getH() << "},{" << otherobj.getX() << "|" << otherobj.getY() << "|" << otherobj.getW() << "|" << otherobj.getH() << endl; return true; } return false; }
Quaternion& Quaternion::inverse() { double normal = sqrt(getW()*getW() + getX()*getX() + getY()*getY() + getZ()*getZ()); if (normal < Quaternion::EPSILON) { normal = 1.0; } const double reciprocal = 1.0/normal; setW(reciprocal * getW()); setX(reciprocal * (-1) * getX()); setY(reciprocal * (-1) * getY()); setZ(reciprocal * (-1) * getZ()); return (*this); }
inline void updateSet(int town, int set) { int curmin = maxw, curmin_index = -1; int maxi = (set + 1) * sizes[town]; if (maxi > cnt[town]) maxi = cnt[town]; for (int i = set * sizes[town]; i < maxi; i++) if (getW(town, i) < curmin) { curmin = getW(town, i); curmin_index = i; } min[ws_start[town] + set] = curmin; min_indices[ws_start[town] + set] = curmin_index; }
void GLPresenter::testAAinternal() { const char* ts = timeString(); GLRenderTexture target(getW(), getH(), GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE); AAManager::aaMode prevMode = aaManager->getAAMode(); aaManager->setAAMode(AAManager::NONE); aaManager->applyAA(buffer, &target); target.saveToImage(format("%s__noaa.png", ts)); aaManager->setAAMode(AAManager::FXAA); aaManager->applyAA(buffer, &target); target.saveToImage(format("%s__fxaa.png", ts)); aaManager->setAAMode(AAManager::PXAA); aaManager->applyAA(buffer, &target); target.saveToImage(format("%s__pxaa.png", ts)); aaManager->setAAMode(AAManager::TPXAA); aaManager->applyAA(buffer, &target); target.saveToImage(format("%s__tpxaa.png", ts)); aaManager->setAAMode(AAManager::SMAA); aaManager->applyAA(buffer, &target); target.saveToImage(format("%s__smaa.png", ts)); aaManager->setAAMode(prevMode); }
void testApp::draw(){ int w = getW(); int h = getH(); if(bCap){ ofBeginSaveScreenAsPDF(pdfCapturePath, false, false, ofRectangle(0,0,w,h)); } ofBackground(0); if(gprm.bBlack){ return; } // cam.begin(); // ofRotate(180, 1, 0, 0); // ofTranslate(-w/2, -h/2); if(bCap){ //ofBeginSaveScreenAsPDF(pdfCapturePath, false, false, ofRectangle(0,0,w,h)); gps->drawForPdf(); ofEndSaveScreenAsPDF(); bCap = false; }else{ gps->draw(); } // cam.end(); if(gprm.bTestPicture){ ofSetRectMode(OF_RECTMODE_CENTER); ofSetColor(255, 255, 255, 150); float asp = wc.getWidth()/wc.getHeight(); wc.draw(w/2, h/2, h*asp, h); ofSetRectMode(OF_RECTMODE_CORNER); } }
void NewtonImageSequential::refreshAll(const DomaineMaths& domainNew){ int w = getW(); int h = getH(); float dx = (float) (domainNew.dx / (float) w); float dy = (float) (domainNew.dy / (float) h); float y = domainNew.y0; for(int i = 1; i <= h; ++i){ float x = domainNew.x0; for(int j = 1; j <= w; ++j){ int color = newton_seq::real_newton(x, y); if(color == 0){ setFloatRGBA(i, j, 0, 0, 0); } else if(color == 1){ setFloatRGBA(i, j, 1, 0, 0); } else if(color == 2){ setFloatRGBA(i, j, 0, 1, 0); } else if(color == 3){ setFloatRGBA(i, j, 0, 0, 1); } x += dx; } y += dy; } }
void Rect::grow(float amount) { setX(getX() - amount); setY(getY() - amount); setW(getW() + amount * 2); setH(getH() + amount * 2); }
bool CSulGuiDial::eventMouseRelease( CSulGuiCanvas* pCanvas, float local_x, float local_y, float x, float y ) { // NOTE: because we have flipped the y-axis to have 0,0 in top,left corner.. means that the degress for // circle is also flipped on the y-axis. which means that our angle calculation is going clockwise. // we need to fix this when presenting this value to the user of this class. float w = getW(); float h = getH(); float xx = local_x - (w/2.0f); float yy = local_y-(h/2.0f); float a = atan2( yy, xx ); m_deg = sigma::RAD2DEG( a ); if ( m_deg<0 ) m_deg = 180.0f + (180.0f+m_deg); osg::Quat q( sigma::DEG2RAD(m_deg), osg::Vec3(0,0,1) ); osg::Matrix m = m_mt->getMatrix(); m.setRotate( q ); m_mt->setMatrix( m ); return true; }
HeaterMOO::~HeaterMOO () { int w = getW (); free ( _imgHeater, w ); free ( _imgInit, w ); free ( _imgA, w ); free ( _imgB, w ); }
void Player::addItem(Item* i){ //inventory.push_back(i); for (int j = 0; j < invSize; j++){ // std::cout << i->getName() << " " << inventory[j]->getName() << std::endl; //Need to cast them to strings to have them equal each other. Lua string to char* doesn't seem to work. if (std::string(i->getName()) == std::string(inventory[j]->getName()) && i->isStackable()) { // std::cout << inventory[j]->getNumberOf() << std::endl; inventory[j]->incrNum(); EntityManager::getInstance()->Remove(i->getIndex()); // std::cout << inventory[j]->getNumberOf() << std::endl; return; } } if (invSize < 45){ inventory[invSize] = i; inventory[invSize]->setHardPosition((float)((invSize % 4)*getW()), (float)(invSize / 4 * i->getH())); invSize++; } else { delete i; } }
void AAM::train(vector<Mat> images, Mat shapes) { this->images=images; this->shapeSet = shapes; //cout<<"training shape set: "<<shapeSet<<endl; makeShapeModel(); triangulateMeanPoints(); //cout<<"shape pca counted"<<endl; this->meanConvexHull = this->createConvexHull(this->meanPoints); cout<<"convexHull"<<meanConvexHull<<endl; for(int i=0; i<this->images.size(); i++) { Mat image_grey; cvtColor(this->images[i], image_grey, COLOR_BGR2GRAY); Mat texture=this->getTetureInShape(image_grey, this->shapeSet.row(i)); //cout<<"texture smapled and normalized: "<<texture<<endl; this->addTexture(texture); } makeTextureModel(); this->displayModel(); getW(); makeApearanceModel(); this->countA(); cout<<"A: "<<this->A<<endl; cout<<"AAM training complete"<<endl; }
void PerlinImageOMP::refreshAll(const DomaineMaths& domainNew){ const int w = getW(); const int h = getH(); const float dx = (float) (domainNew.dx / (float) w); const float dy = (float) (domainNew.dy / (float) h); #pragma omp parallel { int tid = omp_get_thread_num(); int i = tid + 1; float y = domainNew.y0 + tid * dy; while(i <= h){ float x = domainNew.x0; for(int j = 1; j <= w; ++j){ float c = perlinNoise(x,y,t); setRGBA(i, j, 135, 206, 250, c * 255.0); x += dx; } y += THREADS * dy; i += THREADS; } } }
void JuliaImageSequential::refreshAll(const DomaineMaths& domainNew){ int w = getW(); int h = getH(); float dx = (float) (domainNew.dx / (float) w); float dy = (float) (domainNew.dy / (float) h); float y = domainNew.y0; for(int i = 1; i <= h; ++i){ float x = domainNew.x0; for(int j = 1; j <= w; ++j){ float h = julia(x, y); //setFloatRGBA(i, j, h, h, h); if(h == 0){ setHSB(i, j, 0, 0, 0); } else { setHSB(i, j, h, 1.0, 1.0); } x += dx; } y += dy; } }
bool Rectangle::collis(Object* other){ int leftA, leftB; int rightA, rightB; int topA, topB; int bottomA, bottomB; leftA = getX(); rightA = getX() + getW(); topA = getY(); bottomA = getY() + getH(); leftB = other->getX(); rightB = other->getX() + other->getW(); topB = other->getY(); bottomB = other->getY() + other->getH(); if(bottomA <= topB) return false; if(topA >= bottomB) return false; if(rightA <= leftB) return false; if(leftA >= rightB) return false; return true; }
Vec3f Quaternion3f::transform(const Vec3f& v) const { Vec3f u(getX(), getY(), getZ()); double s = getW(); Vec3f vprime = 2*u.dot(v)*u + (s*s - u.dot(u))*v + 2*s*u.cross(v); return vprime; }
bool ImageLoader::OverrideByName(const std::string& name, const std::shared_ptr<LunaImage>& img) { // If we're mapping through an HDC, find it for this image name { auto it = m_NameToHDC.find(name); if (it != m_NameToHDC.end()) { if (img) { m_GfxOverride[it->second] = img; } else { m_GfxOverride.erase(it->second); } // Update height/width based on override auto categoryIterator = m_HDCToCategoryAndIndex.find(it->second); if (categoryIterator != m_HDCToCategoryAndIndex.end()) { const SMBXImageCategory* category = categoryIterator->second.first; uint32_t idx = categoryIterator->second.second; if (img) { category->setHeight(idx, img->getH()); category->setWidth(idx, img->getW()); } else { auto currentImg = ImageLoader::GetByName(name); if (currentImg) { category->setHeight(idx, currentImg->getH()); category->setWidth(idx, currentImg->getW()); } } } return true; } } // Otherwise, for "extra gfx" we're mapping directly from name to image, so set the override that way if (m_ExtraGfx.find(name) != m_ExtraGfx.end()) { if (img) { m_ExtraGfxOverride[name] = img; } else { m_ExtraGfxOverride.erase(name); } return true; } return false; }
/******************* Expande ou a altura ou a largura, dependendo do parametro *******************/ void Bitmap :: printFullScreen(int x, int y, int flag) { if(sprite != NULL) { switch(flag) { case 0: al_draw_scaled_bitmap(sprite, 0, 0, getW(), SCREEN_H, x, y, SCREEN_W, SCREEN_H, 0); break; case 1: al_draw_scaled_bitmap(sprite, 0, 0, SCREEN_W, getH(), x, y, SCREEN_W, SCREEN_H, 0); break; case 2: al_draw_scaled_bitmap(sprite, 0, 0, getW(), getH(), x, y, SCREEN_W, SCREEN_H, 0); break; } } }
Quaternion& Quaternion::normalize() { const double normal = sqrt(getW()*getW() + getX()*getX() + getY()*getY() + getZ()*getZ()); if (normal < Quaternion::EPSILON) { setW(1.0); setX(0); setY(0); setZ(0); } else { const double reciprocal = 1.0/normal; setW(reciprocal * getW()); setX(reciprocal * getX()); setY(reciprocal * getY()); setZ(reciprocal * getZ()); } return (*this); }
void Alien::dropBomb(){ Image bombImage("assets/redLaserRay.png", true); //Sprite* bomb = new Bomb(&bombImage, "Bomb"); GameObject* bomb = new Bomb(&bombImage, "Bomb"); bomb->setPosition(getX() + (getW() / 2) - 4, getY() + 30); bomb->toggle_collidable(); GameEngine::getInstance()->getStateManager()->getCurrentState()->addGameObject(bomb); }
BITMAP * Objets::getProprietes(int p_x,int p_y, int p_w, int p_h) { clear_to_color(proprietes,makecol(255,255,255)); rect(proprietes,1,1,149,199,0); textprintf_ex(proprietes, font,35,10, makecol(0, 0, 0),makecol(255, 255, 255), "Proprietes"); line(proprietes,0,20,200,20,0); textprintf_ex(proprietes, font,10,30, makecol(0, 0, 0),makecol(255, 255, 255), "Type : %s",nom); int _x,_y,_z; _x=(getX()-p_x); _y=(getY()-p_y); _z=getZ(); if (!Tx->getSaisie()) Tx->setValeur(_x); if (!Ty->getSaisie()) Ty->setValeur(_y); if (!Tz->getSaisie()) Tz->setValeur(_z); if (!Tw->getSaisie()) Tw->setValeur(getW()); if (!Th->getSaisie()) Th->setValeur(getH()); if (!Td->getSaisie()) Td->setValeur(getD()); textprintf_ex(proprietes, font,10,45, makecol(0, 0, 0),makecol(255, 255, 255), "x ="); blit(Tx->getImage(),proprietes,0,0,Tx->getX(),Tx->getY(),Tx->getW(),Tx->getH()); textprintf_ex(proprietes, font,10,60, makecol(0, 0, 0),makecol(255, 255, 255), "y ="); blit(Ty->getImage(),proprietes,0,0,Ty->getX(),Ty->getY(),Ty->getW(),Ty->getH()); textprintf_ex(proprietes, font,10,75, makecol(0, 0, 0),makecol(255, 255, 255), "z ="); blit(Tz->getImage(),proprietes,0,0,Tz->getX(),Tz->getY(),Tz->getW(),Tz->getH()); textprintf_ex(proprietes, font,10,90, makecol(0, 0, 0),makecol(255, 255, 255), "Longueur ="); blit(Tw->getImage(),proprietes,0,0,Tw->getX(),Tw->getY(),Tw->getW(),Tw->getH()); textprintf_ex(proprietes, font,10,105, makecol(0, 0, 0),makecol(255, 255, 255), "Largeur ="); blit(Th->getImage(),proprietes,0,0,Th->getX(),Th->getY(),Th->getW(),Th->getH()); textprintf_ex(proprietes, font,10,120, makecol(0, 0, 0),makecol(255, 255, 255), "Hauteur ="); blit(Td->getImage(),proprietes,0,0,Td->getX(),Td->getY(),Td->getW(),Td->getH()); char *lesens; if (sens=="N") lesens="Nord"; else if (sens=="E") lesens="Est"; else if (sens=="S") lesens="Sud"; else if (sens=="O") lesens="Ouest"; textprintf_ex(proprietes, font,10,135, makecol(0, 0, 0),makecol(255, 255, 255), "Sens = %s",lesens); delete [] lesens; textprintf_ex(proprietes, font,10,150, makecol(0, 0, 0),makecol(255, 255, 255), "Couleur = "); rectfill(proprietes,90,148,100,158,q_c); rect(proprietes,90,148,100,158,0); return proprietes; }
inline void remove(int town) { int set1 = min_total_index[town] / sizes[town], set2 = (cnt[town] - 1) / sizes[town]; setW(town, min_total_index[town], getW(town, cnt[town] - 1)); cnt[town]--; updateSet(town, set1); if (set2 != set1) updateSet(town, set2); updateTotal(town); }
void printHeader() { int screen_height, screen_weight; char header_buf[ 1024 ]; clear(); getmaxyx( stdscr, screen_height, screen_weight ); printString( "h,? - help; z - toggle color-mode; q,F10,Ctrl-c - quit", A_NORMAL, getW (), NEWLINE ); if( is_colorize ) attron( COLOR_PAIR( 1 ) ); sprintf( header_buf, " +User%c .+cpu(%) %c . +read(B/s)%c . +write(B/s) %c . CAUSE ", sort_type == 3 ? '*' : ' ', !sort_type ? '*' : ' ', sort_type == 1 ? '*' : ' ', sort_type == 2 ? '*' : ' ' ); printString( header_buf, (is_colorize) ? A_NORMAL : A_REVERSE, getW(), NEWLINE ); if( is_colorize ) attroff( COLOR_PAIR( 1 ) ); }
void HeaterMOO::erase ( double** src, double** dest ) { uint32_t h = getH (); uint32_t w = getW (); #pragma omp parallel for if ( _omp ) for ( size_t i = 0; i < w; i++ ) { for ( size_t j = 0; j < h; j++ ) { if ( src[i][j] != .0 ) { dest[i][j] = src[i][j]; } } } }
void GroupOfButtons::draw() { drawGradient(Area(Area::CXYWH, cx, cy, getW(), getH()), Color(0,0,0,100), Color(0,0,0,0)); al_draw_text(font(font_size), Color::white(), cx, cy - getH()/2 + space()*1.5 - font_size/2, ALLEGRO_ALIGN_CENTER, title.c_str()); for (auto& b: buttons) { b.draw(); } for (auto& t: textboxes) { t.box.draw(); } }
void HeaterMOO::fillImage ( double** img ) { uint32_t h = getH (); uint32_t w = getW (); Calibreurs calibreur ( 0, 1, 0.7, 0 ); #pragma omp parallel for if ( _omp ) for ( size_t i = 1; i <= w; i++ ) { for ( size_t j = 1; j <= h; j++ ) { double temperature = img[i - 1][j - 1]; float hue = calibreur.calibrate ( temperature ); setHue ( i, j, hue ); } } }