diff options
author | Pixel <pixel@nobis-crew.org> | 2009-05-27 11:44:52 -0700 |
---|---|---|
committer | Pixel <pixel@nobis-crew.org> | 2009-05-27 11:44:52 -0700 |
commit | fd9cef83e6da75079fa3f0148920752c4434fbd8 (patch) | |
tree | ec27bc12c3b0934c2d8c88eb0e1449da3f884a3a /src | |
parent | 088199a6451cf694cd0af688975b9e0ee33f6abc (diff) |
Enabling full alpha blending support.
Diffstat (limited to 'src')
-rw-r--r-- | src/plugin-luaosmesa.cc | 40 |
1 files changed, 27 insertions, 13 deletions
diff --git a/src/plugin-luaosmesa.cc b/src/plugin-luaosmesa.cc index daf0fd4..a594e0e 100644 --- a/src/plugin-luaosmesa.cc +++ b/src/plugin-luaosmesa.cc @@ -1,5 +1,3 @@ -#include <pthread.h> - #include <GL/gl.h> #include <GL/glu.h> #include <GL/osmesa.h> @@ -92,14 +90,19 @@ void flip_scene(scene_t * scene, const char * buffer, int width, int height, boo glFinish(); Magick::Image i(width, height, "BGRA", Magick::CharPixel, buffer); + i.matte(true); i.flip(); i.animationDelay(6); - i.opacity(0); + if (scene->scene.size() >= 1) + i.opacity(255); + if (scene->scene.size() == 1) + scene->scene.begin()->opacity(255); if (upscale) { - i.resize(Magick::Geometry(width / 2, height / 2)); +// i.resize(Magick::Geometry(width / 2, height / 2)); + i.sample(Magick::Geometry(width / 2, height / 2)); } - + scene->scene.push_back(i); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); } @@ -108,22 +111,30 @@ void * dump_scene_threaded(void * arg) { scene_t * scene = (scene_t *) arg; char fname[2049]; - writeImages(scene->scene.begin(), scene->scene.end(), scene->tmp_filename.to_charp()); + if (scene->scene.size() == 1) { + scene->scene.begin()->write(scene->tmp_filename.to_charp()); + } else { + writeImages(scene->scene.begin(), scene->scene.end(), scene->tmp_filename.to_charp()); + } unlink(scene->filename.to_charp()); rename(scene->tmp_filename.to_charp(), scene->filename.to_charp()); delete scene; pthread_exit(0); } -void dump_scene(scene_t * scene, const String & filename, Handle * out, const char * buffer, int width, int height, bool upscale) { +void dump_scene(scene_t * scene, const String & filename, Handle * out, const char * buffer, int width, int height, bool upscale, const String & format) { if (scene->scene.begin() == scene->scene.end()) flip_scene(scene, buffer, width, height, upscale); if (out) { Magick::Blob b; - scene->scene.begin()->magick("JPEG"); + scene->scene.begin()->magick(format.to_charp()); scene->scene.begin()->quality(95); - writeImages(scene->scene.begin(), scene->scene.end(), &b); + if (scene->scene.size() == 1) { + scene->scene.begin()->write(&b); + } else { + writeImages(scene->scene.begin(), scene->scene.end(), &b); + } out->write(b.data(), b.length()); delete scene; } else { @@ -160,7 +171,7 @@ enum plugin_osmesa_functions_t { struct lua_functypes_t plugin_osmesa_functions[] = { { PLUGIN_OSMESA_INITOSMESA, "InitOSMesa", 3, 4, { BLUA_USERDATA | BLUA_NIL, BLUA_NUMBER, BLUA_NUMBER, BLUA_BOOLEAN } }, { PLUGIN_OSMESA_FLIPSCENE, "FlipScene", 1, 1, { BLUA_USERDATA } }, - { PLUGIN_OSMESA_DUMPSCENE, "DumpScene", 2, 2, { BLUA_USERDATA, BLUA_STRING | BLUA_OBJECT } }, + { PLUGIN_OSMESA_DUMPSCENE, "DumpScene", 2, 3, { BLUA_USERDATA, BLUA_STRING | BLUA_OBJECT, BLUA_STRING } }, { PLUGIN_OSMESA_LOADTEX, "LoadTex", 1, 1, { BLUA_STRING } }, { -1, 0, 0, 0, 0 } }; @@ -219,10 +230,13 @@ int sLua_plugin_osmesa::plugin_osmesa_proceed_statics(Lua * L, int n, int caller case PLUGIN_OSMESA_DUMPSCENE: if (L->isstring(2)) { filename = L->tostring(2); - dump_scene((scene_t *) L->touserdata(1), filename, 0, (char *) buffer, width, height, upscale); + dump_scene((scene_t *) L->touserdata(1), filename, 0, (char *) buffer, width, height, upscale, ""); } else { - Handle * t = (Handle *) LuaObject::getme(L, 2); - dump_scene((scene_t *) L->touserdata(1), "", t, (char *) buffer, width, height, upscale); + Handle * t = lua_recast<Handle>(L, 2); + String format = "JPEG"; + if (n == 3) + format = L->tostring(3); + dump_scene((scene_t *) L->touserdata(1), "", t, (char *) buffer, width, height, upscale, format); } break; case PLUGIN_OSMESA_LOADTEX: |