Jump to content
whiterabbit

Write Buffer to file? (Taking a screenshot)

Recommended Posts

I've managed to get a Buffer (and Texture) filled with the current screen. I want to write it to a file, so my game will have a builtin screenshot feature.

Leadwerks 2 apparently had a function SaveBuffer which would do exactly what I want, but as far as I can tell it doesn't exist or has been renamed to something else.

So, before I try to manually write the bytes to a file, does anyone know if there is a current function for writing a buffer to an image file? (Or maybe there is complete function for taking a screenshot that I don't know about?)

 

EDIT: How do I even get individual values out of a buffer?

Share this post


Link to post

I've been using C++, so I use this:

if (window->KeyHit(Key::F12)) {

context->Screenshot();

}

 

I'm sure lua has something similar

Share this post


Link to post

yes it does:

if self.window:KeyHit(Key.P) then self.context:Screenshot() end

which puts an image into "C:\Users\XXXX\AppData\Local/xProjectNamex/Screenshots/screenshot1.tga" on windows.

 

I preferred the old LE2 way where you had control over where the file was created.

 

EDIT-- ooh ok just saw that you can specify the file path and name:

if self.window:KeyHit(Key.P) then self.context:Screenshot("C:/example.tga") end

 

excellent!

Share this post


Link to post

Strange that it is not documented, maybe there is a place where I can watch for other undocumented Lua functions?

Share this post


Link to post

Strange that it is not documented, maybe there is a place where I can watch for other undocumented Lua functions?

 

Inside the C++ header files biggrin.pngtongue.png

Share this post


Link to post

Maybe anyone could post a whole list of these functions?

What would be the point? If you have the c++ version you have the header files, if you dont then you cant use them...

Share this post


Link to post

Because digging through the source is not the same as documentation.

 

He wants a list of functions (methods really) from the headder files - how is that any different than "digging through the source"

Share this post


Link to post

He wants a list of functions (methods really) from the headder files - how is that any different than "digging through the source"

What would be the point? If you have the c++ version you have the header files, if you dont then you cant use them...

Not everyone has the c++ version. While its not exactly the most efficient way to have documentation - having a list of available commands that show the parameters is useful. It looks like Josh has commented the ones that were exposed to lua.

 

Another method I have done is to perform a dump of all globals in LE's lua implementation that show at least the available lua commands for LE classes.

globals.txt

Share this post


Link to post

My point was ; not all methods are mapped to lua

And my point and others is: majority of them are exposed to lua and if we can't get official documentation then I see no reason why it hurts to have these posted. I personally would not have been able to do any of the shader effects I have done in lua without shadmar posting the c++ info about buffers here: http://www.leadwerks.com/werkspace/topic/10171-buffer-commands-exposed-to-lua-with-documentation/#entry75328

 

Granted all of this would be moot if the official documentation was completed.

Share this post


Link to post

Thanks very much everyone, context:Screenshot() works perfect, just have to make sure the filename is named with .tga extension.

 

UPDATE: If you call Screenshot() with no filename and you are using Steam, it puts it in your Steam screenshots folder (awesome) !

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...