mirror of
https://github.com/bkaradzic/bgfx.git
synced 2026-02-20 05:43:12 +01:00
texturev: Added image orientation.
This commit is contained in:
@@ -155,7 +155,7 @@ static void imageReleaseCb(void* _ptr, void* _userData)
|
||||
bimg::imageFree(imageContainer);
|
||||
}
|
||||
|
||||
bgfx::TextureHandle loadTexture(bx::FileReaderI* _reader, const char* _filePath, uint32_t _flags, uint8_t _skip, bgfx::TextureInfo* _info)
|
||||
bgfx::TextureHandle loadTexture(bx::FileReaderI* _reader, const char* _filePath, uint32_t _flags, uint8_t _skip, bgfx::TextureInfo* _info, bimg::Orientation::Enum* _orientation)
|
||||
{
|
||||
BX_UNUSED(_skip);
|
||||
bgfx::TextureHandle handle = BGFX_INVALID_HANDLE;
|
||||
@@ -168,6 +168,11 @@ bgfx::TextureHandle loadTexture(bx::FileReaderI* _reader, const char* _filePath,
|
||||
|
||||
if (NULL != imageContainer)
|
||||
{
|
||||
if (NULL != _orientation)
|
||||
{
|
||||
*_orientation = imageContainer->m_orientation;
|
||||
}
|
||||
|
||||
const bgfx::Memory* mem = bgfx::makeRef(
|
||||
imageContainer->m_data
|
||||
, imageContainer->m_size
|
||||
@@ -231,9 +236,9 @@ bgfx::TextureHandle loadTexture(bx::FileReaderI* _reader, const char* _filePath,
|
||||
return handle;
|
||||
}
|
||||
|
||||
bgfx::TextureHandle loadTexture(const char* _name, uint32_t _flags, uint8_t _skip, bgfx::TextureInfo* _info)
|
||||
bgfx::TextureHandle loadTexture(const char* _name, uint32_t _flags, uint8_t _skip, bgfx::TextureInfo* _info, bimg::Orientation::Enum* _orientation)
|
||||
{
|
||||
return loadTexture(entry::getFileReader(), _name, _flags, _skip, _info);
|
||||
return loadTexture(entry::getFileReader(), _name, _flags, _skip, _info, _orientation);
|
||||
}
|
||||
|
||||
bimg::ImageContainer* imageLoad(const char* _filePath, bgfx::TextureFormat::Enum _dstFormat)
|
||||
|
||||
@@ -23,7 +23,7 @@ bgfx::ShaderHandle loadShader(const char* _name);
|
||||
bgfx::ProgramHandle loadProgram(const char* _vsName, const char* _fsName);
|
||||
|
||||
///
|
||||
bgfx::TextureHandle loadTexture(const char* _name, uint32_t _flags = BGFX_TEXTURE_NONE, uint8_t _skip = 0, bgfx::TextureInfo* _info = NULL);
|
||||
bgfx::TextureHandle loadTexture(const char* _name, uint32_t _flags = BGFX_TEXTURE_NONE, uint8_t _skip = 0, bgfx::TextureInfo* _info = NULL, bimg::Orientation::Enum* _orientation = NULL);
|
||||
|
||||
///
|
||||
bimg::ImageContainer* imageLoad(const char* _filePath, bgfx::TextureFormat::Enum _dstFormat);
|
||||
|
||||
@@ -205,6 +205,7 @@ struct View
|
||||
, m_angy(0.0f)
|
||||
, m_zoom(1.0f)
|
||||
, m_angle(0.0f)
|
||||
, m_orientation(0.0f)
|
||||
, m_filter(true)
|
||||
, m_fit(true)
|
||||
, m_alpha(false)
|
||||
@@ -401,6 +402,19 @@ struct View
|
||||
m_angle = 0.0f;
|
||||
}
|
||||
}
|
||||
else if (0 == bx::strCmp(_argv[1], "orientation") )
|
||||
{
|
||||
if (_argc >= 3)
|
||||
{
|
||||
float angle;
|
||||
bx::fromString(&angle, _argv[2]);
|
||||
m_orientation = bx::toRad(angle);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_orientation = 0.0f;
|
||||
}
|
||||
}
|
||||
else if (0 == bx::strCmp(_argv[1], "filter") )
|
||||
{
|
||||
if (_argc >= 3)
|
||||
@@ -588,6 +602,7 @@ struct View
|
||||
float m_angy;
|
||||
float m_zoom;
|
||||
float m_angle;
|
||||
float m_orientation;
|
||||
bool m_filter;
|
||||
bool m_fit;
|
||||
bool m_alpha;
|
||||
@@ -1423,6 +1438,7 @@ int _main_(int _argc, char** _argv)
|
||||
bx::FilePath fp = view.m_path;
|
||||
fp.join(view.m_fileList[view.m_fileIndex].c_str() );
|
||||
|
||||
bimg::Orientation::Enum orientation;
|
||||
texture = loadTexture(fp.get()
|
||||
, 0
|
||||
| BGFX_TEXTURE_U_CLAMP
|
||||
@@ -1430,8 +1446,18 @@ int _main_(int _argc, char** _argv)
|
||||
| BGFX_TEXTURE_W_CLAMP
|
||||
, 0
|
||||
, &view.m_info
|
||||
, &orientation
|
||||
);
|
||||
|
||||
switch (orientation)
|
||||
{
|
||||
default:
|
||||
case bimg::Orientation::R0: cmdExec("view orientation 0"); break;
|
||||
case bimg::Orientation::R90: cmdExec("view orientation -90"); break;
|
||||
case bimg::Orientation::R180: cmdExec("view orientation -180"); break;
|
||||
case bimg::Orientation::R270: cmdExec("view orientation -270"); break;
|
||||
}
|
||||
|
||||
std::string title;
|
||||
if (isValid(texture) )
|
||||
{
|
||||
@@ -1566,7 +1592,7 @@ int _main_(int _argc, char** _argv)
|
||||
);
|
||||
|
||||
float rotz[16];
|
||||
bx::mtxRotateZ(rotz, angle.getValue() );
|
||||
bx::mtxRotateZ(rotz, angle.getValue()+view.m_orientation);
|
||||
bgfx::setTransform(rotz);
|
||||
|
||||
float mtx[16];
|
||||
|
||||
Reference in New Issue
Block a user