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


C++ Texture::Create方法代码示例

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


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

示例1: Capture

/*---------------------------------------------------------------------------
   Captures the contents of the frame buffer object for streaming purposes.
   Returns true if the frame was successfully captured. If the Wait flag is
   set, the function with use a blocking mutex lock on the Frame texture.
  ---------------------------------------------------------------------------*/
bool Filter::Capture(Texture &Frame, bool Wait)
   {
   if (!Ready()) {return false;}

   MutexControl Mutex(Frame.GetMutexHandle());
   if (!Wait && !Mutex.LockRequest()) {return false;}
   else {Mutex.Lock();}
   
   vector2u Res = Frame.Resolution();
   if (Res.U != ViewPort.C2 || Res.V != ViewPort.C3 || Frame.DataType() != Texture::TypeRGB) 
      {
      Res.Set(ViewPort.C2, ViewPort.C3);
      Frame.Create(Res, Texture::TypeRGB);
      }

   glBindFramebuffer(GL_READ_FRAMEBUFFER, FBOID);
   glReadPixels(0, 0, Res.U, Res.V, Frame.DataFormat(), Frame.DataCompType(), Frame.Pointer());
   glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);

   #if defined (DEBUG)
      GLenum Error = glGetError();
      if (Error != GL_NO_ERROR) {throw dexception("OpenGL generated an error: %s", Debug::ErrorGL(Error));}
   #endif
   
   return true;
   }
开发者ID:DominikDeak,项目名称:KFX,代码行数:31,代码来源:filter.cpp

示例2: CreateFor

Texture* SolidColorTextureCache::CreateFor(const Color &color, Texture *existing)
{
	LOG_INFO(LOGCAT_ASSETS, "SolidColorTextureCache: creating texture for color 0x%8x.\n", color.ToInt());

	Image *img = new Image();
	bool imageCreateSuccess = img->Create(8, 8, IMAGE_FORMAT_RGBA);
	ASSERT(imageCreateSuccess == true);

	Texture *texture;
	if (existing != NULL)
	{
		texture = existing;
		texture->Release();
	}
	else
		texture = new Texture();

	img->Clear(color);	
	bool success = texture->Create(m_graphicsDevice, img);
	SAFE_DELETE(img);

	if (!success)
	{
		// if we allocated the texture ourselves, we should free it
		if (existing != NULL)
		{
			SAFE_DELETE(texture);
		}
	}

	return texture;
}
开发者ID:gered,项目名称:MyGameFramework,代码行数:32,代码来源:solidcolortexturecache.cpp

示例3: vdLogGlobalWarning

Texture*
Texture::Create3D(
    const Texture::Properties& properties,
    const void* ptr)
{
    Texture* texture = VD_NEW(Texture);
    bool success = texture->Create(properties, ptr);
    if(!success)
    {
        vdLogGlobalWarning("Texture: Error Creating Texture!");
        VD_DELETE(texture);
        return NULL;
    }
    return texture;
}
开发者ID:ICRAR,项目名称:void,代码行数:15,代码来源:texture.cpp

示例4: BmpALoader

Resource* BmpALoader(const std::string& resName)
{
  std::string img = resName.substr(0, resName.size() - 1);
  std::string alpha = GetFileNoExt(img) + "-a.bmp";

  unsigned int w = 0;
  unsigned int h = 0;
  
  unsigned char* rgbdata = LoadDIBitmap(img.c_str(), &w, &h);
  
  if (!rgbdata)
  {
//?    ReportError("Failed to load texture " + img);
    return 0;
  }

  // Add space for alpha
  unsigned char* withAlpha = AddAlpha(rgbdata, w, h);
  Assert(withAlpha);
  delete [] rgbdata;
  rgbdata = 0;

  // Load alpha image
  unsigned int aw = 0;
  unsigned int ah = 0;
  unsigned char* alphadata = LoadDIBitmap(alpha.c_str(), &aw, &ah);
  Assert(alphadata);
  Assert(aw == w);
  Assert(ah == h);

  // Copy alpha image to alpha channel of RGB image
  CopyAlpha(alphadata, withAlpha, w, h);
  delete [] alphadata;
  alphadata = 0;

  Texture* pTex = new Texture;
  pTex->Create(withAlpha, w, h, 4); // 4 bytes per pixel
  delete [] withAlpha;

  return (Resource*)pTex;
}
开发者ID:jason-amju,项目名称:amjulib,代码行数:41,代码来源:AlphaBmpLoader.cpp

