当前位置: 首页>>代码示例>>C++>>正文


C++ CTexture::GetWidth方法代码示例

本文整理汇总了C++中CTexture::GetWidth方法的典型用法代码示例。如果您正苦于以下问题:C++ CTexture::GetWidth方法的具体用法?C++ CTexture::GetWidth怎么用?C++ CTexture::GetWidth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CTexture的用法示例。


在下文中一共展示了CTexture::GetWidth方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1:

bool CWinSystemX11::CreateNewWindow(const CStdString& name, bool fullScreen, RESOLUTION_INFO& res, PHANDLE_EVENT_FUNC userFunction)
{
  RESOLUTION_INFO& desktop = g_settings.m_ResInfo[RES_DESKTOP];

  if (fullScreen &&
      (res.iWidth != desktop.iWidth || res.iHeight != desktop.iHeight ||
       res.fRefreshRate != desktop.fRefreshRate || res.iScreen != desktop.iScreen))
  {
    //on the first call to SDL_SetVideoMode, SDL stores the current displaymode
    //SDL restores the displaymode on SDL_QUIT(), if we change the displaymode
    //before the first call to SDL_SetVideoMode, SDL changes the displaymode back
    //to the wrong mode on exit

    CLog::Log(LOGINFO, "CWinSystemX11::CreateNewWindow initializing to desktop resolution first");
    if (!SetFullScreen(true, desktop, false))
      return false;
  }

  if(!SetFullScreen(fullScreen, res, false))
    return false;

  CTexture iconTexture;
  iconTexture.LoadFromFile("special://xbmc/media/icon.png");

  SDL_WM_SetIcon(SDL_CreateRGBSurfaceFrom(iconTexture.GetPixels(), iconTexture.GetWidth(), iconTexture.GetHeight(), 32, iconTexture.GetPitch(), 0xff0000, 0x00ff00, 0x0000ff, 0xff000000L), NULL);
  SDL_WM_SetCaption("XBMC Media Center", NULL);

  m_bWindowCreated = true;
  return true;
}
开发者ID:tmacreturns,项目名称:XBMC_wireless_setup,代码行数:30,代码来源:WinSystemX11.cpp

示例2: DoWork

bool CTextureDDSJob::DoWork()
{
  CTexture texture;
  if (URIUtils::GetExtension(m_original).Equals(".dds"))
    return false;
  if (texture.LoadFromFile(m_original))
  { // convert to DDS
    CDDSImage dds;
    CLog::Log(LOGDEBUG, "Creating DDS version of: %s", m_original.c_str());
    return dds.Create(URIUtils::ReplaceExtension(m_original, ".dds"), texture.GetWidth(), texture.GetHeight(), texture.GetPitch(), texture.GetPixels(), 40);
  }
  return false;
}
开发者ID:misa17,项目名称:xbmc,代码行数:13,代码来源:TextureCacheJob.cpp

示例3: CreateNewWindow

bool CWinSystemEGL::CreateNewWindow(const CStdString& name, bool fullScreen, RESOLUTION_INFO& res, PHANDLE_EVENT_FUNC userFunction)
{
  if(!SetFullScreen(fullScreen, res, false))
	return false;

  CTexture iconTexture;
  iconTexture.LoadFromFile("special://xbmc/media/icon.png");

  SDL_WM_SetIcon(SDL_CreateRGBSurfaceFrom(iconTexture.GetPixels(), iconTexture.GetWidth(), iconTexture.GetHeight(), BPP, iconTexture.GetPitch(), 0xff0000, 0x00ff00, 0x0000ff, 0xff000000L), NULL);
  SDL_WM_SetCaption("XBMC Media Center", NULL);

  m_bWindowCreated = true;

  m_eglext  = " ";
  m_eglext += eglQueryString(m_eglDisplay, EGL_EXTENSIONS);
  m_eglext += " ";

  CLog::Log(LOGDEBUG, "EGL_EXTENSIONS:%s", m_eglext.c_str());

  return true;
}
开发者ID:Bobbin007,项目名称:xbmc,代码行数:21,代码来源:WinSystemEGL.cpp

示例4: lock

