summaryrefslogtreecommitdiffstatshomepage
path: root/src/osd/modules/render/bgfx/texture.cpp
diff options
context:
space:
mode:
author therealmogminer@gmail.com <therealmogminer@gmail.com>2016-02-18 15:57:34 +0100
committer therealmogminer@gmail.com <therealmogminer@gmail.com>2016-02-21 03:03:23 +0100
commit9a47a870df619656e9092f2f77622e84e640307a (patch)
treeb8640bf79ffb55d0c9ed6fc27bbd4ce16a5e1a2e /src/osd/modules/render/bgfx/texture.cpp
parentdadf8e7d79696996ab3ef840fe99a588ede538fa (diff)
First take on render API reorg, nw
Diffstat (limited to 'src/osd/modules/render/bgfx/texture.cpp')
-rw-r--r--src/osd/modules/render/bgfx/texture.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/osd/modules/render/bgfx/texture.cpp b/src/osd/modules/render/bgfx/texture.cpp
new file mode 100644
index 00000000000..bf2668bc68b
--- /dev/null
+++ b/src/osd/modules/render/bgfx/texture.cpp
@@ -0,0 +1,30 @@
+#include "emu.h"
+
+#include "texture.h"
+
+bgfx_texture::bgfx_texture(std::string name, bgfx::TextureFormat::Enum format, uint32_t width, uint32_t height, void* data, uint32_t flags)
+ : m_name(name)
+ , m_format(format)
+ , m_width(width)
+ , m_height(height)
+{
+ bgfx::TextureInfo info;
+ bgfx::calcTextureSize(info, width, height, 1, false, 1, format);
+ if (data != nullptr)
+ {
+ m_handle = bgfx::createTexture2D(width, height, 1, format, flags, bgfx::copy(data, info.storageSize));
+ }
+ else
+ {
+ m_handle = bgfx::createTexture2D(width, height, 1, format, flags);
+
+ const bgfx::Memory* memory = bgfx::alloc(info.storageSize);
+ memset(memory->data, 0, info.storageSize);
+ bgfx::updateTexture2D(m_handle, 0, 0, 0, width, height, memory, info.storageSize / height);
+ }
+}
+
+bgfx_texture::~bgfx_texture()
+{
+ bgfx::destroyTexture(m_handle);
+}