TexturePtr D3D9VideoBufferManager::FindTexture(const TString128 & sName) { // 1. find in 2d texture map Texture2DMap::Iterator iter0 = mTextures.Find(sName); Texture2DMap::Iterator end0 = mTextures.End(); if (iter0 != end0) return TexturePtr(iter0->second); // 2. find in cube texture map TextureCubeMap::Iterator iter1 = mCubeTextures.Find(sName); TextureCubeMap::Iterator end1 = mCubeTextures.End(); if (iter1 != end1) return TexturePtr(iter1->second); // 3. find in volume texture map TextureVolMap::Iterator iter2 = mVolumeTextures.Find(sName); TextureVolMap::Iterator end2 = mVolumeTextures.End(); if (iter2 != end2) return TexturePtr(iter2->second); return TexturePtr(); }
/// \fn ResourceManager::loadTexture (const std::string& file) /// \brief Returns a texture from a the given file. TexturePtr ResourceManager::getTexture(const String& file) { ResourceHandle<Graphics::Texture>* phandle = NULL; if ( !mResources.contains(file) ) { String path = sPath + file; std::unique_ptr<Graphics::Texture> texture(mContentManager.loadContent<Graphics::Texture>(path)); if ( !(texture) ) return TexturePtr(); phandle = new ResourceHandle<Graphics::Texture>(*this, texture.release()); phandle->setName(file); ResourceHandleBase* pbasehandle = phandle; // needed for *& in container, perhaps time to change that.. mResources.insert(file, pbasehandle); } else { phandle = static_cast<ResourceHandle<Graphics::Texture>*>(*mResources.get(file)); } ASSERT_PTR(phandle); return TexturePtr(phandle); }
void FrameBuffer::resize(const Size& size) { assert(size.isValid()); if(m_texture && m_texture->getSize() == size) return; m_texture = TexturePtr(new Texture(size)); m_texture->setSmooth(m_smooth); m_texture->setUpsideDown(true); if(m_fbo) { internalBind(); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_texture->getId(), 0); GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER); if(status != GL_FRAMEBUFFER_COMPLETE) g_logger.fatal("Unable to setup framebuffer object"); internalRelease(); } else { if(m_backuping) { m_screenBackup = TexturePtr(new Texture(size)); m_screenBackup->setUpsideDown(true); } } }
SSRPostProcess::SSRPostProcess() : PostProcess(L"ScreenSpaceReflection") { input_pins_.push_back(std::make_pair("g_buffer_0_tex", TexturePtr())); input_pins_.push_back(std::make_pair("g_buffer_1_tex", TexturePtr())); input_pins_.push_back(std::make_pair("front_side_depth_tex", TexturePtr())); input_pins_.push_back(std::make_pair("front_side_tex", TexturePtr())); input_pins_.push_back(std::make_pair("foreground_depth_tex", TexturePtr())); params_.push_back(std::make_pair("min_samples", RenderEffectParameterPtr())); params_.push_back(std::make_pair("max_samples", RenderEffectParameterPtr())); RenderEffectPtr effect = SyncLoadRenderEffect("SSR.fxml"); this->Technique(effect->TechniqueByName("ScreenSpaceReflectionPostProcess")); if (technique_ && technique_->Validate()) { proj_param_ = effect->ParameterByName("proj"); inv_proj_param_ = effect->ParameterByName("inv_proj"); near_q_far_param_ = effect->ParameterByName("near_q_far"); ray_length_param_ = effect->ParameterByName("ray_length"); } this->SetParam(0, static_cast<int32_t>(20)); this->SetParam(1, static_cast<int32_t>(30)); }
TexturePtr GLGraphicFactory::load2DTexture(const ResourcePtr& rsrc, bool generateMipmaps) const { GLTexture2D* texture = new GLTexture2D(); if(texture->load(rsrc, generateMipmaps)) { return TexturePtr(texture); } delete texture; return TexturePtr(); }
TexturePtr GLGraphicFactory::create2DTexture(uint32 width, uint32 height, uint32 numMipmaps, ElementFormat format, const uint8* initialData, uint32 flag) const { GLTexture2D* texture = new GLTexture2D(); if(texture->create(width, height, numMipmaps, format, initialData)) { return TexturePtr(texture); } delete texture; return TexturePtr(); }
SSVOPostProcess::SSVOPostProcess() : PostProcess(L"SSVO") { input_pins_.emplace_back("g_buffer_tex", TexturePtr()); input_pins_.emplace_back("depth_tex", TexturePtr()); output_pins_.emplace_back("out_tex", TexturePtr()); this->Technique(SyncLoadRenderEffect("SSVO.fxml")->TechniqueByName("SSVO")); proj_param_ = technique_->Effect().ParameterByName("proj"); inv_proj_param_ = technique_->Effect().ParameterByName("inv_proj"); far_plane_param_ = technique_->Effect().ParameterByName("far_plane"); }
SSGIPostProcess::SSGIPostProcess() : PostProcess(L"SSGI") { input_pins_.push_back(std::make_pair("g_buffer_tex", TexturePtr())); input_pins_.push_back(std::make_pair("depth_tex", TexturePtr())); input_pins_.push_back(std::make_pair("shading_tex", TexturePtr())); output_pins_.push_back(std::make_pair("out_tex", TexturePtr())); this->Technique(SyncLoadRenderEffect("SSGI.fxml")->TechniqueByName("SSGI")); proj_param_ = technique_->Effect().ParameterByName("proj"); inv_proj_param_ = technique_->Effect().ParameterByName("inv_proj"); far_plane_param_ = technique_->Effect().ParameterByName("far_plane"); }
TexturePtr LightView::generateLightBubble(float centerFactor) { int bubbleRadius = 256; int centerRadius = bubbleRadius * centerFactor; int bubbleDiameter = bubbleRadius * 2; ImagePtr lightImage = ImagePtr(new Image(Size(bubbleDiameter, bubbleDiameter))); for(int x = 0; x < bubbleDiameter; x++) { for(int y = 0; y < bubbleDiameter; y++) { float radius = std::sqrt((bubbleRadius - x)*(bubbleRadius - x) + (bubbleRadius - y)*(bubbleRadius - y)); float intensity = stdext::clamp<float>((bubbleRadius - radius) / (float)(bubbleRadius - centerRadius), 0.0f, 1.0f); // light intensity varies inversely with the square of the distance intensity = intensity * intensity; uint8_t colorByte = intensity * 0xff; uint8_t pixel[4] = {colorByte,colorByte,colorByte,0xff}; lightImage->setPixel(x, y, pixel); } } TexturePtr tex = TexturePtr(new Texture(lightImage, true)); tex->setSmooth(true); return tex; }
void SDLTextureRenderer::start_draw() { if (!m_texture) { const int w = m_size.width / m_downscale; const int h = m_size.height / m_downscale; SDL_Texture* sdl_texture = SDL_CreateTexture(m_renderer, SDL_PIXELFORMAT_RGB888, SDL_TEXTUREACCESS_TARGET, w, h); if (!sdl_texture) { std::stringstream msg; msg << "Couldn't create lightmap texture: " << SDL_GetError(); throw std::runtime_error(msg.str()); } m_texture = TexturePtr(new SDLTexture(sdl_texture, w, h, Sampler())); } SDL_SetRenderTarget(m_renderer, get_sdl_texture()); SDL_RenderSetScale(m_renderer, 1.0f / static_cast<float>(m_downscale), 1.0f / static_cast<float>(m_downscale)); }
TexturePtr TextureManager::loadTexture(std::stringstream& file) { TexturePtr texture; apng_data apng; if(load_apng(file, &apng) == 0) { Size imageSize(apng.width, apng.height); if(apng.num_frames > 1) { // animated texture std::vector<ImagePtr> frames; std::vector<int> framesDelay; for(uint i=0;i<apng.num_frames;++i) { uchar *frameData = apng.pdata + ((apng.first_frame+i) * imageSize.area() * apng.bpp); int frameDelay = apng.frames_delay[i]; framesDelay.push_back(frameDelay); frames.push_back(ImagePtr(new Image(imageSize, apng.bpp, frameData))); } AnimatedTexturePtr animatedTexture = new AnimatedTexture(imageSize, frames, framesDelay); m_animatedTextures.push_back(animatedTexture); texture = animatedTexture; } else { ImagePtr image = ImagePtr(new Image(imageSize, apng.bpp, apng.pdata)); texture = TexturePtr(new Texture(image)); } free_apng(&apng); } return texture; }
SSGIPostProcess::SSGIPostProcess() : PostProcess(L"SSGI") { input_pins_.emplace_back("g_buffer_tex", TexturePtr()); input_pins_.emplace_back("depth_tex", TexturePtr()); input_pins_.emplace_back("shading_tex", TexturePtr()); output_pins_.emplace_back("out_tex", TexturePtr()); auto effect = SyncLoadRenderEffect("SSGI.fxml"); this->Technique(effect, effect->TechniqueByName("SSGI")); proj_param_ = effect->ParameterByName("proj"); inv_proj_param_ = effect->ParameterByName("inv_proj"); far_plane_param_ = effect->ParameterByName("far_plane"); }
TexturePtr TextureCache::load (const std::string& textureName) { if (textureName.empty()) return TexturePtr(); const size_t length = strlen(TEXTURE_SPECIAL_MARKER); if (textureName.compare(0, length, TEXTURE_SPECIAL_MARKER) == 0) { TextureMap::iterator iter = _textures.find(textureName); if (iter != _textures.end()) { _textures.erase(iter); } } else { TextureDefinitionMap::iterator i = _textureDefs.find(textureName); if (i != _textureDefs.end()) { return i->second; } TextureMap::iterator iter = _textures.find(textureName); if (iter != _textures.end()) { return iter->second; } } TexturePtr p(new Texture(textureName, _frontend)); _textures[textureName] = p; return p; }
const Vec2I& ImageBox::SetTextureAtlasRegion(const char* atlas, const char* region) { mTextureAtlas = Renderer::GetInstance().GetTextureAtlas(atlas); if (mTextureAtlas) { if (mImageFixedSize) { DrawAsFixedSize(); } SAMPLER_DESC sdesc; sdesc.Filter = TEXTURE_FILTER_MIN_MAG_MIP_POINT; TriggerRedraw(); mAtlasRegion = mTextureAtlas->GetRegion(region); if (!mAtlasRegion) { mTexture = 0; mUIObject->GetMaterial()->SetTexture(TexturePtr(), BINDING_SHADER_PS, 0, sdesc); mUIObject->ClearTexCoord(); Error("Cannot find the region %s in the atlas %s", region, atlas); return Vec2I::ZERO; } // need to set to material. matarial will hold its reference counter mTexture = mTextureAtlas->GetTexture(); mUIObject->GetMaterial()->SetTexture(mTexture, BINDING_SHADER_PS, 0, sdesc); Vec2 texcoords[4]; mAtlasRegion->GetQuadUV(texcoords); mUIObject->SetTexCoord(texcoords, 4); DWORD colors[4] = {0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff}; mUIObject->SetColors(colors, 4); mAtlasRegions.clear(); return mAtlasRegion->GetSize(); } return Vec2I::ZERO; }
SSSBlurPP::SSSBlurPP() : PostProcess(L"SSSBlurPP") { RenderDeviceCaps const & caps = Context::Instance().RenderFactoryInstance().RenderEngineInstance().DeviceCaps(); mrt_blend_support_ = (caps.max_simultaneous_rts > 1) && caps.independent_blend_support; input_pins_.emplace_back("src_tex", TexturePtr()); input_pins_.emplace_back("depth_tex", TexturePtr()); output_pins_.emplace_back("output", TexturePtr()); params_.emplace_back("strength", nullptr); params_.emplace_back("correction", nullptr); RenderEffectPtr effect = SyncLoadRenderEffect("SSS.fxml"); copy_tech_ = effect->TechniqueByName("Copy"); blur_x_tech_ = effect->TechniqueByName("BlurX"); if (mrt_blend_support_) { std::string blur_y_name = "BlurY1"; for (uint32_t i = 0; i < 3; ++ i) { blur_y_name[5] = static_cast<char>('1' + i); blur_y_techs_[i] = effect->TechniqueByName(blur_y_name); } } else { blur_y_techs_[0] = blur_x_tech_; std::string accum_name = "Accum1"; for (uint32_t i = 0; i < 3; ++ i) { accum_name[5] = static_cast<char>('1' + i); accum_techs_[i] = effect->TechniqueByName(accum_name); } } this->Technique(effect, blur_x_tech_); RenderFactory& rf = Context::Instance().RenderFactoryInstance(); blur_x_fb_ = rf.MakeFrameBuffer(); blur_y_fb_ = rf.MakeFrameBuffer(); src_tex_param_ = effect->ParameterByName("src_tex"); step_param_ = effect->ParameterByName("step"); far_plane_param_ = effect->ParameterByName("far_plane"); }
TexturePtr DShowVMR9Allocator::PresentTexture() { unique_lock<mutex> lock(mutex_); if (FAILED(d3d_device_->TestCooperativeLevel())) { return TexturePtr(); } if (cur_surf_index_ < surfaces_.size()) { TIF(d3d_device_->GetRenderTargetData(surfaces_[cur_surf_index_], cache_surf_.get())); D3DLOCKED_RECT d3dlocked_rc; TIF(cache_surf_->LockRect(&d3dlocked_rc, nullptr, D3DLOCK_NOSYSLOCK | D3DLOCK_READONLY)); uint32_t const width = present_tex_->Width(0); uint32_t const height = present_tex_->Height(0); uint32_t const texel_size = NumFormatBytes(present_tex_->Format()); uint8_t const * src = static_cast<uint8_t const *>(d3dlocked_rc.pBits); { ElementFormat fmt = present_tex_->Format(); Texture::Mapper mapper(*present_tex_, 0, 0, TMA_Write_Only, 0, 0, width, height); uint8_t* dst = mapper.Pointer<uint8_t>(); if ((EF_ARGB8 == fmt) || (EF_ARGB8_SRGB == fmt)) { for (uint32_t y = 0; y < height; ++ y) { std::memcpy(dst, src, width * texel_size); dst += mapper.RowPitch(); src += d3dlocked_rc.Pitch; } } else { BOOST_ASSERT((EF_ABGR8 == fmt) || (EF_ABGR8_SRGB == fmt)); for (uint32_t y = 0; y < height; ++ y) { for (uint32_t x = 0; x < width; ++ x) { dst[x * 4 + 0] = src[x * 4 + 2]; dst[x * 4 + 1] = src[x * 4 + 1]; dst[x * 4 + 2] = src[x * 4 + 0]; dst[x * 4 + 3] = src[x * 4 + 3]; } dst += mapper.RowPitch(); src += d3dlocked_rc.Pitch; } } } TIF(cache_surf_->UnlockRect()); } return present_tex_; }
TexturePtr DDSImage::bindTexture(const std::string& name) const { GLuint textureNum; GlobalOpenGL().assertNoErrors(); // Allocate a new texture number and store it into the Texture structure glGenTextures(1, &textureNum); glBindTexture(GL_TEXTURE_2D, textureNum); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR ); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_FALSE); for (std::size_t i = 0; i < _mipMapInfo.size(); ++i) { const MipMapInfo& mipMap = _mipMapInfo[i]; glCompressedTexImage2D( GL_TEXTURE_2D, static_cast<GLint>(i), _format, static_cast<GLsizei>(mipMap.width), static_cast<GLsizei>(mipMap.height), 0, static_cast<GLsizei>(mipMap.size), _pixelData + mipMap.offset ); // Handle unsupported format error if (glGetError() == GL_INVALID_ENUM) { rConsoleError() << "[DDSImage] Unable to bind texture '" << name << "'; unsupported texture format" << std::endl; return TexturePtr(); } GlobalOpenGL().assertNoErrors(); } glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, static_cast<GLint>(_mipMapInfo.size() - 1)); // Un-bind the texture glBindTexture(GL_TEXTURE_2D, 0); // Create and return texture object BasicTexture2DPtr texObj(new BasicTexture2D(textureNum, name)); texObj->setWidth(getWidth(0)); texObj->setHeight(getHeight(0)); GlobalOpenGL().assertNoErrors(); return texObj; }
TexturePtr Graphics::GetDefaultToonTexture( int index ) { if( index < 0 || 10 <= index ) { return TexturePtr(); } return m_defaultToonTextures[index]; }
UINode::~UINode () { for (UINodeListIter i = _nodes.begin(); i != _nodes.end(); ++i) { delete *i; } _nodes.clear(); delete _layout; _texture = TexturePtr(); }
TexturePtr Graphic::getTexture(){ if (m_texture.get() == 0){ m_texture = TexturePtr(new sf::Texture); m_texture->loadFromFile("graphics/" + m_path); m_texture->setSmooth(false); } return m_texture; }
TexturePtr TextureManager::findTexture(const std::string & theTextureId) const { dom::NodePtr myTextureNode = _myTextureList->getElementById(theTextureId); if (myTextureNode) { return myTextureNode->getFacade<Texture>(); } return TexturePtr(); }
Space::Space() { offset = 0; // Z of 1 means back as there is no perspective projection applied during render position.z = 1; // Initialize static resources if needed if (!shader) shader = ShaderPtr(new Shader{space_vert, space_frag}); if (!texture) texture = TexturePtr(new Texture{"stars.rgb", 512, 512}); if (!mesh) mesh = MeshPtr(new Mesh{shader, "quad.obj"}); }
void Text::build() { I18nShapeWidget::build(); AC_DEBUG << "build "<<*this << " caching: " << _myCacheFlag; AC_TRACE << "data: " << getText().substr(_myTextStartPos, getText().size()); mar::UnlitTexturedMaterialPtr myMaterial = boost::static_pointer_cast<mar::UnlitTexturedMaterial>(getShape()->elementList_[0]->material_); bool myCreateTextureFlag = true; unsigned int myKey = 0; if (_myCacheFlag) { myKey = masl::CRC32(getText().substr(_myTextStartPos, getText().size()) + as_string(_myFontSize) + _myFontPath + as_string(_myTextColor)); TexturePtr myTexturePtr = TextureLoader::get().getTexture(myKey); if (myTexturePtr) { _myTextSize[0] = myTexturePtr->_width; _myTextSize[1] = myTexturePtr->_height; _myRenderedGlyphIndex = TextGlyphIndexMap::get().getIndex(myKey); setSize(_myTextSize[0], _myTextSize[1]); myMaterial->getTextureUnit()->setTexture(myTexturePtr); myCreateTextureFlag = false; } } if (myCreateTextureFlag) { TexturePtr myTexture; if (!_myCacheFlag) { myTexture = myMaterial->getTextureUnit()->getTexture(); } else { myTexture = TexturePtr(new Texture()); } masl::TextInfo myTextInfo = masl::MobileSDK_Singleton::get() .getNative()->renderText(getText(), myTexture->_textureId, _myFontSize, _myTextColor, _myMaxWidth, _myMaxHeight, _myTextAlign, _myFontPath, _myLineHeight, _myTextStartPos, myTexture->_mirrorFlag); myMaterial->getTextureUnit()->setTexture(myTexture); _myTextSize[0] = myTextInfo.width; _myTextSize[1] = myTextInfo.height; _myRenderedGlyphIndex = myTextInfo.renderedGlyphIndex; setSize(_myTextSize[0], _myTextSize[1]); myTexture->_width = myTextInfo.width; myTexture->_height = myTextInfo.height; myTexture->_textureId = myTextInfo.textureID; myTexture->_transparency = true; if (_myCacheFlag) { TextGlyphIndexMap::get().store(myKey, _myRenderedGlyphIndex); TextureLoader::get().storeTexture(myKey, myTexture); } } }
void GraphicalApplication::resize(const Size& size) { m_onInputEvent = true; g_graphics.resize(size); g_ui.resize(size); m_onInputEvent = false; if(g_graphics.canCacheBackbuffer()) { m_foreground = TexturePtr(new Texture(size)); m_foreground->setUpsideDown(true); } m_mustRepaint = true; }
Projectile::Projectile() { // Initialize age to 0 age = 0; // Set default speed speed = glm::vec3(0.0f, 3.0f, 0.0f); rotMomentum = glm::vec3(0.0f, 0.0f, Rand(-PI/4.0f, PI/4.0f)); // Initialize static resources if needed if (!shader) shader = ShaderPtr(new Shader{object_vert, object_frag}); if (!texture) texture = TexturePtr(new Texture{"missile.rgb", 512, 512}); if (!mesh) mesh = MeshPtr(new Mesh{shader, "missile.obj"}); }
TexturePtr TexturesLoader::loadTexture(std::string path) { GLuint result = SOIL_load_OGL_texture( path.c_str(), SOIL_LOAD_AUTO, SOIL_CREATE_NEW_ID, SOIL_FLAG_MIPMAPS | SOIL_FLAG_INVERT_Y | SOIL_FLAG_NTSC_SAFE_RGB | SOIL_FLAG_COMPRESS_TO_DXT); if (result == 0) throw std::logic_error("Error while loading texture " + std::string(SOIL_last_result())); return TexturePtr(new Texture(result)); }
void MaskSubSkin::doRender(MyGUI::IRenderTarget* _target) { if (!mVisible) return; if (mRenderItem) { { RenderTargetImpl* target = static_cast<RenderTargetImpl*>(_target); MyGUI::Widget* widget_p = static_cast<MyGUI::Widget*>(mCroppedParent); MaskImageWidget* widget = widget_p->castType<MaskImageWidget>(false); ShaderPtr shader; Image fill_image; if (widget) { ImagePtr img = widget->getImage(); if (img && img->GetTexture()) { fill_image = *img; } shader = widget->getShader(); } if (!fill_image.GetTexture()) { MyGUI::ISubWidgetRect* main = widget_p->getSubWidgetMain(); if (main) { MaskSetSubSkin* sub = main->castType<MaskSetSubSkin>(false); if (sub) { get_sub_image(fill_image,sub); } } } if (!fill_image.GetTexture()) { Base::doRender(_target); return; } Graphics* g = target->graphics(); if (g) { g->SetShader(shader); setMask(*g, fill_image); Base::doRender(_target); g->SetMask(MASK_MODE_NONE, TexturePtr(), Transform2d()); g->SetShader(ShaderPtr()); // } else { sb_assert(false); } } } }
TextureHnd TextureManager::addTexture(std::string name, std::string uri, WindowHnd win, bool allowOverwrite){ if (allowOverwrite || !has(name)){ if (!hasByURI(uri)){ try{ TexturePtr t = TexturePtr(new Texture(uri, win)); mResources.insert(std::pair<std::string, TexturePtr>(name, t)); return TextureHnd(t); } catch (std::runtime_error e){ throw e; } } } return TextureHnd(); }
Asteroid::Asteroid() { // Reset the age to 0 age = 0; // Set random scale speed and rotation scale *= Rand(1.0f, 3.0f); speed = glm::vec3(Rand(-2.0f, 2.0f), Rand(-5.0f, -10.0f), 0.0f); rotation = glm::vec3(Rand(-PI, PI), Rand(-PI, PI), Rand(-PI, PI)); rotMomentum = glm::vec3(Rand(-PI, PI), Rand(-PI, PI), Rand(-PI, PI)); // Initialize static resources if needed if (!shader) shader = ShaderPtr(new Shader{object_vert, object_frag}); if (!texture) texture = TexturePtr(new Texture{"asteroid.rgb", 512, 512}); if (!mesh) mesh = MeshPtr(new Mesh{shader, "asteroid.obj"}); }
bool D3D11RenderTarget::Create(int count, int w, int h, G_FORMAT formats[], int miplvls) { if(count == 0) { return false; } m_pRTViews = new ID3D11RenderTargetView*[count]; for(int i = 0; i < count; ++i) { D3D11_TEXTURE2D_DESC td; ZeroMemory(&td, sizeof(td)); td.ArraySize = 1; td.BindFlags = D3D11_BIND_RENDER_TARGET | D3D11_BIND_SHADER_RESOURCE; td.CPUAccessFlags = 0; td.Format = D3D11Format::Convert(formats[i]); td.Height = h; td.MipLevels = miplvls; td.MiscFlags = 0; td.SampleDesc.Count = 1; td.SampleDesc.Quality = 0; td.Usage = D3D11_USAGE_DEFAULT; td.Width = w; ID3D11Texture2D* pD3D11Tex = NULL; if(FAILED(m_pDevice->CreateTexture2D(&td, NULL, &pD3D11Tex))) { return false; } D3D11Texture* pTex = new D3D11Texture(m_pContext); if(false == pTex->CreateFromRes(pD3D11Tex)) { pD3D11Tex->Release(); return false; } m_pTexures.push_back(TexturePtr(pTex)); if(FAILED(m_pDevice->CreateRenderTargetView( pD3D11Tex, NULL, &m_pRTViews[i]))) { return false; } } return true; }