示例5: init

void App::init()
{  
    pause = true;
    m_timer = 1000;
	printf("Loading...");
	m_MatProj3D = glm::perspective(35.0f, (float)getScreen().x / (float)getScreen().y, 0.01f, 100.f);
    m_MatProj2D = ortho(0.0f,(float)getScreen().x,0.0f,(float)getScreen().y);
	drawMouse = false;
	draw = true;
	pause = false;
    DeferredRendering* mode = new DeferredRendering(getScreen());
    //RenderingMode::SetRenderingMode(mode);
	tex[0].Create(getScreen(),PXF_A8R8G8B8,TEXTURE_2D);
	tex[1].Create(getScreen(),PXF_A8R8G8B8,TEXTURE_2D);
    m_fxaa = new AntiAliasing();
	blur = new BlurMotionEffect(getScreen());
	//drug = new DrugEffect();
	//PostEffectMgr::Instance().AddEffect(drug);
	//PostEffectMgr::Instance().AddEffect(new BlurMotionEffect(getScreen()));
    //PostEffectMgr::Instance().AddEffect(m_fxaa);
	//PostEffectMgr::Instance().AddEffect(new Inverse());
    m_fps = new GraphicString(ivec2(0,getScreen().y-15),"",Color::black);
    m_Scene = new SceneMgr();
	Texture t;
	Texture color_gradiant;
	
	Material* mat = new Material();
	mat->SetTexture(t,0,(TRenderPass)((1<<RENDERPASS_DEFERRED) | (1<<RENDERPASS_ZBUFFER)));
	mat->SetTexture(color_gradiant,1,(TRenderPass)(1<<RENDERPASS_DEFERRED));
    Driver::Get().SetActiveScene(m_Scene);
    Driver::Get().SetCullFace(2);

    m_light = new Light(vec3(0, 0 ,10),-normalize(vec3(0,0.2,-1)),LightType::LIGHT_DIR);//new Light(vec3(0,0,10),-normalize(vec3(0,0.5,-1)),LIGHT_SPOT);
    m_Scene->AddLight(m_light);
    m_light->SetRange(2000.0f);
	ShaderProgram prog;
	ShaderProgram prog2;
	/*particles1 = new ParticlesEmitter("Shader/particle_1.glsl",250,new Transform(vec3(-6,0,0)));
	particles2 = new ParticlesEmitter("Shader/particle_2.glsl",250,new Transform(vec3(6,0,0)));*/
	
	string cubemap[6];
	/*for(int i = 0; i < 6; i++)
	{
		cubemap[i] = StringBuilder("Texture/background/")(i+1)(".png");
	}*/
	//Texture tex_cubemap;
	//tex_cubemap.CreateFromFile(cubemap,PXF_A8R8G8B8);
	mouse_emitter = new ParticlesEmitter(std::string("shader/particle_3.glsl"),2,new Transform());
	AWindow* position =new AWindow();
	AWindow* velocity = new AWindow();
	AWindow* life = new AWindow();


	//particles->velocity_buffer[1]);
	//life->SetBackground(mouse_emitter->extra_buffer[0]);
	//GUIMgr::Instance().AddWidget(position);
	//GUIMgr::Instance().AddWidget(velocity);
//	GUIMgr::Instance().AddWidget(life);
	SkyBox* box = new SkyBox();
	//box->SetTexture(tex_cubemap);
	cam3D = new FollowCamera(m_MatProj3D,0,0,vec2(-65.7063446,0),10.f);//m_MatProj3D,4.8f,8.8f,vec2(0,-7.55264f),9.87785f); //Follow Camera Theta(4.8) _phi(8.8) angles(0,-7.55264) distance(9.87785)
	cam2D = new FPCamera(m_MatProj2D);

	velocity_program.LoadFromFile("Shader/particle_velocity_render.glsl");
	mass_program.LoadFromFile("Shader/particle_mass_render.glsl");
	tmass.Create(getScreen(),PXF_A8R8G8B8,TEXTURE_2D);
	tvelocity.Create(getScreen(),PXF_A8R8G8B8,TEXTURE_2D);
	position->SetBackground(tmass);
	velocity->SetBackground(tvelocity);
	

    Camera::setCurrent(cam3D, CAMERA_3D);
    Camera::setCurrent(cam2D, CAMERA_2D);

	m_particles.push_back(new ParticlesEmitter(std::string("shader/particle_4.glsl"),2500	,new Transform(vec3((0),0.f,0)*30.f)));
	printf("Loading end");
}
开发者ID:Agamand,项目名称:AgmdEngine,代码行数:77,代码来源:App.cpp

