/* スプライト描画 */ void SpriteRenderer::ShowSprite( TexturePtr texture, int X, int Y, int Width, int Height, ArgbColor color, RECT* rect, int CenterX, int CenterY, TransformMatrix* matrix) { if ((!sprite) || (!texture)) return; // ぬるぽは(・∀・)カエレ!! RECT defaultRect = {0, 0, Width, Height}; #if defined(_WIN32) && defined(WITH_DIRECTX) TransformMatrix defaultMatrix; D3DXMatrixIdentity(&defaultMatrix); D3DXMatrixScaling(&defaultMatrix, Geometry::WindowScale(), Geometry::WindowScale(), 0.0f); D3DXVECTOR3 Center(CenterX, CenterY, 0); D3DXVECTOR3 Pos((float)X, (float)Y, 0); sprite->SetTransform(matrix ? matrix : &defaultMatrix); sprite->Draw(texture, rect ? rect : &defaultRect, &Center, &Pos, color); sprite->Flush(); #else const TransformMatrix defaultMatrix = { Geometry::WindowScale(), 0, 0, 0, 0, Geometry::WindowScale(), 0, 0, 0, 0, 1, 0, 0, Geometry::WindowHeight * (1.0f - Geometry::WindowScale()), 0, 1, }; glDisable(GL_DEPTH_TEST); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(0, Geometry::WindowWidth, 0, Geometry::WindowHeight, 0, 1); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glLoadMatrixf(matrix ? &((*matrix)[0]) : &defaultMatrix[0]); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, texture); RECT* txRect = rect ? rect : &defaultRect; glBegin(GL_QUADS); glColor4d( (double)((color & 0x00ff0000) >> 16) / 255.0, (double)((color & 0x0000ff00) >> 8) / 255.0, (double)((color & 0x000000ff) ) / 255.0, (double)((color & 0xff000000) >> 24) / 255.0); const double lpos = (double)txRect->left / (double)getTextureWidth (nullptr, texture); const double rpos = (double)txRect->right / (double)getTextureWidth (nullptr, texture); const double tpos = (double)txRect->top / (double)getTextureHeight(nullptr, texture); const double bpos = (double)txRect->bottom / (double)getTextureHeight(nullptr, texture); glTexCoord2d(lpos, bpos); glVertex2i(X - CenterX, Geometry::WindowHeight - (Y + Height - CenterY)); glTexCoord2d(rpos, bpos); glVertex2i(X + Width - CenterX, Geometry::WindowHeight - (Y + Height - CenterY)); glTexCoord2d(rpos, tpos); glVertex2i(X + Width - CenterX, Geometry::WindowHeight - (Y - CenterY)); glTexCoord2d(lpos, tpos); glVertex2i(X - CenterX, Geometry::WindowHeight - (Y - CenterY)); glEnd(); //glFlush(); // ←[20130415]ボトルネックになることが判明。これを外したら26FPSが40FPSまで改善(デバッグビルド)。リリースだと50FPS→60FPS達成。(GeForce GT240で) glDisable(GL_TEXTURE_2D); #endif }
int MatPlotDecomposer::fillTextureData(char* id, unsigned char* buffer, int bufferLength, int x, int y, int width, int height) { double* value = NULL; getGraphicObjectProperty(id, __GO_DATA_MODEL_Z__, jni_double_vector, (void**) &value); if (width * height * 4 == bufferLength) { char* parentFigure = NULL; double* colormap = NULL; int colormapSize = 0; int* piColormapSize = &colormapSize; getGraphicObjectProperty(id, __GO_PARENT_FIGURE__, jni_string, (void**) &parentFigure); getGraphicObjectProperty(parentFigure, __GO_COLORMAP__, jni_double_vector, (void**) &colormap); getGraphicObjectProperty(parentFigure, __GO_COLORMAP_SIZE__, jni_int, (void**) &piColormapSize); int textureHeight = getTextureHeight(id); int k = 0; for (int j = y ; j < y + height ; j++) { for (int i = x ; i < x + width ; i++) { ColorComputer::getDirectByteColor(value[j + i * textureHeight] - 1, colormap, colormapSize, &buffer[k]); buffer[k + 3] = 255; k += 4; } } releaseGraphicObjectProperty(__GO_COLORMAP__, colormap, jni_double_vector, colormapSize); return bufferLength; } else { return 0; } }
SWIGEXPORT jint JNICALL Java_org_scilab_modules_graphic_1objects_DataLoaderJNI_getTextureHeight(JNIEnv *jenv, jclass jcls, jstring jarg1) { jint jresult = 0 ; char *arg1 = (char *) 0 ; int result; (void)jenv; (void)jcls; arg1 = 0; if (jarg1) { arg1 = (char *)(*jenv)->GetStringUTFChars(jenv, jarg1, 0); if (!arg1) { return 0; } } result = (int)getTextureHeight(arg1); jresult = (jint)result; if (arg1) { (*jenv)->ReleaseStringUTFChars(jenv, jarg1, (const char *)arg1); } return jresult; }
SWIGEXPORT jint JNICALL Java_org_scilab_modules_graphic_1objects_DataLoaderJNI_getTextureHeight(JNIEnv *jenv, jclass jcls, jint jarg1) { jint jresult = 0 ; int arg1 ; int result; (void)jenv; (void)jcls; arg1 = (int)jarg1; result = (int)getTextureHeight(arg1); jresult = (jint)result; return jresult; }
int MatPlotDecomposer::getTextureData(char * id, void ** address, unsigned int * size) { int type = getTextureImageType(id); if (type == MATPLOT_INDEX) { // Indexed colors const int h = getTextureHeight(id); const int w = getTextureWidth(id); const int bsize = w * h * sizeof(int); unsigned char * buffer = new unsigned char[bsize]; fillTextureData(id, buffer, bsize); *address = buffer; *size = bsize; return 1; } getGraphicObjectProperty(id, __GO_DATA_MODEL_MATPLOT_IMAGE_DATA__, jni_double_vector, address); getGraphicObjectProperty(id, __GO_DATA_MODEL_MATPLOT_IMAGE_DATASIZE__, jni_int, (void **)&size); return 1; }
GaussianBlurFilter::GaussianBlurFilter(const TextureFilterBuilder *textureFilterBuilder, GaussianDirection gaussianDirection): TextureFilter(textureFilterBuilder), gaussianDirection(gaussianDirection), blurSize(textureFilterBuilder->getBlurSize()), nbTextureFetch(std::ceil(blurSize / 2.0f)), textureSize((GaussianDirection::VERTICAL==gaussianDirection) ? getTextureHeight() : getTextureWidth()) { //See http://rastergrid.com/blog/2010/09/efficient-gaussian-blur-with-linear-sampling/ if(blurSize<=1) { throw std::invalid_argument("Blur size must be greater than one. Value: " + std::to_string(blurSize)); }else if(blurSize%2==0) { throw std::invalid_argument("Blur size must be an odd number. Value: " + std::to_string(blurSize)); } std::vector<float> weights = computeWeights(); std::vector<float> weightsLinearSampling = computeWeightsLinearSampling(weights); weightsTab = toShaderVectorValues(weightsLinearSampling); std::vector<float> offsetsLinearSampling = computeOffsetsLinearSampling(weights, weightsLinearSampling); offsetsTab = toShaderVectorValues(offsetsLinearSampling); }
void Unit::generalBirth(){ issueStopOrder(); targetUnit=NULL; this->lastWaypointGeneration=-1; selected=false; selectedScaleX=getTextureWidth()/SelectedFX::textureW; selectedScaleY=getTextureHeight()/SelectedFX::textureH; maxSpeedFactor=attackSpeedFactor=maxHealthFactor=armorFactor=strengthFactor=1.0f; maxHealthIncrease=armorIncrease=strengthIncrease=0; p->armyStrength+=this->strengthEstimate(); p->numCreated++; waypoints.clear(); isDisturbed=0; if(typeid(*this)==typeid(Warrior)) p->numWarriorsCreated++; if(typeid(*this)==typeid(WizardUnit)) p->numWizardsCreated++; if(typeid(*this)==typeid(Ogre)) p->numOgresCreated++; if(typeid(*this)==typeid(Archer)) p->numArchersCreated++; if(typeid(*this)==typeid(Knight)) p->numKnightsCreated++; }
int MatPlotDecomposer::fillTextureData(char* id, unsigned char* buffer, int bufferLength) { // Indexed colors void * data = NULL; char * parentFigure = NULL; double * colormap = NULL; int colormapSize = 0; int * piColormapSize = &colormapSize; int datatype = -1; int * pidataType = &datatype; const int h = getTextureHeight(id); const int w = getTextureWidth(id); getGraphicObjectProperty(id, __GO_DATA_MODEL_Z__, jni_double_vector, &data); getGraphicObjectProperty(id, __GO_DATA_MODEL_MATPLOT_DATA_TYPE__, jni_int, (void**) &pidataType); getGraphicObjectProperty(id, __GO_PARENT_FIGURE__, jni_string, (void**) &parentFigure); getGraphicObjectProperty(parentFigure, __GO_COLORMAP__, jni_double_vector, (void**) &colormap); getGraphicObjectProperty(parentFigure, __GO_COLORMAP_SIZE__, jni_int, (void**) &piColormapSize); switch ((DataType)datatype) { case MATPLOT_HM1_Char : case MATPLOT_Char : { char * index = (char *)data; for (int i = 0 ; i < w * h; i++) { ColorComputer::getDirectByteColor(index[i] - 1, colormap, colormapSize, &buffer[4 * i], false); } break; } case MATPLOT_HM1_UChar : case MATPLOT_UChar : { unsigned char * index = (unsigned char *)data; for (int i = 0 ; i < w * h; i++) { ColorComputer::getDirectByteColor(index[i] - 1, colormap, colormapSize, &buffer[4 * i], false); } break; } case MATPLOT_Int : { int * index = (int *)data; for (int i = 0 ; i < w * h; i++) { ColorComputer::getDirectByteColor(index[i] - 1, colormap, colormapSize, &buffer[4 * i], false); } break; } case MATPLOT_UInt : { unsigned int * index = (unsigned int *)data; for (int i = 0 ; i < w * h; i++) { ColorComputer::getDirectByteColor(index[i] - 1, colormap, colormapSize, &buffer[4 * i], false); } break; } case MATPLOT_Short : { short * index = (short *)data; for (int i = 0 ; i < w * h; i++) { ColorComputer::getDirectByteColor(index[i] - 1, colormap, colormapSize, &buffer[4 * i], false); } break; } case MATPLOT_UShort : { unsigned short * index = (unsigned short *)data; for (int i = 0 ; i < w * h; i++) { ColorComputer::getDirectByteColor(index[i] - 1, colormap, colormapSize, &buffer[4 * i], false); } break; } case MATPLOT_HM1_Double : case MATPLOT_Double : { double * index = (double *)data; for (int i = 0 ; i < w * h ; i++) { ColorComputer::getDirectByteColor(index[i] - 1, colormap, colormapSize, &buffer[4 * i], false); } break; } } releaseGraphicObjectProperty(__GO_COLORMAP__, colormap, jni_double_vector, colormapSize); return bufferLength; }
int TextLine::getLineHeight() { //get the height in pixels of the line return getTextureHeight( mTexture ); }