static inline hkvVec2 BiLerp(const hkvVec2 pSrcVertexCoords[4], const hkvVec2 &coord1) { hkvVec2 coord0(1.f-coord1.x, 1.f-coord1.y); hkvVec2 row0 = pSrcVertexCoords[0] * coord0.x + pSrcVertexCoords[1] * coord1.x; hkvVec2 row1 = pSrcVertexCoords[2] * coord0.x + pSrcVertexCoords[3] * coord1.x; return row0*coord0.y + row1*coord1.y; }
static void imove(int x, int y) { ix = x; iy = y; #ifndef VNMRJ if (Wisgraphon() || Wishds()) { *(drawIconPtr++) = GRAF; /* Gprintf("%c",GRAF); */ sa=sb=sc=sd=0; /* force all 4 chars to be send */ coord0(x,y); /* move to current position */ } else if (Wistek()) { sa=sb=sc=sd=se=0; /* force all 5 chars to be sent */ } #endif }
static void idraw(int x, int y) { #ifdef VNMRJ (void) x; (void) y; #else int incre, iter, limit, new_x, new_y, old_x, old_y, use_x; if (Wisgraphon() || Wishds()) { ix = x; iy = y; coord0(ix,iy); } else if (Wistek()) { /* Take the easy way out, if possible. */ if (x-ix == 0 || y-iy == 0) { *(drawIconPtr++) = ESC; *(drawIconPtr++) = 'R'; *(drawIconPtr++) = 'R'; /* Gprintf( "%cRR", ESC); */ coord0( ix, iy ); coord0( x, y ); *(drawIconPtr++) = '1'; } /* Have to 'rasterize' the vector into a series of vertical or horizontal vectors. */ else { use_x = iabs( x-ix ) < iabs( y-iy ); if (use_x) { limit = iabs( x-ix ) + 1; incre = ( x < ix ) ? -1 : 1; } else { limit = iabs( y-iy ) + 1; incre = ( y < iy ) ? -1 : 1; } old_x = ix; old_y = iy; /* For each pixel in the shorter direction... */ for (iter = 0; iter < limit; iter++) { if (use_x) { new_x = old_x; new_y = (y-iy) * (iter+1) / limit + iy; } else { new_x = (x-ix) * (iter+1) / limit + ix; new_y = old_y; } *(drawIconPtr++) = ESC; *(drawIconPtr++) = 'R'; *(drawIconPtr++) = 'R'; coord0( old_x, old_y ); coord0( new_x, new_y ); *(drawIconPtr++) = '1'; if (use_x) { old_x += incre; old_y = new_y; } else { old_x = new_x; old_y += incre; } } } /* Update internal position values. */ ix = x; iy = y; } #endif }
void TextureBackground::updateGrid(void) { bool gridChanged=( (getHor() != _hor) || (getVert() != _vert) ); if(gridChanged) { //resize grid UInt32 gridCoords=(getHor()+2)*(getVert()+2); _textureCoordArray.resize(gridCoords); _vertexCoordArray .resize(gridCoords); int indexArraySize=(getHor()+2)*((getVert()+1)*2); _indexArray.resize(indexArraySize); _hor = getHor(); _vert = getVert(); } if(gridChanged || _radialDistortion != getRadialDistortion() || _centerOfDistortion != getCenterOfDistortion() ) { _radialDistortion = getRadialDistortion(); _centerOfDistortion = getCenterOfDistortion(); // calculate grid coordinates and triangle strip indices float xStep=1.0/float(getHor()+1); float yStep=1.0/float(getVert()+1); std::vector<Vec2f>::iterator texCoord=_textureCoordArray.begin(); std::vector<Vec2f>::iterator vertexCoord=_vertexCoordArray.begin(); std::vector<UInt32>::iterator index=_indexArray.begin(); UInt32 coord0(0),coord1(0); GLfloat x,y; Int16 xx,yy; Int16 xxmax=getHor()+2,yymax=getVert()+2; for(yy=0,y=0.0f;yy<yymax;yy++,y+=yStep) { if(yy>0) { coord1=yy*xxmax; coord0=coord1-xxmax; *index++=coord1++; *index++=coord0++; } float dy=y-getCenterOfDistortion().y(); float dy2=dy*dy; for(xx=0,x=0.0f;xx<xxmax;xx++,x+=xStep) { *texCoord++=Vec2f(x,y); float dx=(x-getCenterOfDistortion().x()); float dx2=dx*dx; float dist2=dx2+dy2; float deltaX=dx*getRadialDistortion()*dist2; float deltaY=dy*getRadialDistortion()*dist2; *vertexCoord++=Vec2f(x+deltaX,y+deltaY); if(yy>0&&xx>0) { *index++=coord1++; *index++=coord0++; } } } } }