示例6: Load


//.........这里部分代码省略.........

   if (setjmp(png_jmpbuf(PngPtr)))
      {throw dexception("setjmp( ) failed.");}

   //Read into structures
   png_init_io(PngPtr, File);
   png_set_sig_bytes(PngPtr, PNG::HeaderSize);
   png_read_info(PngPtr, InfoPtr);

   //Determine image attributes
   vector2<png_uint_32> Res;
   int BitDepth, ColourType;
   png_get_IHDR(PngPtr, InfoPtr, &Res.U, &Res.V, &BitDepth, &ColourType, nullptr, nullptr, nullptr);

   Texture::TexType Type = Texture::TypeRGB;
   switch (ColourType)
      {
      case PNG_COLOR_TYPE_GRAY :
         if (BitDepth < 8)
            {
            Type = Texture::TypeLum;
            png_set_expand_gray_1_2_4_to_8(PngPtr);
            }
         else if (BitDepth == 16)
            {
            Type = Texture::TypeDepth;
            }
         break;

      case PNG_COLOR_TYPE_GRAY_ALPHA :
         Type = Texture::TypeRGBA;
         png_set_gray_to_rgb(PngPtr);
         break;

      case PNG_COLOR_TYPE_PALETTE :
         Type = Texture::TypeRGB;
         png_set_palette_to_rgb(PngPtr);
         break;

      case PNG_COLOR_TYPE_RGB :
         Type = Texture::TypeRGB;
         png_set_strip_alpha(PngPtr); //If libpng reports RGB, make sure we completely strip alpha
         break;

      case PNG_COLOR_TYPE_RGB_ALPHA :
         Type = Texture::TypeRGBA;
         break;

      default : throw dexception("Unknown colour type.");
      }

   //Convert palette alpha into a separate alpha channel
   if (png_get_valid(PngPtr, InfoPtr, PNG_INFO_tRNS))
      {
      png_set_tRNS_to_alpha(PngPtr);
      if (ColourType == PNG_COLOR_TYPE_PALETTE) {Type = Texture::TypeRGBA;}
      }

   //Force 8 bit per channel
   if (BitDepth >= 16)
      {
      if (Type != Texture::TypeDepth) {png_set_strip_16(PngPtr);}
      }
   else if (BitDepth < 8)
      {
      png_set_packing(PngPtr);
      }

   //Specify display and file gamma (assume 0.45455 for missing file gamma)
   double FileGamma;
   if (!png_get_gAMA(PngPtr, InfoPtr, &FileGamma)) {FileGamma = 0.45455;}
   png_set_gamma(PngPtr, Gamma, FileGamma);

   //Swap byte order for int16 values on big endian machines
   if ((BitDepth >= 16) && !Math::MachineLittleEndian())
      {png_set_swap(PngPtr);}

   //Apply the above transformation settings
   png_read_update_info(PngPtr, InfoPtr);

   //Allocate image
   Image.Create(cast_vector2(uint, Res), Type);

   if (Image.GetBytesPerLine() < (usize)png_get_rowbytes(PngPtr, InfoPtr))
      {throw dexception("Incorrect scan line size for allocated image.");}

   //Populate row pointer array
   Rows.Create((usize)Res.V);
   for (uiter I = 0; I < (usize)Res.V; I++)
      {
      Rows[I] = Image.Address(0, I);
      }

   //Decode
   png_read_image(PngPtr, Rows.Pointer());
   png_read_end(PngPtr, InfoPtr);

   //Clean up
   Destroy();
   }
开发者ID:DominikDeak,项目名称:KFX,代码行数:101,代码来源:file_png.cpp


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