@@ -68,6 +68,12 @@ namespace oxygine
getStage()->addChild(DebugActor::instance);
}
+ void DebugActor::hide()
+ {
+ if (DebugActor::instance)
+ DebugActor::instance->detach();
+ }
+
void DebugActor::release()
{
instance = 0;
@@ -282,7 +288,7 @@ namespace oxygine
s << "update=" << getStage()->_statUpdate << "ms ";
s << "render=" << getStage()->_statRender << "ms ";
s << "textures=" << NativeTexture::created << " ";
- s << "\nlisteners=" << getStage()->getListenersCount() << "";
+ //s << "\nlisteners=" << getStage()->getListenersCount() << "";
if (!_debugText.empty())
@@ -22,6 +22,7 @@ namespace oxygine
static Resources* resSystem;
static void initialize();
static void show();
+ static void hide();
static void release();
static std::string getDefaultName() { return "debug_actor"; }
@@ -28,9 +28,6 @@ extern "C"
namespace oxygine
- typedef bool (*cbLoadImageFromBuffer)(MemoryTexture& mt, void* data, int nSize, bool premultiplied, TextureFormat format);
-
bool loadImageNotSupported(MemoryTexture& mt, void* data, int nSize, bool premultiplied, TextureFormat format)
@@ -494,6 +491,18 @@ namespace oxygine
#endif
+ void setJpegLoader(cbLoadImageFromBuffer cb)
+ _loadJpegImage = cb;
+ void setPngLoader(cbLoadImageFromBuffer cb)
+ _loadPngImage = cb;
bool loadPngImage(MemoryTexture& mt, void* pData, int nDatalen, bool premultiplied, TextureFormat format)
bool s = _loadPngImage(mt, pData, nDatalen, premultiplied, format);
@@ -57,4 +57,8 @@ namespace oxygine
size_t _offset;//buffer offset
std::vector<unsigned char> _buffer;
};
+ typedef bool (*cbLoadImageFromBuffer)(MemoryTexture& mt, void* data, int nSize, bool premultiplied, TextureFormat format);
+ void setJpegLoader(cbLoadImageFromBuffer);
+ void setPngLoader(cbLoadImageFromBuffer);
@@ -52,6 +52,15 @@ namespace oxygine
init(frames, columns, scaleFactor);
+ void ResAnim::init(const std::string& file, int columns, int rows, float scaleFactor)
+ file::buffer bf;
+ file::read(file.c_str(), bf);
+ MemoryTexture mt;
+ mt.init(bf, true);
+ init(&mt, columns, rows, scaleFactor);
void ResAnim::init(MemoryTexture* original, int columns, int rows, float scaleFactor)
_scaleFactor = scaleFactor;
@@ -20,6 +20,7 @@ namespace oxygine
ResAnim(Resource* atlas = 0);
~ResAnim();
+ void init(const std::string& file, int columns = 1, int rows = 1, float scaleFactor = 1.0f);
void init(MemoryTexture* original, int columns = 1, int rows = 1, float scaleFactor = 1.0f);
void init(animationFrames& frames, int columns, float scaleFactor = 1.0f, float appliedScale = 1.0f);
/**creates animation frames from NativeTexture*/
@@ -11,6 +11,7 @@
#include "core/Mem2Native.h"
#include "core/VideoDriver.h"
#include <stdint.h>
+#include "utils/stringUtils.h"
extern "C"
@@ -51,6 +52,15 @@ namespace oxygine
mt.init(ad.mt.lock().getRect(Rect(0, 0, w, h)));
ImageData image_data = mt.lock();
+#if 0
+ static int n = 0;
+ n++;
+ char name[255];
+ safe_sprintf(name, "test%d.tga", n);
+ saveImage(image_data, name);
+#endif
ad.texture->init(image_data, false);
ad.mt.unlock();
@@ -12,6 +12,7 @@ namespace oxygine
DECLARE_SMART(NativeTexture, spNativeTexture);
class ResFontBM: public ResFont
public:
@@ -22,8 +23,8 @@ namespace oxygine
ResFontBM();
~ResFontBM();
- /**use it only if you want create font without Resources*/
- void init(const char* fntPath, bool premultipliedAlpha = true);
+ /**loads "fnt" font from file, supported XML and text format*/
+ void init(const char* fntPath, bool premultipliedAlpha = false);
void cleanup();
@@ -1,6 +1,6 @@
#include "ImageUtils.h"
#include "core/ImageData.h"
+#include "MemoryTexture.h"
//#include "png.h"
@@ -16,8 +16,14 @@ extern "C"
- void saveImage(const ImageData& im, const char* path, const char* format)
+ void saveImage(const ImageData& im_, const char* path, const char* format)
+ MemoryTexture src;
+ src.init(im_);
+ MemoryTexture dest;
+ src.convert(dest, TF_B8G8R8A8);
+ const ImageData& im = dest.lock();
file::handle h = file::open(path, "wb");
file::autoClose ac(h);
char header[18] = { 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };