Jump to content

Write Buffer to file? (Taking a screenshot)


whiterabbit
 Share

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?

Link to comment
Share on other sites

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!

  • Upvote 1

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

Link to comment
Share on other sites

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...

System:

Linux Mint 17 ( = Ubuntu 14.04 with cinnamon desktop ) Ubuntu 14.04, AMD HD 6850, i5 2500k

Link to comment
Share on other sites

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"

System:

Linux Mint 17 ( = Ubuntu 14.04 with cinnamon desktop ) Ubuntu 14.04, AMD HD 6850, i5 2500k

Link to comment
Share on other sites

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

  • Upvote 2

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

Link to comment
Share on other sites

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.

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

Link to comment
Share on other sites

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.

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.

 Share

×
×
  • Create New...