本文整理汇总了C++中TexturePtr类的典型用法代码示例。如果您正苦于以下问题:C++ TexturePtr类的具体用法?C++ TexturePtr怎么用?C++ TexturePtr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TexturePtr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetCurrentTargetSize
bool GLES2Video::BeginTargetScene(const Color& dwBGColor, const bool clear)
{
// explicit static cast for better performance
TexturePtr texturePtr = m_currentTarget.lock();
if (texturePtr)
{
Texture *pTexture = texturePtr.get(); // safety compile-time error checking
GLES2Texture *pGLES2Texture = static_cast<GLES2Texture*>(pTexture); // safer direct cast
const GLuint target = pGLES2Texture->GetFrameBufferID();
glBindFramebuffer(GL_FRAMEBUFFER, target);
CheckFrameBufferStatus(m_logger, target, pGLES2Texture->GetTextureID(), false);
if (clear)
{
Vector4 color;
color.SetColor(dwBGColor);
glClearColor(color.x, color.y, color.z, color.w);
glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
}
const Texture::PROFILE& profile = pGLES2Texture->GetProfile();
Enable2D(static_cast<int>(profile.width), static_cast<int>(profile.height), true);
m_shaderContext->ResetViewConstants(m_orthoMatrix, GetCurrentTargetSize());
}
else
{
Message(GS_L("There's no render target"), GSMT_ERROR);
}
m_rendering = true;
return true;
}
示例2: scaleBias
void Material::bindShaderData() {
m_gpuProgram->bind();
m_gpuProgram->setUniform(ShaderConstants::UNIFORM_MaterialAmbient, m_ambient);
m_gpuProgram->setUniform(ShaderConstants::UNIFORM_MaterialDiffuse, m_diffuse);
m_gpuProgram->setUniform(ShaderConstants::UNIFORM_MaterialSpecular, m_specular);
m_gpuProgram->setUniform(ShaderConstants::UNIFORM_MaterialShininess, m_shininess);
// pack the parallax scale and bias in a single 2d vector
Vec2f scaleBias(m_parallaxScale, m_parallaxBias);
m_gpuProgram->setUniform(ShaderConstants::UNIFORM_MaterialParallaxScaleBias, scaleBias);
if (m_transparent) {
m_gpuProgram->setUniform(ShaderConstants::UNIFORM_MaterialOpacity, m_opacity);
} else {
float opacity = 1.0f;
m_gpuProgram->setUniform(ShaderConstants::UNIFORM_MaterialOpacity, opacity);
}
uint numTextures = this->getActiveTextures();
for (uint i = 0; i < numTextures; i++) {
TexturePtr tex = m_texStack->textures[i];
// std::cout << "binding texture " << tex->m_filename << " to unit " << (int)i << "\n";
glActiveTexture(GL_TEXTURE0 + i);
glClientActiveTexture(GL_TEXTURE0 + i);
tex->bind();
m_gpuProgram->setUniform(ShaderConstants::UNIFORM_Samplers[i], i);
m_gpuProgram->setUniform(ShaderConstants::UNIFORM_TexEnvColors[i], tex->getEnvColour());
}
m_gpuProgram->setUniform(ShaderConstants::UNIFORM_NumTextures, numTextures);
}
示例3: ResourceBuffer
bool SurveyMapTextureCreator::init()
{
TexturePtr texture = TextureManager::getSingleton().createManual(getTextureName(), ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, TEX_TYPE_2D, 2048, 2048, TU_RENDERTARGET, PF_R8G8B8, TU_RENDERTARGET, new ResourceBuffer());
if ( texture.isNull() ) return false;;
mRttTex = texture->getBuffer()->getRenderTarget();
if ( !mRttTex ) return false;
mRttTex->setAutoUpdated(false);
mCamera = gEnv->sceneManager->createCamera(getCameraName());
mViewport = mRttTex->addViewport(mCamera);
mViewport->setBackgroundColour(ColourValue::Black);
mViewport->setOverlaysEnabled(false);
mViewport->setShadowsEnabled(false);
mViewport->setSkiesEnabled(false);
mMaterial = MaterialManager::getSingleton().create(getMaterialName(), ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
if ( mMaterial.isNull() ) return false;
mTextureUnitState = mMaterial->getTechnique(0)->getPass(0)->createTextureUnitState(getTextureName());
mRttTex->addListener(this);
mCamera->setFixedYawAxis(false);
mCamera->setProjectionType(PT_ORTHOGRAPHIC);
mCamera->setNearClipDistance(1.0f);
return true;
}
示例4: hash
TexturePtr NullHWBufferManager::LoadTexture(const String & filename, float priority, int mipmaps, eUsage usage)
{
Hash2 hash(filename.c_str());
TexturePtr p = _find(hash, filename);
if (p == NULL)
{
NullTexture * pTexture = new NullTexture(filename, filename);
pTexture->mWidth = 0;
pTexture->mHeight = 0;
pTexture->mMipmaps = 1;
pTexture->mUsage = usage;
pTexture->mFormat = ePixelFormat::UNKNOWN;
pTexture->mPriority = priority;
p = pTexture;
mTextureMap.Insert(hash, p.c_ptr());
}
if (priority < 0)
{
p->EnsureLoad();
}
else
{
p->Load();
}
return p;
}
示例5: DepthTexture
void SDSMCascadedShadowLayer::DepthTexture(TexturePtr const & depth_tex)
{
depth_tex_ = depth_tex;
if (!cs_support_)
{
RenderFactory& rf = Context::Instance().RenderFactoryInstance();
uint32_t const width = depth_tex->Width(0);
uint32_t const height = depth_tex->Height(0);
depth_deriative_tex_ = rf.MakeTexture2D(width / 2, height / 2, 0, 1, EF_GR16F, 1, 0, EAH_GPU_Read | EAH_GPU_Write, nullptr);
depth_deriative_small_tex_ = rf.MakeTexture2D(width / 4, height / 4, 0, 1, EF_GR16F, 1, 0, EAH_GPU_Write, nullptr);
float delta_x = 1.0f / depth_tex_->Width(0);
float delta_y = 1.0f / depth_tex_->Height(0);
reduce_z_bounds_from_depth_pp_->SetParam(0, float4(delta_x, delta_y, -delta_x / 2, -delta_y / 2));
reduce_z_bounds_from_depth_pp_->InputPin(0, depth_tex_);
reduce_z_bounds_from_depth_pp_->OutputPin(0, depth_deriative_tex_);
reduce_z_bounds_from_depth_mip_map_pp_->InputPin(0, depth_deriative_tex_);
compute_log_cascades_from_z_bounds_pp_->SetParam(0, static_cast<float>(depth_deriative_tex_->NumMipMaps() - 1));
compute_log_cascades_from_z_bounds_pp_->InputPin(0, depth_deriative_tex_);
compute_log_cascades_from_z_bounds_pp_->OutputPin(0, interval_tex_);
}
}
示例6: generateRandomVelocityTexture
TexturePtr RandomTools::generateRandomVelocityTexture()
{
// PPP: Temp workaround for DX 11 which does not seem to like usage dynamic
// TextureUsage usage = (Root::getSingletonPtr()->getRenderSystem()->getName()=="Direct3D11 Rendering Subsystem") ?
// TU_DEFAULT : TU_DYNAMIC;
TexturePtr texPtr = TextureManager::getSingleton().createManual(
"RandomVelocityTexture",
// ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
"General",
TEX_TYPE_1D,
1024, 1, 1,
0,
PF_FLOAT32_RGBA);//,
//usage);
HardwarePixelBufferSharedPtr pixelBuf = texPtr->getBuffer();
// Lock the buffer so we can write to it.
pixelBuf->lock(HardwareBuffer::HBL_DISCARD);
const PixelBox &pb = pixelBuf->getCurrentLock();
float *randomData = static_cast<float*>(pb.data);
// float randomData[NUM_RAND_VALUES * 4];
for(int i = 0; i < NUM_RAND_VALUES * 4; i++)
{
randomData[i] = float( (rand() % 10000) - 5000 );
}
// PixelBox pixelBox(1024, 1, 1, PF_FLOAT32_RGBA, &randomData[0]);
// pixelBuf->blitFromMemory(pixelBox);
pixelBuf->unlock();
return texPtr;
}
示例7: mSceneMgr
HeatHaze::HeatHaze(SceneManager *sceneMgr, RenderWindow *mWindow, Ogre::Camera *cam) : mSceneMgr(sceneMgr), rttTex(0), listener(0)
{
TexturePtr rttTexPtr = TextureManager::getSingleton().createManual("heathaze_rtt", ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, TEX_TYPE_2D, cam->getViewport()->getWidth(), cam->getViewport()->getHeight(), 0, PF_R8G8B8, TU_RENDERTARGET, new ResourceBuffer());
rttTex = rttTexPtr->getBuffer()->getRenderTarget();
{
/*
// we use the main camera now
mHazeCam = mSceneMgr->createCamera("Hazecam");
mHazeCam->setNearClipDistance(1.0);
mHazeCam->setFarClipDistance(1000.0);
mHazeCam->setPosition(Vector3(0, 0, 0));
*/
//mHazeCam->setAspectRatio(2.0);
// setup viewport
Viewport *v = rttTex->addViewport(cam);
//v->setClearEveryFrame(true);
//v->setBackgroundColour(ColourValue::Black);
v->setOverlaysEnabled(false);
// setup projected material
MaterialPtr mat = MaterialManager::getSingleton().getByName("tracks/HeatHazeMat");
tex = mat->getTechnique(0)->getPass(0)->getTextureUnitState(1);
tex->setTextureName("heathaze_rtt");
tex->setProjectiveTexturing(true, cam);
listener = new HeatHazeListener(mSceneMgr);
rttTex->addListener(listener);
rttTex->setAutoUpdated(false);
}
}
示例8: CPepeEngineEntity
// -----------------------------------------------------------------------------------------
void CDemoGlassApplication::createScene()
{
m_pSceneManager->createSkyBox(_T("snow.jpg"), 500);
CPepeEngineEntity* pVase = new CPepeEngineEntity(_T("Vase"), _T("Teapot.3ds"));
CPepeEngineSceneNode* pRootNode = m_pSceneManager->getRootSceneNode();
pRootNode->attachObject(pVase);
pRootNode->setPosition(0.0f, 0.0f, -15.0f);
pRootNode->setScale(0.1f, 0.1f, 0.1f);
pVase->setVertexShader(_T("glass.vs"));
pVase->setPixelShader(_T("glass.ps"));
pVase->setCullingMode(CULL_CLOCKWISE);
GPUProgramPtr pVasePS = IPepeEngineGPUProgramManager::getSingleton().getByName(_T("glass.ps"));
TexturePtr pRainbowTexture = IPepeEngineTextureManager::getSingleton().create(_T("Rainbow.tga"));
pRainbowTexture->load();
pVasePS->getParameters()->bindTexture(_T("Rainbow"), pRainbowTexture);
pVasePS->getParameters()->setNamedConstant(_T("indexOfRefractionRatio"), 1.14f);
pVasePS->getParameters()->setNamedConstant(_T("rainbowSpread"), 0.18f);
pVasePS->getParameters()->setNamedConstant(_T("rainbowScale"), 0.2f);
pVasePS->getParameters()->setNamedConstant(_T("reflectionScale"), 1.0f);
pVasePS->getParameters()->setNamedConstant(_T("refractionScale"), 1.0f);
pVasePS->getParameters()->setNamedConstant(_T("ambient"), 0.2f);
pVasePS->getParameters()->setNamedConstant(_T("baseColor"), CPepeEngineVector4(0.78f, 0.78f, 0.78f, 1.0f));
}
示例9: assert
void D3D9VideoBufferManager::BitBlt(TexturePtr texDest, ImagePtr imageSrc, const Rect * pDest, const Rect * pSrc)
{
IDirect3DTexture9 * pD3DDestTexture = NULL;
IDirect3DTexture9 * pD3DSrcTexture = NULL;
if (texDest->GetTextureType() == TEXTYPE_2D)
{
pD3DDestTexture = static_cast<D3D9Texture*>(texDest.c_ptr())->mD3D9Texture;
}
D3D9Image * img = (D3D9Image*)imageSrc.c_ptr();
pD3DSrcTexture = img->_MyTexture();
assert(pD3DDestTexture && pD3DSrcTexture);
IDirect3DSurface9 * pDestSurface;
IDirect3DSurface9 * pSrcSurface;
const RECT * pDestRect = reinterpret_cast<const RECT *>(pDest);
const RECT * pSrcRect = reinterpret_cast<const RECT *>(pSrc);
pD3DDestTexture->GetSurfaceLevel(0, &pDestSurface);
pD3DSrcTexture->GetSurfaceLevel(0, &pSrcSurface);
D3DXLoadSurfaceFromSurface(pDestSurface,
NULL,
pDestRect,
pSrcSurface,
NULL,
pSrcRect,
D3DX_DEFAULT,
0);
}
示例10: CreateTextureFromBitmap
CPixelBufferView::TexturePtr CPixelBufferView::CreateTextureFromBitmap(const Framework::CBitmap& bitmap)
{
TexturePtr texture;
if(!bitmap.IsEmpty())
{
HRESULT result = S_OK;
result = m_device->CreateTexture(bitmap.GetWidth(), bitmap.GetHeight(), 1, D3DUSAGE_DYNAMIC, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &texture, nullptr);
assert(SUCCEEDED(result));
D3DLOCKED_RECT lockedRect = {};
result = texture->LockRect(0, &lockedRect, nullptr, 0);
assert(SUCCEEDED(result));
uint32* dstPtr = reinterpret_cast<uint32*>(lockedRect.pBits);
uint32* srcPtr = reinterpret_cast<uint32*>(bitmap.GetPixels());
for(unsigned int y = 0; y < bitmap.GetHeight(); y++)
{
memcpy(dstPtr, srcPtr, bitmap.GetWidth() * sizeof(uint32));
dstPtr += lockedRect.Pitch / sizeof(uint32);
srcPtr += bitmap.GetPitch() / sizeof(uint32);
}
result = texture->UnlockRect(0);
assert(SUCCEEDED(result));
}
return texture;
}
示例11: RenderTargetPtr
RenderTargetPtr D3D9VideoBufferManager::CreateRenderTarget(TexturePtr rtTex)
{
int rWidth = rtTex->GetWidth(), rHeight = rtTex->GetHeight();
if (rWidth == -1 || rHeight == -1)
{
rWidth = Engine::Instance()->GetDeviceProperty()->Width;
rHeight = Engine::Instance()->GetDeviceProperty()->Height;
}
IDirect3DSurface9 * pD3D9RenderTarget = NULL;
D3D9RenderTarget * pTexture = new D3D9RenderTarget(mD3D9Device);
pTexture->mName = rtTex->GetName();
pTexture->mWidth = rWidth;
pTexture->mHeight = rHeight;
pTexture->mFormat = rtTex->GetFormat();
pTexture->mMSAA = MSAA_NONE;
pTexture->mTexture = rtTex;
D3D9Texture * d3dTex = (D3D9Texture *)rtTex.c_ptr();
d3dTex->GetD3DTexture()->GetSurfaceLevel(0, &pTexture->mRenderTarget);
mRenderTargets.Insert(pTexture->GetName(), pTexture);
return RenderTargetPtr(pTexture);
}
示例12: NxScreen
NxScreen * NxScreenManager::CreateExternalWindow( int MonitorID, bool FullScreen, unsigned int Width, unsigned int Height )
{
//Viewport * mainviewport = NxEngine::getSingleton().GetNxViewport();
//Log("Enabling Output Compositor...");
//Ogre::CompositorManager::getSingleton().setCompositorEnabled( mainviewport , "NxCompositorOutput" , true );
//Log("Enabling Output Compositor:Done");
static bool Initialized = false;
if( !Initialized )
{
TexturePtr tester = TextureManager::getSingleton().createManual( "RTT_Texture_100",
ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, Ogre::TEX_TYPE_2D,
32, 32, 0, Ogre::PF_BYTE_BGR, TU_RENDERTARGET );
mRenderTexture = tester->getBuffer(0,0)->getRenderTarget();
mRenderTexture->setAutoUpdated( false );
//Ogre::Viewport * NxViewport = mRenderTexture->addViewport( NxEngine::getSingleton().GetNxCamera() ); // view from main scene
Ogre::Viewport * NxViewport = mRenderTexture->addViewport( NxEngine::getSingleton().GetNxWindow()->GetViewport(0)->GetViewport()->getCamera( ) );
Initialized = true;
}
NxScreen * Output = new NxScreen( MonitorID, FullScreen, Width, Height );
MonitorListActive.push_back( Output );
return Output ;
}
示例13: mDashCam
Dashboard::Dashboard() :
mDashCam(0)
, mDashboardListener(0)
, rttTex(0)
{
TexturePtr rttTexPtr = TextureManager::getSingleton().createManual("dashtexture", ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, TEX_TYPE_2D, 1024, 512, 0, PF_R8G8B8, TU_RENDERTARGET, new ResourceBuffer());
rttTex = rttTexPtr->getBuffer()->getRenderTarget();
mDashCam = gEnv->sceneManager->createCamera("DashCam");
mDashCam->setNearClipDistance(1.0);
mDashCam->setFarClipDistance(10.0);
mDashCam->setPosition(Vector3(0.0, -10000.0, 0.0));
mDashCam->setAspectRatio(2.0);
Viewport *v = rttTex->addViewport(mDashCam);
v->setClearEveryFrame(true);
v->setBackgroundColour(ColourValue::Black);
//v->setOverlaysEnabled(false);
MaterialPtr mat = MaterialManager::getSingleton().getByName("renderdash");
mat->getTechnique(0)->getPass(0)->getTextureUnitState(0)->setTextureName("dashtexture");
mDashboardListener = new DashboardListener();
rttTex->addListener(mDashboardListener);
mDashboardListener->dashOverlay = OverlayManager::getSingleton().getByName("tracks/3D_DashboardOverlay");
mDashboardListener->needlesOverlay = OverlayManager::getSingleton().getByName("tracks/3D_NeedlesOverlay");
mDashboardListener->blendOverlay = OverlayManager::getSingleton().getByName("tracks/3D_BlendOverlay");
mDashboardListener->truckHUDOverlay = OverlayManager::getSingleton().getByName("tracks/TruckInfoBox");
// mDashboardListener->dbdebugOverlay = OverlayManager::getSingleton().getByName("Core/DebugOverlay");
// mDashboardListener->dbeditorOverlay = OverlayManager::getSingleton().getByName("tracks/EditorOverlay");
}
示例14: saveTexture
void TextureToolWindow::saveTexture(String texName, bool usePNG)
{
try
{
TexturePtr tex = TextureManager::getSingleton().getByName(texName);
if (tex.isNull())
return;
Image img;
tex->convertToImage(img);
// Save to disk!
String outname = std::string(App::sys_user_dir.GetActive()) + RoR::PATH_SLASH + texName;
if (usePNG)
outname += ".png";
img.save(outname);
UTFString msg = _L("saved texture as ") + outname;
RoR::App::GetConsole()->putMessage(Console::CONSOLE_MSGTYPE_INFO, Console::CONSOLE_MSGTYPE_INFO, msg, "information.png");
}
catch (Exception& e)
{
UTFString str = "Exception while saving image: " + e.getFullDescription();
RoR::App::GetConsole()->putMessage(Console::CONSOLE_MSGTYPE_INFO, Console::CONSOLE_MSGTYPE_INFO, str, "error.png");
}
}
示例15: ImagePtr
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;
}