本文整理汇总了C++中ITexture::GetAtlasWidthInPixel方法的典型用法代码示例。如果您正苦于以下问题:C++ ITexture::GetAtlasWidthInPixel方法的具体用法?C++ ITexture::GetAtlasWidthInPixel怎么用?C++ ITexture::GetAtlasWidthInPixel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ITexture
的用法示例。
在下文中一共展示了ITexture::GetAtlasWidthInPixel方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
INLINE void OGL14RendererDevice::TextureRequestProcess() const
{
for (u32 i = 0; i < arTexture.Size(); i++)
{
GLuint **texId = (GLuint **)arTextureName[i];
ITexture *texture = arTexture[i];
if (!(*texId))
{
GLint tex = 0;
glGenTextures(1, (GLuint *)&tex);
glBindTexture(GL_TEXTURE_2D, (GLuint)tex);
/*
eTextureFilter min = texture->GetFilter(Seed::TextureFilterTypeMin);
eTextureFilter mag = texture->GetFilter(Seed::TextureFilterTypeMag);
if (min == Seed::TextureFilterLinear)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
else if (min == Seed::TextureFilterNearest)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
if (mag == Seed::TextureFilterLinear)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
else if (mag == Seed::TextureFilterNearest)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
*/
GLuint w = texture->GetAtlasWidthInPixel();
GLuint h = texture->GetAtlasHeightInPixel();
const void *data = texture->GetData();
// if data == NULL then this can be a dynamic texture. we need just the texture id.
if (data)
{
switch (texture->GetBytesPerPixel())
{
case 4:
// OpenGL 1.2+ only GL_EXT_bgra
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_BGRA, GL_UNSIGNED_BYTE, data);
break;
case 3:
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, w, h, 0, GL_RGB, GL_UNSIGNED_BYTE, data);
break;
case 2:
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, w, h, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, data);
break;
case 1:
glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, w, h, 0, GL_ALPHA, GL_UNSIGNED_BYTE, data);
break;
default:
break;
}
}
//glBindTexture(GL_TEXTURE_2D, 0);
*texId = (GLuint *)tex;
texture->Close(); // free ram
}
}
arTexture.Truncate();
arTextureName.Truncate();
}
示例2: if
INLINE void OGLES1RendererDevice::TextureRequestProcess() const
{
for (u32 i = 0; i < arTexture.Size(); i++)
{
ITexture *texture = arTexture[i];
if (texture)
{
GLint tex = 0;
glGenTextures(1, (GLuint *)&tex);
glBindTexture(GL_TEXTURE_2D, (GLuint)tex);
eTextureFilter min = texture->GetFilter(Seed::TextureFilterTypeMin);
eTextureFilter mag = texture->GetFilter(Seed::TextureFilterTypeMag);
if (min == Seed::TextureFilterLinear)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
else if (min == Seed::TextureFilterNearest)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
if (mag == Seed::TextureFilterLinear)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
else if (mag == Seed::TextureFilterNearest)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
const void *data = texture->GetData();
// if data == NULL then this can be a dynamic texture. we need just the texture id.
if (data)
{
GLuint w = texture->GetAtlasWidthInPixel();
GLuint h = texture->GetAtlasHeightInPixel();
//BOOL compressed = texture->IsCompressed();
u32 bpp = texture->GetBytesPerPixel();
/*if (compressed)
{
GLuint bpp = 2;
GLsizei size = w * h * bpp / 8;
if (size < 32)
{
size = 32;
}
glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG, w, h, 0, size, data);
}
else*/
{
switch (bpp)
{
case 4:
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, data);
break;
case 3:
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, w, h, 0, GL_RGB, GL_UNSIGNED_BYTE, data);
break;
case 2:
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, w, h, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, data);
break;
case 1:
glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, w, h, 0, GL_ALPHA, GL_UNSIGNED_BYTE, data);
break;
default:
break;
}
}
}
//glBindTexture(GL_TEXTURE_2D, 0);
texture->iTextureId = tex;
texture->Close(); // free ram
}
}
arTexture.Truncate();
}