LandscapeEditorDrawSystem::eErrorType LandscapeEditorDrawSystem::Init() { if (!heightmapProxy) { Heightmap* heightmap = baseLandscape->GetHeightmap(); if (heightmap == NULL || heightmap->Size() == 0) { return LANDSCAPE_EDITOR_SYSTEM_HEIGHTMAP_ABSENT; } heightmapProxy = new HeightmapProxy(baseLandscape->GetHeightmap()->Clone(NULL)); } if (!customColorsProxy) { customColorsProxy = new CustomColorsProxy((int32)GetTextureSize(Landscape::TEXTURE_TILE_FULL)); } if (!visibilityToolProxy) { visibilityToolProxy = new VisibilityToolProxy((int32)GetTextureSize(Landscape::TEXTURE_TILE_FULL)); } if (!rulerToolProxy) { rulerToolProxy = new RulerToolProxy((int32)GetTextureSize(Landscape::TEXTURE_TILE_FULL)); } return LANDSCAPE_EDITOR_SYSTEM_NO_ERRORS; }
//uses the glyphs and determines the size of the texture needed to lay them out with a sigle pixel boundary //around each character static bool GetTextureSizeFromCharSizes(const CTextureStringGlyph* pGlyphs, uint32 nNumGlyphs, uint32 nMaxGlyphWidth, uint32 nMaxGlyphHeight, uint32 nCharSpacing, SIZE& sizeTexture ) { //default the size sizeTexture.cx = sizeTexture.cy = 0; // Start the height off as one row. uint32 nRawHeight = nMaxGlyphHeight + nCharSpacing; // To find the height, keep putting characters into the rows until we reach the bottom. int nXOffset = 0; int nMaxXOffset = 0; for( uint32 nGlyph = 0; nGlyph < nNumGlyphs; nGlyph++ ) { // Get this character's width. int nCharWidthWithSpacing = pGlyphs[nGlyph].m_rBlackBox.GetWidth() + nCharSpacing; // See if this width fits in the current row. if( nXOffset + nCharWidthWithSpacing < MAXIMUM_TEXTURE_SIZE ) { // Still fits in the current row. nXOffset += nCharWidthWithSpacing; //keep track of the maximum extent nMaxXOffset = LTMAX(nMaxXOffset, nXOffset); } else { // Doesn't fit in the current row. Englarge by one row // and start at the left again. nXOffset = 0; nRawHeight += nMaxGlyphHeight + nCharSpacing; //keep track of the maximum extent nMaxXOffset = LTMAX(nMaxXOffset, nCharWidthWithSpacing); } } //if the nMaxOffset extends past the maximum texture size, then we have a glyph that is too //large to fit on a texture if(nMaxXOffset >= MAXIMUM_TEXTURE_SIZE) return false; //also see if the whole string couldn't fit on the texture if(nRawHeight >= MAXIMUM_TEXTURE_SIZE) return false; //adjust the offset to be a texture size sizeTexture.cx = GetTextureSize( nMaxXOffset ); // Enlarge the height to the nearest power of two and use that as our final height. sizeTexture.cy = GetTextureSize( nRawHeight ); //otherwise the texture size is valid return true; }
void LightmapsPacker::ParseSpriteDescriptors() { FileList * fileList = new FileList(outputDir); char8 buf[512]; uint32 readSize; int32 itemsCount = fileList->GetCount(); for(int32 i = 0; i < itemsCount; ++i) { const FilePath & filePath = fileList->GetPathname(i); if(fileList->IsDirectory(i) || !filePath.IsEqualToExtension(".txt")) { continue; } LightmapAtlasingData data; data.meshInstanceName = filePath.GetBasename(); File * file = File::Create(filePath, File::OPEN | File::READ); file->ReadLine(buf, sizeof(buf)); //textures count readSize = file->ReadLine(buf, sizeof(buf)); //texture name FilePath originalTextureName = outputDir + String(buf, readSize); data.textureName = originalTextureName; file->ReadLine(buf, sizeof(buf)); //image size file->ReadLine(buf, sizeof(buf)); //frames count file->ReadLine(buf, sizeof(buf)); //frame rect int32 x, y, dx, dy, unused0, unused1, unused2; sscanf(buf, "%d %d %d %d %d %d %d", &x, &y, &dx, &dy, &unused0, &unused1, &unused2); dx++;//cause TexturePacker::ReduceRectToOriginalSize removed one pixel by default dy++; Vector2 textureSize = GetTextureSize(originalTextureName); data.uvOffset = Vector2((float32)x/textureSize.x, (float32)y/textureSize.y); data.uvScale = Vector2((float32)dx/textureSize.x, (float32)dy/textureSize.y); file->Release(); atlasingData.push_back(data); FileSystem::Instance()->DeleteFile(filePath); } fileList->Release(); }
void ScopeBarIcon::Draw(nux::GraphicsEngine& graphics_engine, bool force_draw) { nux::Geometry const& geo = GetGeometry(); graphics_engine.PushClippingRectangle(geo); if (HasKeyFocus() && focus_layer_) { nux::Geometry geo(GetGeometry()); nux::AbstractPaintLayer* layer = focus_layer_.get(); layer->SetGeometry(geo); layer->Renderlayer(graphics_engine); } if (texture()) { unsigned int current_alpha_blend; unsigned int current_src_blend_factor; unsigned int current_dest_blend_factor; graphics_engine.GetRenderStates().GetBlend(current_alpha_blend, current_src_blend_factor, current_dest_blend_factor); graphics_engine.GetRenderStates().SetBlend(true, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); float opacity = active ? 1.0f : inactive_opacity_; int width = 0, height = 0; GetTextureSize(&width, &height); nux::TexCoordXForm texxform; texxform.SetTexCoordType(nux::TexCoordXForm::OFFSET_COORD); texxform.SetWrap(nux::TEXWRAP_CLAMP_TO_BORDER, nux::TEXWRAP_CLAMP_TO_BORDER); graphics_engine.QRP_1Tex(geo.x + ((geo.width - width) / 2), geo.y + ((geo.height - height) / 2), width, height, texture()->GetDeviceTexture(), texxform, nux::color::White * opacity); graphics_engine.GetRenderStates().SetBlend(current_alpha_blend, current_src_blend_factor, current_dest_blend_factor); } graphics_engine.PopClippingRectangle(); }
bool FFMpegVideoDecoder::ProcessInput( const PlayerProcedureKey&, void* data ) { FFMpegVideoPackage* package = (FFMpegVideoPackage*)data; int got_frame = 0; bool ret = (avcodec_decode_video2( package->codecContext, m_pFrame, &got_frame, &package->packet ) >= 0); av_free_packet( &package->packet ); if ( got_frame ) { uint32 size = GetTextureSize( m_pFrame->width, m_pFrame->height ); m_pPlayerContext->mediaInfo.video.frameWidth = m_pFrame->width; m_pPlayerContext->mediaInfo.video.frameHeight = m_pFrame->height; m_pImageConvertContext = sws_getCachedContext( m_pImageConvertContext, m_pFrame->width, m_pFrame->height, (AVPixelFormat)m_pFrame->format, size, size, AV_PIX_FMT_RGBA, SWS_BILINEAR, NULL, NULL, NULL ); if ( NULL == m_pImageConvertContext ) { av_frame_unref( m_pFrame ); return false; } RGBATexture* texture = (RGBATexture*)GetOutputBuffer( STRETCHED_RGBA_TEXTURE, sizeof(RGBATexture) + size * size * 4 ); if ( NULL != texture ) { AVPicture pict = { { 0 } }; texture->pixelData = (uint8*)texture + sizeof(RGBATexture); texture->width = size; texture->pixelCount = size * size; int64_t pts = av_frame_get_best_effort_timestamp( m_pFrame ); m_lastTimeStamp += (int64)((float32)(pts - m_lastPts) * (float32)m_pPlayerContext->mediaInfo.video.frameNum / (float32)m_pPlayerContext->mediaInfo.video.fraquency * 1000.f); m_lastPts = pts; if ( m_lastTimeStamp < 0 ) { m_lastTimeStamp = 0; } texture->time = m_lastTimeStamp; pict.data[0] = (uint8_t*)texture->pixelData; pict.linesize[0] = texture->width * 4; sws_scale( m_pImageConvertContext, m_pFrame->data, m_pFrame->linesize, 0, m_pFrame->height, pict.data, pict.linesize ); CommitOutputBuffer( STRETCHED_RGBA_TEXTURE ); } av_frame_unref( m_pFrame ); } return ret; }
GLTexture* UIOpenGLTextures::CreateTexture(QSize ActualSize, bool UsePBO, uint Type, uint DataType, uint DataFmt, uint InternalFmt, uint Filter, uint Wrap) { if (!Type) Type = m_defaultTextureType; QSize totalsize = GetTextureSize(Type, ActualSize); GLuint tex; glGenTextures(1, &tex); glBindTexture(Type, tex); if (tex) { GLTexture *texture = new GLTexture(tex); texture->m_type = Type; texture->m_dataType = DataType; texture->m_dataFmt = DataFmt; texture->m_internalFmt = InternalFmt; texture->m_size = totalsize; texture->m_actualSize = ActualSize; texture->m_dataSize = GetBufferSize(ActualSize, DataFmt, DataType); texture->m_internalDataSize = GetBufferSize(totalsize, InternalFmt, GL_UNSIGNED_BYTE); SetTextureFilters(texture, Filter, Wrap); ClearTexture(texture); if (UsePBO) CreatePBO(texture); CreateVBO(texture); m_textures.insert(tex, texture); return texture; } return NULL; }
static int Init() { nInitedSubsytems = SDL_WasInit(SDL_INIT_VIDEO); if (!(nInitedSubsytems & SDL_INIT_VIDEO)) { SDL_InitSubSystem(SDL_INIT_VIDEO); } nGamesWidth = nVidImageWidth; nGamesHeight = nVidImageHeight; nRotateGame = 0; if (bDrvOkay) { // Get the game screen size BurnDrvGetVisibleSize(&nGamesWidth, &nGamesHeight); if (BurnDrvGetFlags() & BDF_ORIENTATION_VERTICAL) { printf("Vertical\n"); nRotateGame = 1; } if (BurnDrvGetFlags() & BDF_ORIENTATION_FLIPPED) { printf("Flipped\n"); bFlipped = true; } } if (!nRotateGame) { nTextureWidth = GetTextureSize(nGamesWidth); nTextureHeight = GetTextureSize(nGamesHeight); } else { nTextureWidth = GetTextureSize(nGamesHeight); nTextureHeight = GetTextureSize(nGamesWidth); } nSize = 2; bVidScanlines = 0; RECT test_rect; test_rect.left = 0; test_rect.right = nGamesWidth; test_rect.top = 0; test_rect.bottom = nGamesHeight; printf("correctx before %d, %d\n", test_rect.right, test_rect.bottom); VidSScaleImage(&test_rect); printf("correctx after %d, %d\n", test_rect.right, test_rect.bottom); screen = SDL_SetVideoMode(test_rect.right * nSize, test_rect.bottom * nSize, 32, SDL_OPENGL); SDL_WM_SetCaption("FB Alpha", NULL); // Initialize the buffer surfaces BlitFXInit(); // Init opengl init_gl(); return 0; }
Rect LandscapeEditorDrawSystem::GetTextureRect(Landscape::eTextureLevel level) { float32 textureSize = GetTextureSize(level); return Rect(Vector2(0.f, 0.f), Vector2(textureSize, textureSize)); }