const CTextureArray& CGUITextureManager::Load(const std::string& strTextureName, bool checkBundleOnly /*= false */)
{
    std::string strPath;
    static CTextureArray emptyTexture;
    int bundle = -1;
    int size = 0;
    if (!HasTexture(strTextureName, &strPath, &bundle, &size))
        return emptyTexture;

    if (size) // we found the texture
    {
        for (int i = 0; i < (int)m_vecTextures.size(); ++i)
        {
            CTextureMap *pMap = m_vecTextures[i];
            if (pMap->GetName() == strTextureName)
            {
                //CLog::Log(LOGDEBUG, "Total memusage %u", GetMemoryUsage());
                return pMap->GetTexture();
            }
        }
        // Whoops, not there.
        return emptyTexture;
    }

    for (ilistUnused i = m_unusedTextures.begin(); i != m_unusedTextures.end(); ++i)
    {
        CTextureMap* pMap = i->first;
        if (pMap->GetName() == strTextureName && i->second > 0)
        {
            m_vecTextures.push_back(pMap);
            m_unusedTextures.erase(i);
            return pMap->GetTexture();
        }
    }

    if (checkBundleOnly && bundle == -1)
        return emptyTexture;

    //Lock here, we will do stuff that could break rendering
    CSingleLock lock(g_graphicsContext);

#ifdef _DEBUG_TEXTURES
    int64_t start;
    start = CurrentHostCounter();
#endif

    if (bundle >= 0 && StringUtils::EndsWithNoCase(strPath, ".gif"))
    {
        CTextureMap* pMap = nullptr;
        CBaseTexture **pTextures = nullptr;
        int nLoops = 0, width = 0, height = 0;
        int* Delay = nullptr;
        int nImages = m_TexBundle[bundle].LoadAnim(strTextureName, &pTextures, width, height, nLoops, &Delay);
        if (!nImages)
        {
            CLog::Log(LOGERROR, "Texture manager unable to load bundled file: %s", strTextureName.c_str());
            delete[] pTextures;
            delete[] Delay;
            return emptyTexture;
        }

        unsigned int maxWidth = 0;
        unsigned int maxHeight = 0;
        pMap = new CTextureMap(strTextureName, width, height, nLoops);
        for (int iImage = 0; iImage < nImages; ++iImage)
        {
            pMap->Add(pTextures[iImage], Delay[iImage]);
            maxWidth = std::max(maxWidth, pTextures[iImage]->GetWidth());
            maxHeight = std::max(maxHeight, pTextures[iImage]->GetHeight());
        }

        pMap->SetWidth((int)maxWidth);
        pMap->SetHeight((int)maxHeight);

        delete[] pTextures;
        delete[] Delay;

        if (pMap)
        {
            m_vecTextures.push_back(pMap);
            return pMap->GetTexture();
        }
    }
    else if (StringUtils::EndsWithNoCase(strPath, ".gif") ||
             StringUtils::EndsWithNoCase(strPath, ".apng"))
    {
        CTextureMap* pMap = nullptr;

        std::string mimeType;
        if (StringUtils::EndsWithNoCase(strPath, ".gif"))
            mimeType = "image/gif";
        else if (StringUtils::EndsWithNoCase(strPath, ".apng"))
            mimeType = "image/apng";

        XFILE::CFile file;
        XFILE::auto_buffer buf;
        CFFmpegImage anim(mimeType);
        pMap = new CTextureMap(strTextureName, 0, 0, 0);

        if (file.LoadFile(strPath, buf) <= 0 ||
//.........这里部分代码省略.........
开发者ID:deniscostadsc,项目名称:xbmc,代码行数:101,代码来源:TextureManager.cpp

示例5: texture

//********************************************
// BuildList
//********************************************
int CSceneGraph3d::glBuildList()
{
	// Meshes
	//***********************************
	unsigned int i,size = m_ArrayObject3d.GetSize();
	for(i=0; i<size; i++)
	{
		CObject3d *pObject3d = m_ArrayObject3d.GetAt(i);
		if(pObject3d != NULL)
		{
			pObject3d->glBuildList();
		}
	}

	// Textures
	//***********************************
	unsigned int NbTexture = m_ArrayTexture.GetSize();
	if(NbTexture)
	{
		TRACE("SceneGraph : texture binding...(%d texture(s))\n",NbTexture);

		// Cleanup
		if(m_pIndexTextureBinding != NULL)
		{
			::glDeleteTextures(NbTexture,m_pIndexTextureBinding);
			delete [] m_pIndexTextureBinding;
		}
		m_pIndexTextureBinding = new unsigned int[NbTexture];

		::glGenTextures(NbTexture,m_pIndexTextureBinding);
		int error = glGetError();
		ASSERT(error !=  GL_INVALID_VALUE);
		ASSERT(error !=  GL_INVALID_OPERATION);

		TRACE("Bind texture...\n");
		for(i=0;i<NbTexture;i++)
		{
			while (GL_NO_ERROR != glGetError() ) {}

			// Bind texture
			glBindTexture(GL_TEXTURE_2D,m_pIndexTextureBinding[i]);


			glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
			glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
			glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
			glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
			glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);

			int error = glGetError();
			ASSERT(error !=  GL_INVALID_ENUM);
			ASSERT(error !=  GL_INVALID_OPERATION);

			// Read datas
			CTexture *pTexture = m_ArrayTexture[i];
			ASSERT(pTexture->GetData() != NULL);
			::glTexImage2D(GL_TEXTURE_2D,0,3,
										 pTexture->GetWidth(),pTexture->GetHeight(),0,			
										 GL_RGB,GL_UNSIGNED_BYTE,pTexture->GetData());
			error = glGetError();
			ASSERT(error !=  GL_INVALID_ENUM);
			ASSERT(error !=  GL_INVALID_OPERATION);
			ASSERT(error !=  GL_INVALID_VALUE);

		}

	}
	m_ListDone = 1;

	return 1;
}
开发者ID:TomKerekes,项目名称:KMotionX,代码行数:74,代码来源:SceneGraph3d.cpp

示例6: _UpdateVertexes

	void _UpdateVertexes()
	{
		if(!m_Font || !m_TextLines.Size())
			return;

		m_Vertexes.SetUsed(m_GlyphCount << 2);
		m_Positions.SetUsed(m_GlyphCount << 2);

		f32 nXCoord = 0.0f;
		f32 nYCoord = 0.0f;

		CTexture* texture = m_Font->GetTexture();

		u32 glyphCounter =  0;

		CList<STextLine>::CIterator it = m_TextLines.Begin();
		while(it != m_TextLines.End())
		{
			STextLine& line = *it;

			++it;

			for(u32 j = 0; j < line.Text.Size(); j++)
			{
				CFont2D::SGlyph* glyph = m_Font->GetGlyph(line.Text[j]);

				if(glyph)
				{
					f32 tx = f32(glyph->X)/f32(texture->GetWidth());
					f32 ty = f32(glyph->Y)/f32(texture->GetHeight());
					f32 tw = f32(glyph->W)/f32(texture->GetWidth());
					f32 th = f32(glyph->H)/f32(texture->GetHeight());

					f32 fXOffset = f32(glyph->Xo);
					f32 fYOffset = f32(glyph->Yo);

					f32 ox = 0.0f;
					f32 oy = 0.0f;

					if(m_HAlignment == EHA_CENTER)
					{
						ox = (m_TextSize.X - line.Width)/2.0f;
					}
					else
					if(m_HAlignment == EHA_RIGHT)
					{
						ox = m_TextSize.X - line.Width;
					}

					if(m_VAlignment == EVA_CENTER)
					{
						oy = (m_TextSize.Y - m_TextLines.Size()*m_Font->GetSize())/2.0f;
					}
					else
					if(m_VAlignment == EVA_BOTTOM)
					{
						oy = m_TextSize.Y - m_TextLines.Size()*m_Font->GetSize();
					}

					u32 idx = glyphCounter << 2;

					m_Positions[idx + 0].X = nXCoord + fXOffset + ox;
					m_Positions[idx + 0].Y = nYCoord + fYOffset + oy;
					m_Positions[idx + 0].Z = 0.0f;
					m_Vertexes[idx + 0].U = tx;
					m_Vertexes[idx + 0].V = ty;
					m_Vertexes[idx + 0].Color = m_Color;

					m_Positions[idx + 1].X = nXCoord + fXOffset + ox;
					m_Positions[idx + 1].Y = nYCoord + f32(glyph->H) + fYOffset + oy;
					m_Positions[idx + 1].Z = 0.0f;
					m_Vertexes[idx + 1].U = tx;
					m_Vertexes[idx + 1].V = ty + th;
					m_Vertexes[idx + 1].Color = m_Color;

					m_Positions[idx + 2].X = nXCoord + f32(glyph->W) + fXOffset + ox;
					m_Positions[idx + 2].Y = nYCoord + f32(glyph->H) + fYOffset + oy;
					m_Positions[idx + 2].Z = 0.0f;
					m_Vertexes[idx + 2].U = tx + tw;
					m_Vertexes[idx + 2].V = ty + th;
					m_Vertexes[idx + 2].Color = m_Color;

					m_Positions[idx + 3].X = nXCoord + f32(glyph->W) + fXOffset + ox;
					m_Positions[idx + 3].Y = nYCoord + fYOffset + oy;
					m_Positions[idx + 3].Z = 0.0f;
					m_Vertexes[idx + 3].U = tx + tw;
					m_Vertexes[idx + 3].V = ty;
					m_Vertexes[idx + 3].Color = m_Color;

					glyphCounter++;

					nXCoord += glyph->Xa;
				}
				else
					nXCoord += m_Font->GetSize();
			}

			nXCoord = 0.0;
			nYCoord += m_Font->GetSize();
		}
//.........这里部分代码省略.........
开发者ID:dexmas,项目名称:WaloEngine,代码行数:101,代码来源:Text2D.hpp


注:本文中的CTexture::GetWidth方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。