Aaron Symons Posted May 21, 2016 Share Posted May 21, 2016 Hi guys, I was just wondering if there's a way to draw/play an animated gif image on screen in C++ using Leadwerks? Many thanks 1 Quote Win7 64-bit | Intel i7-3770 3.40GHz | NVIDIA GeForce GTX 660 Link to comment Share on other sites More sharing options...
mbarhon Posted June 22, 2016 Share Posted June 22, 2016 Hi, i like your idea. The way is maybe create your own loader/class. For every frame of GIF create texture using function Texture:Create and fill data with Texture:SetPixel (look for it in API) Description of GIF format will be on internet or look for some GIF loader for pure opengl, it will be similar i guess Quote Link to comment Share on other sites More sharing options...
Aaron Symons Posted July 1, 2016 Author Share Posted July 1, 2016 Hi mbarhon, Thank you for the guidance. I'll try your suggestions when I have time and update the thread accordingly. Many thanks Quote Win7 64-bit | Intel i7-3770 3.40GHz | NVIDIA GeForce GTX 660 Link to comment Share on other sites More sharing options...
Aaron Symons Posted September 12, 2016 Author Share Posted September 12, 2016 I thought I'd update this thread, seeing as I said I would! During my research I came across issues with GIF licensing, and why the GNU - and others - pretty much refuse to even deal with GIF now. However, I came across Animated-PNG which is an extension to the PNG format developed by Mozilla! I think APNG is a viable substitute if we want to integrate animated images in Leadwerks. I have the APNG add-on for GIMP, and now I'm researching how to read the file's frames in C++ and draw them to the screen using OpenGL. I haven't come across much information yet, but I think it's worth the effort. 1 Quote Win7 64-bit | Intel i7-3770 3.40GHz | NVIDIA GeForce GTX 660 Link to comment Share on other sites More sharing options...
Dan22 Posted September 13, 2016 Share Posted September 13, 2016 My game would benefit so much from animated textures, although its in Lua Quote Link to comment Share on other sites More sharing options...
gamecreator Posted September 13, 2016 Share Posted September 13, 2016 Just want to make sure you guys saw this thread: http://www.leadwerks.com/werkspace/topic/14677-lua-animated-sprite-sheet/ Quote Link to comment Share on other sites More sharing options...
martyj Posted September 13, 2016 Share Posted September 13, 2016 I wonder if Josh's new UI stuff would work for this. I believe he is adding draw functions on the Window itself. Quote Link to comment Share on other sites More sharing options...
Aaron Symons Posted September 14, 2016 Author Share Posted September 14, 2016 [i know this post could have been much better in explanation, but I'm tired and need sleep ] Okay guys, another update on implementing an animated image file (now A-PNG) in Leadwerks. It's pretty simple: implement the TinyImageLoader ! Use that library to read the APNG into a TIL::Image - by default it will give you image frame count - then, just use a Leadwerks::Texture to draw to the context, setting the texture's pixels to the appropriate TIL::Image frame's pixels based on a simple interval timer - using TIL to get the pixel data (and manually converting it to a char* before passing to the Leadwerks::Texture). There are a couple of good examples included with TinyImageLoader SDK. I just referenced the first example, and thought how I could create an actual Leadwerks::Texture from the information supplied to me by TinyImageLoader. I now have an Animated-PNG image that renders to the screen and auto-updates the frame based on a set interval. I was going to have the APNG class implement Leadwerks::Texture, but I don't feel like implementing the extra 30+ virtual methods right now! *sad face* That's all for now, as I feel it could be simple enough for others to implement - if not a good test of some basic C++ to C/C++1 implementation abilities. However, if anyone would like me to post a code example I will! Many thanks! 1 The original code was written in C and then rewritten in C++ for TinymageLoader, though some C-style syntax does still appear. 2 Quote Win7 64-bit | Intel i7-3770 3.40GHz | NVIDIA GeForce GTX 660 Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.