本文整理汇总了C++中Texture::GetHeight方法的典型用法代码示例。如果您正苦于以下问题:C++ Texture::GetHeight方法的具体用法?C++ Texture::GetHeight怎么用?C++ Texture::GetHeight使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Texture
的用法示例。
在下文中一共展示了Texture::GetHeight方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CopyFrom
void GenericBuffer::CopyFrom(vk::CommandBuffer commandBuffer, Texture& srcTexture)
{
auto textureSize =
srcTexture.GetWidth() * srcTexture.GetHeight() * GetBytesPerPixel(srcTexture.GetFormat());
if (textureSize != mSize)
{
throw std::runtime_error("Cannot copy texture of different sizes");
}
srcTexture.Barrier(commandBuffer,
vk::ImageLayout::eGeneral,
vk::AccessFlagBits::eShaderWrite | vk::AccessFlagBits::eColorAttachmentWrite,
vk::ImageLayout::eTransferSrcOptimal,
vk::AccessFlagBits::eTransferRead);
auto info = vk::BufferImageCopy()
.setImageSubresource({vk::ImageAspectFlagBits::eColor, 0, 0, 1})
.setImageExtent({srcTexture.GetWidth(), srcTexture.GetHeight(), 1});
commandBuffer.copyImageToBuffer(
srcTexture.mImage, vk::ImageLayout::eTransferSrcOptimal, mBuffer, info);
srcTexture.Barrier(commandBuffer,
vk::ImageLayout::eTransferSrcOptimal,
vk::AccessFlagBits::eTransferRead,
vk::ImageLayout::eGeneral,
vk::AccessFlagBits::eShaderRead | vk::AccessFlagBits::eColorAttachmentRead);
Barrier(commandBuffer, vk::AccessFlagBits::eTransferWrite, vk::AccessFlagBits::eShaderRead);
}
示例2: sizeof
void GSDevice10::StretchRect(Texture& st, const GSVector4& sr, Texture& dt, const GSVector4& dr, ID3D10PixelShader* ps, ID3D10Buffer* ps_cb, ID3D10BlendState* bs, bool linear)
{
BeginScene();
// om
OMSetDepthStencilState(m_convert.dss, 0);
OMSetBlendState(bs, 0);
OMSetRenderTargets(dt, NULL);
// ia
float left = dr.x * 2 / dt.GetWidth() - 1.0f;
float top = 1.0f - dr.y * 2 / dt.GetHeight();
float right = dr.z * 2 / dt.GetWidth() - 1.0f;
float bottom = 1.0f - dr.w * 2 / dt.GetHeight();
GSVertexPT1 vertices[] =
{
{GSVector4(left, top, 0.5f, 1.0f), GSVector2(sr.x, sr.y)},
{GSVector4(right, top, 0.5f, 1.0f), GSVector2(sr.z, sr.y)},
{GSVector4(left, bottom, 0.5f, 1.0f), GSVector2(sr.x, sr.w)},
{GSVector4(right, bottom, 0.5f, 1.0f), GSVector2(sr.z, sr.w)},
};
D3D10_BOX box = {0, 0, 0, sizeof(vertices), 1, 1};
m_dev->UpdateSubresource(m_convert.vb, 0, &box, vertices, 0, 0);
IASetVertexBuffer(m_convert.vb, sizeof(vertices[0]));
IASetInputLayout(m_convert.il);
IASetPrimitiveTopology(D3D10_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP);
// vs
VSSetShader(m_convert.vs, NULL);
// gs
GSSetShader(NULL);
// ps
PSSetShader(ps, ps_cb);
PSSetSamplerState(linear ? m_convert.ln : m_convert.pt, NULL);
PSSetShaderResources(st, NULL);
// rs
RSSet(dt.GetWidth(), dt.GetHeight());
//
DrawPrimitive(countof(vertices));
//
EndScene();
}
示例3: sr
void GSDevice10::DoInterlace(Texture& st, Texture& dt, int shader, bool linear, float yoffset)
{
GSVector4 sr(0, 0, 1, 1);
GSVector4 dr(0.0f, yoffset, (float)dt.GetWidth(), (float)dt.GetHeight() + yoffset);
InterlaceConstantBuffer cb;
cb.ZrH = GSVector2(0, 1.0f / dt.GetHeight());
cb.hH = (float)dt.GetHeight() / 2;
m_dev->UpdateSubresource(m_interlace.cb, 0, NULL, &cb, 0, 0);
StretchRect(st, sr, dt, dr, m_interlace.ps[shader], m_interlace.cb, linear);
}
示例4: SetTexture
void Sprite::SetTexture(const Texture& texture, bool adjustToNewSize)
{
// If there was no valid texture before, force adjusting to the new texture size
if (!myTexture)
adjustToNewSize = true;
// If we want to adjust the size and the new texture is valid, we adjust the source rectangle
if (adjustToNewSize && (texture.GetWidth() > 0) && (texture.GetHeight() > 0))
{
SetSubRect(IntRect(0, 0, texture.GetWidth(), texture.GetHeight()));
}
// Assign the new texture
myTexture = &texture;
}
示例5: Load
void Terrain::Load()
{
std::cout << "Loading Terrain" << std::endl;
Texture* heightmap = new Texture();
heightmap->SetFile(sFilepath);
heightmap->Load();
iWidth = heightmap->GetWidth();
iLength = heightmap->GetHeight();
pHeights = new float*[iLength];
for(int i = 0; i < iLength; i++)
{
pHeights[i] = new float[iWidth];
}
vNormals = new glm::vec3*[iLength];
for(int i = 0; i < iLength; i++)
{
vNormals[i] = new glm::vec3[iWidth];
}
for(int y = 0; y < iLength; y++)
{
for(int x = 0; x < iWidth; x++)
{
unsigned char color = heightmap->GetData()[3 * (y * iWidth + x)];
float h = fScale * ((color / 255.0f) - 0.5f);
SetHeight(x, y, h);
}
}
delete heightmap;
ComputeNormals();
}
示例6: img
void ESSUB_LoadPNG (const std::string& aPath, Texture** aTexture)
{
assert(aTexture);
wchar_t buffer[1024];
MultiByteToWideChar(CP_UTF8, 0, aPath.c_str(), -1, buffer, 512);
Texture* output = 0;
Bitmap img(buffer, false);
if(img.GetWidth())
{
output = ESVideo::CreateTexture(img.GetWidth(), img.GetHeight(), true);
output->Clear(0);
BitmapData BMData;
BMData.Width = std::min(output->GetWidth(), img.GetWidth());
BMData.Height = std::min(output->GetHeight(), img.GetHeight());
BMData.Stride = output->GetWidth() * 4;
BMData.PixelFormat = PixelFormat32bppARGB;
BMData.Scan0 = output->Map();
BMData.Reserved = 0;
Rect area(0, 0, img.GetWidth(), img.GetHeight());
img.LockBits(&area, ImageLockModeRead | ImageLockModeUserInputBuf, PixelFormat32bppARGB, &BMData);
img.UnlockBits(&BMData);
output->Unmap();
}
*aTexture = output;
}
示例7: RestoreState
void LandscapeEditorCustomColors::RestoreState(DAVA::Image *image)
{
Texture* texture = Texture::CreateTextFromData(image->GetPixelFormat(), image->GetData(), image->GetWidth(), image->GetHeight(), false);
Sprite* sprite = Sprite::CreateFromTexture(texture, 0, 0, texture->GetWidth(), texture->GetHeight());
uint32 width = 0;
uint32 height = 0;
if (colorSprite)
{
width = colorSprite->GetWidth();
height = colorSprite->GetHeight();
}
else
{
width = texSurf->GetWidth();
height = texSurf->GetHeight();
}
SafeRelease(colorSprite);
colorSprite = Sprite::CreateAsRenderTarget(width, height, FORMAT_RGBA8888);
RenderManager::Instance()->SetRenderTarget(colorSprite);
sprite->Draw();
RenderManager::Instance()->RestoreRenderTarget();
SafeRelease(sprite);
SafeRelease(texture);
if (IsActive())
PerformLandscapeDraw();
unsavedChanges = true;
}
示例8:
Texture* GetTexture ()
{
Texture* output = 0;
if(Valid)
{
output = ESVideo::CreateTexture(Width, Height, true);
output->Clear(0);
uint32_t copyWidth = std::min(Width, output->GetWidth());
uint32_t copyHeight = std::min(Height, output->GetHeight());
uint32_t* texPixels = output->Map();
for(int i = 0; i != copyHeight; i ++)
{
uint32_t* dest = texPixels + (output->GetPitch() * i);
uint8_t* source = RowPointers[i];
for(int j = 0; j != copyWidth; j ++)
{
uint32_t a = (InfoPtr->color_type == PNG_COLOR_TYPE_RGB_ALPHA) ? *source++ : 0xFF;
uint32_t r = *source ++;
uint32_t g = *source ++;
uint32_t b = *source ++;
*dest++ = output->ConvertPixel(r, g, b, a);
}
}
output->Unmap();
}
return output;
}
示例9: LoadTexture
bool CustomColorsSystem::LoadTexture( const DAVA::FilePath &filePath, bool createUndo /* = true */ )
{
if(filePath.IsEmpty())
return false;
Vector<Image*> images;
ImageSystem::Instance()->Load(filePath, images);
if(images.empty())
return false;
Image* image = images.front();
if(image)
{
Texture* texture = Texture::CreateFromData(image->GetPixelFormat(),
image->GetData(),
image->GetWidth(),
image->GetHeight(),
false);
Sprite* sprite = Sprite::CreateFromTexture(texture, 0, 0, texture->GetWidth(), texture->GetHeight());
if (createUndo)
{
StoreOriginalState();
}
RenderManager::Instance()->SetRenderTarget(drawSystem->GetCustomColorsProxy()->GetSprite());
Sprite::DrawState drawState;
sprite->Draw(&drawState);
RenderManager::Instance()->RestoreRenderTarget();
AddRectToAccumulator(Rect(Vector2(0.f, 0.f), Vector2(texture->GetWidth(), texture->GetHeight())));
SafeRelease(sprite);
SafeRelease(texture);
for_each(images.begin(), images.end(), SafeRelease<Image>);
if (createUndo)
{
((SceneEditor2*)GetScene())->BeginBatch("Load custom colors texture");
StoreSaveFileName(filePath);
CreateUndoPoint();
((SceneEditor2*)GetScene())->EndBatch();
}
}
return true;
}
示例10: DrawTexture
void Graphics::DrawTexture(const Rect& screenCoords, int textureId, float xOffset, float yOffset)
{
Texture* texture = ResourceManager::GetInstance().GetTexture(textureId);
if (!texture)
return;
Rect textureCoords;
textureCoords.left = 0.0f;
textureCoords.top = 0.0f;
textureCoords.right = texture->GetWidth();
textureCoords.bottom = texture->GetHeight();
DrawTexture(screenCoords, textureId, textureCoords, xOffset, yOffset);
}
示例11: Draw
void SpriteBatch::Draw(int tex_id, RectInt* rect, VecInt* pos, unsigned char alpha/* = 0xff*/, float scl /* = 1.0f */, float rot /* = 0.0f */)
{
if (sm_state != BEGAN) return;
Texture* tex = TextureManager::GetTexture(tex_id);
if (tex == NULL) return;
RECT tex_rect;
RECT* ptex_rect = &tex_rect;
if (rect)
SetRect(ptex_rect, rect->left, rect->top, rect->left + rect->width, rect->top + rect->height);
else
SetRect(ptex_rect, 0, 0, tex->GetWidth(), tex->GetHeight());
D3DXVECTOR3 v3pos;
v3pos.x = (pos == NULL) ? 0.0f : (float)(pos->x);
v3pos.y = (pos == NULL) ? 0.0f : (float)(pos->y);
v3pos.z = 0.0f;
DWORD color = alpha << 24;
color += 0x00ffffff;
g_pSprite->Draw(tex->GetD3DTexture(), ptex_rect, NULL, &v3pos, color);
}
示例12: ComTexture
// the operator
ComTexture Texture::operator * ( const Texture& tex ) const
{
if( tex.GetWidth() != m_iTexWidth || tex.GetHeight() != m_iTexHeight )
LOG_ERROR<<"Size of the images are not the same , can't multiply."<<CRASH;
if( m_iTexWidth == 0 || m_iTexHeight == 0 )
LOG_ERROR<<"One dimension of the image is zero , can't multiply."<<CRASH;
//allocate the data
Spectrum* data = new Spectrum[ m_iTexWidth * m_iTexHeight ];
for( unsigned i = 0 ; i < m_iTexHeight; i++ )
for( unsigned j = 0 ; j < m_iTexWidth ; j++ )
{
unsigned offset = i * m_iTexWidth + j;
data[offset] = tex.GetColor( (int)j , (int)i ) * GetColor( (int)j , (int)i );
}
return ComTexture( data , m_iTexWidth , m_iTexHeight );
}
示例13: LoadTextureAction
void LandscapeEditorCustomColors::LoadTextureAction(const FilePath &pathToFile)
{
if(pathToFile.IsEmpty())
return;
Vector<Image*> images = ImageLoader::CreateFromFile(pathToFile);
if(images.empty())
return;
Image* image = images.front();
if(image)
{
Texture* texture = Texture::CreateFromData(image->GetPixelFormat(),
image->GetData(),
image->GetWidth(),
image->GetHeight(),
false);
SafeRelease(colorSprite);
colorSprite = Sprite::CreateAsRenderTarget(texSurf->GetWidth(), texSurf->GetHeight(), FORMAT_RGBA8888);
Sprite* sprite = Sprite::CreateFromTexture(texture, 0, 0, texture->GetWidth(), texture->GetHeight());
StoreOriginalState();
RenderManager::Instance()->SetRenderTarget(colorSprite);
sprite->Draw();
RenderManager::Instance()->RestoreRenderTarget();
PerformLandscapeDraw();
SafeRelease(sprite);
SafeRelease(texture);
for_each(images.begin(), images.end(), SafeRelease<Image>);
StoreSaveFileName(pathToFile);
CreateUndoPoint();
}
}
示例14: ApplyImageToTexture
Sprite* ModifyTilemaskCommand::ApplyImageToTexture(DAVA::Image *image, DAVA::Texture *texture)
{
int32 width = texture->GetWidth();
int32 height = texture->GetHeight();
Sprite* resSprite = Sprite::CreateAsRenderTarget((float32)width, (float32)height, FORMAT_RGBA8888);
RenderManager::Instance()->SetRenderTarget(resSprite);
RenderManager::Instance()->ClearWithColor(0.f, 0.f, 0.f, 0.f);
eBlendMode srcBlend = RenderManager::Instance()->GetSrcBlend();
eBlendMode dstBlend = RenderManager::Instance()->GetDestBlend();
RenderManager::Instance()->SetBlendMode(BLEND_ONE, BLEND_ZERO);
Sprite* s = Sprite::CreateFromTexture(texture, 0, 0, (float32)width, (float32)height);
s->SetPosition(0.f, 0.f);
s->Draw();
SafeRelease(s);
RenderManager::Instance()->ClipPush();
RenderManager::Instance()->SetClip(updatedRect);
RenderManager::Instance()->ClearWithColor(0.f, 0.f, 0.f, 0.f);
Texture* t = Texture::CreateFromData(image->GetPixelFormat(), image->GetData(),
image->GetWidth(), image->GetHeight(), false);
s = Sprite::CreateFromTexture(t, 0, 0, (float32)t->GetWidth(), (float32)t->GetHeight());
s->SetPosition(updatedRect.x, updatedRect.y);
s->Draw();
SafeRelease(s);
SafeRelease(t);
RenderManager::Instance()->ClipPop();
RenderManager::Instance()->SetBlendMode(srcBlend, dstBlend);
RenderManager::Instance()->ResetColor();
RenderManager::Instance()->RestoreRenderTarget();
return resSprite;
}
示例15:
void gfx::GraphicsEngine::RenderActiveTarget(){
glViewport((GLint)(m_Width * 0.5f), BUTTON_SIZE, (GLint)(m_Width * 0.5f), m_Height - BUTTON_SIZE * 2);
glDisable(GL_DEPTH_TEST);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
ShaderProgram* spriteProg = g_ShaderBank.GetProgramFromHandle(m_SpriteShader);
spriteProg->Apply();
glBindVertexArray(0);
Texture* tex = g_MaterialBank.GetTexture(m_FrameBuffer.GetTexture());
float sizeH;
sizeH = tex->GetHeight() / tex->GetWidth();
tex->Apply(spriteProg->FetchUniform("g_Texture"), 0);
spriteProg->SetUniformVec4("g_Color", glm::vec4(1));
spriteProg->SetUniformVec4("g_Pos", glm::vec4(0.0f, 0.5f + sizeH * 0.5f, 0.0f,0.0f));
spriteProg->SetUniformVec4("g_Size", glm::vec4(1.0f, sizeH, 1.0f, 1.0f));
if (tex->GetChannels() == 1){
spriteProg->SetUniformBool("g_GreyScale", true);
}
else{
spriteProg->SetUniformBool("g_GreyScale", false);
}
glDrawArrays(GL_POINTS, 0, 1);
}